From 69ef3ba644cf3e15dbee32994a6f640294bc54b0 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 27 Feb 2017 21:19:31 +0000 Subject: Chat logging. --- ShiftOS.Server/ChatBackend.cs | 69 ++++++++++++++++++++++++++++++++++++++++--- ShiftOS.Server/ShopBackend.cs | 19 +++++++----- 2 files changed, 76 insertions(+), 12 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/ChatBackend.cs b/ShiftOS.Server/ChatBackend.cs index 242ae16..ba1c48e 100644 --- a/ShiftOS.Server/ChatBackend.cs +++ b/ShiftOS.Server/ChatBackend.cs @@ -1,4 +1,4 @@ -/* +/* * MIT License * * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs @@ -73,12 +73,14 @@ namespace ShiftOS.Server { 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(new ChatMessage(s.Author.Username, "discord_" + s.Channel.Name, (s as SocketUserMessage).Resolve(0), chatID)) + Contents = JsonConvert.SerializeObject(msg) })); + Log(chatID, $"[{msg.Username}@{msg.SystemName}] {msg.Message}"); } } } @@ -94,10 +96,11 @@ namespace ShiftOS.Server 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}"); } - //Relay it back to all MUD clients. - RelayMessage(g, msg); } }; Reinitialized += () => @@ -115,6 +118,8 @@ namespace ShiftOS.Server { //Just relay it. RelayMessage(g, msg); + //...Then log it. + Log(chatID, $"[{msg.Username}@{msg.SystemName}] {msg.Message}"); } }; Reinitialized += () => { chatKilled = true; }; @@ -157,6 +162,62 @@ namespace ShiftOS.Server MessageReceived?.Invoke(guid, new ChatMessage(msg["Username"], msg["SystemName"], msg["Message"], msg["Channel"])); } + + [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/ShopBackend.cs b/ShiftOS.Server/ShopBackend.cs index 12f69ce..baf1e7a 100644 --- a/ShiftOS.Server/ShopBackend.cs +++ b/ShiftOS.Server/ShopBackend.cs @@ -1,4 +1,4 @@ -/* +/* * MIT License * * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs @@ -185,15 +185,18 @@ namespace ShiftOS.Server if (File.Exists("shops.json")) foreach (var shop in JsonConvert.DeserializeObject>(File.ReadAllText("shops.json"))) { - if (shop.Owner == shopOwner) + if (shop != null) { - server.DispatchTo(new Guid(guid), new NetObject("ruecuodaL", new ServerMessage + if (shop.Owner == shopOwner) { - Name = "user_shop", - GUID = "server", - Contents = JsonConvert.SerializeObject(shop) - })); - return; + server.DispatchTo(new Guid(guid), new NetObject("ruecuodaL", new ServerMessage + { + Name = "user_shop", + GUID = "server", + Contents = JsonConvert.SerializeObject(shop) + })); + return; + } } } -- cgit v1.2.3 From 9e30864a106a1a9b5dab0ffd6c333951d3c91dd2 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 6 Mar 2017 17:01:16 +0000 Subject: improvements --- ShiftOS.Objects/Objects.cs | 4 ++++ ShiftOS.Objects/Save.cs | 2 ++ ShiftOS.Server/ChatBackend.cs | 43 ++++++++++++++++++++++++++++++++++++++++++- ShiftOS.Server/Program.cs | 4 ++++ ShiftOS.Server/SaveManager.cs | 8 +++++++- 5 files changed, 59 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Objects/Objects.cs b/ShiftOS.Objects/Objects.cs index 17f40ea..c4cd67c 100644 --- a/ShiftOS.Objects/Objects.cs +++ b/ShiftOS.Objects/Objects.cs @@ -96,6 +96,10 @@ namespace ShiftOS.Objects //Don't describe this one. We want it to be hidden from the admin panel's chat editor. public string ID { get; set; } + [FriendlyName("Requires Patreon?")] + [FriendlyDescription("If checked, this chat will only be shown in the MUD Control Centre if the user's save is marked as a Patreon supporter.")] + public bool RequiresPatreon { get; set; } + [FriendlyName("Chat topic")] [FriendlyDescription("A more in-depth version of your chat name. Describe what your chat's about in a sentence.")] public string Topic { get; set; } diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 23c1d0f..35bfdc2 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -45,6 +45,8 @@ namespace ShiftOS.Objects public int MinorVersion { get; set; } public int Revision { get; set; } + public bool IsPatreon { get; set; } + public string Password { get; set; } public bool PasswordHashed { get; set; } public string SystemName { get; set; } diff --git a/ShiftOS.Server/ChatBackend.cs b/ShiftOS.Server/ChatBackend.cs index ba1c48e..b9fbf25 100644 --- a/ShiftOS.Server/ChatBackend.cs +++ b/ShiftOS.Server/ChatBackend.cs @@ -103,7 +103,21 @@ namespace ShiftOS.Server } } }; - Reinitialized += () => + 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(); @@ -122,11 +136,31 @@ namespace ShiftOS.Server 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 @@ -163,6 +197,13 @@ namespace ShiftOS.Server } + 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) { 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")) diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index cef8b37..e986ecd 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -1,4 +1,4 @@ -/* +/* * MIT License * * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs @@ -73,6 +73,12 @@ namespace ShiftOS.Server if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString()) { + if(save.ID == new Guid()) + { + save.ID = Guid.NewGuid(); + WriteEncFile(savefile, JsonConvert.SerializeObject(save)); + } + Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { -- cgit v1.2.3 From 078c729d0918b923a4b4076bd927b53cd1bcc9d7 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 6 Mar 2017 21:24:34 +0000 Subject: server-side for auto npc generation --- ShiftOS.Server/RandomUserGenerator.cs | 277 ++++++++++++++++++++++++++++++++++ ShiftOS.Server/ShiftOS.Server.csproj | 1 + 2 files changed, 278 insertions(+) create mode 100644 ShiftOS.Server/RandomUserGenerator.cs (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs new file mode 100644 index 0000000..afaee46 --- /dev/null +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.IO; +using ShiftOS.Objects; +using static ShiftOS.Objects.ShiftFS.Utils; + +namespace ShiftOS.Server +{ + public static class RandomUserGenerator + { + const string USERPREFIXES = "culled;purged;anon;fatal;unaccounted;netban;killed;old"; + const string SYSNAMES = "unknown;error;dead;system;mud"; + const string PASSCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_"; + + public static void StartThread() + { + var t = new Thread(() => + { + var rnd = new Random(); + while (Program.server.IsOnline) + { + if (!Directory.Exists("deadsaves")) + { + Directory.CreateDirectory("deadsaves"); + } + + var sve = new Save(); + + int passLength = 0; + int securityGrade = rnd.Next(1, 5); + switch (securityGrade) + { + default: + passLength = 4; + break; + case 2: + passLength = 6; + break; + case 3: + passLength = 10; + break; + case 4: + passLength = 15; + break; + } + + string pass = ""; + char lastChar = '\0'; + for (int i = 0; i < passLength; i++) + { + char c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)]; + while(c == lastChar) + { + c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)]; + } + pass += c; + lastChar = c; //this ensures no repeated sequences. + } + + sve.Password = pass; + + int id_length = rnd.Next(3, 10); + string id = ""; + + lastChar = '\0'; + for (int i = 0; i < id_length; i++) + { + char c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)]; + while (c == lastChar) + { + c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)]; + } + id += c; + lastChar = c; //this ensures no repeated sequences. + } + + string[] names = USERPREFIXES.Split(';'); + string name = names[rnd.Next(0, names.Length)]; + sve.Username = $"{id}_{name}"; + + names = SYSNAMES.Split(';'); + name = names[rnd.Next(0, names.Length)]; + + sve.SystemName = name; + + //Codepoint generation. + int startCP = 0; + int maxAmt = 0; + + switch (securityGrade) + { + default: + startCP = 1000; + maxAmt = 12500; + break; + case 2: + startCP = 25000; + maxAmt = 50000; + break; + case 3: + startCP = 75000; + maxAmt = 150000; + break; + case 4: + startCP = 500000; + maxAmt = 1500000; + break; + } + + 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 + dir.Name = sve.Username; + //json the object and mount + string json = Newtonsoft.Json.JsonConvert.SerializeObject(dir); + //mount it to the MUD + ShiftOS.Objects.ShiftFS.Utils.Mount(json); + //get the mount id + int mountid = ShiftOS.Objects.ShiftFS.Utils.Mounts.Count - 1; + + bool leakShiftnetDataRandomly = (rnd.Next(0, 10) > 5); + + //create home directory + CreateDirectory($"{mountid}:/home"); + //create downloads directory + CreateDirectory($"{mountid}:/home/downloads"); + //if we're leaking shiftnet data... + CreateDirectory($"{mountid}:/home/documents"); + + //alright, let's leak some shop items. + foreach(var shop in Newtonsoft.Json.JsonConvert.DeserializeObject(File.ReadAllText("shops.json"))) + { + if(shop != null) + { + try + { + foreach(var item in shop.Items) + { + if(rnd.Next(0,10) > 5) + { + if (sve.Codepoints >= item.Cost) + { + //deduct item's codepoints. + sve.Codepoints -= item.Cost; + + //create a new file in user's downloads folder...with the item's name and binary contents inside. + WriteAllBytes($"{mountid}:/home/downloads/{item.Name}.{GetFileExt(item.FileType)}", item.MUDFile); + } + } + } + } + catch { } + } + } + + //shiftnetData + Dictionary shiftnetData = new Dictionary(); + + if(leakShiftnetDataRandomly == true) + { + //And maybe let's leak some shiftnet sites. + LeakDirectories($"{mountid}:/home/documents", out shiftnetData); + + //Now start saving the directories. + foreach(var kv in shiftnetData) + { + if(!DirectoryExists(kv.Value)) + CreateDirectory(kv.Value); + + foreach(var file in Directory.GetFiles(kv.Key)) + { + 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. + + } + }); + t.IsBackground = true; + t.Start(); + } + + public static void LeakDirectories(string output, out Dictionary targets) + { + var rnd = new Random(); + List dirs = new List(); + foreach(var pth in getDirectories("shiftnet")) + { + if(rnd.Next(0,10) > 5) + { + dirs.Add(pth); + } + } + + targets = new Dictionary(); + foreach(var dir in dirs) + { + string sDir = dir.Replace("\\", "/"); + while (!sDir.StartsWith("shiftnet/")) + { + sDir = sDir.Remove(0, 1); + } + targets.Add(dir, output + "/" + sDir); + } + + } + + private static List getDirectories(string path) + { + List paths = new List(); + foreach(var pth in Directory.GetDirectories(path)) + { + paths.AddRange(getDirectories(pth).ToArray()); + } + paths.Add(path); + return paths; + } + + public static string GetFileExt(int fType) + { + switch((FileType)fType) + { + default: + return "bin"; + case FileType.Executable: + return "sft"; + case FileType.Filesystem: + return "mfs"; + case FileType.Image: + return "pic"; + case FileType.JSON: + return "json"; + case FileType.Lua: + return "lua"; + case FileType.Skin: + return "skn"; + case FileType.TextFile: + return ".txt"; + } + } + + public enum FileType + { + TextFile, + Directory, + Mount, + UpOne, + Image, + Skin, + JSON, + Executable, + Lua, + Python, + Filesystem, + Unknown + } + } +} diff --git a/ShiftOS.Server/ShiftOS.Server.csproj b/ShiftOS.Server/ShiftOS.Server.csproj index a6af8c7..aed227f 100644 --- a/ShiftOS.Server/ShiftOS.Server.csproj +++ b/ShiftOS.Server/ShiftOS.Server.csproj @@ -180,6 +180,7 @@ True Resources.resx + -- 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') 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 bf3dbc26a5579e9c2134435d272aafe857ffd1d1 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 01:09:53 +0000 Subject: the mud called me a drunk --- ShiftOS.Server/RandomUserGenerator.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs index afaee46..8c1e430 100644 --- a/ShiftOS.Server/RandomUserGenerator.cs +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -214,12 +214,18 @@ namespace ShiftOS.Server targets = new Dictionary(); foreach(var dir in dirs) { - string sDir = dir.Replace("\\", "/"); - while (!sDir.StartsWith("shiftnet/")) + if (!string.IsNullOrWhiteSpace(dir)) { - sDir = sDir.Remove(0, 1); + string sDir = dir.Replace("\\", "/"); + if (sDir.Contains("shiftnet")) + { + while (!sDir.StartsWith("shiftnet/")) + { + sDir = sDir.Remove(0, 1); + } + targets.Add(dir, output + "/" + sDir); + } } - targets.Add(dir, output + "/" + sDir); } } -- cgit v1.2.3 From 01530d637d790a101ea4dcb0e183664420d98ff9 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 13:14:07 +0000 Subject: Fix NPC generation --- ShiftOS.Objects/ShiftFS.cs | 5 ++++- ShiftOS.Server/RandomUserGenerator.cs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index e14c2a8..2c6b28b 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -291,10 +291,13 @@ namespace ShiftOS.Objects.ShiftFS { string[] pathlist = path.Split('/'); int vol = Convert.ToInt32(pathlist[0].Replace(":", "")); + if (Mounts[vol] == null) + Mounts[vol] = new Directory(); var dir = Mounts[vol]; + for (int i = 1; i <= pathlist.Length - 1; i++) { - dir = dir.FindDirectoryByName(pathlist[i]); + dir = dir?.FindDirectoryByName(pathlist[i]); } return dir != null; diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs index 8c1e430..672f25d 100644 --- a/ShiftOS.Server/RandomUserGenerator.cs +++ b/ShiftOS.Server/RandomUserGenerator.cs @@ -119,6 +119,7 @@ namespace ShiftOS.Server var dir = new ShiftOS.Objects.ShiftFS.Directory(); //name the directory after the user dir.Name = sve.Username; + dir.permissions = Objects.ShiftFS.Permissions.All; //json the object and mount string json = Newtonsoft.Json.JsonConvert.SerializeObject(dir); //mount it to the MUD @@ -219,7 +220,7 @@ namespace ShiftOS.Server string sDir = dir.Replace("\\", "/"); if (sDir.Contains("shiftnet")) { - while (!sDir.StartsWith("shiftnet/")) + while (!sDir.StartsWith("shiftnet")) { sDir = sDir.Remove(0, 1); } -- 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') 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 c64333d0f57c50a2519b5c631d44243ff41ca815 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Tue, 7 Mar 2017 18:43:07 +0000 Subject: User hacking fundamentals. It's intentionally insecure. --- ShiftOS.Server/Core.cs | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index 42a9127..4ec421d 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -125,5 +125,91 @@ namespace ShiftOS.Server } } + + [MudRequest("getusers", typeof(string))] + public static void GetAllUsers(string guid, string contents) + { + List accs = new List(); + if(contents == "dead") + { + foreach(var sve in Directory.GetFiles("deadsaves")) + { + if (sve.EndsWith(".save")) + { + var save = JsonConvert.DeserializeObject(File.ReadAllText(sve)); + accs.Add($"{save.Username}@{save.SystemName}"); + } + + } + } + server.DispatchTo(new Guid(guid), new NetObject("h4xx0r", new ServerMessage + { + Name = "allusers", + GUID = "server", + Contents = JsonConvert.SerializeObject(accs) + })); + } + + [MudRequest("mud_save_allow_dead", typeof(Save))] + public static void SaveDead(string guid, Save sve) + { + if(File.Exists("saves/" + sve.Username + ".save")) + { + WriteEncFile("saves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve)); + } + else if(File.Exists("deadsaves/" + sve.Username + ".save")) + { + File.WriteAllText("deadsaves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve)); + } + } + + [MudRequest("get_user_data", typeof(Dictionary))] + public static void GetUserData(string guid, Dictionary contents) + { + string usr = contents["user"]; + string sys = contents["sysname"]; + + foreach(var sve in Directory.GetFiles("deadsaves")) + { + if (sve.EndsWith(".save")) + { + var saveFile = JsonConvert.DeserializeObject(File.ReadAllText(sve)); + if(saveFile.Username == usr && saveFile.SystemName == sys) + { + server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage + { + Name = "user_data", + GUID = "server", + Contents = JsonConvert.SerializeObject(saveFile) + })); + } + return; + } + } + foreach (var sve in Directory.GetFiles("saves")) + { + if (sve.EndsWith(".save")) + { + var saveFile = JsonConvert.DeserializeObject(ReadEncFile(sve)); + if (saveFile.Username == usr && saveFile.SystemName == sys) + { + server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage + { + Name = "user_data", + GUID = "server", + Contents = JsonConvert.SerializeObject(saveFile) + })); + } + return; + } + } + + server.DispatchTo(new Guid(guid), new NetObject("n07_50_1337", new ServerMessage + { + Name = "user_data_not_found", + GUID = "server" + })); + + } } } -- cgit v1.2.3 From 0f19359ef042805ac645a1817a5c95b722c96a37 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Wed, 8 Mar 2017 01:43:25 +0000 Subject: They're all bears on unicycles... --- ShiftOS.Server/ShiftnetBackend.cs | 44 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/ShiftnetBackend.cs b/ShiftOS.Server/ShiftnetBackend.cs index 60b3aa4..c7bf0e8 100644 --- a/ShiftOS.Server/ShiftnetBackend.cs +++ b/ShiftOS.Server/ShiftnetBackend.cs @@ -43,37 +43,49 @@ namespace ShiftOS.Server string url = contents as string; if (!url.StartsWith("shiftnet/")) { - server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + try { - Name = "shiftnet_file", - GUID = "server", - Contents = (File.Exists("badrequest.md") == true) ? File.ReadAllText("badrequest.md") : @"# Bad request. + + server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + { + Name = "shiftnet_file", + GUID = "server", + Contents = (File.Exists("badrequest.md") == true) ? File.ReadAllText("badrequest.md") : @"# Bad request. You have sent a bad request to the multi-user domain. Please try again." - })); + })); + } + catch { } return; } if (File.Exists(url)) { - server.DispatchTo(new Guid(guid), new NetObject("download", new ServerMessage + try { - Name = "download_meta", - GUID = "server", - Contents = JsonConvert.SerializeObject(File.ReadAllBytes(url)) - })); + server.DispatchTo(new Guid(guid), new NetObject("download", new ServerMessage + { + Name = "download_meta", + GUID = "server", + Contents = JsonConvert.SerializeObject(File.ReadAllBytes(url)) + })); + } + catch { } } else { - server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + try { - Name = "shiftnet_file", - GUID = "server", - Contents = (File.Exists("notfound.md") == true) ? File.ReadAllText("notfound.md") : @"# Not found. + server.DispatchTo(new Guid(guid), new NetObject("shiftnet_got", new ServerMessage + { + Name = "shiftnet_file", + GUID = "server", + Contents = (File.Exists("notfound.md") == true) ? File.ReadAllText("notfound.md") : @"# Not found. The page you requested at was not found on this multi-user domain." - })); - + })); + } + catch { } } } -- cgit v1.2.3 From a9d7195f1e631a88386cf58dd1e33e36cba28a69 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Thu, 9 Mar 2017 14:43:03 +0000 Subject: make script runner less drunk --- ShiftOS.Server/Core.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index 4ec421d..a602240 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -96,10 +96,11 @@ namespace ShiftOS.Server { Name = "run", GUID = "Server", - Contents = $@"{{ - script:""{File.ReadAllText($"scripts/{user}/{script}.lua").Replace("\"", "\\\"")}"", - args:""{sArgs}"" - }}" + Contents = JsonConvert.SerializeObject(new + { + script = File.ReadAllText($"scripts/{user}/{script}.lua"), + args = sArgs + }) })); } else @@ -115,7 +116,7 @@ namespace ShiftOS.Server { Name = "Error", GUID = "Server", - Contents = JsonConvert.SerializeObject(new MudException("Command parse error")) + Contents = JsonConvert.SerializeObject(new MudException(" Script not found or script error detected.")) })); } catch @@ -182,8 +183,8 @@ namespace ShiftOS.Server GUID = "server", Contents = JsonConvert.SerializeObject(saveFile) })); + return; } - return; } } foreach (var sve in Directory.GetFiles("saves")) @@ -199,8 +200,8 @@ namespace ShiftOS.Server GUID = "server", Contents = JsonConvert.SerializeObject(saveFile) })); + return; } - return; } } -- cgit v1.2.3 From 23671dedd1b715eb3b24d3174530926d7cbc3b52 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Thu, 9 Mar 2017 17:52:24 +0000 Subject: MUD now collects diagnostics. --- ShiftOS.Server/Core.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index a602240..e14ca27 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -127,6 +127,17 @@ namespace ShiftOS.Server } + [MudRequest("diag_log", typeof(string))] + public static void Diagnostic(string guid, string line) + { + List lines = new List(); + if (File.Exists("diagnostics.log")) + lines = new List(File.ReadAllLines("diagnostics.log")); + + lines.Add(line); + File.WriteAllLines("diagnostics.log", lines.ToArray()); + } + [MudRequest("getusers", typeof(string))] public static void GetAllUsers(string guid, string contents) { -- 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') 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 edf4aef6adf8a2a45c347f70804fc5ac93070576 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Fri, 7 Apr 2017 17:01:23 +0000 Subject: Merge --- ShiftOS.Server/Core.cs | 234 ------- ShiftOS.WinForms/Applications/FormatEditor.cs | 186 ----- ShiftOS.WinForms/Applications/Pong.Designer.cs | 744 -------------------- ShiftOS.WinForms/Applications/Pong.cs | 675 ------------------- .../Applications/ShiftoriumFrontend.Designer.cs | 261 ------- .../Applications/ShiftoriumFrontend.cs | 196 ------ ShiftOS.WinForms/Controls/TerminalBox.cs | 115 ---- ShiftOS.WinForms/Oobe.cs | 540 --------------- ShiftOS.WinForms/Tools/ControlManager.cs | 325 --------- ShiftOS.WinForms/WindowBorder.cs | 490 -------------- ShiftOS.WinForms/WinformsDesktop.cs | 746 --------------------- ShiftOS.WinForms/WinformsWindowManager.cs | 183 ----- ShiftOS_TheReturn/AudioManager.cs | 126 ---- ShiftOS_TheReturn/Commands.cs | 739 -------------------- ShiftOS_TheReturn/Localization.cs | 201 ------ ShiftOS_TheReturn/SaveSystem.cs | 331 --------- ShiftOS_TheReturn/ServerManager.cs | 230 ------- ShiftOS_TheReturn/Shiftorium.cs | 285 -------- ShiftOS_TheReturn/TerminalTextWriter.cs | 131 ---- 19 files changed, 6738 deletions(-) delete mode 100644 ShiftOS.Server/Core.cs delete mode 100644 ShiftOS.WinForms/Applications/FormatEditor.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs delete mode 100644 ShiftOS.WinForms/Controls/TerminalBox.cs delete mode 100644 ShiftOS.WinForms/Oobe.cs delete mode 100644 ShiftOS.WinForms/Tools/ControlManager.cs delete mode 100644 ShiftOS.WinForms/WindowBorder.cs delete mode 100644 ShiftOS.WinForms/WinformsDesktop.cs delete mode 100644 ShiftOS.WinForms/WinformsWindowManager.cs delete mode 100644 ShiftOS_TheReturn/AudioManager.cs delete mode 100644 ShiftOS_TheReturn/Commands.cs delete mode 100644 ShiftOS_TheReturn/Localization.cs delete mode 100644 ShiftOS_TheReturn/SaveSystem.cs delete mode 100644 ShiftOS_TheReturn/ServerManager.cs delete mode 100644 ShiftOS_TheReturn/Shiftorium.cs delete mode 100644 ShiftOS_TheReturn/TerminalTextWriter.cs (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs deleted file mode 100644 index 7fe600f..0000000 --- a/ShiftOS.Server/Core.cs +++ /dev/null @@ -1,234 +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; - - -namespace ShiftOS.Server -{ - public static class Core - { - [MudRequest("getguid_reply", typeof(string))] - public static void GuidBounce(string guid, object contents) - { - //The message's GUID was manipulated by the client to send to another client. - //So we can just bounce back the message to the other client. - server.DispatchTo(new Guid(guid), new NetObject("bounce", new ServerMessage - { - Name = "getguid_reply", - GUID = guid, - Contents = contents as string - })); - - } - - [MudRequest("getguid_send", typeof(string))] - public static void GuidReceiver(string guid, object contents) - { - string usrname = contents as string; - server.DispatchAll(new NetObject("are_you_this_guy", new ServerMessage - { - Name = "getguid_fromserver", - GUID = guid, - Contents = usrname, - })); - - } - - [MudRequest("script", typeof(Dictionary))] - public static void RunScript(string guid, object contents) - { - try - { - var args = contents as Dictionary; - - string user = ""; - string script = ""; - string sArgs = ""; - - if (!args.ContainsKey("user")) - throw new MudException("No 'user' arg specified in message to server"); - - if (!args.ContainsKey("script")) - throw new MudException("No 'script' arg specified in message to server"); - - if (!args.ContainsKey("args")) - throw new MudException("No 'args' arg specified in message to server"); - - user = args["user"] as string; - script = args["script"] as string; - sArgs = args["args"] as string; - - if (File.Exists($"scripts/{user}/{script}.lua")) - { - var script_arguments = JsonConvert.DeserializeObject>(sArgs); - server.DispatchTo(new Guid(guid), new NetObject("runme", new ServerMessage - { - Name = "run", - GUID = "Server", - Contents = JsonConvert.SerializeObject(new - { - script = File.ReadAllText($"scripts/{user}/{script}.lua"), - args = sArgs - }) - })); - } - else - { - throw new MudException($"{user}.{script}: Script not found."); - } - } - catch - { - try - { - Program.server.DispatchTo(new Guid(guid), new NetObject("error", new ServerMessage - { - Name = "Error", - GUID = "Server", - Contents = JsonConvert.SerializeObject(new MudException(" Script not found or script error detected.")) - })); - } - catch - { - //fuck. - } - } - - } - - [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) - { - List lines = new List(); - if (File.Exists("diagnostics.log")) - lines = new List(File.ReadAllLines("diagnostics.log")); - - lines.Add(line); - File.WriteAllLines("diagnostics.log", lines.ToArray()); - } - - [MudRequest("getusers", typeof(string))] - public static void GetAllUsers(string guid, string contents) - { - List accs = new List(); - if(contents == "dead") - { - foreach(var sve in Directory.GetFiles("deadsaves")) - { - if (sve.EndsWith(".save")) - { - var save = JsonConvert.DeserializeObject(File.ReadAllText(sve)); - accs.Add($"{save.Username}@{save.SystemName}"); - } - - } - } - server.DispatchTo(new Guid(guid), new NetObject("h4xx0r", new ServerMessage - { - Name = "allusers", - GUID = "server", - Contents = JsonConvert.SerializeObject(accs) - })); - } - - [MudRequest("mud_save_allow_dead", typeof(Save))] - public static void SaveDead(string guid, Save sve) - { - if(File.Exists("saves/" + sve.Username + ".save")) - { - WriteEncFile("saves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve)); - } - else if(File.Exists("deadsaves/" + sve.Username + ".save")) - { - File.WriteAllText("deadsaves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve)); - } - } - - [MudRequest("get_user_data", typeof(Dictionary))] - public static void GetUserData(string guid, Dictionary contents) - { - string usr = contents["user"]; - string sys = contents["sysname"]; - - foreach(var sve in Directory.GetFiles("deadsaves")) - { - if (sve.EndsWith(".save")) - { - var saveFile = JsonConvert.DeserializeObject(File.ReadAllText(sve)); - if(saveFile.Username == usr && saveFile.SystemName == sys) - { - server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage - { - Name = "user_data", - GUID = "server", - Contents = JsonConvert.SerializeObject(saveFile) - })); - return; - } - } - } - foreach (var sve in Directory.GetFiles("saves")) - { - if (sve.EndsWith(".save")) - { - var saveFile = JsonConvert.DeserializeObject(ReadEncFile(sve)); - if (saveFile.Username == usr && saveFile.SystemName == sys) - { - server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage - { - Name = "user_data", - GUID = "server", - Contents = JsonConvert.SerializeObject(saveFile) - })); - return; - } - } - } - - server.DispatchTo(new Guid(guid), new NetObject("n07_50_1337", new ServerMessage - { - Name = "user_data_not_found", - GUID = "server" - })); - - } - } -} diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs deleted file mode 100644 index c5afc02..0000000 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ /dev/null @@ -1,186 +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.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms.Applications { - [MultiplayerOnly] - [Launcher("FormatEditor", true, "al_format_editor", "Games")] - [RequiresUpgrade("format_editor")] - [WinOpen("formateditor")] - [DefaultIcon("iconFormatEditor")] - - public partial class FormatEditor : UserControl, IShiftOSWindow { - - IList parts = new List(); - CommandParser parser = new CommandParser(); - IList editorBoxes = new List(); - - string commandMode = "namespace"; - int avcount = 0; - - public FormatEditor() { - InitializeComponent(); - } - - public void OnLoad() { - OnUpgrade(); - } - - public void OnSkinLoad() { } - - public bool OnUnload() { return true; } - - public void OnUpgrade() { - btnAddOptionalText.Visible = ShiftoriumFrontend.UpgradeInstalled("format_editor_optional_text"); - btnAddRegexText.Visible = ShiftoriumFrontend.UpgradeInstalled("format_editor_regex"); - btnAddColor.Visible = ShiftoriumFrontend.UpgradeInstalled("format_editor_syntax_highlighting"); - } - - private void addPart(CommandFormat part) { - parser.AddPart(part); - - addPart(part.Draw()); - } - - private void addPart(Control part) { - Panel container = new Panel(); - - Control drawnPart = part; - container.Size = drawnPart.Size; - container.Controls.Add(drawnPart); - - int woffset = 0; - if (editorBoxes.Count > 0) { - woffset = editorBoxes.Last().Width + editorBoxes.Last().Location.X; - } else { - woffset = 0; - } - - container.Location = new Point(woffset, 0); - editorBoxes.Add(container); - panelEditor.Controls.Add(container); - } - - private void btnAddText_Click(object sender, EventArgs e) { - addPart(new CommandFormatText()); - } - - private void btnAddOptionalText_Click(object sender, EventArgs e) { - addPart(new CommandFormatOptionalText()); - } - - private void btnAddRegexText_Click(object sender, EventArgs e) { - - } - - private void btnAddColor_Click(object sender, EventArgs e) { - - } - - private void btnAddCommand_Click(object sender, EventArgs e) { - switch (commandMode) { - case "namespace": - addPart(new CommandFormatNamespace()); - commandMode = "command"; - btnAddCommand.Text = "+ Command"; - break; - case "command": - addPart(new CommandFormatCommand()); - commandMode = "argument"; - btnAddCommand.Text = "+ Argument"; - break; - case "argument": - addPart(new CommandFormatArgument()); - commandMode = "value"; - btnAddCommand.Text = "+ \"Value\""; - break; - case "value": - addPart(new CommandFormatValue()); - avcount++; - if (avcount >= 2) { - commandMode = ""; - btnAddCommand.Text = ""; - btnAddCommand.Enabled = false; - }else { - commandMode = "argument"; - btnAddCommand.Text = "+ Argument"; - } - break; - } - } - - private void richTextBox1_TextChanged(object sender, EventArgs e) { - var result = parser.ParseCommand(richTextBox1.Text); - - if (result.Equals(default(KeyValuePair, Dictionary>))) { - lblExampleCommand.Text = "Syntax Error"; - } else { - string argvs = "{"; - - foreach (KeyValuePair entry in result.Value) { - argvs += entry.Key + "=\"" + entry.Value + "\", "; - } - - argvs += "}"; - - lblExampleCommand.Text = result.Key + argvs; - } - } - - private void btnTest_Click(object sender, EventArgs e) { - - } - - private void btnSave_Click(object sender, EventArgs e) { - CurrentCommandParser.parser = parser; - - FileSkimmerBackend.GetFile(new string[] { ".cf" }, FileOpenerStyle.Save, new Action((result) => { - Objects.ShiftFS.Utils.WriteAllText(result, parser.Save()); - })); - } - - private void btnLoad_Click(object sender, EventArgs e) { - FileSkimmerBackend.GetFile(new string[] { ".cf" }, FileOpenerStyle.Open, new Action((result) => { - parser = CommandParser.Load(Objects.ShiftFS.Utils.ReadAllText(result)); - foreach(CommandFormat part in parser.parts) { - addPart(part.Draw()); - } - })); - } - - private void btnApply_Click(object sender, EventArgs e) { - CurrentCommandParser.parser = parser; - } - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs deleted file mode 100644 index faaf0f5..0000000 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ /dev/null @@ -1,744 +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. - */ - - -/* - * 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 ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class Pong - { - /// - /// 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); - } - - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.gameTimer = new System.Windows.Forms.Timer(this.components); - this.counter = new System.Windows.Forms.Timer(this.components); - this.tmrcountdown = new System.Windows.Forms.Timer(this.components); - this.tmrstoryline = new System.Windows.Forms.Timer(this.components); - this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); - this.pnlgamestats = new System.Windows.Forms.Panel(); - this.button1 = new System.Windows.Forms.Button(); - this.label12 = new System.Windows.Forms.Label(); - this.lblnextstats = new System.Windows.Forms.Label(); - this.Label7 = new System.Windows.Forms.Label(); - this.lblpreviousstats = new System.Windows.Forms.Label(); - this.Label4 = new System.Windows.Forms.Label(); - this.btnplayon = new System.Windows.Forms.Button(); - this.Label3 = new System.Windows.Forms.Label(); - this.btncashout = new System.Windows.Forms.Button(); - this.Label2 = new System.Windows.Forms.Label(); - this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListBox(); - this.label10 = new System.Windows.Forms.Label(); - this.pnlfinalstats = new System.Windows.Forms.Panel(); - this.btnplayagain = new System.Windows.Forms.Button(); - this.lblfinalcodepoints = new System.Windows.Forms.Label(); - this.Label11 = new System.Windows.Forms.Label(); - this.lblfinalcomputerreward = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); - this.lblfinallevelreward = new System.Windows.Forms.Label(); - this.lblfinallevelreached = new System.Windows.Forms.Label(); - this.lblfinalcodepointswithtext = new System.Windows.Forms.Label(); - this.pnllose = new System.Windows.Forms.Panel(); - this.lblmissedout = new System.Windows.Forms.Label(); - this.lblbutyougained = new System.Windows.Forms.Label(); - this.btnlosetryagain = new System.Windows.Forms.Button(); - this.Label5 = new System.Windows.Forms.Label(); - this.Label1 = new System.Windows.Forms.Label(); - this.pnlintro = new System.Windows.Forms.Panel(); - this.Label6 = new System.Windows.Forms.Label(); - this.btnstartgame = new System.Windows.Forms.Button(); - this.Label8 = new System.Windows.Forms.Label(); - this.lblbeatai = new System.Windows.Forms.Label(); - this.lblcountdown = new System.Windows.Forms.Label(); - this.ball = new ShiftOS.WinForms.Controls.Canvas(); - this.paddleHuman = new System.Windows.Forms.PictureBox(); - this.paddleComputer = new System.Windows.Forms.Panel(); - this.lbllevelandtime = new System.Windows.Forms.Label(); - this.lblstatscodepoints = new System.Windows.Forms.Label(); - this.lblstatsY = new System.Windows.Forms.Label(); - this.lblstatsX = new System.Windows.Forms.Label(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); - this.pgcontents.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); - this.pnlhighscore.SuspendLayout(); - this.pnlfinalstats.SuspendLayout(); - this.pnllose.SuspendLayout(); - this.pnlintro.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.flowLayoutPanel1.SuspendLayout(); - this.SuspendLayout(); - // - // gameTimer - // - this.gameTimer.Interval = 30; - this.gameTimer.Tick += new System.EventHandler(this.gameTimer_Tick); - // - // counter - // - this.counter.Interval = 1000; - this.counter.Tick += new System.EventHandler(this.counter_Tick); - // - // tmrcountdown - // - this.tmrcountdown.Interval = 1000; - this.tmrcountdown.Tick += new System.EventHandler(this.countdown_Tick); - // - // tmrstoryline - // - this.tmrstoryline.Interval = 1000; - this.tmrstoryline.Tick += new System.EventHandler(this.tmrstoryline_Tick); - // - // pgcontents - // - this.pgcontents.BackColor = System.Drawing.Color.White; - this.pgcontents.Controls.Add(this.pnlhighscore); - this.pgcontents.Controls.Add(this.pnlgamestats); - this.pgcontents.Controls.Add(this.pnlfinalstats); - this.pgcontents.Controls.Add(this.pnllose); - this.pgcontents.Controls.Add(this.pnlintro); - this.pgcontents.Controls.Add(this.lblbeatai); - this.pgcontents.Controls.Add(this.lblcountdown); - this.pgcontents.Controls.Add(this.ball); - this.pgcontents.Controls.Add(this.paddleHuman); - this.pgcontents.Controls.Add(this.paddleComputer); - this.pgcontents.Controls.Add(this.lbllevelandtime); - this.pgcontents.Controls.Add(this.lblstatscodepoints); - this.pgcontents.Controls.Add(this.lblstatsY); - this.pgcontents.Controls.Add(this.lblstatsX); - this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.pgcontents.Location = new System.Drawing.Point(0, 0); - this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(700, 400); - this.pgcontents.TabIndex = 20; - this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); - this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - // - // pnlgamestats - // - this.pnlgamestats.Controls.Add(this.button1); - this.pnlgamestats.Controls.Add(this.label12); - this.pnlgamestats.Controls.Add(this.lblnextstats); - this.pnlgamestats.Controls.Add(this.Label7); - this.pnlgamestats.Controls.Add(this.lblpreviousstats); - this.pnlgamestats.Controls.Add(this.Label4); - this.pnlgamestats.Controls.Add(this.btnplayon); - this.pnlgamestats.Controls.Add(this.Label3); - this.pnlgamestats.Controls.Add(this.btncashout); - this.pnlgamestats.Controls.Add(this.Label2); - this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(56, 76); - this.pnlgamestats.Name = "pnlgamestats"; - this.pnlgamestats.Size = new System.Drawing.Size(466, 284); - this.pnlgamestats.TabIndex = 6; - this.pnlgamestats.Visible = false; - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(32, 223); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(191, 35); - this.button1.TabIndex = 10; - this.button1.Text = "{PONG_VIEW_HIGHSCORES}"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.btnhighscore_Click); - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(8, 187); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(245, 33); - this.label12.TabIndex = 9; - this.label12.Text = "{PONG_HIGHSCORE_EXP}"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblnextstats - // - this.lblnextstats.AutoSize = true; - this.lblnextstats.Location = new System.Drawing.Point(278, 136); - this.lblnextstats.Name = "lblnextstats"; - this.lblnextstats.Size = new System.Drawing.Size(0, 13); - this.lblnextstats.TabIndex = 8; - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label7.Location = new System.Drawing.Point(278, 119); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(124, 16); - this.Label7.TabIndex = 7; - this.Label7.Text = "Next Level Stats:"; - // - // lblpreviousstats - // - this.lblpreviousstats.AutoSize = true; - this.lblpreviousstats.Location = new System.Drawing.Point(278, 54); - this.lblpreviousstats.Name = "lblpreviousstats"; - this.lblpreviousstats.Size = new System.Drawing.Size(0, 13); - this.lblpreviousstats.TabIndex = 6; - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label4.Location = new System.Drawing.Point(278, 37); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(154, 16); - this.Label4.TabIndex = 5; - this.Label4.Text = "Previous Level Stats:"; - // - // btnplayon - // - this.btnplayon.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayon.Location = new System.Drawing.Point(32, 147); - this.btnplayon.Name = "btnplayon"; - this.btnplayon.Size = new System.Drawing.Size(191, 35); - this.btnplayon.TabIndex = 4; - this.btnplayon.Text = "Play on for 3 codepoints!"; - this.btnplayon.UseVisualStyleBackColor = true; - this.btnplayon.Click += new System.EventHandler(this.btnplayon_Click); - // - // Label3 - // - this.Label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label3.Location = new System.Drawing.Point(8, 111); - this.Label3.Name = "Label3"; - this.Label3.Size = new System.Drawing.Size(245, 33); - this.Label3.TabIndex = 3; - this.Label3.Text = "{PONG_PLAYON_DESC}"; - this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btncashout - // - this.btncashout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btncashout.Location = new System.Drawing.Point(32, 73); - this.btncashout.Name = "btncashout"; - this.btncashout.Size = new System.Drawing.Size(191, 35); - this.btncashout.TabIndex = 2; - this.btncashout.Text = "Cash out with 1 codepoint!"; - this.btncashout.UseVisualStyleBackColor = true; - this.btncashout.Click += new System.EventHandler(this.btncashout_Click); - // - // Label2 - // - this.Label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label2.Location = new System.Drawing.Point(8, 37); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(245, 33); - this.Label2.TabIndex = 1; - this.Label2.Text = "{PONG_CASHOUT_DESC}"; - this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbllevelreached - // - this.lbllevelreached.AutoSize = true; - this.lbllevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelreached.Location = new System.Drawing.Point(149, 6); - this.lbllevelreached.Name = "lbllevelreached"; - this.lbllevelreached.Size = new System.Drawing.Size(185, 20); - this.lbllevelreached.TabIndex = 0; - this.lbllevelreached.Text = "You Reached Level 2!"; - // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(67, 29); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.FormattingEnabled = true; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.MultiColumn = true; - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.SelectionMode = System.Windows.Forms.SelectionMode.None; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlfinalstats - // - this.pnlfinalstats.Controls.Add(this.btnplayagain); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepoints); - this.pnlfinalstats.Controls.Add(this.Label11); - this.pnlfinalstats.Controls.Add(this.lblfinalcomputerreward); - this.pnlfinalstats.Controls.Add(this.Label9); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreward); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreached); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepointswithtext); - this.pnlfinalstats.Location = new System.Drawing.Point(172, 74); - this.pnlfinalstats.Name = "pnlfinalstats"; - this.pnlfinalstats.Size = new System.Drawing.Size(362, 226); - this.pnlfinalstats.TabIndex = 9; - this.pnlfinalstats.Visible = false; - // - // btnplayagain - // - this.btnplayagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayagain.Location = new System.Drawing.Point(5, 194); - this.btnplayagain.Name = "btnplayagain"; - this.btnplayagain.Size = new System.Drawing.Size(352, 29); - this.btnplayagain.TabIndex = 16; - this.btnplayagain.Text = "{PLAY}"; - this.btnplayagain.UseVisualStyleBackColor = true; - this.btnplayagain.Click += new System.EventHandler(this.btnplayagain_Click); - // - // lblfinalcodepoints - // - this.lblfinalcodepoints.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepoints.Location = new System.Drawing.Point(3, 124); - this.lblfinalcodepoints.Name = "lblfinalcodepoints"; - this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); - this.lblfinalcodepoints.TabIndex = 15; - this.lblfinalcodepoints.Text = "134 CP"; - this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label11 - // - this.Label11.AutoSize = true; - this.Label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label11.Location = new System.Drawing.Point(162, 82); - this.Label11.Name = "Label11"; - this.Label11.Size = new System.Drawing.Size(33, 33); - this.Label11.TabIndex = 14; - this.Label11.Text = "+"; - this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcomputerreward - // - this.lblfinalcomputerreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcomputerreward.Location = new System.Drawing.Point(193, 72); - this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; - this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); - this.lblfinalcomputerreward.TabIndex = 12; - this.lblfinalcomputerreward.Text = "34"; - this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label9 - // - this.Label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label9.Location = new System.Drawing.Point(179, 31); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(180, 49); - this.Label9.TabIndex = 11; - this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreward - // - this.lblfinallevelreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreward.Location = new System.Drawing.Point(12, 72); - this.lblfinallevelreward.Name = "lblfinallevelreward"; - this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); - this.lblfinallevelreward.TabIndex = 10; - this.lblfinallevelreward.Text = "100"; - this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreached - // - this.lblfinallevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreached.Location = new System.Drawing.Point(3, 31); - this.lblfinallevelreached.Name = "lblfinallevelreached"; - this.lblfinallevelreached.Size = new System.Drawing.Size(170, 49); - this.lblfinallevelreached.TabIndex = 9; - this.lblfinallevelreached.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcodepointswithtext - // - this.lblfinalcodepointswithtext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepointswithtext.Location = new System.Drawing.Point(3, 2); - this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; - this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); - this.lblfinalcodepointswithtext.TabIndex = 1; - this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; - this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // pnllose - // - this.pnllose.Controls.Add(this.lblmissedout); - this.pnllose.Controls.Add(this.lblbutyougained); - this.pnllose.Controls.Add(this.btnlosetryagain); - this.pnllose.Controls.Add(this.Label5); - this.pnllose.Controls.Add(this.Label1); - this.pnllose.Location = new System.Drawing.Point(209, 71); - this.pnllose.Name = "pnllose"; - this.pnllose.Size = new System.Drawing.Size(266, 214); - this.pnllose.TabIndex = 10; - this.pnllose.Visible = false; - // - // lblmissedout - // - this.lblmissedout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblmissedout.Location = new System.Drawing.Point(3, 175); - this.lblmissedout.Name = "lblmissedout"; - this.lblmissedout.Size = new System.Drawing.Size(146, 35); - this.lblmissedout.TabIndex = 3; - this.lblmissedout.Text = "You Missed Out On: 500 Codepoints"; - this.lblmissedout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblbutyougained - // - this.lblbutyougained.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbutyougained.Location = new System.Drawing.Point(3, 125); - this.lblbutyougained.Name = "lblbutyougained"; - this.lblbutyougained.Size = new System.Drawing.Size(146, 35); - this.lblbutyougained.TabIndex = 3; - this.lblbutyougained.Text = "But you gained 5 Codepoints"; - this.lblbutyougained.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnlosetryagain - // - this.btnlosetryagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnlosetryagain.Location = new System.Drawing.Point(155, 176); - this.btnlosetryagain.Name = "btnlosetryagain"; - this.btnlosetryagain.Size = new System.Drawing.Size(106, 35); - this.btnlosetryagain.TabIndex = 2; - this.btnlosetryagain.Text = "Try Again"; - this.btnlosetryagain.UseVisualStyleBackColor = true; - this.btnlosetryagain.Click += new System.EventHandler(this.btnlosetryagain_Click); - // - // Label5 - // - this.Label5.Location = new System.Drawing.Point(7, 26); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(260, 163); - this.Label5.TabIndex = 1; - // - // Label1 - // - this.Label1.Dock = System.Windows.Forms.DockStyle.Top; - this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label1.Location = new System.Drawing.Point(0, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(266, 16); - this.Label1.TabIndex = 0; - this.Label1.Text = "You lose!"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlintro - // - this.pnlintro.Controls.Add(this.Label6); - this.pnlintro.Controls.Add(this.btnstartgame); - this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(52, 29); - this.pnlintro.Name = "pnlintro"; - this.pnlintro.Size = new System.Drawing.Size(595, 303); - this.pnlintro.TabIndex = 13; - // - // Label6 - // - this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label6.Location = new System.Drawing.Point(3, 39); - this.Label6.Name = "Label6"; - this.Label6.Size = new System.Drawing.Size(589, 227); - this.Label6.TabIndex = 15; - this.Label6.Text = "{PONG_DESC}"; - this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.Label6.Click += new System.EventHandler(this.Label6_Click); - // - // btnstartgame - // - this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnstartgame.Location = new System.Drawing.Point(186, 273); - this.btnstartgame.Name = "btnstartgame"; - this.btnstartgame.Size = new System.Drawing.Size(242, 28); - this.btnstartgame.TabIndex = 15; - this.btnstartgame.Text = "{PLAY}"; - this.btnstartgame.UseVisualStyleBackColor = true; - this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click); - // - // Label8 - // - this.Label8.AutoSize = true; - this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label8.ForeColor = System.Drawing.Color.Black; - this.Label8.Location = new System.Drawing.Point(250, 5); - this.Label8.Name = "Label8"; - this.Label8.Size = new System.Drawing.Size(280, 31); - this.Label8.TabIndex = 14; - this.Label8.Text = "{PONG_WELCOME}"; - this.Label8.Click += new System.EventHandler(this.Label8_Click); - // - // lblbeatai - // - this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbeatai.Location = new System.Drawing.Point(47, 41); - this.lblbeatai.Name = "lblbeatai"; - this.lblbeatai.Size = new System.Drawing.Size(600, 30); - this.lblbeatai.TabIndex = 8; - this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; - this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblbeatai.Visible = false; - // - // lblcountdown - // - this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblcountdown.Location = new System.Drawing.Point(182, 152); - this.lblcountdown.Name = "lblcountdown"; - this.lblcountdown.Size = new System.Drawing.Size(315, 49); - this.lblcountdown.TabIndex = 7; - this.lblcountdown.Text = "3"; - this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblcountdown.Visible = false; - // - // ball - // - this.ball.BackColor = System.Drawing.Color.Black; - this.ball.Location = new System.Drawing.Point(300, 152); - this.ball.Name = "ball"; - this.ball.Size = new System.Drawing.Size(20, 20); - this.ball.TabIndex = 2; - this.ball.MouseEnter += new System.EventHandler(this.ball_MouseEnter); - this.ball.MouseLeave += new System.EventHandler(this.ball_MouseLeave); - // - // paddleHuman - // - this.paddleHuman.BackColor = System.Drawing.Color.Black; - this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - this.paddleHuman.Name = "paddleHuman"; - this.paddleHuman.Size = new System.Drawing.Size(20, 100); - this.paddleHuman.TabIndex = 3; - this.paddleHuman.TabStop = false; - // - // paddleComputer - // - this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(666, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - this.paddleComputer.Name = "paddleComputer"; - this.paddleComputer.Size = new System.Drawing.Size(20, 100); - this.paddleComputer.TabIndex = 1; - // - // lbllevelandtime - // - this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; - this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); - this.lbllevelandtime.Name = "lbllevelandtime"; - this.lbllevelandtime.Size = new System.Drawing.Size(700, 22); - this.lbllevelandtime.TabIndex = 4; - this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; - this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatscodepoints - // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 356); - this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(219, 35); - this.lblstatscodepoints.TabIndex = 12; - this.lblstatscodepoints.Text = "Codepoints: "; - this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsY - // - this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsY.Location = new System.Drawing.Point(542, 356); - this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(144, 35); - this.lblstatsY.TabIndex = 11; - this.lblstatsY.Text = "Yspeed:"; - this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsX - // - this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsX.Location = new System.Drawing.Point(3, 356); - this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(144, 35); - this.lblstatsX.TabIndex = 5; - this.lblstatsX.Text = "Xspeed: "; - this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // Pong - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pgcontents); - this.DoubleBuffered = true; - this.Name = "Pong"; - this.Text = "{PONG_NAME}"; - this.Size = new System.Drawing.Size(820, 500); - this.Load += new System.EventHandler(this.Pong_Load); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - this.pgcontents.ResumeLayout(false); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); - this.pnlhighscore.ResumeLayout(false); - this.pnlhighscore.PerformLayout(); - this.pnlfinalstats.ResumeLayout(false); - this.pnlfinalstats.PerformLayout(); - this.pnllose.ResumeLayout(false); - this.pnlintro.ResumeLayout(false); - this.pnlintro.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); - this.ResumeLayout(false); - - } - internal System.Windows.Forms.Panel paddleComputer; - internal System.Windows.Forms.Timer gameTimer; - internal System.Windows.Forms.PictureBox paddleHuman; - internal System.Windows.Forms.Label lbllevelandtime; - internal System.Windows.Forms.Label lblstatsX; - internal System.Windows.Forms.Timer counter; - internal System.Windows.Forms.Panel pnlgamestats; - internal System.Windows.Forms.Label lblnextstats; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.Label lblpreviousstats; - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.Button btnplayon; - internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.Button btncashout; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label lbllevelreached; - internal System.Windows.Forms.Label lblcountdown; - internal System.Windows.Forms.Timer tmrcountdown; - internal System.Windows.Forms.Label lblbeatai; - internal System.Windows.Forms.Panel pnlfinalstats; - internal System.Windows.Forms.Button btnplayagain; - internal System.Windows.Forms.Label lblfinalcodepoints; - internal System.Windows.Forms.Label Label11; - internal System.Windows.Forms.Label lblfinalcomputerreward; - internal System.Windows.Forms.Label Label9; - internal System.Windows.Forms.Label lblfinallevelreward; - internal System.Windows.Forms.Label lblfinallevelreached; - internal System.Windows.Forms.Label lblfinalcodepointswithtext; - internal System.Windows.Forms.Panel pnllose; - internal System.Windows.Forms.Label lblmissedout; - internal System.Windows.Forms.Label lblbutyougained; - internal System.Windows.Forms.Button btnlosetryagain; - internal System.Windows.Forms.Label Label5; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Label lblstatscodepoints; - internal System.Windows.Forms.Label lblstatsY; - internal System.Windows.Forms.Panel pnlintro; - internal System.Windows.Forms.Label Label6; - internal System.Windows.Forms.Button btnstartgame; - internal System.Windows.Forms.Label Label8; - internal System.Windows.Forms.Timer tmrstoryline; - private System.Windows.Forms.Panel pnlhighscore; - private System.Windows.Forms.ListBox lbhighscore; - private System.Windows.Forms.Label label10; - internal Canvas pgcontents; - internal Canvas ball; - internal System.Windows.Forms.Button button1; - internal System.Windows.Forms.Label label12; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.Button button2; - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs deleted file mode 100644 index 157ce8c..0000000 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ /dev/null @@ -1,675 +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.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.Objects; - -namespace ShiftOS.WinForms.Applications -{ - [MultiplayerOnly] - [Launcher("Pong", true, "al_pong", "Games")] - [WinOpen("pong")] - [DefaultIcon("iconPong")] - public partial class Pong : UserControl, IShiftOSWindow - { - //I can assure you guaranteed that there is an acorn somewhere, in this place, and the sailors are looking for it - int xVel = 7; - int yVel = 8; - int computerspeed = 8; - int level = 1; - int secondsleft = 60; - int casualposition; - double xveldec = 3.0; - double yveldec = 3.0; - double incrementx = 0.4; - double incrementy = 0.2; - int levelxspeed = 3; - int levelyspeed = 3; - int beatairewardtotal; - int beataireward = 1; - int[] levelrewards = new int[50]; - int totalreward; - int countdown = 3; - - bool aiShouldIsbeEnabled = true; - - public Pong() - { - InitializeComponent(); - } - - private void Pong_Load(object sender, EventArgs e) - { - setuplevelrewards(); - } - - - - // Move the paddle according to the mouse position. - private void pongMain_MouseMove(object sender, MouseEventArgs e) - { - var loc = this.PointToClient(MousePosition); - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - } - - - // ERROR: Handles clauses are not supported in C# - private void gameTimer_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - ball.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleComputer.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - - //Check if paddle upgrade has been bought and change paddles accordingly - if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) - { - paddleHuman.Height = 150; - paddleComputer.Height = 150; - } - - //Set the computer player to move according to the ball's position. - if (aiShouldIsbeEnabled) - if (ball.Location.X > 500 - xVel * 10 && xVel > 0) - { - if (ball.Location.Y > paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - if (ball.Location.Y < paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - casualposition = rand.Next(-150, 201); - } - else - { - //used to be me.location.y - if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - //used to be me.location.y - if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - } - - //Set Xvel and Yvel speeds from decimal - if (xVel > 0) - xVel = (int)Math.Round(xveldec); - if (xVel < 0) - xVel = (int)-Math.Round(xveldec); - if (yVel > 0) - yVel = (int)Math.Round(yveldec); - if (yVel < 0) - yVel = (int)-Math.Round(yveldec); - - // Move the game ball. - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - - // Check for top wall. - if (ball.Location.Y < 0) - { - ball.Location = new Point(ball.Location.X, 0); - yVel = -yVel; - } - - // Check for bottom wall. - if (ball.Location.Y > pgcontents.Height - ball.Height) - { - ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height); - yVel = -yVel; - } - - // Check for player paddle. - if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) - { - ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width, ball.Location.Y); - //randomly increase x or y speed of ball - switch (rand.Next(1, 3)) - { - case 1: - xveldec = xveldec + incrementx; - break; - case 2: - if (yveldec > 0) - yveldec = yveldec + incrementy; - if (yveldec < 0) - yveldec = yveldec - incrementy; - break; - } - xVel = -xVel; - } - - // Check for computer paddle. - if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) - { - ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width + 1, ball.Location.Y); - xveldec = xveldec + incrementx; - xVel = -xVel; - } - - // Check for left wall. - if (ball.Location.X < -100) - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - pnllose.Show(); - gameTimer.Stop(); - counter.Stop(); - lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) - { - totalreward = levelrewards[level - 1] + beatairewardtotal; - double onePercent = (totalreward / 100); - lblbutyougained.Show(); - lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100)); - } - else - { - lblbutyougained.Hide(); - } - } - - // Check for right wall. - if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100) - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - beatairewardtotal = beatairewardtotal + beataireward; - lblbeatai.Show(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}"); - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - } - - //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy - lblstatsX.Text = Localization.Parse("{H_VEL}: ") + xveldec; - lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - - if (xVel > 20 || xVel < -20) - { - paddleHuman.Width = Math.Abs(xVel); - paddleComputer.Width = Math.Abs(xVel); - } - else - { - paddleHuman.Width = 20; - paddleComputer.Width = 20; - } - - computerspeed = Math.Abs(yVel); - - // pgcontents.Refresh() - // pgcontents.CreateGraphics.FillRectangle(Brushes.Black, ball.Location.X, ball.Location.Y, ball.Width, ball.Height) - - } - } - - // ERROR: Handles clauses are not supported in C# - private void counter_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - secondsleft = secondsleft - 1; - if (secondsleft == 1) - { - secondsleft = 60; - level = level + 1; - generatenextlevel(); - pnlgamestats.Show(); - pnlgamestats.BringToFront(); - pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2)); - - counter.Stop(); - gameTimer.Stop(); - SendHighscores(); - } - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - } - } - - public void SendHighscores() - { - var highscore = new PongHighscore - { - UserName = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}", - HighestLevel = level, - HighestCodepoints = totalreward - }; - ServerManager.SendMessage("pong_sethighscore", JsonConvert.SerializeObject(highscore)); - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayon_Click(object sender, EventArgs e) - { - xveldec = levelxspeed; - yveldec = levelyspeed; - - secondsleft = 60; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, paddleHuman.Location.Y + paddleHuman.Height / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - //Increase the ball speed stats for the next level - private void generatenextlevel() - { - lbllevelreached.Text = Localization.Parse("{YOU_REACHED_LEVEL} " + level + "!"); - - lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - switch (rand.Next(1, 3)) - { - case 1: - levelxspeed = levelxspeed + 1; - break; - case 2: - levelxspeed = levelxspeed + 2; - break; - } - - switch (rand.Next(1, 3)) - { - case 1: - levelyspeed = levelyspeed + 1; - break; - case 2: - levelyspeed = levelyspeed + 2; - break; - } - - switch (rand.Next(1, 6)) - { - case 1: - incrementx = incrementx + 0.1; - break; - case 2: - incrementx = incrementx + 0.2; - break; - case 3: - incrementy = incrementy + 0.1; - break; - case 4: - incrementy = incrementy + 0.2; - break; - case 5: - incrementy = incrementy + 0.3; - break; - } - - lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - if (level < 15) - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = level * 10; - } else - { - beataireward = level * 5; - } - } - else - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; - } else - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; - } - } - - totalreward = levelrewards[level - 1] + beatairewardtotal; - - btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); - btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); - } - - private void setuplevelrewards() - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - levelrewards[0] = 0; - levelrewards[1] = 40; - levelrewards[2] = 120; - levelrewards[3] = 280; - levelrewards[4] = 580; - levelrewards[5] = 800; - levelrewards[6] = 1200; - levelrewards[7] = 1800; - levelrewards[8] = 2400; - levelrewards[9] = 3200; - levelrewards[10] = 4000; - levelrewards[11] = 5000; - levelrewards[12] = 6000; - levelrewards[13] = 8000; - levelrewards[14] = 10000; - levelrewards[15] = 12000; - levelrewards[16] = 16000; - levelrewards[17] = 20000; - levelrewards[18] = 26000; - levelrewards[19] = 32000; - levelrewards[20] = 40000; - levelrewards[21] = 50000; - levelrewards[22] = 64000; - levelrewards[23] = 80000; - levelrewards[24] = 100000; - levelrewards[25] = 120000; - levelrewards[26] = 150000; - levelrewards[27] = 180000; - levelrewards[28] = 220000; - levelrewards[29] = 280000; - levelrewards[30] = 360000; - levelrewards[31] = 440000; - levelrewards[32] = 540000; - levelrewards[33] = 640000; - levelrewards[34] = 800000; - levelrewards[35] = 1000000; - levelrewards[36] = 1280000; - levelrewards[37] = 1600000; - levelrewards[38] = 2000000; - levelrewards[39] = 3000000; - levelrewards[40] = 4000000; - } else - { - levelrewards[0] = 0; - levelrewards[1] = 20; - levelrewards[2] = 60; - levelrewards[3] = 140; - levelrewards[4] = 290; - levelrewards[5] = 400; - levelrewards[6] = 600; - levelrewards[7] = 900; - levelrewards[8] = 1200; - levelrewards[9] = 1600; - levelrewards[10] = 2000; - levelrewards[11] = 2500; - levelrewards[12] = 3000; - levelrewards[13] = 4000; - levelrewards[14] = 5000; - levelrewards[15] = 6000; - levelrewards[16] = 8000; - levelrewards[17] = 10000; - levelrewards[18] = 13000; - levelrewards[19] = 16000; - levelrewards[20] = 20000; - levelrewards[21] = 25000; - levelrewards[22] = 32000; - levelrewards[23] = 40000; - levelrewards[24] = 50000; - levelrewards[25] = 60000; - levelrewards[26] = 75000; - levelrewards[27] = 90000; - levelrewards[28] = 110000; - levelrewards[29] = 140000; - levelrewards[30] = 180000; - levelrewards[31] = 220000; - levelrewards[32] = 270000; - levelrewards[33] = 320000; - levelrewards[34] = 400000; - levelrewards[35] = 500000; - levelrewards[36] = 640000; - levelrewards[37] = 800000; - levelrewards[38] = 1000000; - levelrewards[39] = 1500000; - levelrewards[40] = 2000000; - } - } - - // ERROR: Handles clauses are not supported in C# - private void countdown_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - switch (countdown) - { - case 0: - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - break; - case 1: - lblcountdown.Text = "1"; - countdown = countdown - 1; - break; - case 2: - lblcountdown.Text = "2"; - countdown = countdown - 1; - break; - case 3: - lblcountdown.Text = "3"; - countdown = countdown - 1; - lblcountdown.Show(); - break; - } - - } - } - - // ERROR: Handles clauses are not supported in C# - private void btncashout_Click(object sender, EventArgs e) - { - pnlgamestats.Hide(); - pnlfinalstats.Show(); - lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); - lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = levelrewards[level - 1].ToString(); - lblfinalcomputerreward.Text = beatairewardtotal.ToString(); - lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); - SaveSystem.TransferCodepointsFrom("pong", totalreward); - } - - private void newgame() - { - pnlfinalstats.Hide(); - pnllose.Hide(); - pnlintro.Hide(); - - level = 1; - totalreward = 0; - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = 10; - } else - { - beataireward = 5; - } - beatairewardtotal = 0; - secondsleft = 60; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: "); - //reset stats text - lblstatsX.Text = Localization.Parse("{H_VEL}: "); - lblstatsY.Text = Localization.Parse("{V_VEL}: "); - - levelxspeed = 3; - levelyspeed = 3; - - incrementx = 0.4; - incrementy = 0.2; - - xveldec = levelxspeed; - yveldec = levelyspeed; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, (paddleHuman.Location.Y + paddleHuman.Height) / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{{LEVEL}}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - public void btnhighscore_Click(object s, EventArgs a) - { - pnlhighscore.BringToFront(); - SetupHighScores(); - } - - public void SetupHighScores() - { - lbhighscore.Items.Clear(); - ServerManager.MessageReceived += (msg) => - { - if(msg.Name == "pong_highscores") - { - var hs = JsonConvert.DeserializeObject>(msg.Contents); - - var orderedhs = hs.OrderByDescending(i => i.HighestLevel); - - foreach(var score in orderedhs) - { - this.Invoke(new Action(() => - { - lbhighscore.Items.Add($"{score.UserName}\t\t\t{score.HighestLevel}\t\t{score.HighestCodepoints} CP"); - })); - } - } - }; - ServerManager.SendMessage("pong_gethighscores", null); - pnlhighscore.Show(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayagain_Click(object sender, EventArgs e) - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnlosetryagain_Click(object sender, EventArgs e) - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnstartgame_Click(object sender, EventArgs e) - { - newgame(); - } - - Random rand = new Random(); - // ERROR: Handles clauses are not supported in C# - private void tmrstoryline_Tick(object sender, EventArgs e) - { - // Random chance of showing getshiftnet storyline - int i = rand.Next(0, 100); - - if (i >= 25 && i <= 50) - { - tmrstoryline.Stop(); - } - - } - - // ERROR: Handles clauses are not supported in C# - private void me_closing(object sender, FormClosingEventArgs e) - { - tmrstoryline.Stop(); - } - - private void Label6_Click(object sender, EventArgs e) - { - - } - - private void Label8_Click(object sender, EventArgs e) - { - - } - - private void pgcontents_Paint(object sender, PaintEventArgs e) { - - } - - private void ball_MouseEnter(object sender, EventArgs e) { - aiShouldIsbeEnabled = false; - } - - private void ball_MouseLeave(object sender, EventArgs e) { - aiShouldIsbeEnabled = true; - } - - public void OnLoad() - { - pnlintro.BringToFront(); - pnlintro.Show(); - pnlhighscore.Hide(); - pnlgamestats.Hide(); - pnlfinalstats.Hide(); - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - private void button2_Click(object sender, EventArgs e) - { - pnlhighscore.Hide(); - } - } -} diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs deleted file mode 100644 index e0e76fa..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ /dev/null @@ -1,261 +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 ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class ShiftoriumFrontend - { - /// - /// 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.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.lbupgradedesc = new System.Windows.Forms.Label(); - this.pnlupgradeactions = new System.Windows.Forms.Panel(); - this.btnbuy = new System.Windows.Forms.Button(); - this.lbupgradetitle = new System.Windows.Forms.Label(); - this.pnllist = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.pgupgradeprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - this.lbupgrades = new System.Windows.Forms.ListBox(); - this.panel1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.pnlupgradeactions.SuspendLayout(); - this.pnllist.SuspendLayout(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.Controls.Add(this.panel2); - this.panel1.Controls.Add(this.pnllist); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(782, 427); - this.panel1.TabIndex = 0; - // - // panel2 - // - this.panel2.Controls.Add(this.lbupgradedesc); - this.panel2.Controls.Add(this.pnlupgradeactions); - this.panel2.Controls.Add(this.lbupgradetitle); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(406, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(376, 427); - this.panel2.TabIndex = 1; - // - // label2 - // - if (ShiftoriumFrontend.UpgradeInstalled("shiftorium_gui_codepoints_display")) - { - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(128, 357); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(135, 13); - this.label2.TabIndex = 3; - this.label2.Text = "You have: %cp Codepoints"; - this.label2.Click += new System.EventHandler(this.label2_Click); - } else - { - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(128, 357); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(1, 1); - this.label2.TabIndex = 3; - this.label2.Text = ""; - this.label2.Click += new System.EventHandler(this.label2_Click); - } - // - // lbupgradedesc - // - this.lbupgradedesc.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbupgradedesc.Location = new System.Drawing.Point(0, 42); - this.lbupgradedesc.Name = "lbupgradedesc"; - this.lbupgradedesc.Size = new System.Drawing.Size(376, 348); - this.lbupgradedesc.TabIndex = 2; - this.lbupgradedesc.Text = "{SHIFTORIUM_EXP}"; - this.lbupgradedesc.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradedesc.UseCompatibleTextRendering = true; - // - // pnlupgradeactions - // - this.pnlupgradeactions.Controls.Add(this.btnbuy); - this.pnlupgradeactions.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlupgradeactions.Location = new System.Drawing.Point(0, 390); - this.pnlupgradeactions.Name = "pnlupgradeactions"; - this.pnlupgradeactions.Size = new System.Drawing.Size(376, 37); - this.pnlupgradeactions.TabIndex = 1; - // - // btnbuy - // - this.btnbuy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnbuy.AutoSize = true; - this.btnbuy.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnbuy.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnbuy.Location = new System.Drawing.Point(327, 9); - this.btnbuy.Name = "btnbuy"; - this.btnbuy.Size = new System.Drawing.Size(37, 25); - this.btnbuy.TabIndex = 0; - this.btnbuy.Text = "Buy"; - this.btnbuy.UseVisualStyleBackColor = true; - this.btnbuy.Visible = false; - this.btnbuy.Click += new System.EventHandler(this.btnbuy_Click); - // - // lbupgradetitle - // - this.lbupgradetitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbupgradetitle.Location = new System.Drawing.Point(0, 0); - this.lbupgradetitle.Name = "lbupgradetitle"; - this.lbupgradetitle.Size = new System.Drawing.Size(376, 42); - this.lbupgradetitle.TabIndex = 0; - this.lbupgradetitle.Text = "{WELCOME_TO_SHIFTORIUM}"; - this.lbupgradetitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradetitle.UseCompatibleTextRendering = true; - // - // pnllist - // - this.pnllist.Controls.Add(this.label2); - this.pnllist.Controls.Add(this.label1); - this.pnllist.Controls.Add(this.pgupgradeprogress); - this.pnllist.Controls.Add(this.lbupgrades); - this.pnllist.Dock = System.Windows.Forms.DockStyle.Left; - this.pnllist.Location = new System.Drawing.Point(0, 0); - this.pnllist.Name = "pnllist"; - this.pnllist.Size = new System.Drawing.Size(406, 427); - this.pnllist.TabIndex = 0; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 399); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(137, 13); - this.label1.TabIndex = 2; - this.label1.Text = "{UPGRADE_PROGRESS}:"; - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 399); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(137, 13); - this.label3.TabIndex = 2; - int upgradepercent = (pgupgradeprogress.Value / 100) * 100; - this.label3.Text = upgradepercent.ToString(); - // - // pgupgradeprogress - // - this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgupgradeprogress.BlockSize = 5; - this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390); - this.pgupgradeprogress.Maximum = 100; - this.pgupgradeprogress.Name = "pgupgradeprogress"; - this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23); - this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgupgradeprogress.TabIndex = 1; - this.pgupgradeprogress.Value = 25; - // - // lbupgrades - // - this.lbupgrades.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.lbupgrades.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.lbupgrades.FormattingEnabled = true; - this.lbupgrades.Location = new System.Drawing.Point(3, 66); - this.lbupgrades.Name = "lbupgrades"; - this.lbupgrades.Size = new System.Drawing.Size(397, 277); - this.lbupgrades.TabIndex = 0; - this.lbupgrades.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbupgrades_DrawItem); - // - // ShiftoriumFrontend - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.Controls.Add(this.panel1); - this.ForeColor = System.Drawing.Color.LightGreen; - this.Name = "ShiftoriumFrontend"; - this.Text = "{SHIFTORIUM_NAME}"; - this.Size = new System.Drawing.Size(782, 427); - this.Load += new System.EventHandler(this.Shiftorium_Load); - this.panel1.ResumeLayout(false); - this.panel2.ResumeLayout(false); - this.pnlupgradeactions.ResumeLayout(false); - this.pnlupgradeactions.PerformLayout(); - this.pnllist.ResumeLayout(false); - this.pnllist.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Panel pnllist; - private System.Windows.Forms.ListBox lbupgrades; - private System.Windows.Forms.Label lbupgradedesc; - private System.Windows.Forms.Panel pnlupgradeactions; - private System.Windows.Forms.Label lbupgradetitle; - private System.Windows.Forms.Button btnbuy; - private ShiftedProgressBar pgupgradeprogress; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs deleted file mode 100644 index 0580b47..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ /dev/null @@ -1,196 +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.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.SkinEngine; -using backend = ShiftOS.Engine.Shiftorium; -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Shiftorium", true, "al_shiftorium", "Utilities")] - [RequiresUpgrade("shiftorium_gui")] - [MultiplayerOnly] - [WinOpen("shiftorium")] - [DefaultTitle("Shiftorium")] - [DefaultIcon("iconShiftorium")] - public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow - { - - public static System.Timers.Timer timer100; - - - public ShiftoriumFrontend() - { - - InitializeComponent(); - PopulateShiftorium(); - lbupgrades.SelectedIndexChanged += (o, a) => - { - try - { - lbupgrades.Refresh(); - SelectUpgrade(lbupgrades.SelectedItem.ToString()); - } - catch { } - }; - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - backend.Installed += () => - { - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - }; - - } - - public void SelectUpgrade(string name) - { - btnbuy.Show(); - var upg = upgrades[name]; - lbupgradetitle.Text = Localization.Parse(upg.Name); - lbupgradedesc.Text = Localization.Parse(upg.Description); - } - - Dictionary upgrades = new Dictionary(); - - public void PopulateShiftorium() - { - lbupgrades.Items.Clear(); - upgrades.Clear(); - Timer(); - label2.Text = "You have: " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints"; - - foreach (var upg in backend.GetAvailable()) - { - String name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; - upgrades.Add(name, upg); - lbupgrades.Items.Add(name); - } - } - - public static bool UpgradeInstalled(string upg) - { - return backend.UpgradeInstalled(upg); - } - - public static bool UpgradeAttributesUnlocked(FieldInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(MethodInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(Type finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(PropertyInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - private void lbupgrades_DrawItem(object sender, DrawItemEventArgs e) - { - var foreground = new SolidBrush(LoadedSkin.ControlTextColor); - var background = new SolidBrush(LoadedSkin.ControlColor); - - e.Graphics.FillRectangle(background, e.Bounds); - try - { - if (lbupgrades.GetSelected(e.Index) == true) - { - e.Graphics.FillRectangle(foreground, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, background, e.Bounds.Location); - } - else - { - e.Graphics.FillRectangle(background, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, foreground, e.Bounds.Location); - } - } - catch - { - } - } - - private void btnbuy_Click(object sender, EventArgs e) - { - backend.Silent = true; - backend.Buy(upgrades[lbupgrades.SelectedItem.ToString()].ID, upgrades[lbupgrades.SelectedItem.ToString()].Cost); - backend.Silent = false; - PopulateShiftorium(); - btnbuy.Hide(); - } - - private void Shiftorium_Load(object sender, EventArgs e) { - - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - - } - - private void label2_Click(object sender, EventArgs e) - { - - } - - void Timer() - { - timer100 = new System.Timers.Timer(); - timer100.Interval = 2000; - //timer100.Elapsed += ???; - timer100.AutoReset = true; - timer100.Enabled = true; - } - } -} diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs deleted file mode 100644 index 9e4c61c..0000000 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ /dev/null @@ -1,115 +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.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Controls -{ - public class TerminalBox : RichTextBox, ITerminalWidget - { - public void SelectBottom() - { - try - { - this.Select(this.Text.Length, 0); - this.ScrollToCaret(); - } - catch { } - } - - protected override void OnClick(EventArgs e) - { - base.OnClick(e); - this.Select(this.TextLength, 0); - } - - public void Write(string text) - { - this.HideSelection = true; - this.Select(this.TextLength, 0); - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); - this.AppendText(Localization.Parse(text)); - this.HideSelection = false; - } - - private Font ConstructFont() - { - FontStyle fs = FontStyle.Regular; - if (ConsoleEx.Bold) - fs = fs | FontStyle.Bold; - if (ConsoleEx.Italic) - fs = fs | FontStyle.Italic; - if (ConsoleEx.Underline) - fs = fs | FontStyle.Underline; - - return new Font(this.Font, fs); - } - - public void WriteLine(string text) - { - this.HideSelection = true; - this.Select(this.TextLength, 0); - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); - this.AppendText(Localization.Parse(text) + Environment.NewLine); - this.HideSelection = false; - } - - bool quickCopying = false; - - protected override void OnMouseDown(MouseEventArgs e) - { - //if right-clicking, then we initiate a quick-copy. - if (e.Button == MouseButtons.Right) - quickCopying = true; - - //Override the mouse event so that it's a left-click at all times. - base.OnMouseDown(new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta)); - } - - protected override void OnMouseUp(MouseEventArgs mevent) - { - if(quickCopying == true) - { - if (!string.IsNullOrWhiteSpace(this.SelectedText)) - { - this.Copy(); - } - } - base.OnMouseUp(mevent); - } - } -} diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs deleted file mode 100644 index 7370396..0000000 --- a/ShiftOS.WinForms/Oobe.cs +++ /dev/null @@ -1,540 +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; -using ShiftOS.Objects; -using ShiftOS.Objects.ShiftFS; - -namespace ShiftOS.WinForms -{ - public partial class Oobe : Form, IOobe, ITutorial - { - public Oobe() - { - InitializeComponent(); - this.FormBorderStyle = FormBorderStyle.None; - this.WindowState = FormWindowState.Maximized; - this.BackColor = Color.Black; - - } - - - string rtext; - string gtexttotype; - int charcount; - int slashcount; - Label textgeninput; - public bool upgraded = false; - - private bool typing = false; - - public void TextType(string texttotype) - { - while(typing == true) - { - - } - - charcount = texttotype.Length; - gtexttotype = texttotype; - slashcount = 1; - foreach (var c in gtexttotype) - { - typing = true; - rtext += c; - - this.Invoke(new Action(() => - { - textgeninput.Text = rtext + "|"; - })); - slashcount++; - if (slashcount == 5) - slashcount = 1; - Thread.Sleep(50); - } - rtext += Environment.NewLine; - typing = false; - } - - public Save MySave = null; - - public event EventHandler OnComplete; - - private int tutPrg = 0; - - public int TutorialProgress - { - get - { - return tutPrg; - } - - set - { - tutPrg = value; - } - } - - public void StartShowing(Save save) - { - var t = new Thread(new ThreadStart(() => - { - try - { - textgeninput = this.lblHijack; - TextType("Your system is now being hijacked."); - rtext = ""; - Thread.Sleep(1000); - textgeninput = this.lblhackwords; - this.Invoke(new Action(() => - { - lblHijack.Hide(); - })); - TextType("Hello, and welcome to ShiftOS."); - Thread.Sleep(500); - TextType("You have been cordially and involuntarily selected to participate in the development and testing of this operating system."); - Thread.Sleep(500); - TextType("My identity shall remain secret, but if you've been through this before, you'll know exactly who I am."); - Thread.Sleep(500); - TextType("But that doesn't matter."); - Thread.Sleep(500); - TextType("I will now begin to prepare your system for the installation of ShiftOS."); - Thread.Sleep(1000); - FakeSetupScreen fakeForm = null; - this.Invoke(new Action(() => - { - fakeForm = new FakeSetupScreen(this); - fakeForm.Show(); - MySave = save; - lblhackwords.GotFocus += (o, a) => - { - try - { - fakeForm.Invoke(new Action(() => - { - fakeForm.Focus(); - fakeForm.BringToFront(); - })); - } - catch { } - }; - fakeForm.TextSent += (txt) => - { - TextType(txt); - }; - })); - while (fakeForm?.Visible == true) - { - Thread.Sleep(10); - } - if (fakeForm.CreateNewSave == true) - { - TextType("That's all the information I need for now."); - Thread.Sleep(2000); - TextType("Beginning installation of ShiftOS on " + MySave.SystemName + "."); - Thread.Sleep(500); - TextType("Creating new user: " + MySave.Username); - TextType("...with 0 Codepoints, 0 installed upgrades, no legion, and no user shops..."); - MySave.Codepoints = 0; - MySave.CurrentLegions = new List(); - MySave.MyShop = ""; - TextType("User created successfully."); - Thread.Sleep(450); - TextType("You may be wondering what all that meant... You see, in ShiftOS, your user account holds everything I need to know about you."); - Thread.Sleep(640); - TextType("It holds the amount of Codepoints you have - Codepoints are a special currency you can get by doing various tasks in ShiftOS."); - Thread.Sleep(500); - TextType("It also holds all the upgrades you've installed onto ShiftOS - features, applications, enhancements, patches, all that stuff."); - Thread.Sleep(500); - TextType("As for the legions and the shop thing, I'll reveal that to you when it becomes necessary."); - Thread.Sleep(500); - TextType("Your user account is stored on a server of mine called the multi-user domain. It holds every single user account, every script, every application, every thing within ShiftOS."); - Thread.Sleep(600); - TextType("Every time you boot ShiftOS, if you are connected to the Internet, you will immediately connect to the multi-user domain and ShiftOS will attempt to authenticate using the last "); - TextType("successful username and password pair."); - Thread.Sleep(500); - TextType("When you are in the MUD, you are in the middle of a free-for-all. I don't want it to be this way, it just is. I've employed you to help me develop and test the MUD and ShiftOS, "); - TextType("but you have a secondary task if you choose to accept it."); - Thread.Sleep(500); - TextType("There have been a few rebelious groups in the MUD - who have cracked ShiftOS's security barriers - and they're using these exploits to steal others' Codepoints, upgrades, "); - TextType("and even spread damaging viruses."); - Thread.Sleep(500); - TextType("I want you to stop them."); - Thread.Sleep(500); - TextType("Whoever can stop these hackers will gain eternal control over the multi-user domain. They will be given the ability to do as they please, so long as it doesn't interfere with my experiments."); - Thread.Sleep(500); - TextType("I have been installing ShiftOS on your system in the background as I was talking with you. Before I can set you free, I need to give you a tutorial on how to use the system."); - Thread.Sleep(500); - TextType("I will reboot your system in Tutorial Mode now. Complete the tutorial, and you shall be on your way."); - - Thread.Sleep(3000); - SaveSystem.CurrentSave = MySave; - SaveSystem.CurrentSave.StoryPosition = 1; - Utils.WriteAllText(Paths.GetPath("user.dat"), JsonConvert.SerializeObject(new - { - username = MySave.Username, - password = MySave.Password - })); - Shiftorium.Silent = true; - SaveSystem.SaveGame(); //Yknow, just incase it crashes. - } - else - { - TextType("Your login attempt was successful, " + SaveSystem.CurrentSave.Username + "."); - Thread.Sleep(500); - TextType($"According to my data on you, you have earned {SaveSystem.CurrentSave.Codepoints} Codepoints so far."); - Thread.Sleep(500); - TextType($"You have also acquired {SaveSystem.CurrentSave.CountUpgrades()} Shiftorium upgrades out of the {SaveSystem.CurrentSave.Upgrades.Count} available."); - Thread.Sleep(500); - TextType("I will now let you proceed to your system."); - Thread.Sleep(1000); - } - this.Invoke(new Action(this.Close)); - } - catch (Exception e) - { - TextType("I have experienced an error."); - TextType(e.ToString()); - } - })); - this.Show(); - this.BringToFront(); - this.TopMost = true; - t.IsBackground = true; - t.Start(); - } - - public void Clear() - { - this.Invoke(new Action(() => - { - rtext = ""; - textgeninput.Text = ""; - })); - } - - 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(); - } - - public void PromptForLogin() - { - this.Show(); - this.TopMost = true; - lblHijack.Text = ""; - textgeninput = lblhackwords; - - var fsw = new FakeSetupScreen(this, 10); - fsw.Show(); - fsw.TopMost = true; - fsw.DoneLoggingIn += () => - { - this.Close(); - }; - } - - public void StartTrailer() - { - while(AppearanceManager.OpenForms.Count > 0) - { - AppearanceManager.OpenForms[0].Close(); - } - - this.Show(); - this.TopMost = true; - this.TransparencyKey = Color.Magenta; - this.BackColor = this.TransparencyKey; - textgeninput = lblHijack; - textgeninput.BackColor = Color.Black; - textgeninput.Font = new Font("Lucida Console", 13F, FontStyle.Bold); - textgeninput.AutoSize = true; - textgeninput.TextAlign = ContentAlignment.MiddleCenter; - textgeninput.TextChanged += (o, a) => - { - textgeninput.Location = new Point( - (this.Width - textgeninput.Width) / 2, - (this.Height - textgeninput.Height) / 2 - ); - }; - var t = new Thread(() => - { - Clear(); - Thread.Sleep(5000); - TextType("Michael VanOverbeek"); - TextType("presents..."); - Thread.Sleep(2000); - Clear(); - Thread.Sleep(1000); - TextType("A community-developed game"); - Thread.Sleep(3000); - Clear(); - Thread.Sleep(1000); - this.Invoke(new Action(() => - { - textgeninput.Font = new Font("Lucida Console", 14F, FontStyle.Bold); - this.BackColor = Color.Black; - })); - TextType("Welcome to ShiftOS."); - Thread.Sleep(4000); - Clear(); - textgeninput = lblhackwords; - TextType("Hello."); - Thread.Sleep(500); - TextType("You have been cordially and involuntarily selected to participate in the development and testing of an experimental operating system called ShiftOS."); - Thread.Sleep(500); - TextType("I want ShiftOS to be the most advanced operating system in the world."); - Thread.Sleep(500); - TextType("In ShiftOS, you start out with nothing."); - Thread.Sleep(500); - TextType("And your goal is to upgrade the operating system from a barebones command line to a fully graphical operating system."); - Thread.Sleep(500); - TextType("Along the way, you'll meet many people - hackers, rebels, programmers, administrators and many more."); - Thread.Sleep(500); - TextType("You'll meet new friends and foes."); - Thread.Sleep(500); - TextType("Your goal: Take it over. Upgrade the operating system, and take over its multi-user domain."); - Thread.Sleep(500); - TextType("I won't reveal quite what you have to do, but if you can handle it, head over to http://getshiftos.ml/ and download the operating system now."); - Thread.Sleep(5000); - Clear(); - textgeninput = lblHijack; - TextType("Think you can handle it?"); - }); - t.IsBackground = false; - t.Start(); - } - - public void Start() - { - Shiftorium.Silent = false; - foreach(var frm in AppearanceManager.OpenForms) - { - (frm as Form).Invoke(new Action(() => { - frm.Close(); - })); - } - - TerminalBackend.CommandProcessed += (cmd, args) => - { - if(cmd == "sos.help") - { - if (TutorialProgress == 0) - TutorialProgress = 1; - } - else if(cmd == "sos.status") - { - if (TutorialProgress == 1) - TutorialProgress = 2; - - } - else if(cmd == "shiftorium.list") - { - if (TutorialProgress == 2) - { - TutorialProgress = 3; - SaveSystem.TransferCodepointsFrom("sys", 50); - } - } - else if(cmd == "shiftorium.info" && args == "{\"upgrade\":\"mud_fundamentals\"}") - { - if (TutorialProgress == 3) - TutorialProgress = 4; - } - else if(cmd == "win.open") - { - if (TutorialProgress == 4) - TutorialProgress = 5; - } - }; - if(this.Visible == false) - this.Show(); - var t = new Thread(() => - { - textgeninput = lblHijack; - Clear(); - textgeninput = lblhackwords; - Clear(); - - this.Invoke(new Action(() => - { - textgeninput.Font = SkinEngine.LoadedSkin.TerminalFont; - })); - TextType("ShiftOS has been installed successfully."); - Thread.Sleep(500); - TextType("Before you can continue to the operating system, here's a little tutorial on how to use it."); - Thread.Sleep(500); - TextType("Starting a Terminal..."); - Applications.Terminal term = null; - this.Invoke(new Action(() => - { - term = new Applications.Terminal(); - this.Controls.Add(term); - term.Location = new Point( - (this.Width - term.Width) / 2, - (this.Height - term.Height) / 2 - ); - term.Show(); - term.OnLoad(); - term.OnSkinLoad(); - term.OnUpgrade(); - })); - TextType("This little text box is called a Terminal."); - Thread.Sleep(500); - TextType("Normally, it would appear in full-screen, but this window is hosting it as a control so you can see this text as well."); - Thread.Sleep(500); - TextType("In ShiftOS, the Terminal is your main control centre for the operating system. You can see system status, check Codepoints, open other programs, buy upgrades, and more."); - Thread.Sleep(500); - TextType("Go ahead and type 'sos.help' to see a list of commands."); - while(TutorialProgress == 0) - { - - } - TextType("As you can see, sos.help gives you a list of all commands in the system."); - Thread.Sleep(500); - TextType("You can run any command, by typing in their Namespace, followed by a period (.), followed by their Command Name."); - Thread.Sleep(500); - TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does."); - while(TutorialProgress == 1) - { - - } - TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available."); - Thread.Sleep(500); - TextType("Codepoints, as you know, are a special currency within ShiftOS. They are used to buy things within the multi-user domain, such as upgrades, scripts, and applications."); - Thread.Sleep(500); - TextType("You can earn Codepoints by doing things in ShiftOS - such as completing jobs for other users, making things like skins, scripts, documents, etc, and playing games like Pong."); - Thread.Sleep(500); - TextType("At times, you'll be given Codepoints to help complete a task. You will receive Codepoints from 'sys' - the multi-user domain itself."); - //SaveSystem.TransferCodepointsFrom("sys", 50); - TextType("Right now, you don't have any upgrades. Upgrades can give ShiftOS additional features and capabilities - like new core applications, supported file types, and new Terminal commands."); - Thread.Sleep(500); - TextType("You can easily get upgrades using the Shiftorium - a repository of approved ShiftOS upgrades."); - Thread.Sleep(500); - TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades."); - while(TutorialProgress == 2) - { - - } - Clear(); - TextType("Right now, you have enough Codepoints to buy the 'mud_fundamentals' upgrade. You can use shiftorium.info to see information about this upgrade."); - Thread.Sleep(500); - TextType("Some commands, like shiftorium.info, require you to pass information to them in the form of arguments."); - Thread.Sleep(500); - TextType("Argument pairs sit at the end of the command, and are enclosed in curly braces."); - Thread.Sleep(500); - TextType("Inside these curly braces, you can input an argument key, followed by a colon, followed by the value. Then, if you need multiple arguments, you can put a comma after the value, and then insert another argument pair."); - Thread.Sleep(500); - TextType("There are different value types - numeric values, which can be any positive or negative 32-bit integer"); - Thread.Sleep(500); - TextType("Then there are boolean values which can be either 'true' or 'false'"); - Thread.Sleep(500); - TextType("Then there are string values, which are enclosed in double-quotes."); - Thread.Sleep(500); - TextType(" If for some reason you need to use a double-quote inside a string, you must escape it using a single backslash followed by the quote, like this: key:\"My \\\"awesome\\\" value.\""); - Thread.Sleep(500); - TextType("If you want to escape a backslash inside a string, simply type two backslashes instead of one - for example key:\"Back\\\\slash.\""); - Thread.Sleep(500); - TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID."); - while(TutorialProgress == 3) - { - - } - TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!"); - Thread.Sleep(500); - TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!"); - while (!Shiftorium.UpgradeInstalled("mud_fundamentals")) - { - - } - TextType("Hooray! You now have the MUD Fundamentals upgrade."); - Thread.Sleep(500); - TextType("You can also earn more Codepoints by playing Pong. To open Pong, you can use the win.open command."); - Thread.Sleep(500); - TextType("If you run win.open without arguments, you can see a list of applications that you can open."); - Thread.Sleep(500); - TextType("Just run win.open without arguments, and this tutorial will be completed!"); - while(TutorialProgress == 4) - { - - } - TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world."); - Thread.Sleep(2000); - this.Invoke(new Action(() => - { - OnComplete?.Invoke(this, EventArgs.Empty); - this.Close(); - SaveSystem.CurrentSave.StoryPosition = 2; - SaveSystem.SaveGame(); - AppearanceManager.SetupWindow(new Applications.Terminal()); - })); - }); - t.IsBackground = true; - t.Start(); - } - } -} diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs deleted file mode 100644 index 52663d7..0000000 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ /dev/null @@ -1,325 +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.Drawing; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.AppearanceManager; - - -namespace ShiftOS.WinForms.Tools -{ - public static class ControlManager - { - [DllImport("user32.dll")] - public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam); - - private const int WM_SETREDRAW = 11; - - public static void SuspendDrawing(Control parent) - { - SendMessage(parent.Handle, WM_SETREDRAW, false, 0); - } - - public static void ResumeDrawing(Control parent) - { - SendMessage(parent.Handle, WM_SETREDRAW, true, 0); - parent.Refresh(); - } - - public static void Close(this UserControl ctrl) - { - for (int i = 0; i < AppearanceManager.OpenForms.Count; i++) - { - if (OpenForms[i].ParentWindow == ctrl) - { - (OpenForms[i] as Form).Close(); - return; - } - } - } - - - public static void SetupWindows() - { - if (SaveSystem.CurrentSave != null) - { - int screen_height_start = 0; - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - } - else if (Shiftorium.UpgradeInstalled("wm_4_windows")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height_half = (Screen.PrimaryScreen.Bounds.Height - screen_height_start) / 2; - - for (int i = 0; i < OpenForms.Count; i++) - { - var frm = OpenForms[i] as WindowBorder; - - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - case 2: - frm.Location = new System.Drawing.Point(0, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 3) ? screen_width_half : screen_width_half * 2, screen_height_half); - break; - case 3: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_half + screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, (OpenForms.Count > 2) ? screen_height_half : screen_height_half * 2); - break; - } - } - - } - else if (Shiftorium.UpgradeInstalled("window_manager")) - { - int screen_width_half = Screen.PrimaryScreen.Bounds.Width / 2; - int screen_height = (Screen.PrimaryScreen.Bounds.Height) - screen_height_start; - - - - for (int i = 0; i < OpenForms.Count; i++) - { - - - var frm = OpenForms[i] as WindowBorder; - switch (i) - { - case 0: - frm.Location = new System.Drawing.Point(0, screen_height_start); - frm.Size = new System.Drawing.Size((OpenForms.Count > 1) ? screen_width_half : screen_width_half * 2, screen_height); - break; - case 1: - frm.Location = new System.Drawing.Point(screen_width_half, screen_height_start); - frm.Size = new System.Drawing.Size(screen_width_half, screen_height); - break; - } - OpenForms[i] = frm; - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - else - { - var frm = OpenForms[0] as WindowBorder; - frm.Location = new Point(0, 0); - frm.Size = Desktop.Size; - OpenForms[0] = frm; - - } - } - - internal static Color ConvertColor(ConsoleColor cCol) - { - switch (cCol) - { - case ConsoleColor.Black: - return Color.Black; - case ConsoleColor.Gray: - return Color.Gray; - case ConsoleColor.DarkGray: - return Color.DarkGray; - case ConsoleColor.Blue: - return Color.Blue; - case ConsoleColor.Cyan: - return Color.Cyan; - case ConsoleColor.DarkBlue: - return Color.DarkBlue; - case ConsoleColor.DarkCyan: - return Color.DarkCyan; - case ConsoleColor.DarkGreen: - return Color.DarkGreen; - case ConsoleColor.DarkMagenta: - return Color.DarkMagenta; - case ConsoleColor.DarkRed: - return Color.DarkRed; - case ConsoleColor.DarkYellow: - return Color.YellowGreen; - case ConsoleColor.Yellow: - return Color.Yellow; - case ConsoleColor.Green: - return Color.Green; - case ConsoleColor.Magenta: - return Color.Magenta; - case ConsoleColor.Red: - return Color.Red; - case ConsoleColor.White: - return Color.White; - default: - return Color.Black; - } - - } - - public static void SetCursor(Control ctrl) - { -#if STUPID - if (!(ctrl is WebBrowser)) - { - var mouse = SkinEngine.GetImage("mouse"); - if (mouse == null) - mouse = Properties.Resources.DefaultMouse; - - var mBmp = new Bitmap(mouse); - mBmp.MakeTransparent(Color.FromArgb(1, 0, 1)); - var gfx = Graphics.FromImage(mBmp); - var handle = mBmp.GetHicon(); - - var cursor = new Cursor(handle); - ctrl.Cursor = cursor; - } -#endif - } - - public static void SetupControl(Control ctrl) - { - SuspendDrawing(ctrl); - SetCursor(ctrl); - if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) - { - string tag = ""; - - try - { - tag = ctrl.Tag.ToString(); - } - catch { } - - if (!tag.Contains("keepbg")) - { - if (ctrl.BackColor != Control.DefaultBackColor) - { - ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; - } - } - - ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; - - ctrl.Font = SkinEngine.LoadedSkin.MainFont; - - if (tag.Contains("header1")) - { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - } - - if (tag.Contains("header2")) - { - ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - } - - if (tag.Contains("header3")) - { - ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - } - - try - { - ctrl.Text = Localization.Parse(ctrl.Text); - } - catch - { - - } - ctrl.KeyDown += (o, a) => - { - if (a.Control && a.KeyCode == Keys.T) - { - a.SuppressKeyPress = true; - - - if (SaveSystem.CurrentSave != null) - { - if (Shiftorium.UpgradeInstalled("window_manager")) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - } - } - - ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); - //a.Handled = true; - }; - if (ctrl is Button) - { - (ctrl as Button).FlatStyle = FlatStyle.Flat; - } - else if (ctrl is WindowBorder) - { - (ctrl as WindowBorder).Setup(); - } - } - - MakeDoubleBuffered(ctrl); - ResumeDrawing(ctrl); - } - - public static void MakeDoubleBuffered(Control c) - { - if (System.Windows.Forms.SystemInformation.TerminalServerSession) - return; - - System.Reflection.PropertyInfo aProp = - typeof(System.Windows.Forms.Control).GetProperty( - "DoubleBuffered", - System.Reflection.BindingFlags.NonPublic | - System.Reflection.BindingFlags.Instance); - - aProp.SetValue(c, true, null); - - } - - public static void SetupControls(Control frm) - { - SetupControl(frm); - - for (int i = 0; i < frm.Controls.Count; i++) - { - SetupControls(frm.Controls[i]); - } - } - - } -} diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs deleted file mode 100644 index 0308f8a..0000000 --- a/ShiftOS.WinForms/WindowBorder.cs +++ /dev/null @@ -1,490 +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.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -using static ShiftOS.Engine.SkinEngine; -using System.Runtime.InteropServices; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; -using ShiftOS.WinForms.Applications; - -/// -/// Window border. -/// -namespace ShiftOS.WinForms -{ - /// - /// Window border. - /// - public partial class WindowBorder : Form, IWindowBorder - { - /// - /// Raises the closing event. - /// - /// E. - protected override void OnClosing(CancelEventArgs e) - { - if ((ParentWindow as IShiftOSWindow).OnUnload()) - { - if (!SaveSystem.ShuttingDown) - { - if(Engine.AppearanceManager.OpenForms.Contains(this)) - Engine.AppearanceManager.OpenForms.Remove(this); - Desktop.ResetPanelButtons(); - } - } - base.OnClosing(e); - } - - /// - /// The parent window. - /// - private UserControl _parentWindow = null; - - /// - /// Gets or sets the parent window. - /// - /// The parent window. - public IShiftOSWindow ParentWindow - { - get - { - return (IShiftOSWindow)_parentWindow; - } - set - { - _parentWindow = (UserControl)value; - } - } - - internal void SetTitle(string title) - { - lbtitletext.Text = title; - } - - /// - /// Initializes a new instance of the class. - /// - /// Window. - public WindowBorder(UserControl win) - { - InitializeComponent(); - this._parentWindow = win; - Shiftorium.Installed += () => - { - try - { - this.ParentForm.Invoke(new Action(() => - { - Setup(); - })); - } - catch { } - }; - SkinEngine.SkinLoaded += () => - { - try - { - Setup(); - (ParentWindow as IShiftOSWindow).OnSkinLoad(); - ControlManager.SetupControls(this.pnlcontents); - } - catch - { - - } - }; - - this.Width = LoadedSkin.LeftBorderWidth + _parentWindow.Width + LoadedSkin.RightBorderWidth; - this.Height = LoadedSkin.TitlebarHeight + _parentWindow.Height + LoadedSkin.BottomBorderWidth; - - this.pnlcontents.Controls.Add(this._parentWindow); - this._parentWindow.Dock = DockStyle.Fill; - this._parentWindow.Show(); - ControlManager.SetupControls(this._parentWindow); - - - Desktop.ShowWindow(this); - - } - - /// - /// Universals the key down. - /// - /// The key down. - /// O. - /// The alpha component. - public static void Universal_KeyDown(object o, KeyEventArgs a) - { - if (a.Control && a.KeyCode == Keys.T) - { - a.SuppressKeyPress = true; - - - if (SaveSystem.CurrentSave != null) - { - if (Shiftorium.UpgradeInstalled("window_manager")) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - } - } - - ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); - } - - /// - /// Windows the border load. - /// - /// The border load. - /// Sender. - /// E. - public void WindowBorder_Load(object sender, EventArgs e) - { - this.DoubleBuffered = true; - - this._parentWindow.TextChanged += (o, a) => - { - Setup(); - Desktop.ResetPanelButtons(); - - }; - - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - if (!this.IsDialog) - { - Engine.AppearanceManager.OpenForms.Add(this); - } - - SaveSystem.GameReady += () => - { - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - AppearanceManager.Invoke(new Action(() => - { - this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2; - this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2; - - })); - } - AppearanceManager.Invoke(new Action(() => - { - Setup(); - })); - }; - - ControlManager.SetupControls(this); - - Setup(); - - var sWin = (IShiftOSWindow)ParentWindow; - - sWin.OnLoad(); - } - - /// - /// Setup this instance. - /// - public void Setup() - { - this.lbtitletext.Text = NameChangerBackend.GetName(ParentWindow); - - if (SaveSystem.CurrentSave != null) - { - this.pnltitle.Visible = Shiftorium.UpgradeInstalled("wm_titlebar"); - this.pnlclose.Visible = Shiftorium.UpgradeInstalled("close_button"); - this.pnlminimize.Visible = (IsDialog == false) && Shiftorium.UpgradeInstalled("minimize_button"); - this.pnlmaximize.Visible = (IsDialog == false) && Shiftorium.UpgradeInstalled("maximize_button"); - SetupSkin(); - } - else - { - this.pnltitle.Visible = false; - this.pnlclose.Visible = false; - this.pnlminimize.Visible = false; - this.pnlmaximize.Visible = false; - - } - } - - /// - /// Setups the skin. - /// - /// The skin. - public void SetupSkin() - { - this.DoubleBuffered = true; - this.TransparencyKey = LoadedSkin.SystemKey; - pnltitle.Height = LoadedSkin.TitlebarHeight; - pnltitle.BackColor = LoadedSkin.TitleBackgroundColor; - pnltitle.BackgroundImage = GetImage("titlebar"); - pnltitleleft.Visible = LoadedSkin.ShowTitleCorners; - pnltitleright.Visible = LoadedSkin.ShowTitleCorners; - pnltitleleft.BackColor = LoadedSkin.TitleLeftCornerBackground; - pnltitleright.BackColor = LoadedSkin.TitleRightCornerBackground; - pnltitleleft.Width = LoadedSkin.TitleLeftCornerWidth; - pnltitleright.Width = LoadedSkin.TitleRightCornerWidth; - pnltitleleft.BackgroundImage = GetImage("titleleft"); - pnltitleleft.BackgroundImageLayout = GetImageLayout("titleleft"); - pnltitleright.BackgroundImage = GetImage("titleright"); - pnltitleright.BackgroundImageLayout = GetImageLayout("titleright"); - pnltitle.BackgroundImageLayout = GetImageLayout("titlebar"); //RETARD ALERT. WHY WASN'T THIS THERE WHEN IMAGELAYOUTS WERE FIRST IMPLEMENTED? - - lbtitletext.BackColor = (pnltitle.BackgroundImage != null) ? Color.Transparent : LoadedSkin.TitleBackgroundColor; - lbtitletext.ForeColor = LoadedSkin.TitleTextColor; - lbtitletext.Font = LoadedSkin.TitleFont; - - pnlleft.BackColor = LoadedSkin.BorderLeftBackground; - pnlleft.BackgroundImage = GetImage("leftborder"); - pnlleft.BackgroundImageLayout = GetImageLayout("leftborder"); - pnlleft.Width = LoadedSkin.LeftBorderWidth; - pnlright.BackColor = LoadedSkin.BorderRightBackground; - pnlright.BackgroundImage = GetImage("rightborder"); - pnlright.BackgroundImageLayout = GetImageLayout("rightborder"); - pnlright.Width = LoadedSkin.RightBorderWidth; - - pnlbottom.BackColor = LoadedSkin.BorderBottomBackground; - pnlbottom.BackgroundImage = GetImage("bottomborder"); - pnlbottom.BackgroundImageLayout = GetImageLayout("bottomborder"); - pnlbottom.Height = LoadedSkin.BottomBorderWidth; - - pnlbottomr.BackColor = LoadedSkin.BorderBottomRightBackground; - pnlbottomr.BackgroundImage = GetImage("bottomrborder"); - pnlbottomr.BackgroundImageLayout = GetImageLayout("bottomrborder"); - pnlbottoml.BackColor = LoadedSkin.BorderBottomLeftBackground; - pnlbottoml.BackgroundImage = GetImage("bottomlborder"); - pnlbottoml.BackgroundImageLayout = GetImageLayout("bottomlborder"); - - lbtitletext.ForeColor = LoadedSkin.TitleTextColor; - lbtitletext.Font = LoadedSkin.TitleFont; - pnlclose.BackColor = LoadedSkin.CloseButtonColor; - pnlclose.BackgroundImage = GetImage("closebutton"); - pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); - pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; - pnlminimize.BackgroundImage = GetImage("minimizebutton"); - pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); - pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; - pnlmaximize.BackgroundImage = GetImage("maximizebutton"); - pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); - - pnlclose.Size = LoadedSkin.CloseButtonSize; - pnlminimize.Size = LoadedSkin.MinimizeButtonSize; - pnlmaximize.Size = LoadedSkin.MaximizeButtonSize; - pnlclose.Location = FromRight(LoadedSkin.CloseButtonFromSide); - pnlminimize.Location = FromRight(LoadedSkin.MinimizeButtonFromSide); - pnlmaximize.Location = FromRight(LoadedSkin.MaximizeButtonFromSide); - pnlclose.Left -= pnlclose.Width; - pnlmaximize.Left -= pnlmaximize.Width; - pnlminimize.Left -= pnlminimize.Width; - - switch (LoadedSkin.TitleTextCentered) - { - case false: - lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, - LoadedSkin.TitleTextLeft.Y); - break; - default: - lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; - lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; - break; - } - - if (Shiftorium.UpgradeInstalled("app_icons")) - { - pnlicon.Show(); - pnlicon.Size = new Size(16, 16); - pnlicon.BackColor = Color.Transparent; - pnlicon.BackgroundImage = GetIcon(this.ParentWindow.GetType().Name); - pnlicon.BackgroundImageLayout = ImageLayout.Stretch; - pnlicon.Location = LoadedSkin.TitlebarIconFromSide; - } - else - { - pnlicon.Hide(); - } - } - - /// - /// Froms the right. - /// - /// The right. - /// Input. - public Point FromRight(Point input) - { - return new Point(pnltitle.Width - input.X, input.Y); - } - - /// - /// Lbtitletexts the click. - /// - /// The click. - /// Sender. - /// E. - private void lbtitletext_Click(object sender, EventArgs e) - { - - } - - /// - /// Pnlcloses the click. - /// - /// The click. - /// Sender. - /// E. - private void pnlclose_Click(object sender, EventArgs e) - { - this.Close(); - } - - /// - /// Pnlmaximizes the click. - /// - /// The click. - /// Sender. - /// E. - private void pnlmaximize_Click(object sender, EventArgs e) - { - if (maximized == false) - Desktop.MaximizeWindow(this); - else - Desktop.RestoreWindow(this); - maximized = !maximized; - SetupSkin(); - } - - bool minimized = false; - bool maximized = false; - - public bool IsMinimized - { - get - { - return minimized; - } - } - - public bool IsMaximized - { - get - { - return maximized; - } - } - - - /// - /// Pnlminimizes the click. - /// - /// The click. - /// Sender. - /// E. - private void pnlminimize_Click(object sender, EventArgs e) - { - if (minimized == false) - Desktop.MinimizeWindow(this); - else - Desktop.RestoreWindow(this); - minimized = !minimized; - } - - - /// - /// The W m NCLBUTTONDOW. - /// - public const int WM_NCLBUTTONDOWN = 0xA1; - /// - /// The H t CAPTIO. - /// - public const int HT_CAPTION = 0x2; - - /// - /// The is dialog. - /// - public bool IsDialog = false; - - - [DllImportAttribute("user32.dll")] - /// - /// Sends the message. - /// - /// The message. - /// H window. - /// Message. - /// W parameter. - /// L parameter. - public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); - [DllImportAttribute("user32.dll")] - /// - /// Releases the capture. - /// - /// The capture. - public static extern bool ReleaseCapture(); - - /// - /// Pnltitles the mouse move. - /// - /// The mouse move. - /// Sender. - /// E. - private void pnltitle_MouseMove(object sender, MouseEventArgs e) - { - if (e.Button == MouseButtons.Left && Shiftorium.UpgradeInstalled("draggable_windows")) - { - ReleaseCapture(); - SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); - } - } - - /// - /// Pnltitles the paint. - /// - /// The paint. - /// Sender. - /// E. - private void pnltitle_Paint(object sender, PaintEventArgs e) { - - } - - /// - /// Lbtitletexts the mouse move. - /// - /// The mouse move. - /// Sender. - /// E. - private void lbtitletext_MouseMove(object sender, MouseEventArgs e) { - pnltitle_MouseMove(sender, e); - } - } -} diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs deleted file mode 100644 index d30adb4..0000000 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ /dev/null @@ -1,746 +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.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.SkinEngine; -using ShiftOS.WinForms.Tools; -using ShiftOS.WinForms.Applications; -using Newtonsoft.Json; -using ShiftOS.Engine.Scripting; -using System.Threading; - -/// -/// Winforms desktop. -/// -namespace ShiftOS.WinForms -{ - /// - /// Winforms desktop. - /// - public partial class WinformsDesktop : Form, IDesktop - { - private bool InScreensaver = false; - private int millisecondsUntilScreensaver = 300000; - - /// - /// Initializes a new instance of the class. - /// - public WinformsDesktop() - { - InitializeComponent(); - this.TopMost = false; - - NotificationDaemon.NotificationMade += (note) => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = "Notifications (" + NotificationDaemon.GetUnreadCount().ToString() + ")"; - })); - }; - - NotificationDaemon.NotificationRead += () => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = "Notifications (" + NotificationDaemon.GetUnreadCount().ToString() + ")"; - })); - }; - - this.LocationChanged += (o, a) => - { - if (this.Left != 0) - this.Left = 0; - if (this.Top != 0) - this.Top = 0; - }; - - this.SizeChanged += (o, a) => - { - if (this.ClientRectangle != Screen.PrimaryScreen.Bounds) - { - this.WindowState = FormWindowState.Maximized; - } - }; - - SaveSystem.GameReady += () => - { - if (this.Visible == true) - this.Invoke(new Action(() => SetupDesktop())); - this.Invoke(new Action(() => - { - btnnotifications.Text = "Notifications (" + NotificationDaemon.GetUnreadCount().ToString() + ")"; - })); - }; - Shiftorium.Installed += () => - { - if (this.Visible == true) - this.Invoke(new Action(() => SetupDesktop())); - }; - var time = new System.Windows.Forms.Timer(); - time.Interval = 100; - this.KeyDown += (o, a) => - { - if (a.Control && a.KeyCode == Keys.T) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - /*if (a.Control && a.KeyCode == Keys.Tab) - { - // CtrlTabMenu - CtrlTabMenu.Show(); - if (a.Shift) CtrlTabMenu.CycleBack(); - else CtrlTabMenu.CycleForwards(); - }*/ //nyi - - ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); - }; - SkinEngine.SkinLoaded += () => - { - SetupDesktop(); - }; - time.Tick += (o, a) => - { - if (Shiftorium.IsInitiated == true) - { - if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) - { - lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; - lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; - } - } - - try - { - if (SaveSystem.CurrentSave != null) - { - if (SaveSystem.CurrentSave.LastMonthPaid != DateTime.Now.Month) - { - if (SaveSystem.CurrentSave.Codepoints >= DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].CostPerMonth) - { - SaveSystem.CurrentSave.Codepoints -= DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].CostPerMonth; - SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; - } - else - { - SaveSystem.CurrentSave.ShiftnetSubscription = 0; - SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; - Infobox.Show("Shiftnet", "You do not have enough Codepoints to pay for your Shiftnet subscription this month. You have been downgraded to the free plan."); - } - } - } - } - catch { } - - - btnnotifications.Left = lbtime.Left - btnnotifications.Width - 2; - btnnotifications.Top = (desktoppanel.Height - btnnotifications.Height) / 2; - }; - time.Start(); - - var ssThread = new Thread(() => - { - while(this.Visible == true) - { - var mousePos = Cursor.Position; - while(Cursor.Position == mousePos) - { - if(millisecondsUntilScreensaver <= 0) - { - ShowScreensaver(); - InScreensaver = true; - } - millisecondsUntilScreensaver--; - Thread.Sleep(1); - } - millisecondsUntilScreensaver = 300000; - InScreensaver = false; - HideScreensaver(); - } - }); - ssThread.IsBackground = true; - ssThread.Start(); - - this.DoubleBuffered = true; - } - - public void HideScreensaver() - { - if (ResetDesktop == true) - { - this.Invoke(new Action(() => - { - this.TopMost = false; - pnlscreensaver.Hide(); - Cursor.Show(); - SetupDesktop(); - ResetDesktop = false; - - })); - } - } - - private bool ResetDesktop = false; - - private void ShowScreensaver() - { - if (Shiftorium.UpgradeInstalled("screensavers")) - { - this.Invoke(new Action(() => - { - pnlscreensaver.Show(); - this.TopMost = true; - pnlssicon.Show(); - pnlssicon.BackColor = Color.Green; - pnlssicon.BackgroundImage = GetImage("screensaver"); - pnlssicon.BackgroundImageLayout = GetImageLayout("screensaver"); - - if (pnlssicon.BackgroundImage != null) - { - pnlssicon.Size = pnlssicon.BackgroundImage.Size; - } - - Cursor.Hide(); - - var t = new Thread(() => - { - var rnd = new Random(); - while (InScreensaver == true) - { - int x = rnd.Next(0, this.Width); - int y = rnd.Next(0, this.Height); - - this.Invoke(new Action(() => - { - pnlssicon.Location = new Point(x, y); - })); - - Thread.Sleep(5000); - } - ResetDesktop = true; - }); - t.IsBackground = true; - t.Start(); - })); - } - } - - - /// - /// Populates the panel buttons. - /// - /// The panel buttons. - public void PopulatePanelButtons() - { - if (DesktopFunctions.ShowDefaultElements == true) - { - panelbuttonholder.Controls.Clear(); - if (Shiftorium.IsInitiated == true) - { - if (Shiftorium.UpgradeInstalled("wm_panel_buttons")) - { - foreach (WindowBorder form in Engine.AppearanceManager.OpenForms) - { - if (form != null) - { - if (form.Visible == true) - { - EventHandler onClick = (o, a) => - { - if (form == focused) - { - if (form.IsMinimized) - { - RestoreWindow(form); - } - else - { - MinimizeWindow(form); - } - } - else - { - form.BringToFront(); - focused = form; - } - }; - - var pnlbtn = new Panel(); - pnlbtn.Margin = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0); - pnlbtn.BackColor = LoadedSkin.PanelButtonColor; - pnlbtn.BackgroundImage = GetImage("panelbutton"); - pnlbtn.BackgroundImageLayout = GetImageLayout("panelbutton"); - - var pnlbtntext = new Label(); - pnlbtntext.Text = NameChangerBackend.GetName(form.ParentWindow); - pnlbtntext.AutoSize = true; - pnlbtntext.Location = LoadedSkin.PanelButtonFromLeft; - pnlbtntext.ForeColor = LoadedSkin.PanelButtonTextColor; - pnlbtntext.BackColor = Color.Transparent; - - pnlbtn.BackColor = LoadedSkin.PanelButtonColor; - if (pnlbtn.BackgroundImage != null) - { - pnlbtntext.BackColor = Color.Transparent; - } - pnlbtn.Size = LoadedSkin.PanelButtonSize; - pnlbtn.Tag = "keepbg"; - pnlbtntext.Tag = "keepbg"; - pnlbtn.Controls.Add(pnlbtntext); - this.panelbuttonholder.Controls.Add(pnlbtn); - pnlbtn.Show(); - pnlbtntext.Show(); - - if (Shiftorium.UpgradeInstalled("useful_panel_buttons")) - { - pnlbtn.Click += onClick; - pnlbtntext.Click += onClick; - } - pnlbtntext.Font = LoadedSkin.PanelButtonFont; - - } - } - } - } - } - } - - LuaInterpreter.RaiseEvent("on_panelbutton_populate", this); - } - - /// - /// Setups the desktop. - /// - /// The desktop. - public void SetupDesktop() - { - if (DesktopFunctions.ShowDefaultElements == true) - { - ToolStripManager.Renderer = new ShiftOSMenuRenderer(); - - this.DoubleBuffered = true; - this.FormBorderStyle = FormBorderStyle.None; - this.WindowState = FormWindowState.Maximized; - desktoppanel.BackColor = Color.Green; - - //upgrades - - if (Shiftorium.IsInitiated == true) - { - desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); - lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); - - btnnotifications.Visible = Shiftorium.UpgradeInstalled("panel_notifications"); - - //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - - panelbuttonholder.Top = 0; - panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; - panelbuttonholder.Height = desktoppanel.Height; - panelbuttonholder.BackColor = Color.Transparent; - panelbuttonholder.Margin = new Padding(0, 0, 0, 0); - - sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher"); - - //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. - //To compensate, we must recreate the desktop color and make the alpha channel '255'. - this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); - //Not doing this will cause an ArgumentException. - - DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => - { - this.BackgroundImage = img; - })); - this.BackgroundImageLayout = GetImageLayout("desktopbackground"); - desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; - - var pnlimg = GetImage("desktoppanel"); - if (pnlimg != null) - { - var bmp = new Bitmap(pnlimg); - bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); - pnlimg = bmp; - } - - desktoppanel.BackgroundImage = pnlimg; - if (desktoppanel.BackgroundImage != null) - { - desktoppanel.BackColor = Color.Transparent; - } - var appimg = GetImage("applauncher"); - if (appimg != null) - { - var bmp = new Bitmap(appimg); - bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); - appimg = bmp; - } - menuStrip1.BackgroundImage = appimg; - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - lbtime.Font = LoadedSkin.DesktopPanelClockFont; - if (desktoppanel.BackgroundImage == null) - { - lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; - } - else - { - lbtime.BackColor = Color.Transparent; - } - apps.Text = LoadedSkin.AppLauncherText; - sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; - sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; - apps.Size = sysmenuholder.Size; - menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable()); - desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); - desktoppanel.Height = LoadedSkin.DesktopPanelHeight; - if (LoadedSkin.DesktopPanelPosition == 1) - { - desktoppanel.Dock = DockStyle.Bottom; - } - else - { - desktoppanel.Dock = DockStyle.Top; - } - } - } - else - { - desktoppanel.Hide(); - } - - LuaInterpreter.RaiseEvent("on_desktop_skin", this); - - PopulatePanelButtons(); - } - - public ToolStripMenuItem GetALCategoryWithName(string text) - { - foreach (ToolStripMenuItem menuitem in apps.DropDownItems) - { - if (menuitem.Text == text) - return menuitem; - } - - var itm = new ToolStripMenuItem(); - itm.Text = text; - apps.DropDownItems.Add(itm); - return itm; - } - - /// - /// Populates the app launcher. - /// - /// The app launcher. - /// Items. - public void PopulateAppLauncher(LauncherItem[] items) - { - if (DesktopFunctions.ShowDefaultElements == true) - { - apps.DropDownItems.Clear(); - - Dictionary> sortedItems = new Dictionary>(); - - - - foreach (var kv in items) - { - var item = new ToolStripMenuItem(); - item.Text = (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType); - item.Image = (kv.LaunchType == null) ? null : SkinEngine.GetIcon(kv.LaunchType.Name); - item.Click += (o, a) => - { - if (kv is LuaLauncherItem) - { - var interpreter = new Engine.Scripting.LuaInterpreter(); - interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath); - } - else - { - Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow); - } - - }; - if (sortedItems.ContainsKey(kv.DisplayData.Category)) - { - sortedItems[kv.DisplayData.Category].Add(item); - } - else - { - sortedItems.Add(kv.DisplayData.Category, new List()); - sortedItems[kv.DisplayData.Category].Add(item); - } - } - - foreach (var kv in sortedItems) - { - if (Shiftorium.IsInitiated == true) - { - if (Shiftorium.UpgradeInstalled("app_launcher_categories")) - { - var cat = GetALCategoryWithName(kv.Key); - foreach (var subItem in kv.Value) - { - cat.DropDownItems.Add(subItem); - } - } - - else - { - foreach (var subItem in kv.Value) - { - apps.DropDownItems.Add(subItem); - } - } - } - } - - if (Shiftorium.IsInitiated == true) - { - if (Shiftorium.UpgradeInstalled("al_shutdown")) - { - apps.DropDownItems.Add(new ToolStripSeparator()); - var item = new ToolStripMenuItem(); - item.Text = Localization.Parse("{SHUTDOWN}"); - item.Click += (o, a) => - { - TerminalBackend.InvokeCommand("sos.shutdown"); - }; - apps.DropDownItems.Add(item); - - } - } - } - LuaInterpreter.RaiseEvent("on_al_populate", items); - } - - - /// - /// Desktops the load. - /// - /// The load. - /// Sender. - /// E. - private void Desktop_Load(object sender, EventArgs e) - { - - SaveSystem.Begin(); - - SetupDesktop(); - - SaveSystem.GameReady += () => - { - this.Invoke(new Action(() => - { - LuaInterpreter.RaiseEvent("on_desktop_load", this); - })); - }; - } - - /// - /// Shows the window. - /// - /// The window. - /// Border. - public void ShowWindow(IWindowBorder border) - { - var brdr = border as Form; - focused = border; - brdr.GotFocus += (o, a) => - { - focused = border; - }; - brdr.FormBorderStyle = FormBorderStyle.None; - brdr.Show(); - brdr.TopMost = true; - } - - /// - /// Kills the window. - /// - /// The window. - /// Border. - public void KillWindow(IWindowBorder border) - { - border.Close(); - } - - private IWindowBorder focused = null; - - public string DesktopName - { - get - { - return "ShiftOS Desktop"; - } - } - - - /// - /// Minimizes the window. - /// - /// Brdr. - public void MinimizeWindow(IWindowBorder brdr) - { - var loc = (brdr as WindowBorder).Location; - var sz = (brdr as WindowBorder).Size; - (brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new - { - Size = sz, - Location = loc - }); - (brdr as WindowBorder).Location = new Point(this.GetSize().Width * 2, this.GetSize().Height * 2); - } - - /// - /// Maximizes the window. - /// - /// The window. - /// Brdr. - public void MaximizeWindow(IWindowBorder brdr) - { - int startY = (LoadedSkin.DesktopPanelPosition == 1) ? 0 : LoadedSkin.DesktopPanelHeight; - int h = this.GetSize().Height - LoadedSkin.DesktopPanelHeight; - var loc = (brdr as WindowBorder).Location; - var sz = (brdr as WindowBorder).Size; - (brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new - { - Size = sz, - Location = loc - }); - (brdr as WindowBorder).Location = new Point(0, startY); - (brdr as WindowBorder).Size = new Size(this.GetSize().Width, h); - - } - - /// - /// Restores the window. - /// - /// The window. - /// Brdr. - public void RestoreWindow(IWindowBorder brdr) - { - dynamic tag = JsonConvert.DeserializeObject((brdr as WindowBorder).Tag.ToString()); - (brdr as WindowBorder).Location = tag.Location; - (brdr as WindowBorder).Size = tag.Size; - - } - - /// - /// Invokes the on worker thread. - /// - /// The on worker thread. - /// Act. - public void InvokeOnWorkerThread(Action act) - { - this.Invoke(act); - } - - public void OpenAppLauncher(Point loc) - { - apps.DropDown.Left = loc.X; - apps.DropDown.Top = loc.Y; - apps.ShowDropDown(); - } - - /// - /// Gets the size. - /// - /// The size. - public Size GetSize() - { - return this.Size; - } - - private void btnnotifications_Click(object sender, EventArgs e) - { - AppearanceManager.SetupWindow(new Applications.Notifications()); - } - - private void desktoppanel_Paint(object sender, PaintEventArgs e) - { - e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; - } - } - - [ShiftOS.Engine.Scripting.Exposed("desktop")] - public class DesktopFunctions - { - public static bool ShowDefaultElements = true; - - public dynamic getWindow() - { - return Desktop.CurrentDesktop; - } - - public void showDefaultElements(bool val) - { - ShowDefaultElements = val; - SkinEngine.LoadSkin(); - } - - public dynamic getOpenWindows() - { - return AppearanceManager.OpenForms; - } - - public string getALItemName(LauncherItem kv) - { - return (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType); - } - - public void openAppLauncher(Point loc) - { - Desktop.OpenAppLauncher(loc); - } - - public string getWindowTitle(IWindowBorder form) - { - return NameChangerBackend.GetName(form.ParentWindow); - } - - public void openApp(LauncherItem kv) - { - if (kv is LuaLauncherItem) - { - var interpreter = new Engine.Scripting.LuaInterpreter(); - interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath); - } - else - { - Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow); - } - } - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs deleted file mode 100644 index eeaa6c9..0000000 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ /dev/null @@ -1,183 +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.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms -{ - internal class WinformsWindowManager : WindowManager - { - public override void Close(IShiftOSWindow win) - { - (win as UserControl).Close(); - } - - public override void InvokeAction(Action act) - { - Desktop.InvokeOnWorkerThread(act); - } - - public override void Maximize(IWindowBorder form) - { - try - { - var deskSize = new Size(0, 0); - deskSize.Width = Screen.PrimaryScreen.Bounds.Width; - deskSize.Height = Screen.PrimaryScreen.Bounds.Height; - - deskSize.Height -= SkinEngine.LoadedSkin.DesktopPanelHeight; - - var deskStart = new Point((SkinEngine.LoadedSkin.DesktopPanelPosition == 0) ? SkinEngine.LoadedSkin.DesktopPanelHeight : 0, 0); - - (form as WindowBorder).Location = deskStart; - (form as WindowBorder).Size = deskSize; - - - } - catch - { - } - } - - public override void Minimize(IWindowBorder border) - { - try - { - - } - catch { } - } - - public override void SetTitle(IShiftOSWindow win, string title) - { - var wb = (win as UserControl).ParentForm as WindowBorder; - wb.SetTitle(title); - } - - public override void SetupDialog(IShiftOSWindow form) - { - if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) - { - Console.WriteLine("{APP_NOT_FOUND}"); - return; - } - - var wb = new WindowBorder(form as UserControl); - wb.IsDialog = true; - - - wb.Show(); - } - - public override void SetupWindow(IShiftOSWindow form) - { - if (!AppearanceManager.CanOpenWindow(form)) - { - Infobox.Show("{MULTIPLAYER_ONLY}", "{MULTIPLAYER_ONLY_EXP}"); - return; - } - - foreach(var attr in form.GetType().GetCustomAttributes(true)) - { - if(attr is MultiplayerOnlyAttribute) - { - if(KernelWatchdog.MudConnected == false) - { - Infobox.PromptYesNo("Disconnected from MUD", "This application requires a connection to the MUD. Would you like to reconnect?", new Action((answer) => - { - if(answer == true) - { - KernelWatchdog.MudConnected = true; - SetupWindow(form); - } - })); - return; - } - } - } - - if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) - { - Console.WriteLine("{APP_NOT_FOUND}"); - return; - } - - if (SaveSystem.CurrentSave != null) - { - if (!form.GetType().Name.Contains(typeof(Applications.Dialog).Name)) - { - int maxWindows = 0; - - //Window manager will step in here. - if (Shiftorium.UpgradeInstalled("wm_unlimited_windows")) - { - maxWindows = 0; - } - else if (Shiftorium.UpgradeInstalled("wm_4_windows")) - { - maxWindows = 4; - } - else if (Shiftorium.UpgradeInstalled("window_manager")) - { - maxWindows = 2; - } - else - { - maxWindows = 1; - } - - - if (maxWindows > 0) - { - List formstoclose = new List(); - - foreach (WindowBorder frm in AppearanceManager.OpenForms) - { - formstoclose.Add(frm); - - } - - while (formstoclose.Count > maxWindows - 1) - { - formstoclose[0].Close(); - formstoclose.RemoveAt(0); - } - } - } - } - - var wb = new WindowBorder(form as UserControl); - - ControlManager.SetupWindows(); - } - } -} diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs deleted file mode 100644 index 7f6f5e9..0000000 --- a/ShiftOS_TheReturn/AudioManager.cs +++ /dev/null @@ -1,126 +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. - */ - -//#define NOSOUND - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using NAudio; -using NAudio.Wave; - -namespace ShiftOS.Engine -{ - public static class AudioManager - { - private static WaveOut _out = null; - private static AudioFileReader _reader = null; - private static IAudioProvider _provider = null; - private static bool _running = true; - - public static void Init(IAudioProvider _p) - { -#if !NOSOUND - _provider = _p; - AppearanceManager.OnExit += () => - { - _running = false; - _out?.Stop(); - _reader?.Dispose(); - _out?.Dispose(); - System.IO.File.Delete("temp.mp3"); - }; - var t = new Thread(() => - { - SaveSystem.GameReady += () => - { - while(_out == null) - { - - } - _out.Volume = _provider.Volume; - }; - Random rnd = new Random(); - while(_running == true) - { - int track = rnd.Next(0, _provider.Count); - byte[] mp3 = _provider.GetTrack(track); - System.IO.File.WriteAllBytes("temp.mp3", mp3); - _reader = new AudioFileReader("temp.mp3"); - _out = new WaveOut(); - _out.Init(_reader); - _out.Volume = _provider.Volume; - - _out.Play(); - while(_out.PlaybackState == PlaybackState.Playing) - { - Thread.Sleep(5000); //even when the player isn't playing, this will give a good delay between songs. - } - _reader.Dispose(); - _out.Dispose(); - } - }); - t.IsBackground = true; - t.Start(); -#endif - } - - public static void SetVolume(float volume) - { - _provider.Volume = volume; //persist between songs - _out.Volume = volume; - } - - internal static void Kill() - { - _running = false; - _out.Stop(); - _out.Dispose(); - _reader.Dispose(); - } - } - - public interface IAudioProvider - { - /// - /// Gets a byte[] array corresponding to an MP3 track given an index. - /// - /// A track index to use when finding the right track. - /// The MP3 byte[] array. - byte[] GetTrack(int index); - - /// - /// Gets the 1-based count of all available tracks. - /// - int Count { get; } - - /// - /// Gets or sets the track player's volume. - /// - float Volume { get; set; } - } -} diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs deleted file mode 100644 index 73a7e2d..0000000 --- a/ShiftOS_TheReturn/Commands.cs +++ /dev/null @@ -1,739 +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. - */ - -#define DEVEL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine.Properties; -using System.IO; -using Newtonsoft.Json; -using System.IO.Compression; - -using ShiftOS.Objects; -using Discoursistency.Base.Models.Authentication; -using ShiftOS.Engine.Scripting; -using ShiftOS.Objects.ShiftFS; - -namespace ShiftOS.Engine -{ - [Namespace("infobox", hide = true)] - [RequiresUpgrade("desktop;wm_free_placement")] - public static class InfoboxDebugCommands - { - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("show")] - public static bool ShowInfo(Dictionary args) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.Show(args["title"].ToString(), args["msg"].ToString()); - })); - return true; - } - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("yesno")] - public static bool ShowYesNo(Dictionary args) - { - bool forwarding = TerminalBackend.IsForwardingConsoleWrites; - var fGuid = TerminalBackend.ForwardGUID; - Action callback = (result) => - { - TerminalBackend.IsForwardingConsoleWrites = forwarding; - TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - string resultFriendly = (result == true) ? "yes" : "no"; - Console.WriteLine($"{SaveSystem.CurrentSave.Username} says {resultFriendly}."); - TerminalBackend.IsForwardingConsoleWrites = false; - }; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.PromptYesNo(args["title"].ToString(), args["msg"].ToString(), callback); - - })); - return true; - } - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("text")] - public static bool ShowText(Dictionary args) - { - bool forwarding = TerminalBackend.IsForwardingConsoleWrites; - var fGuid = TerminalBackend.ForwardGUID; - Action callback = (result) => - { - TerminalBackend.IsForwardingConsoleWrites = forwarding; - TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - Console.WriteLine($"{SaveSystem.CurrentSave.Username} says \"{result}\"."); - TerminalBackend.IsForwardingConsoleWrites = false; - }; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.PromptText(args["title"].ToString(), args["msg"].ToString(), callback); - })); - return true; - } - - } - - [Namespace("audio")] - public static class AudioCommands - { - [Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")] - [RequiresArgument("value")] - [RequiresUpgrade("audio_volume")] - public static bool SetVolume(Dictionary args) - { - int val = Convert.ToInt32(args["value"].ToString()); - float volume = (val / 100F); - AudioManager.SetVolume(volume); - return true; - } - [RequiresUpgrade("audio_volume")] - [Command("mute", description = "Sets the volume of the system audio to 0")] - public static bool MuteAudio() - { - AudioManager.SetVolume(0); - return true; - } - } - - [RequiresUpgrade("mud_fundamentals")] - [Namespace("mud")] - public static class MUDCommands - { - [MultiplayerOnly] - [Command("status")] - public static bool Status() - { - ServerManager.PrintDiagnostics(); - return true; - } - - [Command("connect")] - public static bool Connect(Dictionary args) - { - try - { - string ip = (args.ContainsKey("addr") == true) ? args["addr"] as string : "michaeltheshifter.me"; - int port = (args.ContainsKey("port") == true) ? Convert.ToInt32(args["port"] as string) : 13370; - try - { - ServerManager.Initiate(ip, port); - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - } - - TerminalBackend.PrefixEnabled = false; - return true; - } - catch (Exception ex) - { - Console.WriteLine("Error running script:" + ex); - return false; - } - } - - [Command("reconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Reconnect() - { - Console.WriteLine("--reconnecting to multi-user domain..."); - KernelWatchdog.MudConnected = true; - Console.WriteLine("--done."); - return true; - } - - [MultiplayerOnly] - [Command("disconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Disconnect() - { - Console.WriteLine("--connection to multi-user domain severed..."); - KernelWatchdog.MudConnected = false; - return true; - } - - [MultiplayerOnly] - [Command("sendmsg")] - [KernelMode] - [RequiresUpgrade("hacker101_deadaccts")] - [RequiresArgument("header")] - [RequiresArgument("body")] - public static bool SendMessage(Dictionary args) - { - ServerManager.SendMessage(args["header"].ToString(), args["body"].ToString()); - return true; - } - } - - [TutorialLock] - [Namespace("trm")] - public static class TerminalCommands - { - [Command("clear")] - public static bool Clear() - { - AppearanceManager.ConsoleOut.Clear(); - return true; - } - - [Command("echo")] - [RequiresArgument("text")] - public static bool Echo(Dictionary args) - { - Console.WriteLine(args["text"]); - return true; - } - } - -#if DEVEL - internal class Rock : Exception - { - internal Rock() : base("Someone threw a rock at the window, and the Terminal shattered.") - { - - } - } - - [MultiplayerOnly] - [Namespace("dev")] - public static class ShiftOSDevCommands - { - [Command("rock", description = "A little surprise for unstable builds...")] - public static bool ThrowASandwichingRock() - { - Infobox.Show("He who lives in a glass house shouldn't throw stones...", new Rock().Message); - return false; - } - - - [Command("unbuy")] - [RequiresArgument("upgrade")] - public static bool UnbuyUpgrade(Dictionary args) - { - try - { - SaveSystem.CurrentSave.Upgrades[args["upgrade"] as string] = false; - } - catch - { - Console.WriteLine("Upgrade not found."); - } - return true; - } - - [Command("getallupgrades")] - public static bool GetAllUpgrades() - { - Console.WriteLine(JsonConvert.SerializeObject(SaveSystem.CurrentSave.Upgrades, Formatting.Indented)); - return true; - } - - [Command("multarg")] - [RequiresArgument("id")] - [RequiresArgument("name")] - [RequiresArgument("type")] - public static bool MultArg(Dictionary args) - { - Console.WriteLine("Success! "+args.ToString()); - return true; - } - - - [Command("freecp")] - public static bool FreeCodepoints(Dictionary args) - { - if (args.ContainsKey("amount")) - try - { - int codepointsToAdd = Convert.ToInt32(args["amount"].ToString()); - SaveSystem.TransferCodepointsFrom("dev", codepointsToAdd); - return true; - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - return true; - } - - SaveSystem.TransferCodepointsFrom("dev", 1000); - return true; - } - - [Command("unlockeverything")] - public static bool UnlockAllUpgrades() - { - foreach (var upg in Shiftorium.GetDefaults()) - { - Shiftorium.Buy(upg.ID, 0); - } - return true; - } - - [Command("info")] - public static bool DevInformation() - { - Console.WriteLine("{SHIFTOS_PLUS_MOTTO}"); - Console.WriteLine("{SHIFTOS_VERSION_INFO}" + Assembly.GetExecutingAssembly().GetName().Version); - return true; - } - [Command("pullfile")] - public static bool PullFile(Dictionary args) - { - if (args.ContainsKey("physical") && args.ContainsKey("virtual")) - { - string file = (string)args["physical"]; - string dest = (string)args["virtual"]; - if (System.IO.File.Exists(file)) - { - Console.WriteLine("Pulling physical file to virtual drive..."); - byte[] filebytes = System.IO.File.ReadAllBytes(file); - ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(dest, filebytes); - } - else - { - Console.WriteLine("The specified file does not exist on the physical drive."); - } - } - else - { - Console.WriteLine("You must supply a physical path."); - } - return true; - } - [Command("crash")] - public static bool CrashInstantly() - { - CrashHandler.Start(new Exception("ShiftOS was sent a command to forcefully crash.")); - return true; - } - } -#endif - - [Namespace("sos")] - public static class ShiftOSCommands - { - [RemoteLock] - [Command("shutdown")] - public static bool Shutdown() - { - TerminalBackend.InvokeCommand("sos.save"); - SaveSystem.ShuttingDown = true; - AppearanceManager.Exit(); - return true; - } - - [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] - public static bool Help() - { - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(exec); - - var types = asm.GetTypes(); - - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (a is Namespace) - { - var ns = a as Namespace; - - if (!ns.hide) - { - string descp = "{NAMESPACE_" + ns.name.ToUpper() + "_DESCRIPTION}"; - if (descp == Localization.Parse(descp)) - descp = ""; - else - descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; - - Console.WriteLine($"{{NAMESPACE}}{ns.name}" + descp); - - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - - if (!cmd.hide) - { - string descriptionparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (descriptionparse == Localization.Parse(descriptionparse)) - descriptionparse = ""; - else - descriptionparse = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descriptionparse) : ""; - - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{SEPERATOR}" + usageparse, new Dictionary() { - {"%ns", ns.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine($"{{COMMAND}}{ns.name}.{cmd.name}" + usageparse + descriptionparse); - } - } - } - } - - } - } - - } - } - } - } - - } - catch { } - } - } - - return true; - } - - [MultiplayerOnly] - [Command("save")] - public static bool Save() - { - SaveSystem.SaveGame(); - return true; - } - - [MultiplayerOnly] - [Command("status")] - public static bool Status() - { - Console.WriteLine($@"ShiftOS version {Assembly.GetExecutingAssembly().GetName().Version.ToString()} - -Codepoints: {SaveSystem.CurrentSave.Codepoints} -Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, - {Shiftorium.GetAvailable().Length} available"); - return true; - } - } - - [MultiplayerOnly] - [Namespace("shiftorium")] - public static class ShiftoriumCommands - { - [Command("buy")] - [RequiresArgument("upgrade")] - public static bool BuyUpgrade(Dictionary userArgs) - { - try - { - string upgrade = ""; - - if (userArgs.ContainsKey("upgrade")) - upgrade = (string)userArgs["upgrade"]; - else - throw new Exception("You must specify a valid 'upgrade' value."); - - foreach (var upg in Shiftorium.GetAvailable()) - { - if (upg.ID == upgrade) - { - Shiftorium.Buy(upgrade, upg.Cost); - return true; - } - } - - throw new Exception($"Couldn't find upgrade with ID: {upgrade}"); - } - catch - { - return false; - } - } - - [RequiresUpgrade("shiftorium_bulk_buy")] - [Command("bulkbuy")] - [RequiresArgument("upgrades")] - public static bool BuyBulk(Dictionary args) - { - if (args.ContainsKey("upgrades")) - { - string[] upgrade_list = (args["upgrades"] as string).Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - foreach (var upg in upgrade_list) - { - var dict = new Dictionary(); - dict.Add("upgrade", upg); - BuyUpgrade(dict); - } - } - else - { - throw new Exception("Please specify a list of upgrades in the 'upgrades' argument. Each upgrade is separated by a comma."); - } - return true; - } - - - [Command("info")] - public static bool ViewInfo(Dictionary userArgs) - { - try - { - string upgrade = ""; - - if (userArgs.ContainsKey("upgrade")) - upgrade = (string)userArgs["upgrade"]; - else - throw new Exception("You must specify a valid 'upgrade' value."); - - foreach (var upg in Shiftorium.GetDefaults()) - { - if (upg.ID == upgrade) - { - Console.WriteLine($@"Information for {upgrade}: - -{upg.Name} - {upg.Cost} Codepoints ------------------------------------------------------- - -{upg.Description} - -To buy this upgrade, run: -shiftorium.buy{{upgrade:""{upg.ID}""}}"); - return true; - } - } - - throw new Exception($"Couldn't find upgrade with ID: {upgrade}"); - } - catch - { - return false; - } - } - [Command("list")] - public static bool ListAll() - { - try - { - Dictionary upgrades = new Dictionary(); - int maxLength = 5; - - foreach (var upg in Shiftorium.GetAvailable()) - { - if (upg.ID.Length > maxLength) - { - maxLength = upg.ID.Length; - } - - upgrades.Add(upg.ID, upg.Cost); - } - - Console.WriteLine("ID".PadRight((maxLength + 5) - 2) + "Cost (Codepoints)"); - - foreach (var upg in upgrades) - { - Console.WriteLine(upg.Key.PadRight((maxLength + 5) - upg.Key.Length) + " " + upg.Value.ToString()); - } - return true; - } - catch (Exception e) - { - CrashHandler.Start(e); - return false; - } - } - } - - [Namespace("win")] - public static class WindowCommands - { - - - - [RemoteLock] - [Command("list")] - public static bool List() - { - Console.WriteLine("Window ID\tName"); - foreach (var app in AppearanceManager.OpenForms) - { - //Windows are displayed the order in which they were opened. - Console.WriteLine($"{AppearanceManager.OpenForms.IndexOf(app)}\t{app.Text}"); - } - return true; - } - - [RemoteLock] - [Command("open")] - public static bool Open(Dictionary args) - { - try - { - if (args.ContainsKey("app")) - { - var app = args["app"] as string; - //ANNND now we start reflecting... - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll")) - { - var asm = Assembly.LoadFile(asmExec); - try - { - foreach (var type in asm.GetTypes()) - { - if (type.BaseType == typeof(UserControl)) - { - foreach (var attr in type.GetCustomAttributes(false)) - { - if (attr is WinOpenAttribute) - { - if (app == (attr as WinOpenAttribute).ID) - { - if (SaveSystem.CurrentSave.Upgrades.ContainsKey(app)) - { - if (Shiftorium.UpgradeInstalled(app)) - { - IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; - AppearanceManager.SetupWindow(frm); - return true; - } - else - { - throw new Exception($"{app} was not found on your system! Try looking in the shiftorium..."); - } - } - else - { - IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; - AppearanceManager.SetupWindow(frm); - return true; - } - } - } - } - } - } - } - catch { } - - } - } - - } - else - { - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(asmExec); - - foreach (var type in asm.GetTypes()) - { - if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) - { - foreach (var attr in type.GetCustomAttributes(false)) - { - if (attr is WinOpenAttribute) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - Console.WriteLine("win.open{app:\"" + (attr as WinOpenAttribute).ID + "\"}"); - } - } - } - } - } - } - catch { } - } - } - - - return true; - } - Console.WriteLine("Couldn't find the specified app on your system."); - return true; - } - catch (Exception ex) - { - Console.WriteLine("Error running script:" + ex); - return false; - } - } - - [RemoteLock] - [Command("close", usage = "{win:integer32}", description ="Closes the specified window.")] - [RequiresArgument("win")] - [RequiresUpgrade("close_command")] - public static bool CloseWindow(Dictionary args) - { - int winNum = -1; - if (args.ContainsKey("win")) - winNum = Convert.ToInt32(args["win"].ToString()); - string err = null; - - if (winNum < 0 || winNum >= AppearanceManager.OpenForms.Count) - err = "The window number must be between 0 and " + (AppearanceManager.OpenForms.Count - 1).ToString() + "."; - - if (string.IsNullOrEmpty(err)) - { - Console.WriteLine($"Closing {AppearanceManager.OpenForms[winNum].Text}..."); - AppearanceManager.Close(AppearanceManager.OpenForms[winNum].ParentWindow); - } - else - { - Console.WriteLine(err); - } - - return true; - } - - } -} diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs deleted file mode 100644 index de5e158..0000000 --- a/ShiftOS_TheReturn/Localization.cs +++ /dev/null @@ -1,201 +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 Newtonsoft.Json; -using ShiftOS.Objects.ShiftFS; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Engine -{ - public interface ILanguageProvider - { - List GetJSONTranscripts(); - void WriteDefaultTranscript(); - string GetCurrentTranscript(); - string[] GetAllLanguages(); - } - - public static class Localization - { - private static ILanguageProvider _provider = null; - - public static string[] GetAllLanguages() - { - if(_provider == null) - { - return JsonConvert.DeserializeObject(Properties.Resources.languages); - } - else - { - return _provider.GetAllLanguages(); - } - } - - public static void SetupTHETRUEDefaultLocals() - { - if (_provider == null) - { - var lines = Properties.Resources.strings_en; - var path = "english.local"; - Utils.WriteAllText(Paths.GetPath(path), lines); - } - else - { - _provider.WriteDefaultTranscript(); - } - } - - public static void SetupDefaultLocals(string lines, string path) - { - Utils.WriteAllText(Paths.GetPath(path), lines); - - } - - - /// - /// Takes in a string and parses localization blocks into text blocks in the current language. - /// - /// "{CODEPOINTS}: 0" will come out as "Codepoints: 0" if the current language is english. - /// The string to parse - /// The parsed string. - /// - public static string Parse(string original) - { - return Parse(original, new Dictionary()); - } - - - public static string Parse(string original, Dictionary replace) - { - Dictionary localizationStrings = new Dictionary(); - - - - try - { - localizationStrings = JsonConvert.DeserializeObject>(_provider.GetCurrentTranscript()); - } - catch - { - localizationStrings = JsonConvert.DeserializeObject>(Utils.ReadAllText(Paths.GetPath("english.local"))); - } - - foreach (var kv in localizationStrings) - { - original = original.Replace(kv.Key, kv.Value); - } - - List orphaned = new List(); - if (Utils.FileExists("0:/dev_orphaned_lang.txt")) - { - orphaned = JsonConvert.DeserializeObject>(Utils.ReadAllText("0:/dev_orphaned_lang.txt")); - } - - - int start_index = 0; - int length = 0; - bool indexing = false; - - foreach (var c in original) - { - if (c == '{') - { - start_index = original.IndexOf(c); - indexing = true; - } - - if (indexing == true) - { - length++; - if (c == '}') - { - indexing = false; - string o = original.Substring(start_index, length); - if (!orphaned.Contains(o)) - { - orphaned.Add(o); - } - start_index = 0; - length = 0; - } - } - } - - if (orphaned.Count > 0) - { - Utils.WriteAllText("0:/dev_orphaned_lang.txt", JsonConvert.SerializeObject(orphaned, Formatting.Indented)); - } - - //string original2 = Parse(original); - - string usernameReplace = ""; - string domainReplace = ""; - - if (SaveSystem.CurrentSave != null) - { - usernameReplace = SaveSystem.CurrentSave.Username; - domainReplace = SaveSystem.CurrentSave.SystemName; - } - - string namespaceReplace = ""; - string commandReplace = ""; - - if (TerminalBackend.latestCommmand != "" && TerminalBackend.latestCommmand.IndexOf('.') > -1) - { - namespaceReplace = TerminalBackend.latestCommmand.Split('.')[0]; - commandReplace = TerminalBackend.latestCommmand.Split('.')[1]; - } - - Dictionary defaultReplace = new Dictionary() { - {"%username", usernameReplace}, - {"%domain", domainReplace}, - {"%ns", namespaceReplace}, - {"%cmd", commandReplace}, - {"%cp", SaveSystem.CurrentSave?.Codepoints.ToString() }, - }; - - foreach (KeyValuePair replacement in replace) - { - original = original.Replace(replacement.Key, Parse(replacement.Value)); - } - - foreach (KeyValuePair replacement in defaultReplace) - { - original = original.Replace(replacement.Key, replacement.Value); - } - - return original; - } - - public static void RegisterProvider(ILanguageProvider p) - { - _provider = p; - } - } -} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs deleted file mode 100644 index df4c6d6..0000000 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ /dev/null @@ -1,331 +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. - */ - -//#define ONLINEMODE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.IO; -using Newtonsoft.Json; -using ShiftOS.Objects; -using ShiftOS.Objects.ShiftFS; -using oobe = ShiftOS.Engine.OutOfBoxExperience; -using static System.Net.Mime.MediaTypeNames; - -namespace ShiftOS.Engine -{ - public class EngineConfig - { - public bool ConnectToMud = true; - public string MudDefaultIP = "dome.rol.im"; - public int MudDefaultPort = 13370; - } - - public static class SaveSystem - { - public static bool ShuttingDown = false; - - public static Save CurrentSave { get; set; } - - /// - /// Start the entire ShiftOS engine. - /// - /// Whether ShiftOS should initiate it's Windows Forms front-end. - public static void Begin(bool useDefaultUI = true) - { - AppDomain.CurrentDomain.UnhandledException += (o, a) => - { - CrashHandler.Start((Exception)a.ExceptionObject); - }; - - if (!System.IO.File.Exists(Paths.SaveFile)) - { - var root = new ShiftOS.Objects.ShiftFS.Directory(); - root.Name = "System"; - root.permissions = Permissions.All; - System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); - } - - - if (Utils.Mounts.Count == 0) - Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); - Paths.Init(); - - Localization.SetupTHETRUEDefaultLocals(); - SkinEngine.Init(); - - TerminalBackend.OpenTerminal(); - - TerminalBackend.InStory = true; - var thread = new Thread(new ThreadStart(() => - { - //Do not uncomment until I sort out the copyright stuff... - Michael - //AudioManager.Init(); - - var defaultConf = new EngineConfig(); - if (System.IO.File.Exists("engineconfig.json")) - defaultConf = JsonConvert.DeserializeObject(System.IO.File.ReadAllText("engineconfig.json")); - else - { - System.IO.File.WriteAllText("engineconfig.json", JsonConvert.SerializeObject(defaultConf, Formatting.Indented)); - } - - Thread.Sleep(350); - Console.WriteLine("Initiating kernel..."); - Thread.Sleep(250); - Console.WriteLine("Reading filesystem..."); - Thread.Sleep(100); - Console.WriteLine("Reading configuration..."); - - Console.WriteLine("{CONNECTING_TO_MUD}"); - - if (defaultConf.ConnectToMud == true) - { - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { - //Connection successful! Stop waiting! - guidReceived = true; - Console.WriteLine("Connection successful."); - }; - - try - { - - ServerManager.Initiate("secondary4162.cloudapp.net", 13370); - //This haults the client until the connection is successful. - while (ServerManager.thisGuid == new Guid()) - { - - } - Console.WriteLine("GUID received - bootstrapping complete."); - FinishBootstrap(); - } - catch (Exception ex) - { - //No errors, this never gets called. - Console.WriteLine("{ERROR}: " + ex.Message); - Thread.Sleep(3000); - ServerManager.StartLANServer(); - while (ServerManager.thisGuid == new Guid()) - { - - } - Console.WriteLine("GUID received - bootstrapping complete."); - FinishBootstrap(); - } - } - else - { - ServerManager.StartLANServer(); - } - - //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - - - })); - thread.IsBackground = true; - thread.Start(); - } - - public static void FinishBootstrap() - { - KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); - - ServerManager.MessageReceived += (msg) => - { - if (msg.Name == "mud_savefile") - { - CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - } - else if (msg.Name == "mud_login_denied") - { - oobe.PromptForLogin(); - } - }; - - ReadSave(); - - while (CurrentSave == null) - { - - } - - Shiftorium.Init(); - - while (CurrentSave.StoryPosition < 1) - { - - } - - Thread.Sleep(75); - - Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); - - TerminalBackend.InStory = false; - TerminalBackend.PrefixEnabled = true; - Shiftorium.LogOrphanedUpgrades = true; - Desktop.InvokeOnWorkerThread(new Action(() => - { - ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); - })); - Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); - if (CurrentSave.StoryPosition == 1) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - TutorialManager.StartTutorial(); - - })); - while (TutorialManager.IsInTutorial == true) { } - GameReady?.Invoke(); - } - else - { - GameReady?.Invoke(); - } - } - - public delegate void EmptyEventHandler(); - - public static List Users - { - get; - private set; - } - - public static event EmptyEventHandler GameReady; - - public static void TransferCodepointsToVoid(int amount) - { - CurrentSave.Codepoints -= amount; - NotificationDaemon.AddNotification(NotificationType.CodepointsSent, amount); - } - - public static void Restart() - { - TerminalBackend.InvokeCommand("sos.shutdown"); - System.Windows.Forms.Application.Restart(); - } - - public static void ReadSave() - { - //Migrate old saves. - if(System.IO.Directory.Exists("C:\\ShiftOS2")) - { - Console.WriteLine("Old save detected. Migrating filesystem to MFS..."); - foreach (string file in System.IO.Directory.EnumerateDirectories("C:\\ShiftOS2") -.Select(d => new DirectoryInfo(d).FullName)) - { - if(!Utils.DirectoryExists(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"))) - Utils.CreateDirectory(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/")); - } - foreach (string file in System.IO.Directory.EnumerateFiles("C:\\ShiftOS2")) - { - - string rfile = Path.GetFileName(file); - Utils.WriteAllBytes(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"), System.IO.File.ReadAllBytes(file)); - Console.WriteLine("Exported file " + file); - } - - } - - - if (Utils.FileExists(Paths.SaveFileInner)) - { - oobe.ShowSaveTransfer(JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.SaveFileInner))); - } - else - { - if (Utils.FileExists(Paths.GetPath("user.dat"))) - { - var userdat = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("user.dat"))); - - ServerManager.SendMessage("mud_login", $@"{{ - username: ""{userdat.Username}"", - password: ""{userdat.Password}"" -}}"); - } - else - { - NewSave(); - } - } - - } - - public static void NewSave() - { - AppearanceManager.Invoke(new Action(() => - { - CurrentSave = new Save(); - CurrentSave.Codepoints = 0; - CurrentSave.Upgrades = new Dictionary(); - Shiftorium.Init(); - oobe.Start(CurrentSave); - })); - } - - public static void SaveGame() - { - if(!Shiftorium.Silent) - Console.WriteLine(""); - if(!Shiftorium.Silent) - Console.Write("{SE_SAVING}... "); - if (SaveSystem.CurrentSave != null) - { - string username = CurrentSave.Username; - string password = CurrentSave.Password; - - Utils.WriteAllText(Paths.GetPath("user.dat"), $@"{{ - username: ""{username}"", - password: ""{password}"" -}}"); - - ServerManager.SendMessage("mud_save", JsonConvert.SerializeObject(CurrentSave, Formatting.Indented)); - } - if (!Shiftorium.Silent) - Console.WriteLine(" ...{DONE}."); - System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); - } - - public static void TransferCodepointsFrom(string who, long amount) - { - NotificationDaemon.AddNotification(NotificationType.CodepointsReceived, amount); - CurrentSave.Codepoints += amount; - } - } - - public delegate void TextSentEventHandler(string text); - - public class DeveloperAttribute : Attribute - { - - } -} diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs deleted file mode 100644 index 31b3129..0000000 --- a/ShiftOS_TheReturn/ServerManager.cs +++ /dev/null @@ -1,230 +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 System.Windows.Forms; -using System.Threading; -using ShiftOS; -using static ShiftOS.Engine.SaveSystem; -using Newtonsoft.Json; - -namespace ShiftOS.Engine -{ - public static class ServerManager - { - public static void PrintDiagnostics() - { - Console.WriteLine($@"{{CLIENT_DIAGNOSTICS}} - -{{GUID}}: {thisGuid} -{{CLIENT_DATA}}: - -{JsonConvert.SerializeObject(client, Formatting.Indented)}"); - } - - public static Guid thisGuid { get; private set; } - private static NetObjectClient client { get; set; } - - public static void Disconnect() - { - if (client != null) - { - client.Disconnect(); - } - Disconnected?.Invoke(); - - } - - public static event EmptyEventHandler Disconnected; - - public static void InitiateMUDHack() - { - MessageReceived += ServerManager_MessageReceived; - SendMessage("mudhack_init", ""); - } - - public static event Action ServerPasswordGenerated; - public static event EmptyEventHandler ServerAccessGranted; - public static event EmptyEventHandler ServerAccessDenied; - public static event Action GUIDReceived; - public static event Action> UsersReceived; - - private static void ServerManager_MessageReceived(ServerMessage msg) - { - switch(msg.Name) - { - case "mudhack_users": - UsersReceived?.Invoke(JsonConvert.DeserializeObject>(msg.Contents)); - break; - case "mudhack_init": - ServerPasswordGenerated?.Invoke(msg.Contents); - break; - case "mudhack_denied": - ServerAccessDenied?.Invoke(); - break; - case "mudhack_granted": - ServerAccessGranted?.Invoke(); - break; - case "getguid_fromserver": - if(SaveSystem.CurrentSave.Username == msg.Contents) - { - client.Send(new NetObject("yes_i_am", new ServerMessage - { - Name = "getguid_reply", - GUID = msg.GUID, - Contents = thisGuid.ToString(), - })); - } - break; - case "getguid_reply": - GUIDReceived?.Invoke(msg.Contents); - break; - } - } - - public static void Detach_ServerManager_MessageReceived() - { - MessageReceived -= new ServerMessageReceived(ServerManager_MessageReceived); - } - - public static void Initiate(string mud_address, int port) - { - client = new NetObjectClient(); - - client.OnReceived += (o, a) => - { - var msg = a.Data.Object as ServerMessage; - if (msg.Name == "Welcome") - { - thisGuid = new Guid(msg.Contents); - GUIDReceived?.Invoke(msg.Contents); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - } - else if(msg.Name == "allusers") - { - foreach(var acc in JsonConvert.DeserializeObject(msg.Contents)) - { - Console.WriteLine(acc); - } - TerminalBackend.PrintPrompt(); - } - else if(msg.Name == "update_your_cp") - { - var args = JsonConvert.DeserializeObject>(msg.Contents); - if(args["username"] as string == SaveSystem.CurrentSave.Username) - { - SaveSystem.CurrentSave.Codepoints += (long)args["amount"]; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.Show($"MUD Control Centre", $"Someone bought an item in your shop, and they have paid {args["amount"]}, and as such, you have been granted these Codepoints."); - })); - SaveSystem.SaveGame(); - } - } - else if(msg.Name =="broadcast") - { - Console.WriteLine(msg.Contents); - } - else if (msg.Name == "Error") - { - var ex = JsonConvert.DeserializeObject(msg.Contents); - TerminalBackend.PrefixEnabled = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - ConsoleEx.Bold = true; - Console.Write($@"{{MUD_ERROR}}: "); - ConsoleEx.Bold = false; - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(ex.Message); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - } - else - { - MessageReceived?.Invoke(msg); - } - }; - - client.Connect(mud_address, port); - - } - - public static void SendMessage(string name, string contents) - { - var sMsg = new ServerMessage - { - Name = name, - Contents = contents, - GUID = thisGuid.ToString(), - }; - - client.Send(new NetObject("msg", sMsg)); - - } - - private static bool singleplayer = false; - public static bool IsSingleplayer { get { return singleplayer; } } - - public static void StartLANServer() - { - singleplayer = true; - ShiftOS.Server.Program.ServerStarted += (address) => - { - Console.WriteLine($"Connecting to {address}..."); - Initiate(address, 13370); - }; - Disconnected += () => - { - ShiftOS.Server.Program.Stop(); - }; - ShiftOS.Server.Program.Main(new[] { "" }); - - - } - - - public static event ServerMessageReceived MessageReceived; - - } - - public delegate void ServerMessageReceived(ServerMessage msg); - - public class MultiplayerOnlyAttribute : Attribute - { - /// - /// Marks this application as a multiplayer-only application. - /// - public MultiplayerOnlyAttribute() - { - - } - } -} diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs deleted file mode 100644 index 0bdd9f4..0000000 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ /dev/null @@ -1,285 +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 Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using static ShiftOS.Engine.SaveSystem; -using System.Diagnostics; - -namespace ShiftOS.Engine -{ - public static class Shiftorium - { - /// - /// Whether or not shiftorium output should be written to the console. - /// - public static bool Silent = false; - - public static void InvokeUpgradeInstalled() - { - Installed?.Invoke(); - } - - - public static bool Buy(string id, int cost) - { - if(SaveSystem.CurrentSave.Codepoints >= cost) - { - SaveSystem.CurrentSave.Upgrades[id] = true; - TerminalBackend.InvokeCommand("sos.save"); - SaveSystem.TransferCodepointsToVoid(cost); - Installed?.Invoke(); - Desktop.ResetPanelButtons(); - Desktop.PopulateAppLauncher(); - return true; - } - else - { - if(!Silent) - Console.WriteLine($"{{SHIFTORIUM_NOTENOUGHCP}}: {cost} > {SaveSystem.CurrentSave.Codepoints}"); - return false; - } - } - - public static bool UpgradeAttributesUnlocked(Type type) - { - foreach(var attr in type.GetCustomAttributes(true)) - { - if(attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool UpgradeAttributesUnlocked(MethodInfo type) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool UpgradeAttributesUnlocked(PropertyInfo type) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool UpgradeAttributesUnlocked(FieldInfo type) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool IsInitiated { get; private set; } - - public static void Init() - { - if (IsInitiated == false) - { - IsInitiated = true; - //Let the crash handler deal with this one... - var dict = GetDefaults(); - foreach (var itm in dict) - { - if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(itm.ID)) - { - try - { - SaveSystem.CurrentSave.Upgrades.Add(itm.ID, false); - } - catch - { - - } - } - } - } - - } - - public static int GetCPValue(string id) - { - foreach(var upg in GetDefaults()) - { - if (upg.ID == id) - return upg.Cost; - } - return 0; - } - - public static ShiftoriumUpgrade[] GetAvailable() - { - List available = new List(); - foreach(var defaultupg in GetDefaults()) - { - if (!UpgradeInstalled(defaultupg.ID) && DependenciesInstalled(defaultupg)) - available.Add(defaultupg); - } - return available.ToArray(); - } - - public static bool DependenciesInstalled(ShiftoriumUpgrade upg) - { - if (string.IsNullOrEmpty(upg.Dependencies)) - { - return true;//root upgrade, no parents - } - else if (upg.Dependencies.Contains(";")) - { - string[] dependencies = upg.Dependencies.Split(';'); - foreach(var dependency in dependencies) - { - if (!UpgradeInstalled(dependency)) - return false; - } - return true; - } - else - { - return UpgradeInstalled(upg.Dependencies); - } - } - - public static event EmptyEventHandler Installed; - - public static bool UpgradeInstalled(string id) - { - if (SaveSystem.CurrentSave != null) - { - if (!IsInitiated) - Init(); - } - try - { - if (SaveSystem.CurrentSave == null) - return false; - - if (SaveSystem.CurrentSave.StoriesExperienced == null) - SaveSystem.CurrentSave.StoriesExperienced = new List(); - - bool upgInstalled = false; - if(SaveSystem.CurrentSave.Upgrades.ContainsKey(id)) - upgInstalled = SaveSystem.CurrentSave.Upgrades[id]; - - if(upgInstalled == false) - return SaveSystem.CurrentSave.StoriesExperienced.Contains(id); - return true; - } - catch - { - Console.WriteLine("Upgrade " + id + "DNE."); - Console.WriteLine(); - return false; - } - - } - - //LEAVE THIS AS FALSE. The game will set it when the save is loaded. - public static bool LogOrphanedUpgrades = false; - - private static IShiftoriumProvider _provider = null; - - public static void RegisterProvider(IShiftoriumProvider p) - { - _provider = p; - } - - //Bless the newer NEWER engine. - public static List GetDefaults() - { - try - { - return _provider.GetDefaults(); - } - catch (Exception ex) - { - Console.WriteLine("Couldn't get the upgrade definition list from the provider."); - Console.WriteLine("This might be able to help:"); - Console.WriteLine(ex); - return JsonConvert.DeserializeObject>(Properties.Resources.Shiftorium); - } - } - } - - public interface IShiftoriumProvider - { - List GetDefaults(); - } - - public class ShiftoriumUpgradeLookupException : Exception - { - public ShiftoriumUpgradeLookupException(string id) : base("A shiftorium upgrade of ID \"" + id + "\" was not found in the system.") - { - ID = id; - - Debug.WriteLine("UpgradeNotFound: " + id); - - } - - public string ID { get; private set; } - } - - public class ShiftoriumUpgrade - { - public string Name { get; set; } - public string Description { get; set; } - public int Cost { get; set; } - public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } - public string Id { get; } - - public string Dependencies { get; set; } - } -} diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs deleted file mode 100644 index bc242a9..0000000 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ /dev/null @@ -1,131 +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 System.IO; -using System.Windows.Forms; - -namespace ShiftOS.Engine -{ - public class TerminalTextWriter : TextWriter - { - [System.Runtime.InteropServices.DllImport("user32.dll")] - public static extern bool LockWindowUpdate(IntPtr hWndLock); - - - public override Encoding Encoding - { - get - { - return Encoding.Unicode; - } - } - - public ITerminalWidget UnderlyingControl - { - get - { - return AppearanceManager.ConsoleOut; - } - } - - public void select() - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl.SelectBottom(); - - })); - } - - public override void Write(char value) - { - if (TerminalBackend.IsForwardingConsoleWrites) - { - ServerManager.SendMessage("write", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"", - text: ""{value}"" -}}"); - } - else - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl.Write(value.ToString()); - select(); - })); - } - } - - public override void WriteLine(string value) - { - if (TerminalBackend.IsForwardingConsoleWrites) - { - ServerManager.SendMessage("write", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"", - text: ""{value + Environment.NewLine}"" -}}"); - } - else - { - - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl.WriteLine(value); - select(); - })); - } - } - - public void SetLastText() - { - } - - public override void Write(string value) - { - if (TerminalBackend.IsForwardingConsoleWrites) - { - ServerManager.SendMessage("write", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"", - text: ""{value}"" -}}"); - } - else - { - - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl.Write(value.ToString()); - select(); - })); - } - } - - - } -} -- cgit v1.2.3 From 624fc98fa2c695a90704cd768b156342f8403d09 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Fri, 7 Apr 2017 17:07:39 +0000 Subject: Missing Core.cs --- ShiftOS.Server/Core.cs | 227 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 ShiftOS.Server/Core.cs (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs new file mode 100644 index 0000000..e14ca27 --- /dev/null +++ b/ShiftOS.Server/Core.cs @@ -0,0 +1,227 @@ +/* + * 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; + + +namespace ShiftOS.Server +{ + public static class Core + { + [MudRequest("getguid_reply", typeof(string))] + public static void GuidBounce(string guid, object contents) + { + //The message's GUID was manipulated by the client to send to another client. + //So we can just bounce back the message to the other client. + server.DispatchTo(new Guid(guid), new NetObject("bounce", new ServerMessage + { + Name = "getguid_reply", + GUID = guid, + Contents = contents as string + })); + + } + + [MudRequest("getguid_send", typeof(string))] + public static void GuidReceiver(string guid, object contents) + { + string usrname = contents as string; + server.DispatchAll(new NetObject("are_you_this_guy", new ServerMessage + { + Name = "getguid_fromserver", + GUID = guid, + Contents = usrname, + })); + + } + + [MudRequest("script", typeof(Dictionary))] + public static void RunScript(string guid, object contents) + { + try + { + var args = contents as Dictionary; + + string user = ""; + string script = ""; + string sArgs = ""; + + if (!args.ContainsKey("user")) + throw new MudException("No 'user' arg specified in message to server"); + + if (!args.ContainsKey("script")) + throw new MudException("No 'script' arg specified in message to server"); + + if (!args.ContainsKey("args")) + throw new MudException("No 'args' arg specified in message to server"); + + user = args["user"] as string; + script = args["script"] as string; + sArgs = args["args"] as string; + + if (File.Exists($"scripts/{user}/{script}.lua")) + { + var script_arguments = JsonConvert.DeserializeObject>(sArgs); + server.DispatchTo(new Guid(guid), new NetObject("runme", new ServerMessage + { + Name = "run", + GUID = "Server", + Contents = JsonConvert.SerializeObject(new + { + script = File.ReadAllText($"scripts/{user}/{script}.lua"), + args = sArgs + }) + })); + } + else + { + throw new MudException($"{user}.{script}: Script not found."); + } + } + catch + { + try + { + Program.server.DispatchTo(new Guid(guid), new NetObject("error", new ServerMessage + { + Name = "Error", + GUID = "Server", + Contents = JsonConvert.SerializeObject(new MudException(" Script not found or script error detected.")) + })); + } + catch + { + //fuck. + } + } + + } + + [MudRequest("diag_log", typeof(string))] + public static void Diagnostic(string guid, string line) + { + List lines = new List(); + if (File.Exists("diagnostics.log")) + lines = new List(File.ReadAllLines("diagnostics.log")); + + lines.Add(line); + File.WriteAllLines("diagnostics.log", lines.ToArray()); + } + + [MudRequest("getusers", typeof(string))] + public static void GetAllUsers(string guid, string contents) + { + List accs = new List(); + if(contents == "dead") + { + foreach(var sve in Directory.GetFiles("deadsaves")) + { + if (sve.EndsWith(".save")) + { + var save = JsonConvert.DeserializeObject(File.ReadAllText(sve)); + accs.Add($"{save.Username}@{save.SystemName}"); + } + + } + } + server.DispatchTo(new Guid(guid), new NetObject("h4xx0r", new ServerMessage + { + Name = "allusers", + GUID = "server", + Contents = JsonConvert.SerializeObject(accs) + })); + } + + [MudRequest("mud_save_allow_dead", typeof(Save))] + public static void SaveDead(string guid, Save sve) + { + if(File.Exists("saves/" + sve.Username + ".save")) + { + WriteEncFile("saves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve)); + } + else if(File.Exists("deadsaves/" + sve.Username + ".save")) + { + File.WriteAllText("deadsaves/" + sve.Username + ".save", JsonConvert.SerializeObject(sve)); + } + } + + [MudRequest("get_user_data", typeof(Dictionary))] + public static void GetUserData(string guid, Dictionary contents) + { + string usr = contents["user"]; + string sys = contents["sysname"]; + + foreach(var sve in Directory.GetFiles("deadsaves")) + { + if (sve.EndsWith(".save")) + { + var saveFile = JsonConvert.DeserializeObject(File.ReadAllText(sve)); + if(saveFile.Username == usr && saveFile.SystemName == sys) + { + server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage + { + Name = "user_data", + GUID = "server", + Contents = JsonConvert.SerializeObject(saveFile) + })); + return; + } + } + } + foreach (var sve in Directory.GetFiles("saves")) + { + if (sve.EndsWith(".save")) + { + var saveFile = JsonConvert.DeserializeObject(ReadEncFile(sve)); + if (saveFile.Username == usr && saveFile.SystemName == sys) + { + server.DispatchTo(new Guid(guid), new NetObject("1337", new ServerMessage + { + Name = "user_data", + GUID = "server", + Contents = JsonConvert.SerializeObject(saveFile) + })); + return; + } + } + } + + server.DispatchTo(new Guid(guid), new NetObject("n07_50_1337", new ServerMessage + { + Name = "user_data_not_found", + GUID = "server" + })); + + } + } +} -- 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') 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 71440207cdaecea96f09f71861eb7b3af2c7d44e Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 10 Apr 2017 20:46:36 +0000 Subject: Force lowercase usernames. --- ShiftOS.Server/SaveManager.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index e986ecd..a277b6d 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -43,7 +43,7 @@ namespace ShiftOS.Server var args = contents as Dictionary; if (!args.ContainsKey("username")) throw new MudException("No 'username' argument supplied."); - + args["username"] = args["username"].ToString().ToLower(); foreach(var savefile in Directory.GetFiles("saves")) { var save = ReadSave(savefile); @@ -64,6 +64,7 @@ namespace ShiftOS.Server var args = contents as Dictionary; if (args["username"] != null && args["password"] != null) { + args["username"] = args["username"].ToString().ToLower(); foreach (var savefile in Directory.GetFiles("saves")) { try @@ -122,6 +123,7 @@ namespace ShiftOS.Server var args = contents as Dictionary; if (args["username"] != null && args["password"] != null) { + args["username"] = args["username"].ToString().ToLower(); foreach (var savefile in Directory.GetFiles("saves")) { try @@ -162,7 +164,7 @@ namespace ShiftOS.Server public static void SaveGame(string guid, object contents) { var sav = contents as Save; - + sav.Username = sav.Username.ToLower(); WriteEncFile("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented)); @@ -181,7 +183,7 @@ namespace ShiftOS.Server public static void DeleteSave(string guid, object contents) { var cSave = contents as ClientSave; - + cSave.Username = cSave.Username.ToLower(); foreach(var saveFile in Directory.GetFiles("saves")) { try @@ -204,6 +206,7 @@ namespace ShiftOS.Server var args = contents as Dictionary; if (args["username"] != null && args["amount"] != null) { + args["username"] = args["username"].ToString().ToLower(); string userName = args["username"] as string; long cpAmount = (long)args["amount"]; @@ -236,6 +239,7 @@ namespace ShiftOS.Server var args = contents as Dictionary; if (args["username"] != null && args["password"] != null && args["amount"] != null && args["yourusername"] != null) { + args["username"] = args["username"].ToString().ToLower(); string userName = args["username"] as string; string passw = args["password"] as string; int cpAmount = (int)args["amount"]; -- cgit v1.2.3 From 32fc6ed13d8334a6af66b43cf84324a123670620 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 17 Apr 2017 15:10:34 -0400 Subject: Basically finish new OOBE --- ShiftOS.Server/SaveManager.cs | 4 +- ShiftOS.WinForms/Applications/Terminal.cs | 5 +- ShiftOS.WinForms/Oobe.Designer.cs | 4 +- ShiftOS.WinForms/Oobe.cs | 134 ++++---------- ShiftOS.WinForms/OobeStory.cs | 284 ++++++++++++++++++++++++++++++ ShiftOS.WinForms/Program.cs | 4 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 7 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS_TheReturn/SaveSystem.cs | 8 +- ShiftOS_TheReturn/Story.cs | 2 +- 10 files changed, 334 insertions(+), 119 deletions(-) create mode 100644 ShiftOS.WinForms/OobeStory.cs (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index a277b6d..56e8d50 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -121,7 +121,7 @@ namespace ShiftOS.Server public static void CheckUserExists(string guid, object contents) { var args = contents as Dictionary; - if (args["username"] != null && args["password"] != null) + if (args["username"] != null) { args["username"] = args["username"].ToString().ToLower(); foreach (var savefile in Directory.GetFiles("saves")) @@ -131,7 +131,7 @@ namespace ShiftOS.Server var save = JsonConvert.DeserializeObject(ReadEncFile(savefile)); - if (save.Username == args["username"].ToString() && save.Password == args["password"].ToString()) + if (save.Username == args["username"].ToString()) { server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 8d29cba..30dbd82 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -56,7 +56,6 @@ namespace ShiftOS.WinForms.Applications { public static string latestCommmand = ""; - public static bool IsInRemoteSystem = false; public static string RemoteGuid = ""; @@ -371,5 +370,9 @@ namespace ShiftOS.WinForms.Applications { } + internal void ClearText() + { + rtbterm.Text = ""; + } } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Oobe.Designer.cs b/ShiftOS.WinForms/Oobe.Designer.cs index 587f50a..d3a0f38 100644 --- a/ShiftOS.WinForms/Oobe.Designer.cs +++ b/ShiftOS.WinForms/Oobe.Designer.cs @@ -82,14 +82,14 @@ namespace ShiftOS.WinForms // // lblhackwords // - this.lblhackwords.AutoSize = true; this.lblhackwords.Dock = System.Windows.Forms.DockStyle.Fill; this.lblhackwords.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblhackwords.ForeColor = System.Drawing.SystemColors.ButtonFace; this.lblhackwords.Location = new System.Drawing.Point(0, 0); this.lblhackwords.Name = "lblhackwords"; - this.lblhackwords.Size = new System.Drawing.Size(127, 18); + this.lblhackwords.Size = new System.Drawing.Size(653, 457); this.lblhackwords.TabIndex = 1; + this.lblhackwords.Tag = "header2"; this.lblhackwords.Text = "Hijack in progress"; // // hackeffecttimer diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index d6d3b92..5b767e0 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -36,6 +36,7 @@ using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; using ShiftOS.Objects.ShiftFS; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms { @@ -47,7 +48,10 @@ namespace ShiftOS.WinForms this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; this.BackColor = Color.Black; - + this.Load += (o, a) => + { + ControlManager.SetupControls(this); + }; } @@ -62,6 +66,7 @@ namespace ShiftOS.WinForms public void TextType(string texttotype) { + textgeninput.TextAlign = ContentAlignment.MiddleCenter; while(typing == true) { //JESUS CHRIST PAST MICHAEL. @@ -116,114 +121,43 @@ namespace ShiftOS.WinForms { try { - textgeninput = this.lblHijack; - TextType("Your system is now being hijacked."); - rtext = ""; - Thread.Sleep(1000); textgeninput = this.lblhackwords; this.Invoke(new Action(() => { lblHijack.Hide(); })); - TextType("Hello, and welcome to ShiftOS."); - Thread.Sleep(500); - TextType("You have been cordially and involuntarily selected to participate in the development and testing of this operating system."); - Thread.Sleep(500); - TextType("My identity shall remain secret, but if you've been through this before, you'll know exactly who I am."); - Thread.Sleep(500); - TextType("But that doesn't matter."); - Thread.Sleep(500); - TextType("I will now begin to prepare your system for the installation of ShiftOS."); - Thread.Sleep(1000); - FakeSetupScreen fakeForm = null; - this.Invoke(new Action(() => - { - fakeForm = new FakeSetupScreen(this); - fakeForm.Show(); - MySave = save; - lblhackwords.GotFocus += (o, a) => - { - try - { - fakeForm.Invoke(new Action(() => - { - fakeForm.Focus(); - fakeForm.BringToFront(); - })); - } - catch { } - }; - fakeForm.TextSent += (txt) => - { - TextType(txt); - }; - })); - while (fakeForm?.Visible == true) - { - Thread.Sleep(10); - } - if (fakeForm.CreateNewSave == true) + + TextType(@"Throughout many years, man has tried to develop +a digital environment usable by anyone that never goes +offline, full of AIs and humans alike, thinking, interacting, +innovating. + +No one has ever come close to a digital society of such +properties yet, except for one sentient being. It does not +have a life, a gender, an age or a body, but simply one name. + +They call it ""DevX"". + +If anyone sees this message, my identity is anonymous, but I +need your help. I am trapped within ""DevX""'s digital society +with no way out, constantly under attack. + +You must join the digital society, rise up the ranks, and save us. + + - undisclosed_0x1DDFB5977."); + + Thread.Sleep(5000); + while(this.Opacity > 0f) { - TextType("That's all the information I need for now."); - Thread.Sleep(2000); - TextType("Beginning installation of ShiftOS on " + MySave.SystemName + "."); - Thread.Sleep(500); - TextType("Creating new user: " + MySave.Username); - TextType("...with 0 Codepoints, 0 installed upgrades, no legion, and no user shops..."); - MySave.Codepoints = 0; - MySave.CurrentLegions = new List(); - MySave.MyShop = ""; - TextType("User created successfully."); - Thread.Sleep(450); - TextType("You may be wondering what all that meant... You see, in ShiftOS, your user account holds everything I need to know about you."); - Thread.Sleep(640); - TextType("It holds the amount of Codepoints you have - Codepoints are a special currency you can get by doing various tasks in ShiftOS."); - Thread.Sleep(500); - TextType("It also holds all the upgrades you've installed onto ShiftOS - features, applications, enhancements, patches, all that stuff."); - Thread.Sleep(500); - TextType("As for the legions and the shop thing, I'll reveal that to you when it becomes necessary."); - Thread.Sleep(500); - TextType("Your user account is stored on a server of mine called the multi-user domain. It holds every single user account, every script, every application, every thing within ShiftOS."); - Thread.Sleep(600); - TextType("Every time you boot ShiftOS, if you are connected to the Internet, you will immediately connect to the multi-user domain and ShiftOS will attempt to authenticate using the last "); - TextType("successful username and password pair."); - Thread.Sleep(500); - TextType("When you are in the MUD, you are in the middle of a free-for-all. I don't want it to be this way, it just is. I've employed you to help me develop and test the MUD and ShiftOS, "); - TextType("but you have a secondary task if you choose to accept it."); - Thread.Sleep(500); - TextType("There have been a few rebelious groups in the MUD - who have cracked ShiftOS's security barriers - and they're using these exploits to steal others' Codepoints, upgrades, "); - TextType("and even spread damaging viruses."); - Thread.Sleep(500); - TextType("I want you to stop them."); - Thread.Sleep(500); - TextType("Whoever can stop these hackers will gain eternal control over the multi-user domain. They will be given the ability to do as they please, so long as it doesn't interfere with my experiments."); - Thread.Sleep(500); - TextType("I have been installing ShiftOS on your system in the background as I was talking with you. Before I can set you free, I need to give you a tutorial on how to use the system."); - Thread.Sleep(500); - TextType("I will reboot your system in Tutorial Mode now. Complete the tutorial, and you shall be on your way."); - - Thread.Sleep(3000); - SaveSystem.CurrentSave = MySave; - SaveSystem.CurrentSave.StoryPosition = 1; - Utils.WriteAllText(Paths.GetPath("user.dat"), JsonConvert.SerializeObject(new + this.Invoke(new Action(() => { - username = MySave.Username, - password = MySave.Password + this.Opacity -= 0.01f; })); - Shiftorium.Silent = true; - SaveSystem.SaveGame(); //Yknow, just incase it crashes. - } - else - { - TextType("Your login attempt was successful, " + SaveSystem.CurrentSave.Username + "."); - Thread.Sleep(500); - TextType($"According to my data on you, you have earned {SaveSystem.CurrentSave.Codepoints} Codepoints so far."); - Thread.Sleep(500); - TextType($"You have also acquired {SaveSystem.CurrentSave.CountUpgrades()} Shiftorium upgrades out of the {SaveSystem.CurrentSave.Upgrades.Count} available."); - Thread.Sleep(500); - TextType("I will now let you proceed to your system."); - Thread.Sleep(1000); + Thread.Sleep(25); } + + Story.Start("mud_fundamentals"); + this.Invoke(new Action(this.Close)); } catch (Exception e) diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs new file mode 100644 index 0000000..68e2a7b --- /dev/null +++ b/ShiftOS.WinForms/OobeStory.cs @@ -0,0 +1,284 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; +using Newtonsoft.Json; +using ShiftOS.Engine; +using ShiftOS.Objects; + +namespace ShiftOS.WinForms +{ + public class OobeStory + { + [Story("mud_fundamentals")] + public static void DoStory() + { + Applications.Terminal term = null; + TerminalBackend.PrefixEnabled = false; + Desktop.InvokeOnWorkerThread(() => + { + term = new Applications.Terminal(); + AppearanceManager.SetupWindow(term); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("Welcome to ShiftOS."); + Console.WriteLine(); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.WriteLine("Before we can bring you to your new system, we must perform some system tasks."); + Console.WriteLine(); + Console.WriteLine("Here's the installation outline."); + Console.WriteLine(); + Console.Write(" - "); + ConsoleEx.Bold = true; + Console.Write("Storage preparation"); + ConsoleEx.Bold = false; + Console.Write(" First, we have to prepare your computer's storage device for ShiftOS. This \r\nincludes formatting your drive with the ShiftFS file \r\nsystem, creating system directories, and generating system files."); + Console.WriteLine(); + Console.Write(" - "); + ConsoleEx.Bold = true; + Console.Write("User configuration"); + ConsoleEx.Bold = false; + Console.Write(" Next it's up to you to set up a system hostname, create a user account, and personalize it."); + Console.WriteLine(); + Console.Write(" - "); + ConsoleEx.Bold = true; + Console.Write("System tutorial"); + ConsoleEx.Bold = false; + Console.WriteLine("Finally, we'll teach you how to use ShiftOS."); + + Console.WriteLine(); + + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Let's get started!"); + }); + int position = 0; + + Thread.Sleep(5000); + + ConsoleEx.Bold = true; + Console.WriteLine("System preparation"); + + + Console.WriteLine(); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.WriteLine(@"We'll now begin formatting your drive. Please be patient."); + Console.WriteLine(); + var dinf = new DriveInfo("C:\\"); + decimal bytesFree = ((dinf.AvailableFreeSpace / 1024) / 1024) / 1024; + decimal totalBytes = ((dinf.TotalSize / 1024) / 1024) / 1024; + string type = dinf.DriveType.ToString(); + string name = dinf.Name; + ConsoleEx.Bold = true; + Console.Write("Drive name: "); + ConsoleEx.Bold = false; + Console.WriteLine(name); + ConsoleEx.Bold = true; + Console.Write("Drive type: "); + ConsoleEx.Bold = false; + Console.WriteLine(type); + ConsoleEx.Bold = true; + Console.Write("Total space: "); + ConsoleEx.Bold = false; + Console.WriteLine(totalBytes.ToString() + " GB"); + ConsoleEx.Bold = true; + Console.Write("Free space: "); + Console.WriteLine(bytesFree.ToString() + " GB"); + Console.WriteLine(); + + + ConsoleEx.Bold = false; + ConsoleEx.BackgroundColor = ConsoleColor.Black; + Console.Write("Formatting: ["); + int formatProgress = 0; + while (formatProgress <= 100) + { + if (formatProgress % 3 == 0) + { + ConsoleEx.BackgroundColor = ConsoleColor.White; + Console.Write(" "); + ConsoleEx.BackgroundColor = ConsoleColor.Black; + } + Engine.AudioManager.PlayStream(Properties.Resources.typesound); + formatProgress++; + Thread.Sleep(175); + } + Console.WriteLine("] ..done."); + Thread.Sleep(1000); + ConsoleEx.Bold = true; + Console.WriteLine("Creating directories..."); + ConsoleEx.Bold = false; + foreach (var dir in Paths.GetAllWithoutKey()) + { + if (!dir.Contains(".") && dir.StartsWith("0:/")) + { + Console.WriteLine("Creating: " + dir); + Thread.Sleep(125); + Engine.AudioManager.PlayStream(Properties.Resources.writesound); + } + } + Console.WriteLine(); + Console.WriteLine("Next, let's get user information."); + Console.WriteLine(); + Console.WriteLine("Please enter a system hostname."); + string allowed_chars = "abcdefghijklmnopqrstuvwxyz1234567890_"; + bool userExists = false; + Applications.Terminal.TextSent += (text) => + { + if(position == 0) + { + if(text.Length < 5) + { + Console.WriteLine("Your hostname must be at least 5 characters long."); + return; + } + + if(!isValid(text, allowed_chars)) + { + Console.WriteLine("Your hostname contains illegal characters. You can only use these characters: " + allowed_chars); + return; + } + SaveSystem.CurrentSave.SystemName = text; + position = 1; + } + else if(position == 1) + { + if (text.Length < 5) + { + Console.WriteLine("Your username must be at least 5 characters long."); + return; + } + if (!isValid(text, allowed_chars)) + { + Console.WriteLine("Your username contains illegal characters. You can only use these characters: " + allowed_chars); + return; + } + SaveSystem.CurrentSave.Username = text; + position = 2; + } + else if(position == 3) + { + if (!userExists) + { + if (text.Length < 5) + { + Console.WriteLine("Your password must be at least 5 characters long."); + return; + } + SaveSystem.CurrentSave.Password = text; + position = 4; + } + else + { + ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new + { + username = SaveSystem.CurrentSave.Username, + password = text + })); + } + } + }; + + TerminalBackend.InStory = false; + + while (position == 0) + Thread.Sleep(10); + Console.WriteLine("Connecting to the multi-user domain as " + SaveSystem.CurrentSave.SystemName + "..."); + Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); + Console.WriteLine("Connection successful, system spinning up..."); + Thread.Sleep(200); + Console.WriteLine("No users associated with this system. Please enter a username."); + Console.WriteLine(" - If the username is registered as a digital being, you will be prompted for your password. Else, you will be prompted to create a new account."); + while(position == 1) + { + Thread.Sleep(10); + } + int incorrectChances = 2; + Console.WriteLine("Checking sentience records..."); + ServerManager.MessageReceived += (msg) => + { + if (position == 2) + { + if (msg.Name == "mud_found") + { + Console.WriteLine("Your username has been taken by another sentient being within the digital society."); + Console.WriteLine("If you are that sentience, you have two chances to type the correct password."); + userExists = true; + } + else if (msg.Name == "mud_notfound") + { + Console.WriteLine("Please enter a password for this new user."); + userExists = false; + } + position = 3; + } + else if (position == 3) + { + if(userExists == true) + { + if(msg.Name == "mud_savefile") + { + Console.WriteLine("Your sentience profile has been assigned to your system successfully. We will bring you to your system shortly."); + SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + position = 4; + } + else if(msg.Name == "mud_login_denied") + { + if (incorrectChances > 0) + { + incorrectChances--; + Console.WriteLine("Access denied. Chances: " + incorrectChances); + } + else + { + Console.WriteLine("Access denied."); + position = 2; + } + } + } + } + }; + ServerManager.SendMessage("mud_checkuserexists", JsonConvert.SerializeObject(new { username = SaveSystem.CurrentSave.Username })); + while(position == 2) + { + Thread.Sleep(10); + } + while (position == 3) + { + Thread.Sleep(10); + } + Console.WriteLine("Sentience linkup successful."); + Console.WriteLine("We will bring you to your system in 5 seconds."); + Thread.Sleep(5000); + Desktop.InvokeOnWorkerThread(() => + { + var lst = new List
(); + foreach (Form frm in Application.OpenForms) + lst.Add(frm); + lst.ForEach((frm) => + { + if (!(frm is WinformsDesktop)) + frm.Close(); + }); + TerminalBackend.PrefixEnabled = true; + + AppearanceManager.SetupWindow(new Applications.Terminal()); + }); + } + private static bool isValid(string text, string chars) + { + foreach(var c in text) + { + if (!chars.Contains(c)) + return false; + } + return true; + } + } +} diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 348360f..36c9338 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -64,12 +64,12 @@ namespace ShiftOS.WinForms { AppearanceManager.SetupWindow(new Applications.Terminal()); }; - AppearanceManager.Initiate(new WinformsWindowManager()); - OutOfBoxExperience.Init(new Oobe()); Infobox.Init(new Dialog()); FileSkimmerBackend.Init(new WinformsFSFrontend()); var desk = new WinformsDesktop(); Desktop.Init(desk); + OutOfBoxExperience.Init(new Oobe()); + AppearanceManager.Initiate(new WinformsWindowManager()); Application.Run(desk); } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index c18f456..c70f849 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -98,13 +98,6 @@ Category: "Enhancements", Description: "Wanna start all over with a new equation? With this CE (Clear Everything) button, you get rid of not only the numbers in the number field, but also the equation!" }, - { - Name: "MUD Fundamentals", - Cost: 50, - Description: "Some basic commands for the terminal that'll help you out in the multi-user domain.", - Category: "Kernel & System", - Dependencies: null - }, { Name: "AL Notifications", Cost: 150, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index a223f47..b9e6910 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -286,6 +286,7 @@ Oobe.cs + True True diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9ff3111..998c60d 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -120,7 +120,7 @@ namespace ShiftOS.Engine //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { - + Thread.Sleep(10); } Console.WriteLine("GUID received - bootstrapping complete."); FinishBootstrap(); @@ -133,7 +133,7 @@ namespace ShiftOS.Engine ServerManager.StartLANServer(); while (ServerManager.thisGuid == new Guid()) { - + Thread.Sleep(10); } Console.WriteLine("GUID received - bootstrapping complete."); FinishBootstrap(); @@ -172,7 +172,7 @@ namespace ShiftOS.Engine while (CurrentSave == null) { - + Thread.Sleep(10); } Localization.SetupTHETRUEDefaultLocals(); @@ -181,7 +181,7 @@ namespace ShiftOS.Engine while (CurrentSave.StoryPosition < 1) { - + Thread.Sleep(10); } Thread.Sleep(75); diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index ecd04f4..8c726ed 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -68,7 +68,7 @@ namespace ShiftOS.Engine } } } - catch { } + catch (Exception ex) { throw ex; } } } #if DEBUG -- cgit v1.2.3 From d4daa694e114db7c3306cb631e5e7f929f7f2fad Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 17 Apr 2017 19:13:58 +0000 Subject: Changes. --- ShiftOS.Server/SaveManager.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 56e8d50..52d665b 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -164,6 +164,8 @@ namespace ShiftOS.Server public static void SaveGame(string guid, object contents) { var sav = contents as Save; + if (string.IsNullOrWhiteSpace(sav.Username)) + return; sav.Username = sav.Username.ToLower(); WriteEncFile("saves/" + sav.Username + ".save", JsonConvert.SerializeObject(sav, Formatting.Indented)); -- 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') 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 baddaee3a88841fe6305f7d2f4923e46e97cc053 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 30 Apr 2017 15:44:29 +0000 Subject: Server-side linking to Unite --- ShiftOS.Objects/Save.cs | 2 ++ ShiftOS.Server/SaveManager.cs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index ef512eb..7208de5 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -45,6 +45,8 @@ namespace ShiftOS.Objects public int MinorVersion { get; set; } public int Revision { get; set; } + public string UniteAuthToken { get; set; } + public bool IsPatreon { get; set; } public UserClass Class { get; set; } diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 52d665b..41ca226 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -32,6 +32,7 @@ using System.IO; using Newtonsoft.Json; using NetSockets; using static ShiftOS.Server.Program; +using System.Net; namespace ShiftOS.Server { @@ -172,6 +173,9 @@ namespace ShiftOS.Server try { + + + Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage { Name = "mud_saved", @@ -179,6 +183,19 @@ namespace ShiftOS.Server })); } catch { } + + try + { + //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()); + wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken); + wreq.GetResponse(); + } + } + catch { } + } [MudRequest("delete_save", typeof(ClientSave))] -- cgit v1.2.3 From df12142c8113e2db9c848bfda20bd195673b7599 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 30 Apr 2017 16:01:48 +0000 Subject: Token logins. --- ShiftOS.Server/SaveManager.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 41ca226..63aa2bf 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -198,6 +198,47 @@ namespace ShiftOS.Server } + [MudRequest("mud_token_login", typeof(string))] + public static void TokenLogin(string guid, string token) + { + foreach (var savefile in Directory.GetFiles("saves")) + { + try + { + var save = JsonConvert.DeserializeObject(ReadEncFile(savefile)); + + + if (save.UniteAuthToken==token) + { + if (save.ID == new Guid()) + { + save.ID = Guid.NewGuid(); + WriteEncFile(savefile, JsonConvert.SerializeObject(save)); + } + + + Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage + { + Name = "mud_savefile", + GUID = "server", + Contents = JsonConvert.SerializeObject(save) + })); + return; + } + } + catch { } + } + try + { + Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage + { + Name = "mud_login_denied", + GUID = "server" + })); + } + catch { } + } + [MudRequest("delete_save", typeof(ClientSave))] public static void DeleteSave(string guid, object contents) { -- 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') 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 3665e073612ff72ad65d6184fd3c8c10c9ab5ab9 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Wed, 3 May 2017 18:10:11 +0000 Subject: Allow forwarding of messages to other clients. --- ShiftOS.Server/Core.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index e14ca27..7bb5b1d 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -38,6 +38,37 @@ namespace ShiftOS.Server { public static class Core { + [MudRequest("mud_forward", typeof(ServerMessage))] + public static void ForwardMessage(string guid, ServerMessage message) + { + if (message.GUID == "all") + { + Server.Program.server.DispatchAll(new NetObject("forward", new ServerMessage + { + Name = "forward", + GUID = "Server", + Contents = JsonConvert.SerializeObject(message) + })); + } + else + { + try + { + Server.Program.server.DispatchTo(new Guid(message.GUID), new NetObject("forward", new ServerMessage + { + Name = "forward", + GUID = "Server", + Contents = JsonConvert.SerializeObject(message) + })); + } + catch + { + + } + } + } + + [MudRequest("getguid_reply", typeof(string))] public static void GuidBounce(string guid, object contents) { -- 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') 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') 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 From 31cc9148dd23737df16d8456a42d003cd31dd488 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 21 May 2017 12:21:41 +0000 Subject: holy ashit --- .vs/config/applicationhost.config | 1030 ++++++++++++++++++++ ShiftOS.Objects/ShiftFS.cs | 37 +- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UserConfig.cs | 37 + ShiftOS.Server/SaveManager.cs | 17 +- .../Applications/FileSkimmer.Designer.cs | 11 +- ShiftOS.WinForms/Applications/FileSkimmer.cs | 69 +- ShiftOS.WinForms/Applications/Pong.Designer.cs | 769 --------------- ShiftOS.WinForms/Applications/Pong.cs | 977 ------------------- .../Applications/ShiftoriumFrontend.Designer.cs | 317 ------ .../Applications/ShiftoriumFrontend.cs | 274 ------ ShiftOS.WinForms/Applications/Skin Loader.cs | 342 ------- ShiftOS.WinForms/Applications/TriWrite.Designer.cs | 192 ---- ShiftOS.WinForms/Applications/TriWrite.cs | 76 -- ShiftOS.WinForms/Applications/TriWrite.resx | 108 +- ShiftOS.WinForms/Controls/TerminalBox.cs | 130 +++ .../DesktopWidgets/HeartbeatWidget.Designer.cs | 62 ++ ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs | 51 + .../DesktopWidgets/HeartbeatWidget.resx | 120 +++ ShiftOS.WinForms/GUILogin.Designer.cs | 135 +++ ShiftOS.WinForms/GUILogin.cs | 136 +++ ShiftOS.WinForms/GUILogin.resx | 120 +++ ShiftOS.WinForms/Oobe.cs | 4 + ShiftOS.WinForms/OobeStory.cs | 6 +- ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Resources/Shiftorium.txt | 7 + ShiftOS.WinForms/ShiftOS.WinForms.csproj | 34 +- ShiftOS.WinForms/UniteLoginDialog.cs | 3 +- ShiftOS.WinForms/UniteSignupDialog.cs | 3 +- ShiftOS.WinForms/WindowBorder.cs | 55 ++ ShiftOS_TheReturn/Commands.cs | 17 +- ShiftOS_TheReturn/LoginManager.cs | 65 ++ ShiftOS_TheReturn/SaveSystem.cs | 209 ++-- ShiftOS_TheReturn/ServerManager.cs | 16 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Skinning.cs | 16 + ShiftOS_TheReturn/UniteClient.cs | 12 +- ShiftOS_TheReturn/UserManagementCommands.cs | 113 +++ 38 files changed, 2506 insertions(+), 3067 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 ShiftOS.Objects/UserConfig.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs delete mode 100644 ShiftOS.WinForms/Applications/Skin Loader.cs delete mode 100644 ShiftOS.WinForms/Applications/TriWrite.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/TriWrite.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx create mode 100644 ShiftOS.WinForms/GUILogin.Designer.cs create mode 100644 ShiftOS.WinForms/GUILogin.cs create mode 100644 ShiftOS.WinForms/GUILogin.resx create mode 100644 ShiftOS_TheReturn/LoginManager.cs (limited to 'ShiftOS.Server') 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/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index c2121f0..45cdb14 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -32,23 +32,16 @@ using System.Threading; namespace ShiftOS.Objects.ShiftFS { - public enum Permissions - { - User, - Administrator, - Superuser, - All - } public class File { public string Name; public byte[] Data; public byte[] HeaderData; public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public System.IO.Stream GetStream() { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return new System.IO.MemoryStream(Data); } @@ -59,7 +52,7 @@ namespace ShiftOS.Objects.ShiftFS return null; } - public File(string name, byte[] data, bool ReadAccess_to_low_users, Permissions perm) + public File(string name, byte[] data, bool ReadAccess_to_low_users, UserPermissions perm) { Name = name; Data = data; @@ -73,31 +66,31 @@ namespace ShiftOS.Objects.ShiftFS public List Files = new List(); public List Subdirectories = new List(); public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public void AddFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Add(file); } } public void RemoveFile(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(Files.Find(x => x.Name == name)); } } public void RemoveFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(file); } } public File FindFileByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Files.Find(x => x.Name == name); } @@ -105,28 +98,28 @@ namespace ShiftOS.Objects.ShiftFS } public void AddDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Add(dir); } } public void RemoveDirectory(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(Subdirectories.Find(x => x.Name == name)); } } public void RemoveDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(dir); } } public Directory FindDirectoryByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Subdirectories.Find(x => x.Name == name); } @@ -136,7 +129,7 @@ namespace ShiftOS.Objects.ShiftFS public static class Utils { - public static Permissions CurrentUser { get; set; } + public static UserPermissions CurrentUser { get; set; } public static List Mounts { get; set; } @@ -232,7 +225,7 @@ namespace ShiftOS.Objects.ShiftFS { try { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, CurrentUser)); } catch { } } @@ -281,7 +274,7 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, CurrentUser)); } else { 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/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 63aa2bf..acf28a5 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(); } @@ -216,6 +216,21 @@ namespace ShiftOS.Server WriteEncFile(savefile, JsonConvert.SerializeObject(save)); } + try + { + var wr = System.Net.HttpWebRequest.Create("http://getshiftos.ml/API/GetCodepoints"); + wr.Headers.Add("Authentication: Token " + save.UniteAuthToken); + var response = wr.GetResponse(); + using (var rstr = response.GetResponseStream()) + { + using (var sreader = new StreamReader(rstr)) + { + long cp = Convert.ToInt64(sreader.ReadToEnd()); + save.Codepoints = cp; + } + } + } + catch { } Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index a7b7aa5..965e4eb 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -69,10 +69,10 @@ namespace ShiftOS.WinForms.Applications // // lvitems // - this.lvitems.Dock = System.Windows.Forms.DockStyle.Right; - this.lvitems.Location = new System.Drawing.Point(120, 0); + this.lvitems.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvitems.Location = new System.Drawing.Point(149, 0); this.lvitems.Name = "lvitems"; - this.lvitems.Size = new System.Drawing.Size(514, 332); + this.lvitems.Size = new System.Drawing.Size(485, 332); this.lvitems.TabIndex = 0; this.lvitems.UseCompatibleStateImageBehavior = false; this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged); @@ -81,8 +81,8 @@ namespace ShiftOS.WinForms.Applications // // panel1 // - this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lvitems); + this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lbcurrentfolder); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 24); @@ -95,8 +95,9 @@ namespace ShiftOS.WinForms.Applications this.pinnedItems.Dock = System.Windows.Forms.DockStyle.Left; this.pinnedItems.Location = new System.Drawing.Point(0, 0); this.pinnedItems.Name = "pinnedItems"; - this.pinnedItems.Size = new System.Drawing.Size(114, 332); + this.pinnedItems.Size = new System.Drawing.Size(149, 332); this.pinnedItems.TabIndex = 3; + this.pinnedItems.Click += new System.EventHandler(this.pinnedItems_Click); // // lbcurrentfolder // diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index 6309775..218e9e2 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -34,8 +34,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using static ShiftOS.Objects.ShiftFS.Utils; -using Newtonsoft.Json; using ShiftOS.Engine; +using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { @@ -129,8 +129,14 @@ namespace ShiftOS.WinForms.Applications { int amountsCalled = -1; amountsCalled = amountsCalled + 1; - pinnedItems.Nodes.Add(path); - pinnedItems.Nodes[amountsCalled].Nodes.Add("test"); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + Pinned.Add(path); + WriteAllText(Paths.GetPath("data") + "/pinned_items.dat", JsonConvert.SerializeObject(Pinned)); + ResetList(); } public void ChangeDirectory(string path) @@ -153,8 +159,40 @@ namespace ShiftOS.WinForms.Applications } } + public void PopulatePinned(TreeNode node, string[] items) + { + foreach(var dir in items) + { + var treenode = new TreeNode(); + if (DirectoryExists(dir)) + { + var dinf = GetDirectoryInfo(dir); + treenode.Text = dinf.Name; + } + else if (FileExists(dir)) + { + var finf = GetFileInfo(dir); + treenode.Text = finf.Name; + } + treenode.Tag = dir; + node.Nodes.Add(treenode); + } + } + public void ResetList() { + pinnedItems.Nodes.Clear(); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + var node = new TreeNode(); + node.Text = "Pinned"; + PopulatePinned(node, Pinned.ToArray()); + pinnedItems.Nodes.Add(node); + node.ExpandAll(); + if(lvitems.LargeImageList == null) { lvitems.LargeImageList = new ImageList(); @@ -423,14 +461,14 @@ namespace ShiftOS.WinForms.Applications { if (result == true) { - if (currentdir != "__system") + if (currentdir != "__system" && lvitems.SelectedItems[0].Text != "Up one") { pinDirectory(currentdir + "/" + lvitems.SelectedItems[0].Text); ResetList(); } else { - Infobox.Show("Cannot Pin", "You cannot pin a system drive."); + Infobox.Show("Cannot Pin", "You can only pin files or folders."); } } @@ -438,5 +476,26 @@ namespace ShiftOS.WinForms.Applications } catch { } } + + private void pinnedItems_Click(object sender, EventArgs e) + { + try + { + if (pinnedItems.SelectedNode != null) + { + string path = pinnedItems.SelectedNode.Tag.ToString(); + if (DirectoryExists(path)) + { + currentdir = path; + ResetList(); + } + else if (FileExists(path)) + { + FileSkimmerBackend.OpenFile(path); + } + } + } + catch { } + } } } diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs deleted file mode 100644 index b1186c6..0000000 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ /dev/null @@ -1,769 +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. - */ - - -/* - * 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 ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class Pong - { - /// - /// 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); - } - - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.gameTimer = new System.Windows.Forms.Timer(this.components); - this.counter = new System.Windows.Forms.Timer(this.components); - this.tmrcountdown = new System.Windows.Forms.Timer(this.components); - this.tmrstoryline = new System.Windows.Forms.Timer(this.components); - this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListView(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); - this.label10 = new System.Windows.Forms.Label(); - this.pnlgamestats = new System.Windows.Forms.Panel(); - this.button1 = new System.Windows.Forms.Button(); - this.label12 = new System.Windows.Forms.Label(); - this.lblnextstats = new System.Windows.Forms.Label(); - this.Label7 = new System.Windows.Forms.Label(); - this.lblpreviousstats = new System.Windows.Forms.Label(); - this.Label4 = new System.Windows.Forms.Label(); - this.btnplayon = new System.Windows.Forms.Button(); - this.Label3 = new System.Windows.Forms.Label(); - this.btncashout = new System.Windows.Forms.Button(); - this.Label2 = new System.Windows.Forms.Label(); - this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlfinalstats = new System.Windows.Forms.Panel(); - this.btnplayagain = new System.Windows.Forms.Button(); - this.lblfinalcodepoints = new System.Windows.Forms.Label(); - this.Label11 = new System.Windows.Forms.Label(); - this.lblfinalcomputerreward = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); - this.lblfinallevelreward = new System.Windows.Forms.Label(); - this.lblfinallevelreached = new System.Windows.Forms.Label(); - this.lblfinalcodepointswithtext = new System.Windows.Forms.Label(); - this.pnllose = new System.Windows.Forms.Panel(); - this.lblmissedout = new System.Windows.Forms.Label(); - this.lblbutyougained = new System.Windows.Forms.Label(); - this.btnlosetryagain = new System.Windows.Forms.Button(); - this.Label5 = new System.Windows.Forms.Label(); - this.Label1 = new System.Windows.Forms.Label(); - this.pnlintro = new System.Windows.Forms.Panel(); - this.Label6 = new System.Windows.Forms.Label(); - this.btnstartgame = new System.Windows.Forms.Button(); - this.Label8 = new System.Windows.Forms.Label(); - this.lblbeatai = new System.Windows.Forms.Label(); - this.lblcountdown = new System.Windows.Forms.Label(); - this.ball = new ShiftOS.WinForms.Controls.Canvas(); - this.paddleHuman = new System.Windows.Forms.PictureBox(); - this.paddleComputer = new System.Windows.Forms.Panel(); - this.lbllevelandtime = new System.Windows.Forms.Label(); - this.lblstatscodepoints = new System.Windows.Forms.Label(); - this.lblstatsY = new System.Windows.Forms.Label(); - this.lblstatsX = new System.Windows.Forms.Label(); - this.btnmatchmake = new System.Windows.Forms.Button(); - this.pgcontents.SuspendLayout(); - this.pnlhighscore.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); - this.pnlfinalstats.SuspendLayout(); - this.pnllose.SuspendLayout(); - this.pnlintro.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.SuspendLayout(); - // - // gameTimer - // - this.gameTimer.Interval = 30; - this.gameTimer.Tick += new System.EventHandler(this.gameTimer_Tick); - // - // counter - // - this.counter.Interval = 1000; - this.counter.Tick += new System.EventHandler(this.counter_Tick); - // - // tmrcountdown - // - this.tmrcountdown.Interval = 1000; - this.tmrcountdown.Tick += new System.EventHandler(this.countdown_Tick); - // - // tmrstoryline - // - this.tmrstoryline.Interval = 1000; - this.tmrstoryline.Tick += new System.EventHandler(this.tmrstoryline_Tick); - // - // pgcontents - // - this.pgcontents.BackColor = System.Drawing.Color.White; - this.pgcontents.Controls.Add(this.pnlintro); - this.pgcontents.Controls.Add(this.pnlhighscore); - this.pgcontents.Controls.Add(this.pnlgamestats); - this.pgcontents.Controls.Add(this.pnlfinalstats); - this.pgcontents.Controls.Add(this.pnllose); - this.pgcontents.Controls.Add(this.lblbeatai); - this.pgcontents.Controls.Add(this.lblcountdown); - this.pgcontents.Controls.Add(this.ball); - this.pgcontents.Controls.Add(this.paddleHuman); - this.pgcontents.Controls.Add(this.paddleComputer); - this.pgcontents.Controls.Add(this.lbllevelandtime); - this.pgcontents.Controls.Add(this.lblstatscodepoints); - this.pgcontents.Controls.Add(this.lblstatsY); - this.pgcontents.Controls.Add(this.lblstatsX); - this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.pgcontents.Location = new System.Drawing.Point(0, 0); - this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(912, 504); - this.pgcontents.TabIndex = 20; - this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); - this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(688, 302); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - this.lbhighscore.UseCompatibleStateImageBehavior = false; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlgamestats - // - this.pnlgamestats.Controls.Add(this.button1); - this.pnlgamestats.Controls.Add(this.label12); - this.pnlgamestats.Controls.Add(this.lblnextstats); - this.pnlgamestats.Controls.Add(this.Label7); - this.pnlgamestats.Controls.Add(this.lblpreviousstats); - this.pnlgamestats.Controls.Add(this.Label4); - this.pnlgamestats.Controls.Add(this.btnplayon); - this.pnlgamestats.Controls.Add(this.Label3); - this.pnlgamestats.Controls.Add(this.btncashout); - this.pnlgamestats.Controls.Add(this.Label2); - this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(104, 375); - this.pnlgamestats.Name = "pnlgamestats"; - this.pnlgamestats.Size = new System.Drawing.Size(466, 284); - this.pnlgamestats.TabIndex = 6; - this.pnlgamestats.Visible = false; - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(32, 223); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(191, 35); - this.button1.TabIndex = 10; - this.button1.Text = "{PONG_VIEW_HIGHSCORES}"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.btnhighscore_Click); - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(8, 187); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(245, 33); - this.label12.TabIndex = 9; - this.label12.Text = "{PONG_HIGHSCORE_EXP}"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblnextstats - // - this.lblnextstats.AutoSize = true; - this.lblnextstats.Location = new System.Drawing.Point(278, 136); - this.lblnextstats.Name = "lblnextstats"; - this.lblnextstats.Size = new System.Drawing.Size(0, 13); - this.lblnextstats.TabIndex = 8; - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label7.Location = new System.Drawing.Point(278, 119); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(124, 16); - this.Label7.TabIndex = 7; - this.Label7.Text = "Next Level Stats:"; - // - // lblpreviousstats - // - this.lblpreviousstats.AutoSize = true; - this.lblpreviousstats.Location = new System.Drawing.Point(278, 54); - this.lblpreviousstats.Name = "lblpreviousstats"; - this.lblpreviousstats.Size = new System.Drawing.Size(0, 13); - this.lblpreviousstats.TabIndex = 6; - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label4.Location = new System.Drawing.Point(278, 37); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(154, 16); - this.Label4.TabIndex = 5; - this.Label4.Text = "Previous Level Stats:"; - // - // btnplayon - // - this.btnplayon.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayon.Location = new System.Drawing.Point(32, 147); - this.btnplayon.Name = "btnplayon"; - this.btnplayon.Size = new System.Drawing.Size(191, 35); - this.btnplayon.TabIndex = 4; - this.btnplayon.Text = "Play on for 3 codepoints!"; - this.btnplayon.UseVisualStyleBackColor = true; - this.btnplayon.Click += new System.EventHandler(this.btnplayon_Click); - // - // Label3 - // - this.Label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label3.Location = new System.Drawing.Point(8, 111); - this.Label3.Name = "Label3"; - this.Label3.Size = new System.Drawing.Size(245, 33); - this.Label3.TabIndex = 3; - this.Label3.Text = "{PONG_PLAYON_DESC}"; - this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btncashout - // - this.btncashout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btncashout.Location = new System.Drawing.Point(32, 73); - this.btncashout.Name = "btncashout"; - this.btncashout.Size = new System.Drawing.Size(191, 35); - this.btncashout.TabIndex = 2; - this.btncashout.Text = "Cash out with 1 codepoint!"; - this.btncashout.UseVisualStyleBackColor = true; - this.btncashout.Click += new System.EventHandler(this.btncashout_Click); - // - // Label2 - // - this.Label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label2.Location = new System.Drawing.Point(8, 37); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(245, 33); - this.Label2.TabIndex = 1; - this.Label2.Text = "{PONG_CASHOUT_DESC}"; - this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbllevelreached - // - this.lbllevelreached.AutoSize = true; - this.lbllevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelreached.Location = new System.Drawing.Point(149, 6); - this.lbllevelreached.Name = "lbllevelreached"; - this.lbllevelreached.Size = new System.Drawing.Size(185, 20); - this.lbllevelreached.TabIndex = 0; - this.lbllevelreached.Text = "You Reached Level 2!"; - // - // pnlfinalstats - // - this.pnlfinalstats.Controls.Add(this.btnplayagain); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepoints); - this.pnlfinalstats.Controls.Add(this.Label11); - this.pnlfinalstats.Controls.Add(this.lblfinalcomputerreward); - this.pnlfinalstats.Controls.Add(this.Label9); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreward); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreached); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepointswithtext); - this.pnlfinalstats.Location = new System.Drawing.Point(172, 74); - this.pnlfinalstats.Name = "pnlfinalstats"; - this.pnlfinalstats.Size = new System.Drawing.Size(362, 226); - this.pnlfinalstats.TabIndex = 9; - this.pnlfinalstats.Visible = false; - // - // btnplayagain - // - this.btnplayagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayagain.Location = new System.Drawing.Point(5, 194); - this.btnplayagain.Name = "btnplayagain"; - this.btnplayagain.Size = new System.Drawing.Size(352, 29); - this.btnplayagain.TabIndex = 16; - this.btnplayagain.Text = "{PLAY}"; - this.btnplayagain.UseVisualStyleBackColor = true; - this.btnplayagain.Click += new System.EventHandler(this.btnplayagain_Click); - // - // lblfinalcodepoints - // - this.lblfinalcodepoints.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepoints.Location = new System.Drawing.Point(3, 124); - this.lblfinalcodepoints.Name = "lblfinalcodepoints"; - this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); - this.lblfinalcodepoints.TabIndex = 15; - this.lblfinalcodepoints.Tag = "header1"; - this.lblfinalcodepoints.Text = "134 CP"; - this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label11 - // - this.Label11.AutoSize = true; - this.Label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label11.Location = new System.Drawing.Point(162, 82); - this.Label11.Name = "Label11"; - this.Label11.Size = new System.Drawing.Size(33, 33); - this.Label11.TabIndex = 14; - this.Label11.Tag = "header2"; - this.Label11.Text = "+"; - this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcomputerreward - // - this.lblfinalcomputerreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcomputerreward.Location = new System.Drawing.Point(193, 72); - this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; - this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); - this.lblfinalcomputerreward.TabIndex = 12; - this.lblfinalcomputerreward.Tag = "header2"; - this.lblfinalcomputerreward.Text = "34"; - this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label9 - // - this.Label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label9.Location = new System.Drawing.Point(179, 31); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(180, 49); - this.Label9.TabIndex = 11; - this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreward - // - this.lblfinallevelreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreward.Location = new System.Drawing.Point(12, 72); - this.lblfinallevelreward.Name = "lblfinallevelreward"; - this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); - this.lblfinallevelreward.TabIndex = 10; - this.lblfinallevelreward.Tag = "header2"; - this.lblfinallevelreward.Text = "100"; - this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreached - // - this.lblfinallevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreached.Location = new System.Drawing.Point(3, 31); - this.lblfinallevelreached.Name = "lblfinallevelreached"; - this.lblfinallevelreached.Size = new System.Drawing.Size(170, 49); - this.lblfinallevelreached.TabIndex = 9; - this.lblfinallevelreached.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcodepointswithtext - // - this.lblfinalcodepointswithtext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepointswithtext.Location = new System.Drawing.Point(3, 2); - this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; - this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); - this.lblfinalcodepointswithtext.TabIndex = 1; - this.lblfinalcodepointswithtext.Tag = "header2"; - this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; - this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // pnllose - // - this.pnllose.Controls.Add(this.lblmissedout); - this.pnllose.Controls.Add(this.lblbutyougained); - this.pnllose.Controls.Add(this.btnlosetryagain); - this.pnllose.Controls.Add(this.Label5); - this.pnllose.Controls.Add(this.Label1); - this.pnllose.Location = new System.Drawing.Point(209, 71); - this.pnllose.Name = "pnllose"; - this.pnllose.Size = new System.Drawing.Size(266, 214); - this.pnllose.TabIndex = 10; - this.pnllose.Visible = false; - // - // lblmissedout - // - this.lblmissedout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblmissedout.Location = new System.Drawing.Point(3, 175); - this.lblmissedout.Name = "lblmissedout"; - this.lblmissedout.Size = new System.Drawing.Size(146, 35); - this.lblmissedout.TabIndex = 3; - this.lblmissedout.Text = "You Missed Out On: 500 Codepoints"; - this.lblmissedout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblbutyougained - // - this.lblbutyougained.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbutyougained.Location = new System.Drawing.Point(3, 125); - this.lblbutyougained.Name = "lblbutyougained"; - this.lblbutyougained.Size = new System.Drawing.Size(146, 35); - this.lblbutyougained.TabIndex = 3; - this.lblbutyougained.Text = "But you gained 5 Codepoints"; - this.lblbutyougained.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnlosetryagain - // - this.btnlosetryagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnlosetryagain.Location = new System.Drawing.Point(155, 176); - this.btnlosetryagain.Name = "btnlosetryagain"; - this.btnlosetryagain.Size = new System.Drawing.Size(106, 35); - this.btnlosetryagain.TabIndex = 2; - this.btnlosetryagain.Text = "Try Again"; - this.btnlosetryagain.UseVisualStyleBackColor = true; - this.btnlosetryagain.Click += new System.EventHandler(this.btnlosetryagain_Click); - // - // Label5 - // - this.Label5.Location = new System.Drawing.Point(7, 26); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(260, 163); - this.Label5.TabIndex = 1; - // - // Label1 - // - this.Label1.Dock = System.Windows.Forms.DockStyle.Top; - this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label1.Location = new System.Drawing.Point(0, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(266, 16); - this.Label1.TabIndex = 0; - this.Label1.Text = "You lose!"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlintro - // - this.pnlintro.Controls.Add(this.btnmatchmake); - this.pnlintro.Controls.Add(this.Label6); - this.pnlintro.Controls.Add(this.btnstartgame); - this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(0, 0); - this.pnlintro.Name = "pnlintro"; - this.pnlintro.Size = new System.Drawing.Size(595, 303); - this.pnlintro.TabIndex = 13; - this.pnlintro.Tag = "header2"; - // - // Label6 - // - this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label6.Location = new System.Drawing.Point(3, 39); - this.Label6.Name = "Label6"; - this.Label6.Size = new System.Drawing.Size(589, 159); - this.Label6.TabIndex = 15; - this.Label6.Text = "{PONG_DESC}"; - this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.Label6.Click += new System.EventHandler(this.Label6_Click); - // - // btnstartgame - // - this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnstartgame.Location = new System.Drawing.Point(188, 215); - this.btnstartgame.Name = "btnstartgame"; - this.btnstartgame.Size = new System.Drawing.Size(242, 28); - this.btnstartgame.TabIndex = 15; - this.btnstartgame.Text = "{PLAY}"; - this.btnstartgame.UseVisualStyleBackColor = true; - this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click); - // - // Label8 - // - this.Label8.AutoSize = true; - this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label8.ForeColor = System.Drawing.Color.Black; - this.Label8.Location = new System.Drawing.Point(250, 5); - this.Label8.Name = "Label8"; - this.Label8.Size = new System.Drawing.Size(280, 31); - this.Label8.TabIndex = 14; - this.Label8.Text = "{PONG_WELCOME}"; - this.Label8.Click += new System.EventHandler(this.Label8_Click); - // - // lblbeatai - // - this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbeatai.Location = new System.Drawing.Point(47, 41); - this.lblbeatai.Name = "lblbeatai"; - this.lblbeatai.Size = new System.Drawing.Size(600, 30); - this.lblbeatai.TabIndex = 8; - this.lblbeatai.Tag = "header2"; - this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; - this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblbeatai.Visible = false; - // - // lblcountdown - // - this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblcountdown.Location = new System.Drawing.Point(182, 152); - this.lblcountdown.Name = "lblcountdown"; - this.lblcountdown.Size = new System.Drawing.Size(315, 49); - this.lblcountdown.TabIndex = 7; - this.lblcountdown.Text = "3"; - this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblcountdown.Visible = false; - // - // ball - // - this.ball.BackColor = System.Drawing.Color.Black; - this.ball.Location = new System.Drawing.Point(300, 152); - this.ball.Name = "ball"; - this.ball.Size = new System.Drawing.Size(20, 20); - this.ball.TabIndex = 2; - this.ball.MouseEnter += new System.EventHandler(this.ball_MouseEnter); - this.ball.MouseLeave += new System.EventHandler(this.ball_MouseLeave); - // - // paddleHuman - // - this.paddleHuman.BackColor = System.Drawing.Color.Black; - this.paddleHuman.Location = new System.Drawing.Point(10, 134); - this.paddleHuman.Name = "paddleHuman"; - this.paddleHuman.Size = new System.Drawing.Size(20, 100); - this.paddleHuman.TabIndex = 3; - this.paddleHuman.TabStop = false; - // - // paddleComputer - // - this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(878, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - this.paddleComputer.Name = "paddleComputer"; - this.paddleComputer.Size = new System.Drawing.Size(20, 100); - this.paddleComputer.TabIndex = 1; - // - // lbllevelandtime - // - this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; - this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); - this.lbllevelandtime.Name = "lbllevelandtime"; - this.lbllevelandtime.Size = new System.Drawing.Size(912, 22); - this.lbllevelandtime.TabIndex = 4; - this.lbllevelandtime.Tag = "header1"; - this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; - this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatscodepoints - // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatscodepoints.AutoSize = true; - this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 460); - this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23); - this.lblstatscodepoints.TabIndex = 12; - this.lblstatscodepoints.Tag = "header2"; - this.lblstatscodepoints.Text = "Codepoints: "; - this.lblstatscodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsY - // - this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatsY.AutoSize = true; - this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsY.Location = new System.Drawing.Point(440, 460); - this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(76, 23); - this.lblstatsY.TabIndex = 11; - this.lblstatsY.Tag = "header2"; - this.lblstatsY.Text = "Yspeed:"; - this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatsX - // - this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lblstatsX.AutoSize = true; - this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatsX.Location = new System.Drawing.Point(3, 460); - this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(83, 23); - this.lblstatsX.TabIndex = 5; - this.lblstatsX.Tag = "header2"; - this.lblstatsX.Text = "Xspeed: "; - this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnmatchmake - // - this.btnmatchmake.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnmatchmake.Location = new System.Drawing.Point(188, 253); - this.btnmatchmake.Name = "btnmatchmake"; - this.btnmatchmake.Size = new System.Drawing.Size(242, 28); - this.btnmatchmake.TabIndex = 16; - this.btnmatchmake.Text = "Or, play against another Shifter!"; - this.btnmatchmake.UseVisualStyleBackColor = true; - this.btnmatchmake.Click += new System.EventHandler(this.btnmatchmake_Click); - // - // Pong - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pgcontents); - this.DoubleBuffered = true; - this.Name = "Pong"; - this.Size = new System.Drawing.Size(912, 504); - this.Load += new System.EventHandler(this.Pong_Load); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - this.pgcontents.ResumeLayout(false); - this.pgcontents.PerformLayout(); - this.pnlhighscore.ResumeLayout(false); - this.pnlhighscore.PerformLayout(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); - this.pnlfinalstats.ResumeLayout(false); - this.pnlfinalstats.PerformLayout(); - this.pnllose.ResumeLayout(false); - this.pnlintro.ResumeLayout(false); - this.pnlintro.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); - this.ResumeLayout(false); - - } - internal System.Windows.Forms.Panel paddleComputer; - internal System.Windows.Forms.Timer gameTimer; - internal System.Windows.Forms.PictureBox paddleHuman; - internal System.Windows.Forms.Label lbllevelandtime; - internal System.Windows.Forms.Label lblstatsX; - internal System.Windows.Forms.Timer counter; - internal System.Windows.Forms.Panel pnlgamestats; - internal System.Windows.Forms.Label lblnextstats; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.Label lblpreviousstats; - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.Button btnplayon; - internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.Button btncashout; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label lbllevelreached; - internal System.Windows.Forms.Label lblcountdown; - internal System.Windows.Forms.Timer tmrcountdown; - internal System.Windows.Forms.Label lblbeatai; - internal System.Windows.Forms.Panel pnlfinalstats; - internal System.Windows.Forms.Button btnplayagain; - internal System.Windows.Forms.Label lblfinalcodepoints; - internal System.Windows.Forms.Label Label11; - internal System.Windows.Forms.Label lblfinalcomputerreward; - internal System.Windows.Forms.Label Label9; - internal System.Windows.Forms.Label lblfinallevelreward; - internal System.Windows.Forms.Label lblfinallevelreached; - internal System.Windows.Forms.Label lblfinalcodepointswithtext; - internal System.Windows.Forms.Panel pnllose; - internal System.Windows.Forms.Label lblmissedout; - internal System.Windows.Forms.Label lblbutyougained; - internal System.Windows.Forms.Button btnlosetryagain; - internal System.Windows.Forms.Label Label5; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Label lblstatscodepoints; - internal System.Windows.Forms.Label lblstatsY; - internal System.Windows.Forms.Panel pnlintro; - internal System.Windows.Forms.Label Label6; - internal System.Windows.Forms.Button btnstartgame; - internal System.Windows.Forms.Label Label8; - internal System.Windows.Forms.Timer tmrstoryline; - private System.Windows.Forms.Panel pnlhighscore; - private System.Windows.Forms.ListView lbhighscore; - private System.Windows.Forms.Label label10; - internal Canvas pgcontents; - internal Canvas ball; - internal System.Windows.Forms.Button button1; - internal System.Windows.Forms.Label label12; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.Button button2; - internal System.Windows.Forms.Button btnmatchmake; - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs deleted file mode 100644 index 585639a..0000000 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ /dev/null @@ -1,977 +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; -using ShiftOS.Objects; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [MultiplayerOnly] - [Launcher("Pong", true, "al_pong", "Games")] - [WinOpen("pong")] - [DefaultIcon("iconPong")] - public partial class Pong : UserControl, IShiftOSWindow - { - //I can assure you guaranteed that there is an acorn somewhere, in this place, and the sailors are looking for it - int xVel = 7; - int yVel = 8; - int computerspeed = 8; - int level = 1; - int secondsleft = 60; - int casualposition; - double xveldec = 3.0; - double yveldec = 3.0; - double incrementx = 0.4; - double incrementy = 0.2; - int levelxspeed = 3; - int levelyspeed = 3; - int beatairewardtotal; - int beataireward = 1; - int[] levelrewards = new int[50]; - int totalreward; - int countdown = 3; - - bool aiShouldIsbeEnabled = true; - - public Pong() - { - InitializeComponent(); - } - - private void Pong_Load(object sender, EventArgs e) - { - setuplevelrewards(); - } - - - - // Move the paddle according to the mouse position. - private void pongMain_MouseMove(object sender, MouseEventArgs e) - { - var loc = this.PointToClient(MousePosition); - if (IsMultiplayerSession) - { - if (IsLeader) - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleHuman.Top.ToString()); - } - else - { - paddleComputer.Location = new Point(paddleComputer.Location.X, (loc.Y) - (paddleComputer.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleComputer.Top.ToString()); - } - } - else - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - } - } - - private void CenterPanels() - { - pnlfinalstats.CenterParent(); - pnlgamestats.CenterParent(); - pnlhighscore.CenterParent(); - pnlintro.CenterParent(); - pnllose.CenterParent(); - lblcountdown.CenterParent(); - lblbeatai.Left = (this.Width - lblbeatai.Width) / 2; - SetupStats(); - } - - public void SetupStats() - { - lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5); - lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5); - lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5; - lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2; - } - - int OpponentY = 0; - - bool IsLeader = false; - - int LeaderX = 0; - int LeaderY = 0; - - // ERROR: Handles clauses are not supported in C# - private void gameTimer_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - ball.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleComputer.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - - //Check if paddle upgrade has been bought and change paddles accordingly - //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) - //{ - // paddleHuman.Height = 150; - // paddleComputer.Height = 150; - //} - //I don't know the point of this but I'm fucking 86ing it. - Michael - - //Set the computer player to move according to the ball's position. - if (IsMultiplayerSession == true) - { - //If we're multiplayer, then we want to set the computer Y to the opponent's Y. - //If we're the leader, we set the AI paddle, else we set the player paddle. - if (IsLeader) - paddleComputer.Top = OpponentY; - else - paddleHuman.Top = OpponentY; - } - else - { - if (aiShouldIsbeEnabled) - if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) - { - if (ball.Location.Y > paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - if (ball.Location.Y < paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - casualposition = rand.Next(-150, 201); - } - else - { - //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael - if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - //Rylan is hot. Used to be //used to be me.location.y - if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - } - } - //Set Xvel and Yvel speeds from decimal - if (xVel > 0) - xVel = (int)Math.Round(xveldec); - if (xVel < 0) - xVel = (int)-Math.Round(xveldec); - if (yVel > 0) - yVel = (int)Math.Round(yveldec); - if (yVel < 0) - yVel = (int)-Math.Round(yveldec); - - bool BallPhysics = true; - - if (IsMultiplayerSession) - { - //Logic for moving the ball in Multiplayer. - if (IsLeader) - { - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - else - { - //Move it to the leader's ball position. - ball.Location = new Point(LeaderX, LeaderY); - BallPhysics = false; - } - } - else - {// Move the game ball. - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - if (BallPhysics) - { - // Check for top wall. - if (ball.Location.Y < 0) - { - ball.Location = new Point(ball.Location.X, 0); - yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - } - - // Check for bottom wall. - if (ball.Location.Y > pgcontents.Height - ball.Height) - { - ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height); - yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - } - - - // Check for player paddle. - if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) - { - ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, ball.Location.Y); - //randomly increase x or y speed of ball - switch (rand.Next(1, 3)) - { - case 1: - xveldec = xveldec + incrementx; - break; - case 2: - if (yveldec > 0) - yveldec = yveldec + incrementy; - if (yveldec < 0) - yveldec = yveldec - incrementy; - break; - } - xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); - - } - - // Check for computer paddle. - if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) - { - ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width - 1, ball.Location.Y); - xveldec = xveldec + incrementx; - xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); - } - } - - - - // Check for left wall. - if (ball.Location.X < -100) - { - //If we are in multiplayer, and not the leader, we won. - if (IsMultiplayerSession) - { - if (IsLeader) - { - //We lost. - NotifyLoseToTarget(); - } - else - { - //We won. - NotifyWinToTarget(); - Win(); - } - } - else - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - pnllose.Show(); - gameTimer.Stop(); - counter.Stop(); - lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) - { - totalreward = levelrewards[level - 1] + beatairewardtotal; - double onePercent = (totalreward / 100); - lblbutyougained.Show(); - lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100)); - } - else - { - lblbutyougained.Hide(); - } - } - } - - // Check for right wall. - if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100) - { - if (IsMultiplayerSession) - { - //If we are the leader we won. - if (IsLeader) - { - NotifyWinToTarget(); - Win(); - } - else - { - NotifyLoseToTarget(); - } - } - else - { - Win(); - } - } - - if (IsMultiplayerSession) - { - if (IsLeader) - { - ServerManager.Forward(OpponentGUID, "pong_mp_setballpos", JsonConvert.SerializeObject(ball.Location)); - } - } - - if (IsLeader) - { - //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy - lblstatsX.Text = Localization.Parse("{H_VEL}: ") + xveldec; - lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - - if (xVel > 20 || xVel < -20) - { - paddleHuman.Width = Math.Abs(xVel); - paddleComputer.Width = Math.Abs(xVel); - } - else - { - paddleHuman.Width = 20; - paddleComputer.Width = 20; - } - } - if (!IsMultiplayerSession) - { - computerspeed = Math.Abs(yVel); - } - } - } - - public void ServerMessageReceivedHandler(ServerMessage msg) - { - if(msg.Name == "pong_mp_setballpos") - { - var pt = JsonConvert.DeserializeObject(msg.Contents); - LeaderX = pt.X; - LeaderY = pt.Y; - } - else if(msg.Name == "pong_mp_youlose") - { - LoseMP(); - } - else if(msg.Name == "pong_mp_setopponenty") - { - int y = Convert.ToInt32(msg.Contents); - OpponentY = y; - } - else if(msg.Name == "pong_handshake_matchmake") - { - PossibleMatchmakes.Add(msg.Contents); - } - else if(msg.Name == "pong_handshake_complete") - { - LeaveMatchmake(); - StartLevel(); - } - else if(msg.Name == "pong_handshake_giveleaderid") - { - IsLeader = false; - OpponentGUID = msg.Contents; - YouGUID = ServerManager.thisGuid.ToString(); - SendFollowerGUID(); - } - else if(msg.Name == "pong_handshake_left") - { - if (this.PossibleMatchmakes.Contains(msg.Contents)) - this.PossibleMatchmakes.Remove(msg.Contents); - } - else if(msg.Name == "pong_handshake_setfollowerguid") - { - IsLeader = false; - OpponentGUID = msg.Contents; - } - else if(msg.Name == "pong_mp_youwin") - { - Win(); - } - } - - public void NotifyLoseToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youwin", null); - } - - public void NotifyWinToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youlose", null); - } - - public void LeaveMatchmake() - { - ServerManager.Forward("all", "pong_handshake_left", YouGUID); - } - - List PossibleMatchmakes = new List(); - - public void SendLeaderGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_giveleaderid", YouGUID); - } - - - public void StartMultiplayer() - { - IsMultiplayerSession = true; - YouGUID = ServerManager.thisGuid.ToString(); - ServerManager.SendMessage("pong_handshake_matchmake", YouGUID); - } - - - public void SendFollowerGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_setfollowerguid", YouGUID); - } - - public void LoseMP() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - if(IsLeader) - if (xVel > 0) - xVel = -xVel; - lblbeatai.Show(); - lblbeatai.Text = "The opponent has beaten you!"; - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - public void Win() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - beatairewardtotal = beatairewardtotal + beataireward; - lblbeatai.Show(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}"); - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - // ERROR: Handles clauses are not supported in C# - private void counter_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - secondsleft = secondsleft - 1; - if (secondsleft == 1) - { - secondsleft = 60; - level = level + 1; - if (SaveSystem.CurrentSave.UniteAuthToken != null) - { - try - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongLevel() < level) - unite.SetPongLevel(level); - } - catch { } - } - generatenextlevel(); - pnlgamestats.Show(); - pnlgamestats.BringToFront(); - pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2)); - - counter.Stop(); - gameTimer.Stop(); - SendHighscores(); - } - - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - } - SetupStats(); - } - - [Obsolete("This method does nothing. Use UniteClient for highscore queries.")] - public void SendHighscores() - { - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayon_Click(object sender, EventArgs e) - { - xveldec = levelxspeed; - yveldec = levelyspeed; - - secondsleft = 60; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, paddleHuman.Location.Y + paddleHuman.Height / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - //Increase the ball speed stats for the next level - private void generatenextlevel() - { - lbllevelreached.Text = Localization.Parse("{YOU_REACHED_LEVEL} " + level + "!"); - - lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - switch (rand.Next(1, 3)) - { - case 1: - levelxspeed = levelxspeed + 1; - break; - case 2: - levelxspeed = levelxspeed + 2; - break; - } - - switch (rand.Next(1, 3)) - { - case 1: - levelyspeed = levelyspeed + 1; - break; - case 2: - levelyspeed = levelyspeed + 2; - break; - } - - switch (rand.Next(1, 6)) - { - case 1: - incrementx = incrementx + 0.1; - break; - case 2: - incrementx = incrementx + 0.2; - break; - case 3: - incrementy = incrementy + 0.1; - break; - case 4: - incrementy = incrementy + 0.2; - break; - case 5: - incrementy = incrementy + 0.3; - break; - } - - lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - if (level < 15) - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = level * 10; - } else - { - beataireward = level * 5; - } - } - else - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; - } else - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; - } - } - - totalreward = levelrewards[level - 1] + beatairewardtotal; - - btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); - btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); - } - - private void setuplevelrewards() - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - levelrewards[0] = 0; - levelrewards[1] = 40; - levelrewards[2] = 120; - levelrewards[3] = 280; - levelrewards[4] = 580; - levelrewards[5] = 800; - levelrewards[6] = 1200; - levelrewards[7] = 1800; - levelrewards[8] = 2400; - levelrewards[9] = 3200; - levelrewards[10] = 4000; - levelrewards[11] = 5000; - levelrewards[12] = 6000; - levelrewards[13] = 8000; - levelrewards[14] = 10000; - levelrewards[15] = 12000; - levelrewards[16] = 16000; - levelrewards[17] = 20000; - levelrewards[18] = 26000; - levelrewards[19] = 32000; - levelrewards[20] = 40000; - levelrewards[21] = 50000; - levelrewards[22] = 64000; - levelrewards[23] = 80000; - levelrewards[24] = 100000; - levelrewards[25] = 120000; - levelrewards[26] = 150000; - levelrewards[27] = 180000; - levelrewards[28] = 220000; - levelrewards[29] = 280000; - levelrewards[30] = 360000; - levelrewards[31] = 440000; - levelrewards[32] = 540000; - levelrewards[33] = 640000; - levelrewards[34] = 800000; - levelrewards[35] = 1000000; - levelrewards[36] = 1280000; - levelrewards[37] = 1600000; - levelrewards[38] = 2000000; - levelrewards[39] = 3000000; - levelrewards[40] = 4000000; - } else - { - levelrewards[0] = 0; - levelrewards[1] = 20; - levelrewards[2] = 60; - levelrewards[3] = 140; - levelrewards[4] = 290; - levelrewards[5] = 400; - levelrewards[6] = 600; - levelrewards[7] = 900; - levelrewards[8] = 1200; - levelrewards[9] = 1600; - levelrewards[10] = 2000; - levelrewards[11] = 2500; - levelrewards[12] = 3000; - levelrewards[13] = 4000; - levelrewards[14] = 5000; - levelrewards[15] = 6000; - levelrewards[16] = 8000; - levelrewards[17] = 10000; - levelrewards[18] = 13000; - levelrewards[19] = 16000; - levelrewards[20] = 20000; - levelrewards[21] = 25000; - levelrewards[22] = 32000; - levelrewards[23] = 40000; - levelrewards[24] = 50000; - levelrewards[25] = 60000; - levelrewards[26] = 75000; - levelrewards[27] = 90000; - levelrewards[28] = 110000; - levelrewards[29] = 140000; - levelrewards[30] = 180000; - levelrewards[31] = 220000; - levelrewards[32] = 270000; - levelrewards[33] = 320000; - levelrewards[34] = 400000; - levelrewards[35] = 500000; - levelrewards[36] = 640000; - levelrewards[37] = 800000; - levelrewards[38] = 1000000; - levelrewards[39] = 1500000; - levelrewards[40] = 2000000; - } - } - - // ERROR: Handles clauses are not supported in C# - private void countdown_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - switch (countdown) - { - case 0: - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - break; - case 1: - lblcountdown.Text = "1"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 2: - lblcountdown.Text = "2"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 3: - lblcountdown.Text = "3"; - countdown = countdown - 1; - lblcountdown.Show(); - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - } - - } - } - - // ERROR: Handles clauses are not supported in C# - private void btncashout_Click(object sender, EventArgs e) - { - pnlgamestats.Hide(); - pnlfinalstats.Show(); - lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); - lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = levelrewards[level - 1].ToString(); - lblfinalcomputerreward.Text = beatairewardtotal.ToString(); - lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); - SaveSystem.TransferCodepointsFrom("pong", totalreward); - if (!string.IsNullOrWhiteSpace(SaveSystem.CurrentSave.UniteAuthToken)) - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongCP() < totalreward) - { - unite.SetPongCP(totalreward); - } - } - } - - private void newgame() - { - pnlfinalstats.Hide(); - pnllose.Hide(); - pnlintro.Hide(); - - level = 1; - totalreward = 0; - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = 10; - } else - { - beataireward = 5; - } - beatairewardtotal = 0; - secondsleft = 60; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: "); - //reset stats text - lblstatsX.Text = Localization.Parse("{H_VEL}: "); - lblstatsY.Text = Localization.Parse("{V_VEL}: "); - - levelxspeed = 3; - levelyspeed = 3; - - incrementx = 0.4; - incrementy = 0.2; - - xveldec = levelxspeed; - yveldec = levelyspeed; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, (paddleHuman.Location.Y + paddleHuman.Height) / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{{LEVEL}}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - public void btnhighscore_Click(object s, EventArgs a) - { - pnlhighscore.BringToFront(); - SetupHighScores(); - } - - bool IsMultiplayerSession = false; - - string YouGUID = ""; - string OpponentGUID = ""; - - public void SetupHighScores() - { - lbhighscore.Items.Clear(); - lbhighscore.View = View.Details; - lbhighscore.FullRowSelect = true; - lbhighscore.Columns.Clear(); - var n = new ColumnHeader(); - n.Text = "Player"; - n.Width = lbhighscore.Width / 3; - var l = new ColumnHeader(); - l.Text = "Level"; - l.Width = n.Width; - var c = new ColumnHeader(); - c.Text = "Codepoints"; - c.Width = n.Width; - lbhighscore.Columns.Add(n); - lbhighscore.Columns.Add(l); - lbhighscore.Columns.Add(c); - - var t = new Thread(() => - { - try - { - - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - var hs = unite.GetPongHighscores(); - foreach (var score in hs.Highscores) - { - string username = unite.GetDisplayNameId(score.UserId); - this.Invoke(new Action(() => - { - var name_item = new ListViewItem(); - name_item.Text = username; - lbhighscore.Items.Add(name_item); - name_item.SubItems.Add(score.Level.ToString()); - name_item.SubItems.Add(score.CodepointsCashout.ToString()); - })); - } - } - catch - { - Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); - this.Invoke(new Action(pnlgamestats.BringToFront)); - return; - } - }); - t.Start(); - pnlhighscore.Show(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayagain_Click(object sender, EventArgs e) - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnlosetryagain_Click(object sender, EventArgs e) - { - newgame(); - } - - public void StartLevel() - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnstartgame_Click(object sender, EventArgs e) - { - newgame(); - } - - Random rand = new Random(); - // ERROR: Handles clauses are not supported in C# - private void tmrstoryline_Tick(object sender, EventArgs e) - { - // Random chance of showing getshiftnet storyline - int i = rand.Next(0, 100); - - if (i >= 25 && i <= 50) - { - tmrstoryline.Stop(); - } - - } - - // ERROR: Handles clauses are not supported in C# - private void me_closing(object sender, FormClosingEventArgs e) - { - tmrstoryline.Stop(); - } - - private void Label6_Click(object sender, EventArgs e) - { - - } - - private void Label8_Click(object sender, EventArgs e) - { - - } - - private void pgcontents_Paint(object sender, PaintEventArgs e) { - - } - - private void ball_MouseEnter(object sender, EventArgs e) { - aiShouldIsbeEnabled = false; - } - - private void ball_MouseLeave(object sender, EventArgs e) { - aiShouldIsbeEnabled = true; - } - - public void OnLoad() - { - pnlintro.BringToFront(); - pnlintro.Show(); - pnlhighscore.Hide(); - pnlgamestats.Hide(); - pnlfinalstats.Hide(); - CenterPanels(); - lblbeatai.Hide(); - } - - public void OnSkinLoad() - { - CenterPanels(); - this.SizeChanged += (o, a) => - { - CenterPanels(); - }; - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - CenterPanels(); - } - - private void button2_Click(object sender, EventArgs e) - { - pnlhighscore.Hide(); - } - - private void btnmatchmake_Click(object sender, EventArgs e) - { - this.StartMultiplayer(); - pnlintro.Hide(); - lblbeatai.Text = "Beat the other player to earn Codepoints."; - lblcountdown.Text = "Waiting for another player..."; - lblcountdown.Left = (this.Width - lblcountdown.Width) / 2; - } - } -} diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs deleted file mode 100644 index 32d508b..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ /dev/null @@ -1,317 +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 ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class ShiftoriumFrontend - { - /// - /// 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.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.lbupgradedesc = new System.Windows.Forms.Label(); - this.pnlupgradeactions = new System.Windows.Forms.Panel(); - this.btnbuy = new System.Windows.Forms.Button(); - this.lbupgradetitle = new System.Windows.Forms.Label(); - this.pnllist = new System.Windows.Forms.Panel(); - this.lbcodepoints = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.pgupgradeprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - this.lbupgrades = new System.Windows.Forms.ListBox(); - this.label3 = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.btncat_back = new System.Windows.Forms.Button(); - this.btncat_forward = new System.Windows.Forms.Button(); - this.lblcategorytext = new System.Windows.Forms.Label(); - this.lbnoupgrades = new System.Windows.Forms.Label(); - this.panel1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.pnlupgradeactions.SuspendLayout(); - this.pnllist.SuspendLayout(); - this.panel3.SuspendLayout(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.Controls.Add(this.panel2); - this.panel1.Controls.Add(this.pnllist); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(782, 427); - this.panel1.TabIndex = 0; - // - // panel2 - // - this.panel2.Controls.Add(this.lbupgradedesc); - this.panel2.Controls.Add(this.pnlupgradeactions); - this.panel2.Controls.Add(this.lbupgradetitle); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(406, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(376, 427); - this.panel2.TabIndex = 1; - // - // lbupgradedesc - // - this.lbupgradedesc.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbupgradedesc.Location = new System.Drawing.Point(0, 42); - this.lbupgradedesc.Name = "lbupgradedesc"; - this.lbupgradedesc.Size = new System.Drawing.Size(376, 348); - this.lbupgradedesc.TabIndex = 2; - this.lbupgradedesc.Text = "{SHIFTORIUM_EXP}"; - this.lbupgradedesc.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradedesc.UseCompatibleTextRendering = true; - // - // pnlupgradeactions - // - this.pnlupgradeactions.Controls.Add(this.btnbuy); - this.pnlupgradeactions.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlupgradeactions.Location = new System.Drawing.Point(0, 390); - this.pnlupgradeactions.Name = "pnlupgradeactions"; - this.pnlupgradeactions.Size = new System.Drawing.Size(376, 37); - this.pnlupgradeactions.TabIndex = 1; - // - // btnbuy - // - this.btnbuy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnbuy.AutoSize = true; - this.btnbuy.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnbuy.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnbuy.Location = new System.Drawing.Point(327, 9); - this.btnbuy.Name = "btnbuy"; - this.btnbuy.Size = new System.Drawing.Size(37, 25); - this.btnbuy.TabIndex = 0; - this.btnbuy.Text = "Buy"; - this.btnbuy.UseVisualStyleBackColor = true; - this.btnbuy.Visible = false; - this.btnbuy.Click += new System.EventHandler(this.btnbuy_Click); - // - // lbupgradetitle - // - this.lbupgradetitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbupgradetitle.Location = new System.Drawing.Point(0, 0); - this.lbupgradetitle.Name = "lbupgradetitle"; - this.lbupgradetitle.Size = new System.Drawing.Size(376, 42); - this.lbupgradetitle.TabIndex = 0; - this.lbupgradetitle.Text = "{WELCOME_TO_SHIFTORIUM}"; - this.lbupgradetitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradetitle.UseCompatibleTextRendering = true; - // - // pnllist - // - this.pnllist.Controls.Add(this.lbnoupgrades); - this.pnllist.Controls.Add(this.panel3); - this.pnllist.Controls.Add(this.lbcodepoints); - this.pnllist.Controls.Add(this.label1); - this.pnllist.Controls.Add(this.pgupgradeprogress); - this.pnllist.Controls.Add(this.lbupgrades); - this.pnllist.Dock = System.Windows.Forms.DockStyle.Left; - this.pnllist.Location = new System.Drawing.Point(0, 0); - this.pnllist.Name = "pnllist"; - this.pnllist.Size = new System.Drawing.Size(406, 427); - this.pnllist.TabIndex = 0; - // - // lbcodepoints - // - this.lbcodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lbcodepoints.AutoSize = true; - this.lbcodepoints.Location = new System.Drawing.Point(128, 357); - this.lbcodepoints.Name = "lbcodepoints"; - this.lbcodepoints.Size = new System.Drawing.Size(135, 13); - this.lbcodepoints.TabIndex = 3; - this.lbcodepoints.Text = "You have: %cp Codepoints"; - this.lbcodepoints.Click += new System.EventHandler(this.lbcodepoints_Click); - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 399); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(137, 13); - this.label1.TabIndex = 2; - this.label1.Text = "{UPGRADE_PROGRESS}:"; - // - // pgupgradeprogress - // - this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgupgradeprogress.BlockSize = 5; - this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390); - this.pgupgradeprogress.Maximum = 100; - this.pgupgradeprogress.Name = "pgupgradeprogress"; - this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23); - this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgupgradeprogress.TabIndex = 1; - this.pgupgradeprogress.Value = 25; - // - // lbupgrades - // - this.lbupgrades.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.lbupgrades.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.lbupgrades.FormattingEnabled = true; - this.lbupgrades.Location = new System.Drawing.Point(3, 105); - this.lbupgrades.Name = "lbupgrades"; - this.lbupgrades.Size = new System.Drawing.Size(397, 238); - this.lbupgrades.TabIndex = 0; - this.lbupgrades.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbupgrades_DrawItem); - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 399); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(137, 13); - this.label3.TabIndex = 2; - // - // panel3 - // - this.panel3.Controls.Add(this.lblcategorytext); - this.panel3.Controls.Add(this.btncat_forward); - this.panel3.Controls.Add(this.btncat_back); - this.panel3.Location = new System.Drawing.Point(6, 76); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(394, 23); - this.panel3.TabIndex = 5; - // - // btncat_back - // - this.btncat_back.AutoSize = true; - this.btncat_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_back.Dock = System.Windows.Forms.DockStyle.Left; - this.btncat_back.Location = new System.Drawing.Point(0, 0); - this.btncat_back.Name = "btncat_back"; - this.btncat_back.Size = new System.Drawing.Size(29, 23); - this.btncat_back.TabIndex = 0; - this.btncat_back.Text = "<--"; - this.btncat_back.UseVisualStyleBackColor = true; - this.btncat_back.Click += new System.EventHandler(this.btncat_back_Click); - // - // btncat_forward - // - this.btncat_forward.AutoSize = true; - this.btncat_forward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_forward.Dock = System.Windows.Forms.DockStyle.Right; - this.btncat_forward.Location = new System.Drawing.Point(365, 0); - this.btncat_forward.Name = "btncat_forward"; - this.btncat_forward.Size = new System.Drawing.Size(29, 23); - this.btncat_forward.TabIndex = 1; - this.btncat_forward.Text = "-->"; - this.btncat_forward.UseVisualStyleBackColor = true; - this.btncat_forward.Click += new System.EventHandler(this.btncat_forward_Click); - // - // lblcategorytext - // - this.lblcategorytext.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblcategorytext.Location = new System.Drawing.Point(29, 0); - this.lblcategorytext.Name = "lblcategorytext"; - this.lblcategorytext.Size = new System.Drawing.Size(336, 23); - this.lblcategorytext.TabIndex = 2; - this.lblcategorytext.Text = "label2"; - this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbnoupgrades - // - this.lbnoupgrades.AutoSize = true; - this.lbnoupgrades.Location = new System.Drawing.Point(69, 183); - this.lbnoupgrades.Name = "lbnoupgrades"; - this.lbnoupgrades.Size = new System.Drawing.Size(71, 13); - this.lbnoupgrades.TabIndex = 6; - this.lbnoupgrades.Tag = "header2"; - this.lbnoupgrades.Text = "No upgrades!"; - this.lbnoupgrades.Visible = false; - // - // ShiftoriumFrontend - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.Controls.Add(this.panel1); - this.ForeColor = System.Drawing.Color.LightGreen; - this.Name = "ShiftoriumFrontend"; - this.Size = new System.Drawing.Size(782, 427); - this.Load += new System.EventHandler(this.Shiftorium_Load); - this.panel1.ResumeLayout(false); - this.panel2.ResumeLayout(false); - this.pnlupgradeactions.ResumeLayout(false); - this.pnlupgradeactions.PerformLayout(); - this.pnllist.ResumeLayout(false); - this.pnllist.PerformLayout(); - this.panel3.ResumeLayout(false); - this.panel3.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Panel pnllist; - private System.Windows.Forms.ListBox lbupgrades; - private System.Windows.Forms.Label lbupgradedesc; - private System.Windows.Forms.Panel pnlupgradeactions; - private System.Windows.Forms.Label lbupgradetitle; - private System.Windows.Forms.Button btnbuy; - private ShiftedProgressBar pgupgradeprogress; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label lbcodepoints; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Label lblcategorytext; - private System.Windows.Forms.Button btncat_forward; - private System.Windows.Forms.Button btncat_back; - private System.Windows.Forms.Label lbnoupgrades; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs deleted file mode 100644 index 66b0448..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ /dev/null @@ -1,274 +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.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.SkinEngine; -using backend = ShiftOS.Engine.Shiftorium; -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Shiftorium", true, "al_shiftorium", "Utilities")] - [RequiresUpgrade("shiftorium_gui")] - [MultiplayerOnly] - [WinOpen("shiftorium")] - [DefaultTitle("Shiftorium")] - [DefaultIcon("iconShiftorium")] - public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow - { - public int CategoryId = 0; - public static System.Timers.Timer timer100; - - - public ShiftoriumFrontend() - { - cp_update = new System.Windows.Forms.Timer(); - cp_update.Tick += (o, a) => - { - lbcodepoints.Text = $"You have {SaveSystem.CurrentSave.Codepoints} Codepoints."; - }; - cp_update.Interval = 100; - InitializeComponent(); - PopulateShiftorium(); - lbupgrades.SelectedIndexChanged += (o, a) => - { - try - { - lbupgrades.Refresh(); - SelectUpgrade(lbupgrades.SelectedItem.ToString()); - } - catch { } - }; - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - backend.Installed += () => - { - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - }; - - } - - public void SelectUpgrade(string name) - { - btnbuy.Show(); - var upg = upgrades[name]; - lbupgradetitle.Text = Localization.Parse(upg.Name); - lbupgradedesc.Text = Localization.Parse(upg.Description); - } - - Dictionary upgrades = new Dictionary(); - - public void PopulateShiftorium() - { - try - { - lbnoupgrades.Hide(); - lbupgrades.Items.Clear(); - upgrades.Clear(); - Timer(); - - foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId])) - { - String name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; - upgrades.Add(name, upg); - lbupgrades.Items.Add(name); - } - - if (lbupgrades.Items.Count == 0) - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } - else - { - lbnoupgrades.Hide(); - } - lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; - btncat_back.Visible = (CategoryId > 0); - btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); - } - catch - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } - } - - public static bool UpgradeInstalled(string upg) - { - return backend.UpgradeInstalled(upg); - } - - public static bool UpgradeAttributesUnlocked(FieldInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(MethodInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(Type finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(PropertyInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - private void lbupgrades_DrawItem(object sender, DrawItemEventArgs e) - { - var foreground = new SolidBrush(LoadedSkin.ControlTextColor); - var background = new SolidBrush(LoadedSkin.ControlColor); - - e.Graphics.FillRectangle(background, e.Bounds); - try - { - if (lbupgrades.GetSelected(e.Index) == true) - { - e.Graphics.FillRectangle(foreground, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, background, e.Bounds.Location); - } - else - { - e.Graphics.FillRectangle(background, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, foreground, e.Bounds.Location); - } - } - catch - { - } - } - - private void btnbuy_Click(object sender, EventArgs e) - { - long cpCost = 0; - backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); - foreach (var itm in lbupgrades.SelectedItems) - { - cpCost += upgrades[itm.ToString()].Cost; - UpgradesToBuy.Add(upgrades[itm.ToString()].ID, upgrades[itm.ToString()].Cost); - } - if (SaveSystem.CurrentSave.Codepoints < cpCost) - { - Infobox.Show("Insufficient Codepoints", $"You do not have enough Codepoints to perform this action. You need {cpCost - SaveSystem.CurrentSave.Codepoints} more."); - - } - else - { - foreach(var upg in UpgradesToBuy) - { - backend.Buy(upg.Key, upg.Value); - } - } - - backend.Silent = false; - PopulateShiftorium(); - btnbuy.Hide(); - } - - private void Shiftorium_Load(object sender, EventArgs e) { - - } - - public void OnLoad() - { - cp_update.Start(); - lbnoupgrades.Hide(); - } - - public void OnSkinLoad() - { - - } - - Timer cp_update = new System.Windows.Forms.Timer(); - - public bool OnUnload() - { - cp_update.Stop(); - cp_update = null; - return true; - } - - public void OnUpgrade() - { - lbupgrades.SelectionMode = (UpgradeInstalled("shiftorium_gui_bulk_buy") == true) ? SelectionMode.MultiExtended : SelectionMode.One; - lbcodepoints.Visible = Shiftorium.UpgradeInstalled("shiftorium_gui_codepoints_display"); - } - - private void lbcodepoints_Click(object sender, EventArgs e) - { - - } - - void Timer() - { - timer100 = new System.Timers.Timer(); - timer100.Interval = 2000; - //timer100.Elapsed += ???; - timer100.AutoReset = true; - timer100.Enabled = true; - } - - private void btncat_back_Click(object sender, EventArgs e) - { - if(CategoryId > 0) - { - CategoryId--; - PopulateShiftorium(); - } - } - - private void btncat_forward_Click(object sender, EventArgs e) - { - if(CategoryId < backend.GetCategories().Length - 1) - { - CategoryId++; - PopulateShiftorium(); - } - } - } -} diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs deleted file mode 100644 index 1f09e4a..0000000 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ /dev/null @@ -1,342 +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.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Skin Loader", true, "al_skin_loader", "Customization")] - [RequiresUpgrade("skinning")] - [WinOpen("skin_loader")] - [DefaultTitle("Skin Loader")] - [DefaultIcon("iconSkinLoader")] - public partial class Skin_Loader : UserControl, IShiftOSWindow - { - public Skin_Loader() - { - InitializeComponent(); - SetupControls(pnlborder); - SetupControls(pnldesktop); - LoadedSkin = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(SkinEngine.LoadedSkin)); - this.Load += (o, a) => { SetupUI(); }; - - } - - public void SetupControls(Control ctrl) - { - ctrl.Tag = "keepbg keepfg keepfont"; - foreach (Control c in ctrl.Controls) - SetupControls(c); - } - - public Skin LoadedSkin { get; set; } - - public void SetupUI() - { - SetupDesktop(); - Setup(); - } - - public void SetupDesktop() - { - menuStrip1.Renderer = new ShiftOSMenuRenderer(); - - this.DoubleBuffered = true; - desktoppanel.BackColor = Color.Green; - - //upgrades - - if (SaveSystem.CurrentSave != null) - { - desktoppanel.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop"); - lbtime.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop_clock_widget"); - - //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - - sysmenuholder.Visible = ShiftoriumFrontend.UpgradeInstalled("app_launcher"); - - //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. - //To compensate, we must recreate the desktop color and make the alpha channel '255'. - pnldesktop.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); - //Not doing this will cause an ArgumentException. - - pnldesktop.BackgroundImage = GetImage("desktopbackground"); - pnldesktop.BackgroundImageLayout = GetImageLayout("desktopbackground"); - desktoppanel.BackgroundImage = GetImage("desktoppanel"); - menuStrip1.BackgroundImage = GetImage("applauncher"); - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - lbtime.Font = LoadedSkin.DesktopPanelClockFont; - lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; - lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; - - if (desktoppanel.BackgroundImage == null) - { - lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; - } - else - { - lbtime.BackColor = Color.Transparent; - } - apps.Text = LoadedSkin.AppLauncherText; - sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; - sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; - apps.Size = sysmenuholder.Size; - menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable()); - desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; - desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); - desktoppanel.Height = LoadedSkin.DesktopPanelHeight; - if (LoadedSkin.DesktopPanelPosition == 1) - { - desktoppanel.Dock = DockStyle.Bottom; - } - else - { - desktoppanel.Dock = DockStyle.Top; - } - } - - } - - public ImageLayout GetImageLayout(string img) - { - if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) - { - return LoadedSkin.SkinImageLayouts[img]; - } - else - { - LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); - return ImageLayout.Tile; - } - } - - public Image GetImage(string img) - { - var type = typeof(Skin); - - foreach (var field in type.GetFields()) - { - foreach (var attr in field.GetCustomAttributes(false)) - { - if (attr is ImageAttribute) - { - var iattr = attr as ImageAttribute; - if (iattr.Name == img) - { - byte[] image = (byte[])field.GetValue(LoadedSkin); - return SkinEngine.ImageFromBinary(image); - } - } - } - } - - return null; - } - - bool IsDialog = false; - - public void Setup() - { - pnlcontents.BackColor = LoadedSkin.ControlColor; - - this.lbtitletext.Text = Localization.Parse("{TEMPLATE}"); - this.Dock = DockStyle.Fill; - - if (SaveSystem.CurrentSave != null) - { - this.pnltitle.Visible = ShiftoriumFrontend.UpgradeInstalled("wm_titlebar"); - this.pnlclose.Visible = ShiftoriumFrontend.UpgradeInstalled("close_button"); - this.pnlminimize.Visible = (IsDialog == false) && ShiftoriumFrontend.UpgradeInstalled("minimize_button"); - this.pnlmaximize.Visible = (IsDialog == false) && ShiftoriumFrontend.UpgradeInstalled("maximize_button"); - SetupSkin(); - } - else - { - this.pnltitle.Visible = false; - this.pnlclose.Visible = false; - this.pnlminimize.Visible = false; - this.pnlmaximize.Visible = false; - - } - } - - public void SetupSkin() - { - pnltitlemaster.Height = LoadedSkin.TitlebarHeight; - pnltitle.BackColor = LoadedSkin.TitleBackgroundColor; - pnltitle.BackgroundImage = GetImage("titlebar"); - pnltitleleft.Visible = LoadedSkin.ShowTitleCorners; - pnltitleright.Visible = LoadedSkin.ShowTitleCorners; - pnltitleleft.BackColor = LoadedSkin.TitleLeftCornerBackground; - pnltitleright.BackColor = LoadedSkin.TitleRightCornerBackground; - pnltitleleft.Width = LoadedSkin.TitleLeftCornerWidth; - pnltitleright.Width = LoadedSkin.TitleRightCornerWidth; - pnltitleleft.BackgroundImage = GetImage("titleleft"); - pnltitleleft.BackgroundImageLayout = GetImageLayout("titleleft"); - pnltitleright.BackgroundImage = GetImage("titleright"); - pnltitleright.BackgroundImageLayout = GetImageLayout("titleright"); - - - lbtitletext.BackColor = LoadedSkin.TitleBackgroundColor; - lbtitletext.ForeColor = LoadedSkin.TitleTextColor; - lbtitletext.Font = LoadedSkin.TitleFont; - - pnlleft.BackColor = LoadedSkin.BorderLeftBackground; - pnlleft.BackgroundImage = GetImage("leftborder"); - pnlleft.BackgroundImageLayout = GetImageLayout("leftborder"); - pnlleft.Width = LoadedSkin.LeftBorderWidth; - pnlright.BackColor = LoadedSkin.BorderRightBackground; - pnlright.BackgroundImage = GetImage("rightborder"); - pnlright.BackgroundImageLayout = GetImageLayout("rightborder"); - pnlright.Width = LoadedSkin.RightBorderWidth; - - pnlbottom.BackColor = LoadedSkin.BorderBottomBackground; - pnlbottom.BackgroundImage = GetImage("bottomborder"); - pnlbottom.BackgroundImageLayout = GetImageLayout("bottomborder"); - pnlbottom.Height = LoadedSkin.BottomBorderWidth; - - pnlbottomr.BackColor = LoadedSkin.BorderBottomRightBackground; - pnlbottomr.BackgroundImage = GetImage("bottomrborder"); - pnlbottomr.BackgroundImageLayout = GetImageLayout("bottomrborder"); - pnlbottoml.BackColor = LoadedSkin.BorderBottomLeftBackground; - pnlbottoml.BackgroundImage = GetImage("bottomlborder"); - pnlbottoml.BackgroundImageLayout = GetImageLayout("bottomlborder"); - - lbtitletext.ForeColor = LoadedSkin.TitleTextColor; - lbtitletext.Font = LoadedSkin.TitleFont; - pnlclose.BackColor = LoadedSkin.CloseButtonColor; - pnlclose.BackgroundImage = GetImage("closebutton"); - pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); - pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; - pnlminimize.BackgroundImage = GetImage("minimizebutton"); - pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); - pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; - pnlmaximize.BackgroundImage = GetImage("maximizebutton"); - pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); - - pnlclose.Size = LoadedSkin.CloseButtonSize; - pnlminimize.Size = LoadedSkin.MinimizeButtonSize; - pnlmaximize.Size = LoadedSkin.MaximizeButtonSize; - pnlclose.Location = FromRight(LoadedSkin.CloseButtonFromSide); - pnlminimize.Location = FromRight(LoadedSkin.MinimizeButtonFromSide); - pnlmaximize.Location = FromRight(LoadedSkin.MaximizeButtonFromSide); - pnlclose.Left -= pnlclose.Width; - pnlmaximize.Left -= pnlmaximize.Width; - pnlminimize.Left -= pnlminimize.Width; - - switch (LoadedSkin.TitleTextCentered) - { - case false: - lbtitletext.Location = LoadedSkin.TitleTextLeft; - break; - default: - lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; - lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; - break; - } - } - - public Point FromRight(Point input) - { - return new Point(pnltitle.Width - input.X, input.Y); - } - - private void btnapply_Click(object sender, EventArgs e) - { - ShiftOS.Objects.ShiftFS.Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin)); - SkinEngine.LoadSkin(); - } - - private void btnclose_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btnloaddefault_Click(object sender, EventArgs e) - { - this.LoadedSkin = new ShiftOS.Engine.Skin(); - SetupUI(); - } - - private void btnexport_Click(object sender, EventArgs e) - { - AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Save, new Action((filename) => - { - ShiftOS.Objects.ShiftFS.Utils.WriteAllText(filename, JsonConvert.SerializeObject(LoadedSkin)); - string fname = filename.Split('/')[filename.Split('/').Length - 1]; - if(!System.IO.Directory.Exists(Paths.SharedFolder + "\\skins")) - { - System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins"); - } - - string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname; - System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin)); - - }))); - } - - private void btnimport_Click(object sender, EventArgs e) - { - AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Open, new Action((filename) => - { - LoadedSkin = JsonConvert.DeserializeObject(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename)); - SetupUI(); - }))); - } - - public void OnLoad() - { - - SetupUI(); - } - - public void OnSkinLoad() - { - SetupUI(); - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - SetupUI(); - } - } -} diff --git a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs b/ShiftOS.WinForms/Applications/TriWrite.Designer.cs deleted file mode 100644 index e420fd5..0000000 --- a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs +++ /dev/null @@ -1,192 +0,0 @@ -namespace ShiftOS.WinForms.Applications -{ - partial class TriWrite - { - /// - /// 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 Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TriWrite)); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tvcontacts = new System.Windows.Forms.TreeView(); - this.panel1 = new System.Windows.Forms.Panel(); - this.txtbody = new System.Windows.Forms.Label(); - this.lbtitle = new System.Windows.Forms.Label(); - this.txtcontents = new System.Windows.Forms.TextBox(); - this.menuStrip2 = new System.Windows.Forms.MenuStrip(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip3 = new System.Windows.Forms.MenuStrip(); - this.menuStrip1.SuspendLayout(); - this.panel1.SuspendLayout(); - this.menuStrip2.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addContactToolStripMenuItem, - this.removeToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(872, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // addContactToolStripMenuItem - // - this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem"; - this.addContactToolStripMenuItem.Size = new System.Drawing.Size(32, 19); - // - // removeToolStripMenuItem - // - this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - this.removeToolStripMenuItem.Size = new System.Drawing.Size(32, 19); - // - // tvcontacts - // - this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left; - this.tvcontacts.Location = new System.Drawing.Point(0, 24); - this.tvcontacts.Name = "tvcontacts"; - this.tvcontacts.Size = new System.Drawing.Size(224, 551); - this.tvcontacts.TabIndex = 1; - // - // panel1 - // - this.panel1.Controls.Add(this.txtbody); - this.panel1.Controls.Add(this.lbtitle); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(224, 24); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(648, 551); - this.panel1.TabIndex = 2; - // - // txtbody - // - this.txtbody.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.txtbody.Location = new System.Drawing.Point(7, 54); - this.txtbody.Name = "txtbody"; - this.txtbody.Size = new System.Drawing.Size(626, 481); - this.txtbody.TabIndex = 1; - this.txtbody.Text = resources.GetString("txtbody.Text"); - // - // lbtitle - // - this.lbtitle.AutoSize = true; - this.lbtitle.Location = new System.Drawing.Point(7, 4); - this.lbtitle.Name = "lbtitle"; - this.lbtitle.Size = new System.Drawing.Size(44, 13); - this.lbtitle.TabIndex = 0; - this.lbtitle.Tag = "header1"; - this.lbtitle.Text = "TriWrite"; - // - // txtcontents - // - this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtcontents.Location = new System.Drawing.Point(0, 53); - this.txtcontents.Multiline = true; - this.txtcontents.Name = "txtcontents"; - this.txtcontents.Size = new System.Drawing.Size(527, 460); - this.txtcontents.TabIndex = 1; - this.txtcontents.TabStop = false; - // - // menuStrip2 - // - this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.openToolStripMenuItem, - this.saveToolStripMenuItem}); - this.menuStrip2.Location = new System.Drawing.Point(0, 0); - this.menuStrip2.Name = "menuStrip2"; - this.menuStrip2.Size = new System.Drawing.Size(527, 24); - this.menuStrip2.TabIndex = 2; - this.menuStrip2.Text = "menuStrip2"; - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(43, 20); - this.newToolStripMenuItem.Text = "New"; - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(48, 20); - this.openToolStripMenuItem.Text = "Open"; - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(43, 20); - this.saveToolStripMenuItem.Text = "Save"; - // - // menuStrip3 - // - this.menuStrip3.Location = new System.Drawing.Point(0, 30); - this.menuStrip3.Name = "menuStrip3"; - this.menuStrip3.Size = new System.Drawing.Size(527, 24); - this.menuStrip3.TabIndex = 3; - this.menuStrip3.Text = "menuStrip3"; - // - // TriWrite - // - this.Controls.Add(this.txtcontents); - this.Controls.Add(this.menuStrip3); - this.Controls.Add(this.menuStrip2); - this.Name = "TriWrite"; - this.Size = new System.Drawing.Size(527, 513); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.menuStrip2.ResumeLayout(false); - this.menuStrip2.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem addContactToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; - private System.Windows.Forms.TreeView tvcontacts; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Label txtbody; - private System.Windows.Forms.Label lbtitle; - private System.Windows.Forms.TextBox txtcontents; - private System.Windows.Forms.MenuStrip menuStrip2; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.MenuStrip menuStrip3; - } -} diff --git a/ShiftOS.WinForms/Applications/TriWrite.cs b/ShiftOS.WinForms/Applications/TriWrite.cs deleted file mode 100644 index 6fb814f..0000000 --- a/ShiftOS.WinForms/Applications/TriWrite.cs +++ /dev/null @@ -1,76 +0,0 @@ -using ShiftOS.Objects.ShiftFS; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms.Applications -{ - [WinOpen("triwrite")] - [AppscapeEntry("TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, null, "Office")] - [DefaultTitle("TriWrite")] - [Launcher("TriWrite", false, null, "Office")] - public partial class TriWrite : UserControl, IShiftOSWindow - { - - public TriWrite() - { - InitializeComponent(); - } - - private void newToolStripMenuItem_Click(object sender, EventArgs e) - { - txtcontents.Text = ""; - } - - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - var txt = new List(); - txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Open, new Action((file) => this.LoadFile(file)))); - } - - public void LoadFile(string file) - { - txtcontents.Text = Utils.ReadAllText(file); - } - - public void SaveFile(string file) - { - Utils.WriteAllText(file, txtcontents.Text); - } - - private void saveToolStripMenuItem_Click(object sender, EventArgs e) - { - var txt = new List(); - txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Save, new Action((file) => this.SaveFile(file)))); - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/TriWrite.resx b/ShiftOS.WinForms/Applications/TriWrite.resx index 525a23c..a06716c 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.resx +++ b/ShiftOS.WinForms/Applications/TriWrite.resx @@ -130,7 +130,113 @@ To add a contact, simply click "Add Contact", and to remove one, click "Remove". 132, 17 - + 247, 17 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index cdb0965..ea7808c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -86,6 +86,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); this.SelectionFont = ConstructFont(); @@ -119,6 +120,135 @@ namespace ShiftOS.WinForms.Controls base.OnMouseUp(mevent); } + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + if (!TerminalBackend.InStory) + { + switch (e.KeyCode) { + case Keys.Add: + case Keys.Alt: + case Keys.Apps: + case Keys.Attn: + case Keys.BrowserBack: + case Keys.BrowserFavorites: + case Keys.BrowserForward: + case Keys.BrowserHome: + case Keys.BrowserRefresh: + case Keys.BrowserSearch: + case Keys.BrowserStop: + case Keys.Cancel: + case Keys.Capital: + case Keys.Clear: + case Keys.Control: + case Keys.ControlKey: + case Keys.Crsel: + case Keys.Decimal: + case Keys.Divide: + case Keys.Down: + case Keys.End: + case Keys.Enter: + case Keys.EraseEof: + case Keys.Escape: + case Keys.Execute: + case Keys.Exsel: + case Keys.F1: + case Keys.F10: + case Keys.F11: + case Keys.F12: + case Keys.F13: + case Keys.F14: + case Keys.F15: + case Keys.F16: + case Keys.F17: + case Keys.F18: + case Keys.F19: + case Keys.F2: + case Keys.F20: + case Keys.F21: + case Keys.F22: + case Keys.F23: + case Keys.F24: + case Keys.F3: + case Keys.F4: + case Keys.F5: + case Keys.F6: + case Keys.F7: + case Keys.F8: + case Keys.F9: + case Keys.FinalMode: + case Keys.HanguelMode: + case Keys.HanjaMode: + case Keys.Help: + case Keys.Home: + case Keys.IMEAccept: + case Keys.IMEConvert: + case Keys.IMEModeChange: + case Keys.IMENonconvert: + case Keys.Insert: + case Keys.JunjaMode: + case Keys.KeyCode: + case Keys.LaunchApplication1: + case Keys.LaunchApplication2: + case Keys.LaunchMail: + case Keys.LButton: + case Keys.LControlKey: + case Keys.Left: + case Keys.LineFeed: + case Keys.LMenu: + case Keys.LShiftKey: + case Keys.LWin: + case Keys.MButton: + case Keys.MediaNextTrack: + case Keys.MediaPlayPause: + case Keys.MediaPreviousTrack: + case Keys.MediaStop: + case Keys.Menu: + case Keys.Modifiers: + case Keys.Multiply: + case Keys.Next: + case Keys.NoName: + case Keys.None: + case Keys.NumLock: + case Keys.Pa1: + case Keys.Packet: + case Keys.PageUp: + case Keys.Pause: + case Keys.Play: + case Keys.Print: + case Keys.PrintScreen: + case Keys.ProcessKey: + case Keys.RButton: + case Keys.RControlKey: + case Keys.Right: + case Keys.RMenu: + case Keys.RShiftKey: + case Keys.RWin: + case Keys.Scroll: + case Keys.Select: + case Keys.SelectMedia: + case Keys.Separator: + case Keys.Shift: + case Keys.ShiftKey: + case Keys.Sleep: + case Keys.Subtract: + case Keys.Tab: + case Keys.Up: + case Keys.VolumeDown: + case Keys.VolumeMute: + case Keys.VolumeUp: + case Keys.XButton1: + case Keys.XButton2: + case Keys.Zoom: + + break; + default: + //Engine.AudioManager.PlayStream(Properties.Resources.typesound); // infernal beeping noise only enable for the trailers + break; + } + } + } + public TerminalBox() : base() { this.Tag = "keepbg keepfg keepfont"; diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs new file mode 100644 index 0000000..c6a7d83 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs @@ -0,0 +1,62 @@ +namespace ShiftOS.WinForms.DesktopWidgets +{ + partial class HeartbeatWidget + { + /// + /// 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 Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lbheartbeat = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbheartbeat + // + this.lbheartbeat.AutoSize = true; + this.lbheartbeat.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbheartbeat.Location = new System.Drawing.Point(0, 0); + this.lbheartbeat.Name = "lbheartbeat"; + this.lbheartbeat.Size = new System.Drawing.Size(35, 13); + this.lbheartbeat.TabIndex = 0; + this.lbheartbeat.Text = "label1"; + // + // HeartbeatWidget + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.lbheartbeat); + this.Name = "HeartbeatWidget"; + this.Size = new System.Drawing.Size(35, 13); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbheartbeat; + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs new file mode 100644 index 0000000..b0dc552 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.WinForms.Tools; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.DesktopWidgets +{ + [DesktopWidget("Server ping", "See the time spent between client requests and server replies in the digital society.")] + public partial class HeartbeatWidget : UserControl, IDesktopWidget + { + public HeartbeatWidget() + { + InitializeComponent(); + tmr.Interval = 1; + tmr.Tick += (o, a) => + { + if(ts != ServerManager.DigitalSocietyPing) + { + ts = ServerManager.DigitalSocietyPing; + lbheartbeat.Text = "Server ping: " + ts.ToString() + " MS"; + } + }; + } + + //Fun fact. I misspelled this as "TimeSpam." + long ts = 0; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + Timer tmr = new Timer(); + + public void Setup() + { + tmr.Start(); + } + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs new file mode 100644 index 0000000..e10071f --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.Designer.cs @@ -0,0 +1,135 @@ +namespace ShiftOS.WinForms +{ + partial class GUILogin + { + /// + /// 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.pnlloginform = new System.Windows.Forms.Panel(); + this.btnlogin = new System.Windows.Forms.Button(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.lblogintitle = new System.Windows.Forms.Label(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlloginform.SuspendLayout(); + this.SuspendLayout(); + // + // pnlloginform + // + this.pnlloginform.Controls.Add(this.btnlogin); + this.pnlloginform.Controls.Add(this.txtpassword); + this.pnlloginform.Controls.Add(this.txtusername); + this.pnlloginform.Location = new System.Drawing.Point(13, 13); + this.pnlloginform.Name = "pnlloginform"; + this.pnlloginform.Size = new System.Drawing.Size(358, 236); + this.pnlloginform.TabIndex = 0; + this.pnlloginform.Tag = ""; + // + // btnlogin + // + this.btnlogin.AutoSize = true; + this.btnlogin.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnlogin.Location = new System.Drawing.Point(159, 163); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(43, 23); + this.btnlogin.TabIndex = 2; + this.btnlogin.Text = "Login"; + this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(69, 115); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(300, 20); + this.txtpassword.TabIndex = 1; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(3, 14); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(300, 20); + this.txtusername.TabIndex = 0; + // + // lblogintitle + // + this.lblogintitle.AutoSize = true; + this.lblogintitle.Location = new System.Drawing.Point(99, 553); + this.lblogintitle.Name = "lblogintitle"; + this.lblogintitle.Size = new System.Drawing.Size(103, 13); + this.lblogintitle.TabIndex = 1; + this.lblogintitle.Tag = "header1 keepbg"; + this.lblogintitle.Text = "Welcome to ShiftOS"; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.Location = new System.Drawing.Point(924, 652); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(65, 23); + this.btnshutdown.TabIndex = 2; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + this.btnshutdown.Click += new System.EventHandler(this.btnshutdown_Click); + // + // GUILogin + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(1001, 687); + this.Controls.Add(this.btnshutdown); + this.Controls.Add(this.lblogintitle); + this.Controls.Add(this.pnlloginform); + this.ForeColor = System.Drawing.Color.White; + this.Name = "GUILogin"; + this.Text = "GUILogin"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GUILogin_FormClosing); + this.Load += new System.EventHandler(this.GUILogin_Load); + this.pnlloginform.ResumeLayout(false); + this.pnlloginform.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel pnlloginform; + private System.Windows.Forms.Button btnlogin; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.Label lblogintitle; + private System.Windows.Forms.Button btnshutdown; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/GUILogin.cs b/ShiftOS.WinForms/GUILogin.cs new file mode 100644 index 0000000..078061c --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms +{ + public partial class GUILogin : Form + { + public GUILogin() + { + InitializeComponent(); + uiTimer.Tick += (o, a) => + { + btnlogin.Left = txtusername.Left + ((txtusername.Width - btnlogin.Width) / 2); + btnlogin.Top = txtpassword.Top + txtpassword.Height + 5; + + lblogintitle.Left = pnlloginform.Left + ((pnlloginform.Width - lblogintitle.Width) / 2); + lblogintitle.Top = pnlloginform.Top - lblogintitle.Width - 5; + + }; + uiTimer.Interval = 100; + this.FormBorderStyle = FormBorderStyle.None; + this.WindowState = FormWindowState.Maximized; + this.TopMost = true; + } + + Timer uiTimer = new Timer(); + + public event Action LoginComplete; + + private void GUILogin_Load(object sender, EventArgs e) + { + uiTimer.Start(); + ControlManager.SetupControl(lblogintitle); + ControlManager.SetupControls(pnlloginform); + ControlManager.SetupControl(btnshutdown); + pnlloginform.CenterParent(); + txtusername.CenterParent(); + txtusername.Location = new System.Drawing.Point(txtusername.Location.X, 77); + txtpassword.CenterParent(); + btnlogin.CenterParent(); + btnlogin.Location = new System.Drawing.Point(btnlogin.Location.X, 143); + this.BackColor = SkinEngine.LoadedSkin.LoginScreenColor; + this.BackgroundImage = SkinEngine.GetImage("login"); + this.BackgroundImageLayout = SkinEngine.GetImageLayout("login"); + } + + private ClientSave User = null; + + bool userRequestClose = true; + bool shuttingdown = false; + + private void GUILogin_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = userRequestClose; + if (!e.Cancel) + { + uiTimer.Stop(); + if (shuttingdown == false) + { + LoginComplete?.Invoke(User); + } + } + } + + private void btnlogin_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(txtusername.Text)) + { + Infobox.Show("Enter a username", "You must enter your username to login."); + return; + } + + //Don't check for blank passwords. + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == txtusername.Text); + if(user == null) + { + Infobox.Show("Invalid username", "That username was not found on your system."); + return; + } + + if (user.Password != txtpassword.Text) + { + Infobox.Show("Access denied.", "That password didn't work. Please try a different one."); + return; + } + + User = user; + userRequestClose = false; + shuttingdown = false; + this.Close(); + } + + private void btnshutdown_Click(object sender, EventArgs e) + { + userRequestClose = false; + shuttingdown = true; + this.Close(); + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + TerminalBackend.InvokeCommand("sos.shutdown"); + } + } + + public class GUILoginFrontend : ILoginFrontend + { + public bool UseGUILogin + { + get + { + return Shiftorium.UpgradeInstalled("gui_based_login_screen"); + } + } + + public event Action LoginComplete; + + public void Login() + { + var lform = new GUILogin(); + lform.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + lform.Show(); + } + } +} diff --git a/ShiftOS.WinForms/GUILogin.resx b/ShiftOS.WinForms/GUILogin.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 a4d63e0..d5f28f8 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -312,11 +312,15 @@ You must join the digital society, rise up the ranks, and save us. sve.Codepoints = 0; sve.Upgrades = new Dictionary(); sve.ID = Guid.NewGuid(); + sve.StoriesExperienced = new List(); + sve.StoriesExperienced.Add("mud_fundamentals"); Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () => { sve.StoryPosition = 8675309; SaveSystem.CurrentSave = sve; + Shiftorium.Silent = true; SaveSystem.SaveGame(); + Shiftorium.Silent = false; }); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index bab4889..a35e1d8 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,15 +135,15 @@ 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(); - } + private static bool isValid(string text, string chars) { foreach(var c in text) diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b2f064d..ad8fc83 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index b528c72..c3d27ae 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,13 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "GUI Based Login Screen", + Cost: 500, + Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, why not use these tools to create a functioning and awesome-looking login screen?", + Dependencies: "skinning;desktop;wm_free_placement", + Category: "Kernel & System" + }, { Name: "Shift Screensavers", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9fc237f..97cc3c9 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -70,9 +70,7 @@ About.cs - - UserControl - + TriWrite.cs @@ -178,9 +176,7 @@ Notifications.cs - - UserControl - + Pong.cs @@ -202,9 +198,7 @@ Shiftnet.cs - - UserControl - + ShiftoriumFrontend.cs @@ -226,9 +220,7 @@ ShopItemCreator.cs - - UserControl - + Skin Loader.cs @@ -298,6 +290,12 @@ CodepointsWidget.cs + + UserControl + + + HeartbeatWidget.cs + UserControl @@ -317,6 +315,12 @@ DownloadControl.cs + + Form + + + GUILogin.cs + @@ -502,6 +506,9 @@ CodepointsWidget.cs + + HeartbeatWidget.cs + TerminalWidget.cs @@ -511,6 +518,9 @@ DownloadControl.cs + + GUILogin.cs + Oobe.cs 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.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 25c7639..40dc629 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -515,6 +515,17 @@ namespace ShiftOS.WinForms if(resizing == true) { this.Width += e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -522,6 +533,17 @@ namespace ShiftOS.WinForms { resizing = false; pnlcontents.Show(); + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } private void pnlleft_MouseMove(object sender, MouseEventArgs e) @@ -530,6 +552,17 @@ namespace ShiftOS.WinForms { this.Left += e.X; this.Width -= e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -547,6 +580,17 @@ namespace ShiftOS.WinForms { this.Width += e.X; this.Height += e.Y; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -557,6 +601,17 @@ namespace ShiftOS.WinForms this.Width -= e.X; this.Height += e.Y; this.Left += e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 57d1d34..dc0b3a2 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -276,6 +276,17 @@ namespace ShiftOS.Engine return true; } + [Command("restart")] + public static bool Restart() + { + SaveSystem.CurrentSave.Upgrades = new Dictionary(); + SaveSystem.CurrentSave.Codepoints = 0; + SaveSystem.CurrentSave.StoriesExperienced.Clear(); + SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals"); + SaveSystem.SaveGame(); + Shiftorium.InvokeUpgradeInstalled(); + return true; + } [Command("freecp")] public static bool FreeCodepoints(Dictionary args) @@ -283,8 +294,8 @@ namespace ShiftOS.Engine if (args.ContainsKey("amount")) try { - Int64 codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); - SaveSystem.TransferCodepointsFrom("dev", codepointsToAdd); + long codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); + SaveSystem.CurrentSave.Codepoints += codepointsToAdd; return true; } catch (Exception ex) @@ -293,7 +304,7 @@ namespace ShiftOS.Engine return true; } - SaveSystem.TransferCodepointsFrom("dev", 1000); + SaveSystem.CurrentSave.Codepoints += 1000; return true; } 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 LoginComplete; + } + + /// + /// Interface for GUI-based logins. + /// + public interface ILoginFrontend + { + /// + /// When implemented, shows the login UI. + /// + void Login(); + + /// + /// Gets whether the ShiftOS engine should use a GUI-based login system or the default one. + /// + bool UseGUILogin { get; } + + + /// + /// Occurs when the login is complete. + /// + event Action LoginComplete; + + + + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 945869b..31db58a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,7 @@ namespace ShiftOS.Engine { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; - root.permissions = Permissions.All; + root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } @@ -98,13 +98,25 @@ namespace ShiftOS.Engine } Thread.Sleep(350); - Console.WriteLine("Initiating kernel..."); + Console.WriteLine("ShiftKernel v0.4.2"); + Console.WriteLine("(MIT) DevX 2017, Very Little Rights Reserved"); + Console.WriteLine(""); + Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); + Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); + Console.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); + Console.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); + Console.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); + Console.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); + Console.WriteLine("SOFTWARE."); + Console.WriteLine(""); Thread.Sleep(250); - Console.WriteLine("Reading filesystem..."); + Console.WriteLine("[init] Kernel boot complete."); + Console.WriteLine("[sfs] Loading SFS driver v3"); Thread.Sleep(100); - Console.WriteLine("Reading configuration..."); + Console.WriteLine("[sfs] 4096 blocks read."); + Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - Console.WriteLine("{CONNECTING_TO_MUD}"); + Console.WriteLine("[inetd] Connecting to network..."); if (defaultConf.ConnectToMud == true) { @@ -113,32 +125,32 @@ namespace ShiftOS.Engine { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("Connection successful."); + Console.WriteLine("[inetd] Connection successful."); }; 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()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } catch (Exception ex) { //No errors, this never gets called. - Console.WriteLine("{ERROR}: " + ex.Message); + Console.WriteLine("[inetd] SEVERE: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); while (ServerManager.thisGuid == new Guid()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } } @@ -196,14 +208,60 @@ namespace ShiftOS.Engine Thread.Sleep(75); Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); + Console.WriteLine("[usr-man] Accepting logins on local tty 1."); + Sysname: + bool waitingForNewSysName = false; + bool gobacktosysname = false; + + if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) + { + Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name) => + { + if (string.IsNullOrWhiteSpace(name)) + Infobox.Show("Invalid name", "Please enter a valid name.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else if (name.Length < 5) + Infobox.Show("Value too small.", "Your system name must have at least 5 characters in it.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else + { + CurrentSave.SystemName = name; + if (!string.IsNullOrWhiteSpace(CurrentSave.UniteAuthToken)) + { + var unite = new Unite.UniteClient("http://getshiftos.ml", CurrentSave.UniteAuthToken); + unite.SetSysName(name); + } + SaveSystem.SaveGame(); + gobacktosysname = false; + waitingForNewSysName = false; + } + }); + + + } + + while (waitingForNewSysName) + { + Thread.Sleep(10); + } + + if (gobacktosysname) + { + goto Sysname; + } if (CurrentSave.Users == null) CurrentSave.Users = new List(); - if(CurrentSave.Users.Count == 0) + if (CurrentSave.Users.Count == 0) { CurrentSave.Users.Add(new ClientSave { @@ -211,76 +269,101 @@ namespace ShiftOS.Engine Password = "", Permissions = UserPermissions.Root }); - Console.WriteLine("No users found. Creating new user with username \"root\", with no password."); + Console.WriteLine("[usr-man] WARN: No users found. Creating new user with username \"root\", with no password."); } TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) + { + Action Completed = null; + Completed += (user) => + { + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else { - if (progress == 0) + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => { - if (!string.IsNullOrWhiteSpace(text)) + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + string loginstr = CurrentSave.SystemName + " login: "; + string getuser = text.Remove(0, loginstr.Length); + if (!string.IsNullOrWhiteSpace(getuser)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = getuser; 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."); + string passwordstr = "password: "; + string getpass = text.Remove(0, passwordstr.Length); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == getpass) + { + 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.Write(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.Write("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/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 0bdfcd9..825064b 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -35,6 +35,7 @@ using ShiftOS; using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; using System.Net.Sockets; +using System.Diagnostics; namespace ShiftOS.Engine { @@ -54,6 +55,12 @@ namespace ShiftOS.Engine private static NetObjectClient client { get; set; } private static bool UserDisconnect = false; + public static long DigitalSocietyPing + { + get; + private set; + } + public static void Disconnect() { UserDisconnect = true; @@ -139,6 +146,11 @@ namespace ShiftOS.Engine }; client.OnReceived += (o, a) => { + if (PingTimer.IsRunning) + { + DigitalSocietyPing = PingTimer.ElapsedMilliseconds; + PingTimer.Reset(); + } var msg = a.Data.Object as ServerMessage; if (msg.Name == "Welcome") { @@ -207,6 +219,8 @@ namespace ShiftOS.Engine } } + private static Stopwatch PingTimer = new Stopwatch(); + public static void SendMessage(string name, string contents) { var sMsg = new ServerMessage @@ -215,7 +229,7 @@ namespace ShiftOS.Engine Contents = contents, GUID = thisGuid.ToString(), }; - + PingTimer.Start(); client.Send(new NetObject("msg", sMsg)); } 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 @@ + 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 AppIcons = new Dictionary(); + [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")] 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; } diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index 62735a3..5702e08 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -47,6 +47,11 @@ namespace ShiftOS.Engine } var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); + if(user.Username != SaveSystem.CurrentUser.Username) + { + Console.WriteLine("Error: Cannot remove yourself."); + return true; + } SaveSystem.CurrentSave.Users.Remove(user); Console.WriteLine($"Removing user \"{name}\" from system..."); SaveSystem.SaveGame(); @@ -55,13 +60,121 @@ namespace ShiftOS.Engine + + [Command("set_acl")] + [RequiresArgument("user")] + [RequiresArgument("val")] + public static bool SetUserPermission(Dictionary args) + { + int permission = 0; + string username = args["user"].ToString(); + try + { + permission = Convert.ToInt32(args["val"].ToString()); + } + catch + { + Console.WriteLine("Error: Permission value must be an integer."); + return true; + } + + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) + { + Console.WriteLine("Error: User not found."); + return true; + } + + UserPermissions uperm = UserPermissions.Guest; + + switch (permission) + { + case 0: + uperm = UserPermissions.Guest; + break; + case 1: + uperm = UserPermissions.User; + break; + case 2: + uperm = UserPermissions.Admin; + break; + case 3: + uperm = UserPermissions.Root; + break; + default: + Console.WriteLine("Permission value must be between 0 and 4."); + return true; + } + + //Permissions are backwards... oops... + if(uperm < SaveSystem.CurrentUser.Permissions) + { + Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); + return true; + } + + var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; + if (SaveSystem.CurrentUser.Permissions > oldperm) + { + Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); + return true; + } + + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; + Console.WriteLine("User permissions updated."); + return true; + } + + + [Command("users", description = "Get a list of all users on the system.")] + public static bool GetUsers() + { + foreach (var u in SaveSystem.CurrentSave.Users) + { + if (u.Username == SaveSystem.CurrentUser.Username) + { + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + } + else + { + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + } + Console.WriteLine(u.Username); + } + return true; + } } [Namespace("user")] [RequiresUpgrade("mud_fundamentals")] public static class UserManagementCommands { + [Command("login", description = "Log in as another user.")] + [RequiresArgument("user")] + [RequiresArgument("pass")] + public static bool Login(Dictionary args) + { + string user = args["user"].ToString(); + string pass = args["pass"].ToString(); + + var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); + if(usr==null) + { + Console.WriteLine("Error: No such user."); + return true; + } + if (usr.Password != pass) + { + Console.WriteLine("Access denied."); + return true; + } + + SaveSystem.CurrentUser = usr; + Console.WriteLine("Access granted."); + return true; + } [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] [RequiresArgument("old")] -- cgit v1.2.3 From fe2a1a84c3a45c88c20fcea1e6970b0644279d52 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 21 May 2017 13:09:07 +0000 Subject: I obsolesced something I made within an hour ago. --- ShiftOS.Server/SaveManager.cs | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index acf28a5..d81a1a7 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -216,21 +216,6 @@ namespace ShiftOS.Server WriteEncFile(savefile, JsonConvert.SerializeObject(save)); } - try - { - var wr = System.Net.HttpWebRequest.Create("http://getshiftos.ml/API/GetCodepoints"); - wr.Headers.Add("Authentication: Token " + save.UniteAuthToken); - var response = wr.GetResponse(); - using (var rstr = response.GetResponseStream()) - { - using (var sreader = new StreamReader(rstr)) - { - long cp = Convert.ToInt64(sreader.ReadToEnd()); - save.Codepoints = cp; - } - } - } - catch { } Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { -- cgit v1.2.3 From c7ba7d733c756d196f98dd4533289a1ef4db715f Mon Sep 17 00:00:00 2001 From: Rylan/wowmom98 Date: Sun, 28 May 2017 14:44:08 -0400 Subject: un obsoleting --- ShiftOS.Server/Core.cs | 3 ++- ShiftOS.WinForms/Applications/MUDControlCentre.cs | 16 ++++++++-------- ShiftOS.WinForms/Applications/Skin Loader.cs | 2 +- ShiftOS.WinForms/HackerCommands.cs | 8 ++++---- ShiftOS.WinForms/Oobe.cs | 2 +- ShiftOS.WinForms/Stories/LegionStory.cs | 2 +- ShiftOS_TheReturn/Commands.cs | 2 +- ShiftOS_TheReturn/Scripting.cs | 2 +- ShiftOS_TheReturn/ServerManager.cs | 4 ++-- ShiftOS_TheReturn/TerminalBackend.cs | 8 ++++---- 10 files changed, 25 insertions(+), 24 deletions(-) (limited to 'ShiftOS.Server') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index 7bb5b1d..a53a5bc 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -32,6 +32,7 @@ using NetSockets; using Newtonsoft.Json; using System.IO; using static ShiftOS.Server.Program; +using ShiftOS.Engine namespace ShiftOS.Server @@ -180,7 +181,7 @@ namespace ShiftOS.Server if (sve.EndsWith(".save")) { var save = JsonConvert.DeserializeObject(File.ReadAllText(sve)); - accs.Add($"{save.Username}@{save.SystemName}"); + accs.Add($"{ShiftOS.Engine.SaveSytem.CurrentUser.Username}@{save.SystemName}"); } } diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index ab89ffd..97212e7 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -100,7 +100,7 @@ namespace ShiftOS.WinForms.Applications { ServerManager.SendMessage("shop_removeowned", JsonConvert.SerializeObject(new { - username = SaveSystem.CurrentSave.Username + username = SaveSystem.CurrentUser.Username })); ShowCreateShop(); } @@ -290,7 +290,7 @@ namespace ShiftOS.WinForms.Applications creatingShop = true; editingShop.Name = "My shop"; editingShop.Description = "My shop has lots of awesome items. You should buy from my shop."; - editingShop.Owner = SaveSystem.CurrentSave.Username; + editingShop.Owner = SaveSystem.CurrentUser.Username; editingShop.Items = new List(); shop_editor.BringToFront(); PopulateShopEditor(); @@ -402,7 +402,7 @@ namespace ShiftOS.WinForms.Applications lbprice.Text = $"Cost: {item.Cost} CP"; btnbuy.Show(); }; - if(shop.Owner == SaveSystem.CurrentSave.Username) + if(shop.Owner == SaveSystem.CurrentUser.Username) { btneditshop.Show(); } @@ -560,7 +560,7 @@ namespace ShiftOS.WinForms.Applications you_systemstatus.BringToFront(); - lblsysstatus.Text = $@"Username: {SaveSystem.CurrentSave.Username} + lblsysstatus.Text = $@"Username: {SaveSystem.CurrentUser.Username} System name: {SaveSystem.CurrentSave.SystemName} Codepoints: {SaveSystem.CurrentSave.Codepoints} @@ -591,7 +591,7 @@ Current legions: {legionname}"; private void tsMemos_Click(object sender, EventArgs e) { ServerManager.SendMessage("get_memos_for_user", $@"{{ - username: ""{SaveSystem.CurrentSave.Username}"" + username: ""{SaveSystem.CurrentUser.Username}"" }}"); you_memos.BringToFront(); } @@ -812,7 +812,7 @@ Current legions: {legionname}"; { ServerManager.SendMessage("user_shop_check", JsonConvert.SerializeObject(new { - username = SaveSystem.CurrentSave.Username + username = SaveSystem.CurrentUser.Username })); } @@ -895,7 +895,7 @@ Current legions: {legionname}"; private void myShopToolStripMenuItem_Click(object sender, EventArgs e) { - ServerManager.SendMessage("user_get_shop", SaveSystem.CurrentSave.Username); + ServerManager.SendMessage("user_get_shop", SaveSystem.CurrentUser.Username); } private void btneditshop_Click(object sender, EventArgs e) @@ -923,7 +923,7 @@ Current legions: {legionname}"; { ServerManager.SendMessage("delete_save", JsonConvert.SerializeObject(new ClientSave { - Username = SaveSystem.CurrentSave.Username, + Username = SaveSystem.CurrentUser.Username, Password = SaveSystem.CurrentSave.Password })); diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs index 90b05a1..e4f0597 100644 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ b/ShiftOS.WinForms/Applications/Skin Loader.cs @@ -306,7 +306,7 @@ namespace ShiftOS.WinForms.Applications System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins"); } - string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname; + string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentUser.Username + "-" + fname; System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin)); }))); diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 86981f4..47b486d 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -107,7 +107,7 @@ namespace ShiftOS.WinForms Thread.Sleep(2000); writeSlow($"Hello there, fellow multi-user domain user."); writeSlow("My name, as you can tell, is hacker101."); - writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentSave.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?"); + writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentUser.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?"); writeSlow("Of course it is."); writeSlow("And I bet you 10,000 Codepoints that you have... " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints."); writeSlow("Oh, and how much upgrades have you installed since you first started using ShiftOS?"); @@ -135,7 +135,7 @@ namespace ShiftOS.WinForms Console.Write(" ..done"); TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = true; - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); StartHackerTutorial(); TerminalBackend.PrefixEnabled = true; TerminalBackend.PrintPrompt(); @@ -454,7 +454,7 @@ namespace ShiftOS.WinForms var sve = JsonConvert.DeserializeObject(msg.Contents); if(sve.Password == pass) { - Console.WriteLine("Username: " + sve.Username); + Console.WriteLine("Username: " + SaveSystem.CurrentUser.Username); Console.WriteLine("Password: " + sve.Password); Console.WriteLine("System name: " + sve.SystemName); Console.WriteLine(); @@ -531,7 +531,7 @@ namespace ShiftOS.WinForms } sve.Codepoints -= amount; - SaveSystem.TransferCodepointsFrom(sve.Username, amount); + SaveSystem.TransferCodepointsFrom(SaveSystem.CurrentUser.Username, amount); ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); SaveSystem.SaveGame(); } diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 9182b4b..90395a7 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -302,7 +302,7 @@ namespace ShiftOS.WinForms var client = new UniteClient("http://getshiftos.ml", token); var sve = new Save(); - sve.Username = client.GetEmail(); + SaveSystem.CurrentUser.Username = client.GetEmail(); sve.Password = Guid.NewGuid().ToString(); sve.SystemName = client.GetSysName(); sve.UniteAuthToken = token; diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 53d55fb..433ad2d 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -142,7 +142,7 @@ namespace ShiftOS.WinForms.Stories { WriteLine("DevX@mud - user connecting to your system.", false); Thread.Sleep(2000); - WriteLine($"Hello, {SaveSystem.CurrentSave.Username}. It's been a while."); + WriteLine($"Hello, {SaveSystem.CurrentUser.Username}. It's been a while."); WriteLine("My intelligence suggests you've installed all GUI-based Shiftorium upgrades."); WriteLine("Bet you're liking ShiftOS now that the terminal isn't the only way you can control it."); WriteLine("Well, now it's time to introduce your next task."); diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 96e5af5..b97cd1d 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -95,7 +95,7 @@ namespace ShiftOS.Engine { TerminalBackend.IsForwardingConsoleWrites = forwarding; TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - Console.WriteLine($"{SaveSystem.CurrentSave.Username} says \"{result}\"."); + Console.WriteLine($"{SaveSystem.CurrentUser.Username} says \"{result}\"."); TerminalBackend.IsForwardingConsoleWrites = false; }; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index dd5acfd..61c6676 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -312,7 +312,7 @@ end"); { Console.WriteLine(""); Lua(lua); - Console.WriteLine($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.WriteLine($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } catch (Exception e) { diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index f0acaa2..abb674d 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -148,7 +148,7 @@ Ping: {ServerManager.DigitalSocietyPing} ms switch(msg.Name) { case "getguid_fromserver": - if(SaveSystem.CurrentSave.Username == msg.Contents) + if(SaveSystem.CurrentUser.Username == msg.Contents) { client.Send(new NetObject("yes_i_am", new ServerMessage { @@ -244,7 +244,7 @@ Ping: {ServerManager.DigitalSocietyPing} ms else if(msg.Name == "update_your_cp") { var args = JsonConvert.DeserializeObject>(msg.Contents); - if(args["username"] as string == SaveSystem.CurrentSave.Username) + if(args["username"] as string == SaveSystem.CurrentUser.Username) { SaveSystem.CurrentSave.Codepoints += (long)args["amount"]; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 1c024eb..6104927 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -581,7 +581,7 @@ namespace ShiftOS.Engine 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); } IsForwardingConsoleWrites = true; if (TerminalBackend.InStory == false) @@ -590,7 +590,7 @@ namespace ShiftOS.Engine } if (TerminalBackend.PrefixEnabled) { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } IsForwardingConsoleWrites = false; } @@ -605,7 +605,7 @@ namespace ShiftOS.Engine string pass = a["password"] as string; string sys = a["sysname"] as string; string guid = msg.GUID; - if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) + if (SaveSystem.CurrentUser.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) { ForwardGUID = guid; ServerManager.SendMessage("trm_handshake_accept", $@"{{ @@ -615,7 +615,7 @@ namespace ShiftOS.Engine IsForwardingConsoleWrites = true; InvokeCommand("sos.status"); - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); IsForwardingConsoleWrites = false; } } -- cgit v1.2.3