diff --git a/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs index 6be4ef8b9..4c28712c9 100644 --- a/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs @@ -23,7 +23,7 @@ namespace ClassicalSharp.Gui { MakeClassicBool( -1, -150, "Invert mouse", OptionsKey.InvertMouse, OnWidgetClick, g => g.InvertMouse, (g, v) => g.InvertMouse = v ), - MakeClassic( -1, -100, "View distance", OnWidgetClick, + MakeClassic2( -1, -100, "View distance", OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance( Int32.Parse( v ), true ) ), @@ -43,7 +43,7 @@ namespace ClassicalSharp.Gui { MakeClassicBool( 1, -100, "View bobbing", OptionsKey.ViewBobbing, OnWidgetClick, g => g.ViewBobbing, (g, v) => g.ViewBobbing = v ), - MakeClassic( 1, -50, "FPS limit mode", OnWidgetClick, + MakeClassic2( 1, -50, "FPS mode", OnWidgetClick, g => g.FpsLimit.ToString(), (g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v ); g.SetFpsLimitMethod( (FpsLimitMethod)raw ); diff --git a/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs index 4a5d243e1..26382e2e2 100644 --- a/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs @@ -19,40 +19,40 @@ namespace ClassicalSharp.Gui { widgets = new Widget[] { // Column 1 - Make( -1, -150, "Clouds colour", OnWidgetClick, + Make2( -1, -150, "Clouds col", OnWidgetClick, g => g.World.CloudsCol.ToRGBHexString(), (g, v) => g.World.SetCloudsColour( FastColour.Parse( v ) ) ), - Make( -1, -100, "Sky colour", OnWidgetClick, + Make2( -1, -100, "Sky col", OnWidgetClick, g => g.World.SkyCol.ToRGBHexString(), (g, v) => g.World.SetSkyColour( FastColour.Parse( v ) ) ), - Make( -1, -50, "Fog colour", OnWidgetClick, + Make2( -1, -50, "Fog col", OnWidgetClick, g => g.World.FogCol.ToRGBHexString(), (g, v) => g.World.SetFogColour( FastColour.Parse( v ) ) ), - Make( -1, 0, "Clouds speed", OnWidgetClick, + Make2( -1, 0, "Clouds speed", OnWidgetClick, g => g.World.CloudsSpeed.ToString(), (g, v) => g.World.SetCloudsSpeed( Single.Parse( v ) ) ), - Make( -1, 50, "Clouds height", OnWidgetClick, + Make2( -1, 50, "Clouds height", OnWidgetClick, g => g.World.CloudHeight.ToString(), (g, v) => g.World.SetCloudsLevel( Int32.Parse( v ) ) ), // Column 2 - Make( 1, -100, "Sunlight colour", OnWidgetClick, + Make2( 1, -100, "Sunlight col", OnWidgetClick, g => g.World.Sunlight.ToRGBHexString(), (g, v) => g.World.SetSunlight( FastColour.Parse( v ) ) ), - Make( 1, -50, "Shadow colour", OnWidgetClick, + Make2( 1, -50, "Shadow col", OnWidgetClick, g => g.World.Shadowlight.ToRGBHexString(), (g, v) => g.World.SetShadowlight( FastColour.Parse( v ) ) ), - Make( 1, 0, "Weather", OnWidgetClick, + Make2( 1, 0, "Weather", OnWidgetClick, g => g.World.Weather.ToString(), (g, v) => g.World.SetWeather( (Weather)Enum.Parse( typeof(Weather), v ) ) ), - Make( 1, 50, "Water level", OnWidgetClick, + Make2( 1, 50, "Water level", OnWidgetClick, g => g.World.EdgeHeight.ToString(), (g, v) => g.World.SetEdgeLevel( Int32.Parse( v ) ) ), @@ -60,7 +60,6 @@ namespace ClassicalSharp.Gui { (g, w) => g.SetNewScreen( new OptionsGroupScreen( g ) ) ), null, null, null, }; - widgets[7].Metadata = typeof(Weather); MakeDefaultValues(); MakeValidators(); } diff --git a/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs index 2d99ca8e4..ef2e3416c 100644 --- a/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs @@ -17,23 +17,23 @@ namespace ClassicalSharp.Gui { widgets = new Widget[] { - Make( -1, 0, "FPS limit mode", OnWidgetClick, + Make2( -1, 0, "FPS mode", OnWidgetClick, g => g.FpsLimit.ToString(), (g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v ); g.SetFpsLimitMethod( (FpsLimitMethod)raw ); Options.Set( OptionsKey.FpsLimit, v ); } ), - Make( -1, 50, "View distance", OnWidgetClick, + Make2( -1, 50, "View distance", OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance( Int32.Parse( v ), true ) ), - Make( 1, 0, "Names mode", OnWidgetClick, + Make2( 1, 0, "Names", OnWidgetClick, g => g.Players.NamesMode.ToString(), (g, v) => { object raw = Enum.Parse( typeof(NameMode), v ); g.Players.NamesMode = (NameMode)raw; Options.Set( OptionsKey.NamesMode, v ); } ), - Make( 1, 50, "Entity shadows", OnWidgetClick, + Make2( 1, 50, "Shadows", OnWidgetClick, g => g.Players.ShadowMode.ToString(), (g, v) => { object raw = Enum.Parse( typeof(EntityShadow), v ); g.Players.ShadowMode = (EntityShadow)raw; @@ -62,15 +62,15 @@ namespace ClassicalSharp.Gui { descriptions[0] = new[] { "&eVSync: &fNumber of frames rendered is at most the monitor's refresh rate.", "&e30/60/120 FPS: &f30/60/120 frames rendered at most each second.", - "&eNoLimit: &Renders as many frames as the GPU can handle each second.", + "&eNoLimit: &Renders as many frames as possible each second.", "&cUsing NoLimit mode is discouraged for general usage.", }; descriptions[2] = new[] { "&eNoNames: &fNo player names are drawn.", "&eHoveredOnly: &fName of the targeted player is drawn see-through.", - "&eAllNames: &fAll player names are drawn normally.", - "&eAllNamesAndHovered: &fName of the targeted player is drawn see-through.", - "&f All other player names are drawn normally.", + "&eAll: &fAll player names are drawn normally.", + "&eAllAndHovered: &fName of the targeted player is drawn see-through.", + "&f All other player names are drawn normally.", }; descriptions[3] = new[] { "&eNone: &fNo entity shadows are drawn.", diff --git a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs index 7e081090b..fe055833d 100644 --- a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs @@ -19,15 +19,15 @@ namespace ClassicalSharp.Gui { MakeBool( -1, -100, "Show FPS", OptionsKey.ShowFPS, OnWidgetClick, g => g.ShowFPS, (g, v) => g.ShowFPS = v ), - Make( -1, -50, "Hotbar scale", OnWidgetClick, - g => g.HotbarScale.ToString(), + Make2( -1, -50, "Hotbar scale", OnWidgetClick, + g => g.HotbarScale.ToString( "F1" ), (g, v) => { g.HotbarScale = Single.Parse( v ); Options.Set( OptionsKey.HotbarScale, v ); g.RefreshHud(); } ), - Make( -1, 0, "Inventory scale", OnWidgetClick, - g => g.InventoryScale.ToString(), + Make2( -1, 0, "Inventory scale", OnWidgetClick, + g => g.InventoryScale.ToString( "F1" ), (g, v) => { g.InventoryScale = Single.Parse( v ); Options.Set( OptionsKey.InventoryScale, v ); g.RefreshHud(); @@ -40,25 +40,25 @@ namespace ClassicalSharp.Gui { MakeBool( 1, -150, "Clickable chat", OptionsKey.ClickableChat, OnWidgetClick, g => g.ClickableChat, (g, v) => g.ClickableChat = v ), - Make( 1, -100, "Chat scale", OnWidgetClick, - g => g.ChatScale.ToString(), + Make2( 1, -100, "Chat scale", OnWidgetClick, + g => g.ChatScale.ToString( "F1" ), (g, v) => { g.ChatScale = Single.Parse( v ); Options.Set( OptionsKey.ChatScale, v ); g.RefreshHud(); } ), - Make( 1, -50, "Chat lines", OnWidgetClick, + Make2( 1, -50, "Chat lines", OnWidgetClick, g => g.ChatLines.ToString(), (g, v) => { g.ChatLines = Int32.Parse( v ); Options.Set( OptionsKey.ChatLines, v ); g.RefreshHud(); } ), - MakeBool( 1, 0, "Arial chat font", OptionsKey.ArialChatFont, + MakeBool( 1, 0, "Use font", OptionsKey.ArialChatFont, OnWidgetClick, g => !g.Drawer2D.UseBitmappedChat, (g, v) => { g.Drawer2D.UseBitmappedChat = !v; HandleFontChange(); } ), - Make( 1, 50, "Chat font name", OnWidgetClick, + Make2( 1, 50, "Font", OnWidgetClick, g => g.FontName, (g, v) => { g.FontName = v; Options.Set( OptionsKey.FontName, v ); @@ -70,6 +70,7 @@ namespace ClassicalSharp.Gui { null, null, }; MakeValidators(); + MakeDescriptions(); } void HandleFontChange() { @@ -104,5 +105,12 @@ namespace ClassicalSharp.Gui { new StringValidator( 32 ), }; } + + void MakeDescriptions() { + descriptions = new string[widgets.Length][]; + descriptions[8] = new[] { + "&eWhether a system font is used instead of default.png for drawing text", + }; + } } } \ No newline at end of file diff --git a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs index b5d847081..e5d62885a 100644 --- a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs @@ -21,15 +21,15 @@ namespace ClassicalSharp.Gui { (g, v) => { g.LocalPlayer.Hacks.Enabled = v; g.LocalPlayer.CheckHacksConsistency(); } ), - Make( -1, -100, "Speed multiplier", OnWidgetClick, - g => g.LocalPlayer.Hacks.SpeedMultiplier.ToString(), + Make2( -1, -100, "Speed multiplier", OnWidgetClick, + g => g.LocalPlayer.Hacks.SpeedMultiplier.ToString( "F3" ), (g, v) => { g.LocalPlayer.Hacks.SpeedMultiplier = Single.Parse( v ); Options.Set( OptionsKey.Speed, v ); } ), MakeBool( -1, -50, "Camera clipping", OptionsKey.CameraClipping, OnWidgetClick, g => g.CameraClipping, (g, v) => g.CameraClipping = v ), - Make( -1, 0, "Jump height", OnWidgetClick, + Make2( -1, 0, "Jump height", OnWidgetClick, g => g.LocalPlayer.JumpHeight.ToString( "F3" ), (g, v) => g.LocalPlayer.CalculateJumpVelocity( Single.Parse( v ) ) ), @@ -49,7 +49,7 @@ namespace ClassicalSharp.Gui { OnWidgetClick, g => g.LocalPlayer.Hacks.NoclipSlide, (g, v) => g.LocalPlayer.Hacks.NoclipSlide = v ), - Make( 1, 50, "Field of view", OnWidgetClick, + Make2( 1, 50, "Field of view", OnWidgetClick, g => g.FieldOfView.ToString(), (g, v) => { g.FieldOfView = Int32.Parse( v ); Options.Set( OptionsKey.FieldOfView, v ); diff --git a/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs index c2ac6619b..f153babb0 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs @@ -12,7 +12,6 @@ namespace ClassicalSharp.Gui { protected MenuInputWidget inputWidget; protected MenuInputValidator[] validators; - protected TextWidget descWidget; protected string[][] descriptions; protected ChatTextWidget[] extendedHelp; Font extendedHelpFont; @@ -29,16 +28,12 @@ namespace ClassicalSharp.Gui { graphicsApi.Texturing = true; RenderMenuWidgets( delta ); if( inputWidget != null ) - inputWidget.Render( delta ); - + inputWidget.Render( delta ); if( extendedHelp != null && extEndY <= widgets[widgets.Length - 3].Y ) { for( int i = 0; i < extendedHelp.Length; i++ ) extendedHelp[i].Render( delta ); } - if( descWidget != null ) - descWidget.Render( delta ); - graphicsApi.Texturing = false; } @@ -75,8 +70,6 @@ namespace ClassicalSharp.Gui { } public override void OnResize( int oldWidth, int oldHeight, int width, int height ) { - if( descWidget != null ) - descWidget.OnResize( oldWidth, oldHeight, width, height ); if( inputWidget != null ) inputWidget.OnResize( oldWidth, oldHeight, width, height ); @@ -87,10 +80,6 @@ namespace ClassicalSharp.Gui { } public override void Dispose() { - if( descWidget != null ) { - descWidget.Dispose(); - descWidget = null; - } if( inputWidget != null ) { inputWidget.Dispose(); inputWidget = null; @@ -114,16 +103,9 @@ namespace ClassicalSharp.Gui { } protected void UpdateDescription( ButtonWidget widget ) { - if( descWidget != null ) - descWidget.Dispose(); DisposeExtendedHelp(); if( widget == null || widget.GetValue == null ) return; - int index = Array.IndexOf( widgets, widget ); - if( index >= validators.Length || !(validators[index] is BooleanValidator) ) { - string text = widget.Text + ": " + widget.GetValue( game ); - descWidget = TextWidget.Create( game, 0, 100, text, Anchor.Centre, Anchor.Centre, regularFont ); - } ShowExtendedHelp(); } @@ -139,8 +121,13 @@ namespace ClassicalSharp.Gui { return widget; } - protected ButtonWidget MakeBool( int dir, int y, string optName, string optKey, - ClickHandler onClick, Func getter, Action setter ) { + protected ButtonWidget Make2( int dir, int y, string text, ClickHandler onClick, + Func getter, Action setter ) { + return Make2Impl( 160 * dir, y, 280, 35, text, onClick, getter, setter ); + } + + protected ButtonWidget MakeBool( int dir, int y, string optName, string optKey, + ClickHandler onClick, Func getter, Action setter ) { return MakeBoolImpl( 160 * dir, y, 280, 35, optName, optKey, onClick, getter, setter ); } @@ -152,20 +139,38 @@ namespace ClassicalSharp.Gui { return widget; } - protected ButtonWidget MakeClassicBool( int dir, int y, string text, string optKey, + protected ButtonWidget MakeClassic2( int dir, int y, string text, ClickHandler onClick, + Func getter, Action setter ) { + return Make2Impl( 165 * dir, y, 301, 41, text, onClick, getter, setter ); + } + + protected ButtonWidget MakeClassicBool( int dir, int y, string text, string optKey, ClickHandler onClick, Func getter, Action setter ) { return MakeBoolImpl( 165 * dir, y, 301, 41, text, optKey, onClick, getter, setter ); } - ButtonWidget MakeBoolImpl( int x, int y, int width, int height, string text, string optKey, - ClickHandler onClick, Func getter, Action setter ) { + ButtonWidget Make2Impl( int x, int y, int width, int height, string text, + ClickHandler onClick, Func getter, Action setter ) { + ButtonWidget widget = ButtonWidget.Create( game, x, y, width, height, text + ": " + getter( game ), + Anchor.Centre, Anchor.Centre, titleFont, onClick ); + widget.Metadata = text; + widget.GetValue = getter; + widget.SetValue = (g, v) => { + setter( g, v ); + widget.SetText( (string)widget.Metadata + ": " + getter( g ) ); + }; + return widget; + } + + ButtonWidget MakeBoolImpl( int x, int y, int width, int height, string text, string optKey, + ClickHandler onClick, Func getter, Action setter ) { string optName = text; text = text + ": " + (getter( game ) ? "ON" : "OFF"); ButtonWidget widget = ButtonWidget.Create( game, x, y, width, height, text, Anchor.Centre, Anchor.Centre, titleFont, onClick ); widget.Metadata = optName; widget.GetValue = g => getter( g ) ? "yes" : "no"; - widget.SetValue = (g, v) => { + widget.SetValue = (g, v) => { setter( g, v == "yes" ); Options.Set( optKey, v == "yes" ); widget.SetText( (string)widget.Metadata + ": " + (v == "yes" ? "ON" : "OFF") ); diff --git a/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs index e8d7ce5cf..352824bff 100644 --- a/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs @@ -17,7 +17,7 @@ namespace ClassicalSharp.Gui { widgets = new Widget[] { // Column 1 !network.IsSinglePlayer ? null : - Make( -1, -100, "Click distance", OnWidgetClick, + Make2( -1, -100, "Click distance", OnWidgetClick, g => g.LocalPlayer.ReachDistance.ToString(), (g, v) => g.LocalPlayer.ReachDistance = Single.Parse( v ) ), @@ -45,7 +45,7 @@ namespace ClassicalSharp.Gui { MakeBool( 1, 0, "Invert mouse", OptionsKey.InvertMouse, OnWidgetClick, g => g.InvertMouse, (g, v) => g.InvertMouse = v ), - Make( 1, 50, "Mouse sensitivity", OnWidgetClick, + Make2( 1, 50, "Mouse sensitivity", OnWidgetClick, g => g.MouseSensitivity.ToString(), (g, v) => { g.MouseSensitivity = Int32.Parse( v ); Options.Set( OptionsKey.Sensitivity, v ); } ), diff --git a/ClassicalSharp/Entities/EntityList.cs b/ClassicalSharp/Entities/EntityList.cs index 1ec9411a7..0e923a230 100644 --- a/ClassicalSharp/Entities/EntityList.cs +++ b/ClassicalSharp/Entities/EntityList.cs @@ -5,7 +5,7 @@ using ClassicalSharp.GraphicsAPI; namespace ClassicalSharp.Entities { - public enum NameMode { NoNames, HoveredOnly, AllNames, AllNamesAndHovered, } + public enum NameMode { NoNames, HoveredOnly, All, AllAndHovered, } public enum EntityShadow { None, SnapToBlock, Circle, CircleAll, } @@ -19,12 +19,12 @@ namespace ClassicalSharp.Entities { /// Mode of how names of hovered entities are rendered (with or without depth testing), /// and how other entity names are rendered. - public NameMode NamesMode = NameMode.AllNamesAndHovered; + public NameMode NamesMode = NameMode.AllAndHovered; public EntityList( Game game ) { this.game = game; game.Events.ChatFontChanged += ChatFontChanged; - NamesMode = Options.GetEnum( OptionsKey.NamesMode, NameMode.AllNamesAndHovered ); + NamesMode = Options.GetEnum( OptionsKey.NamesMode, NameMode.AllAndHovered ); if( game.ClassicMode ) NamesMode = NameMode.HoveredOnly; ShadowMode = Options.GetEnum( OptionsKey.EntityShadow, EntityShadow.None ); if( game.ClassicMode ) ShadowMode = EntityShadow.None; @@ -62,7 +62,7 @@ namespace ClassicalSharp.Entities { Vector3 eyePos = localP.EyePosition; closestId = 255; - if( NamesMode != NameMode.AllNames ) + if( NamesMode != NameMode.All ) closestId = GetClosetPlayer( game.LocalPlayer ); if( NamesMode == NameMode.HoveredOnly || !game.LocalPlayer.Hacks.CanSeeAllNames ) { api.Texturing = false; @@ -80,7 +80,7 @@ namespace ClassicalSharp.Entities { } public void RenderHoveredNames( IGraphicsApi api, double delta, float t ) { - if( NamesMode == NameMode.NoNames || NamesMode == NameMode.AllNames ) + if( NamesMode == NameMode.NoNames || NamesMode == NameMode.All ) return; api.Texturing = true; api.AlphaTest = true;