public void OnGameClose(object source, EventArgs e) { UnhookGameEvents(); Discord.Dispose(); Discord = null; if (UserSettings.PlayerConfig.HunterPie.Options.CloseWhenGameCloses) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { this.Close(); })); } MonsterHunter.StopScanning(); Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { GameOverlay.Dispose(); GameOverlay = null; })); MonsterHunter.DestroyInstances(); }
public void OnGameStart(object source, EventArgs e) { // Create game instances MonsterHunter.CreateInstances(); // Hook game events HookGameEvents(); // Creates new overlay Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { if (GameOverlay == null) { GameOverlay = new Overlay(MonsterHunter); GameOverlay.HookEvents(); UserSettings.TriggerSettingsEvent(); } })); // Loads memory map if (Address.LoadMemoryMap(Scanner.GameVersion) || Scanner.GameVersion == Address.GAME_VERSION) { Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MAP_LOAD']").Replace("{HunterPie_Map}", $"'MonsterHunterWorld.{Scanner.GameVersion}.map'")); } else { Debugger.Error(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_GAME_VERSION_UNSUPPORTED']").Replace("{GAME_VERSION}", $"{Scanner.GameVersion}")); return; } // Starts scanning MonsterHunter.StartScanning(); // Initializes rich presence if (Discord == null) { Discord = new Presence(MonsterHunter); if (this.OfflineMode) { Discord.SetOfflineMode(); } Discord.StartRPC(); } }