Files
wiicompiled/Launcher/WiiCompiled.Setup.Windows/Program.cs
T
patchzyy ac99413d45 v0.9.0 (v1.0 beta) (#338)
* move aurora to the aurora-wiicompiled submodule (#315)

* Update settings_overlay.cpp (#257)

* Simplify controller settings menu (#317)

* simplify controller settings menu

* platform pairing hint

* build for x86-64-v2 on older linux cpus (#319)

* Real Wii Remote support over Bluetooth (#323)

* pass real wii remotes through emulated bluetooth

* build bluetooth tests on macos ci

* address review comments

* cancel replaced bluetooth reads

* Run GX on its own thread (#325)

* NTSC-U and NTSC-J support (#326)

* add ntsc-u and ntsc-j support

Co-authored-by: DarthMDev <mgracer48@yahoo.com>
Co-authored-by: rooklz <rookieb@muzo-works.com>

* hash inc files and require project for shards

* port remaining stale rr us hooks

* drop map report generation

* drop one-off region porters

---------

Co-authored-by: DarthMDev <mgracer48@yahoo.com>
Co-authored-by: rooklz <rookieb@muzo-works.com>

* Keyboard input for friend code entry (#327)

* keyboard input for friend code entry

* add new guest imports to synthetic test

* replace per-address region table with range map (#328)

* paste friend codes from clipboard (#329)

* Verify dependency archive hashes (#330)

* verify dependency archive hashes

* verify cached cppwinrt tool

* check dependency path types

* Check CPU support before building (#331)

* check cpu support before building

* build for x86-64-v2 on windows and intel macs

* bump aurora for fog fsel fix

* add vsync option (#333)

* Add exe icons (#334)

* add exe icons

* rebuild icon resource on ico change

* drop icon rebuild tracking

* Fix bugs found in forks (#336)

* port fixes found in forks

* fill whole disk id

* dump kamek overlay on crash (#335)

* bump aurora and version to 0.9.0

---------

Co-authored-by: DarthMDev <mgracer48@yahoo.com>
Co-authored-by: rooklz <rookieb@muzo-works.com>
2026-10-23 18:00:55 +02:00

142 lines
5.6 KiB
C#

namespace WiiCompiled.Setup.Windows;
using System.Reflection;
using System.Runtime.InteropServices;
internal static class Program
{
private static int Main(string[] args)
{
var progressJson = CommandLine.WantsProgressJson(args);
try
{
PlatformChecks.EnsureSupportedHost();
if (args.Length == 0 && GetConsoleProcessList(new uint[1], 1) == 1)
{
Console.Out.WriteLine(
"Mario Kart WiiCompiled is installed through Wheel Wizard - download it from " +
"https://github.com/TeamWheelWizard/WheelWizard");
Console.ReadKey(intercept: true);
return 0;
}
CommandLine command;
try
{
command = CommandLine.Parse(args);
}
catch (ArgumentException ex) when (args.Length > 0)
{
// A command line was supplied, so a caller is driving this process. Rejecting the
// command with a modal dialog would hang that caller forever.
if (progressJson) new NdjsonInstallReporter(ProductInfo.Version).Failure(ex.Message);
else Console.Error.WriteLine(ex.Message);
return 1;
}
if (command.Mode == AppMode.Version)
return ConsoleCommands.Version();
if (command.Mode == AppMode.Help)
return ConsoleCommands.Help();
if (command.Mode == AppMode.SelfTest)
return SelfTests.Run();
if (command.Mode == AppMode.VerifyInputs)
return ConsoleCommands.VerifyInputs(command);
if (command.Mode == AppMode.EmitPayloadIdentities)
return ConsoleCommands.EmitPayloadIdentities(command);
if (command.Mode == AppMode.CheckProducts)
{
using var cancellationSignal = CancellationSignal.ObserveEnvironment();
return ConsoleCommands.CheckProducts(command, cancellationSignal.Token);
}
if (command.Mode is AppMode.LaunchBase or AppMode.LaunchRetro)
return GameLaunchService.LaunchAsync(
command.Mode == AppMode.LaunchBase ? BuildProfile.Base : BuildProfile.RetroRewind)
.GetAwaiter().GetResult();
if (command.Mode is AppMode.SilentInstall or AppMode.RepairProducts)
{
// CPUs without x86-64-v3 get an x86-64-v2 build.
HostCpuRequirement.EnsureSupported(X86CpuProfile.V2);
using var cancellationSignal = CancellationSignal.ObserveEnvironment();
return command.Mode == AppMode.SilentInstall
? ConsoleCommands.Install(command, cancellationSignal.Token).GetAwaiter().GetResult()
: ConsoleCommands.RepairProducts(command, cancellationSignal.Token)
.GetAwaiter().GetResult();
}
if (command.Mode is AppMode.Uninstall or AppMode.SilentUninstall)
{
UninstallService.StartWorker(command.InstallDirectory!,
quiet: command.Mode == AppMode.SilentUninstall || command.Quiet);
return 0;
}
if (command.Mode == AppMode.UninstallWorker)
return UninstallService.RunWorker(command.InstallDirectory!, command.Quiet);
return ConsoleCommands.Help();
}
catch (Exception ex)
{
// A caller reading the NDJSON protocol must always receive a terminal result line, even
// when the failure happened before the installer was reached (a bad command line, for
// instance). ConsoleCommands already reports its own failures, so this only fires for
// errors raised outside it.
if (progressJson)
{
new NdjsonInstallReporter(ProductInfo.Version).Failure(ex.Message);
Console.Error.WriteLine(ex);
}
else
{
Console.Error.WriteLine(ex);
}
return 1;
}
}
[DllImport("kernel32.dll", SetLastError = true)]
private static extern uint GetConsoleProcessList(
[Out] uint[] processList,
uint processCount);
}
internal static class PlatformChecks
{
public static void EnsureSupportedHost()
{
if (!OperatingSystem.IsWindows() || !Environment.Is64BitOperatingSystem)
throw new PlatformNotSupportedException("WiiCompiled requires 64-bit Windows.");
if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 18362))
throw new PlatformNotSupportedException("WiiCompiled requires Windows 10 version 1903 or newer.");
}
}
internal static class ProductInfo
{
public const string Name = "WiiCompiled";
public static readonly string Version =
typeof(ProductInfo).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!
.InformationalVersion;
/// <summary>
/// The setup executable is copied into the installation under this name. It is the launcher and
/// launch entry point named by the Wheel Wizard contract, so the name is part of that interface.
/// </summary>
public const string SetupCopyName = "WiiCompiled-Setup.exe";
public const string UninstallKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\WiiCompiled";
public static string DefaultInstallDirectory =>
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Programs", "WiiCompiled");
}