Improved plugin installation experience
display plugin version on installation
don't display "plugin updated" on start when no new updates available
added "Restart now" button on installation notification
display message when plugin is up-to-date already
MODIFY
HunterPie/HunterPie.Plugins/PluginManager.cs
HunterPie/HunterPie.Plugins/PluginManager.cs
@@ -79,17 +79,22 @@ namespace HunterPie.Plugins
if (PluginUpdate.PluginSupportsUpdate(modInformation))
{
- if (await PluginUpdate.UpdateAllFiles(modInformation, module))
+ switch (await PluginUpdate.UpdateAllFiles(modInformation, module))
{
+ case UpdateResult.Updated:
serializedModule = File.ReadAllText(Path.Combine(module, "module.json"));
modInformation = JsonConvert.DeserializeObject<PluginInformation>(serializedModule);
- Debugger.Module($"Updated plugin: {modInformation.Name}");
- }
- else
- {
+ Debugger.Module($"Updated plugin: {modInformation.Name} (ver {modInformation.Version})");
+ break;
+
+ case UpdateResult.Failed:
Debugger.Error($"Failed to update plugin: {modInformation.Name}");
continue;
+
+ case UpdateResult.UpToDate:
+ Debugger.Module($"Plugin {modInformation.Name} is up-to-date (ver {modInformation.Version})");
+ break;
}
}

MODIFY
HunterPie/HunterPie.Plugins/PluginUpdate.cs
HunterPie/HunterPie.Plugins/PluginUpdate.cs
@@ -14,23 +14,25 @@ namespace HunterPie.Plugins
return !string.IsNullOrEmpty(pluginInformation.Update.UpdateUrl);
}
- public static async Task<bool> UpdateAllFiles(PluginInformation pInformation, string modPath)
+ public static async Task<UpdateResult> UpdateAllFiles(PluginInformation pInformation, string modPath)
{
string onlineSerializedInformation = await ReadOnlineModuleJson(pInformation.Update.UpdateUrl);
if (onlineSerializedInformation is null)
{
//Debugger.Error($"Failed to update plugin: {pInformation.Name}!");
- return false;
+ return UpdateResult.Failed;
}
PluginInformation onlineInformation = JsonConvert.DeserializeObject<PluginInformation>(onlineSerializedInformation);
if (!(Hunterpie.ParseVersion(Hunterpie.HUNTERPIE_VERSION) >= Hunterpie.ParseVersion(onlineInformation.Update.MinimumVersion)))
{
- return false;
+ return UpdateResult.Failed;
}
+ var result = UpdateResult.UpToDate;
+
foreach (string filePath in onlineInformation.Update.FileHashes.Keys)
{
string onlineHash = onlineInformation.Update.FileHashes[filePath];
@@ -51,8 +53,10 @@ namespace HunterPie.Plugins
if (!(await DownloadFileAsync(updateurl, outputPath, filePath)))
{
- return false;
+ return UpdateResult.Failed;
}
+
+ result = UpdateResult.Updated;
}
}
else
@@ -61,11 +65,15 @@ namespace HunterPie.Plugins
string outputPath = Path.Combine(modPath, filePath);
if (!(await DownloadFileAsync(updateurl, outputPath, filePath)))
{
- return false;
+ return UpdateResult.Failed;
}
+ result = UpdateResult.Updated;
}
}
- return await DownloadFileAsync($"{pInformation.Update.UpdateUrl}/module.json", Path.Combine(modPath, "module.json"), "module.json");
+
+ return await DownloadFileAsync($"{pInformation.Update.UpdateUrl}/module.json", Path.Combine(modPath, "module.json"), "module.json")
+ ? result
+ : UpdateResult.Failed;
}
public static async Task<bool> DownloadFileAsync(string URL, string output, string relFilepath)

