private async void Command_Run(object sender, ExecutedRoutedEventArgs e) { if (Data == null) { return; } RuntimePicker picker = new RuntimePicker(); picker.Owner = this; var runtime = picker.Pick(FilePath, Data); if (runtime == null) { return; } bool origDbg = Data.GeneralInfo.DisableDebugger; Data.GeneralInfo.DisableDebugger = true; bool saveOk = true; if (MessageBox.Show("Save changes first?", "UndertaleModTool", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { saveOk = await DoSaveDialog(); } if (saveOk) { Process.Start(runtime.Path, "-game \"" + FilePath + "\" -debugoutput \"" + System.IO.Path.ChangeExtension(FilePath, ".gamelog.txt") + "\""); } Data.GeneralInfo.DisableDebugger = origDbg; }
private async void Window_Loaded(object sender, RoutedEventArgs e) { try { var HKCU_Classes = Registry.CurrentUser.OpenSubKey(@"Software\Classes", true); var UndertaleModTool_app = HKCU_Classes.CreateSubKey(@"UndertaleModTool"); UndertaleModTool_app.SetValue("", "UndertaleModTool"); UndertaleModTool_app.CreateSubKey(@"shell\open\command").SetValue("", "\"" + Assembly.GetExecutingAssembly().Location + "\" \"%1\"", RegistryValueKind.String); UndertaleModTool_app.CreateSubKey(@"shell\launch\command").SetValue("", "\"" + Assembly.GetExecutingAssembly().Location + "\" \"%1\" launch", RegistryValueKind.String); UndertaleModTool_app.CreateSubKey(@"shell\launch").SetValue("", "Run game", RegistryValueKind.String); foreach (var extStr in new string[] { ".win", ".unx", ".ios" }) { var ext = HKCU_Classes.CreateSubKey(extStr); ext.SetValue("", "UndertaleModTool", RegistryValueKind.String); } SHChangeNotify(SHCNE_ASSOCCHANGED, 0, IntPtr.Zero, IntPtr.Zero); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } var args = Environment.GetCommandLineArgs(); if (args.Length > 1) { var fileName = args[1]; if (File.Exists(fileName)) { await LoadFile(fileName); } } if (args.Length > 2) { if (args[2] == "launch") { RuntimePicker picker = new RuntimePicker(); picker.Owner = this; var runtime = picker.Pick(FilePath, Data); if (runtime == null) { return; } Process.Start(runtime.Path, "-game \"" + FilePath + "\""); Close(); } else { ListenChildConnection(args[2]); } } }
private async void Command_RunDebug(object sender, ExecutedRoutedEventArgs e) { if (Data == null) { return; } RuntimePicker picker = new RuntimePicker(); picker.Owner = this; var runtime = picker.Pick(FilePath, Data); if (runtime == null) { return; } if (runtime.DebuggerPath == null) { MessageBox.Show("The selected runtime does not support debugging.", "Run error", MessageBoxButton.OK, MessageBoxImage.Error); return; } bool origDbg = Data.GeneralInfo.DisableDebugger; Data.GeneralInfo.DisableDebugger = false; if (await DoSaveDialog()) { string tempProject = System.IO.Path.GetTempFileName().Replace(".tmp", ".gmx"); File.WriteAllText(tempProject, @"<!-- Without this file the debugger crashes, but it doesn't actually need to contain anything! --> <assets> <Configs name=""configs""> <Config>Configs\Default</Config> </Configs> <NewExtensions/> <sounds name=""sound""/> <sprites name=""sprites""/> <backgrounds name=""background""/> <paths name=""paths""/> <objects name=""objects""/> <rooms name=""rooms""/> <help/> <TutorialState> <IsTutorial>0</IsTutorial> <TutorialName></TutorialName> <TutorialPage>0</TutorialPage> </TutorialState> </assets>"); Process.Start(runtime.Path, "-game \"" + FilePath + "\" -debugoutput \"" + System.IO.Path.ChangeExtension(FilePath, ".gamelog.txt") + "\""); Process.Start(runtime.DebuggerPath, "-d=\"" + System.IO.Path.ChangeExtension(FilePath, ".yydebug") + "\" -t=\"127.0.0.1\" -tp=" + Data.GeneralInfo.DebuggerPort + " -p=\"" + tempProject + "\""); } Data.GeneralInfo.DisableDebugger = origDbg; }