Пример #1
0
        private async void DownloadPlugin()
        {
            IsBusy = true;
            try
            {
                var moduleContent = await http.GetStringAsync(entry.Module);

                var modulePath = await Hunterpie.Instance.InstallPlugin(moduleContent);

#if !DEBUG
                // we don't actually care if this request is failed, nor interested in value, so we will not await it
                _ = PluginRegistryService.Instance.ReportInstall(entry.InternalName);
#endif
                DownloadReadme(modulePath);

                // when plugin is installed, we can open it's directory
                openDirAction = new PluginActionViewModel(
                    GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_DIRECTORY']"),
                    Application.Current.FindResource("ICON_FOLDER") as ImageSource,
                    new ArglessRelayCommand(() => Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                                             "modules", this.InternalName)))
                    );
                this.Actions.Insert(0, openDirAction);

                pluginList.UpdatePluginsArrangement();

                OnPropertyChanged(nameof(CanDelete));
                OnPropertyChanged(nameof(CanInstall));
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
 private string GetDescription()
 {
     if (ctx is null || ctx?.Player is null || IsDisposed)
     {
         return("");
     }
     // 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) || ctx.HuntedMonster?.Name == "Missing Translation")
         {
             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));
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        public static string FormatLongDate(DateTime?dateTime)
        {
            if (dateTime == null)
            {
                return(null);
            }

            var    diffDate = DateTime.Now.Subtract(dateTime.Value);
            string diffStr;

            if (diffDate.TotalDays >= 1)
            {
                diffStr = GStrings
                          .GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_LAST_UPDATE_STRING_DAYS_PART']")
                          .Replace("{DaysAgo}", ((int)diffDate.TotalDays).ToString());
            }
            else
            {
                diffStr = GStrings
                          .GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_LAST_UPDATE_STRING_HOURS_PART']")
                          .Replace("{HoursAgo}", ((int)diffDate.TotalHours).ToString());
            }

            return(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_LAST_UPDATE_STRING']")
                   .Replace("{UpdateTime}", dateTime.Value.ToLongDateString())
                   .Replace("{TimeAgo}", diffStr));
        }
Пример #5
0
 private void PopulateMonsterBox()
 {
     MonsterShowModeSelection.Items.Add(GStrings.GetLocalizationByXPath("/Settings/String[@ID='STATIC_MONSTER_BAR_MODE_0']"));
     MonsterShowModeSelection.Items.Add(GStrings.GetLocalizationByXPath("/Settings/String[@ID='STATIC_MONSTER_BAR_MODE_1']"));
     MonsterShowModeSelection.Items.Add(GStrings.GetLocalizationByXPath("/Settings/String[@ID='STATIC_MONSTER_BAR_MODE_2']"));
     MonsterShowModeSelection.Items.Add(GStrings.GetLocalizationByXPath("/Settings/String[@ID='STATIC_MONSTER_BAR_MODE_3']"));
 }
Пример #6
0
 private void LoadCustomTheme()
 {
     if (UserSettings.PlayerConfig.HunterPie.Theme == null || UserSettings.PlayerConfig.HunterPie.Theme == "Default")
     {
         return;
     }
     if (!Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Themes")))
     {
         Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Themes"));
     }
     if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@"Themes/{UserSettings.PlayerConfig.HunterPie.Theme}")))
     {
         Debugger.Error(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_THEME_NOT_FOUND_ERROR']".Replace("{THEME_NAME}", UserSettings.PlayerConfig.HunterPie.Theme)));
         return;
     }
     try {
         using (FileStream stream = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@"Themes/{UserSettings.PlayerConfig.HunterPie.Theme}"), FileMode.Open)) {
             XamlReader         reader          = new XamlReader();
             ResourceDictionary ThemeDictionary = (ResourceDictionary)reader.LoadAsync(stream);
             Application.Current.Resources.MergedDictionaries.Add(ThemeDictionary);
             Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_THEME_LOAD_WARN']"));
         }
     } catch (Exception err) {
         Debugger.Error($"{GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_THEME_NOT_LOAD_ERROR']")}\n{err}");
     }
 }
Пример #7
0
 private void argsTextBox_LostFocus(object sender, System.Windows.RoutedEventArgs e)
 {
     if (argsTextBox.Text == "")
     {
         argsTextBox.Text = GStrings.GetLocalizationByXPath("/Settings/String[@ID='STATIC_LAUNCHARGS_NOARGS']");
     }
 }
