HunterPie / HunterPie-legacy

A complete, modern and clean overlay with Discord Rich Presence integration for Monster Hunter: World.
https://hunterpie.haato.dev/
MIT License
428 stars 81 forks source link

added LoadJson and SaveJson to PluginExtension #158

Closed DevilPepper closed 3 years ago

DevilPepper commented 3 years ago

Before moving these methods here, I made them extension methods for Main: https://github.com/Stuff-Mods/MHWItemBoxTracker/blob/settings/ItemBoxTracker/MainExtension.cs

The compiler complains that await can only be used in an async function... So I get around it like this:

https://github.com/Stuff-Mods/MHWItemBoxTracker/blob/e5859683a1d85d14a904ee5068e55dc3425f7efb/ItemBoxTracker/Main.cs#L32-L36

            Dispatch(async () => {
                var module = await this.LoadJson<PluginInformation>("module.json");
                Name = module.Name;
                Description = module.Description;
            });

https://github.com/Stuff-Mods/MHWItemBoxTracker/blob/e5859683a1d85d14a904ee5068e55dc3425f7efb/ItemBoxTracker/GUI/ItemBoxTracker.xaml.cs#L26-L32

            Dispatch(async () => {
                widgetSettings = await Plugin.LoadJson<ItemBoxWidgetSettings>(settingsJson);
                Plugin.Log($"Loaded widget settings...{JsonConvert.SerializeObject(widgetSettings)}");
                Plugin.Log($"Settings: {JsonConvert.SerializeObject(Settings)}");

                ApplySettings();
            })

Here's some logs I put around save and load for widget settings: image

DevilPepper commented 3 years ago

this job passes on my fork whenever the fork sync job opens a PR.: https://github.com/ForksKnivesAndSpoons/HunterPie/actions/runs/714085814

I have seen the nuget restore step fail before, but I can't figure out why. Could be that NuGet was down briefly ¯\_(ツ)_/¯. Try re-running the job and it'll probably pass. I don't think I can re-run it.