Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-01-16 13:06:19 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-01-16 13:06:19 +0300
commit98baa664036f58ddaa38cd79d7092502db770e76 (patch)
tree457ad6f95772ff4cddc338e86d3a9fd301d4c172 /ConfigIni.cs
parent81a106d35bab7386754e8b875eb9d355818a1a20 (diff)
Game Genie support + some fixes
Diffstat (limited to 'ConfigIni.cs')
-rw-r--r--ConfigIni.cs64
1 files changed, 36 insertions, 28 deletions
diff --git a/ConfigIni.cs b/ConfigIni.cs
index 88f336e1..2daccaa9 100644
--- a/ConfigIni.cs
+++ b/ConfigIni.cs
@@ -15,7 +15,7 @@ namespace com.clusterrr.hakchi_gui
public static bool CustomFlashed = false;
public static bool UseFont = true;
public static Dictionary<string, string> Presets = new Dictionary<string, string>();
- const string ConfigFile = "config.ini";
+ const string ConfigFile = "config.ini";
public static void Load()
{
@@ -23,39 +23,45 @@ namespace com.clusterrr.hakchi_gui
if (File.Exists(fileName))
{
var configLines = File.ReadAllLines(fileName);
+ string section = "";
foreach (var line in configLines)
{
- int pos = line.IndexOf('=');
+ var l = line.Trim();
+ if (l.StartsWith("[") && l.EndsWith("]"))
+ section = l.Substring(1, l.Length - 2).ToLower();
+ int pos = l.IndexOf('=');
if (pos <= 0) continue;
- var param = line.Substring(0, pos).Trim();
- var value = line.Substring(pos + 1).Trim();
- if (param.StartsWith("+"))
+ var param = l.Substring(0, pos).Trim();
+ var value = l.Substring(pos + 1).Trim();
+ switch (section)
{
- Presets[param.Substring(1)] = value;
- continue;
- }
- param = param.ToLower();
- switch (param)
- {
- case "selectedgames":
- SelectedGames = value;
- break;
- case "hiddengames":
- HiddenGames = value;
+ case "config":
+ param = param.ToLower();
+ switch (param)
+ {
+ case "selectedgames":
+ SelectedGames = value;
+ break;
+ case "hiddengames":
+ HiddenGames = value;
+ break;
+ case "customflashed":
+ CustomFlashed = !value.ToLower().Equals("false");
+ FirstRun = false;
+ break;
+ case "usefont":
+ UseFont = !value.ToLower().Equals("false");
+ break;
+ case "firstrun":
+ FirstRun = !value.ToLower().Equals("false");
+ break;
+ }
break;
- case "customflashed":
- CustomFlashed = !value.ToLower().Equals("false");
- FirstRun = false;
- break;
- case "usefont":
- UseFont = !value.ToLower().Equals("false");
- break;
- case "firstrun":
- FirstRun = !value.ToLower().Equals("false");
+ case "presets":
+ Presets[param] = value;
break;
}
}
-
}
}
@@ -68,9 +74,11 @@ namespace com.clusterrr.hakchi_gui
configLines.Add(string.Format("CustomFlashed={0}", CustomFlashed));
configLines.Add(string.Format("UseFont={0}", UseFont));
configLines.Add(string.Format("FirstRun={0}", FirstRun));
- foreach(var preset in Presets.Keys)
+ configLines.Add("[Presets]");
+ configLines.Add("");
+ foreach (var preset in Presets.Keys)
{
- configLines.Add(string.Format("+{0}={1}", preset, Presets[preset]));
+ configLines.Add(string.Format("{0}={1}", preset, Presets[preset]));
}
File.WriteAllLines(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), ConfigFile), configLines.ToArray());
}