void DrawSplitTree(NesMenuCollection.SplitStyle splitStyle = NesMenuCollection.SplitStyle.NoSplit) { var node = treeView.SelectedNode; NesMenuCollection collection; if (node.Tag is NesMenuFolder) { collection = (node.Tag as NesMenuFolder).ChildMenuCollection; } else if (node.Tag is NesMenuCollection) { collection = node.Tag as NesMenuCollection; } else { return; } // Collide and resplit collection collection.Unsplit(); collection.Split(splitStyle, ConfigIni.MaxGamesPerFolder); // Refill nodes with new collection node.Nodes.Clear(); AddNodes(node.Nodes, collection); node.Expand(); treeView.SelectedNode = node; ShowSelected(); }
public static void Load() { Debug.WriteLine("Loading config"); var fileNameOld = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), ConfigFile); var configFullDir = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), 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 "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; 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 = 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; } break; case "presets": Presets[param] = value; break; } } } }
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 "selectedborders": SelectedBorders = value; break; case "selectedgames": SelectedGamesNes = value; break; case "selectedgamessnes": SelectedGamesSnes = value; break; case "hiddengamesborders": HiddenGamesBorders = 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": UseFontNes = !value.ToLower().Equals("false"); break; case "usefontfamicom": UseFontFamicom = !value.ToLower().Equals("false"); break; case "usefontsnes": UseFontSnes = !value.ToLower().Equals("false"); break; case "usefontsuperfamicom": UseFontSuperFamicom = !value.ToLower().Equals("false"); break; case "runcount": RunCount = int.Parse(value); break; case "antiarmetlevel": AntiArmetLevel = byte.Parse(value); break; case "resethack": case "cloverconhack": ResetHackNes = !value.ToLower().Equals("false"); break; case "resethacksnes": ResetHackSnes = !value.ToLower().Equals("false"); break; case "autofirehack": AutofireHackNes = !value.ToLower().Equals("false"); break; case "autofirehacksnes": AutofireHackSnes = !value.ToLower().Equals("false"); break; case "autofirexyhack": AutofireXYHack = !value.ToLower().Equals("false"); break; case "resetcombination": ResetCombinationNes = uint.Parse(value); break; case "resetcombinationsnes": ResetCombinationSnes = uint.Parse(value); break; case "consoletype": ConsoleType = (MainForm.ConsoleType) byte.Parse(value); break; case "extracommandlinearguments": ExtraCommandLineArgumentsNes = value; break; case "extracommandlineargumentssnes": ExtraCommandLineArgumentsSnes = value; break; case "fcstart": FcStart = !value.ToLower().Equals("false"); break; case "maxgamesperfolder": MaxGamesPerFolderNes = byte.Parse(value); break; case "maxgamesperfolderfamicom": MaxGamesPerFolderFamicom = byte.Parse(value); break; case "maxgamesperfoldersnes": MaxGamesPerFolderSnes = byte.Parse(value); break; case "maxgamesperfoldersuperfamicom": MaxGamesPerFolderSuperFamicom = byte.Parse(value); break; case "foldersmode": FoldersModeNes = (NesMenuCollection.SplitStyle) byte.Parse(value); break; case "foldersmodefamicom": FoldersModeSuperFamicom = (NesMenuCollection.SplitStyle) byte.Parse(value); break; case "foldersmodesnes": FoldersModeSnes = (NesMenuCollection.SplitStyle) byte.Parse(value); break; case "foldersmodesuperfamicom": FoldersModeSuperFamicom = (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; } } } }