public MainWindow() { InitializeComponent(); var p = ConsoleTextBox.Document.Blocks.FirstBlock as Paragraph; ConsoleTextBox.Document.Blocks.Clear(); config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); context = new UserDataContext(DialogCoordinator.Instance, config); DataContext = context; config.PropertyChanged += ConfigOnPropertyChanged; App.handler.OnReady += (sender, args) => { App.socket.AddHandler(App.handler); }; if (context.Settings.discordToken != "") { Task.Factory.StartNew(() => { Thread.Sleep(2000); App.handler.Init(context.Settings.discordToken); }); } else { Task.Factory.StartNew(() => { Thread.Sleep(2000); WriteConsoleLineFormatted("Discord", Color.Red, "You do not have a self-host discord token set. Enabling this in settings will increase performance."); }); } GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; IPCAdapter.getInstance().OnToken += (sender, token) => { this.BeginInvoke((w) => { if (!w.IsVisible) { w.Show(); } if (w.WindowState == WindowState.Minimized) { w.WindowState = WindowState.Normal; } w.Activate(); w.Topmost = true; // important w.Topmost = false; // important w.Focus(); // important w.Activate(); }); }; //ApplyDarkMode(); }
private async void ReloadOffsetsButton_OnClick(object sender, RoutedEventArgs e) { GameMemReader.getInstance().offMan.refreshLocal(); await GameMemReader.getInstance().offMan.RefreshIndex(); GameMemReader.getInstance().CurrentOffsets = GameMemReader.getInstance().offMan .FetchForHash(GameMemReader.getInstance().GameHash); if (GameMemReader.getInstance().CurrentOffsets is not null) { WriteConsoleLineFormatted("GameMemReader", Color.Lime, $"Loaded offsets: {GameMemReader.getInstance().CurrentOffsets.Description}"); } else { WriteConsoleLineFormatted("GameMemReader", Color.Lime, $"No offsets found for: {Color.Aqua.ToTextColor()}{GameMemReader.getInstance().GameHash.ToString()}."); } }
static void Main(string[] args) { Console.WriteLine(Process.GetCurrentProcess().MainModule.ModuleName); var uriStart = IPCAdapter.getInstance().HandleURIStart(args); switch (uriStart) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } var foreverTask = Task.Factory.StartNew(() => { IPCAdapter.getInstance().OnToken += OnTokenHandler; var socketTask = Task.Factory.StartNew(() => socket.Init()); // run socket in background. Important to wait for init to have actually finished before continuing GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().GameOver += OnGameOver; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; var gameReader = Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background socketTask.Wait(); IPCAdapter.getInstance().RegisterMinion(); Settings.conInterface = new ConsoleLogger(); if (uriStart == URIStartResult.PARSE) { IPCAdapter.getInstance().SendToken(args[0]); } gameReader.Wait(); }); foreverTask.Wait(); }
public MainWindow() { InitializeComponent(); var p = ConsoleTextBox.Document.Blocks.FirstBlock as Paragraph; ConsoleTextBox.Document.Blocks.Clear(); config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); context = new UserDataContext(DialogCoordinator.Instance, config); DataContext = context; config.PropertyChanged += ConfigOnPropertyChanged; GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; //ApplyDarkMode(); }
public MainWindow() { InitializeComponent(); var p = ConsoleTextBox.Document.Blocks.FirstBlock as Paragraph; ConsoleTextBox.Document.Blocks.Clear(); config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); context = new UserDataContext(DialogCoordinator.Instance, config); DataContext = context; config.PropertyChanged += ConfigOnPropertyChanged; GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().DisplayImposter += UserForm_DisplayImposter; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; IPCAdapter.getInstance().OnToken += (sender, token) => { this.BeginInvoke((w) => { if (!w.IsVisible) { w.Show(); } if (w.WindowState == WindowState.Minimized) { w.WindowState = WindowState.Normal; } w.Activate(); w.Topmost = true; // important w.Topmost = false; // important w.Focus(); // important w.Activate(); }); }; //ApplyDarkMode(); }
public MainWindow() { InitializeComponent(); var p = ConsoleTextBox.Document.Blocks.FirstBlock as Paragraph; ConsoleTextBox.Document.Blocks.Clear(); config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); context = new UserDataContext(DialogCoordinator.Instance, config); DataContext = context; config.PropertyChanged += ConfigOnPropertyChanged; App.handler.OnReady += (sender, args) => { App.socket.AddHandler(App.handler); }; if (context.Settings.discordToken != "") { Task.Factory.StartNew(() => { Thread.Sleep(2000); App.handler.Init(context.Settings.discordToken); }); } else { Task.Factory.StartNew(() => { Thread.Sleep(2000); WriteConsoleLineFormatted("Discord", Color.Red, "You do not have a self-host discord token set. Enabling this in settings will increase performance."); }); } GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; GameMemReader.getInstance().GameOver += OnGameOver; IPCAdapter.getInstance().OnToken += (sender, token) => { this.BeginInvoke((w) => { if (!w.context.Settings.FocusOnToken) { return; } if (!w.IsVisible) { w.Show(); } if (w.WindowState == WindowState.Minimized) { w.WindowState = WindowState.Normal; } w.Activate(); w.Focus(); // important }); }; Version version = new Version(context.Version); Version latestVersion = new Version(context.LatestVersion); if (latestVersion.CompareTo(version) > 0) { this.ShowMessageAsync("Caution", $"We've detected you're using an older version of AmongUsCapture!\nYour version: {version}\nLatest version: {latestVersion}", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Download", NegativeButtonText = "No thanks", DefaultButtonFocus = MessageDialogResult.Affirmative }).ContinueWith( task => { if (task.Result == MessageDialogResult.Affirmative) { OpenBrowser(@"https://github.com/denverquane/amonguscapture/releases/latest/"); } }); } //ApplyDarkMode(); }
public MainWindow() { InitializeComponent(); string appFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); string appName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName); string appExtension = Path.GetExtension(Process.GetCurrentProcess().MainModule.FileName); string archivePath = Path.Combine(appFolder, appName + "_Old" + appExtension); if (File.Exists(archivePath)) { Updated = true; try { //Will wait for the other program to exit. var me = Process.GetCurrentProcess(); Process[] aProcs = Process.GetProcessesByName(me.ProcessName); aProcs = aProcs.Where(x => x.Id != me.Id).ToArray(); if (aProcs != null && aProcs.Length > 0) { aProcs[0].WaitForExit(1000); } File.Delete(archivePath); } catch (Exception e) { Console.WriteLine("Could not delete old file."); } } else { Updated = false; } Paragraph p = ConsoleTextBox.Document.Blocks.FirstBlock as Paragraph; ConsoleTextBox.Document.Blocks.Clear(); try { config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); } catch (Newtonsoft.Json.JsonReaderException e) //Delete file and recreate config { Console.WriteLine($"Bad config. Clearing."); File.Delete(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")); config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); } context = new UserDataContext(DialogCoordinator.Instance, config); DataContext = context; config.PropertyChanged += ConfigOnPropertyChanged; App.handler.OnReady += (sender, args) => { App.socket.AddHandler(App.handler); }; GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; GameMemReader.getInstance().GameOver += OnGameOver; IPCAdapter.getInstance().OnToken += (sender, token) => { this.BeginInvoke((w) => { if (!w.context.Settings.FocusOnToken) { return; } if (!w.IsVisible) { w.Show(); } if (w.WindowState == WindowState.Minimized) { w.WindowState = WindowState.Normal; } w.Activate(); w.Focus(); // important }); }; if (!context.Settings.discordTokenEncrypted) //Encrypt discord token if it is not encrypted. { context.Settings.discordToken = JsonConvert.SerializeObject(encryptToken(context.Settings.discordToken)); context.Settings.discordTokenEncrypted = true; } byte[] encryptedBuff = JsonConvert.DeserializeObject <byte[]>(context.Settings.discordToken); discordTokenBox.Password = decryptToken(encryptedBuff); System.Windows.Media.Color savedColor; try { savedColor = JsonConvert.DeserializeObject <System.Windows.Media.Color>(context.Settings.SelectedAccent); AccentColorPicker.SelectedColor = savedColor; string BaseColor; if (context.Settings.DarkMode) { BaseColor = ThemeManager.BaseColorDark; } else { BaseColor = ThemeManager.BaseColorLight; } Theme newTheme = new Theme(name: "CustomTheme", displayName: "CustomTheme", baseColorScheme: BaseColor, colorScheme: "CustomAccent", primaryAccentColor: savedColor, showcaseBrush: new SolidColorBrush(savedColor), isRuntimeGenerated: true, isHighContrast: false); ThemeManager.Current.ChangeTheme(this, newTheme); } catch (Exception e) { } //ApplyDarkMode(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); SetupLoggingConfig(); var args = e.Args; // needs to be the first call in the program to prevent weird bugs if (Settings.PersistentSettings.debugConsole) { AllocConsole(); } var uriStart = IPCAdapter.getInstance().HandleURIStart(e.Args); switch (uriStart) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {e.Args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } Console.WriteLine(string.Join(", ", Assembly.GetExecutingAssembly().GetManifestResourceNames())); //Gets all the embedded resources try { config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); } catch (JsonReaderException) //Delete file and recreate config { Console.WriteLine("Bad config. Clearing."); File.Delete(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")); config = new ConfigurationBuilder <IAppSettings>() .UseJsonFile(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "\\AmongUsCapture\\AmongUsGUI", "Settings.json")).Build(); } var r = new Random(); var rValue = r.Next(101); var goingToPop = rValue == 1; var goingToDouche = rValue == 2; var goingToMonke = rValue == 3; if (!config.startupMemes || (!goingToPop && !goingToDouche && !goingToMonke)) { if (DateTime.Now.Month == 12) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenChristmas.png").Show(true); } else { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenNormal.png").Show(true); } //Console.WriteLine(string.Join(", ",Assembly.GetExecutingAssembly().GetManifestResourceNames())); //Gets all the embedded resources } else if (goingToPop) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenPop.png").Show(true); PlaySound("https://cdn.automute.us/Eggs/popcat.wav"); } else if (goingToDouche) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenDouche.png").Show(true); PlaySound("https://cdn.automute.us/Eggs/douchebag.wav"); } else { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenMonke.png").Show(true); PlaySound("https://cdn.automute.us/Eggs/stinky.wav"); } var mainWindow = new MainWindow(); this.MainWindow = mainWindow; IPCAdapter.getInstance().OnToken += OnTokenHandler; socket.Init(); IPCAdapter.getInstance().RegisterMinion(); mainWindow.Loaded += (sender, args2) => { Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background if (uriStart == URIStartResult.PARSE) { IPCAdapter.getInstance().SendToken(args[0]); } }; mainWindow.Closing += (sender, args2) => { Environment.Exit(0); }; mainWindow.Show(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var args = e.Args; ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll; ThemeManager.Current.SyncTheme(); // needs to be the first call in the program to prevent weird bugs if (Settings.PersistentSettings.debugConsole) { AllocConsole(); } var uriStart = IPCAdapter.getInstance().HandleURIStart(e.Args); switch (uriStart) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {e.Args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } Console.WriteLine(string.Join(", ", Assembly.GetExecutingAssembly().GetManifestResourceNames())); //Gets all the embedded resources var r = new Random(); var rValue = r.Next(101); var goingToPop = rValue <= 3; var goingToDouche = rValue == 4; var goingToMonke = rValue <= 7 && rValue > 4; if (!goingToPop && !goingToDouche && !goingToMonke) { if (DateTime.Now.Month == 12) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenChristmas.png").Show(true); } else { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenNormal.png").Show(true); } //Console.WriteLine(string.Join(", ",Assembly.GetExecutingAssembly().GetManifestResourceNames())); //Gets all the embedded resources } else if (goingToPop) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenPop.png").Show(true); PlaySound("https://cdn.automute.us/Eggs/popcat.wav"); } else if (goingToDouche) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenDouche.png").Show(true); PlaySound("https://cdn.automute.us/Eggs/douchebag.wav"); } else { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenMonke.png").Show(true); PlaySound("https://cdn.automute.us/Eggs/stinky.wav"); } var mainWindow = new MainWindow(); this.MainWindow = mainWindow; Settings.conInterface = new WPFLogger(mainWindow); IPCAdapter.getInstance().OnToken += OnTokenHandler; socket.Init(); IPCAdapter.getInstance().RegisterMinion(); mainWindow.Loaded += (sender, args2) => { Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background if (uriStart == URIStartResult.PARSE) { IPCAdapter.getInstance().SendToken(args[0]); } }; mainWindow.Closing += (sender, args2) => { Environment.Exit(0); }; mainWindow.Show(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var args = e.Args; ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll; ThemeManager.Current.SyncTheme(); // needs to be the first call in the program to prevent weird bugs if (Settings.PersistentSettings.debugConsole) { AllocConsole(); } var uriStart = IPCAdapter.getInstance().HandleURIStart(e.Args); switch (uriStart) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {e.Args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } var splashScreen = new SplashScreenWindow(); this.MainWindow = splashScreen; splashScreen.Show(); Task.Factory.StartNew(() => { this.Dispatcher.Invoke(() => { //initialize the main window, set it as the application main window //and close the splash screen var mainWindow = new MainWindow(); this.MainWindow = mainWindow; Settings.conInterface = new WPFLogger(mainWindow); IPCAdapter.getInstance().OnToken += OnTokenHandler; var socketTask = Task.Factory.StartNew(() => socket.Init()); // run socket in background. Important to wait for init to have actually finished before continuing socketTask.Wait(); IPCAdapter.getInstance().RegisterMinion(); mainWindow.Loaded += (sender, args2) => { Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background if (uriStart == URIStartResult.PARSE) { IPCAdapter.getInstance().SendToken(args[0]); } }; mainWindow.Closing += (sender, args2) => { Environment.Exit(0); }; mainWindow.Show(); splashScreen.Close(); }); }); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var args = e.Args; ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll; ThemeManager.Current.SyncTheme(); // needs to be the first call in the program to prevent weird bugs if (Settings.PersistentSettings.debugConsole) { AllocConsole(); } var uriStart = IPCAdapter.getInstance().HandleURIStart(e.Args); switch (uriStart) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {e.Args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } Console.WriteLine(string.Join(", ", Assembly.GetExecutingAssembly().GetManifestResourceNames())); //Gets all the embedded resources var r = new Random(); var goingToPop = r.Next(101) < 5; if (!goingToPop) { if (DateTime.Now.Month == 12) { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenChristmas.png").Show(true); } else { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenNormal.png").Show(true); } //Console.WriteLine(string.Join(", ",Assembly.GetExecutingAssembly().GetManifestResourceNames())); //Gets all the embedded resources } else { new SplashScreen(Assembly.GetExecutingAssembly(), "SplashScreens\\SplashScreenPop.png").Show(true); try { var req = System.Net.WebRequest.Create( "https://github.com/denverquane/amonguscapture/raw/master/AUCapture-WPF/SplashScreens/popcat.wav"); using (Stream stream = req.GetResponse().GetResponseStream()) { SoundPlayer myNewSound = new SoundPlayer(stream); myNewSound.Load(); myNewSound.Play(); } } catch (Exception errrr) { Console.WriteLine("Minor error"); } } var mainWindow = new MainWindow(); this.MainWindow = mainWindow; Settings.conInterface = new WPFLogger(mainWindow); IPCAdapter.getInstance().OnToken += OnTokenHandler; socket.Init(); IPCAdapter.getInstance().RegisterMinion(); mainWindow.Loaded += (sender, args2) => { Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background if (uriStart == URIStartResult.PARSE) { IPCAdapter.getInstance().SendToken(args[0]); } }; mainWindow.Closing += (sender, args2) => { Environment.Exit(0); }; mainWindow.Show(); }