diff options
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/LoginManager.cs | 65 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/SaveSystem.cs | 120 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Skinning.cs | 16 |
4 files changed, 152 insertions, 50 deletions
diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs new file mode 100644 index 0000000..d326f2c --- /dev/null +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public static class LoginManager + { + private static ILoginFrontend _login = null; + + public static void Init(ILoginFrontend login) + { + _login = login; + } + + public static void PromptForLogin() + { + _login.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + _login.Login(); + } + + public static bool ShouldUseGUILogin + { + get + { + if (_login == null) + return false; + return _login.UseGUILogin; + } + } + + public static event Action<ClientSave> LoginComplete; + } + + /// <summary> + /// Interface for GUI-based logins. + /// </summary> + public interface ILoginFrontend + { + /// <summary> + /// When implemented, shows the login UI. + /// </summary> + void Login(); + + /// <summary> + /// Gets whether the ShiftOS engine should use a GUI-based login system or the default one. + /// </summary> + bool UseGUILogin { get; } + + + /// <summary> + /// Occurs when the login is complete. + /// </summary> + event Action<ClientSave> LoginComplete; + + + + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f29e5b8..93a8add 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -263,70 +263,90 @@ namespace ShiftOS.Engine TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) { - if (progress == 0) + Action<ClientSave> Completed = null; + Completed += (user) => { - if (!string.IsNullOrWhiteSpace(text)) + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else + { + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => + { + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + if (!string.IsNullOrWhiteSpace(text)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; progress++; + } + else + { + Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; - return; + goback = true; + progress++; } - username = text; - progress++; } - else + else if (progress == 1) { - Console.WriteLine("Username not provided."); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == text) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } TerminalBackend.TextSent -= ev; - goback = true; - progress++; } - } - else if (progress == 1) + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while (progress == 0) { - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; + Thread.Sleep(10); } - }; - TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); - while(progress == 0) - { - Thread.Sleep(10); + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; } - if (goback) - goto Login; - Console.WriteLine("password:"); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - - TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index fb33dc5..3b5eadd 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -111,6 +111,7 @@ <Compile Include="IShiftOSWindow.cs" /> <Compile Include="KernelWatchdog.cs" /> <Compile Include="Localization.cs" /> + <Compile Include="LoginManager.cs" /> <Compile Include="NotificationDaemon.cs" /> <Compile Include="OutOfBoxExperience.cs" /> <Compile Include="Paths.cs" /> diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4cc9bbd..b731c4f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -267,6 +267,22 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary<string, byte[]> AppIcons = new Dictionary<string, byte[]>(); + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("gui_based_login_screen")] + [ShifterName("Login Screen Background Color")] + [ShifterDescription("Change the background color of the login screen.")] + public Color LoginScreenColor = Skin.DesktopBG; + + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("skinning;gui_based_login_screen")] + [ShifterName("Login Screen Background Image")] + [ShifterDescription("Set an image as your login screen!")] + [Image("login")] + public byte[] LoginScreenBG = null; + + [RequiresUpgrade("shift_screensaver")] [ShifterMeta("System")] [ShifterCategory("Screen saver")] |
