Skip to content

Commit

Permalink
PS3 GoA Music
Browse files Browse the repository at this point in the history
Because Hyper demanded it.
Also adds an option to include the GoA music in the music randomiser.
  • Loading branch information
Knuxfan24 committed Sep 11, 2022
1 parent efa049e commit 653955d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Binary file not shown.
1 change: 1 addition & 0 deletions MarathonRandomiser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
<CheckBox x:Name="CheckBox_Episode_SonicVH" Content="Enable Very Hard ~ Sonic" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_ShadowVH" Content="Enable Very Hard ~ Shadow" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_SilverVH" Content="Enable Very Hard ~ Silver" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_GoAMusic" Content="Use GoA Music in Randomisation" IsEnabled="False"/>
</StackPanel>

<hc:TabControl Style="{StaticResource TabControlInLine}" Margin="210,0,0,60" HorizontalAlignment="Stretch" Name="TabControl_Episode" IsEnabled="False">
Expand Down
30 changes: 19 additions & 11 deletions MarathonRandomiser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ private void Dependency_CheckBox_Changed(object sender, RoutedEventArgs e)
CheckBox_Episode_SonicVH.IsEnabled = NewCheckedStatus;
CheckBox_Episode_ShadowVH.IsEnabled = NewCheckedStatus;
CheckBox_Episode_SilverVH.IsEnabled = NewCheckedStatus;
CheckBox_Episode_GoAMusic.IsEnabled = NewCheckedStatus;
TabControl_Episode.IsEnabled = NewCheckedStatus;
break;

Expand Down Expand Up @@ -1725,7 +1726,7 @@ private async void Randomise(object sender, RoutedEventArgs e)
if (TexturesArchives.Count == 0)
CheckBox_Textures_Textures.IsChecked = false;

if (AudioMusic.Count == 0)
if (AudioMusic.Count == 0 && CheckBox_Episode_Generate.IsChecked == false && CheckBox_Episode_GoAMusic.IsChecked == false)
CheckBox_Audio_Music.IsChecked = false;
if (AudioCSBs.Count == 0)
CheckBox_Audio_SFX.IsChecked = false;
Expand All @@ -1747,6 +1748,7 @@ private async void Randomise(object sender, RoutedEventArgs e)
bool? episodeGenerate = CheckBox_Episode_Generate.IsChecked;
bool? episodeTownMissions = CheckBox_Episode_TownMissions.IsChecked;
int episodeTownMissionCount = (int)NumericUpDown_Episode_TownMissionCount.Value;
bool? episodeGoAMusic = CheckBox_Episode_GoAMusic.IsChecked;

// Set up a level order for later.
Dictionary<string, int> LevelOrder = new();
Expand Down Expand Up @@ -1776,6 +1778,10 @@ private async void Randomise(object sender, RoutedEventArgs e)
}
}
}

// Add the Garden of Assemblage's music to the Music Randomiser if the option for it is checked.
if (episodeGoAMusic == true)
AudioMusic.Add("stg_goa_khii");
#endregion

#region Object Placement
Expand Down Expand Up @@ -2708,7 +2714,7 @@ await Task.Run(() => SceneRandomiser.Process(luaFile, sceneLightAmbient, sceneLi
File.Copy($@"{Environment.CurrentDirectory}\ExternalResources\GeneratedEpisodeHUB\collision.bin", $@"{unpackedArchive}\{corePath}\stage\goa\khii\collision.bin", true);
}

// Add a music reference to bgm.sbk if we're on the 360.
// Add a music reference to bgm.sbk.
if (Path.GetFileName(archive).ToLower() == "sound.arc")
{
string unpackedArchive = await Task.Run(() => Helpers.ArchiveHandler(archive));
Expand All @@ -2722,29 +2728,31 @@ await Task.Run(() => SceneRandomiser.Process(luaFile, sceneLightAmbient, sceneLi

File.Copy($@"{Environment.CurrentDirectory}\ExternalResources\GeneratedEpisodeHUB\stage_goa_khii.arc", $@"{ModDirectory}\win32\archives\stage_goa_khii.arc", true);

// Copy the music XMA.
if (corePath == "xenon")
{
if (!Directory.Exists($@"{ModDirectory}\xenon\sound"))
Directory.CreateDirectory($@"{ModDirectory}\xenon\sound");
// Set up the extension type for the Garden of Assemblage's music.
string musicExtension = ".xma";
if (corePath == "ps3")
musicExtension = ".at3";

File.Copy($@"{Environment.CurrentDirectory}\ExternalResources\GeneratedEpisodeHUB\stg_goa_khii.xma", $@"{ModDirectory}\xenon\sound\stg_goa_khii.xma", true);
}
// Copy the music XMA/AT3.
if (!Directory.Exists($@"{ModDirectory}\{corePath}\sound"))
Directory.CreateDirectory($@"{ModDirectory}\{corePath}\sound");

File.Copy($@"{Environment.CurrentDirectory}\ExternalResources\GeneratedEpisodeHUB\stg_goa_khii{musicExtension}", $@"{ModDirectory}\{corePath}\sound\stg_goa_khii{musicExtension}", true);

// Edit the mod ini to include the custom stuff.
// Setup a check in chase we already have Custom Files.
bool alreadyHasCustom = false;

// Set the initial path.
string archivePath = "Custom=\"stage_goa_khii.arc,stg_goa_khii.xma\"";
string archivePath = $"Custom=\"stage_goa_khii.arc,stg_goa_khii{musicExtension}\"";

// Load the mod configuration ini to see if we already have custom content. If we do, then read the custom files line.
string[] modConfig = File.ReadAllLines(Path.Combine($@"{ModDirectory}", "mod.ini"));
if (modConfig[9].Contains("True") || modConfig.Length == 11)
{
alreadyHasCustom = true;
archivePath = modConfig[10].Remove(modConfig[10].LastIndexOf('\"'));
archivePath += ",stage_goa_khii.arc,stage_goa_khii.xma\"";
archivePath += $",stage_goa_khii.arc,stage_goa_khii{musicExtension}\"";
}

// If we aren't already using custom files, then write the custom list the same way as the custom music function does.
Expand Down
3 changes: 3 additions & 0 deletions MarathonRandomiser/MarathonRandomiser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
<None Update="ExternalResources\GeneratedEpisodeHUB\stage_goa_khii.arc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ExternalResources\GeneratedEpisodeHUB\stg_goa_khii.at3">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ExternalResources\GeneratedEpisodeHUB\stg_goa_khii.xma">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down

0 comments on commit 653955d

Please sign in to comment.