public static void SetDefaultSpeed(string material) { if (material == null) { Console.WriteLine(" : Enter the material you'd like to access your saved defualts for :"); Console.WriteLine(" ( If the material doesn't exist a blank new file will be created )"); Display.ShowHeader(); material = Console.ReadLine(); } string path = FileLogic.MaterialToFilePath(material); if (FileLogic.CheckFileExistance(path) == false) { Console.WriteLine(" : No file detected, creating a blank save file :"); FileLogic.FormatFileToSettingStandard(path, false); } int slot = SecondaryLogic.GetSlot(path, true); double speed = SecondaryLogic.RateCalculation(true, null); Console.WriteLine(" : Enter a label for this default : "); Display.ShowHeader(); string comment = Console.ReadLine(); string ammendment = Convert.ToString(speed); FileLogic.AmmendSettingsFile(path, ammendment, slot - 1, comment); Console.WriteLine(" : Default successfully saved :"); }
public static void Main() { Console.WriteLine("\nSEC Release 4.0 {Feb 2021}"); Console.WriteLine("Created by Lucifer_009"); if (FileLogic.CheckFolderExsistance(FileLogic.SETTINGS_FOLDER) == false) // Ensures a settings folder is there { // Creates one if not there Display.ShowError("No main settings folder. Created one"); FileLogic.CreateDirectory(FileLogic.SETTINGS_FOLDER); } LaunchMenu.MenuLogic(); }
public static int GetSlot(string path, bool overwrite) { string[,] settings = FileLogic.ReadFileToSettings(path); bool EmptyPreset = true; Console.WriteLine("--- --- ---"); for (int x = 0; x < settings.Length; x++) { try { if (settings[x, 0] == null) { Console.WriteLine(@$"Preset {x + 1} : \EMPTY\"); } else { Console.WriteLine($"Preset {x + 1} : {settings[x, 0]} | {settings[x, 1]}"); EmptyPreset = false; } } catch (IndexOutOfRangeException) { break; } } Console.WriteLine("--- --- ---"); int option; while (true) { Console.WriteLine(" : Enter the preset number you'd like to select : "); Display.ShowHeader(); option = Input.GetInt(); if (option < 1 || option > settings.Length && EmptyPreset == false) { Display.ShowError("Entered an invalid response, number chosen outside the presets shown"); } else if (EmptyPreset == true && overwrite == false) { Display.ShowError("There is nothing saved into that preset"); } else { break; } } return option; }
public static double loadMinionSave(bool Write, string material) { string path; while(true) { if (material == null) { Console.WriteLine(" : Enter name of material to load defaults for : "); Display.ShowHeader(); material = Console.ReadLine(); } path = FileLogic.MaterialToFilePath(material); if (FileLogic.CheckFileExistance(path) == false) { Display.ShowError("CRITICAL ERROR - No file in exsistance to load"); MainLogic.SetDefaultSpeed(material); } else { break; } } int option = GetSlot(path, Write); string[,] settings = FileLogic.ReadFileToSettings(path); double speedSelected = Convert.ToDouble(settings[option-1, 0]); return speedSelected; }
public static void ClearDefualts() { Console.WriteLine(@" 1 - Clear all settings 2 - Clear specific settings file "); int choice; while (true) { Console.WriteLine(" : Enter you choice from the menu :"); choice = Input.GetInt(); if (choice > 2 || choice < 1) { Display.ShowError("Invalid input, (1-2)"); } else { break; } } string material; string path; if (choice == 1) { Console.WriteLine(" : Are you sure you want to wipe the file (Y/N) : "); string YesOrNO = Console.ReadLine().ToLower(); if (YesOrNO == "yes" || YesOrNO == "y") { FileLogic.DeleteDir(FileLogic.SETTINGS_FOLDER); Console.WriteLine(" - FILE RESET -"); FileLogic.CreateDirectory(FileLogic.SETTINGS_FOLDER); } else { Console.WriteLine("- DELETION ABORTED -"); } } else if (choice == 2) { Console.WriteLine(" : Enter material defaults you'd like to clear :"); Display.ShowHeader(); material = Console.ReadLine(); path = FileLogic.MaterialToFilePath(material); if (FileLogic.CheckFileExistance(path) == false) { Display.ShowError("This file doesn't exsist, and so can't be deleted"); } else { Console.WriteLine(" : Are you sure you want to wipe the file (Y/N) : "); string YesOrNO = Console.ReadLine().ToLower(); if (YesOrNO == "yes" || YesOrNO == "y") { FileLogic.DeleteFile(path); Console.WriteLine(" - FILE DELETED -"); } else { Console.WriteLine("- DELETION ABORTED -"); } } } }