Skip to content

Commit

Permalink
Add P5R EU, use mod.cpk for USA, bump to 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrineFox committed Jan 11, 2021
1 parent 715bc2f commit 5fb80b1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions Source/ModCompendium/GameConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ public GameConfigWindow(GameConfig config)
Height = 35,
};
region.Items.Add("UP0177-CUSA17416");
region.Items.Add("EP0177-CUSA17419");
region.Items.Add("JP0005-CUSA08644");
//region.Items.Add("HP0177-CUSA17544");

Expand Down
6 changes: 3 additions & 3 deletions Source/ModCompendium/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany( "" )]
[assembly: AssemblyProduct( "ModCompendium" )]
[assembly: AssemblyCopyright( "Copyright © 2018 - 2020" )]
[assembly: AssemblyCopyright( "Copyright © 2018 - 2021" )]
[assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture( "" )]

Expand Down Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion( "1.6.0.0" )]
[assembly: AssemblyFileVersion( "1.6.0.0" )]
[assembly: AssemblyVersion( "1.6.0.1" )]
[assembly: AssemblyFileVersion( "1.6.0.1" )]
28 changes: 17 additions & 11 deletions Source/ModCompendiumLibrary/ModSystem/Builders/PS4PKGModBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ public VirtualFileSystemEntry Build(VirtualDirectory root, List<Mod> enabledMods

//Get game config
var config = ConfigStore.Get(Game) as PKGGameConfig ?? throw new InvalidOperationException("Game config is missing.");
//Set cpk name
string cpkName = "patch1R";
if (config.Region.Split('-')[1] == "CUSA17416")
{
cpkName = "mod";
}

Log.Builder.Info($"Building {gameName} Mod");
Log.Builder.Info("Processing mod files");

var modFilesDirectory = new VirtualDirectory(null, "patch1R");
var modFilesDirectory = new VirtualDirectory(null, cpkName);
foreach (var entry in root)
{
if (entry.EntryType == VirtualFileSystemEntryType.Directory)
Expand All @@ -55,30 +61,30 @@ public VirtualFileSystemEntry Build(VirtualDirectory root, List<Mod> enabledMods

default:
// Move directory to 'mod' directory
Log.Builder.Trace($"Adding directory {entry.FullName} to patch1R.cpk");
Log.Builder.Trace($"Adding directory {entry.FullName} to {cpkName}.cpk");
entry.CopyTo(modFilesDirectory);
break;
}
}
else
{
// Move file to 'mod' directory
Log.Builder.Trace($"Adding file {entry.FullName} to patch1R.cpk");
Log.Builder.Trace($"Adding file {entry.FullName} to {cpkName}.cpk");
entry.CopyTo(modFilesDirectory);
}
}

bool.TryParse(config.Compression, out useCompression);

// Build mod cpk
Log.Builder.Info($"Building patch1R.cpk");
Log.Builder.Info($"Building {cpkName}.cpk");
var cpkModCompiler = new CpkModBuilder();

if (hostOutputPath != null) Directory.CreateDirectory(hostOutputPath);

var cpkFilePath = hostOutputPath != null ? Path.Combine(hostOutputPath, "patch1R.cpk") : null;
var cpkFilePath = hostOutputPath != null ? Path.Combine(hostOutputPath, $"{cpkName}.cpk") : null;
var cpkNotWritable = File.Exists(cpkFilePath) && FileHelper.IsFileInUse(cpkFilePath);
var cpkFileBuildPath = hostOutputPath != null ? cpkNotWritable ? Path.Combine(Path.GetTempPath(), "patch1R.cpk") : cpkFilePath : null;
var cpkFileBuildPath = hostOutputPath != null ? cpkNotWritable ? Path.Combine(Path.GetTempPath(), $"{cpkName}.cpk") : cpkFilePath : null;
var cpkFile = cpkModCompiler.Build(modFilesDirectory, enabledMods, cpkFileBuildPath, gameName, useCompression);

if (cpkFileBuildPath != cpkFilePath)
Expand All @@ -92,7 +98,7 @@ public VirtualFileSystemEntry Build(VirtualDirectory root, List<Mod> enabledMods
if (File.Exists(cpkFilePath))
{
string programPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string patch1R = $"{programPath}\\Dependencies\\GenGP4\\{config.Region.Split('-')[1]}-patch\\USRDIR\\patch1R.cpk";
string moddedCpk = $"{programPath}\\Dependencies\\GenGP4\\{config.Region.Split('-')[1]}-patch\\USRDIR\\{cpkName}.cpk";
string outputPKG = $"{programPath}\\Output\\Persona5Royal\\{config.Region}_00-PERSONA5R0000000-A0101-V0100.pkg";

Log.Builder.Info($"Building update .pkg");
Expand All @@ -101,10 +107,10 @@ public VirtualFileSystemEntry Build(VirtualDirectory root, List<Mod> enabledMods
if (!File.Exists(config.PKGPath))
throw new InvalidConfigException("Original game .pkg not found at specified location.");
//Copy to patch folder
if (File.Exists(patch1R))
File.Delete(patch1R);
File.Copy(cpkFilePath, patch1R);
using (WaitForFile(patch1R, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { };
if (File.Exists(moddedCpk))
File.Delete(moddedCpk);
File.Copy(cpkFilePath, moddedCpk);
using (WaitForFile(moddedCpk, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { };
//Edit XML/SFO
string mods = "";
foreach (var mod in enabledMods)
Expand Down

0 comments on commit 5fb80b1

Please sign in to comment.