Skip to content

Commit

Permalink
Localize name of icons folder
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Oct 10, 2024
1 parent d9c9a4c commit 5c11742
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
1 change: 0 additions & 1 deletion Bloxstrap/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ public static void DoUninstall(bool keepData)

() => Directory.Delete(Paths.Downloads, true),
() => Directory.Delete(Paths.Roblox, true),
() => Directory.Delete(Paths.Icons, true),

() => File.Delete(App.State.FileLocation)
};
Expand Down
13 changes: 7 additions & 6 deletions Bloxstrap/Models/SettingTasks/ExtractIconsTask.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
using System.Reflection;
using System.Windows.Markup;

namespace Bloxstrap.Models.SettingTasks
{
public class ExtractIconsTask : BoolBaseTask
{
private string _path => Path.Combine(Paths.Base, Strings.Paths_Icons);

public ExtractIconsTask() : base("ExtractIcons")
{
OriginalState = Directory.Exists(Paths.Icons);
OriginalState = Directory.Exists(_path);
}

public override void Execute()
{
if (NewState)
{
Directory.CreateDirectory(Paths.Icons);
Directory.CreateDirectory(_path);

var assembly = Assembly.GetExecutingAssembly();
var resourceNames = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".ico"));

foreach (string name in resourceNames)
{
string path = Path.Combine(Paths.Icons, name.Replace("Bloxstrap.Resources.", ""));
string path = Path.Combine(_path, name.Replace("Bloxstrap.Resources.", ""));
var stream = assembly.GetManifestResourceStream(name)!;

using var memoryStream = new MemoryStream();
Expand All @@ -31,9 +32,9 @@ public override void Execute()
File.WriteAllBytes(path, memoryStream.ToArray());
}
}
else if (Directory.Exists(Paths.Icons))
else if (Directory.Exists(_path))
{
Directory.Delete(Paths.Icons, true);
Directory.Delete(_path, true);
}

OriginalState = NewState;
Expand Down
2 changes: 0 additions & 2 deletions Bloxstrap/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static class Paths
public static string Integrations { get; private set; } = "";
public static string Modifications { get; private set; } = "";
public static string Roblox { get; private set; } = "";
public static string Icons { get; private set; } = "";

public static string Application { get; private set; } = "";

Expand All @@ -38,7 +37,6 @@ public static void Initialize(string baseDirectory)
Integrations = Path.Combine(Base, "Integrations");
Modifications = Path.Combine(Base, "Modifications");
Roblox = Path.Combine(Base, "Roblox");
Icons = Path.Combine(Base, "Icons");

Application = Path.Combine(Base, $"{App.ProjectName}.exe");
}
Expand Down
9 changes: 9 additions & 0 deletions Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1230,4 +1230,8 @@ Would you like to enable test mode?</value>
<value>Support us on Ko-fi!</value>
<comment>Call-to-action button</comment>
</data>
<data name="Paths.Icons" xml:space="preserve">
<value>Icons</value>
<comment>Name of the folder that gets created according to the "create shortcut icons" option. Ensure that it is a valid folder name.</comment>
</data>
</root>

0 comments on commit 5c11742

Please sign in to comment.