static public void LoadMonsterData() { MonsterDataDocument = new XmlDocument(); if (UserSettings.PlayerConfig.HunterPie.Debug.LoadCustomMonsterData) { try { MonsterDataDocument.Load(UserSettings.PlayerConfig.HunterPie.Debug.CustomMonsterData); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']")); LoadAilments(); LoadMonsters(); MonsterDataDocument = null; return; } catch (Exception err) { Debugger.Error(err); } } MonsterDataDocument.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HunterPie.Resources/Data/MonsterData.xml")); LoadAilments(); LoadMonsters(); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']")); // Unload XmlDocument since we don't need it anymore MonsterDataDocument = null; }
/* Connection */ public void StartRPC() { if (isOffline) { return; } // Check if connection exists to avoid creating multiple connections Instance = new RichPresence(); Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_CONNECTED']")); Instance.Secrets = new Secrets(); Client = new DiscordRpcClient(APP_ID, autoEvents: true); Client.RegisterUriScheme("582010"); // Events Client.OnReady += Client_OnReady; Client.OnJoinRequested += Client_OnJoinRequested; Client.OnJoin += Client_OnJoin; Client.SetSubscription(EventType.JoinRequest | EventType.Join); Client.Initialize(); if (!UserSettings.PlayerConfig.RichPresence.Enabled && isVisible) { Client?.ClearPresence(); isVisible = false; } }
public void HandlePresence(object source, EventArgs e) { if (Instance == null) { return; } // Do nothing if RPC is disabled if (!isVisible) { return; } if (!FailedToRegisterScheme) { if (ctx.Player.SteamSession != 0 && ctx.Player.InPeaceZone && UserSettings.PlayerConfig.RichPresence.LetPeopleJoinSession) { Instance.Secrets.JoinSecret = $"{ctx.Player.SteamSession}/{ctx.Player.SteamID}"; } else { Instance.Secrets.JoinSecret = null; } } // Only update RPC if player isn't in loading screen switch (ctx.Player.ZoneID) { case 0: Instance.Details = ctx.Player.PlayerAddress == 0 ? GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_MAIN_MENU']") : GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_LOADING_SCREEN']"); Instance.State = null; GenerateAssets("main-menu", null, null, null); Instance.Party = null; break; default: if (ctx.Player.PlayerAddress == 0) { Instance.Details = GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_MAIN_MENU']"); Instance.State = null; GenerateAssets("main-menu", null, null, null); Instance.Party = null; break; } Instance.Details = GetDescription(); Instance.State = GetState(); GenerateAssets(ctx.Player.ZoneName == null ? "main-menu" : $"st{ctx.Player.ZoneID}", ctx.Player.ZoneID == 0 ? null : ctx.Player.ZoneName, ctx.Player.WeaponName == null ? "hunter-rank" : $"weap{ctx.Player.WeaponID}", $"{ctx.Player.Name} | HR: {ctx.Player.Level} | MR: {ctx.Player.MasterRank}"); if (!ctx.Player.InPeaceZone) { MakeParty(ctx.Player.PlayerParty.Size, ctx.Player.PlayerParty.MaxSize, ctx.Player.PlayerParty.PartyHash); } else { MakeParty(ctx.Player.PlayerParty.LobbySize, ctx.Player.PlayerParty.MaxLobbySize, ctx.Player.SteamSession.ToString()); } Instance.Timestamps = NewTimestamp(ctx.Time); break; } Client.SetPresence(Instance); }
private string GetDescription() { // Custom description for special zones switch (ctx.Player.ZoneID) { case 504: return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_TRAINING']")); } if (ctx.Player.InPeaceZone) { return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_TOWN']")); } if (ctx.HuntedMonster == null) { return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_EXPLORING']")); } else { if (string.IsNullOrEmpty(ctx.HuntedMonster.Name)) { return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_EXPLORING']")); } return(UserSettings.PlayerConfig.RichPresence.ShowMonsterHealth ? GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_HUNTING']").Replace("{Monster}", ctx.HuntedMonster.Name).Replace("{Health}", $"{(int)(ctx.HuntedMonster.HPPercentage * 100)}%") : GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_HUNTING']").Replace("{Monster}", ctx.HuntedMonster.Name).Replace("({Health})", null)); } }
public void StartScanning() { ScanPlayerInfoRef = new ThreadStart(GetPlayerInfo); ScanPlayerInfo = new Thread(ScanPlayerInfoRef) { Name = "Scanner_Player" }; Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLAYER_SCANNER_INITIALIZED']")); ScanPlayerInfo.Start(); }
public void StartThreadingScan() { MonsterInfoScanRef = new ThreadStart(ScanMonsterInfo); MonsterInfoScan = new Thread(MonsterInfoScanRef) { Name = $"Scanner_Monster.{MonsterNumber}" }; Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_SCANNER_INITIALIZED']").Replace("{MonsterNumber}", MonsterNumber.ToString())); MonsterInfoScan.Start(); }
public void StopScanning() { Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_GAME_SCANNER_STOP']")); UnhookEvents(); FirstMonster.StopThread(); SecondMonster.StopThread(); ThirdMonster.StopThread(); Player.StopScanning(); ScanGameThreading.Abort(); IsActive = false; }
public void StartScanning() { StartGameScanner(); HookEvents(); Player.StartScanning(); FirstMonster.StartThreadingScan(); SecondMonster.StartThreadingScan(); ThirdMonster.StartThreadingScan(); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_GAME_SCANNER_INITIALIZED']")); IsActive = true; }
private void Client_OnJoinRequested(object sender, DiscordRPC.Message.JoinRequestMessage args) { Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_JOIN_REQUEST']").Replace("{Username}", args.User.ToString())); App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() => { GUI.Widgets.Notification_Widget.DiscordNotify DiscordNotification = new GUI.Widgets.Notification_Widget.DiscordNotify(args); DiscordNotification.OnRequestAccepted += OnDiscordRequestAccepted; DiscordNotification.OnRequestRejected += OnDiscordRequestRejected; DiscordNotification.Show(); })); }
static public void LoadAbnormalityData() { AbnormalitiesData = new XmlDocument(); AbnormalitiesData.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "HunterPie.Resources/Data/AbnormalityData.xml")); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_ABNORMALITIES_DATA_LOAD']")); LoadHuntingHornAbnormalities(); LoadPalicoAbnormalities(); LoadBlightAbnormalities(); LoadMiscAbnormalities(); LoadGearAbnormalities(); // Unload Abnormalities Data since we don't need it anymore AbnormalitiesData = null; }
static public void LoadMonsterData() { MonsterDataDocument = new XmlDocument(); if (UserSettings.PlayerConfig.HunterPie.Debug.LoadCustomMonsterData) { try { MonsterDataDocument.Load(UserSettings.PlayerConfig.HunterPie.Debug.CustomMonsterData); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']")); return; } catch (Exception err) { Debugger.Error(err); } } MonsterDataDocument.LoadXml(Resources.MonsterData); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MONSTER_DATA_LOAD']")); }
private string GetState() { if (ctx.Player.PlayerParty.Size > 1 || ctx.Player.PlayerParty.LobbySize > 1) { if (ctx.Player.InPeaceZone) { return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_LOBBY']")); } else { return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_PARTY']")); } } else { return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_SOLO']")); } }
private void Client_OnReady(object sender, DiscordRPC.Message.ReadyMessage args) { Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_USER_CONNECTED']").Replace("{Username}", args.User.ToString())); }
private void Client_OnJoin(object sender, DiscordRPC.Message.JoinMessage args) { Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_JOINING']")); System.Diagnostics.Process.Start($"steam://joinlobby/582010/{args.Secret}"); Debugger.Debug($"steam://joinlobby/582010/{args.Secret}"); }
/* Dispose */ public void Dispose() { Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_DISCONNECTED']")); Dispose(true); GC.SuppressFinalize(this); }
static public void LoadAbnormalityData() { AbnormalitiesData = new XmlDocument(); AbnormalitiesData.LoadXml(Resources.AbnormalityData); Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_ABNORMALITIES_DATA_LOAD']")); }