MODIFY
HunterPie/HunterPie.csproj
HunterPie/HunterPie.csproj
<Compile Include="GUIControls\Settings.xaml.cs">
<DependentUpon>Settings.xaml</DependentUpon>
</Compile>
+ <Compile Include="HunterPie.Plugins\UpdateResult.cs" />
<Compile Include="Utils\FloatExtensions.cs" />
<None Include="address\MonsterHunterWorld.420540.map">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

MODIFY
HunterPie/Hunterpie.xaml.cs
HunterPie/Hunterpie.xaml.cs
@@ -1117,28 +1117,53 @@ namespace HunterPie
if (PluginUpdate.PluginSupportsUpdate(moduleInformation))
{
- if (await PluginUpdate.UpdateAllFiles(moduleInformation, modPath))
+ switch (await PluginUpdate.UpdateAllFiles(moduleInformation, modPath))
{
- Debugger.Module($"Installed {moduleInformation.Name}!");
- } else
+ case UpdateResult.Updated:
+ Debugger.Module($"Installed {moduleInformation.Name}! (ver {moduleInformation.Version})");
+
+ CNotification notification = new CNotification
{
+ Text = GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_INSTALLED']").Replace("{name}", moduleInformation.Name),
+ NIcon = FindResource("ICON_PLUGIN") as ImageSource,
+
+ FirstButtonVisibility = Visibility.Visible,
+ Callback1 = Reload,
+ FirstButtonImage = FindResource("ICON_RESTART") as ImageSource,
+ FirstButtonText = GStrings.GetLocalizationByXPath("/Notifications/String[@ID='STATIC_RESTART']"),
+
+ SecondButtonVisibility = Visibility.Collapsed,
+ ShowTime = 15
+ };
+ NotificationsPanel.Children.Add(notification);
+ notification.ShowNotification();
+ break;
+
+ case UpdateResult.Failed:
Debugger.Error($"Failed to install {moduleInformation.Name}.");
- }
- } else
- {
- Debugger.Error(GStrings.GetLocalizationByXPath("/Console/String[@ID='ERROR_PLUGIN_AUTO_UPDATE']"));
- }
+ return;
- CNotification notification = new CNotification()
+ case UpdateResult.UpToDate:
+ string uptodateText =
+ $"Plugin {moduleInformation.Name} is already installed and up-to-date! (ver {moduleInformation.Version})";
+ Debugger.Module(uptodateText);
+ CNotification uptodateNotification = new CNotification
{
- Text = GStrings.GetLocalizationByXPath("/Console/String[@ID='MESSAGE_PLUGIN_INSTALLED']").Replace("{name}", moduleInformation.Name),
+ Text = uptodateText,
NIcon = FindResource("ICON_PLUGIN") as ImageSource,
+
FirstButtonVisibility = Visibility.Collapsed,
SecondButtonVisibility = Visibility.Collapsed,
ShowTime = 5
};
- NotificationsPanel.Children.Add(notification);
- notification.ShowNotification();
+ NotificationsPanel.Children.Add(uptodateNotification);
+ uptodateNotification.ShowNotification();
+ return;
+ }
+ } else
+ {
+ Debugger.Error(GStrings.GetLocalizationByXPath("/Console/String[@ID='ERROR_PLUGIN_AUTO_UPDATE']"));
+ }
}
private void window_DragEnter(object sender, DragEventArgs e)

MODIFY
HunterPie/Languages/en-us.xml
HunterPie/Languages/en-us.xml
<String ID="STATIC_OPENFOLDER" Name="Open Folder"/>
<String ID="MESSAGE_BUILD_UPLOADED" Name="Build uploaded to Honey Hunters World!"/>
<String ID="MESSAGE_GEAR_EXPORTED" Name="Exported gear to ./DataExport!"/>
+ <String ID="STATIC_RESTART" Name="Restart now"/>
</Notifications>
<RichPresence>
<String ID="RPC_DESCRIPTION_IN_MAIN_MENU" Name="In Main Menu"/>

