mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 03:27:01 +00:00
增加防傻功能
This commit is contained in:
61
BootMenu.cs
61
BootMenu.cs
@@ -3,6 +3,7 @@ using Sys = Cosmos.System;
|
|||||||
using Cosmos.HAL;
|
using Cosmos.HAL;
|
||||||
using Cosmos.Core;
|
using Cosmos.Core;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace CMLeonOS
|
namespace CMLeonOS
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,10 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
internal static class BootMenu
|
internal static class BootMenu
|
||||||
{
|
{
|
||||||
|
private static bool UserDatExists()
|
||||||
|
{
|
||||||
|
return File.Exists(@"0:\system\user.dat");
|
||||||
|
}
|
||||||
private static void PrintOption(string text, bool selected)
|
private static void PrintOption(string text, bool selected)
|
||||||
{
|
{
|
||||||
Console.SetCursorPosition(1, Console.GetCursorPosition().Top);
|
Console.SetCursorPosition(1, Console.GetCursorPosition().Top);
|
||||||
@@ -35,8 +40,6 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
uint mem = Cosmos.Core.CPU.GetAmountOfRAM();
|
uint mem = Cosmos.Core.CPU.GetAmountOfRAM();
|
||||||
Console.WriteLine($"{Version.DisplayVersion} [{mem} MB memory]");
|
Console.WriteLine($"{Version.DisplayVersion} [{mem} MB memory]");
|
||||||
// 这里老显示 unknown,谁知道为啥
|
|
||||||
// Console.WriteLine($"Git Commit: {Version.GitCommit}");
|
|
||||||
Console.WriteLine($"Build Time: {GetBuildTime()}");
|
Console.WriteLine($"Build Time: {GetBuildTime()}");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine($"Auto-select in {remainingTime} seconds...");
|
Console.WriteLine($"Auto-select in {remainingTime} seconds...");
|
||||||
@@ -44,10 +47,16 @@ namespace CMLeonOS
|
|||||||
Console.WriteLine("Select an option:");
|
Console.WriteLine("Select an option:");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
PrintOption("Normal Boot", selIdx == 0);
|
bool userDatExists = UserDatExists();
|
||||||
PrintOption("GUI Boot", selIdx == 1);
|
int optionIndex = 0;
|
||||||
PrintOption("Reboot", selIdx == 2);
|
|
||||||
PrintOption("Shutdown", selIdx == 3);
|
PrintOption("Normal Boot", selIdx == optionIndex++);
|
||||||
|
if (userDatExists)
|
||||||
|
{
|
||||||
|
PrintOption("GUI Boot", selIdx == optionIndex++);
|
||||||
|
}
|
||||||
|
PrintOption("Reboot", selIdx == optionIndex++);
|
||||||
|
PrintOption("Shutdown", selIdx == optionIndex++);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BootMenuAction Confirm(int selIdx)
|
private static BootMenuAction Confirm(int selIdx)
|
||||||
@@ -61,21 +70,29 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
Console.CursorVisible = true;
|
Console.CursorVisible = true;
|
||||||
|
|
||||||
switch (selIdx)
|
bool userDatExists = UserDatExists();
|
||||||
|
int optionIndex = 0;
|
||||||
|
|
||||||
|
if (selIdx == optionIndex++)
|
||||||
{
|
{
|
||||||
case 0:
|
return BootMenuAction.NormalBoot;
|
||||||
return BootMenuAction.NormalBoot;
|
|
||||||
case 1:
|
|
||||||
return BootMenuAction.GuiBoot;
|
|
||||||
case 2:
|
|
||||||
Sys.Power.Reboot();
|
|
||||||
return BootMenuAction.Reboot;
|
|
||||||
case 3:
|
|
||||||
Sys.Power.Shutdown();
|
|
||||||
return BootMenuAction.Shutdown;
|
|
||||||
default:
|
|
||||||
return BootMenuAction.NormalBoot;
|
|
||||||
}
|
}
|
||||||
|
if (userDatExists && selIdx == optionIndex++)
|
||||||
|
{
|
||||||
|
return BootMenuAction.GuiBoot;
|
||||||
|
}
|
||||||
|
if (selIdx == optionIndex++)
|
||||||
|
{
|
||||||
|
Sys.Power.Reboot();
|
||||||
|
return BootMenuAction.Reboot;
|
||||||
|
}
|
||||||
|
if (selIdx == optionIndex++)
|
||||||
|
{
|
||||||
|
Sys.Power.Shutdown();
|
||||||
|
return BootMenuAction.Shutdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BootMenuAction.NormalBoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BootMenuAction Show()
|
public static BootMenuAction Show()
|
||||||
@@ -131,12 +148,14 @@ namespace CMLeonOS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maxOptionIndex = UserDatExists() ? 3 : 2;
|
||||||
|
|
||||||
if (selIdx < 0)
|
if (selIdx < 0)
|
||||||
{
|
{
|
||||||
selIdx = 3;
|
selIdx = maxOptionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selIdx > 3)
|
if (selIdx > maxOptionIndex)
|
||||||
{
|
{
|
||||||
selIdx = 0;
|
selIdx = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2026-03-01 19:12:06
|
2026-03-01 19:30:39
|
||||||
@@ -1 +1 @@
|
|||||||
f0a9223
|
1f385ac
|
||||||
@@ -159,7 +159,7 @@ namespace CMLeonOS.Gui.ShellComponents
|
|||||||
}
|
}
|
||||||
|
|
||||||
window = new AppWindow(this, (int)(wm.ScreenWidth / 2 - width / 2), (int)(wm.ScreenHeight / 2 - height / 2), width, height);
|
window = new AppWindow(this, (int)(wm.ScreenWidth / 2 - width / 2), (int)(wm.ScreenHeight / 2 - height / 2), width, height);
|
||||||
window.Title = "CMLeonOS Logon";
|
window.Title = "CMLeonOS Login";
|
||||||
window.Icon = Images.Icon_Key;
|
window.Icon = Images.Icon_Key;
|
||||||
window.CanMove = false;
|
window.CanMove = false;
|
||||||
window.CanClose = false;
|
window.CanClose = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user