mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Allow extraction of icons for shortcuts (#1143)
This commit is contained in:
parent
96ed47635e
commit
81c6512055
@ -27,6 +27,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\Icon2008.ico" />
|
||||
<EmbeddedResource Include="Resources\Icon2011.ico" />
|
||||
<EmbeddedResource Include="Resources\Icon2017.ico" />
|
||||
<EmbeddedResource Include="Resources\Icon2019.ico" />
|
||||
<EmbeddedResource Include="Resources\Icon2022.ico" />
|
||||
<EmbeddedResource Include="Resources\IconBloxstrap.ico" />
|
||||
<EmbeddedResource Include="Resources\IconEarly2015.ico" />
|
||||
<EmbeddedResource Include="Resources\IconLate2015.ico" />
|
||||
<EmbeddedResource Include="Resources\Mods\Cursor\From2006\ArrowCursor.png" />
|
||||
<EmbeddedResource Include="Resources\Mods\Cursor\From2006\ArrowFarCursor.png" />
|
||||
<EmbeddedResource Include="Resources\Mods\Cursor\From2013\ArrowCursor.png" />
|
||||
|
@ -12,7 +12,9 @@ namespace Bloxstrap.Models.SettingTasks.Base
|
||||
|
||||
public abstract bool Changed { get; }
|
||||
|
||||
public BaseTask(string prefix, string name) => Name = $"{prefix}.{name}";
|
||||
public BaseTask(string prefix, string name) : this($"{prefix}.{name}") { }
|
||||
|
||||
public BaseTask(string name) => Name = name;
|
||||
|
||||
public override string ToString() => Name;
|
||||
|
||||
|
@ -41,5 +41,7 @@ namespace Bloxstrap.Models.SettingTasks.Base
|
||||
public override bool Changed => _newState != OriginalState;
|
||||
|
||||
public BoolBaseTask(string prefix, string name) : base(prefix, name) { }
|
||||
|
||||
public BoolBaseTask(string name) : base(name) { }
|
||||
}
|
||||
}
|
||||
|
42
Bloxstrap/Models/SettingTasks/ExtractIconsTask.cs
Normal file
42
Bloxstrap/Models/SettingTasks/ExtractIconsTask.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Reflection;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Bloxstrap.Models.SettingTasks
|
||||
{
|
||||
public class ExtractIconsTask : BoolBaseTask
|
||||
{
|
||||
public ExtractIconsTask() : base("ExtractIcons")
|
||||
{
|
||||
OriginalState = Directory.Exists(Paths.Icons);
|
||||
}
|
||||
|
||||
public override void Execute()
|
||||
{
|
||||
if (NewState)
|
||||
{
|
||||
Directory.CreateDirectory(Paths.Icons);
|
||||
|
||||
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.", ""));
|
||||
var stream = assembly.GetManifestResourceStream(name)!;
|
||||
|
||||
using var memoryStream = new MemoryStream();
|
||||
stream.CopyTo(memoryStream);
|
||||
|
||||
Filesystem.AssertReadOnly(path);
|
||||
File.WriteAllBytes(path, memoryStream.ToArray());
|
||||
}
|
||||
}
|
||||
else if (Directory.Exists(Paths.Icons))
|
||||
{
|
||||
Directory.Delete(Paths.Icons, true);
|
||||
}
|
||||
|
||||
OriginalState = NewState;
|
||||
}
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ namespace Bloxstrap.Models.SettingTasks
|
||||
|
||||
using var resourceStream = data.ResourceStream;
|
||||
using var memoryStream = new MemoryStream();
|
||||
data.ResourceStream.CopyTo(memoryStream);
|
||||
resourceStream.CopyTo(memoryStream);
|
||||
|
||||
Filesystem.AssertReadOnly(data.FullFilePath);
|
||||
File.WriteAllBytes(data.FullFilePath, memoryStream.ToArray());
|
||||
|
@ -1,6 +1,4 @@
|
||||
using Bloxstrap.Models.SettingTasks.Base;
|
||||
|
||||
namespace Bloxstrap.Models.SettingTasks
|
||||
namespace Bloxstrap.Models.SettingTasks
|
||||
{
|
||||
public class ShortcutTask : BoolBaseTask
|
||||
{
|
||||
|
@ -22,6 +22,7 @@
|
||||
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; } = "";
|
||||
|
||||
@ -37,6 +38,7 @@
|
||||
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");
|
||||
}
|
||||
|
18
Bloxstrap/Resources/Strings.Designer.cs
generated
18
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -3088,6 +3088,24 @@ namespace Bloxstrap.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to To use for your shortcuts, right-click it, open properties, change icon, browse, and pick from the Icons folder..
|
||||
/// </summary>
|
||||
public static string Menu_Shortcuts_ExtractIcons_Description {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Shortcuts.ExtractIcons.Description", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Extract Roblox icons to folder.
|
||||
/// </summary>
|
||||
public static string Menu_Shortcuts_ExtractIcons_Title {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.Shortcuts.ExtractIcons.Title", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create shortcuts for quick access to specific functions. These will all be placed on the Desktop..
|
||||
/// </summary>
|
||||
|
@ -1198,4 +1198,10 @@ Please manually delete Bloxstrap.exe from the install location or try restarting
|
||||
|
||||
{0}</value>
|
||||
</data>
|
||||
<data name="Menu.Shortcuts.ExtractIcons.Title" xml:space="preserve">
|
||||
<value>Extract Roblox icons to folder</value>
|
||||
</data>
|
||||
<data name="Menu.Shortcuts.ExtractIcons.Description" xml:space="preserve">
|
||||
<value>To use for your shortcuts, right-click it, open properties, change icon, browse, and pick from the Icons folder.</value>
|
||||
</data>
|
||||
</root>
|
@ -17,6 +17,13 @@
|
||||
<StackPanel Margin="0,0,14,14">
|
||||
<TextBlock Margin="0,0,0,16" Text="{x:Static resources:Strings.Menu_Shortcuts_Description}" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||
|
||||
<controls:OptionControl
|
||||
Header="{x:Static resources:Strings.Menu_Shortcuts_ExtractIcons_Title}"
|
||||
Description="{x:Static resources:Strings.Menu_Shortcuts_ExtractIcons_Description}"
|
||||
Margin="0,0,0,16">
|
||||
<ui:ToggleSwitch IsChecked="{Binding ExtractIconsTask.NewState, Mode=TwoWay}" />
|
||||
</controls:OptionControl>
|
||||
|
||||
<TextBlock Text="{x:Static resources:Strings.Menu_Shortcuts_General_Title}" FontSize="20" FontWeight="Medium" />
|
||||
<TextBlock Text="{x:Static resources:Strings.Menu_Shortcuts_General_Description}" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||
|
||||
|
@ -12,5 +12,7 @@ namespace Bloxstrap.UI.ViewModels.Settings
|
||||
public ShortcutTask PlayerIconTask { get; } = new("RobloxPlayer", Paths.Desktop, $"{Strings.LaunchMenu_LaunchRoblox}.lnk", "-player");
|
||||
|
||||
public ShortcutTask SettingsIconTask { get; } = new("Settings", Paths.Desktop, $"{Strings.Menu_Title}.lnk", "-settings");
|
||||
|
||||
public ExtractIconsTask ExtractIconsTask { get; } = new();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user