Initial version
This commit is contained in:
1 parent
2cff35f215
commit
fe8e2cb5e7
360 files changed
+253989
-74
No files matched your search
@@ -0,0 +1,279 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace EonaCat.XSBOX.Launcher;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new LauncherForm());
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record Setting(string Page, string Label, string Key, string Default, string[] Values, string Description);
|
||||
internal sealed record GameEntry(string Name, string Executable, string Directory, string? IconPath = null);
|
||||
|
||||
internal sealed partial class LauncherForm : Form
|
||||
{
|
||||
static readonly Color Panel0 = Color.FromArgb(10, 10, 13);
|
||||
static readonly Color Panel1 = Color.FromArgb(18, 18, 22);
|
||||
static readonly Color Panel2 = Color.FromArgb(27, 23, 27);
|
||||
|
||||
readonly string root = FindRoot();
|
||||
readonly string exe;
|
||||
readonly string? logoPath = LauncherBrand.ResolveLogoPath();
|
||||
readonly string settingsPath = GetSettingsPath();
|
||||
readonly TextBox gamePath = new() { Width = 590 };
|
||||
readonly FlowLayoutPanel gameTiles = new() { Dock = DockStyle.Fill, AutoScroll = true, WrapContents = true, BackColor = Panel1 };
|
||||
readonly Label selectedGameLabel = new() { Dock = DockStyle.Fill, AutoSize = false, AutoEllipsis = true, UseMnemonic = false, TextAlign = ContentAlignment.MiddleLeft, ForeColor = Color.Gainsboro };
|
||||
readonly List<GameEntry> games = new();
|
||||
GameEntry? selectedGame;
|
||||
readonly string home = GetHomePath();
|
||||
readonly string gameListPath = Path.Combine(GetHomePath(), "launcher-games.json");
|
||||
readonly string selectedGamePath = Path.Combine(GetHomePath(), "launcher-selected-game.txt");
|
||||
readonly WrapLabel status = new() { AutoHeight = true, MaxLines = 3, ForeColor = Color.LightGreen };
|
||||
readonly TabControl tabs = new() { Dock = DockStyle.Fill, Multiline = true, HotTrack = true };
|
||||
readonly Dictionary<string, Control> editors = new(StringComparer.Ordinal);
|
||||
readonly TextBox output = new() { Multiline = true, ReadOnly = true, ScrollBars = ScrollBars.Vertical, Dock = DockStyle.Fill, BackColor = Color.FromArgb(12, 12, 15), ForeColor = Color.Gainsboro, Font = Ui.Font(9, FontStyle.Regular, "Consolas"), MaxLength = int.MaxValue };
|
||||
readonly System.Windows.Forms.Timer outputPump = new() { Interval = 100 };
|
||||
PreloadProgressDialog? preloadDialog;
|
||||
Bitmap? logoBitmap;
|
||||
bool logoLoaded;
|
||||
Button? scanButton;
|
||||
|
||||
public LauncherForm()
|
||||
{
|
||||
exe = Path.Combine(root, "eonacat-xsbox.exe");
|
||||
Text = "EonaCat XS";
|
||||
AutoScaleMode = AutoScaleMode.None; // every size below is scaled explicitly with Ui.S
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
var area = Screen.FromPoint(Cursor.Position).WorkingArea;
|
||||
MinimumSize = new Size(Math.Min(Ui.S(940), area.Width), Math.Min(Ui.S(680), area.Height));
|
||||
Size = new Size(Math.Min(Ui.S(1120), area.Width - Ui.S(40)), Math.Min(Ui.S(820), area.Height - Ui.S(40)));
|
||||
BackColor = Panel1; ForeColor = Color.White;
|
||||
Font = Ui.Font(9.5f);
|
||||
Icon = LauncherBrand.CreateIcon();
|
||||
|
||||
gameTiles.Padding = new Padding(Ui.S(14));
|
||||
selectedGameLabel.Font = Ui.Font(10);
|
||||
tabs.Padding = new Point(Ui.S(14), Ui.S(6));
|
||||
|
||||
var header = BuildHeader();
|
||||
var footerActions = BuildFooterActions();
|
||||
status.Dock = DockStyle.Bottom;
|
||||
status.BackColor = Panel0;
|
||||
status.Padding = new Padding(Ui.S(14), Ui.S(2), Ui.S(14), Ui.S(8));
|
||||
var gamePanel = BuildGamePanel();
|
||||
|
||||
BuildOverviewPage();
|
||||
BuildGamesPage();
|
||||
var pageOrder = new[] { "Graphics", "Display & Stats", "Frame Generation", "Textures & Streaming", "Memory", "Controls", "Advanced" };
|
||||
foreach (var page in pageOrder.Where(page => Settings.Any(setting => setting.Page == page))) BuildPage(page);
|
||||
BuildToolsPage();
|
||||
var logTab = new TabPage("Installer log") { Name = "Installer log", BackColor = BackColor, ForeColor = ForeColor };
|
||||
logTab.Controls.Add(output);
|
||||
logTab.Controls.Add(CreatePageHeader("Installer log", "Engine output, runtime setup and diagnostic messages"));
|
||||
tabs.TabPages.Add(logTab);
|
||||
|
||||
// Dock order: the control added first (the tabs) fills whatever the later, edge-docked controls leave.
|
||||
Controls.Add(tabs); Controls.Add(gamePanel); Controls.Add(header); Controls.Add(footerActions); Controls.Add(status);
|
||||
tabs.SelectedIndex = 0;
|
||||
LoadSettings();
|
||||
LoadGameLibrary();
|
||||
|
||||
outputPump.Tick += (_, _) => PumpEngineOutput();
|
||||
outputPump.Start();
|
||||
Shown += async (_, _) => await ScanForGamesAsync();
|
||||
status.Text = "Settings, shaders, caches and game data are stored under %LOCALAPPDATA%\\EonaCat\\XS";
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
outputPump.Dispose();
|
||||
preloadDialog?.Dispose();
|
||||
logoBitmap?.Dispose();
|
||||
foreach (var bitmap in tileIcons.Values) bitmap?.Dispose();
|
||||
tileIcons.Clear();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
Bitmap? CreateLogoBitmap()
|
||||
{
|
||||
if (logoLoaded) return logoBitmap;
|
||||
logoLoaded = true;
|
||||
if (logoPath == null) return null;
|
||||
try
|
||||
{
|
||||
using var icon = new Icon(logoPath, Ui.S(64), Ui.S(64)); // picks the sharpest frame for this DPI
|
||||
logoBitmap = icon.ToBitmap();
|
||||
}
|
||||
catch { logoBitmap = null; }
|
||||
return logoBitmap;
|
||||
}
|
||||
|
||||
Panel BuildHeader()
|
||||
{
|
||||
var header = new Panel { Dock = DockStyle.Top, Height = Ui.S(92), Padding = new Padding(Ui.S(18), Ui.S(10), Ui.S(18), Ui.S(10)), BackColor = Panel0 };
|
||||
var titleFont = Ui.Font(22, FontStyle.Bold);
|
||||
var subFont = Ui.Font(9, FontStyle.Bold);
|
||||
var title = new Label { Text = "EonaCat XS", Font = titleFont, ForeColor = Color.White, Dock = DockStyle.Top, Height = titleFont.Height + Ui.S(4), AutoSize = false, AutoEllipsis = true, UseMnemonic = false };
|
||||
var sub = new Label { Text = "XBOX COMPATIBILITY • DIRECT3D 12 • PERFORMANCE", Font = subFont, ForeColor = Color.FromArgb(245, 55, 65), Dock = DockStyle.Top, Height = subFont.Height + Ui.S(4), AutoSize = false, AutoEllipsis = true, UseMnemonic = false };
|
||||
var textHost = new Panel { Dock = DockStyle.Fill, BackColor = Color.Transparent, Padding = new Padding(Ui.S(14), Ui.S(6), 0, 0) };
|
||||
textHost.Controls.Add(sub); textHost.Controls.Add(title);
|
||||
var mark = new PictureBox { Dock = DockStyle.Left, Width = Ui.S(64), SizeMode = PictureBoxSizeMode.Zoom, Image = CreateLogoBitmap(), BackColor = Color.Transparent };
|
||||
header.Controls.Add(textHost); header.Controls.Add(mark);
|
||||
return header;
|
||||
}
|
||||
|
||||
FlowLayoutPanel BuildFooterActions()
|
||||
{
|
||||
var profile = MakeButton("RTX 4090 - UW", 120); profile.Click += (_, _) => ApplyRtx4090Profile();
|
||||
var save = MakeButton("Save settings", 100); save.Click += (_, _) => SaveSettings();
|
||||
var launch = MakeButton("Launch game", 100); launch.Click += (_, _) => LaunchGame();
|
||||
var nvidia = MakeButton("NVIDIA runtime", 120); nvidia.Click += async (_, _) => await RunEngineCommand("get-dlss");
|
||||
var amd = MakeButton("AMD FSR runtime", 120); amd.Click += async (_, _) => await RunEngineCommand("get-fsr");
|
||||
var d3d = MakeButton("D3D12 runtime", 115); d3d.Click += async (_, _) => await RunEngineCommand("get-d3d12");
|
||||
var browse = MakeButton("Browse game…", 100); browse.Click += (_, _) => BrowseGame();
|
||||
var autoGpu = MakeButton("Auto GPU runtime", 135); autoGpu.Click += async (_, _) => await InstallDetectedGpuRuntime();
|
||||
// Docked to the bottom and AutoSize: the bar grows by whole rows when the buttons need to wrap.
|
||||
var footerActions = new FlowLayoutPanel
|
||||
{
|
||||
Dock = DockStyle.Bottom,
|
||||
AutoSize = true,
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink,
|
||||
FlowDirection = FlowDirection.LeftToRight,
|
||||
WrapContents = true,
|
||||
BackColor = Panel0,
|
||||
Padding = new Padding(Ui.S(10), Ui.S(8), Ui.S(10), Ui.S(2))
|
||||
};
|
||||
foreach (var button in new[] { profile, save, launch, browse, autoGpu, nvidia, amd, d3d })
|
||||
{
|
||||
button.Margin = new Padding(Ui.S(3));
|
||||
footerActions.Controls.Add(button);
|
||||
}
|
||||
return footerActions;
|
||||
}
|
||||
|
||||
Panel BuildGamePanel()
|
||||
{
|
||||
var gamePanel = new Panel { Dock = DockStyle.Top, Height = Ui.S(60), Padding = new Padding(Ui.S(14), Ui.S(8), Ui.S(14), Ui.S(8)), BackColor = Panel2 };
|
||||
var gameActions = new FlowLayoutPanel
|
||||
{
|
||||
Dock = DockStyle.Right,
|
||||
AutoSize = true,
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink,
|
||||
FlowDirection = FlowDirection.LeftToRight,
|
||||
WrapContents = false,
|
||||
BackColor = Color.Transparent
|
||||
};
|
||||
scanButton = MakeButton("Scan for Xbox games", 155); scanButton.Click += async (_, _) => await ScanForGamesAsync();
|
||||
var addFolder = MakeButton("Add game folder…", 135); addFolder.Click += (_, _) => AddGameFolder();
|
||||
scanButton.Margin = addFolder.Margin = new Padding(Ui.S(3));
|
||||
gameActions.Controls.Add(scanButton);
|
||||
gameActions.Controls.Add(addFolder);
|
||||
gamePanel.Controls.Add(selectedGameLabel);
|
||||
gamePanel.Controls.Add(gameActions);
|
||||
return gamePanel;
|
||||
}
|
||||
|
||||
Panel CreatePageHeader(string titleText, string subtitleText)
|
||||
{
|
||||
var titleFont = Ui.Font(15, FontStyle.Bold);
|
||||
var subFont = Ui.Font(8.5f);
|
||||
var header = new Panel
|
||||
{
|
||||
Dock = DockStyle.Top,
|
||||
Height = Ui.S(78),
|
||||
Padding = new Padding(Ui.S(18), Ui.S(10), Ui.S(18), Ui.S(8)),
|
||||
BackColor = Color.FromArgb(22, 20, 25)
|
||||
};
|
||||
var title = new Label { Text = titleText, Font = titleFont, ForeColor = Color.White, Dock = DockStyle.Top, Height = titleFont.Height + Ui.S(4), AutoSize = false, AutoEllipsis = true, UseMnemonic = false };
|
||||
var subtitle = new Label { Text = subtitleText, Font = subFont, ForeColor = Color.FromArgb(190, 184, 194), Dock = DockStyle.Top, Height = subFont.Height + Ui.S(4), AutoSize = false, AutoEllipsis = true, UseMnemonic = false };
|
||||
var textHost = new Panel { Dock = DockStyle.Fill, BackColor = Color.Transparent, Padding = new Padding(Ui.S(12), Ui.S(4), 0, 0) };
|
||||
textHost.Controls.Add(subtitle); textHost.Controls.Add(title);
|
||||
var mark = new PictureBox { Dock = DockStyle.Left, Width = Ui.S(54), SizeMode = PictureBoxSizeMode.Zoom, Image = CreateLogoBitmap(), BackColor = Color.Transparent };
|
||||
header.Controls.Add(textHost); header.Controls.Add(mark);
|
||||
return header;
|
||||
}
|
||||
|
||||
static StackPanel Card(Color back) => new()
|
||||
{
|
||||
AutoScroll = false,
|
||||
BackColor = back,
|
||||
Padding = new Padding(Ui.S(18)),
|
||||
Margin = new Padding(0, 0, 0, Ui.S(14))
|
||||
};
|
||||
|
||||
void BuildOverviewPage()
|
||||
{
|
||||
var page = new TabPage("EonaCat") { Name = "EonaCat", BackColor = BackColor, ForeColor = ForeColor };
|
||||
var content = new StackPanel { Dock = DockStyle.Fill, BackColor = BackColor, Padding = new Padding(Ui.S(22)), MaxContentWidth = Ui.S(940) };
|
||||
|
||||
var welcome = Card(Color.FromArgb(30, 25, 31));
|
||||
welcome.Controls.Add(new WrapLabel { Text = "Your Xbox compatibility launcher", Font = Ui.Font(17, FontStyle.Bold), ForeColor = Color.White, Margin = new Padding(0, 0, 0, Ui.S(8)) });
|
||||
welcome.Controls.Add(new WrapLabel { Text = "Choose a game, tune graphics and memory, then launch with the EonaCat XS engine.", ForeColor = Color.Gainsboro, Margin = new Padding(0, 0, 0, Ui.S(8)) });
|
||||
welcome.Controls.Add(new WrapLabel { Text = "GPU-FIRST • DIRECT3D 12 • CONFIGURABLE PERFORMANCE", Font = Ui.Font(8, FontStyle.Bold), ForeColor = Color.FromArgb(245, 55, 65) });
|
||||
|
||||
var actions = new FlowRow { Margin = new Padding(0, 0, 0, Ui.S(8)) };
|
||||
var launch = MakeButton("Launch selected game", 190); launch.Click += (_, _) => LaunchGame();
|
||||
var gamesButton = MakeButton("Installed games", 150); gamesButton.Click += (_, _) => tabs.SelectedTab = tabs.TabPages["Installed games"];
|
||||
var graphicsButton = MakeButton("Graphics settings", 150); graphicsButton.Click += (_, _) => tabs.SelectedTab = tabs.TabPages["Graphics"];
|
||||
var memoryButton = MakeButton("Memory settings", 150); memoryButton.Click += (_, _) => tabs.SelectedTab = tabs.TabPages["Memory"];
|
||||
foreach (var button in new[] { launch, gamesButton, graphicsButton, memoryButton })
|
||||
{
|
||||
button.MinimumSize = new Size(button.MinimumSize.Width, Ui.S(40));
|
||||
button.Margin = new Padding(0, 0, Ui.S(8), Ui.S(8));
|
||||
actions.Controls.Add(button);
|
||||
}
|
||||
|
||||
var profile = Card(Color.FromArgb(27, 23, 27));
|
||||
profile.Controls.Add(new WrapLabel { Text = "Quick profile", Font = Ui.Font(11, FontStyle.Bold), ForeColor = Color.White, Margin = new Padding(0, 0, 0, Ui.S(6)) });
|
||||
profile.Controls.Add(new WrapLabel { Text = "Apply the RTX 4090 ultrawide profile as a starting point. The runtime's CPU-submission optimisations are now active for every preset; review GPU/display settings before launching.", Font = Ui.Font(8.75f), ForeColor = Color.Gainsboro, Margin = new Padding(0, 0, 0, Ui.S(10)) });
|
||||
var preset = MakeButton("Apply RTX 4090 profile", 190); preset.Click += (_, _) => ApplyRtx4090Profile();
|
||||
profile.Controls.Add(preset);
|
||||
|
||||
content.Controls.Add(welcome); content.Controls.Add(actions); content.Controls.Add(profile);
|
||||
page.Controls.Add(content);
|
||||
page.Controls.Add(CreatePageHeader("EonaCat XS", "Launcher overview and quick actions"));
|
||||
tabs.TabPages.Add(page);
|
||||
}
|
||||
|
||||
static string GetHomePath()
|
||||
{
|
||||
var configured = Environment.GetEnvironmentVariable("EONACAT_XS_HOME");
|
||||
return string.IsNullOrWhiteSpace(configured)
|
||||
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "EonaCat", "XS")
|
||||
: configured;
|
||||
}
|
||||
static string GetSettingsPath() => Path.Combine(GetHomePath(), "eonacat-xs-settings.txt");
|
||||
|
||||
static string FindRoot()
|
||||
{
|
||||
var dir = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
for (int i = 0; i < 6 && dir != null; i++, dir = dir.Parent!)
|
||||
if (File.Exists(Path.Combine(dir.FullName, "eonacat-xsbox.exe")) || File.Exists(Path.Combine(dir.FullName, "Cargo.toml"))) return dir.FullName;
|
||||
return AppContext.BaseDirectory;
|
||||
}
|
||||
|
||||
/// <summary>Buttons size themselves to their text; <paramref name="minWidth"/> only keeps related buttons visually even.</summary>
|
||||
static Button MakeButton(string text, int minWidth) => new()
|
||||
{
|
||||
Text = text,
|
||||
UseMnemonic = false,
|
||||
AutoSize = true,
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink,
|
||||
MinimumSize = new Size(Ui.S(minWidth), Ui.S(34)),
|
||||
Padding = new Padding(Ui.S(10), Ui.S(2), Ui.S(10), Ui.S(2)),
|
||||
Font = Ui.Font(9.5f),
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
BackColor = Color.FromArgb(48, 31, 35),
|
||||
ForeColor = Color.White,
|
||||
UseVisualStyleBackColor = false,
|
||||
FlatAppearance = { BorderColor = Color.FromArgb(112, 45, 52) }
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user