From 9e30864a106a1a9b5dab0ffd6c333951d3c91dd2 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 6 Mar 2017 17:01:16 +0000 Subject: improvements --- ShiftOS.Server/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 04d7b2e..3ef9715 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -185,6 +185,10 @@ namespace ShiftOS.Server Console.WriteLine("Save not found."); } } + else if(cmd.ToLower().StartsWith("broadcast ")) + { + ChatBackend.Broadcast(cmd.Remove(0, 10)); + } else if (cmd == "purge_all_bad_saves") { foreach(var f in Directory.GetFiles("saves")) -- cgit v1.2.3 From 220a1bccd60cbf6848e68fe9611df530d379189f Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 6 Mar 2017 21:35:26 +0000 Subject: oops You know... when implementing a new MUD-side function... it's helpful to actually ENABLE it in the startup routine... --- ShiftOS.Server/Program.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 3ef9715..7e5a517 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -167,6 +167,8 @@ namespace ShiftOS.Server var task = ChatBackend.StartDiscordBots(); task.Wait(); + RandomUserGenerator.StartThread(); + while (server.IsOnline) { Console.Write("> "); -- cgit v1.2.3 From 9c143b1249e03fa63492c7aa5283bf60f88c118b Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 14:17:58 +0000 Subject: auto crash handling --- ShiftOS.Server/Program.cs | 21 +++++++++++++++++++++ ShiftOS.Server/RandomUserGenerator.cs | 7 +++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 7e5a517..9093c35 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -123,6 +123,27 @@ namespace ShiftOS.Server Console.WriteLine("Client connected."); server.DispatchTo(a.Guid, new NetObject("welcome", new ServerMessage { Name = "Welcome", Contents = a.Guid.ToString(), GUID = "Server" })); }; + + server.OnClientDisconnected += (o, a) => + { + Console.WriteLine("Client disconnected."); + }; + + server.OnClientRejected += (o, a) => + { + Console.WriteLine("FUCK. Something HORRIBLE JUST HAPPENED."); + }; + + AppDomain.CurrentDomain.UnhandledException += (o, a) => + { + ChatBackend.Broadcast("**Automatic Broadcast:** The multi-user domain is restarting because of a crash."); +#if DEBUG + ChatBackend.Broadcast("Crash summary: " + a.ExceptionObject.ToString()); +#endif + if(server.IsOnline == true) + server.Stop(); + System.Diagnostics.Process.Start("ShiftOS.Server.exe"); + }; server.OnReceived += (o, a) => { diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs index 672f25d..3a62f9c 100644 --- a/ShiftOS.Server/RandomUserGenerator.cs +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -114,7 +114,7 @@ namespace ShiftOS.Server sve.Codepoints = rnd.Next(startCP, maxAmt); //FS treasure generation. - + /* //create a ramdisk dir var dir = new ShiftOS.Objects.ShiftFS.Directory(); //name the directory after the user @@ -181,16 +181,19 @@ namespace ShiftOS.Server WriteAllBytes(kv.Value, File.ReadAllBytes(file)); } } - } + }*/ //save the save file to disk. File.WriteAllText("deadsaves/" + sve.Username + ".save", Newtonsoft.Json.JsonConvert.SerializeObject(sve, Newtonsoft.Json.Formatting.Indented)); //We don't care about the encryption algorithm because these saves can't be logged into as regular users. + /* //Now we export the mount. string exportedMount = ExportMount(mountid); //And save it to disk. File.WriteAllText("deadsaves/" + sve.Username + ".mfs", exportedMount); + */ + Thread.Sleep((60 * 60) * 1000); //approx. 1 hour. -- cgit v1.2.3 From 9aa1becb306f5acf139bf0dc864304ebff8ffabf Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Fri, 7 Apr 2017 16:57:05 +0000 Subject: MUD updates long-over-due. --- ShiftOS.Server/Core.cs | 7 +++++++ ShiftOS.Server/Program.cs | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index e14ca27..7fe600f 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -127,6 +127,13 @@ namespace ShiftOS.Server } + [MudRequest("delete_dead_save", typeof(Save))] + public static void DeleteSave(string guid, Save save) + { + if (File.Exists("deadsaves/" + save.Username + ".save")) + File.Delete("deadsaves/" + save.Username + ".save"); + } + [MudRequest("diag_log", typeof(string))] public static void Diagnostic(string guid, string line) { diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 9093c35..3f64054 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -121,8 +121,15 @@ namespace ShiftOS.Server server.OnClientAccepted += (o, a) => { Console.WriteLine("Client connected."); - server.DispatchTo(a.Guid, new NetObject("welcome", new ServerMessage { Name = "Welcome", Contents = a.Guid.ToString(), GUID = "Server" })); - }; + try + { + server.DispatchTo(a.Guid, new NetObject("welcome", new ServerMessage { Name = "Welcome", Contents = a.Guid.ToString(), GUID = "Server" })); + } + catch + { + Console.WriteLine("Oh, you don't have time to finish the handshake? Fine. Get off."); + } + }; server.OnClientDisconnected += (o, a) => { @@ -185,8 +192,11 @@ namespace ShiftOS.Server Console.WriteLine("Server stopping."); }; + + /* var task = ChatBackend.StartDiscordBots(); task.Wait(); + */ RandomUserGenerator.StartThread(); -- cgit v1.2.3 From 4aa7a6dee500dee2cb0a777a60160bbf3927be9f Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 10 Apr 2017 15:09:52 -0400 Subject: KILL ChatBackend.cs --- ShiftOS.Server/App.config | 14 +- ShiftOS.Server/ChatBackend.cs | 264 ----------------------------------- ShiftOS.Server/Program.cs | 8 -- ShiftOS.Server/ShiftOS.Server.csproj | 69 --------- ShiftOS.Server/packages.config | 29 ---- ShiftOS.Updater/App.config | 14 +- 6 files changed, 20 insertions(+), 378 deletions(-) delete mode 100644 ShiftOS.Server/ChatBackend.cs (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/App.config b/ShiftOS.Server/App.config index cadfa91..a87bf6b 100644 --- a/ShiftOS.Server/App.config +++ b/ShiftOS.Server/App.config @@ -1,18 +1,18 @@ - + - + - + - - + + - - + + diff --git a/ShiftOS.Server/ChatBackend.cs b/ShiftOS.Server/ChatBackend.cs deleted file mode 100644 index b9fbf25..0000000 --- a/ShiftOS.Server/ChatBackend.cs +++ /dev/null @@ -1,264 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Objects; -using NetSockets; -using Newtonsoft.Json; -using System.IO; -using static ShiftOS.Server.Program; -using Discord; -using Discord.WebSocket; -using Discord.Net.WebSockets; - -namespace ShiftOS.Server -{ - public static class ChatBackend - { - public static async Task StartDiscordBots() - { - Reinitialized?.Invoke(); - if (!File.Exists("chats.json")) - File.WriteAllText("chats.json", "[]"); - foreach (var chat in JsonConvert.DeserializeObject>(File.ReadAllText("chats.json"))) - { - string chatID = chat.ID; - bool chatKilled = false; - if (chat.IsDiscordProxy == true) - { - DiscordSocketConfig builder = new DiscordSocketConfig(); - builder.AudioMode = Discord.Audio.AudioMode.Disabled; - builder.WebSocketProvider = () => Discord.Net.Providers.WS4Net.WS4NetProvider.Instance(); - var client = new DiscordSocketClient(builder); - await client.LoginAsync(TokenType.Bot, chat.DiscordBotToken); - - await client.ConnectAsync(); - await client.SetGameAsync("ShiftOS"); - await client.SetStatusAsync(UserStatus.Online); - //Get the Discord channel for this chat. - var Chan = client.GetChannel(Convert.ToUInt64(chat.DiscordChannelID)) as ISocketMessageChannel; - //Relay the message to Discord. - await Chan.SendMessageAsync("**Hello! Multi-user domain is online.**"); - - client.MessageReceived += async (s) => - { - if (chatKilled == false) - { - if (s.Channel.Id == Convert.ToUInt64(chat.DiscordChannelID)) - { - if (s.Author.Id != client.CurrentUser.Id) - { - var msg = new ChatMessage(s.Author.Username, "discord_" + s.Channel.Name, (s as SocketUserMessage).Resolve(0), chatID); - server.DispatchAll(new NetObject("chat_msgreceived", new ServerMessage - { - Name = "chat_msgreceived", - GUID = "server", - Contents = JsonConvert.SerializeObject(msg) - })); - Log(chatID, $"[{msg.Username}@{msg.SystemName}] {msg.Message}"); - } - } - } - }; - MessageReceived += (g, msg) => - { - if (chatKilled == false) - { - //Determine if the message was sent to this channel. - if (msg.Channel == chat.ID) - { - //Get the Discord channel for this chat. - var dChan = client.GetChannel(Convert.ToUInt64(chat.DiscordChannelID)) as ISocketMessageChannel; - //Relay the message to Discord. - dChan.SendMessageAsync($"**[{msg.Username}@{msg.SystemName}]** `` {msg.Message}"); - //Relay it back to all MUD clients. - RelayMessage(g, msg); - Log(chatID, $"[{msg.Username}@{msg.SystemName}] {msg.Message}"); - - } - } - }; - OnBroadcast += (msg) => - { - if (chatKilled == false) - { - var cMsg = new ChatMessage("sys", "mud", msg, chatID); - RelayMessageToAll(cMsg); - Log(chatID, msg); - //Get the Discord channel for this chat. - var dChan = client.GetChannel(Convert.ToUInt64(chat.DiscordChannelID)) as ISocketMessageChannel; - //Relay the message to Discord. - dChan.SendMessageAsync($"{msg}"); - //Relay it back to all MUD clients. - - } - }; Reinitialized += () => - { - client.DisconnectAsync(); - - chatKilled = true; - }; - } - else - { - MessageReceived += (g, msg) => - { - if (chatKilled == false) - { - //Just relay it. - RelayMessage(g, msg); - //...Then log it. - Log(chatID, $"[{msg.Username}@{msg.SystemName}] {msg.Message}"); - } - }; - OnBroadcast += (msg) => - { - if (chatKilled == false) - { - var cMsg = new ChatMessage("sys", "mud", msg, chatID); - RelayMessageToAll(cMsg); - Log(chatID, msg); - } - }; - Reinitialized += () => { chatKilled = true; }; - } - } - } - - internal static void RelayMessageToAll(ChatMessage msg) - { - server.DispatchAll(new NetObject("chat_msgreceived", new ServerMessage - { - Name = "chat_msgreceived", - GUID = "server", - Contents = JsonConvert.SerializeObject(msg) - })); - - } - - internal static void RelayMessage(string guid, ChatMessage msg) - { - server.DispatchAllExcept(new Guid(guid), new NetObject("chat_msgreceived", new ServerMessage - { - Name = "chat_msgreceived", - GUID = "server", - Contents = JsonConvert.SerializeObject(msg) - })); - - } - - public static event Action MessageReceived; - public static event empty Reinitialized; - - - public delegate void empty(); - - [MudRequest("chat_getallchannels", null)] - public static void GetAllChannels(string guid, object contents) - { - server.DispatchTo(new Guid(guid), new NetObject("chat_all", new ServerMessage - { - Name = "chat_all", - GUID = "Server", - Contents = (File.Exists("chats.json") == true) ? File.ReadAllText("chats.json") : "[]" - })); - } - - [MudRequest("chat_send", typeof(Dictionary))] - public static void ReceiveMessage(string guid, object contents) - { - var msg = contents as Dictionary; - MessageReceived?.Invoke(guid, new ChatMessage(msg["Username"], msg["SystemName"], msg["Message"], msg["Channel"])); - - } - - public static event Action OnBroadcast; - - public static void Broadcast(string text) - { - OnBroadcast?.Invoke("[Broadcast] " + text); - } - - [MudRequest("chat_getlog", typeof(ChatLogRequest))] - public static void GetChatlog(string guid, ChatLogRequest req) - { - if (!Directory.Exists("chatlogs")) - Directory.CreateDirectory("chatlogs"); - - if(File.Exists("chatlogs/" + req.Channel + ".log")) - { - string[] log = File.ReadAllLines("chatlogs/" + req.Channel + ".log"); - string seg = ""; - - if(req.Backtrack == 0 || log.Length < req.Backtrack) - { - //send all of it. - foreach(var ln in log) - { - seg += ln + Environment.NewLine; - } - } - else - { - //send only a specific chunk. - for(int i = log.Length - 1; i >= log.Length - req.Backtrack; i--) - { - seg += log[i] + Environment.NewLine; - } - } - - try - { - server.DispatchTo(new Guid(guid), new NetObject("always watching, always listening, my eyes are everywhere, you cannot escape me", new ServerMessage - { - Name = "chatlog", - Contents = seg, - GUID = "server" - })); - } - catch { } - } - } - - - public static void Log(string channel, string line) - { - if (!Directory.Exists("chatlogs")) - Directory.CreateDirectory("chatlogs"); - - List lines = new List(); - if (File.Exists("chatlogs/" + channel + ".log")) - lines = new List(File.ReadAllLines("chatlogs/" + channel + ".log")); - - lines.Add(line); - File.WriteAllLines("chatlogs/" + channel + ".log", lines.ToArray()); - - } - } - -} diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 3f64054..afc2541 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -143,10 +143,6 @@ namespace ShiftOS.Server AppDomain.CurrentDomain.UnhandledException += (o, a) => { - ChatBackend.Broadcast("**Automatic Broadcast:** The multi-user domain is restarting because of a crash."); -#if DEBUG - ChatBackend.Broadcast("Crash summary: " + a.ExceptionObject.ToString()); -#endif if(server.IsOnline == true) server.Stop(); System.Diagnostics.Process.Start("ShiftOS.Server.exe"); @@ -218,10 +214,6 @@ namespace ShiftOS.Server Console.WriteLine("Save not found."); } } - else if(cmd.ToLower().StartsWith("broadcast ")) - { - ChatBackend.Broadcast(cmd.Remove(0, 10)); - } else if (cmd == "purge_all_bad_saves") { foreach(var f in Directory.GetFiles("saves")) diff --git a/ShiftOS.Server/ShiftOS.Server.csproj b/ShiftOS.Server/ShiftOS.Server.csproj index aed227f..86c7e55 100644 --- a/ShiftOS.Server/ShiftOS.Server.csproj +++ b/ShiftOS.Server/ShiftOS.Server.csproj @@ -34,26 +34,6 @@ 4 - - ..\packages\Discord.Net.Core.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Core.dll - True - - - ..\packages\Discord.Net.Providers.WS4Net.1.0.0-rc-00595\lib\net45\Discord.Net.Providers.WS4Net.dll - True - - - ..\packages\Discord.Net.Rest.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Rest.dll - True - - - ..\packages\Discord.Net.Rpc.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.Rpc.dll - True - - - ..\packages\Discord.Net.WebSocket.1.0.0-rc-00595\lib\netstandard1.1\Discord.Net.WebSocket.dll - True - ..\packages\Microsoft.Win32.Primitives.4.0.1\lib\net46\Microsoft.Win32.Primitives.dll True @@ -65,64 +45,16 @@ ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.dll - True - - - ..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Concurrent.dll - True - - - ..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll - True - ..\packages\RestSharp.105.2.3\lib\net451\RestSharp.dll True - - ..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll - True - - - ..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll - True - - - ..\packages\System.Console.4.0.0\lib\net46\System.Console.dll - True - - - ..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll - True - - - ..\packages\System.Globalization.Calendars.4.0.1\lib\net46\System.Globalization.Calendars.dll - True - - - ..\packages\System.Interactive.Async.3.1.0\lib\net45\System.Interactive.Async.dll - True - - - ..\packages\System.IO.Compression.ZipFile.4.0.1\lib\net46\System.IO.Compression.ZipFile.dll - True - - - ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll - True - - - ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll - True - ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll True @@ -168,7 +100,6 @@ - diff --git a/ShiftOS.Server/packages.config b/ShiftOS.Server/packages.config index 325c809..11643b9 100644 --- a/ShiftOS.Server/packages.config +++ b/ShiftOS.Server/packages.config @@ -1,38 +1,10 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -57,6 +29,5 @@ - \ No newline at end of file diff --git a/ShiftOS.Updater/App.config b/ShiftOS.Updater/App.config index 88fa402..757ddce 100644 --- a/ShiftOS.Updater/App.config +++ b/ShiftOS.Updater/App.config @@ -1,6 +1,18 @@ - + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 03d01cdb4de62c1c431aefe9d11f5d276dd21b5a Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 30 Apr 2017 15:37:25 +0000 Subject: Changes. --- ShiftOS.Server/Program.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index afc2541..9e89e56 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -86,7 +86,18 @@ namespace ShiftOS.Server /// The command-line arguments. public static void Main(string[] args) { - + System.Timers.Timer tmr = new System.Timers.Timer(5000); + tmr.Elapsed += (o, a) => + { + if (server.IsOnline) + { + server.DispatchAll(new NetObject("heartbeat", new ServerMessage + { + Name = "heartbeat", + GUID = "server" + })); + } + }; if (!Directory.Exists("saves")) { Directory.CreateDirectory("saves"); @@ -106,11 +117,13 @@ namespace ShiftOS.Server { Console.WriteLine($"Server started on address {server.Address}, port {server.Port}."); ServerStarted?.Invoke(server.Address.ToString()); - }; + tmr.Start(); + }; server.OnStopped += (o, a) => { Console.WriteLine("WARNING! Server stopped."); + tmr.Stop(); }; server.OnError += (o, a) => -- cgit v1.2.3 From 7532df70757ecbcaf735a5fc50eee282f555741a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 1 May 2017 15:23:46 -0400 Subject: Replace most instances of "CurrentSave.Username" --- ShiftOS.Objects/Save.cs | 4 + ShiftOS.Server/Program.cs | 7 +- ShiftOS.WinForms/Applications/Dialog.cs | 2 - ShiftOS.WinForms/Applications/Terminal.cs | 12 +- ShiftOS.WinForms/FakeSetupScreen.Designer.cs | 624 --------------------------- ShiftOS.WinForms/FakeSetupScreen.cs | 395 ----------------- ShiftOS.WinForms/FakeSetupScreen.resx | 120 ------ ShiftOS.WinForms/Oobe.cs | 34 +- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 - ShiftOS.WinForms/WinformsDesktop.cs | 5 +- ShiftOS_TheReturn/CommandParser.cs | 3 - ShiftOS_TheReturn/Commands.cs | 2 +- 12 files changed, 14 insertions(+), 1203 deletions(-) delete mode 100644 ShiftOS.WinForms/FakeSetupScreen.Designer.cs delete mode 100644 ShiftOS.WinForms/FakeSetupScreen.cs delete mode 100644 ShiftOS.WinForms/FakeSetupScreen.resx (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 1adaf3b..4f91db7 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -34,7 +34,11 @@ namespace ShiftOS.Objects //Better to store this stuff server-side so we can do some neat stuff with hacking... public class Save { + + [Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")] public string Username { get; set; } + + public long Codepoints { get; set; } public Dictionary Upgrades { get; set; } public int StoryPosition { get; set; } diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 9e89e56..97c8a66 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -296,8 +296,6 @@ namespace ShiftOS.Server /// Message. public static void Interpret(ServerMessage msg) { - Dictionary args = null; - try { Console.WriteLine($@"[{DateTime.Now}] Message received from {msg.GUID}: {msg.Name}"); @@ -325,8 +323,7 @@ namespace ShiftOS.Server try { object contents = null; - bool throwOnNull = false; - + if (mAttrib.ExpectedType == typeof(int)) { @@ -354,7 +351,6 @@ namespace ShiftOS.Server } else if (mAttrib.ExpectedType == typeof(bool)) { - throwOnNull = true; if (msg.Contents.ToLower() == "true") { contents = true; @@ -371,7 +367,6 @@ namespace ShiftOS.Server } else if (mAttrib.ExpectedType == null) { - throwOnNull = false; } else if(mAttrib.ExpectedType == typeof(string)) { diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs index 2abc705..f9d0b86 100644 --- a/ShiftOS.WinForms/Applications/Dialog.cs +++ b/ShiftOS.WinForms/Applications/Dialog.cs @@ -85,8 +85,6 @@ namespace ShiftOS.WinForms.Applications } - private Action OpenCallback = null; - public void Open(string title, string msg, Action c = null) { new Dialog().OpenInternal(title, msg, c); diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index d35f7e0..32c5363 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -197,7 +197,7 @@ namespace ShiftOS.WinForms.Applications public void ResetAllKeywords() { - string primary = SaveSystem.CurrentSave.Username + " "; + string primary = SaveSystem.CurrentUser.Username + " "; string secondary = "shiftos "; @@ -279,7 +279,7 @@ namespace ShiftOS.WinForms.Applications { if (TerminalBackend.PrefixEnabled) { - text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); + text3 = text4.Remove(0, $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); } TerminalBackend.LastCommand = text3; TextSent?.Invoke(text4); @@ -327,7 +327,7 @@ namespace ShiftOS.WinForms.Applications { var tostring3 = txt.Lines[txt.Lines.Length - 1]; var tostringlen = tostring3.Length + 1; - var workaround = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; + var workaround = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; var derp = workaround.Length + 1; if (tostringlen != derp) { @@ -347,7 +347,7 @@ namespace ShiftOS.WinForms.Applications { var getstring = txt.Lines[txt.Lines.Length - 1]; var stringlen = getstring.Length + 1; - var header = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; + var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; var headerlen = header.Length + 1; var selstart = txt.SelectionStart; var remstrlen = txt.TextLength - stringlen; @@ -365,7 +365,7 @@ namespace ShiftOS.WinForms.Applications else if (a.KeyCode == Keys.Up) { var tostring3 = txt.Lines[txt.Lines.Length - 1]; - if (tostring3 == $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") + if (tostring3 == $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") Console.Write(TerminalBackend.LastCommand); a.SuppressKeyPress = true; @@ -465,7 +465,7 @@ namespace ShiftOS.WinForms.Applications if (TerminalBackend.PrefixEnabled) { - Console.Write($"{SaveSystem.CurrentSave.Username}@shiftos:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@shiftos:~$ "); } } catch (Exception ex) diff --git a/ShiftOS.WinForms/FakeSetupScreen.Designer.cs b/ShiftOS.WinForms/FakeSetupScreen.Designer.cs deleted file mode 100644 index b14367b..0000000 --- a/ShiftOS.WinForms/FakeSetupScreen.Designer.cs +++ /dev/null @@ -1,624 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -namespace ShiftOS.WinForms -{ - partial class FakeSetupScreen - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.pnlheader = new System.Windows.Forms.Panel(); - this.flbuttons = new System.Windows.Forms.FlowLayoutPanel(); - this.btnnext = new System.Windows.Forms.Button(); - this.btnback = new System.Windows.Forms.Button(); - this.page1 = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.page2 = new System.Windows.Forms.Panel(); - this.lbbyteszeroed = new System.Windows.Forms.Label(); - this.pgformatprogress = new System.Windows.Forms.ProgressBar(); - this.lbformattitle = new System.Windows.Forms.Label(); - this.page3 = new System.Windows.Forms.Panel(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.label3 = new System.Windows.Forms.Label(); - this.txtnewusername = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.txtnewpassword = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.txtnewsysname = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.page4 = new System.Windows.Forms.Panel(); - this.txtlicenseagreement = new System.Windows.Forms.RichTextBox(); - this.label10 = new System.Windows.Forms.Label(); - this.pgrereg = new System.Windows.Forms.Panel(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); - this.label7 = new System.Windows.Forms.Label(); - this.txtruname = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.txtrpass = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.txtrsys = new System.Windows.Forms.TextBox(); - this.label11 = new System.Windows.Forms.Label(); - this.pglogin = new System.Windows.Forms.Panel(); - this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); - this.label12 = new System.Windows.Forms.Label(); - this.txtluser = new System.Windows.Forms.TextBox(); - this.label13 = new System.Windows.Forms.Label(); - this.txtlpass = new System.Windows.Forms.TextBox(); - this.label15 = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.btnnlogin = new System.Windows.Forms.Button(); - this.flbuttons.SuspendLayout(); - this.page1.SuspendLayout(); - this.page2.SuspendLayout(); - this.page3.SuspendLayout(); - this.tableLayoutPanel1.SuspendLayout(); - this.page4.SuspendLayout(); - this.pgrereg.SuspendLayout(); - this.tableLayoutPanel2.SuspendLayout(); - this.pglogin.SuspendLayout(); - this.tableLayoutPanel3.SuspendLayout(); - this.SuspendLayout(); - // - // pnlheader - // - this.pnlheader.BackColor = System.Drawing.SystemColors.ControlDark; - this.pnlheader.Dock = System.Windows.Forms.DockStyle.Left; - this.pnlheader.Location = new System.Drawing.Point(0, 0); - this.pnlheader.Name = "pnlheader"; - this.pnlheader.Size = new System.Drawing.Size(138, 300); - this.pnlheader.TabIndex = 0; - // - // flbuttons - // - this.flbuttons.AutoSize = true; - this.flbuttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flbuttons.Controls.Add(this.btnnext); - this.flbuttons.Controls.Add(this.btnback); - this.flbuttons.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flbuttons.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flbuttons.Location = new System.Drawing.Point(0, 300); - this.flbuttons.Name = "flbuttons"; - this.flbuttons.Size = new System.Drawing.Size(490, 29); - this.flbuttons.TabIndex = 1; - // - // btnnext - // - this.btnnext.Location = new System.Drawing.Point(412, 3); - this.btnnext.Name = "btnnext"; - this.btnnext.Size = new System.Drawing.Size(75, 23); - this.btnnext.TabIndex = 0; - this.btnnext.Text = "Next"; - this.btnnext.UseVisualStyleBackColor = true; - this.btnnext.Click += new System.EventHandler(this.btnnext_Click); - // - // btnback - // - this.btnback.Location = new System.Drawing.Point(331, 3); - this.btnback.Name = "btnback"; - this.btnback.Size = new System.Drawing.Size(75, 23); - this.btnback.TabIndex = 1; - this.btnback.Text = "Back"; - this.btnback.UseVisualStyleBackColor = true; - this.btnback.Click += new System.EventHandler(this.btnback_Click); - // - // page1 - // - this.page1.Controls.Add(this.label2); - this.page1.Controls.Add(this.label1); - this.page1.Dock = System.Windows.Forms.DockStyle.Fill; - this.page1.Location = new System.Drawing.Point(138, 0); - this.page1.Name = "page1"; - this.page1.Size = new System.Drawing.Size(352, 300); - this.page1.TabIndex = 2; - // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label2.Location = new System.Drawing.Point(20, 87); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(320, 199); - this.label2.TabIndex = 1; - this.label2.Text = "This wizard will guide you through the installation and configuration of ShiftOS." + - "\r\n\r\nPress Next to continue."; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); - this.label1.Location = new System.Drawing.Point(19, 22); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(321, 44); - this.label1.TabIndex = 0; - this.label1.Text = "Welcome to the ShiftOS installation wizard."; - // - // page2 - // - this.page2.Controls.Add(this.lbbyteszeroed); - this.page2.Controls.Add(this.pgformatprogress); - this.page2.Controls.Add(this.lbformattitle); - this.page2.Dock = System.Windows.Forms.DockStyle.Fill; - this.page2.Location = new System.Drawing.Point(138, 0); - this.page2.Name = "page2"; - this.page2.Size = new System.Drawing.Size(352, 300); - this.page2.TabIndex = 2; - // - // lbbyteszeroed - // - this.lbbyteszeroed.AutoSize = true; - this.lbbyteszeroed.Location = new System.Drawing.Point(20, 91); - this.lbbyteszeroed.Name = "lbbyteszeroed"; - this.lbbyteszeroed.Size = new System.Drawing.Size(127, 13); - this.lbbyteszeroed.TabIndex = 5; - this.lbbyteszeroed.Text = "Bytes zeroed: 0/1000000"; - // - // pgformatprogress - // - this.pgformatprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgformatprogress.Location = new System.Drawing.Point(23, 61); - this.pgformatprogress.Name = "pgformatprogress"; - this.pgformatprogress.Size = new System.Drawing.Size(317, 23); - this.pgformatprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgformatprogress.TabIndex = 4; - // - // lbformattitle - // - this.lbformattitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lbformattitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); - this.lbformattitle.Location = new System.Drawing.Point(16, 9); - this.lbformattitle.Name = "lbformattitle"; - this.lbformattitle.Size = new System.Drawing.Size(321, 26); - this.lbformattitle.TabIndex = 3; - this.lbformattitle.Text = "Formatting your drive..."; - // - // page3 - // - this.page3.Controls.Add(this.btnnlogin); - this.page3.Controls.Add(this.tableLayoutPanel1); - this.page3.Controls.Add(this.label4); - this.page3.Dock = System.Windows.Forms.DockStyle.Fill; - this.page3.Location = new System.Drawing.Point(138, 0); - this.page3.Name = "page3"; - this.page3.Size = new System.Drawing.Size(352, 300); - this.page3.TabIndex = 6; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.AutoSize = true; - this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.Controls.Add(this.label3, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.txtnewusername, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.label5, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.txtnewpassword, 1, 1); - this.tableLayoutPanel1.Controls.Add(this.label6, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.txtnewsysname, 1, 2); - this.tableLayoutPanel1.Location = new System.Drawing.Point(20, 61); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 3; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(212, 72); - this.tableLayoutPanel1.TabIndex = 4; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(58, 13); - this.label3.TabIndex = 0; - this.label3.Text = "Username:"; - // - // txtnewusername - // - this.txtnewusername.Location = new System.Drawing.Point(109, 3); - this.txtnewusername.Name = "txtnewusername"; - this.txtnewusername.Size = new System.Drawing.Size(100, 20); - this.txtnewusername.TabIndex = 1; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(3, 26); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(56, 13); - this.label5.TabIndex = 2; - this.label5.Text = "Password:"; - // - // txtnewpassword - // - this.txtnewpassword.Location = new System.Drawing.Point(109, 29); - this.txtnewpassword.Name = "txtnewpassword"; - this.txtnewpassword.PasswordChar = '*'; - this.txtnewpassword.Size = new System.Drawing.Size(100, 20); - this.txtnewpassword.TabIndex = 3; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(3, 52); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(75, 13); - this.label6.TabIndex = 4; - this.label6.Text = "System Name:"; - // - // txtnewsysname - // - this.txtnewsysname.Location = new System.Drawing.Point(109, 55); - this.txtnewsysname.Name = "txtnewsysname"; - this.txtnewsysname.Size = new System.Drawing.Size(100, 20); - this.txtnewsysname.TabIndex = 5; - // - // label4 - // - this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); - this.label4.Location = new System.Drawing.Point(16, 9); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(321, 26); - this.label4.TabIndex = 3; - this.label4.Text = "User information"; - // - // page4 - // - this.page4.Controls.Add(this.txtlicenseagreement); - this.page4.Controls.Add(this.label10); - this.page4.Dock = System.Windows.Forms.DockStyle.Fill; - this.page4.Location = new System.Drawing.Point(138, 0); - this.page4.Name = "page4"; - this.page4.Size = new System.Drawing.Size(352, 300); - this.page4.TabIndex = 7; - // - // txtlicenseagreement - // - this.txtlicenseagreement.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtlicenseagreement.Location = new System.Drawing.Point(23, 58); - this.txtlicenseagreement.Name = "txtlicenseagreement"; - this.txtlicenseagreement.ReadOnly = true; - this.txtlicenseagreement.Size = new System.Drawing.Size(326, 228); - this.txtlicenseagreement.TabIndex = 4; - this.txtlicenseagreement.Text = ""; - // - // label10 - // - this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); - this.label10.Location = new System.Drawing.Point(16, 9); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(321, 26); - this.label10.TabIndex = 3; - this.label10.Text = "License Agreement"; - // - // pgrereg - // - this.pgrereg.Controls.Add(this.tableLayoutPanel2); - this.pgrereg.Controls.Add(this.label11); - this.pgrereg.Dock = System.Windows.Forms.DockStyle.Fill; - this.pgrereg.Location = new System.Drawing.Point(138, 0); - this.pgrereg.Name = "pgrereg"; - this.pgrereg.Size = new System.Drawing.Size(352, 300); - this.pgrereg.TabIndex = 8; - // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.AutoSize = true; - this.tableLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel2.ColumnCount = 2; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.Controls.Add(this.label7, 0, 0); - this.tableLayoutPanel2.Controls.Add(this.txtruname, 1, 0); - this.tableLayoutPanel2.Controls.Add(this.label8, 0, 1); - this.tableLayoutPanel2.Controls.Add(this.txtrpass, 1, 1); - this.tableLayoutPanel2.Controls.Add(this.label9, 0, 2); - this.tableLayoutPanel2.Controls.Add(this.txtrsys, 1, 2); - this.tableLayoutPanel2.Location = new System.Drawing.Point(20, 61); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 3; - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(212, 72); - this.tableLayoutPanel2.TabIndex = 4; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(3, 0); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(58, 13); - this.label7.TabIndex = 0; - this.label7.Text = "Username:"; - // - // txtruname - // - this.txtruname.Location = new System.Drawing.Point(109, 3); - this.txtruname.Name = "txtruname"; - this.txtruname.Size = new System.Drawing.Size(100, 20); - this.txtruname.TabIndex = 1; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(3, 26); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(56, 13); - this.label8.TabIndex = 2; - this.label8.Text = "Password:"; - // - // txtrpass - // - this.txtrpass.Location = new System.Drawing.Point(109, 29); - this.txtrpass.Name = "txtrpass"; - this.txtrpass.PasswordChar = '*'; - this.txtrpass.Size = new System.Drawing.Size(100, 20); - this.txtrpass.TabIndex = 3; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(3, 52); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(75, 13); - this.label9.TabIndex = 4; - this.label9.Text = "System Name:"; - // - // txtrsys - // - this.txtrsys.Location = new System.Drawing.Point(109, 55); - this.txtrsys.Name = "txtrsys"; - this.txtrsys.Size = new System.Drawing.Size(100, 20); - this.txtrsys.TabIndex = 5; - // - // label11 - // - this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); - this.label11.Location = new System.Drawing.Point(16, 9); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(321, 26); - this.label11.TabIndex = 3; - this.label11.Text = "User information"; - // - // pglogin - // - this.pglogin.Controls.Add(this.tableLayoutPanel3); - this.pglogin.Controls.Add(this.label15); - this.pglogin.Controls.Add(this.button1); - this.pglogin.Dock = System.Windows.Forms.DockStyle.Fill; - this.pglogin.Location = new System.Drawing.Point(138, 0); - this.pglogin.Name = "pglogin"; - this.pglogin.Size = new System.Drawing.Size(352, 300); - this.pglogin.TabIndex = 9; - // - // tableLayoutPanel3 - // - this.tableLayoutPanel3.AutoSize = true; - this.tableLayoutPanel3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanel3.ColumnCount = 2; - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel3.Controls.Add(this.label12, 0, 0); - this.tableLayoutPanel3.Controls.Add(this.txtluser, 1, 0); - this.tableLayoutPanel3.Controls.Add(this.label13, 0, 1); - this.tableLayoutPanel3.Controls.Add(this.txtlpass, 1, 1); - this.tableLayoutPanel3.Location = new System.Drawing.Point(20, 61); - this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 3; - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(212, 72); - this.tableLayoutPanel3.TabIndex = 4; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(3, 0); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(58, 13); - this.label12.TabIndex = 0; - this.label12.Text = "Username:"; - // - // txtluser - // - this.txtluser.Location = new System.Drawing.Point(109, 3); - this.txtluser.Name = "txtluser"; - this.txtluser.Size = new System.Drawing.Size(100, 20); - this.txtluser.TabIndex = 1; - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(3, 26); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(56, 13); - this.label13.TabIndex = 2; - this.label13.Text = "Password:"; - // - // txtlpass - // - this.txtlpass.Location = new System.Drawing.Point(109, 29); - this.txtlpass.Name = "txtlpass"; - this.txtlpass.PasswordChar = '*'; - this.txtlpass.Size = new System.Drawing.Size(100, 20); - this.txtlpass.TabIndex = 3; - // - // label15 - // - this.label15.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 13F); - this.label15.Location = new System.Drawing.Point(16, 9); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(321, 26); - this.label15.TabIndex = 3; - this.label15.Text = "User information"; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(129, 142); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 21); - this.button1.TabIndex = 4; - this.button1.Text = "Register"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // btnnlogin - // - this.btnnlogin.Location = new System.Drawing.Point(129, 156); - this.btnnlogin.Name = "btnnlogin"; - this.btnnlogin.Size = new System.Drawing.Size(75, 23); - this.btnnlogin.TabIndex = 5; - this.btnnlogin.Text = "Log in"; - this.btnnlogin.UseVisualStyleBackColor = true; - this.btnnlogin.Click += new System.EventHandler(this.btnnlogin_Click); - // - // FakeSetupScreen - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(490, 329); - this.Controls.Add(this.pglogin); - this.Controls.Add(this.page3); - this.Controls.Add(this.pgrereg); - this.Controls.Add(this.page4); - this.Controls.Add(this.page2); - this.Controls.Add(this.page1); - this.Controls.Add(this.pnlheader); - this.Controls.Add(this.flbuttons); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "FakeSetupScreen"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "ShiftOS"; - this.TopMost = true; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FakeSetupScreen_FormClosing); - this.flbuttons.ResumeLayout(false); - this.page1.ResumeLayout(false); - this.page2.ResumeLayout(false); - this.page2.PerformLayout(); - this.page3.ResumeLayout(false); - this.page3.PerformLayout(); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.page4.ResumeLayout(false); - this.pgrereg.ResumeLayout(false); - this.pgrereg.PerformLayout(); - this.tableLayoutPanel2.ResumeLayout(false); - this.tableLayoutPanel2.PerformLayout(); - this.pglogin.ResumeLayout(false); - this.pglogin.PerformLayout(); - this.tableLayoutPanel3.ResumeLayout(false); - this.tableLayoutPanel3.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Panel pnlheader; - private System.Windows.Forms.FlowLayoutPanel flbuttons; - private System.Windows.Forms.Button btnnext; - private System.Windows.Forms.Button btnback; - private System.Windows.Forms.Panel page1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Panel page2; - private System.Windows.Forms.Label lbformattitle; - private System.Windows.Forms.Label lbbyteszeroed; - private System.Windows.Forms.ProgressBar pgformatprogress; - private System.Windows.Forms.Panel page3; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox txtnewusername; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox txtnewpassword; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.TextBox txtnewsysname; - private System.Windows.Forms.Panel page4; - private System.Windows.Forms.RichTextBox txtlicenseagreement; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Panel pgrereg; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.TextBox txtruname; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.TextBox txtrpass; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox txtrsys; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Panel pglogin; - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.TextBox txtluser; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.TextBox txtlpass; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button btnnlogin; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/FakeSetupScreen.cs b/ShiftOS.WinForms/FakeSetupScreen.cs deleted file mode 100644 index f62c777..0000000 --- a/ShiftOS.WinForms/FakeSetupScreen.cs +++ /dev/null @@ -1,395 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - public partial class FakeSetupScreen : Form - { - private Oobe oobe = null; - - public Action MUDUserFound = null; - - public FakeSetupScreen(Oobe _oobe, int page = 0) - { - oobe = _oobe; - InitializeComponent(); - currentPage = page; - SetupUI(); - ServerManager.MessageReceived += (msg) => - { - if (this.Visible == true) - { - if (msg.Name == "mud_notfound") - this.Invoke(new Action(() => { MUDUserFound?.Invoke(false); })); - else if (msg.Name == "mud_found") - this.Invoke(new Action(() => { MUDUserFound?.Invoke(true); })); - } - }; - } - - public event Action TextSent; - bool isTyping = false; - - private int currentPage = 0; - - public void SetupUI() - { - btnback.Show(); - pnlheader.Dock = DockStyle.Top; - pnlheader.Height = 50; - switch (currentPage) - { - case 0: - page1.BringToFront(); - pnlheader.Dock = DockStyle.Left; - pnlheader.Width = 100; - btnback.Hide(); - break; - case 1: - btnnext.Hide(); - btnback.Hide(); - page2.BringToFront(); - pgformatprogress.Value = 0; - var dinf = new System.IO.DriveInfo("C:"); - StartWipingInBackground(((dinf.TotalSize / 1024) / 1024) / 1024); - TextType($@"So I see you're progressing through. -I really hope you aren't one of those newbies who just next-next-next-finish their way through these things. -I see you've named your drive " + dinf.VolumeLabel + $@" -And it can contain up to {dinf.TotalSize} bytes of information. -And you've formatted this drive with a partition of type " + dinf.DriveFormat + $@". -Interesting... -Very interesting..."); - break; - case 2: - btnnext.Show(); - btnback.Hide(); - TextType(@"Now it's all gone. Now I need some user input so I can install ShiftOS. -Firstly, please enter a username, password, and system name. -Make the username and system name unique so I can identify exactly who you are. You're not the only one here. -Also, make sure the password is secure... There have been people known to breach users' accounts in ShiftOS and steal their stuff. -So make sure your password is secure enough that it can't be guessed, but easy for you to remember, and don't put any personal information in your account."); - page3.BringToFront(); - break; - case 3: - if (string.IsNullOrEmpty(txtnewusername.Text)) - { - TextType("You must specify a valid username!"); - currentPage--; - //SetupUI(); - break; - } - - if (string.IsNullOrEmpty(txtnewpassword.Text)) - { - TextType("A password would seriously be recommended."); - currentPage--; - //SetupUI(); - break; - } - - if (string.IsNullOrEmpty(txtnewsysname.Text)) - { - TextType("You must name your computer."); - currentPage--; - //SetupUI(); - break; - } - - - MUDUserFound = (val) => - { - if(val == true) - { - TextType("I have just verified that your username and password already exists on my end. Please choose another."); - currentPage--; - //SetupUI(); - - } - else - { - TextType("I am going to keep that info on my checklist for installing ShiftOS on your system. Now, onto some legal stuff. I highly suggest you read this."); - currentPage++; - oobe.MySave.Username = txtnewusername.Text; - oobe.MySave.Password = txtnewpassword.Text; - oobe.MySave.SystemName = txtnewsysname.Text; - SetupUI(); - } - }; - ServerManager.SendMessage("mud_checkuserexists", $@"{{ - username: ""{txtnewusername.Text}"", - password: ""{txtnewpassword.Text}"" -}}"); - break; - case 4: - page4.BringToFront(); - txtlicenseagreement.Rtf = Properties.Resources.ShiftOS; - break; - case 5: - CanClose = true; - this.Close(); - break; - case 7: - btnnext.Show(); - btnback.Hide(); - pgrereg.BringToFront(); - TextType("You have two choices - either you can migrate your local user file to this multi-user domain, or you can restart with 0 Codepoints, no upgrades, and still keep your files."); - break; - case 8: - btnnext.Hide(); - ServerMessageReceived rc = null; - - rc = (msg) => - { - if(msg.Name == "mud_found") - { - TextType("That username and password already exists in this multi-user domain. Please choose another."); - currentPage = 7; - } - else if(msg.Name == "mud_notfound") - { - currentPage = 9; - SetupUI(); - } - ServerManager.MessageReceived -= rc; - }; - - if (string.IsNullOrEmpty(txtruname.Text)) - { - TextType("You must provide a username."); - currentPage = 7; - } - - if (string.IsNullOrEmpty(txtrpass.Text)) - { - TextType("You must provide a password."); - currentPage = 7; - } - - if (string.IsNullOrEmpty(txtrsys.Text)) - { - TextType("You must provide a system hostname."); - currentPage = 7; - } - - if (currentPage == 7) - return; - - ServerManager.MessageReceived += rc; - ServerManager.SendMessage("mud_checkuserexists", $@"{{ - username: ""{txtruname.Text}"", - password: ""{txtrpass.Text}"" -}}"); - break; - case 9: - UserReregistered?.Invoke(txtruname.Text, txtrpass.Text, txtrsys.Text); - this.CanClose = true; - this.Close(); - break; - case 10: - btnnext.Show(); - btnback.Hide(); - pglogin.BringToFront(); - break; - case 11: - btnnext.Hide(); - ServerMessageReceived login = null; - - login = (msg) => - { - if (msg.Name == "mud_found") - { - this.Invoke(new Action(() => - { - currentPage = 12; - SetupUI(); - })); - - ServerManager.MessageReceived -= login; - } - else if (msg.Name == "mud_notfound") - { - this.Invoke(new Action(() => - { - currentPage = 10; - SetupUI(); - })); - - ServerManager.MessageReceived -= login; - } - }; - - ServerManager.MessageReceived += login; - if(!string.IsNullOrWhiteSpace(txtluser.Text) && !string.IsNullOrWhiteSpace(txtlpass.Text)) - { - ServerManager.SendMessage("mud_checkuserexists", JsonConvert.SerializeObject(new - { - username = txtluser.Text, - password = txtlpass.Text - })); - } - break; - case 12: - btnnext.Hide(); - ServerMessageReceived getsave = null; - - getsave = (msg) => - { - if (msg.Name == "mud_savefile") - { - this.Invoke(new Action(() => - { - SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - SaveSystem.SaveGame(); - CreateNewSave = false; - DoneLoggingIn?.Invoke(); - this.CanClose = true; - this.Close(); - - })); - } - else if (msg.Name == "mud_notfound") - { - this.Invoke(new Action(() => - { - currentPage = 10; - SetupUI(); - })); - } - ServerManager.MessageReceived -= getsave; - }; - - ServerManager.MessageReceived += getsave; - - ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new - { - username = txtluser.Text, - password = txtlpass.Text - })); - - break; - } - } - - public event Action DoneLoggingIn; - - public bool CreateNewSave = true; - - public event Action UserReregistered; - - public void StartWipingInBackground(long arbitraryAmountOfBytes) - { - pgformatprogress.Maximum = (int)arbitraryAmountOfBytes; - var t = new Thread(() => - { - for(long i = 0; i <= arbitraryAmountOfBytes; i++) - { - Thread.Sleep(40); - this.Invoke(new Action(() => - { - pgformatprogress.Value = (int)i; - lbbyteszeroed.Text = $"Gigabytes zeroed: {i}/{arbitraryAmountOfBytes}"; - })); - } - this.Invoke(new Action(() => - { - currentPage++; - SetupUI(); - })); - }); - t.IsBackground = true; - t.Start(); - } - - - - private void TextType(string text) - { - new Thread(() => - { - while(isTyping == true) - { - - } - isTyping = true; - TextSent?.Invoke(text); - isTyping = false; - }).Start(); - } - - bool CanClose = false; - - private void FakeSetupScreen_FormClosing(object sender, FormClosingEventArgs e) - { - if (CanClose) - { - - } - else - { - e.Cancel = true; - TextType("Don't try to close the dialog. It's a futile attempt."); - } - } - - private void btnback_Click(object sender, EventArgs e) - { - currentPage--; - SetupUI(); - } - - private void btnnext_Click(object sender, EventArgs e) - { - currentPage++; - SetupUI(); - } - - private void button1_Click(object sender, EventArgs e) - { - ShiftOS.Objects.ShiftFS.Utils.Delete(Paths.GetPath("user.dat")); - System.IO.File.WriteAllText(Paths.SaveFile, ShiftOS.Objects.ShiftFS.Utils.ExportMount(0)); - SaveSystem.NewSave(); - this.CanClose = true; - this.Close(); - } - - private void btnnlogin_Click(object sender, EventArgs e) - { - currentPage = 10; - SetupUI(); - } - } -} diff --git a/ShiftOS.WinForms/FakeSetupScreen.resx b/ShiftOS.WinForms/FakeSetupScreen.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ShiftOS.WinForms/FakeSetupScreen.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 54a022c..a4d63e0 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -185,39 +185,7 @@ You must join the digital society, rise up the ranks, and save us. public void ShowSaveTransfer(Save save) { - this.Show(); - var fSetup = new FakeSetupScreen(this, 7); - - var t = new Thread(() => - { - textgeninput = lblhackwords; - Clear(); - TextType("Welcome back to ShiftOS."); - Thread.Sleep(500); - TextType("Since your last time inside ShiftOS, the operating system has changed. Your user account is no longer stored on your local system."); - Thread.Sleep(500); - this.Invoke(new Action(() => - { - //UPS is drunky heaven over here... it's a liquor store, I think... - Drunk Michael - fSetup.UserReregistered += (u, p, s) => - { - save.Username = u; - save.Password = p; - save.SystemName = s; - SaveSystem.CurrentSave = save; - SaveSystem.CurrentSave.Upgrades = new Dictionary(); - Shiftorium.Init(); - - SaveSystem.SaveGame(); - if(Utils.FileExists(Paths.SaveFileInner)) - Utils.Delete(Paths.SaveFileInner); - this.Close(); - }; - fSetup.Show(); - })); - }); - t.IsBackground = true; - t.Start(); + //Stub. } public void PerformUniteLogin() diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1d4e91a..9fc237f 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -316,12 +316,6 @@ DownloadControl.cs - - Form - - - FakeSetupScreen.cs - @@ -517,9 +511,6 @@ DownloadControl.cs - - FakeSetupScreen.cs - Oobe.cs diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index d7c5196..6825f34 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -52,7 +52,6 @@ namespace ShiftOS.WinForms public List Widgets = new List(); - private bool InScreensaver = false; private int millisecondsUntilScreensaver = 300000; /// @@ -231,13 +230,11 @@ namespace ShiftOS.WinForms if(millisecondsUntilScreensaver <= 0) { ShowScreensaver(); - InScreensaver = true; } millisecondsUntilScreensaver--; Thread.Sleep(1); } millisecondsUntilScreensaver = 300000; - InScreensaver = false; HideScreensaver(); } }); @@ -990,7 +987,7 @@ namespace ShiftOS.WinForms { if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) { - lbalstatus.Text = $@"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName} + lbalstatus.Text = $@"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName} {SaveSystem.CurrentSave.Codepoints} Codepoints {Shiftorium.GetAvailable().Length} available, {SaveSystem.CurrentSave.CountUpgrades()} installed."; diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index 7a190df..868d27a 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -98,8 +98,6 @@ namespace ShiftOS.Engine int firstValuePos = -1; int lastValuePos = -1; - string syntaxError = ""; - for (int ii = 0; ii < parts.Count; ii++) { CommandFormat part = parts[ii]; @@ -184,7 +182,6 @@ namespace ShiftOS.Engine else { position = text.Length; - syntaxError = "Syntax Error"; command = "+FALSE+"; } help = -1; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 7980635..87aacd6 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -73,7 +73,7 @@ namespace ShiftOS.Engine TerminalBackend.IsForwardingConsoleWrites = forwarding; TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; string resultFriendly = (result == true) ? "yes" : "no"; - Console.WriteLine($"{SaveSystem.CurrentSave.Username} says {resultFriendly}."); + Console.WriteLine($"{SaveSystem.CurrentUser.Username} says {resultFriendly}."); TerminalBackend.IsForwardingConsoleWrites = false; }; Desktop.InvokeOnWorkerThread(new Action(() => -- cgit v1.2.3 From 75ed7e9215ba88358d9b838dd82fa3841f78ae5a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 May 2017 11:31:20 -0400 Subject: Fix softlocks on pre-user OOBE. --- .vs/config/applicationhost.config | 1030 ++++++++++++++++++++++++++++++++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UserConfig.cs | 37 ++ ShiftOS.Server/Program.cs | 1 + ShiftOS.Server/SaveManager.cs | 2 +- ShiftOS.WinForms/OobeStory.cs | 10 +- ShiftOS.WinForms/UniteLoginDialog.cs | 3 +- ShiftOS.WinForms/UniteSignupDialog.cs | 3 +- ShiftOS_TheReturn/SaveSystem.cs | 2 +- ShiftOS_TheReturn/UniteClient.cs | 12 +- 10 files changed, 1091 insertions(+), 10 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 ShiftOS.Objects/UserConfig.cs (limited to 'ShiftOS.Server/Program.cs') diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..b42cd34 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1030 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 7a19aeb..c2ef5ed 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -58,6 +58,7 @@ + diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs new file mode 100644 index 0000000..61d11b8 --- /dev/null +++ b/ShiftOS.Objects/UserConfig.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace ShiftOS.Objects +{ + public class UserConfig + { + public string UniteUrl { get; set; } + public string DigitalSocietyAddress { get; set; } + public int DigitalSocietyPort { get; set; } + + public static UserConfig Get() + { + var conf = new UserConfig + { + UniteUrl = "http://getshiftos.ml", + DigitalSocietyAddress = "michaeltheshifter.me", + DigitalSocietyPort = 13370 + }; + + if (!File.Exists("servers.json")) + { + File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); + } + else + { + conf = JsonConvert.DeserializeObject(File.ReadAllText("servers.json")); + } + return conf; + } + } +} diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 97c8a66..75af56f 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -86,6 +86,7 @@ namespace ShiftOS.Server /// The command-line arguments. public static void Main(string[] args) { + UserConfig.Get(); System.Timers.Timer tmr = new System.Timers.Timer(5000); tmr.Elapsed += (o, a) => { diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 63aa2bf..d81a1a7 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -189,7 +189,7 @@ namespace ShiftOS.Server //Update the shiftos website with the user's codepoints. if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken)) { - var wreq = WebRequest.Create("http://getshiftos.ml/API/SetCodepoints/" + sav.Codepoints.ToString()); + var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString()); wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken); wreq.GetResponse(); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index bab4889..39ca5b5 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -120,7 +120,7 @@ namespace ShiftOS.WinForms Console.Write(" "); ConsoleEx.BackgroundColor = ConsoleColor.Black; } - Engine.AudioManager.PlayStream(Properties.Resources.typesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); formatProgress++; Thread.Sleep(175); } @@ -135,14 +135,16 @@ namespace ShiftOS.WinForms { Console.WriteLine("Creating: " + dir); Thread.Sleep(125); - Engine.AudioManager.PlayStream(Properties.Resources.writesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound)); } } Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); - ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); - + Desktop.InvokeOnWorkerThread(() => + { + ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); + }); } private static bool isValid(string text, string chars) { diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs index 4c85005..c78e987 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -59,7 +60,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index a46a9b0..7d0fd33 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -99,7 +100,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index e635a7a..31db58a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -131,7 +131,7 @@ namespace ShiftOS.Engine try { - ServerManager.Initiate("secondary4162.cloudapp.net", 13370); + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 1136b5c..8d6a58d 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -5,13 +5,20 @@ using System.Net; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using ShiftOS.Objects; namespace ShiftOS.Unite { public class UniteClient { public string Token { get; private set; } - public string BaseURL { get; private set; } + public string BaseURL + { + get + { + return UserConfig.Get().UniteUrl; + } + } public string GetDisplayNameId(string id) { @@ -25,7 +32,8 @@ namespace ShiftOS.Unite public UniteClient(string baseurl, string usertoken) { - BaseURL = baseurl; + //Handled by the servers.json file + //BaseURL = baseurl; Token = usertoken; } -- cgit v1.2.3 From 3b1c71e6710c06a9e390f449589bd30cb2f4b7dd Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 9 May 2017 01:54:31 +0000 Subject: test --- ShiftOS.Server/Program.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ShiftOS.Server/Program.cs') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 97c8a66..fbbfd7d 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -86,6 +86,12 @@ namespace ShiftOS.Server /// The command-line arguments. public static void Main(string[] args) { + Thread.Sleep(2000); + AppDomain.CurrentDomain.UnhandledException += (o, a) => + { + System.Diagnostics.Process.Start("ShiftOS.Server.exe"); + Environment.Exit(0); + }; System.Timers.Timer tmr = new System.Timers.Timer(5000); tmr.Elapsed += (o, a) => { -- cgit v1.2.3