public static void Open() { win = EditorWindow.GetWindow <DatabaseEditor>(); win.titleContent = new GUIContent("Database"); win.menu_item = 0; Database.Refresh(); win.Show(); }
private void SelectWindowStartup() { //switch into application modes based on mode enum Logging.Debug("Starting application in {0} mode", CommandLineSettings.ApplicationMode.ToString()); switch (CommandLineSettings.ApplicationMode) { case ApplicationMode.Updater: ModpackToolbox updater = new ModpackToolbox(modpackSettings, Logfiles.Updater) { CommandLineSettings = CommandLineSettings, LaunchedFromMainWindow = false, RunStandAloneUpdateCheck = true }; //close application log if open if (Logging.IsLogOpen(Logfiles.Application)) { CloseApplicationLog(true); } //start updater logging if (!Logging.Init(Logfiles.Updater, modpackSettings.VerboseLogging, true)) { MessageBox.Show("Failed to initialize logfile for updater"); Current.Shutdown((int)ReturnCodes.LogfileError); return; } Logging.WriteHeader(Logfiles.Updater); //redirect application log file to the modpack toolbox if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.Updater)) { Logging.Error(Logfiles.Updater, LogOptions.MethodName, "Failed to redirect messages from application to modpack toolbox"); } //show window updater.Show(); break; case ApplicationMode.Editor: DatabaseEditor editor = new DatabaseEditor(modpackSettings, Logfiles.Editor) { CommandLineSettings = CommandLineSettings, LaunchedFromMainWindow = false, RunStandAloneUpdateCheck = true }; //close application log if open if (Logging.IsLogOpen(Logfiles.Application)) { CloseApplicationLog(true); } //start updater logging if (!Logging.Init(Logfiles.Editor, modpackSettings.VerboseLogging, true)) { MessageBox.Show("Failed to initialize logfile for editor"); Current.Shutdown((int)ReturnCodes.LogfileError); return; } Logging.WriteHeader(Logfiles.Editor); //redirect application log file to the editor if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.Editor)) { Logging.Error(Logfiles.Editor, LogOptions.MethodName, "Failed to redirect messages from application to editor"); } //show window editor.Show(); break; case ApplicationMode.PatchDesigner: PatchDesigner patcher = new PatchDesigner(modpackSettings, Logfiles.PatchDesigner) { CommandLineSettings = CommandLineSettings, LaunchedFromMainWindow = false, RunStandAloneUpdateCheck = true }; //close application log if open if (Logging.IsLogOpen(Logfiles.Application)) { CloseApplicationLog(true); } //start updater logging if (!Logging.Init(Logfiles.PatchDesigner, modpackSettings.VerboseLogging, true)) { MessageBox.Show("Failed to initialize logfile for patcher"); Current.Shutdown((int)ReturnCodes.LogfileError); return; } Logging.WriteHeader(Logfiles.PatchDesigner); //redirect application log file to the patch designer if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.PatchDesigner)) { Logging.Error(Logfiles.PatchDesigner, LogOptions.MethodName, "Failed to redirect messages from application to patch designer"); } //show window patcher.Show(); break; case ApplicationMode.AutomationRunner: DatabaseAutomationRunner automationRunner = new DatabaseAutomationRunner(modpackSettings, Logfiles.AutomationRunner) { CommandLineSettings = CommandLineSettings, LaunchedFromMainWindow = false, RunStandAloneUpdateCheck = true }; //close application log if open if (Logging.IsLogOpen(Logfiles.Application)) { CloseApplicationLog(true); } //start DatabaseAutomationRunner logging if (!Logging.Init(Logfiles.AutomationRunner, modpackSettings.VerboseLogging, true)) { MessageBox.Show("Failed to initialize logfile for DatabaseAutomationRunner"); Current.Shutdown((int)ReturnCodes.LogfileError); return; } Logging.WriteHeader(Logfiles.AutomationRunner); //redirect application log file to the automation runner if (!Logging.RedirectLogOutput(Logfiles.Application, Logfiles.AutomationRunner)) { Logging.Error(Logfiles.AutomationRunner, LogOptions.MethodName, "Failed to redirect messages from application to automation runner"); } //show window automationRunner.Show(); break; case ApplicationMode.Patcher: //check that at least one patch file was specified from command line if (CommandLineSettings.PatchFilenames.Count == 0) { Logging.Error("0 patch files parsed from command line!"); Current.Shutdown((int)ReturnCodes.PatcherNoSpecifiedFiles); Environment.Exit((int)ReturnCodes.PatcherNoSpecifiedFiles); } else { //parse patch objects from command line file list List <Instruction> patchList = new List <Instruction>(); InstructionLoader loader = new InstructionLoader(); foreach (string file in CommandLineSettings.PatchFilenames) { if (!File.Exists(file)) { Logging.Warning("Skipping file path {0}, not found", file); continue; } Logging.Info("Adding patches from file {0}", file); loader.AddInstructionObjectsToList(file, patchList, InstructionsType.Patch, Patch.PatchXmlSearchPath); } //check for at least one patchfile was parsed if (patchList.Count == 0) { Logging.Error("0 patches parsed from files!"); Current.Shutdown((int)ReturnCodes.PatcherNoPatchesParsed); Environment.Exit((int)ReturnCodes.PatcherNoPatchesParsed); } //set default patch return code PatcherExitCode = PatchExitCode.Success; //always return on worst condition int i = 1; //TODO: does WoTDirectory get set later? maybe tm? Patcher thePatcher = new Patcher() { WoTDirectory = null }; foreach (Patch p in patchList) { Logging.Info("Running patch {0} of {1}", i++, patchList.Count); PatchExitCode exitCodeTemp = thePatcher.RunPatchFromCommandline(p); if ((int)exitCodeTemp < (int)PatcherExitCode) { PatcherExitCode = exitCodeTemp; } } } break; case ApplicationMode.Default: MainWindow window = new MainWindow(modpackSettings) { CommandLineSettings = CommandLineSettings }; window.Show(); break; } }