Make mod preset application a bit less painful

This commit is contained in:
pizzaboxer 2023-07-24 10:12:42 +01:00
parent 5558e5163b
commit b0334b7866
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
6 changed files with 39 additions and 18 deletions

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
@ -29,11 +29,11 @@
<EmbeddedResource Include="Resources\Mods\Cursor\From2006\ArrowFarCursor.png" />
<EmbeddedResource Include="Resources\Mods\Cursor\From2013\ArrowCursor.png" />
<EmbeddedResource Include="Resources\Mods\Cursor\From2013\ArrowFarCursor.png" />
<EmbeddedResource Include="Resources\Mods\Empty.mp3" />
<EmbeddedResource Include="Resources\Mods\Sounds\OldDeath.ogg" />
<EmbeddedResource Include="Resources\Mods\Sounds\OldJump.mp3" />
<EmbeddedResource Include="Resources\Mods\Sounds\OldWalk.mp3" />
<EmbeddedResource Include="Resources\Mods\Sounds\Empty.mp3" />
<EmbeddedResource Include="Resources\Mods\OldAvatarBackground.rbxl" />
<EmbeddedResource Include="Resources\Mods\OldDeath.ogg" />
<EmbeddedResource Include="Resources\Mods\OldJump.mp3" />
<EmbeddedResource Include="Resources\Mods\OldWalk.mp3" />
</ItemGroup>
<ItemGroup>

View File

@ -962,19 +962,31 @@ namespace Bloxstrap
bool appDisabled = App.Settings.Prop.UseDisableAppPatch && !_launchCommandLine.Contains("--deeplink");
// cursors
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2006.ArrowCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "Cursor.From2006.ArrowFarCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2013, @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2013.ArrowCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2013, @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "Cursor.From2013.ArrowFarCursor.png");
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, new Dictionary<string, string>
{
{ @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2006.ArrowCursor.png" },
{ @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "Cursor.From2006.ArrowFarCursor.png" }
});
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2013, new Dictionary<string, string>
{
{ @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2013.ArrowCursor.png" },
{ @"content\textures\Cursors\KeyboardMouse\ArrowFarCursor.png", "Cursor.From2013.ArrowFarCursor.png" }
});
// character sounds
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_footsteps_plastic.mp3", "OldWalk.mp3");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_jump.mp3", "OldJump.mp3");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_falling.mp3", "Empty.mp3");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_jump_land.mp3", "Empty.mp3");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\action_swim.mp3", "Empty.mp3");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, @"content\sounds\impact_water.mp3", "Empty.mp3");
await CheckModPreset(App.Settings.Prop.UseOldDeathSound, @"content\sounds\ouch.ogg", "OldDeath.ogg");
await CheckModPreset(App.Settings.Prop.UseOldDeathSound, @"content\sounds\ouch.ogg", "Sounds.OldDeath.ogg");
await CheckModPreset(App.Settings.Prop.UseOldCharacterSounds, new Dictionary<string, string>
{
{ @"content\sounds\action_footsteps_plastic.mp3", "Sounds.OldWalk.mp3" },
{ @"content\sounds\action_jump.mp3", "Sounds.OldJump.mp3" },
{ @"content\sounds\action_falling.mp3", "Sounds.Empty.mp3" },
{ @"content\sounds\action_jump_land.mp3", "Sounds.Empty.mp3" },
{ @"content\sounds\action_swim.mp3", "Sounds.Empty.mp3" },
{ @"content\sounds\impact_water.mp3", "Sounds.Empty.mp3" }
});
// Mobile.rbxl
await CheckModPreset(appDisabled, @"ExtraContent\places\Mobile.rbxl", "");
@ -1114,10 +1126,13 @@ namespace Bloxstrap
private static async Task CheckModPreset(bool condition, string location, string name)
{
string fullLocation = Path.Combine(Directories.Modifications, location);
string fileHash = File.Exists(fullLocation) ? Utility.MD5Hash.FromFile(fullLocation) : "";
string fileHash = File.Exists(fullLocation) ? MD5Hash.FromFile(fullLocation) : "";
if (!condition && fileHash == "")
return;
byte[] embeddedData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await Resource.Get(name);
string embeddedHash = Utility.MD5Hash.FromBytes(embeddedData);
string embeddedHash = MD5Hash.FromBytes(embeddedData);
if (!condition)
{
@ -1136,6 +1151,12 @@ namespace Bloxstrap
}
}
private static async Task CheckModPreset(bool condition, Dictionary<string, string> mapping)
{
foreach (var pair in mapping)
await CheckModPreset(condition, pair.Key, pair.Value);
}
private async Task DownloadPackage(Package package)
{
if (_cancelFired)