aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-05-06 16:49:05 -0700
committerwilliam341 <[email protected]>2017-05-06 16:49:05 -0700
commitd8004332b61bb310321b48e0f80efcb6ae68e579 (patch)
tree5777e7e3cba9cdc12207b684e10a09293cb03250 /ShiftOS_TheReturn
parent7d744a64d05250e3883126db90f4e4c265ccfffa (diff)
parentd0d193bb1b869697d633d7ccac35179241f8e981 (diff)
downloadshiftos_thereturn-d8004332b61bb310321b48e0f80efcb6ae68e579.tar.gz
shiftos_thereturn-d8004332b61bb310321b48e0f80efcb6ae68e579.tar.bz2
shiftos_thereturn-d8004332b61bb310321b48e0f80efcb6ae68e579.zip
Merge remote-tracking branch 'origin/master'
# Conflicts: # ShiftOS_TheReturn/SaveSystem.cs
Diffstat (limited to 'ShiftOS_TheReturn')
-rw-r--r--ShiftOS_TheReturn/LoginManager.cs65
-rw-r--r--ShiftOS_TheReturn/SaveSystem.cs98
-rw-r--r--ShiftOS_TheReturn/ShiftOS.Engine.csproj1
-rw-r--r--ShiftOS_TheReturn/Skinning.cs16
4 files changed, 163 insertions, 17 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 1feb6d8..50aa260 100644
--- a/ShiftOS_TheReturn/SaveSystem.cs
+++ b/ShiftOS_TheReturn/SaveSystem.cs
@@ -275,40 +275,92 @@ 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)
{
+<<<<<<< HEAD
string loginstr = CurrentSave.SystemName + " login: ";
string getuser = text.Remove(0, loginstr.Length);
if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null)
+=======
+ if (!string.IsNullOrWhiteSpace(text))
+>>>>>>> origin/master
{
- 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++;
}
+<<<<<<< HEAD
username = getuser;
progress++;
+=======
+>>>>>>> origin/master
}
- 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)
{
+<<<<<<< HEAD
string passwordstr = "password: ";
string getpass = text.Remove(0, passwordstr.Length);
var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username);
@@ -344,6 +396,18 @@ namespace ShiftOS.Engine
goto Login;
+=======
+ Thread.Sleep(10);
+ }
+ if (goback)
+ goto Login;
+ Console.WriteLine("password:");
+ while (progress == 1)
+ Thread.Sleep(10);
+ if (goback)
+ goto Login;
+ }
+>>>>>>> origin/master
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")]