Пример #8
0
 private void OnReady(object sender, ReadyMessage args)
 {
     Debugger.Discord(
         GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_USER_CONNECTED']")
         .Replace("{Username}", args.User.ToString())
         );
 }
Пример #9
0
 private void PopulateProxyModeBox()
 {
     foreach (PluginProxyMode item in Enum.GetValues(typeof(PluginProxyMode)))
     {
         comboPluginUpdateProxy.Items.Add(
             GStrings.GetLocalizationByXPath($"/Settings/String[@ID='PLUGIN_PROXY_MODE_{item.ToString("G").ToUpperInvariant()}']"));
     }
 }
Пример #10
0
 private void PopulatePlotDisplayModeBox()
 {
     foreach (DamagePlotMode item in Enum.GetValues(typeof(DamagePlotMode)))
     {
         comboDamagePlotMode.Items.Add(
             GStrings.GetLocalizationByXPath($"/Settings/String[@ID='DAMAGE_PLOT_MODE_{(byte)item}']"));
     }
 }
Пример #11
0
 private void PopulateMonsterBox()
 {
     for (int i = 0; i < 5; i++)
     {
         MonsterShowModeSelection.Items.Add(
             GStrings.GetLocalizationByXPath($"/Settings/String[@ID='STATIC_MONSTER_BAR_MODE_{i}']"));
     }
 }
Пример #12
0
        public Hunterpie()
        {
            if (CheckIfHunterPieOpen())
            {
                Close();
                return;
            }

            AppDomain.CurrentDomain.UnhandledException += ExceptionLogger;

            SetDPIAwareness();

            Buffers.Initialize(1024);
            Buffers.Add <byte>(64);

            // Initialize debugger and player config
            Debugger.InitializeDebugger();
            UserSettings.InitializePlayerConfig();

            // Initialize localization
            GStrings.InitStrings(UserSettings.PlayerConfig.HunterPie.Language);

            // Load custom theme and console colors
            LoadCustomTheme();
            Debugger.LoadNewColors();

            InitializeComponent();

            OpenDebugger();
            // Initialize everything under this line
            if (!CheckIfUpdateEnableAndStart())
            {
                return;
            }

            Width  = UserSettings.PlayerConfig.HunterPie.Width;
            Height = UserSettings.PlayerConfig.HunterPie.Height;

            // Convert the old HotKey to the new one
            ConvertOldHotkeyToNew(UserSettings.PlayerConfig.Overlay.ToggleDesignModeKey);

            IsUpdating = false;
            InitializeTrayIcon();

            // Update version text
            this.version_text.Text = GStrings.GetLocalizationByXPath("/Console/String[@ID='CONSOLE_VERSION']").Replace("{HunterPie_Version}", HUNTERPIE_VERSION).Replace("{HunterPie_Branch}", UserSettings.PlayerConfig.HunterPie.Update.Branch);

            // Initializes the rest of HunterPie
            LoadData();
            Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_HUNTERPIE_INITIALIZED']"));

            BUTTON_UPLOADBUILD.IsEnabled = false;
            BUTTON_UPLOADBUILD.Opacity   = 0.5;

            SetHotKeys();
            StartEverything();
        }
Пример #13
0
        private void OnCloseWindowButtonClick(object sender, MouseButtonEventArgs e)
        {
            // X button function;
            bool ExitConfirmation = MessageBox.Show(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_QUIT']"), "HunterPie", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;

            if (ExitConfirmation)
            {
                Close();
            }
        }
Пример #14
0
 private bool CheckIfUpdateEnableAndStart()
 {
     if (UserSettings.PlayerConfig.HunterPie.Update.Enabled)
     {
         bool     justUpdated   = false;
         bool     latestVersion = false;
         string[] args          = Environment.GetCommandLineArgs();
         foreach (string argument in args)
         {
             if (argument.StartsWith("justUpdated"))
             {
                 string parsed = ParseArgs(argument);
                 justUpdated = parsed == "True";
             }
             if (argument.StartsWith("latestVersion"))
             {
                 string parsed = ParseArgs(argument);
                 latestVersion = parsed == "True";
             }
             if (argument.StartsWith("offlineMode"))
             {
                 OfflineMode = ParseArgs(argument) == "True";
             }
         }
         if (justUpdated)
         {
             OpenChangelog();
             return(true);
         }
         if (latestVersion)
         {
             return(true);
         }
         Debugger.Log("Updating updater.exe");
         // This will update Update.exe
         AutoUpdate au = new AutoUpdate(UserSettings.PlayerConfig.HunterPie.Update.Branch);
         au.Instance.DownloadFileCompleted += OnUpdaterDownloadComplete;
         OfflineMode = au.offlineMode;
         if (!au.CheckAutoUpdate() && !au.offlineMode)
         {
             HandleUpdaterUpdate();
         }
         else
         {
             return(true);
         }
         Hide();
         return(false);
     }
     else
     {
         Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_AUTOUPDATE_DISABLED_WARN']"));
         return(true);
     }
 }
Пример #15
0
 private void LaunchGame()
 {
     try {
         Process createGameProcess = new Process();
         createGameProcess.StartInfo.FileName  = "steam://run/582010";
         createGameProcess.StartInfo.Arguments = UserSettings.PlayerConfig.HunterPie.Launch.LaunchArgs;
         createGameProcess.Start();
     } catch (Exception err) {
         Debugger.Error($"{GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_LAUNCH_ERROR']")}\n{err.ToString()}");
     }
 }
