public static Dictionary <string, string> GetConfigDictionary(MainForm.ConsoleType?consoleType = null) { MainForm.ConsoleType oldConsoleType = ConsoleType; if (consoleType != null && consoleType != MainForm.ConsoleType.Unknown) { ConsoleType = consoleType ?? MainForm.ConsoleType.Unknown; } var config = new Dictionary <string, string>(); config["clovercon_home_combination"] = ConfigIni.ResetHack ? string.Format("0x{0:X4}", ConfigIni.ResetCombination) : "0x7FFF"; config["clovercon_autofire"] = ConfigIni.AutofireHack ? "1" : "0"; config["clovercon_autofire_xy"] = ConfigIni.AutofireXYHack /*&& (ConfigIni.ConsoleType == MainForm.ConsoleType.NES || ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom)*/ ? "1" : "0"; config["clovercon_fc_start"] = ConfigIni.FcStart && (ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom) ? "1" : "0"; config["fontfix_enabled"] = ConfigIni.UseFont ? "y" : "n"; config["disable_armet"] = ConfigIni.AntiArmetLevel > 0 /*&& (ConfigIni.ConsoleType == MainForm.ConsoleType.NES || ConfigIni.ConsoleType == MainForm.ConsoleType.Famicom)*/ ? "y" : "n"; config["nes_extra_args"] = ExtraCommandLineArgumentsNes; config["snes_extra_args"] = ExtraCommandLineArgumentsSnes; config["usb_host"] = ConfigIni.UsbHost ? "y" : "n"; ConsoleType = oldConsoleType; return(config); }
public static void Load() { Debug.WriteLine("Loading config"); var fileNameOld = Path.Combine(Program.BaseDirectoryExternal, ConfigFile); var configFullDir = Path.Combine(Program.BaseDirectoryExternal, ConfigDir); var fileName = Path.Combine(configFullDir, ConfigFile); if (File.Exists(fileNameOld)) // Moving old config to new directory { Directory.CreateDirectory(configFullDir); File.Copy(fileNameOld, fileName, true); File.Delete(fileNameOld); } if (File.Exists(fileName)) { var configLines = File.ReadAllLines(fileName); string section = ""; foreach (var line in configLines) { 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 = l.Substring(0, pos).Trim(); var value = l.Substring(pos + 1).Trim(); switch (section) { case "config": param = param.ToLower(); switch (param) { case "language": Language = value; break; case "selectedgames": SelectedGamesNes = value; break; case "selectedgamessnes": SelectedGamesSnes = value; break; case "hiddengames": HiddenGamesNes = value; break; case "hiddengamesfamicom": HiddenGamesFamicom = value; break; case "hiddengamessnes": HiddenGamesSnes = value; break; case "hiddengamessuperfamicom": HiddenGamesSuperFamicom = value; break; case "customflashednes": CustomFlashedNes = !value.ToLower().Equals("false"); break; case "customflashedfamicom": CustomFlashedFamicom = !value.ToLower().Equals("false"); break; case "customflashedsnes": CustomFlashedSnes = !value.ToLower().Equals("false"); break; case "customflashedsuperfamicom": CustomFlashedSuperFamicom = !value.ToLower().Equals("false"); break; case "usefont": UseFont = !value.ToLower().Equals("false"); break; case "runcount": RunCount = int.Parse(value); break; case "antiarmetlevel": AntiArmetLevel = byte.Parse(value); break; case "resethack": case "cloverconhack": ResetHack = !value.ToLower().Equals("false"); break; case "autofirehack": AutofireHack = !value.ToLower().Equals("false"); break; case "autofirexyhack": AutofireXYHack = !value.ToLower().Equals("false"); break; case "resetcombination": ResetCombination = (SelectButtonsForm.NesButtons) byte.Parse(value); break; case "consoletype": ConsoleType = (MainForm.ConsoleType) byte.Parse(value); break; case "extracommandlinearguments": ExtraCommandLineArguments = value; break; case "fcstart": FcStart = !value.ToLower().Equals("false"); break; case "maxgamesperfolder": MaxGamesPerFolder = byte.Parse(value); break; case "foldersmode": FoldersMode = (NesMenuCollection.SplitStyle) byte.Parse(value); break; case "compress": Compress = !value.ToLower().Equals("false"); break; case "ftpserver": FtpServer = !value.ToLower().Equals("false"); break; case "telnetserver": TelnetServer = !value.ToLower().Equals("false"); break; } break; case "presets": Presets[param] = value; break; } } } }
// special case method public ICollection <string> SelectedGamesForConsole(MainForm.ConsoleType c) { return((c == MainForm.ConsoleType.Unknown) ? null : gamesCollectionSettings[c].SelectedGames); }