diff --git a/ClassicalSharp/2D/IsometricBlockDrawer.cs b/ClassicalSharp/2D/IsometricBlockDrawer.cs index 86457ca53..2d7fb43c9 100644 --- a/ClassicalSharp/2D/IsometricBlockDrawer.cs +++ b/ClassicalSharp/2D/IsometricBlockDrawer.cs @@ -62,7 +62,6 @@ namespace ClassicalSharp { if( index == 0 ) return; if( atlas.TexIds[texIndex] != lastTexId ) { lastTexId = atlas.TexIds[texIndex]; - Console.WriteLine( "BIND: " + texIndex ); api.BindTexture( lastTexId ); } for( int i = 0; i < index; i++ ) @@ -149,7 +148,6 @@ namespace ClassicalSharp { index = 0; } lastTexId = texId; - Console.WriteLine( "BIND" + texIndex ); api.BindTexture( texId ); } diff --git a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs index 3709c2120..01c942569 100644 --- a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs +++ b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs @@ -77,8 +77,8 @@ namespace ClassicalSharp { } public override void OnResize( int oldWidth, int oldHeight, int width, int height ) { - blockSize = (int)(50 * Math.Sqrt(game.GuiScale)); - selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale)); + blockSize = (int)(50 * Math.Sqrt(game.GuiInventoryScale)); + selBlockExpand = (float)(25 * Math.Sqrt(game.GuiInventoryScale)); startX = game.Width / 2 - (blockSize * blocksPerRow) / 2; startY = game.Height / 2 - (maxRows * blockSize) / 2; @@ -87,8 +87,8 @@ namespace ClassicalSharp { } public override void Init() { - blockSize = (int)(50 * Math.Sqrt(game.GuiScale)); - selBlockExpand = (float)(25 * Math.Sqrt(game.GuiScale)); + blockSize = (int)(50 * Math.Sqrt(game.GuiInventoryScale)); + selBlockExpand = (float)(25 * Math.Sqrt(game.GuiInventoryScale)); game.Events.BlockPermissionsChanged += BlockPermissionsChanged; RecreateBlockTable(); diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index 67a11d694..33063996b 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -105,7 +105,7 @@ namespace ClassicalSharp { fontSize = (int)(14 * game.GuiChatScale); Utils.Clamp( ref fontSize, 8, 60 ); announcementFont = new Font( "Arial", fontSize ); - blockSize = (int)(23 * 2 * game.GuiScale); + blockSize = (int)(23 * 2 * game.GuiHotbarScale); textInput = new TextInputWidget( game, chatFont, chatInputFont ); textInput.YOffset = blockSize + 5; @@ -213,7 +213,7 @@ namespace ClassicalSharp { public override void OnResize( int oldWidth, int oldHeight, int width, int height ) { announcementTex.X1 += (width - oldWidth) / 2; announcementTex.Y1 += (height - oldHeight) / 2; - blockSize = (int)(23 * 2 * game.GuiScale); + blockSize = (int)(23 * 2 * game.GuiHotbarScale); textInput.YOffset = blockSize + 5; bottomRight.YOffset = blockSize * 3 / 2; diff --git a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs index 203dbb7a7..565fa8fef 100644 --- a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs @@ -23,58 +23,47 @@ namespace ClassicalSharp { g => g.ShowFPS ? "yes" : "no", (g, v) => g.ShowFPS = v == "yes" ), - Make( -140, -50, "Hud scale", OnWidgetClick, - g => g.HudScale.ToString(), - (g, v) => { g.HudScale = Single.Parse( v ); - Options.Set( OptionsKey.HudScale, v ); + Make( -140, -50, "Hotbar scale", OnWidgetClick, + g => g.HotbarScale.ToString(), + (g, v) => { g.HotbarScale = Single.Parse( v ); + Options.Set( OptionsKey.HotbarScale, v ); g.RefreshHud(); } ), - Make( -140, 0, "Tab auto-complete", OnWidgetClick, + Make( -140, 0, "Inventory scale", OnWidgetClick, + g => g.InventoryScale.ToString(), + (g, v) => { g.InventoryScale = Single.Parse( v ); + Options.Set( OptionsKey.InventoryScale, v ); + g.RefreshHud(); + } ), + + // Column 2 + Make( 140, -150, "Tab auto-complete", OnWidgetClick, g => g.TabAutocomplete ? "yes" : "no", (g, v) => { g.TabAutocomplete = v == "yes"; Options.Set( OptionsKey.TabAutocomplete, v == "yes" ); } ), - // Column 2 - Make( 140, -150, "Clickable chat", OnWidgetClick, + Make( 140, -100, "Clickable chat", OnWidgetClick, g => g.ClickableChat ? "yes" : "no", (g, v) => { g.ClickableChat = v == "yes"; Options.Set( OptionsKey.ClickableChat, v == "yes" ); } ), - Make( 140, -100, "Chat scale", OnWidgetClick, + Make( 140, -50, "Chat scale", OnWidgetClick, g => g.ChatScale.ToString(), (g, v) => { g.ChatScale = Single.Parse( v ); Options.Set( OptionsKey.ChatScale, v ); g.RefreshHud(); } ), - Make( 140, -50, "Chat lines", OnWidgetClick, + Make( 140, 0, "Chat lines", OnWidgetClick, g => g.ChatLines.ToString(), (g, v) => { g.ChatLines = Int32.Parse( v ); Options.Set( OptionsKey.ChatLines, v ); g.RefreshHud(); } ), - Make( 140, 0, "Arial chat font", OnWidgetClick, - g => g.Drawer2D.UseBitmappedChat ? "no" : "yes", - (g, v) => { - g.Drawer2D.UseBitmappedChat = v == "no"; - Options.Set( OptionsKey.ArialChatFont, v == "yes" ); - game.Events.RaiseChatFontChanged(); - - if( inputWidget != null ) { - inputWidget.Dispose(); inputWidget = null; - } - if( descWidget != null ) { - descWidget.Dispose(); descWidget = null; - } - - g.RefreshHud(); - Recreate(); - } ), - MakeBack( false, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), null, @@ -83,7 +72,7 @@ namespace ClassicalSharp { new BooleanValidator(), new BooleanValidator(), new RealValidator( 0.25f, 5f ), - new BooleanValidator(), + new RealValidator( 0.25f, 5f ), new BooleanValidator(), new RealValidator( 0.25f, 5f ), diff --git a/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs b/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs index 883578b8d..a2d86e08e 100644 --- a/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs @@ -21,7 +21,7 @@ namespace ClassicalSharp { (g, v) => { g.SimpleArmsAnim = v == "yes"; Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }), - Make( -140, -50, "Use classic gui", OnWidgetClick, + Make( -140, -50, "Classic gui textures", OnWidgetClick, g => g.UseClassicGui ? "yes" : "no", (g, v) => { g.UseClassicGui = v == "yes"; Options.Set( OptionsKey.UseClassicGui, v == "yes" ); @@ -33,6 +33,24 @@ namespace ClassicalSharp { Options.Set( OptionsKey.UseClassicTabList, v == "yes" ); } ), + Make( -140, 50, "Arial chat font", OnWidgetClick, + g => g.Drawer2D.UseBitmappedChat ? "no" : "yes", + (g, v) => { + g.Drawer2D.UseBitmappedChat = v == "no"; + Options.Set( OptionsKey.ArialChatFont, v == "yes" ); + game.Events.RaiseChatFontChanged(); + + if( inputWidget != null ) { + inputWidget.Dispose(); inputWidget = null; + } + if( descWidget != null ) { + descWidget.Dispose(); descWidget = null; + } + + g.RefreshHud(); + Recreate(); + } ), + // Column 2 Make( 140, -100, "Allow custom blocks", OnWidgetClick, g => g.AllowCustomBlocks ? "yes" : "no", @@ -61,6 +79,7 @@ namespace ClassicalSharp { new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), + new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs index 338c46747..c6552ad5a 100644 --- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs +++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs @@ -19,7 +19,7 @@ namespace ClassicalSharp { float barXOffset, borderSize; public override void Init() { - float scale = 2 * game.GuiScale; + float scale = 2 * game.GuiHotbarScale; selBlockSize = (float)Math.Ceiling( 24 * scale ); barHeight = (int)(22 * scale); Width = (int)(182 * scale); @@ -45,7 +45,7 @@ namespace ClassicalSharp { int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2); int y = (int)(game.Height - barHeight / 2); - float scale = (elemSize - 8) / 2f; + float scale = (elemSize * 14/16f) / 2f; IsometricBlockDrawer.Draw( game, block, scale, x, y ); } RenderSelected(); @@ -84,7 +84,7 @@ namespace ClassicalSharp { void MakeSelectionTexture() { int hSize = (int)selBlockSize; - int vSize = (int)Math.Floor( 23 * 2 * game.GuiScale ); + int vSize = (int)Math.Floor( 23 * 2 * game.GuiHotbarScale ); int y = game.Height - vSize; TextureRec rec = new TextureRec( 0, 22/256f, 24/256f, 24/256f ); selTex = new Texture( 0, 0, y, hSize, vSize, rec ); diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj index 5b46a490d..873caaca3 100644 --- a/ClassicalSharp/ClassicalSharp.csproj +++ b/ClassicalSharp/ClassicalSharp.csproj @@ -4,7 +4,7 @@ {BEB1C785-5CAD-48FF-A886-876BF0A318D4} Debug AnyCPU - WinExe + Exe ClassicalSharp ClassicalSharp v2.0 diff --git a/ClassicalSharp/Game/Game.Properties.cs b/ClassicalSharp/Game/Game.Properties.cs index 258dd235c..7679dcfa1 100644 --- a/ClassicalSharp/Game/Game.Properties.cs +++ b/ClassicalSharp/Game/Game.Properties.cs @@ -133,7 +133,7 @@ namespace ClassicalSharp { public int ChatLines = 12; public bool ClickableChat = false, HideGui = false, ShowFPS = true; - internal float HudScale = 1.0f, ChatScale = 1.0f; + internal float HotbarScale = 1.0f, ChatScale = 1.0f, InventoryScale = 1.0f; public bool ViewBobbing, ShowBlockInHand; public bool UseSound, UseMusic, LiquidsBreakable; @@ -145,13 +145,23 @@ namespace ClassicalSharp { internal List WarningScreens = new List(); internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" ); - /// Calculates the amount that 2D widgets should be scaled by when rendered. + /// Calculates the amount that the hotbar widget should be scaled by when rendered. /// Affected by both the current resolution of the window, as well as the - /// scaling specified by the user (field HudScale). - public float GuiScale { + /// scaling specified by the user (field HotbarScale). + public float GuiHotbarScale { get { float scaleX = Width / 640f, scaleY = Height / 480f; - return Math.Min( scaleX, scaleY ) * HudScale; + return Math.Min( scaleX, scaleY ) * HotbarScale; + } + } + + /// Calculates the amount that the block inventory menu should be scaled by when rendered. + /// Affected by both the current resolution of the window, as well as the + /// scaling specified by the user (field InventoryScale). + public float GuiInventoryScale { + get { + float scaleX = Width / 640f, scaleY = Height / 480f; + return Math.Min( scaleX, scaleY ) * InventoryScale; } } diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index b6af004ed..a97ce9ae1 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -53,7 +53,8 @@ namespace ClassicalSharp { InputHandler = new InputHandler( this ); Chat = new Chat( this ); ParticleManager = new ParticleManager( this ); - HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 5f, 1f ); + InventoryScale = Options.GetFloat( OptionsKey.InventoryScale, 0.25f, 5f, 1f ); + HotbarScale = Options.GetFloat( OptionsKey.HotbarScale, 0.25f, 5f, 1f ); ChatScale = Options.GetFloat( OptionsKey.ChatScale, 0.35f, 5f, 1f ); defaultIb = Graphics.MakeDefaultIb(); MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 ); diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index 2b96bd988..add4827a0 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -10,35 +10,37 @@ namespace ClassicalSharp { public static class OptionsKey { public const string ViewDist = "viewdist"; - public const string HudScale = "hudscale"; - public const string ChatScale = "chatscale"; - public const string Sensitivity = "mousesensitivity"; - public const string Speed = "speedmultiplier"; - public const string ChatLines = "chatlines"; - public const string ClickableChat = "chatclickable"; - public const string ArialChatFont = "arialchatfont"; public const string DefaultTexturePack = "defaulttexpack"; - public const string SingleplayerPhysics = "singleplayerphysics"; - public const string ShowBlockInHand = "blockinhand"; + public const string SingleplayerPhysics = "singleplayerphysics"; public const string UseMusic = "usemusic"; - public const string UseSound = "usesound"; - public const string HacksEnabled = "hacksenabled"; + public const string UseSound = "usesound"; public const string NamesMode = "namesmode"; - + public const string InvertMouse = "invertmouse"; + public const string Sensitivity = "mousesensitivity"; public const string MouseLeft = "mouseleft"; public const string MouseMiddle = "mousemiddle"; public const string MouseRight = "mouseright"; public const string FpsLimit = "fpslimit"; public const string AutoCloseLauncher = "autocloselauncher"; public const string ViewBobbing = "viewbobbing"; - public const string FieldOfView = "fov"; + + public const string HacksEnabled = "hacksenabled"; + public const string FieldOfView = "fov"; + public const string Speed = "speedmultiplier"; public const string LiquidsBreakable = "liquidsbreakable"; - public const string PushbackPlacing = "pushbackplacing"; - public const string InvertMouse = "invertmouse"; + public const string PushbackPlacing = "pushbackplacing"; public const string NoclipSlide = "noclipslide"; public const string CameraClipping = "cameraclipping"; public const string DoubleJump = "doublejump"; + public const string TabAutocomplete = "tab-autocomplete"; + public const string ShowBlockInHand = "blockinhand"; + public const string ChatLines = "chatlines"; + public const string ClickableChat = "chatclickable"; + public const string ArialChatFont = "arialchatfont"; + public const string HotbarScale = "gui-hotbarscale"; + public const string InventoryScale = "gui-inventoryscale"; + public const string ChatScale = "chatscale"; public const string AllowCustomBlocks = "nostalgia-customblocks"; public const string UseCPE = "nostalgia-usecpe";