MODIFY
HunterPie/Resources/Resources.xaml
HunterPie/Resources/Resources.xaml
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
+ <DrawingImage x:Key="ICON_RESTART">
+ <DrawingImage.Drawing>
+ <DrawingGroup ClipGeometry="M3,3 V19 H19 V3 H3 Z">
+ <DrawingGroup.Transform>
+ <TranslateTransform X="-0.42599999904632568" Y="1049.36" />
+ </DrawingGroup.Transform>
+ <DrawingGroup Transform="1,0,0,-1,0,-1030.36">
+ <GeometryDrawing Brush="{StaticResource BUTTON_ICON_FOREGROUND}">
+ <GeometryDrawing.Geometry>
+ <EllipseGeometry RadiusX="8" RadiusY="8" Center="11,-1041.36" />
+ </GeometryDrawing.Geometry>
+ </GeometryDrawing>
+ </DrawingGroup>
+ <DrawingGroup Transform="0.07192,0,0,0.07192,6.674,6.768">
+ <GeometryDrawing Brush="{StaticResource CONSOLE_WINDOWBAR_BACKGROUND}"
+ Geometry="F1 M16,16z M0,0z M120.6,38.723C117.288,31.01 112.834,24.356 107.24,18.762 101.645,13.168 94.992,8.712 87.278,5.401 79.565,2.087 71.473,0.431 63,0.431 55.016,0.431 47.29,1.937 39.82,4.952 32.352,7.962 25.71,12.217 19.9,17.703L9.30699999999999,7.192C7.67699999999999,5.508 5.80399999999999,5.128 3.68499999999999,6.051 1.51199999999999,6.975 0.425999999999992,8.578 0.425999999999992,10.859L0.425999999999992,47.359C0.425999999999992,48.771 0.941999999999992,49.993 1.97399999999999,51.025 3.00699999999999,52.057 4.22899999999999,52.573 5.64099999999999,52.573L42.141,52.573C44.423,52.573 46.025,51.487 46.948,49.314 47.871,47.196 47.491,45.322 45.807,43.692L34.645,32.449C38.448,28.864 42.793,26.108 47.685,24.179 52.574,22.251 57.679,21.286 63.002,21.286 68.651,21.286 74.042,22.387 79.172,24.586 84.305,26.786 88.744,29.76 92.492,33.508 96.24,37.255 99.214,41.695 101.414,46.828 103.613,51.961 104.713,57.351 104.713,62.998 104.713,68.648 103.613,74.038 101.414,79.168 99.214,84.301 96.24,88.741 92.492,92.489 88.744,96.237 84.304,99.211 79.172,101.41 74.039,103.61 68.647,104.71 63.002,104.71 56.538,104.71 50.428,103.298 44.67,100.474 38.913,97.65 34.052,93.658 30.087,88.497 29.707,87.954 29.087,87.627 28.213,87.518 27.398,87.518 26.719,87.762 26.176,88.251L15.014,99.495C14.58,99.931 14.349,100.486 14.322,101.165 14.295,101.845 14.472,102.455 14.852,102.998 20.773,110.168 27.942,115.722 36.361,119.659 44.78,123.596 53.661,125.566 63.003,125.566 71.476,125.566 79.569,123.909 87.282,120.596 94.995,117.283 101.647,112.828 107.243,107.235 112.837,101.639 117.293,94.987 120.604,87.274 123.917,79.561 125.573,71.467 125.573,62.995 125.573,54.521 123.916,46.431 120.603,38.718" />
+ </DrawingGroup>
+ </DrawingGroup>
+ </DrawingImage.Drawing>
+ </DrawingImage>
<DrawingImage x:Key="ICON_ADMINISTRATOR">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V64.01 H64.01 V0 H0 Z">

Improved plugin installation experience
- display plugin version on installation
- don't display "plugin updated" on start when no new updates available
- added "Restart now" button on installation notification
- display message when plugin is up-to-date already