Add basic command line interface

This commit is contained in:
Jarrod Doyle 2024-10-28 20:40:06 +00:00
parent 0ea00fa109
commit 350a891118
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 37 additions and 15 deletions

View File

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="TinyEmbree" Version="1.0.3" />
</ItemGroup>

View File

@ -1,25 +1,46 @@
using System.CommandLine;
namespace KeepersCompound.Lightmapper;
class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
Timing.Reset();
var installPathArg = new Argument<string>(
"installPath",
"The path to the root Thief installation.");
var campaignNameArg = new Argument<string>(
"campaignName",
"The folder name of the fan mission. For OMs this is blank.");
var missionNameArg = new Argument<string>(
"missionName",
"The name of the mission file including extension.");
var outputFileOption = new Option<string>(
["-o", "--output"],
() => "kc_lit",
"Name of output file excluding extension.");
var multiSamplingOption = new Option<bool>(
"--multiSampling",
() => false,
"Enables multi-sampled shadows. Higher quality but slower.");
// TODO: Read this from args
var installPath = "/stuff/Games/thief/drive_c/GOG Games/TG ND 1.27 (MAPPING)/";
var campaignName = "JAYRUDE_Tests";
var missionName = "lm_test.cow";
var rootCommand = new RootCommand("Compute lightmaps for a NewDark .MIS/.COW");
rootCommand.AddArgument(installPathArg);
rootCommand.AddArgument(campaignNameArg);
rootCommand.AddArgument(missionNameArg);
rootCommand.AddOption(outputFileOption);
rootCommand.AddOption(multiSamplingOption);
rootCommand.SetHandler((installPath, campaignName, missionName, outputFile, multiSampling) =>
{
Timing.Reset();
// campaignName = "JAYRUDE_1MIL_Mages";
// campaignName = "TDP20AC_a_burrick_in_a_room";
// campaignName = "AtdV";
// missionName = "miss20.mis";
var lightMapper = new LightMapper(installPath, campaignName, missionName);
lightMapper.Light(multiSampling);
lightMapper.Save(outputFile);
var lightMapper = new LightMapper(installPath, campaignName, missionName);
lightMapper.Light(false);
lightMapper.Save("kc_lit");
Timing.LogAll();
}, installPathArg, campaignNameArg, missionNameArg, outputFileOption, multiSamplingOption);
Timing.LogAll();
rootCommand.Invoke(args);
}
}