150 lines
No EOL
6.7 KiB
C#
150 lines
No EOL
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using BetaVersionLauncher;
|
|
using TeaBox.Code;
|
|
using TeaBox.Macros;
|
|
|
|
namespace TeaBox.BuildVersion
|
|
{
|
|
public class MakeNxPackageCommand : MakePackageCommand
|
|
{
|
|
private string DiscName => $"{UAFConstants.GameName}_Game_{DataChangelist}_{Branch}.nsp";
|
|
protected string PatchName => $"{UAFConstants.GameName}_Patch_{DataChangelist}_{Branch}.nsp";
|
|
protected override string CodeWorkingDirectory => Path.Combine(WorkingDirectory, "code");
|
|
protected override string DataWorkingDirectory => Path.Combine(WorkingDirectory, "data");
|
|
protected string OutputGame { get; set; }
|
|
protected string MetaFile { get; set; }
|
|
protected string DescFile { get; set; }
|
|
protected string ProgramFile { get; set; }
|
|
protected string Icon { get; set; }
|
|
protected string LegalInformation { get; set; }
|
|
|
|
protected override IEnumerable<string> GetFilesList()
|
|
{
|
|
return new List<string>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nx has a different organisation, we only want the rpx from the executable folder
|
|
/// </summary>
|
|
protected override void CopyDataFromOutput(IStep stepcontext)
|
|
{
|
|
Func<string, bool> keepFunc = file =>
|
|
{
|
|
var patterns = new[] { ".csv", ".txt" };
|
|
return !patterns.Any(file.Replace('\\', '/').Contains);
|
|
};
|
|
|
|
stepcontext.LogMessage("== Data copy step ==");
|
|
stepcontext.LogMessage($"Starting to copy data from {GameConstants.BundleOutputPath} to {DataWorkingDirectory}");
|
|
RoboCopy.ReplicateDirectory(GameConstants.BundleOutputPath, DataWorkingDirectory, stepcontext, deleteMissingFiles:false, @where: keepFunc);
|
|
|
|
/* To activate if patch needs to be included on the master
|
|
stepcontext.LogMessage("== Patch ( empty ) copy step ==");
|
|
stepcontext.LogMessage($"Starting to copy data from {UAFConstants.BundleOutput} to {DataWorkingDirectory}");
|
|
RoboCopy.ReplicateDirectory(UAFConstants.PatchOutput, DataWorkingDirectory, stepcontext, deleteMissingFiles: false, where: keepFunc); */
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nx has a different organisation, we only want the rpx from the executable folder
|
|
/// </summary>
|
|
protected override void CopyExecutableFromOutput(IStep stepcontext)
|
|
{
|
|
// excluding icon and meta from code directory
|
|
Func<string, bool> excludedFile = file =>
|
|
{
|
|
var patterns = new[] { "dashboard", ".meta" };
|
|
return !patterns.Any(file.Replace('\\', '/').Contains);
|
|
};
|
|
|
|
RoboCopy.ReplicateDirectory(EngineExecutable.DeliveredDirectory, CodeWorkingDirectory, stepcontext, true, @where: excludedFile);
|
|
}
|
|
|
|
protected override void PrePackageImpl()
|
|
{
|
|
PkgTool = NxConstants.GetPackageTool();
|
|
|
|
base.PrePackageImpl();
|
|
|
|
OutputGame = Path.Combine(OutputDirectory, DiscName);
|
|
|
|
Context.AddStep("Make Local Copy Of Meta, Application File and Icon", step =>
|
|
{
|
|
ProgramFile = Path.Combine(CodeWorkingDirectory, Variant != DevEnvBuildVariant.Release ? "nx_ua_engine_f.nspd" : "nx_ua_engine_r.nspd", "program0.ncd", "code");
|
|
|
|
// Copy NX gameroot to the ressource directory
|
|
RoboCopy.ReplicateDirectory(EngineExecutable.DeliveredDirectory, ResourcesDirectory, Context, verbose: true);
|
|
|
|
// Copy Application desc file to ressource directory
|
|
var descFile = Path.Combine(NxConstants.GetResourcesPath(), "Application.desc");
|
|
DescFile = Path.Combine(ResourcesDirectory, "Application.desc");
|
|
File.Copy(descFile, DescFile, true);
|
|
|
|
// Get the patch name of the legal information zip
|
|
// Remove Ox from the application ID
|
|
var applicationId = string.Join(string.Empty, NxConstants.GetProductId(GameType).Skip(2));
|
|
Context.LogMessage($"Application ID is : {applicationId}");
|
|
var zips = Directory.GetFiles(EngineExecutable.DeliveredDirectory, $"legal_info_{applicationId}_*.zip");
|
|
|
|
// Check if at least one zip file has been found
|
|
var zip = zips as string[] ?? zips.ToArray();
|
|
|
|
if (zips == null || zip.IsEmpty())
|
|
{
|
|
Context.LogError("No Legal Information Zip");
|
|
return;
|
|
}
|
|
|
|
if (zip.Count() > 1)
|
|
{
|
|
Context.LogWarning($"{zip.Count()} zips files were found");
|
|
return;
|
|
}
|
|
|
|
LegalInformation = zip[0];
|
|
|
|
// Get the path of the Icon
|
|
Icon = Path.Combine(ResourcesDirectory, "dashboard_00.bmp");
|
|
|
|
// get the path of the SDK meta file into the working directory
|
|
MetaFile = Path.Combine(ResourcesDirectory, "JD.aarch64.lp64.meta");
|
|
});
|
|
|
|
Context.AddStep("Update Meta Display Version", step =>
|
|
{
|
|
var engineChangelist = PackageUtilities.GetChangelistCode(Path.Combine(ResourcesDirectory, "engine.dat"));
|
|
var newContent = $" <DisplayVersion>{engineChangelist}.{DataChangelist}</DisplayVersion>";
|
|
step.LogMessage($"Engine changelist = {engineChangelist}");
|
|
step.LogMessage($"Data changelist = {DataChangelist}");
|
|
|
|
PackageUtilities.UpdateFileContent(Context, MetaFile, "<DisplayVersion>", newContent);
|
|
|
|
// Remove Flagpresets line from meta
|
|
PackageUtilities.XmlNodeRemove(Context, MetaFile, "/Meta/Core/FsAccessControlData", "FlagPresets");
|
|
});
|
|
}
|
|
|
|
protected override void SetOnlineEnvironmentImpl()
|
|
{
|
|
// Environment none, uat are default ones, don't need to change anything on the disc layout
|
|
if (GameOnlineEnvironment == GameOnlineEnvironment.Default || GameOnlineEnvironment.ToString().ToLower() == "uat" ||
|
|
GameOnlineEnvironment.ToString().ToLower() == "")
|
|
{
|
|
Context.LogWarning($"Selected environment: - {GameOnlineEnvironment} - doesn't require any changes");
|
|
return;
|
|
}
|
|
|
|
base.SetOnlineEnvironmentImpl();
|
|
}
|
|
|
|
protected override void GeneratePackageImpl()
|
|
{
|
|
base.GeneratePackageImpl();
|
|
|
|
Context.AddStep("Creating package",
|
|
new GenericCommand(PkgTool, $"creatensp -o {OutputGame} --meta {MetaFile} --desc {DescFile} --program {ProgramFile} {DataWorkingDirectory} --type Application --verbose").Execute);
|
|
}
|
|
}
|
|
} |