/// <summary> /// Validates that the game exists and then runs it with the emulator. /// </summary> /// <param name="gameProfile">Input profile.</param> /// <param name="testMenuString">Command to run test menu.</param> /// <param name="exeName">Test menu exe name.</param> private void ValidateAndRun(GameProfile gameProfile, string testMenuString, string exeName = "") { if (!ValidateGameRun(gameProfile)) { return; } var testMenu = ChkTestMenu.IsChecked; var gameRunning = new GameRunning(gameProfile, testMenu, MainWindow.ParrotData, testMenuString, gameProfile.TestMenuIsExecutable, exeName, false, false, this); Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = gameRunning; }
/// <summary> /// This button actually launches the game selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnLaunchGame(object sender, RoutedEventArgs e) { if (gameList.Items.Count == 0) { return; } var gameProfile = (GameProfile)((ListBoxItem)gameList.SelectedItem).Tag; if (Lazydata.ParrotData.SaveLastPlayed) { Lazydata.ParrotData.LastPlayed = gameProfile.GameName; JoystickHelper.Serialize(); } if (ValidateAndRun(gameProfile, out var loader, out var dll)) { var testMenu = ChkTestMenu.IsChecked; var gameRunning = new GameRunning(gameProfile, loader, dll, testMenu, false, false, this); Application.Current.Windows.OfType <MainWindow>().Single().contentControl.Content = gameRunning; } }
private void Application_Startup(object sender, StartupEventArgs e) { // This fixes the paths when the ui is started through the command line in a different folder Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler((_, ex) => { // give us the exception in english System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); var exceptiontext = (ex.ExceptionObject as Exception).ToString(); MessageBoxHelper.ErrorOK($"TeknoParrotUI ran into an exception!\nPlease send exception.txt to the #teknoparrothelp channel on Discord or create a Github issue!\n{exceptiontext}"); File.WriteAllText("exception.txt", exceptiontext); Environment.Exit(1); }); // Localization testing without changing system language. // Language code list: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR"); //this'll sort dumb stupid tp online gay shit HandleArgs(e.Args); if (!_tpOnline) { if (Process.GetProcessesByName("TeknoParrotUi").Where((p) => p.Id != Process.GetCurrentProcess().Id) .Count() > 0) { if (MessageBoxHelper.ErrorYesNo(TeknoParrotUi.Properties.Resources.ErrorAlreadyRunning)) { TerminateProcesses(); } else { Current.Shutdown(0); return; } } } if (File.Exists("DumbJVSManager.exe")) { MessageBoxHelper.ErrorOK(TeknoParrotUi.Properties.Resources.ErrorOldTeknoParrotDirectory); Current.Shutdown(0); return; } // updater cleanup var bakfiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bak", SearchOption.AllDirectories); foreach (var file in bakfiles) { try { Debug.WriteLine($"Deleting old updater file {file}"); File.Delete(file); } catch { // ignore.. } } // old description file cleanup var olddescriptions = Directory.GetFiles("Descriptions", "*.xml"); foreach (var file in olddescriptions) { try { Debug.WriteLine($"Deleting old description file {file}"); File.Delete(file); } catch { // ignore.. } } JoystickHelper.DeSerialize(); Current.Resources.MergedDictionaries.Clear(); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString($"MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString("MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString($"MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString("MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml")) }); LoadTheme(Lazydata.ParrotData.UiColour, Lazydata.ParrotData.UiDarkMode, Lazydata.ParrotData.UiHolidayThemes); if (Lazydata.ParrotData.UiDisableHardwareAcceleration) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; if (e.Args.Length != 0) { // Process command args if (HandleArgs(e.Args) && Views.Library.ValidateAndRun(_profile, out var loader, out var dll, _emuOnly, null)) { var gamerunning = new Views.GameRunning(_profile, loader, dll, _test, _emuOnly, _profileLaunch); // Args ok, let's do stuff var window = new Window { //f**k you nezarn no more resizing smh /s Title = "GameRunning", Content = gamerunning, MaxWidth = 800, MinWidth = 800, MaxHeight = 800, MinHeight = 800, }; if (_startMin) { window.WindowState = WindowState.Minimized; } // d:DesignHeight="800" d:DesignWidth="800" Loaded="GameRunning_OnLoaded" Unloaded="GameRunning_OnUnloaded"> window.Dispatcher.ShutdownStarted += (x, x2) => gamerunning.GameRunning_OnUnloaded(null, null); window.Show(); return; } } DiscordRPC.StartOrShutdown(); StartApp(); }
private void Application_Startup(object sender, StartupEventArgs e) { // Localization testing without changing system language. // Language code list: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR"); if (SingleApplicationDetector.IsRunning()) { if ((e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.All(x => x != "--emuonly")) || (e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.Any(x => x == "--emuonly"))) { } else { if (MessageBoxHelper.ErrorYesNo(TeknoParrotUi.Properties.Resources.ErrorAlreadyRunning)) { TerminateProcesses(); } else { Current.Shutdown(0); return; } } } if (File.Exists("DumbJVSManager.exe")) { MessageBoxHelper.ErrorOK(TeknoParrotUi.Properties.Resources.ErrorOldTeknoParrotDirectory); Current.Shutdown(0); return; } // updater cleanup var bakfiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bak", SearchOption.AllDirectories); foreach (var file in bakfiles) { try { Debug.WriteLine($"Deleting old updater file {file}"); File.Delete(file); } catch { // ignore.. } } // old description file cleanup var olddescriptions = Directory.GetFiles("Descriptions", "*.xml"); foreach (var file in olddescriptions) { try { Debug.WriteLine($"Deleting old description file {file}"); File.Delete(file); } catch { // ignore.. } } JoystickHelper.DeSerialize(); Current.Resources.MergedDictionaries.Clear(); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString($"MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString("MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString($"MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString("MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml")) }); LoadTheme(Lazydata.ParrotData.UiColour, Lazydata.ParrotData.UiDarkMode, Lazydata.ParrotData.UiHolidayThemes); if (Lazydata.ParrotData.UiDisableHardwareAcceleration) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; if (e.Args.Length != 0) { // Process command args if (HandleArgs(e.Args) && Views.Library.ValidateAndRun(_profile, out var loader, out var dll, _emuOnly)) { var gamerunning = new Views.GameRunning(_profile, loader, dll, _test, _emuOnly, _profileLaunch); // Args ok, let's do stuff var window = new Window { Title = "GameRunning", Content = gamerunning, MaxWidth = 800, MaxHeight = 800, }; // d:DesignHeight="800" d:DesignWidth="800" Loaded="GameRunning_OnLoaded" Unloaded="GameRunning_OnUnloaded"> window.Dispatcher.ShutdownStarted += (x, x2) => gamerunning.GameRunning_OnUnloaded(null, null); window.Show(); return; } } DiscordRPC.StartOrShutdown(); StartApp(); }
private void Application_Startup(object sender, StartupEventArgs e) { if (SingleApplicationDetector.IsRunning()) { if ((e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.All(x => x != "--emuonly")) || (e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.Any(x => x == "--emuonly"))) { } else { if (MessageBox.Show( "TeknoParrot UI seems to already be running, want me to close it?", "Error", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes) { TerminateProcesses(); } else { Current.Shutdown(0); return; } } } if (File.Exists("DumbJVSManager.exe")) { MessageBox.Show( "Seems you have extracted me to directory of old TeknoParrot, please extract me to a new directory instead!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(0); return; } // updater cleanup var bakfiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bak", SearchOption.AllDirectories); foreach (var file in bakfiles) { try { Debug.WriteLine($"Deleting old updater file {file}"); File.Delete(file); } catch { // ignore.. } } // old description file cleanup var olddescriptions = Directory.GetFiles("Descriptions", "*.xml"); foreach (var file in olddescriptions) { try { Debug.WriteLine($"Deleting old description file {file}"); File.Delete(file); } catch { // ignore.. } } JoystickHelper.DeSerialize(); Current.Resources.MergedDictionaries.Clear(); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString($"MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString("MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString($"MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml")) }); Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(GetResourceString("MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml")) }); LoadTheme(Lazydata.ParrotData.UiColour, Lazydata.ParrotData.UiDarkMode); if (Lazydata.ParrotData.UiDisableHardwareAcceleration) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; if (e.Args.Length != 0) { // Process command args if (HandleArgs(e.Args) && Views.Library.ValidateAndRun(_profile, out var loader, out var dll, _emuOnly)) { var gamerunning = new Views.GameRunning(_profile, loader, dll, _test, _emuOnly, _profileLaunch); // Args ok, let's do stuff var window = new Window { Title = "GameRunning", Content = gamerunning, MaxWidth = 800, MaxHeight = 800, }; // d:DesignHeight="800" d:DesignWidth="800" Loaded="GameRunning_OnLoaded" Unloaded="GameRunning_OnUnloaded"> window.Dispatcher.ShutdownStarted += (x, x2) => gamerunning.GameRunning_OnUnloaded(null, null); window.Show(); return; } } DiscordRPC.StartOrShutdown(); StartApp(); }