Пример #16
0
 private void OnUpdaterDownloadComplete(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
 {
     if (e.Error != null)
     {
         Debugger.Error(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_UPDATE_ERROR']"));
         Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_OFFLINEMODE_WARN']"));
         this.OfflineMode = true;
         return;
     }
     HandleUpdaterUpdate();
 }
Пример #17
0
 private void LaunchGame()
 {
     try {
         ProcessStartInfo GameStartInfo = new ProcessStartInfo {
             FileName        = "steam://run/582010",
             Arguments       = UserSettings.PlayerConfig.HunterPie.Launch.LaunchArgs,
             UseShellExecute = true
         };
         Process.Start(GameStartInfo);
     } catch (Exception err) {
         Debugger.Error($"{GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_LAUNCH_ERROR']")}\n{err}");
     }
 }
Пример #18
0
        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();
            }));
        }
Пример #19
0
        /* 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();

            try
            {
                Client = new DiscordRpcClient(AppId, autoEvents: true);
            } catch (Exception err)
            {
                Debugger.Error($"Failed to create Rich Presence connection:\n{err}");
                return;
            }


            try
            {
                Client.RegisterUriScheme("582010");
            }
            catch (Exception err)
            {
                Debugger.Error(err);
                FailedToRegisterScheme = true;
            }

            if (!FailedToRegisterScheme)
            {
                // 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;
            }
        }
Пример #20
0
        private void OnLaunchGameButtonClick(object sender, RoutedEventArgs e)
        {
            // Shorten the class name
            var launchOptions = UserSettings.PlayerConfig.HunterPie.Launch;

            if (launchOptions.GamePath == "")
            {
                if (MessageBox.Show(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MISSING_PATH']"), GStrings.GetLocalizationByXPath("/Console/String[@ID='TITLE_MISSING_PATH']"), MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
                {
                    OpenSettings();
                }
            }
            else
            {
                LaunchGame();
            }
        }
Пример #21
0
        private bool InitializeDiscordClient()
        {
            instance = new RichPresence();
            Debugger.Discord(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_CONNECTED']"));

            instance.Secrets = new Secrets();

            try
            {
                client = new DiscordRpcClient(AppId, autoEvents: true);
            }
            catch (Exception err)
            {
                Debugger.Error($"Failed to create Rich Presence connection:\n{err}");
                return(false);
            }
            return(true);
        }
Пример #22
0
 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']"));
     }
 }
Пример #23
0
        public static string GetLinkName(string name)
        {
            if (name == null)
            {
                return("");
            }
            switch (name.ToLowerInvariant())
            {
            case "home":
            case "homepage":
                return(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_HOMEPAGE']"));

            case "discord":
                return(GStrings.GetLocalizationByXPath("/Settings/String[@ID='STATIC_DISCORD_SETTINGS']"));
            }

            return(name);
        }
Пример #24
0
        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();
            }
        }
Пример #25
0
        private void OnJoinRequested(object sender, JoinRequestMessage args)
        {
            Debugger.Discord(
                GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_DISCORD_JOIN_REQUEST']")
                .Replace("{Username}", args.User.ToString())
                );

            Application.Current.Dispatcher.InvokeAsync(() =>
            {
                DiscordNotify discordNotify      = new DiscordNotify(args);
                discordNotify.OnRequestAccepted += (src, args) =>
                {
                    client.Respond(args, true);
                };
                discordNotify.OnRequestRejected += (src, args) =>
                {
                    client.Respond(args, false);
                };
                discordNotify.Show();
            });
        }
Пример #26
0
        private string GetStateBasedOnContext()
        {
            if (context is null || context.Player is null)
            {
                return(string.Empty);
            }

            if (context.Player.PlayerParty.Size > 1 ||
                context.Player.PlayerParty.LobbySize > 1)
            {
                if (context.Player.InPeaceZone)
                {
                    return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_LOBBY']"));
                }
                else
                {
                    return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_PARTY']"));
                }
            }
            return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_STATE_SOLO']"));
        }
Пример #27
0
        private string GetDescriptionBasedOnContext()
        {
            if (context is null || context.Player is null)
            {
                return(string.Empty);
            }

            // Special cases
            switch (context.Player.ZoneID)
            {
            case 504:
                return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_TRAINING']"));
            }

            // Chilling in village
            if (context.Player.InPeaceZone)
            {
                return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_IN_TOWN']"));
            }

            // Exploring
            if (context.HuntedMonster is null)
            {
                return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_EXPLORING']"));
            }

            // Hunting a monster
            if (string.IsNullOrEmpty(context.HuntedMonster.Name))
            {
                return(GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_EXPLORING']"));
            }

            return(ConfigManager.Settings.RichPresence.ShowMonsterHealth ?
                   GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_HUNTING']")
                   .Replace("{Monster}", context.HuntedMonster.Name)
                   .Replace("{Health}", $"{(int)(context.HuntedMonster.HPPercentage * 100)}%") :
                   GStrings.GetLocalizationByXPath("/RichPresence/String[@ID='RPC_DESCRIPTION_HUNTING']")
                   .Replace("{Monster}", context.HuntedMonster.Name)
                   .Replace("({Health})", null));
        }
Пример #28
0
        private static void LoadMemoryAddresses(string filename)
        {
            // Clear all loaded values
            addresses.Clear();
            offsets.Clear();

            string[] fileLines = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"address/{filename}"));
            foreach (string line in fileLines)
            {
                if (line.StartsWith("#"))
                {
                    continue; // Ignore comments
                }
                string[] parsed = line.Split(' ');
                // parsed[0]: type
                // parsed[1]: name
                // parsed[2]: value
                AddValueToMap(parsed[0], parsed);
            }

            Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_MAP_LOAD']").Replace("{HunterPie_Map}", $"'{filename}'"));
        }
Пример #29
0
        public Hunterpie()
        {
            if (CheckIfHunterPieOpen())
            {
                this.Close();
                return;
            }

            AppDomain.CurrentDomain.UnhandledException += ExceptionLogger;
            // Initialize debugger and player config
            Debugger.InitializeDebugger();
            UserSettings.InitializePlayerConfig();

            // Initialize localization
            GStrings.InitStrings(UserSettings.PlayerConfig.HunterPie.Language);

            // Load custom theme and console colors
            LoadCustomTheme();
            Debugger.LoadNewColors();

            InitializeComponent();
            OpenDebugger();
            // Initialize everything under this line
            if (!CheckIfUpdateEnableAndStart())
            {
                return;
            }

            InitializeTrayIcon();

            // Updates version_text
            this.version_text.Content = GStrings.GetLocalizationByXPath("/Console/String[@ID='CONSOLE_VERSION']").Replace("{HunterPie_Version}", HUNTERPIE_VERSION).Replace("{HunterPie_Branch}", UserSettings.PlayerConfig.HunterPie.Update.Branch);

            // Initializes the rest of HunterPie
            LoadData();
            Debugger.Warn(GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_HUNTERPIE_INITIALIZED']"));
            SetHotKeys();
            StartEverything();
        }
Пример #30
0
        public static PluginActionViewModel ParseLink(string linkString)
        {
            var         name = "";
            var         link = "";
            ImageSource img  = null;

            var parts = linkString.Split('|');

            switch (parts.Length)
            {
            // icon|name|link
            case 3:
                name = GetLinkName(parts[0]);
                img  = (Application.Current.FindResource(parts[1]) as ImageSource)
                       ?? Application.Current.FindResource("ICON_LINK") as ImageSource;
                link = parts[2];
                break;

            // name|link
            case 2:
                name = parts[0];
                link = parts[1];
                img  = GetImageForAction(link) ?? Application.Current.FindResource("ICON_LINK") as ImageSource;
                break;

            // link
            default:
                name = GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_HOMEPAGE']");
                link = parts[0];
                img  = GetImageForAction(link) ?? Application.Current.FindResource("ICON_LINK") as ImageSource;
                break;
            }

            var command = new ArglessRelayCommand(() => Process.Start(link));

            return(new PluginActionViewModel(name, img, command));
        }