Allow using classic gui.png texture.

This commit is contained in:
UnknownShadow200 2016-01-02 23:49:05 +11:00
parent 36115c7b80
commit 784bcd73b4
9 changed files with 60 additions and 12 deletions

View file

@ -30,6 +30,12 @@ namespace ClassicalSharp {
g.RefreshHud();
} ),
Make( -140, 0, "Use classic gui", OnWidgetClick,
g => g.UseClassicGui ? "yes" : "no",
(g, v) => { g.UseClassicGui = v == "yes";
Options.Set( OptionsKey.UseClassicGui, v == "yes" );
} ),
// Column 2
Make( 140, -150, "Clickable chat", OnWidgetClick,
g => g.ClickableChat ? "yes" : "no",
@ -70,6 +76,7 @@ namespace ClassicalSharp {
new BooleanValidator(),
new BooleanValidator(),
new RealValidator( 0.25f, 5f ),
new BooleanValidator(),
new BooleanValidator(),
new RealValidator( 0.25f, 5f ),

View file

@ -52,9 +52,13 @@ namespace ClassicalSharp {
}
void RenderHotbar() {
int texId = game.UseClassicGui ? game.GuiClassicTexId : game.GuiTexId;
backTex.ID = texId;
backTex.Render( graphicsApi );
int i = game.Inventory.HeldBlockIndex;
int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2);
selTex.ID = texId;
selTex.X1 = (int)(x - selBlockSize / 2);
selTex.Render( graphicsApi );
}
@ -70,7 +74,7 @@ namespace ClassicalSharp {
void MakeBackgroundTexture() {
TextureRec rec = new TextureRec( 0, 0, 182/256f, 22/256f );
backTex = new Texture( game.GuiTexId, X, Y, Width, Height, rec );
backTex = new Texture( 0, X, Y, Width, Height, rec );
}
void MakeSelectionTexture() {
@ -78,7 +82,7 @@ namespace ClassicalSharp {
int vSize = (int)Math.Floor( 23 * 2 * game.GuiScale );
int y = game.Height - vSize;
TextureRec rec = new TextureRec( 0, 22/256f, 24/256f, 24/256f );
selTex = new Texture( game.GuiTexId, 0, y, hSize, vSize, rec );
selTex = new Texture( 0, 0, y, hSize, vSize, rec );
}
public override bool HandlesKeyDown( Key key ) {

View file

@ -62,9 +62,11 @@ namespace ClassicalSharp {
return;
Texture backTex = Active ? selectedTex : shadowTex;
if( Disabled ) backTex = disdabledTex;
backTex.ID = game.GuiTexId;
backTex.ID = game.UseClassicGui ? game.GuiClassicTexId : game.GuiTexId;
backTex.X1 = X; backTex.Y1 = Y;
backTex.Width = Width; backTex.Height = Height;
backTex.Render( graphicsApi );
FastColour col = Active ? FastColour.White : new FastColour( 200, 200, 200 );
if( Disabled ) col = new FastColour( 150, 150, 150 );

View file

@ -125,6 +125,8 @@ namespace ClassicalSharp {
/// <summary> How sensitive the client is to changes in the player's mouse position. </summary>
public int MouseSensitivity = 30;
public bool UseClassicGui = false;
public int ChatLines = 12;
public bool ClickableChat = false, HideGui = false, ShowFPS = true;
internal float HudScale = 1.0f, ChatScale = 1.0f;
@ -134,7 +136,7 @@ namespace ClassicalSharp {
public Vector3 CurrentCameraPos;
public Animations Animations;
internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId;
internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId, GuiClassicTexId;
internal bool screenshotRequested;
internal List<WarningScreen> WarningScreens = new List<WarningScreen>();
internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" );

View file

@ -53,6 +53,7 @@ namespace ClassicalSharp {
ChatScale = Options.GetFloat( OptionsKey.ChatScale, 0.35f, 5f, 1f );
defaultIb = Graphics.MakeDefaultIb();
MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );
UseClassicGui = Options.GetBool( OptionsKey.UseClassicGui, false );
BlockInfo = new BlockInfo();
BlockInfo.Init();
ChatLines = Options.GetInt( OptionsKey.ChatLines, 1, 30, 12 );
@ -444,6 +445,7 @@ namespace ClassicalSharp {
Graphics.DeleteTexture( ref RainTexId );
Graphics.DeleteTexture( ref SnowTexId );
Graphics.DeleteTexture( ref GuiTexId );
Graphics.DeleteTexture( ref GuiClassicTexId );
if( Options.HasChanged )
Options.Save();

View file

@ -75,6 +75,8 @@ namespace ClassicalSharp.TexturePack {
UpdateTexture( ref game.SnowTexId, stream, false ); break;
case "gui.png":
UpdateTexture( ref game.GuiTexId, stream, false ); break;
case "gui_classic.png":
UpdateTexture( ref game.GuiClassicTexId, stream, false ); break;
case "animations.png":
case "animation.png":
game.Animations.SetAtlas( new Bitmap( stream ) ); break;

View file

@ -37,6 +37,7 @@ namespace ClassicalSharp {
public const string InvertMouse = "invertmouse";
public const string NoclipSlide = "noclipslide";
public const string CameraClipping = "cameraclipping";
public const string UseClassicGui = "useclassicgui";
}
// TODO: implement this

View file

@ -1,6 +1,7 @@
using System;
using System.IO;
using ClassicalSharp.Network;
using ClassicalSharp.TexturePack;
namespace Launcher2 {
@ -21,7 +22,7 @@ namespace Launcher2 {
const string pngGuiPatchUri = "http://static.classicube.net/gui.png";
const string digSoundsUri = "http://s3.amazonaws.com/MinecraftResources/sound3/dig/";
const string altDigSoundsUri = "http://s3.amazonaws.com/MinecraftResources/sound3/random/";
const string stepSoundsUri = "http://s3.amazonaws.com/MinecraftResources/newsound/step/";
const string stepSoundsUri = "http://s3.amazonaws.com/MinecraftResources/newsound/step/";
const string altStepSoundsUri = "http://s3.amazonaws.com/MinecraftResources/sound3/step/";
const string musicUri = "http://s3.amazonaws.com/MinecraftResources/music/";
const string newMusicUri = "http://s3.amazonaws.com/MinecraftResources/newmusic/";
@ -34,7 +35,7 @@ namespace Launcher2 {
digPatcher.FetchFiles( digSoundsUri, altDigSoundsUri, this );
stepPatcher = new SoundPatcher( stepSounds, "step_",
"classic jar", stepPath );
stepPatcher.FetchFiles( stepSoundsUri, altStepSoundsUri, this );
stepPatcher.FetchFiles( stepSoundsUri, altStepSoundsUri, this );
if( !defaultZipExists ) {
downloader.DownloadData( jarClassicUri, false, "classic_jar" );
downloader.DownloadData( jar162Uri, false, "162_jar" );
@ -116,6 +117,8 @@ namespace Launcher2 {
string texDir = Path.Combine( Program.AppDirectory, "texpacks" );
string zipPath = Path.Combine( texDir, "default.zip" );
defaultZipExists = File.Exists( zipPath );
if( defaultZipExists )
CheckClassicGuiPng( zipPath );
if( !defaultZipExists ) {
// classic.jar + 1.6.2.jar + terrain-patch.png + gui.png
DownloadSize += (291 + 4621 + 7 + 21) / 1024f;
@ -148,12 +151,32 @@ namespace Launcher2 {
CurrentResource, ResourcesCount );
}
bool classicGuiPngExists = false;
void CheckClassicGuiPng( string path ) {
ZipReader reader = new ZipReader();
reader.ShouldProcessZipEntry = ShouldProcessZipEntry;
reader.ProcessZipEntry = ProcessZipEntry;
using( Stream src = new FileStream( path, FileMode.Open, FileAccess.Read ) )
reader.Extract( src );
if( !classicGuiPngExists )
defaultZipExists = false;
}
bool ShouldProcessZipEntry( string filename ) {
if( filename == "gui_classic.png" )
classicGuiPngExists = true;
return false;
}
void ProcessZipEntry( string filename, byte[] data, ZipEntry entry ) { }
bool CheckMusicFiles( Action<string> setStatus ) {
for( int i = 0; i < musicFiles.Length; i++ ) {
string next = i < musicFiles.Length - 1 ?
musicFiles[i + 1] : "dig_cloth1";
string name = musicFiles[i];
byte[] data = null;
byte[] data = null;
if( !DownloadItem( name, name, next,
ref data, setStatus ) )
return false;
@ -177,13 +200,13 @@ namespace Launcher2 {
string digPath, stepPath;
string[] digSounds = new [] { "Acloth1", "Acloth2", "Acloth3", "Acloth4", "Bglass1",
"Bglass2", "Bglass3", "Agrass1", "Agrass2", "Agrass3", "Agrass4", "Agravel1", "Agravel2",
"Agravel3", "Agravel4", "Asand1", "Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3",
"Bglass2", "Bglass3", "Agrass1", "Agrass2", "Agrass3", "Agrass4", "Agravel1", "Agravel2",
"Agravel3", "Agravel4", "Asand1", "Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3",
"Asnow4", "Astone1", "Astone2", "Astone3", "Astone4", "Awood1", "Awood2", "Awood3", "Awood4" };
string[] stepSounds = new [] { "Acloth1", "Acloth2", "Acloth3", "Acloth4", "Bgrass1",
"Bgrass2", "Bgrass3", "Bgrass4", "Agravel1", "Agravel2", "Agravel3", "Agravel4", "Asand1",
"Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3", "Asnow4", "Astone1", "Astone2",
"Bgrass2", "Bgrass3", "Bgrass4", "Agravel1", "Agravel2", "Agravel3", "Agravel4", "Asand1",
"Asand2", "Asand3", "Asand4", "Asnow1", "Asnow2", "Asnow3", "Asnow4", "Astone1", "Astone2",
"Astone3", "Astone4", "Awood1", "Awood2", "Awood3", "Awood4" };
string[] musicFiles = new [] { "calm1", "calm2", "calm3", "hal1", "hal2", "hal3", "hal4" };

View file

@ -50,13 +50,18 @@ namespace Launcher2 {
Bitmap animBitmap;
bool ShouldProcessZipEntry_Classic( string filename ) {
return filename.StartsWith( "mob" ) || (filename.IndexOf( '/' ) < 0);
return filename == "gui/gui.png" || filename.StartsWith( "mob" ) || filename.IndexOf( '/' ) < 0;
}
void ProcessZipEntry_Classic( string filename, byte[] data, ZipEntry entry ) {
if( writer.entries == null )
writer.entries = new ZipEntry[reader.entries.Length];
if( filename != "terrain.png" ) {
int lastSlash = filename.LastIndexOf( '/' );
if( lastSlash >= 0 )
entry.Filename = filename.Substring( lastSlash + 1 );
if( entry.Filename == "gui.png" )
entry.Filename = "gui_classic.png";
writer.WriteZipEntry( entry, data );
return;
}