From 94dc022567cf91d8b56115c274fec9146c3735bd Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 13 Sep 2016 06:51:51 +1000 Subject: [PATCH] Add back in Options.Set(string, string) to avoid MissingMethod. (Thanks Cheesse), fixes #235 --- ClassicalSharp/Hotkeys/HotkeyList.cs | 4 ++-- ClassicalSharp/Utils/Options.cs | 30 +++++++++++++++++++--------- Launcher2/Drawing/Gradient.cs | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ClassicalSharp/Hotkeys/HotkeyList.cs b/ClassicalSharp/Hotkeys/HotkeyList.cs index bad40d78b..889e542ab 100644 --- a/ClassicalSharp/Hotkeys/HotkeyList.cs +++ b/ClassicalSharp/Hotkeys/HotkeyList.cs @@ -114,13 +114,13 @@ namespace ClassicalSharp.Hotkeys { public void UserRemovedHotkey( Key baseKey, byte flags ) { string key = "hotkey-" + baseKey + "&" + flags; - Options.Set( key, null ); + Options.Set( key, null ); } public void UserAddedHotkey( Key baseKey, byte flags, bool moreInput, string text ) { string key = "hotkey-" + baseKey + "&" + flags; string value = moreInput + "&" + text; - Options.Set( key, value ); + Options.Set( key, value ); } } diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index 728086e45..500da7996 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -12,9 +12,9 @@ namespace ClassicalSharp { public const string ViewDist = "viewdist"; public const string DefaultTexturePack = "defaulttexpack"; - public const string SingleplayerPhysics = "singleplayerphysics"; + public const string SingleplayerPhysics = "singleplayerphysics"; public const string UseMusic = "usemusic"; - public const string UseSound = "usesound"; + public const string UseSound = "usesound"; public const string NamesMode = "namesmode"; public const string InvertMouse = "invertmouse"; public const string Sensitivity = "mousesensitivity"; @@ -26,10 +26,10 @@ namespace ClassicalSharp { public const string SmoothLighting = "gfx-smoothlighting"; public const string HacksEnabled = "hacks-hacksenabled"; - public const string FieldOfView = "hacks-fov"; + public const string FieldOfView = "hacks-fov"; public const string Speed = "hacks-speedmultiplier"; public const string ModifiableLiquids = "hacks-liquidsbreakable"; - public const string PushbackPlacing = "hacks-pushbackplacing"; + public const string PushbackPlacing = "hacks-pushbackplacing"; public const string NoclipSlide = "hacks-noclipslide"; public const string CameraClipping = "hacks-cameraclipping"; public const string DoubleJump = "hacks-doublejump"; @@ -64,14 +64,14 @@ namespace ClassicalSharp { public static class Options { public static Dictionary OptionsSet = new Dictionary(); - public static List OptionsChanged = new List(); + public static List OptionsChanged = new List(); const string Filename = "options.txt"; static bool TryGetValue( string key, out string value ) { if( OptionsSet.TryGetValue( key, out value ) ) return true; int index = key.IndexOf( '-' ); - if( index == -1 ) return false; + if( index == -1 ) return false; return OptionsSet.TryGetValue( key.Substring( index + 1 ), out value ); } @@ -120,6 +120,18 @@ namespace ClassicalSharp { return mapping; } + public static void Set( string key, string value ) { + key = key.ToLower(); + if( value != null ) { + OptionsSet[key] = value; + } else { + OptionsSet.Remove( key ); + } + + if( !OptionsChanged.Contains( key ) ) + OptionsChanged.Add( key ); + } + public static void Set( string key, T value ) { key = key.ToLower(); if( value != null ) { @@ -139,7 +151,7 @@ namespace ClassicalSharp { string defZip = Path.Combine( Program.AppDirectory, "default.zip" ); string texDir = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir ); if( File.Exists( defZip ) || !Directory.Exists( texDir ) ) - Program.CleanupMainDirectory(); + Program.CleanupMainDirectory(); try { string path = Path.Combine( Program.AppDirectory, Filename ); @@ -161,7 +173,7 @@ namespace ClassicalSharp { List toRemove = new List(); foreach( KeyValuePair kvp in OptionsSet ) { if( !OptionsChanged.Contains( kvp.Key ) ) - toRemove.Add( kvp.Key ); + toRemove.Add( kvp.Key ); } for( int i = 0; i < toRemove.Count; i++ ) OptionsSet.Remove( toRemove[i] ); @@ -185,7 +197,7 @@ namespace ClassicalSharp { try { string path = Path.Combine( Program.AppDirectory, Filename ); using( Stream fs = File.Create( path ) ) - using( StreamWriter writer = new StreamWriter( fs ) ) + using( StreamWriter writer = new StreamWriter( fs ) ) { SaveTo( writer ); } diff --git a/Launcher2/Drawing/Gradient.cs b/Launcher2/Drawing/Gradient.cs index dd8685763..7ee17bed6 100644 --- a/Launcher2/Drawing/Gradient.cs +++ b/Launcher2/Drawing/Gradient.cs @@ -40,7 +40,7 @@ namespace Launcher { for( int yy = 0; yy < height; yy++ ) { int* row = dst.GetRowPtr( y + yy ); - float t = (float)yy / height; + float t = (float)yy / (height - 1); // so last row has b as its colour c.R = (byte)Utils.Lerp( a.R, b.R, t ); c.G = (byte)Utils.Lerp( a.G, b.G, t );