mirror of
https://github.com/xeghosted/OrbisForge.git
synced 2026-10-06 14:00:40 +02:00
Add light/dark mode toggle to the GUI, persisted across launches
This commit is contained in:
1 parent
88e5214781
commit
c76d834ace
3 files changed
+65
-1
No files matched your search
@@ -34,7 +34,8 @@ A Windows GUI wizard and a cross-platform CLI both scaffold the same project lay
|
||||
or the GUI checkbox. No credentials baked in by design — most PS4 FTP servers run anonymous.
|
||||
- **GUI wizard (Windows)** — pick a name, type, output folder, optional `.pkg` packaging, and
|
||||
optional FTP deploy target; detects your WSL distro and the OpenOrbis toolchain automatically,
|
||||
and surfaces the latest available OpenOrbis release as a reference point.
|
||||
and surfaces the latest available OpenOrbis release as a reference point. Light/dark mode
|
||||
toggle, remembered across launches.
|
||||
- **VS Code integration** — generated projects include a build task (Ctrl+Shift+B) and IntelliSense
|
||||
configuration for the toolchain's unusual target triple.
|
||||
- **CLI scaffolder (Windows + Linux + WSL)** — `orbisforge new`, plus `orbisforge build`/
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace OrbisForge.Gui
|
||||
{
|
||||
/// <summary>Tiny persisted preference store -- currently just the light/dark choice.
|
||||
/// Not worth a full settings framework for one boolean.</summary>
|
||||
internal static class GuiSettings
|
||||
{
|
||||
private static string FilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
string dir = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "OrbisForge");
|
||||
Directory.CreateDirectory(dir);
|
||||
return Path.Combine(dir, "settings.txt");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LoadDarkMode()
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.Exists(FilePath) && File.ReadAllText(FilePath).Trim() == "dark";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveDarkMode(bool isDark)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.WriteAllText(FilePath, isDark ? "dark" : "light");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Not worth surfacing to the user -- worst case the choice doesn't persist.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using UIFramework.Controls;
|
||||
using UIFramework.Core.Controls;
|
||||
using UIFramework.Core.Skinning;
|
||||
using UIFramework.Core.Skinning.Skins;
|
||||
|
||||
using OrbisForge.Core;
|
||||
|
||||
@@ -23,6 +25,7 @@ namespace OrbisForge.Gui
|
||||
private readonly SkinLabel _envLabel = new SkinLabel();
|
||||
private readonly SkinButton _generateButton = new SkinButton();
|
||||
private readonly TextBox _statusBox = new TextBox();
|
||||
private readonly CheckBox _darkModeCheck = new CheckBox();
|
||||
|
||||
private WslDetectionResult _wsl;
|
||||
|
||||
@@ -42,6 +45,15 @@ namespace OrbisForge.Gui
|
||||
const int fieldWidth = 320;
|
||||
int y = 16;
|
||||
|
||||
_darkModeCheck.Text = "Dark mode";
|
||||
_darkModeCheck.AutoSize = true;
|
||||
_darkModeCheck.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
_darkModeCheck.Location = new Point(ClientSize.Width - 110, y);
|
||||
_darkModeCheck.Checked = GuiSettings.LoadDarkMode();
|
||||
_darkModeCheck.CheckedChanged += (s, e) => ApplyTheme(_darkModeCheck.Checked, save: true);
|
||||
root.Controls.Add(_darkModeCheck);
|
||||
ApplyTheme(_darkModeCheck.Checked, save: false);
|
||||
|
||||
var nameLabel = new SkinLabel { Text = "Project name:", Location = new Point(left, y), AutoSize = true };
|
||||
y += 20;
|
||||
_nameBox.Location = new Point(left, y);
|
||||
@@ -140,6 +152,12 @@ namespace OrbisForge.Gui
|
||||
Shown += (s, e) => DetectEnvironment();
|
||||
}
|
||||
|
||||
private static void ApplyTheme(bool dark, bool save)
|
||||
{
|
||||
SkinManager.Current = dark ? (ISkin)new DarkSkin() : new LightSkin();
|
||||
if (save) GuiSettings.SaveDarkMode(dark);
|
||||
}
|
||||
|
||||
private void UpdatePkgCheckEnabled()
|
||||
{
|
||||
bool isExe = SelectedType() == OrbisTargetType.Exe;
|
||||
|
||||
Reference in new issue
Block a user