Add back in Options.Set(string, string) to avoid MissingMethod. (Thanks Cheesse), fixes #235

This commit is contained in:
UnknownShadow200 2016-09-13 06:51:51 +10:00
parent b3c2a21fc0
commit 94dc022567
3 changed files with 24 additions and 12 deletions

View File

@ -114,13 +114,13 @@ namespace ClassicalSharp.Hotkeys {
public void UserRemovedHotkey( Key baseKey, byte flags ) { public void UserRemovedHotkey( Key baseKey, byte flags ) {
string key = "hotkey-" + baseKey + "&" + flags; string key = "hotkey-" + baseKey + "&" + flags;
Options.Set<string>( key, null ); Options.Set( key, null );
} }
public void UserAddedHotkey( Key baseKey, byte flags, bool moreInput, string text ) { public void UserAddedHotkey( Key baseKey, byte flags, bool moreInput, string text ) {
string key = "hotkey-" + baseKey + "&" + flags; string key = "hotkey-" + baseKey + "&" + flags;
string value = moreInput + "&" + text; string value = moreInput + "&" + text;
Options.Set<string>( key, value ); Options.Set( key, value );
} }
} }

View File

@ -12,9 +12,9 @@ namespace ClassicalSharp {
public const string ViewDist = "viewdist"; public const string ViewDist = "viewdist";
public const string DefaultTexturePack = "defaulttexpack"; public const string DefaultTexturePack = "defaulttexpack";
public const string SingleplayerPhysics = "singleplayerphysics"; public const string SingleplayerPhysics = "singleplayerphysics";
public const string UseMusic = "usemusic"; public const string UseMusic = "usemusic";
public const string UseSound = "usesound"; public const string UseSound = "usesound";
public const string NamesMode = "namesmode"; public const string NamesMode = "namesmode";
public const string InvertMouse = "invertmouse"; public const string InvertMouse = "invertmouse";
public const string Sensitivity = "mousesensitivity"; public const string Sensitivity = "mousesensitivity";
@ -26,10 +26,10 @@ namespace ClassicalSharp {
public const string SmoothLighting = "gfx-smoothlighting"; public const string SmoothLighting = "gfx-smoothlighting";
public const string HacksEnabled = "hacks-hacksenabled"; 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 Speed = "hacks-speedmultiplier";
public const string ModifiableLiquids = "hacks-liquidsbreakable"; 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 NoclipSlide = "hacks-noclipslide";
public const string CameraClipping = "hacks-cameraclipping"; public const string CameraClipping = "hacks-cameraclipping";
public const string DoubleJump = "hacks-doublejump"; public const string DoubleJump = "hacks-doublejump";
@ -64,14 +64,14 @@ namespace ClassicalSharp {
public static class Options { public static class Options {
public static Dictionary<string, string> OptionsSet = new Dictionary<string, string>(); public static Dictionary<string, string> OptionsSet = new Dictionary<string, string>();
public static List<string> OptionsChanged = new List<string>(); public static List<string> OptionsChanged = new List<string>();
const string Filename = "options.txt"; const string Filename = "options.txt";
static bool TryGetValue( string key, out string value ) { static bool TryGetValue( string key, out string value ) {
if( OptionsSet.TryGetValue( key, out value ) ) return true; if( OptionsSet.TryGetValue( key, out value ) ) return true;
int index = key.IndexOf( '-' ); int index = key.IndexOf( '-' );
if( index == -1 ) return false; if( index == -1 ) return false;
return OptionsSet.TryGetValue( key.Substring( index + 1 ), out value ); return OptionsSet.TryGetValue( key.Substring( index + 1 ), out value );
} }
@ -120,6 +120,18 @@ namespace ClassicalSharp {
return mapping; 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<T>( string key, T value ) { public static void Set<T>( string key, T value ) {
key = key.ToLower(); key = key.ToLower();
if( value != null ) { if( value != null ) {
@ -139,7 +151,7 @@ namespace ClassicalSharp {
string defZip = Path.Combine( Program.AppDirectory, "default.zip" ); string defZip = Path.Combine( Program.AppDirectory, "default.zip" );
string texDir = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir ); string texDir = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir );
if( File.Exists( defZip ) || !Directory.Exists( texDir ) ) if( File.Exists( defZip ) || !Directory.Exists( texDir ) )
Program.CleanupMainDirectory(); Program.CleanupMainDirectory();
try { try {
string path = Path.Combine( Program.AppDirectory, Filename ); string path = Path.Combine( Program.AppDirectory, Filename );
@ -161,7 +173,7 @@ namespace ClassicalSharp {
List<string> toRemove = new List<string>(); List<string> toRemove = new List<string>();
foreach( KeyValuePair<string, string> kvp in OptionsSet ) { foreach( KeyValuePair<string, string> kvp in OptionsSet ) {
if( !OptionsChanged.Contains( kvp.Key ) ) if( !OptionsChanged.Contains( kvp.Key ) )
toRemove.Add( kvp.Key ); toRemove.Add( kvp.Key );
} }
for( int i = 0; i < toRemove.Count; i++ ) for( int i = 0; i < toRemove.Count; i++ )
OptionsSet.Remove( toRemove[i] ); OptionsSet.Remove( toRemove[i] );
@ -185,7 +197,7 @@ namespace ClassicalSharp {
try { try {
string path = Path.Combine( Program.AppDirectory, Filename ); string path = Path.Combine( Program.AppDirectory, Filename );
using( Stream fs = File.Create( path ) ) using( Stream fs = File.Create( path ) )
using( StreamWriter writer = new StreamWriter( fs ) ) using( StreamWriter writer = new StreamWriter( fs ) )
{ {
SaveTo( writer ); SaveTo( writer );
} }

View File

@ -40,7 +40,7 @@ namespace Launcher {
for( int yy = 0; yy < height; yy++ ) { for( int yy = 0; yy < height; yy++ ) {
int* row = dst.GetRowPtr( y + 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.R = (byte)Utils.Lerp( a.R, b.R, t );
c.G = (byte)Utils.Lerp( a.G, b.G, t ); c.G = (byte)Utils.Lerp( a.G, b.G, t );