Skip to content

Commit

Permalink
Added support for modding Sound folder for SMTV and fixed Alt. downlo…
Browse files Browse the repository at this point in the history
…ad regression
  • Loading branch information
TekkaGB committed Nov 13, 2021
1 parent 48ad8ef commit 3a9e83f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Unverum/FeedGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static string GenerateUrl(int page, GameFilter game, TypeFilter type, Fe
}
// Consistent args
url += $"_csvProperties=_sName,_sModelName,_sProfileUrl,_aSubmitter,_tsDateUpdated,_tsDateAdded,_aPreviewMedia,_sText,_sDescription,_aCategory,_aRootCategory,_aGame,_nViewCount," +
$"_nLikeCount,_nDownloadCount,_aFiles,_aModManagerIntegrations,_bIsNsfw&_nPerpage={perPage}";
$"_nLikeCount,_nDownloadCount,_aFiles,_aModManagerIntegrations,_bIsNsfw,_aAlternateFileSources&_nPerpage={perPage}";
if (!nsfw)
url += "&_aArgs[]=_sbIsNsfw = false";
// Sorting filter
Expand Down
24 changes: 23 additions & 1 deletion Unverum/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public static bool Restart(string path, string movies, string splash, string sou
if (Directory.Exists(Global.config.Configs[Global.config.CurrentGame].PatchesFolder))
Directory.Delete(Global.config.Configs[Global.config.CurrentGame].PatchesFolder, true);
Directory.CreateDirectory(Global.config.Configs[Global.config.CurrentGame].PatchesFolder);
// Delete sound folder in romfs if it exists
var SwitchSound = Global.config.Configs[Global.config.CurrentGame].PatchesFolder.Replace("exefs", $"romfs{Global.s}Project{Global.s}Content{Global.s}Sound");
if (Directory.Exists(SwitchSound))
Directory.Delete(SwitchSound, true);
}
// Reset movies and splash folder
if (!String.IsNullOrEmpty(movies) && Directory.Exists(movies))
Expand Down Expand Up @@ -51,7 +55,7 @@ private static int CopyFolder(string sourcePath, string targetPath, string defau
{
var counter = 0;
//Copy all the files & Replaces any files with the same name
foreach (string path in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories))
foreach (var path in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories))
{
if (Path.GetExtension(path).Equals(".pak", StringComparison.InvariantCultureIgnoreCase))
{
Expand All @@ -77,6 +81,24 @@ private static int CopyFolder(string sourcePath, string targetPath, string defau
counter++;
}
}

// Copy over Sound folder to proper location for SMTV if it exists
if (Global.config.CurrentGame.Equals("Shin Megami Tensei V", StringComparison.InvariantCultureIgnoreCase))
foreach (var path in Directory.GetDirectories(sourcePath, "*.*", SearchOption.AllDirectories))
{
var SoundFolder = Global.config.Configs[Global.config.CurrentGame].PatchesFolder.Replace("exefs", $"romfs{Global.s}Project{Global.s}Content{Global.s}Sound");
if (Path.GetFileName(path).Equals("Sound", StringComparison.InvariantCultureIgnoreCase))
{
foreach(var file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
{
var newPath = file.Replace(path, SoundFolder);
Directory.CreateDirectory(Path.GetDirectoryName(newPath));
Global.logger.WriteLine($"Copying over {file} to {newPath}", LoggerType.Info);
File.Copy(file, newPath, true);
}
break;
}
}
return counter;
}

Expand Down
4 changes: 4 additions & 0 deletions Unverum/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async static void CheckForUpdates(string path, MainWindow main)
main.LaunchButton.IsEnabled = false;
main.OpenModsButton.IsEnabled = false;
main.UpdateButton.IsEnabled = false;
main.LauncherOptionsBox.IsEnabled = false;
main.Activate();
return;
}
Expand Down Expand Up @@ -97,6 +98,7 @@ public async static void CheckForUpdates(string path, MainWindow main)
main.LaunchButton.IsEnabled = true;
main.OpenModsButton.IsEnabled = true;
main.UpdateButton.IsEnabled = true;
main.LauncherOptionsBox.IsEnabled = true;
return;
}
List<GameBananaAPIV4> response = new List<GameBananaAPIV4>();
Expand All @@ -121,6 +123,7 @@ public async static void CheckForUpdates(string path, MainWindow main)
main.LaunchButton.IsEnabled = true;
main.OpenModsButton.IsEnabled = true;
main.UpdateButton.IsEnabled = true;
main.LauncherOptionsBox.IsEnabled = true;
return;
}
}
Expand Down Expand Up @@ -155,6 +158,7 @@ public async static void CheckForUpdates(string path, MainWindow main)
main.LaunchButton.IsEnabled = true;
main.OpenModsButton.IsEnabled = true;
main.UpdateButton.IsEnabled = true;
main.LauncherOptionsBox.IsEnabled = true;
main.Activate();
}
private static void ReportUpdateProgress(DownloadProgress progress)
Expand Down
8 changes: 7 additions & 1 deletion Unverum/UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public MainWindow()
LaunchButton.IsEnabled = false;
OpenModsButton.IsEnabled = false;
UpdateButton.IsEnabled = false;
LauncherOptionsBox.IsEnabled = false;
App.Current.Dispatcher.Invoke(() =>
{
ModUpdater.CheckForUpdates($"{Global.assemblyLocation}{Global.s}Mods{Global.s}{Global.config.CurrentGame}", this);
Expand Down Expand Up @@ -347,6 +348,7 @@ private async void Launch_Click(object sender, RoutedEventArgs e)
LaunchButton.IsEnabled = false;
OpenModsButton.IsEnabled = false;
UpdateButton.IsEnabled = false;
LauncherOptionsBox.IsEnabled = false;
Refresh();
Directory.CreateDirectory(Global.config.Configs[Global.config.CurrentGame].ModsFolder);
Global.logger.WriteLine($"Building loadout for {Global.config.CurrentGame}", LoggerType.Info);
Expand All @@ -359,6 +361,7 @@ private async void Launch_Click(object sender, RoutedEventArgs e)
OpenModsButton.IsEnabled = true;
UpdateButton.IsEnabled = true;
GameBox.IsEnabled = true;
LauncherOptionsBox.IsEnabled = true;
return;
}
ModGrid.IsEnabled = true;
Expand All @@ -367,6 +370,7 @@ private async void Launch_Click(object sender, RoutedEventArgs e)
OpenModsButton.IsEnabled = true;
UpdateButton.IsEnabled = true;
GameBox.IsEnabled = true;
LauncherOptionsBox.IsEnabled = true;
}
else
{
Expand Down Expand Up @@ -601,7 +605,7 @@ private async Task<bool> Build(string path)
MoviesFolder = $"{ContentFolder}{Global.s}Binaries{Global.s}Movie";
else if (Directory.Exists($"{ContentFolder}{Global.s}Movies"))
MoviesFolder = $"{ContentFolder}{Global.s}Movie";
if (Directory.Exists($"{ContentFolder}{Global.s}Sound"))
if (Directory.Exists($"{ContentFolder}{Global.s}Sound") && !Global.config.CurrentGame.Equals("Shin Megami Tensei V", StringComparison.InvariantCultureIgnoreCase))
SoundsFolder = $"{ContentFolder}{Global.s}Sound";
else if (Directory.Exists($"{ContentFolder}{Global.s}CriWareData"))
SoundsFolder = $"{ContentFolder}{Global.s}CriWareData";
Expand Down Expand Up @@ -841,6 +845,7 @@ private void Update_Click(object sender, RoutedEventArgs e)
LaunchButton.IsEnabled = false;
OpenModsButton.IsEnabled = false;
UpdateButton.IsEnabled = false;
LauncherOptionsBox.IsEnabled = false;
App.Current.Dispatcher.Invoke(() =>
{
ModUpdater.CheckForUpdates($"{Global.assemblyLocation}{Global.s}Mods{Global.s}{Global.config.CurrentGame}", this);
Expand Down Expand Up @@ -1747,6 +1752,7 @@ private void GameBox_DropDownClosed(object sender, EventArgs e)
LaunchButton.IsEnabled = false;
OpenModsButton.IsEnabled = false;
UpdateButton.IsEnabled = false;
LauncherOptionsBox.IsEnabled = false;
App.Current.Dispatcher.Invoke(() =>
{
ModUpdater.CheckForUpdates($"{Global.assemblyLocation}{Global.s}Mods{Global.s}{Global.config.CurrentGame}", this);
Expand Down
2 changes: 1 addition & 1 deletion Unverum/Unverum.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\unverum.ico</ApplicationIcon>
<AssemblyName>Unverum</AssemblyName>
<AssemblyVersion>1.5.0.0</AssemblyVersion>
<AssemblyVersion>1.5.1.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 3a9e83f

Please sign in to comment.