Skip to content

Commit 1a20a9b

Browse files
committed
- Add Confirmation dialog before erasing output folder
- Add detection for users providing (wrong) settings that would erase their entire drive - Updated Translations Fixes #15
1 parent ab1816f commit 1a20a9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+165
-12
lines changed

Constants.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static class Constants
2525
public static string NoneText = resources.GetString("LOC_HTMLEXPORTER_NoneText");
2626
public static string AscendingText = resources.GetString("LOC_HTMLEXPORTER_AscendingText");
2727
public static string DescendingText = resources.GetString("LOC_HTMLEXPORTER_DescendingText");
28-
28+
public static string EraseQuestionText = resources.GetString("LOC_HTMLEXPORTER_EraseQuestion");
2929

3030

3131
public const string AppName = "HTML Exporter";
@@ -184,7 +184,8 @@ static class Constants
184184

185185

186186
//errors
187-
public static string ErrorHTMLExpoterNoOutputFolder = resources.GetString("LOC_HTMLEXPORTER_ErrorHTMLExpoterNoOutputFolder");
187+
public static string ErrorHTMLExporterNoOutputFolder = resources.GetString("LOC_HTMLEXPORTER_ErrorHTMLExpoterNoOutputFolder");
188+
public static string ErrorHTMLExporterDetectedRootDriveErase = resources.GetString("LOC_HTMLEXPORTER_DetectedRootDrive");
188189

189190
//settingsview
190191
public static string RevertPagesQuestion1 = resources.GetString("LOC_HTMLEXPORTER_RevertPagesQuestion1");

HtmlExporterPlugin.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using System.Windows.Controls;
1717
using System.Security.Cryptography;
1818
using Playnite.SDK.Events;
19+
using System.Windows;
1920
//using ZetaProducerHtmlCompressor.Internal;
2021

