Skip to content

Commit

Permalink
Make mod preset application a bit less painful
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 24, 2023
1 parent 5558e51 commit b0334b7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Bloxstrap/Bloxstrap.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand Down Expand Up @@ -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>
Expand Down
47 changes: 34 additions & 13 deletions Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -962,19 +962,31 @@ private async Task ApplyModifications()
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", "");
Expand Down Expand Up @@ -1114,10 +1126,13 @@ private async Task ApplyModifications()
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)
{
Expand All @@ -1136,6 +1151,12 @@ private static async Task CheckModPreset(bool condition, string location, string
}
}

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)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b0334b7

Please sign in to comment.