mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Fix changed keybinds not saving. (Thanks Cheesse)
This commit is contained in:
parent
43752348bf
commit
f9de4ac85c
@ -80,6 +80,13 @@ namespace ClassicalSharp {
|
|||||||
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 IsChangedOption(string key) {
|
||||||
|
for (int i = 0; i < OptionsChanged.Count; i++) {
|
||||||
|
if (Utils.CaselessEquals(key, OptionsChanged[i])) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool TryGetValue(string key, out string value) {
|
static bool TryGetValue(string key, out string value) {
|
||||||
value = null;
|
value = null;
|
||||||
int i = FindOption(key);
|
int i = FindOption(key);
|
||||||
@ -157,7 +164,7 @@ namespace ClassicalSharp {
|
|||||||
SetOption(key, value);
|
SetOption(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OptionsChanged.Contains(key)) {
|
if (!IsChangedOption(key)) {
|
||||||
OptionsChanged.Add(key);
|
OptionsChanged.Add(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +211,7 @@ namespace ClassicalSharp {
|
|||||||
// remove all the unchanged options
|
// remove all the unchanged options
|
||||||
for (int i = OptionsKeys.Count - 1; i >= 0; i--) {
|
for (int i = OptionsKeys.Count - 1; i >= 0; i--) {
|
||||||
string key = OptionsKeys[i];
|
string key = OptionsKeys[i];
|
||||||
if (OptionsChanged.Contains(key)) continue;
|
if (IsChangedOption(key)) continue;
|
||||||
RemoveOption(i);
|
RemoveOption(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +227,7 @@ namespace ClassicalSharp {
|
|||||||
if (sepIndex == line.Length) continue;
|
if (sepIndex == line.Length) continue;
|
||||||
string value = line.Substring(sepIndex, line.Length - sepIndex);
|
string value = line.Substring(sepIndex, line.Length - sepIndex);
|
||||||
|
|
||||||
if (!OptionsChanged.Contains(key)) {
|
if (!IsChangedOption(key)) {
|
||||||
SetOption(key, value);
|
SetOption(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user