2122
namespace HtmlExporterPlugin
@@ -86,6 +87,18 @@ public string ReplaceDictionary(string text, Dictionary<string, string> keywords
8687

8788
public void DoExportToHtml(List<Game> gameslist)
8889
{
90+
string folder = Settings.Settings.OutputFolder;
91+
92+
if (Directory.Exists(folder))
93+
{
94+
if (Settings.Settings.EraseOutputFolder)
95+
{
96+
if (PlayniteApi.Dialogs.ShowMessage(string.Format(Constants.EraseQuestionText, folder), Constants.AppName, MessageBoxButton.YesNo) == MessageBoxResult.No)
97+
{
98+
return;
99+
}
100+
}
101+
}
89102
ImageProcessRunner ConvertImagesRunner = new ImageProcessRunner();
90103
var progressOptions = new GlobalProgressOptions(String.Empty, true)
91104
{

HtmlExporterPlugin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<Reference Include="WindowsBase" />
5757
</ItemGroup>
5858
<ItemGroup>
59+
<Compile Include="Utils.cs" />
5960
<Compile Include="FileDeDuplicator.cs" />
6061
<Compile Include="OriginalImageDataFile.cs" />
6162
<Compile Include="OriginalGameImageData.cs" />

HtmlExporterPluginSettings.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,13 @@ public bool VerifySettings(out List<string> errors)
248248
if (String.IsNullOrEmpty(Settings.OutputFolder) || (!Directory.Exists(Settings.OutputFolder)))
249249
{
250250
returnvalue = false;
251-
errors.Add(Constants.ErrorHTMLExpoterNoOutputFolder);
251+
errors.Add(Constants.ErrorHTMLExporterNoOutputFolder);
252+
}
253+
254+
if (Settings.EraseOutputFolder && !String.IsNullOrEmpty(Settings.OutputFolder) && Directory.Exists(Settings.OutputFolder) && Utils.IsRootDrive(Settings.OutputFolder))
255+
{
256+
returnvalue = false;
257+
errors.Add(Constants.ErrorHTMLExporterDetectedRootDriveErase);
252258
}
253259

254260
return returnvalue;

Localization/LocSource.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
<sys:String x:Key="LOC_HTMLEXPORTER_AlwaysProcess">Always process images, even if they have not changed</sys:String>
203203
<sys:String x:Key="LOC_HTMLEXPORTER_Optimizations">optimizations</sys:String>
204204
<sys:String x:Key="LOC_HTMLEXPORTER_DetectDuplicates">Detect Duplicate Images</sys:String>
205+
<sys:String x:Key="LOC_HTMLEXPORTER_DetectedRootDrive">It is not allowed to select a root drive folder as output folder while erase output folder is enabled, as the whole drive would get erased!</sys:String>
206+
<sys:String x:Key="LOC_HTMLEXPORTER_EraseQuestion">The Following folder "{0}" will get completely erased! Are you sure you want to continue?</sys:String>
207+
205208

206209

207210

Localization/af_ZA.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
<sys:String x:Key="LOC_HTMLEXPORTER_AlwaysProcess">Always process images, even if they have not changed</sys:String>
203203
<sys:String x:Key="LOC_HTMLEXPORTER_Optimizations">optimizations</sys:String>
204204
<sys:String x:Key="LOC_HTMLEXPORTER_DetectDuplicates">Detect Duplicate Images</sys:String>
205+
<sys:String x:Key="LOC_HTMLEXPORTER_DetectedRootDrive">It is not allowed to select a root drive folder as output folder while erase output folder is enabled, as the whole drive would get erased!</sys:String>
206+
<sys:String x:Key="LOC_HTMLEXPORTER_EraseQuestion">The Following folder &quot;{0}&quot; will get completely erased! Are you sure you want to continue?</sys:String>
207+
205208

206209

207210

Localization/ar_SA.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
<sys:String x:Key="LOC_HTMLEXPORTER_AlwaysProcess">معالجة الصور دائماً، حتى إذا لم تتغير</sys:String>
203203
<sys:String x:Key="LOC_HTMLEXPORTER_Optimizations">التحسينات</sys:String>
204204
<sys:String x:Key="LOC_HTMLEXPORTER_DetectDuplicates">كشف الصور المتكررة</sys:String>
205+
<sys:String x:Key="LOC_HTMLEXPORTER_DetectedRootDrive">It is not allowed to select a root drive folder as output folder while erase output folder is enabled, as the whole drive would get erased!</sys:String>
206+
<sys:String x:Key="LOC_HTMLEXPORTER_EraseQuestion">The Following folder &quot;{0}&quot; will get completely erased! Are you sure you want to continue?</sys:String>
207+
205208

206209

207210

Localization/ca_ES.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
<sys:String x:Key="LOC_HTMLEXPORTER_AlwaysProcess">Always process images, even if they have not changed</sys:String>
203203
<sys:String x:Key="LOC_HTMLEXPORTER_Optimizations">optimizations</sys:String>
204204
<sys:String x:Key="LOC_HTMLEXPORTER_DetectDuplicates">Detect Duplicate Images</sys:String>
205+
<sys:String x:Key="LOC_HTMLEXPORTER_DetectedRootDrive">It is not allowed to select a root drive folder as output folder while erase output folder is enabled, as the whole drive would get erased!</sys:String>
206+
<sys:String x:Key="LOC_HTMLEXPORTER_EraseQuestion">The Following folder &quot;{0}&quot; will get completely erased! Are you sure you want to continue?</sys:String>
207+
205208

206209

207210

Localization/cs_CZ.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
<sys:String x:Key="LOC_HTMLEXPORTER_AlwaysProcess">Always process images, even if they have not changed</sys:String>
203203
<sys:String x:Key="LOC_HTMLEXPORTER_Optimizations">optimizations</sys:String>
204204
<sys:String x:Key="LOC_HTMLEXPORTER_DetectDuplicates">Detect Duplicate Images</sys:String>
205+
<sys:String x:Key="LOC_HTMLEXPORTER_DetectedRootDrive">It is not allowed to select a root drive folder as output folder while erase output folder is enabled, as the whole drive would get erased!</sys:String>
206+
<sys:String x:Key="LOC_HTMLEXPORTER_EraseQuestion">The Following folder &quot;{0}&quot; will get completely erased! Are you sure you want to continue?</sys:String>
207+
205208

206209

207210

Localization/da_DK.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
<sys:String x:Key="LOC_HTMLEXPORTER_AlwaysProcess">Always process images, even if they have not changed</sys:String>
203203
<sys:String x:Key="LOC_HTMLEXPORTER_Optimizations">optimizations</sys:String>
204204
<sys:String x:Key="LOC_HTMLEXPORTER_DetectDuplicates">Detect Duplicate Images</sys:String>
205+
<sys:String x:Key="LOC_HTMLEXPORTER_DetectedRootDrive">It is not allowed to select a root drive folder as output folder while erase output folder is enabled, as the whole drive would get erased!</sys:String>
206+
<sys:String x:Key="LOC_HTMLEXPORTER_EraseQuestion">The Following folder &quot;{0}&quot; will get completely erased! Are you sure you want to continue?</sys:String>
207+
205208

206209

207210

0 commit comments

Comments
 (0)