aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-10 10:17:10 -0400
committerMichael <[email protected]>2017-06-10 10:17:15 -0400
commitc40d071d58859e25b3781299b949b91caa0548fe (patch)
treed26956e6a06336af403e05cfe0ace0e50ff1b6ea /ShiftOS_TheReturn
parent7dd109719be8a9e8b52655665f490f4f7956df80 (diff)
downloadshiftos_thereturn-c40d071d58859e25b3781299b949b91caa0548fe.tar.gz
shiftos_thereturn-c40d071d58859e25b3781299b949b91caa0548fe.tar.bz2
shiftos_thereturn-c40d071d58859e25b3781299b949b91caa0548fe.zip
main menu system + sandbox mode
Diffstat (limited to 'ShiftOS_TheReturn')
-rw-r--r--ShiftOS_TheReturn/AppearanceManager.cs1
-rw-r--r--ShiftOS_TheReturn/SaveSystem.cs152
-rw-r--r--ShiftOS_TheReturn/ServerManager.cs18
-rw-r--r--ShiftOS_TheReturn/Shiftorium.cs3
-rw-r--r--ShiftOS_TheReturn/Story.cs8
5 files changed, 128 insertions, 54 deletions
diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs
index 7cf06c9..e244b77 100644
--- a/ShiftOS_TheReturn/AppearanceManager.cs
+++ b/ShiftOS_TheReturn/AppearanceManager.cs
@@ -126,6 +126,7 @@ namespace ShiftOS.Engine
}
+
// Provides a list of all open ShiftOS windows.
public static List<IWindowBorder> OpenForms = new List<IWindowBorder>();
diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs
index e98a51e..e36fee6 100644
--- a/ShiftOS_TheReturn/SaveSystem.cs
+++ b/ShiftOS_TheReturn/SaveSystem.cs
@@ -67,6 +67,7 @@ namespace ShiftOS.Engine
/// Boolean representing whether the save system is ready to be used.
/// </summary>
public static bool Ready = false;
+ public static bool IsSandbox = false;
/// <summary>
/// Occurs before the save system connects to the ShiftOS Digital Society.
@@ -140,63 +141,126 @@ namespace ShiftOS.Engine
Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)");
Console.WriteLine("[termdb] Building command database from filesystem...");
TerminalBackend.PopulateTerminalCommands();
- Console.WriteLine("[inetd] Connecting to network...");
- Ready = false;
-
- if (PreDigitalSocietyConnection != null)
+ if (IsSandbox == false)
{
- PreDigitalSocietyConnection?.Invoke();
+ Console.WriteLine("[inetd] Connecting to network...");
+
+ Ready = false;
- while (!Ready)
+ if (PreDigitalSocietyConnection != null)
{
- Thread.Sleep(10);
+ PreDigitalSocietyConnection?.Invoke();
+
+ while (!Ready)
+ {
+ Thread.Sleep(10);
+ }
}
- }
-
- bool guidReceived = false;
- ServerManager.GUIDReceived += (str) =>
- {
- //Connection successful! Stop waiting!
- guidReceived = true;
- Console.WriteLine("[inetd] Connection successful.");
- };
- try
- {
+ bool guidReceived = false;
+ ServerManager.GUIDReceived += (str) =>
+ {
+ //Connection successful! Stop waiting!
+ guidReceived = true;
+ Console.WriteLine("[inetd] Connection successful.");
+ };
- ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort);
- //This haults the client until the connection is successful.
- while (ServerManager.thisGuid == new Guid())
+ try
{
- Thread.Sleep(10);
+
+ ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort);
+ //This haults the client until the connection is successful.
+ while (ServerManager.thisGuid == new Guid())
+ {
+ Thread.Sleep(10);
+ }
+ Console.WriteLine("[inetd] DHCP GUID recieved, finished setup");
+ FinishBootstrap();
}
- Console.WriteLine("[inetd] DHCP GUID recieved, finished setup");
- FinishBootstrap();
+ catch (Exception ex)
+ {
+ //No errors, this never gets called.
+ Console.WriteLine("[inetd] SEVERE: " + ex.Message);
+ Thread.Sleep(3000);
+ Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5...");
+ Thread.Sleep(1000);
+ Console.WriteLine("[sys] 4...");
+ Thread.Sleep(1000);
+ Console.WriteLine("[sys] 3...");
+ Thread.Sleep(1000);
+ Console.WriteLine("[sys] 2...");
+ Thread.Sleep(1000);
+ Console.WriteLine("[sys] 1...");
+ Thread.Sleep(1000);
+ Console.WriteLine("[sys] Bye bye.");
+ System.Diagnostics.Process.GetCurrentProcess().Kill();
+ }
+
+ //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above.
}
- catch (Exception ex)
+ else
{
- //No errors, this never gets called.
- Console.WriteLine("[inetd] SEVERE: " + ex.Message);
- Thread.Sleep(3000);
- Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5...");
- Thread.Sleep(1000);
- Console.WriteLine("[sys] 4...");
- Thread.Sleep(1000);
- Console.WriteLine("[sys] 3...");
- Thread.Sleep(1000);
- Console.WriteLine("[sys] 2...");
- Thread.Sleep(1000);
- Console.WriteLine("[sys] 1...");
- Thread.Sleep(1000);
- Console.WriteLine("[sys] Bye bye.");
- System.Diagnostics.Process.GetCurrentProcess().Kill();
- }
+ Console.WriteLine("[inetd] Sandbox mode initiating...");
+ CurrentSave = new Save
+ {
+ IsSandbox = true,
+ Username = "sandbox",
+ Password = "sandbox",
+ SystemName = "shiftos",
+ Users = new List<ClientSave>
+ {
+ new ClientSave
+ {
+ Username = "user",
+ Password = "",
+ Permissions = 0
+ }
+ },
+ Class = 0,
+ ID = new Guid(),
+ Upgrades = new Dictionary<string, bool>(),
+ CurrentLegions = null,
+ IsMUDAdmin = false,
+ IsPatreon = false,
+ Language = "english",
+ LastMonthPaid = 0,
+ MajorVersion = 1,
+ MinorVersion = 0,
+ MusicEnabled = false,
+ MusicVolume = 100,
+ MyShop = "",
+ PasswordHashed = false,
+ PickupPoint = "",
+ RawReputation = 0.0f,
+ Revision = 0,
+ ShiftnetSubscription = 0,
+ SoundEnabled = true,
+ StoriesExperienced = null,
+ StoryPosition = 0,
+ UniteAuthToken = "",
+ };
+
+ CurrentUser = CurrentSave.Users.First();
+
+ Localization.SetupTHETRUEDefaultLocals();
+
+ Shiftorium.Init();
+
+ TerminalBackend.InStory = false;
+ TerminalBackend.PrefixEnabled = true;
+
+ Desktop.InvokeOnWorkerThread(new Action(() =>
+ {
+ ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft"));
+ }));
- //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above.
+ Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher()));
+ GameReady?.Invoke();
+ }
}));
thread.IsBackground = true;
@@ -243,10 +307,6 @@ namespace ShiftOS.Engine
Thread.Sleep(10);
}
- Localization.SetupTHETRUEDefaultLocals();
-
- Shiftorium.Init();
-
while (CurrentSave.StoryPosition < 1)
{
Thread.Sleep(10);
diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs
index 1439c0d..be4f086 100644
--- a/ShiftOS_TheReturn/ServerManager.cs
+++ b/ShiftOS_TheReturn/ServerManager.cs
@@ -302,15 +302,17 @@ Ping: {ServerManager.DigitalSocietyPing} ms
/// <param name="contents">The message body</param>
public static void SendMessage(string name, string contents)
{
- var sMsg = new ServerMessage
+ if (!SaveSystem.IsSandbox)
{
- Name = name,
- Contents = contents,
- GUID = thisGuid.ToString(),
- };
- PingTimer.Start();
- client.Send(new NetObject("msg", sMsg));
-
+ var sMsg = new ServerMessage
+ {
+ Name = name,
+ Contents = contents,
+ GUID = thisGuid.ToString(),
+ };
+ PingTimer.Start();
+ client.Send(new NetObject("msg", sMsg));
+ }
}
private static bool singleplayer = false;
diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs
index 975939f..7faf336 100644
--- a/ShiftOS_TheReturn/Shiftorium.cs
+++ b/ShiftOS_TheReturn/Shiftorium.cs
@@ -429,6 +429,9 @@ namespace ShiftOS.Engine
/// <returns>Whether the upgrade is installed.</returns>
public static bool UpgradeInstalled(string id)
{
+ if (SaveSystem.IsSandbox == true)
+ return true;
+
if (string.IsNullOrWhiteSpace(id))
return true;
if (SaveSystem.CurrentSave != null)
diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs
index f473f89..e44d2be 100644
--- a/ShiftOS_TheReturn/Story.cs
+++ b/ShiftOS_TheReturn/Story.cs
@@ -115,8 +115,16 @@ namespace ShiftOS.Engine
t.IsBackground = true;
t.Start();
+ Console.WriteLine();
+ ConsoleEx.ForegroundColor = ConsoleColor.Red;
+ ConsoleEx.Bold = true;
Console.WriteLine("NEW OBJECTIVE:");
+ Console.WriteLine();
+
+ ConsoleEx.ForegroundColor = ConsoleColor.White;
+ ConsoleEx.Bold = false;
Console.WriteLine("A new objective has been added to your system. Run sos.status to find out what you need to do.");
+ TerminalBackend.PrintPrompt();
}