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.Objects/MudAttributes.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/MudAttributes.cs b/ShiftOS.Objects/MudAttributes.cs index 1822356..d34c40e 100644 --- a/ShiftOS.Objects/MudAttributes.cs +++ b/ShiftOS.Objects/MudAttributes.cs @@ -1,4 +1,4 @@ -/* +/* * MIT License * * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs @@ -64,6 +64,18 @@ namespace ShiftOS.Objects public string ResponseName { get; private set; } } + public class ChatLogRequest + { + public ChatLogRequest(string chan, int backtrack = 0) + { + Channel = chan; + Backtrack = backtrack; + } + + public int Backtrack { get; set; } + public string Channel { get; set; } + } + } -- cgit v1.2.3 From fc55d4feecb64c2bae355cceac93bdac73fe00ea Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Mar 2017 08:02:30 -0500 Subject: hang on, busy making a sad victor tran face --- ShiftOS.Objects/EngineShiftnetSubscription.cs | 17 +++++++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.WinForms/Applications/Downloader.cs | 10 +++++ ShiftOS.WinForms/Properties/Resources.Designer.cs | 54 +++++++++++++++++------ ShiftOS.WinForms/Properties/Resources.resx | 3 ++ ShiftOS.WinForms/Resources/ShiftnetServices.txt | 20 +++++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + 7 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 ShiftOS.Objects/EngineShiftnetSubscription.cs create mode 100644 ShiftOS.WinForms/Resources/ShiftnetServices.txt (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/EngineShiftnetSubscription.cs b/ShiftOS.Objects/EngineShiftnetSubscription.cs new file mode 100644 index 0000000..1296a98 --- /dev/null +++ b/ShiftOS.Objects/EngineShiftnetSubscription.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class EngineShiftnetSubscription + { + public string Name { get; set; } + public string Description { get; set; } + public int CostPerMonth { get; set; } + public int DownloadSpeed { get; set; } + public string Company { get; set; } + } +} diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 484f9df..3dc0c33 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -46,6 +46,7 @@ + diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs index b1b7ed9..48a5cfd 100644 --- a/ShiftOS.WinForms/Applications/Downloader.cs +++ b/ShiftOS.WinForms/Applications/Downloader.cs @@ -187,6 +187,16 @@ namespace ShiftOS.WinForms.Applications return 256; } + public static IEnumerable GetAllSubscriptions() + { + //For now we'll have them hard-coded into the client but in future they'll be in the MUD. + + foreach(var sub in JsonConvert.DeserializeObject(Properties.Resources.ShiftnetServices)) + { + yield return sub; + } + } + public static void StartDownload(Download down) { var t = new Thread(() => diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 9262790..2df6f11 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -913,24 +913,52 @@ namespace ShiftOS.WinForms.Properties { /// /// Looks up a localized string similar to [ - ///// CALCULATOR UPGRADES /// { - /// Name: "Calculator", - /// Cost: 1000, - /// Dependencies: "wm_free_placement;desktop", - /// Description: "Crazy math problems getting you down? Well, this calculator will take care of that!" + /// Name: "Freebie Solutions", + /// DownloadSpeed: 256, + /// CostPerMonth: 0, + /// Description: "The Shiftnet is a wonderful place full of apps, games, websites and skins for ShiftOS. + /// + ///With Freebie Solutions from ShiftSoft, you'll be able to traverse the Shiftnet without any worry about monthly fees.", + /// Company: "ShiftSoft" + /// }, + /// { + /// Company: "" + /// }, + /// { + /// + /// }, + /// { + /// + /// }, + ///]. + /// + internal static string ShiftnetServices { + get { + return ResourceManager.GetString("ShiftnetServices", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [ + ///// SCREENSAVER + /// { + /// Name: "Screensavers", + /// Cost: 750, + /// Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it.", + /// Dependencies: "desktop" /// }, /// { - /// Name: "AL Calculator", - /// Cost: 150, - /// Dependencies: "calculator;app_launcher", - /// Description: "Add an App Launcher Entry for the Calculator!" + /// Name: "Shift Screensavers", + /// Cost: 100, + /// Description: "This Shifter upgrade will allow you to customize the screensaver.", + /// Dependencies: "screensavers;shifter" /// }, + /// + /// + ///// CALCULATOR UPGRADES /// { - /// Name: "Calc Equals Button", - /// Cost: 600, - /// Dependencies: "calculator", - /// Description: "Right now, you can only type numbers, [rest of string was truncated]";. + /// Name: "Calcul [rest of string was truncated]";. /// internal static string Shiftorium { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index a5e2d4e..5100329 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -472,4 +472,7 @@ ..\Resources\SnakeyTailU.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ShiftnetServices.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/ShiftnetServices.txt b/ShiftOS.WinForms/Resources/ShiftnetServices.txt new file mode 100644 index 0000000..a396849 --- /dev/null +++ b/ShiftOS.WinForms/Resources/ShiftnetServices.txt @@ -0,0 +1,20 @@ +[ + { + Name: "Freebie Solutions", + DownloadSpeed: 256, + CostPerMonth: 0, + Description: "The Shiftnet is a wonderful place full of apps, games, websites and skins for ShiftOS. + +With Freebie Solutions from ShiftSoft, you'll be able to traverse the Shiftnet without any worry about monthly fees.", + Company: "ShiftSoft" + }, + { + Company: "" + }, + { + + }, + { + + }, +] \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9c39845..7d4f0d3 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -565,6 +565,7 @@ + -- cgit v1.2.3 From f9acb299c8375522dba1ceed14b20cbf0cf58659 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 5 Mar 2017 14:36:12 -0500 Subject: Paid shiftnet subscriptions are in. You can now subscribe to a shiftnet provider... you just don't get charged....yet. --- ShiftOS.Objects/Save.cs | 2 ++ ShiftOS.WinForms/Applications/Shiftnet.cs | 45 +++++++++++++++++++++++++ ShiftOS.WinForms/Resources/ShiftnetServices.txt | 1 + 3 files changed, 48 insertions(+) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 3c7cb39..23c1d0f 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -65,6 +65,8 @@ namespace ShiftOS.Objects } } + public int LastMonthPaid { get; set; } + public int CountUpgrades() { int count = 0; diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 3da7d6a..22eeec1 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -122,10 +122,55 @@ namespace ShiftOS.WinForms.Applications { e.Cancel = true; Future.Clear(); + if (Url.StartsWith("runsyscmd/")) + { + ProcessShiftnetCmd(Url.Replace("runsyscmd/", "")); + } + ShiftnetNavigate(Url.ToString()); } } + public void ProcessShiftnetCmd(string cmd) + { + var args = cmd.Split('/'); + switch (args[0]) + { + case "setsnsub": + for(int i = 0; i < DownloadManager.GetAllSubscriptions().Length; i++) + { + if(DownloadManager.GetAllSubscriptions()[i].Name == args[1]) + { + var sub = DownloadManager.GetAllSubscriptions()[i]; + Infobox.PromptYesNo("Shiftnet", $"Are you sure you want to switch your system's Shiftnet subscription to {sub.Name} by {sub.Company}?{Environment.NewLine}{Environment.NewLine}Cost per month: {sub.CostPerMonth} CP{Environment.NewLine}Download speed: {sub.DownloadSpeed} bytes per second", new Action((answer) => + { + if(answer == true) + { + if(SaveSystem.CurrentSave.Codepoints >= sub.CostPerMonth) + { + //Initial fee gets deducted. + SaveSystem.CurrentSave.Codepoints -= sub.CostPerMonth; + //Then we set the subscription. + SaveSystem.CurrentSave.ShiftnetSubscription = i; + //Then we say that we have paid this month. + SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; + //Then we send our save to the MUD. + SaveSystem.SaveGame(); + + } + else + { + //User can't afford this subscription. + Infobox.Show("Shiftnet - Not enough Codepoints", $"You cannot afford to pay for this subscription at this time. You need {sub.CostPerMonth - SaveSystem.CurrentSave.Codepoints} more Codepoints."); + } + } + })); + } + } + break; + } + } + public Stack History = new Stack(); public Stack Future = new Stack(); diff --git a/ShiftOS.WinForms/Resources/ShiftnetServices.txt b/ShiftOS.WinForms/Resources/ShiftnetServices.txt index d5b8ab4..d8582b6 100644 --- a/ShiftOS.WinForms/Resources/ShiftnetServices.txt +++ b/ShiftOS.WinForms/Resources/ShiftnetServices.txt @@ -26,5 +26,6 @@ With Freebie Solutions from ShiftSoft, you'll be able to traverse the Shiftnet w Name: "theNet", CostPerMonth: 3000, DownloadSpeed: 786342, //768 kb/s + Description: "theNet is not *just* a Shiftnet service provider. It is theGateway to all of theShiftnet and your needs. It is also theValue service provider with theGreatest price and download speed." }, ] \ No newline at end of file -- 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.Objects') 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 081b59d749a11737b6465aacf2288d5be365cbfa Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 6 Mar 2017 20:05:24 -0500 Subject: Modular stories --- ShiftOS.Objects/Save.cs | 1 + ShiftOS_TheReturn/Story.cs | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 35bfdc2..d5faa78 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -68,6 +68,7 @@ namespace ShiftOS.Objects } public int LastMonthPaid { get; set; } + public List StoriesExperienced { get; set; } public int CountUpgrades() { diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index 9d8078e..ecd04f4 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -37,6 +37,48 @@ namespace ShiftOS.Engine { public class Story { + public static void Start(string stid) + { + foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.EndsWith(".exe") || exec.EndsWith(".dll")) + { + try + { + if (SaveSystem.CurrentSave.StoriesExperienced == null) + SaveSystem.CurrentSave.StoriesExperienced = new List(); + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes()) + { + foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + { + foreach(var attrib in mth.GetCustomAttributes(false)) + { + if(attrib is StoryAttribute) + { + var story = attrib as StoryAttribute; + if(story.StoryID == stid) + { + mth.Invoke(null, null); + SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + return; + } + } + } + } + } + } + catch { } + } + } +#if DEBUG + throw new ArgumentException("Story ID not found: " + stid + " - Talk to Michael. NOW."); +#else + Debug.Print("No such story: " + stid); +#endif + } + + public static void RunFromInternalResource(string resource_id) { var t = typeof(Properties.Resources); @@ -262,4 +304,25 @@ namespace ShiftOS.Engine thread.Start(); } } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class StoryAttribute : Attribute + { + /// + /// Creates a new instance of the attribute. + /// + /// The ID of this story plot. + /// + /// + /// The is used to turn a static, public method into a story element. Using the specified argument, the ShiftOS Engine can determine whether this plot has already been experienced, and using the classes, the ID is treated as a special Shiftorium upgrade, and you can use the attribute as well as the various other ways of determining whether a Shiftorium upgrade is installed to determine if this plot has been experienced. + /// + /// + public StoryAttribute(string id) + { + StoryID = id; + } + + public string StoryID { get; private set; } + + } } -- 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.Objects') 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 f43f6fe17d054f83c686b552201d6b4bfc83524d Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 3 Apr 2017 18:36:13 -0400 Subject: LOADS of optimizations and Pong fixes. --- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 - ShiftOS.Objects/ShiftOSMenuRenderer.cs | 51 ------- ShiftOS.WinForms/Applications/Pong.Designer.cs | 177 +++++++++++++------------ ShiftOS.WinForms/Applications/Pong.cs | 36 ++++- ShiftOS.WinForms/Oobe.cs | 30 ++++- ShiftOS.WinForms/Tools/ControlManager.cs | 107 +++------------ ShiftOS.WinForms/WinformsDesktop.cs | 13 +- ShiftOS.WinForms/WinformsWindowManager.cs | 17 +-- ShiftOS_TheReturn/Shiftorium.cs | 28 +++- 9 files changed, 217 insertions(+), 243 deletions(-) delete mode 100644 ShiftOS.Objects/ShiftOSMenuRenderer.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 3dc0c33..4514b68 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -54,7 +54,6 @@ - diff --git a/ShiftOS.Objects/ShiftOSMenuRenderer.cs b/ShiftOS.Objects/ShiftOSMenuRenderer.cs deleted file mode 100644 index c76bd35..0000000 --- a/ShiftOS.Objects/ShiftOSMenuRenderer.cs +++ /dev/null @@ -1,51 +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.Windows.Forms; - -namespace ShiftOS.Objects -{ - class ShiftOSMenuRenderer : ToolStripProfessionalRenderer - { - public ShiftOSMenuRenderer() : base(new ShiftOSColorTable()) - { - - } - - protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) - { - - } - } - - public class ShiftOSColorTable : ProfessionalColorTable - { - - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index faaf0f5..e619eaa 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -79,6 +79,11 @@ namespace ShiftOS.WinForms.Applications 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.ListBox(); + 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(); @@ -91,9 +96,6 @@ namespace ShiftOS.WinForms.Applications 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(); @@ -122,16 +124,14 @@ namespace ShiftOS.WinForms.Applications 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.flowLayoutPanel1.SuspendLayout(); + this.pnlgamestats.SuspendLayout(); this.pnlfinalstats.SuspendLayout(); this.pnllose.SuspendLayout(); this.pnlintro.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // gameTimer @@ -174,11 +174,67 @@ namespace ShiftOS.WinForms.Applications 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.Size = new System.Drawing.Size(1867, 819); 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.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; + // + // 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); @@ -192,7 +248,7 @@ namespace ShiftOS.WinForms.Applications 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.Location = new System.Drawing.Point(104, 375); this.pnlgamestats.Name = "pnlgamestats"; this.pnlgamestats.Size = new System.Drawing.Size(466, 284); this.pnlgamestats.TabIndex = 6; @@ -307,38 +363,6 @@ namespace ShiftOS.WinForms.Applications 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); @@ -373,6 +397,7 @@ namespace ShiftOS.WinForms.Applications 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; // @@ -384,6 +409,7 @@ namespace ShiftOS.WinForms.Applications 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; // @@ -394,6 +420,7 @@ namespace ShiftOS.WinForms.Applications 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; // @@ -413,6 +440,7 @@ namespace ShiftOS.WinForms.Applications 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; // @@ -432,6 +460,7 @@ namespace ShiftOS.WinForms.Applications 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; // @@ -502,10 +531,11 @@ namespace ShiftOS.WinForms.Applications 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.Location = new System.Drawing.Point(1139, 41); this.pnlintro.Name = "pnlintro"; this.pnlintro.Size = new System.Drawing.Size(595, 303); this.pnlintro.TabIndex = 13; + this.pnlintro.Tag = "header2"; // // Label6 // @@ -548,6 +578,7 @@ namespace ShiftOS.WinForms.Applications 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; @@ -577,7 +608,6 @@ namespace ShiftOS.WinForms.Applications // 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; @@ -587,7 +617,7 @@ namespace ShiftOS.WinForms.Applications // 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.Location = new System.Drawing.Point(1833, 134); this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); this.paddleComputer.Name = "paddleComputer"; this.paddleComputer.Size = new System.Drawing.Size(20, 100); @@ -599,69 +629,52 @@ namespace ShiftOS.WinForms.Applications 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.Size = new System.Drawing.Size(1867, 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) + 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, 356); + this.lblstatscodepoints.Location = new System.Drawing.Point(239, 775); this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(219, 35); + 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(542, 356); + this.lblstatsY.Location = new System.Drawing.Point(1395, 775); this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(144, 35); + 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, 356); + this.lblstatsX.Location = new System.Drawing.Point(3, 775); this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(144, 35); + 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; // - // 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); @@ -670,23 +683,23 @@ namespace ShiftOS.WinForms.Applications this.Controls.Add(this.pgcontents); this.DoubleBuffered = true; this.Name = "Pong"; - this.Text = "{PONG_NAME}"; - this.Size = new System.Drawing.Size(820, 500); + this.Size = new System.Drawing.Size(1867, 819); 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.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.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 157ce8c..a7b1aeb 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { @@ -83,6 +84,26 @@ namespace ShiftOS.WinForms.Applications 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; + } + // ERROR: Handles clauses are not supported in C# private void gameTimer_Tick(object sender, EventArgs e) @@ -102,7 +123,7 @@ namespace ShiftOS.WinForms.Applications //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.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) { if (ball.Location.Y > paddleComputer.Location.Y + 50) { @@ -116,12 +137,12 @@ namespace ShiftOS.WinForms.Applications } else { - //used to be me.location.y + //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); } - //used to be me.location.y + //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); @@ -269,6 +290,7 @@ namespace ShiftOS.WinForms.Applications } lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); } + SetupStats(); } public void SendHighscores() @@ -652,10 +674,17 @@ namespace ShiftOS.WinForms.Applications pnlhighscore.Hide(); pnlgamestats.Hide(); pnlfinalstats.Hide(); + CenterPanels(); + lblbeatai.Hide(); } public void OnSkinLoad() { + CenterPanels(); + this.SizeChanged += (o, a) => + { + CenterPanels(); + }; } public bool OnUnload() @@ -665,6 +694,7 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + CenterPanels(); } private void button2_Click(object sender, EventArgs e) diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 898f60b..d6d3b92 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -64,7 +64,10 @@ namespace ShiftOS.WinForms { while(typing == true) { + //JESUS CHRIST PAST MICHAEL. + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } charcount = texttotype.Length; @@ -452,6 +455,10 @@ namespace ShiftOS.WinForms TextType("Go ahead and type 'sos.help' to see a list of commands."); while (TutorialProgress == 0) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("As you can see, sos.help gives you a list of all commands in the system."); @@ -461,6 +468,10 @@ namespace ShiftOS.WinForms TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does."); while (TutorialProgress == 1) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } 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."); @@ -478,6 +489,10 @@ namespace ShiftOS.WinForms TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades."); while (TutorialProgress == 2) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } Clear(); @@ -502,13 +517,21 @@ namespace ShiftOS.WinForms 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) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } 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")) - { + { //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); + } TextType("Hooray! You now have the MUD Fundamentals upgrade."); @@ -520,6 +543,10 @@ namespace ShiftOS.WinForms TextType("Just run win.open without arguments, and this tutorial will be completed!"); while (TutorialProgress == 4) { + //JESUS CHRIST PAST MICHAEL. + + //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. + Thread.Sleep(100); } TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world."); @@ -528,6 +555,7 @@ namespace ShiftOS.WinForms { OnComplete?.Invoke(this, EventArgs.Empty); SaveSystem.CurrentSave.StoryPosition = 2; + this.Close(); SaveSystem.SaveGame(); AppearanceManager.SetupWindow(new Applications.Terminal()); }); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 52663d7..a2a76b7 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -67,91 +67,6 @@ namespace ShiftOS.WinForms.Tools } - 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) @@ -214,9 +129,22 @@ namespace ShiftOS.WinForms.Tools #endif } + /// + /// Centers the control along its parent. + /// + /// The control to center (this is an extension method - you can call it on a control as though it was a method in that control) + public static void CenterParent(this Control ctrl) + { + ctrl.Location = new Point( + (ctrl.Parent.Width - ctrl.Width) / 2, + (ctrl.Parent.Height - ctrl.Height) / 2 + ); + } + public static void SetupControl(Control ctrl) { SuspendDrawing(ctrl); + ctrl.SuspendLayout(); SetCursor(ctrl); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { @@ -270,13 +198,7 @@ namespace ShiftOS.WinForms.Tools a.SuppressKeyPress = true; - if (SaveSystem.CurrentSave != null) - { - if (Shiftorium.UpgradeInstalled("window_manager")) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - } + Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); } ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); @@ -293,6 +215,7 @@ namespace ShiftOS.WinForms.Tools } MakeDoubleBuffered(ctrl); + ctrl.ResumeLayout(); ResumeDrawing(ctrl); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 06f103e..033802e 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -664,10 +664,17 @@ namespace ShiftOS.WinForms /// Act. public void InvokeOnWorkerThread(Action act) { - this.Invoke(new Action(()=> + try { - act?.Invoke(); - })); + this.Invoke(new Action(() => + { + act?.Invoke(); + })); + } + catch + { + + } } public void OpenAppLauncher(Point loc) diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index 26438bf..cfcb6d3 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -184,20 +184,21 @@ namespace ShiftOS.WinForms if (maxWindows > 0) { - List formstoclose = new List(); - - for (int i = 0; i < maxWindows && i < AppearanceManager.OpenForms.Count; i++) + var windows = new List(); + foreach(var WB in AppearanceManager.OpenForms) { - var frm = AppearanceManager.OpenForms[i] as WindowBorder; - if(!frm.IsDialog) - formstoclose.Add(frm); - + if (WB is WindowBorder) + windows.Add(WB as WindowBorder); } + List formstoclose = new List(windows.Where(x => x.IsDialog == false).ToArray()); + while (formstoclose.Count > maxWindows - 1) { - formstoclose[0].Close(); + this.Close(formstoclose[0].ParentWindow); + AppearanceManager.OpenForms.Remove(formstoclose[0]); formstoclose.RemoveAt(0); + } } } diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index 0bdd9f4..4556cd6 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -46,6 +46,23 @@ namespace ShiftOS.Engine Installed?.Invoke(); } + public static string GetCategory(string id) + { + var upg = GetDefaults().FirstOrDefault(x => x.ID == id); + if (upg == null) + return "Other"; + return (upg.Category == null) ? "Other" : upg.Category; + } + + public static IEnumerable GetAllInCategory(string cat) + { + return GetDefaults().Where(x => x.Category == cat); + } + + public static bool IsCategoryEmptied(string cat) + { + return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null; + } public static bool Buy(string id, int cost) { @@ -278,8 +295,15 @@ namespace ShiftOS.Engine 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 Id { get; set; } + public string Category { get; set; } + public bool Installed + { + get + { + return Shiftorium.UpgradeInstalled(ID); + } + } public string Dependencies { get; set; } } } -- cgit v1.2.3 From 3789b48df00e89fa6dcd7e27bb6885ba880504f6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 7 Apr 2017 12:54:07 -0400 Subject: Unite API objects for ShiftOS --- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/Unite/Download.cs | 22 ++++++++++++++++++++++ ShiftOS.WinForms/Applications/FormatEditor.cs | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ShiftOS.Objects/Unite/Download.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 4514b68..d9b8bf7 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -55,6 +55,7 @@ + diff --git a/ShiftOS.Objects/Unite/Download.cs b/ShiftOS.Objects/Unite/Download.cs new file mode 100644 index 0000000..089a98c --- /dev/null +++ b/ShiftOS.Objects/Unite/Download.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects.Unite +{ + public class Download + { + public string Id { get; set; } + public string Name { get; set; } + public string Changelog { get; set; } + public string DownloadUrl { get; set; } + public bool Obsolete { get; set; } + public DateTime PostDate { get; set; } + public string ReleasedBy { get; set; } + public string DevUpdateId { get; set; } + public string ScreenshotUrl { get; set; } + public bool IsStable { get; set; } + } +} diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs index c5afc02..7491e36 100644 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ b/ShiftOS.WinForms/Applications/FormatEditor.cs @@ -35,9 +35,10 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] - [Launcher("FormatEditor", true, "al_format_editor", "Games")] + [Launcher("Format Editor", true, "al_format_editor", "Customization")] [RequiresUpgrade("format_editor")] [WinOpen("formateditor")] + [DefaultTitle("Format Editor")] [DefaultIcon("iconFormatEditor")] public partial class FormatEditor : UserControl, IShiftOSWindow { -- cgit v1.2.3 From 0d198594c4c1240c274c27706b07e2d3281975ce Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Fri, 7 Apr 2017 21:17:02 +0000 Subject: Do I even need to do server-side updating? --- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/Unite/ReleaseQuery.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 ShiftOS.Objects/Unite/ReleaseQuery.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index d9b8bf7..ac16c30 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -56,6 +56,7 @@ + diff --git a/ShiftOS.Objects/Unite/ReleaseQuery.cs b/ShiftOS.Objects/Unite/ReleaseQuery.cs new file mode 100644 index 0000000..253ce57 --- /dev/null +++ b/ShiftOS.Objects/Unite/ReleaseQuery.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects.Unite +{ + public class ReleaseQuery + { + public bool ShowUnstable { get; set; } + public bool ShowObsolete { get; set; } + public DateTime CurrentBuildDate { get; set; } + } +} -- cgit v1.2.3 From d7ac3bb7e68906de70ceff3428084a05312fb56d Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 9 Apr 2017 10:00:16 -0400 Subject: Reputation work. --- ShiftOS.Objects/Legion.cs | 12 ++++++- ShiftOS.Objects/Reputation.cs | 60 ++++++++++++++++++++++++++++++++++ ShiftOS.Objects/Save.cs | 11 +++++++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 ShiftOS.Objects/Reputation.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Legion.cs b/ShiftOS.Objects/Legion.cs index c67a11d..c5e12f3 100644 --- a/ShiftOS.Objects/Legion.cs +++ b/ShiftOS.Objects/Legion.cs @@ -58,6 +58,16 @@ namespace ShiftOS.Objects public Dictionary Roles { get; set; } public Dictionary RoleNames { get; set; } - //Just adding a birbb in here + public UserClass Class { get; set; } + public double RawReputation { get; set; } + + public Reputation Reputation + { + get + { + return (Reputation)((int)Math.Round(RawReputation)); + } + } + } } diff --git a/ShiftOS.Objects/Reputation.cs b/ShiftOS.Objects/Reputation.cs new file mode 100644 index 0000000..2bdd86d --- /dev/null +++ b/ShiftOS.Objects/Reputation.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public enum Reputation + { + Saint = 5, + Moral = 4, + Trustworthy = 3, + WellKnown = 2 + Respected = 1, + Neutral = 0, + Disrespected = -1, + Criminal = -2, + Untrustworthy = -3, + Immoral = -4, + Outcast = -5 + } + + public enum UserClass + { + /// + /// Skinners, otherwise known as "Shifters" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints. + /// + Skinner, + + /// + /// Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target. + /// + Hacker, + /// + /// Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations. + /// + Investigator, + /// + /// Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent. + /// + Explorer, + /// + /// Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe. + /// + SafetyActivist, + /// + /// Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful. + /// + PenetrationTester, + /// + /// Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints. + /// + Collector, + /// + /// Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions. + /// + Programmer + } +} diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index d5faa78..ef512eb 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -47,6 +47,17 @@ namespace ShiftOS.Objects public bool IsPatreon { get; set; } + public UserClass Class { get; set; } + public double RawReputation { get; set; } + + public Reputation Reputation + { + get + { + return (Reputation)((int)Math.Round(RawReputation)); + } + } + public string Password { get; set; } public bool PasswordHashed { get; set; } public string SystemName { get; set; } diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index ac16c30..7a19aeb 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -52,6 +52,7 @@ + -- cgit v1.2.3 From c17eadf177e550b73acc714a03039aacd073dd8d Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 9 Apr 2017 14:03:00 +0000 Subject: Simple syntax error. --- ShiftOS.Objects/Reputation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Reputation.cs b/ShiftOS.Objects/Reputation.cs index 2bdd86d..32bb911 100644 --- a/ShiftOS.Objects/Reputation.cs +++ b/ShiftOS.Objects/Reputation.cs @@ -11,7 +11,7 @@ namespace ShiftOS.Objects Saint = 5, Moral = 4, Trustworthy = 3, - WellKnown = 2 + WellKnown = 2, Respected = 1, Neutral = 0, Disrespected = -1, -- cgit v1.2.3 From 2ac1033c2dcd0e70114ab9ee5c7bd129bff6c1fa Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 9 Apr 2017 15:56:14 -0400 Subject: Legion story work (SPOILERS!) --- ShiftOS.Objects/Reputation.cs | 21 ++- .../Applications/Installer.Designer.cs | 104 +++++++++++++ ShiftOS.WinForms/Applications/Installer.cs | 150 ++++++++++++++++++ ShiftOS.WinForms/Applications/Installer.resx | 120 +++++++++++++++ .../Applications/MUDControlCentre.Designer.cs | 88 +++++++++++ ShiftOS.WinForms/Applications/MUDControlCentre.cs | 54 ++++++- ShiftOS.WinForms/Controls/TerminalBox.cs | 1 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 10 ++ ShiftOS.WinForms/Stories/LegionStory.cs | 169 +++++++++++++++++++++ 9 files changed, 707 insertions(+), 10 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/Installer.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/Installer.cs create mode 100644 ShiftOS.WinForms/Applications/Installer.resx create mode 100644 ShiftOS.WinForms/Stories/LegionStory.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Reputation.cs b/ShiftOS.Objects/Reputation.cs index 32bb911..0ddea0a 100644 --- a/ShiftOS.Objects/Reputation.cs +++ b/ShiftOS.Objects/Reputation.cs @@ -23,38 +23,43 @@ namespace ShiftOS.Objects public enum UserClass { + /// + /// The user has no class. + /// + None = 0, + /// /// Skinners, otherwise known as "Shifters" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints. /// - Skinner, + Skinner = 1, /// /// Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target. /// - Hacker, + Hacker = 2, /// /// Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations. /// - Investigator, + Investigator = 3, /// /// Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent. /// - Explorer, + Explorer = 4, /// /// Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe. /// - SafetyActivist, + SafetyActivist = 5, /// /// Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful. /// - PenetrationTester, + PenetrationTester = 6, /// /// Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints. /// - Collector, + Collector = 7, /// /// Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions. /// - Programmer + Programmer = 8 } } diff --git a/ShiftOS.WinForms/Applications/Installer.Designer.cs b/ShiftOS.WinForms/Applications/Installer.Designer.cs new file mode 100644 index 0000000..8b4ae81 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Installer.Designer.cs @@ -0,0 +1,104 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class Installer + { + /// + /// 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.lbtitle = new System.Windows.Forms.Label(); + this.pnlselectfile = new System.Windows.Forms.Panel(); + this.pginstall = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); + this.lbprogress = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbtitle + // + this.lbtitle.AutoSize = true; + this.lbtitle.Location = new System.Drawing.Point(14, 13); + this.lbtitle.Name = "lbtitle"; + this.lbtitle.Size = new System.Drawing.Size(155, 13); + this.lbtitle.TabIndex = 0; + this.lbtitle.Tag = "header2"; + this.lbtitle.Text = "Installing MUD Control Centre..."; + // + // pnlselectfile + // + this.pnlselectfile.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.pnlselectfile.Location = new System.Drawing.Point(17, 48); + this.pnlselectfile.Name = "pnlselectfile"; + this.pnlselectfile.Size = new System.Drawing.Size(414, 85); + this.pnlselectfile.TabIndex = 1; + this.pnlselectfile.VisibleChanged += new System.EventHandler(this.pnlselectfile_VisibleChanged); + // + // pginstall + // + this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pginstall.BlockSize = 5; + this.pginstall.Location = new System.Drawing.Point(17, 161); + this.pginstall.Maximum = 100; + this.pginstall.Name = "pginstall"; + this.pginstall.Size = new System.Drawing.Size(414, 23); + this.pginstall.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.pginstall.TabIndex = 2; + this.pginstall.Text = "shiftedProgressBar1"; + this.pginstall.Value = 0; + // + // lbprogress + // + this.lbprogress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbprogress.AutoSize = true; + this.lbprogress.Location = new System.Drawing.Point(17, 140); + this.lbprogress.Name = "lbprogress"; + this.lbprogress.Size = new System.Drawing.Size(35, 13); + this.lbprogress.TabIndex = 3; + this.lbprogress.Text = "label1"; + // + // Installer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbprogress); + this.Controls.Add(this.pginstall); + this.Controls.Add(this.pnlselectfile); + this.Controls.Add(this.lbtitle); + this.Name = "Installer"; + this.Size = new System.Drawing.Size(447, 203); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbtitle; + private System.Windows.Forms.Panel pnlselectfile; + private Controls.ShiftedProgressBar pginstall; + private System.Windows.Forms.Label lbprogress; + } +} diff --git a/ShiftOS.WinForms/Applications/Installer.cs b/ShiftOS.WinForms/Applications/Installer.cs new file mode 100644 index 0000000..1b5521e --- /dev/null +++ b/ShiftOS.WinForms/Applications/Installer.cs @@ -0,0 +1,150 @@ +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 +{ + public partial class Installer : UserControl, IShiftOSWindow + { + public Installer() + { + InitializeComponent(); + lbtitle.Text = "Select file"; + } + + public void InitiateInstall(Installation install) + { + pnlselectfile.Hide(); + install.ProgressReported += (p) => + { + this.Invoke(new Action(() => + { + pginstall.Value = p; + })); + }; + install.StatusReported += (s) => + { + this.Invoke(new Action(() => + { + lbprogress.Text = s; + })); + }; + install.InstallCompleted += () => + { + this.Invoke(new Action(() => + { + lbtitle.Text = "Select file"; + pnlselectfile.Show(); + })); + isInstalling = false; + InstallCompleted?.Invoke(); + }; + isInstalling = true; + install.Install(); + } + + public void OnLoad() + { + } + + private bool isInstalling = false; + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return !isInstalling; //Don't close if an install is running. + } + + public void OnUpgrade() + { + + } + + private void pnlselectfile_VisibleChanged(object sender, EventArgs e) + { + if(this.ParentForm != null) + { + this.ParentForm.Height = (pnlselectfile.Visible == true) ? this.ParentForm.Height + pnlselectfile.Height : this.ParentForm.Height - pnlselectfile.Height; + } + } + public event Action InstallCompleted; + } + + public abstract class Installation + { + /// + /// The display name of the installation. + /// + public string Name { get; set; } + + /// + /// Occurs when the installation updates its status. + /// + public event Action StatusReported; + /// + /// Occurs when the installation updates its progress percentage. + /// + public event Action ProgressReported; + /// + /// Occurs when the installation completes. + /// + public event Action InstallCompleted; + + /// + /// Start the installation. + /// + public void Install() + { + var t = new System.Threading.Thread(() => + { + ProgressReported?.Invoke(0); + StatusReported?.Invoke(""); + Run(); + ProgressReported?.Invoke(100); + StatusReported?.Invoke("Installation completed."); + InstallCompleted?.Invoke(); + }); + t.IsBackground = true; + t.Start(); + } + + /// + /// Sets the install progress percentage. + /// + /// The installation percentage. + protected void SetProgress(int value) + { + if (value < 0 || value > 100) + throw new ArgumentOutOfRangeException("value", "A percentage is typically between 0 and 100.... derp..."); + ProgressReported?.Invoke(value); + } + + /// + /// Sets the install status text. + /// + /// Text to display as status. + protected void SetStatus(string status) + { + StatusReported?.Invoke(status); + } + + /// + /// User-defined code to run during install. Once this code is ran, the installation is complete. + /// + protected abstract void Run(); + } + + + + +} diff --git a/ShiftOS.WinForms/Applications/Installer.resx b/ShiftOS.WinForms/Applications/Installer.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/Installer.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/Applications/MUDControlCentre.Designer.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs index ba4c4f1..e2c0af3 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.Designer.cs @@ -144,6 +144,12 @@ namespace ShiftOS.WinForms.Applications this.you_memos = new System.Windows.Forms.Panel(); this.flmemos = new System.Windows.Forms.FlowLayoutPanel(); this.label3 = new System.Windows.Forms.Label(); + this.pnlclasses = new System.Windows.Forms.Panel(); + this.lbclasstitle = new System.Windows.Forms.Label(); + this.lbclassdesc = new System.Windows.Forms.Label(); + this.lbclasses = new System.Windows.Forms.ListBox(); + this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnchooseclass = new System.Windows.Forms.Button(); this.menuStrip1.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -172,6 +178,8 @@ namespace ShiftOS.WinForms.Applications this.panel3.SuspendLayout(); this.flowLayoutPanel2.SuspendLayout(); this.you_memos.SuspendLayout(); + this.pnlclasses.SuspendLayout(); + this.flowLayoutPanel6.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -301,6 +309,7 @@ namespace ShiftOS.WinForms.Applications // // toolStripContainer1.ContentPanel // + this.toolStripContainer1.ContentPanel.Controls.Add(this.pnlclasses); this.toolStripContainer1.ContentPanel.Controls.Add(this.you_systemstatus); this.toolStripContainer1.ContentPanel.Controls.Add(this.shop_all); this.toolStripContainer1.ContentPanel.Controls.Add(this.shop_view); @@ -1182,6 +1191,75 @@ namespace ShiftOS.WinForms.Applications this.label3.Tag = "header1"; this.label3.Text = "Memos"; // + // pnlclasses + // + this.pnlclasses.Controls.Add(this.flowLayoutPanel6); + this.pnlclasses.Controls.Add(this.lbclasses); + this.pnlclasses.Controls.Add(this.lbclassdesc); + this.pnlclasses.Controls.Add(this.lbclasstitle); + this.pnlclasses.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlclasses.Location = new System.Drawing.Point(0, 0); + this.pnlclasses.Name = "pnlclasses"; + this.pnlclasses.Size = new System.Drawing.Size(756, 464); + this.pnlclasses.TabIndex = 3; + // + // lbclasstitle + // + this.lbclasstitle.AutoSize = true; + this.lbclasstitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbclasstitle.Location = new System.Drawing.Point(0, 0); + this.lbclasstitle.Name = "lbclasstitle"; + this.lbclasstitle.Padding = new System.Windows.Forms.Padding(10); + this.lbclasstitle.Size = new System.Drawing.Size(82, 33); + this.lbclasstitle.TabIndex = 0; + this.lbclasstitle.Tag = "header1"; + this.lbclasstitle.Text = "Join a class"; + // + // lbclassdesc + // + this.lbclassdesc.AutoSize = true; + this.lbclassdesc.Dock = System.Windows.Forms.DockStyle.Top; + this.lbclassdesc.Location = new System.Drawing.Point(0, 33); + this.lbclassdesc.Name = "lbclassdesc"; + this.lbclassdesc.Padding = new System.Windows.Forms.Padding(10); + this.lbclassdesc.Size = new System.Drawing.Size(727, 33); + this.lbclassdesc.TabIndex = 1; + this.lbclassdesc.Text = "A class is a way for the multi-user domain to better understand you. It defines w" + + "ho you are as a sentient being, what you do, what you like, and so on."; + // + // lbclasses + // + this.lbclasses.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbclasses.FormattingEnabled = true; + this.lbclasses.Location = new System.Drawing.Point(0, 66); + this.lbclasses.Name = "lbclasses"; + this.lbclasses.Size = new System.Drawing.Size(756, 398); + this.lbclasses.TabIndex = 2; + // + // flowLayoutPanel6 + // + this.flowLayoutPanel6.AutoSize = true; + this.flowLayoutPanel6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel6.Controls.Add(this.btnchooseclass); + this.flowLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 415); + this.flowLayoutPanel6.Name = "flowLayoutPanel6"; + this.flowLayoutPanel6.Padding = new System.Windows.Forms.Padding(10); + this.flowLayoutPanel6.Size = new System.Drawing.Size(756, 49); + this.flowLayoutPanel6.TabIndex = 3; + // + // btnchooseclass + // + this.btnchooseclass.AutoSize = true; + this.btnchooseclass.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnchooseclass.Location = new System.Drawing.Point(13, 13); + this.btnchooseclass.Name = "btnchooseclass"; + this.btnchooseclass.Size = new System.Drawing.Size(53, 23); + this.btnchooseclass.TabIndex = 0; + this.btnchooseclass.Text = "Choose"; + this.btnchooseclass.UseVisualStyleBackColor = true; + this.btnchooseclass.Click += new System.EventHandler(this.btnchooseclass_Click); + // // MUDControlCentre // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1242,6 +1320,10 @@ namespace ShiftOS.WinForms.Applications this.flowLayoutPanel2.PerformLayout(); this.you_memos.ResumeLayout(false); this.you_memos.PerformLayout(); + this.pnlclasses.ResumeLayout(false); + this.pnlclasses.PerformLayout(); + this.flowLayoutPanel6.ResumeLayout(false); + this.flowLayoutPanel6.PerformLayout(); this.ResumeLayout(false); } @@ -1339,5 +1421,11 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.ToolStripMenuItem chatToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem joinAChatToolStripMenuItem; private System.Windows.Forms.Button btndeletesave; + private System.Windows.Forms.Panel pnlclasses; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6; + private System.Windows.Forms.Button btnchooseclass; + private System.Windows.Forms.ListBox lbclasses; + private System.Windows.Forms.Label lbclassdesc; + private System.Windows.Forms.Label lbclasstitle; } } diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index e2668bd..5a51f48 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -39,7 +39,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] - [RequiresUpgrade("mud_fundamentals")] + [RequiresUpgrade("mud_control_centre")] [Launcher("MUD Control Centre", true, "al_mud_control_centre", "Networking")] [WinOpen("mud_control_centre")] [DefaultIcon("iconSysinfo")] @@ -177,6 +177,42 @@ namespace ShiftOS.WinForms.Applications }; } + + + internal void ShowClasses() + { + var descriptions = new Dictionary { + + { UserClass.Skinner, "Skinners, otherwise known as \"Shifters\" due to their excessive use of the Shifter application, like to customize ShiftOS to look like other operating systems or even have an entirely different UI. They gain heaps of codepoints from it, and like to sell their skins for even more Codepoints." }, + { UserClass.Hacker, "Hackers are notorious for taking down large groups and individuals of which have many useful documents and Codepoints on their system. Hackers enjoy the rush of typing malicious commands into their terminals and seeing how they affect their target." }, + { UserClass.Investigator, "Much like hackers, investigators are skilled with a terminal and breaching systems, but they don't do it directly for monetary gain. They will search a target's system for any files and clues that may lead to them being guilty of a crime within the digital society. Unlike Hackers, Investigators mostly have higher reputations in society, and go after those with lower reputations."}, + { UserClass.Explorer, "Explorers like to venture the vast regions of the multi-user domain and Shiftnet looking for secrets, hidden tools and software, and finding the hidden truths behind their screen. Explorers don't always know how to hack, but if it involves finding a secret about ShiftOS, they will do it. They typically do not have malicious intent."}, + { UserClass.SafetyActivist, "Safety Activists are skilled with exploitation and hacking, but they only go after the worst there is in the multi-user domain. Crime rings, large hacker groups, you name it. Their primary goal is keeping the multi-user domain safe." }, + { UserClass.PenetrationTester, "Penetration testers go hand-in-hand with Safety Activists. They go after the good guys, but rather than attacking them, they alert them that an exploit was found in their service and that this exploit should be fixed. They are a gray subject though - you never know if you are dealing with a genuine pen-tester or a hacker skilled with social engineering. Be careful." }, + { UserClass.Collector, "Collectors go well with Explorers - however, Collectors are the ones who open shops. They like to find rare objects and sell them for Codepoints." }, + {UserClass.Programmer, "Programmers are the ones who write applications and services for ShiftOS and the multi-user domain. Depending on the code that they write, they can be seen as either morally wrong sentiences or morally correct sentiences, it's up to their decisions." }, + + }; + + lbclasses.Items.Clear(); + lbclasses.SelectedIndexChanged += (o, a) => + { + newClass = (UserClass)Enum.Parse(typeof(UserClass), lbclasses.SelectedItem.ToString()); + lbclassdesc.Text = descriptions[newClass]; + lbclasstitle.Text = newClass.ToString(); + }; + foreach (var kv in descriptions) + { + lbclasses.Items.Add(kv.Key.ToString()); + + } + menuStrip1.Hide(); + pnlclasses.Show(); + pnlclasses.BringToFront(); + } + + UserClass newClass = UserClass.None; + public void ListAllChats(Channel[] channels) { shop_all.BringToFront(); @@ -890,5 +926,21 @@ Current legions: {legionname}"; } }); } + + public event Action ClassChanged; + + private void btnchooseclass_Click(object sender, EventArgs e) + { + if(newClass != UserClass.None) + { + SaveSystem.CurrentSave.Class = newClass; + SaveSystem.SaveGame(); + ClassChanged?.Invoke(); + menuStrip1.Show(); + pnlclasses.SendToBack(); + this.SetupSystemStatus(); + return; + } + } } } diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index bc2bcc0..df820f7 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,7 +64,6 @@ namespace ShiftOS.WinForms.Controls 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); diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index ca0001e..95612ef 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -131,6 +131,12 @@ GraphicPicker.cs + + UserControl + + + Installer.cs + UserControl @@ -279,6 +285,7 @@ + @@ -336,6 +343,9 @@ GraphicPicker.cs + + Installer.cs + ShiftLetters.cs diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs new file mode 100644 index 0000000..424c54b --- /dev/null +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Stories +{ + public static class LegionStory + { + private static void WriteLine(string text, bool showCharacterName=true) + { + Console.WriteLine(); + if (showCharacterName == true) + { + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkMagenta; + Console.Write("DevX"); + Console.ForegroundColor = ConsoleColor.White; + Console.Write("@"); + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.Write("mud: "); + } + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + + foreach (var c in text) + { + Desktop.InvokeOnWorkerThread(() => + { + Console.Write(c); + }); + Thread.Sleep(75); + } + Thread.Sleep(1000); + } + + public static bool terminalOpen() + { + foreach(var win in AppearanceManager.OpenForms) + { + if (win.ParentWindow is Applications.Terminal) + return true; + } + return false; + } + + [Story("mud_control_centre")] + public static void MCC_Placeholder() + { + //What a way to create unbuyable, engine-managed Shiftorium Upgrades... :P + } + + [Story("devx_legions")] + public static void DevXLegionStory() + { + bool waiting = false; + //Used for DevX dialogue. + //Used for legion selection. + var mud = new Applications.MUDControlCentre(); + //For installing the MCC + var installer = new Applications.Installer(); + installer.InstallCompleted += () => + { + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.Close(installer); + }); + waiting = false; + }; + + if (!terminalOpen()) + { + var term = new Applications.Terminal(); + AppearanceManager.SetupWindow(term); + } + + var t = new Thread(() => + { + WriteLine("DevX@mud - user connecting to your system.", false); + Thread.Sleep(2000); + WriteLine($"Hello, {SaveSystem.CurrentSave.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."); + WriteLine("In the multi-user domain, each user has a reputation value associated with them."); + WriteLine("Right now, you have a reputation of 0, Neutral."); + WriteLine("This means that nobody has an opinion on you, yet."); + WriteLine("What a good time to make your presence known?"); + WriteLine("I have an application for you to try, that will help you out in the multi-user domain, and help you make yourself famous."); + WriteLine("In the digital society, you can't survive long as a lone sentience. You must kongregate with a group, and these groups are called \"legions\"."); + WriteLine("This application will assist you in finding one. A legion is a group of sentiences who carry out actions together. They're like... a pack of wolves, or a family, if you will."); + WriteLine("They share Codepoints, documents, applications, and other things with each other."); + WriteLine("And they all have their own goals."); + WriteLine("Up until now, you've been blindly following my directions, with the goal of upgrading ShiftOS. Now, it's time for you to join a legion, and fulfill their goals, to become known within the digital society."); + + WriteLine("You'll do all of this through the MUD Control Centre."); + WriteLine("I'll set it up on your system now."); + //Set up an Installer. + waiting = true; + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.SetupWindow(installer); + installer.InitiateInstall(new MCCInstallation()); + }); + while (waiting == true) + Thread.Sleep(25); + + WriteLine("There, it's all installed, so let's get you set up with a legion, shall we?"); + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.SetupWindow(mud); + mud.ShowClasses(); + mud.ClassChanged += () => + { + waiting = false; + }; + }); + WriteLine("First, select a class. A class will help define your personality within the multi-user domain. It'll determine the best legions for you."); + waiting = true; + while (waiting == true) + Thread.Sleep(25); + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + }); + t.IsBackground = true; + t.Start(); + + TerminalBackend.PrefixEnabled = false; + } + + public class MCCInstallation : Applications.Installation + { + protected override void Run() + { + SetStatus("Beginning installation..."); + Thread.Sleep(1270); + SetProgress(10); + SetStatus("Installing base application..."); + for(int i = 0; i < 45; i++) + { + Thread.Sleep(25); + SetProgress(10 + i); + } + SetStatus("Configuring system..."); + //First, we initialize the user's legion value. + SaveSystem.CurrentSave.CurrentLegions = new List(); + Thread.Sleep(250); + SetProgress(65); + //Now we initialize their shop value. + SaveSystem.CurrentSave.MyShop = null; + Thread.Sleep(200); + SetProgress(75); + //Now for their reputation... + SaveSystem.CurrentSave.RawReputation = 0.000; + Thread.Sleep(250); + SetProgress(90); + //Now their class. + SaveSystem.CurrentSave.Class = Objects.UserClass.None; + Thread.Sleep(200); + Story.Start("mud_control_centre"); + SaveSystem.SaveGame(); + SetProgress(100); + } + } + } +} -- cgit v1.2.3 From db563c54aedf5e9d96ca70eec08c560ccbc42d8d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 21 Apr 2017 18:53:41 -0400 Subject: Add ShiftOS->Host Shared Persistence ShiftOS can now write to the shared folder when saving files/deleting files to the 1:/ drive. --- ShiftOS.Objects/ShiftFS.cs | 12 +++++-- .../Applications/FileSkimmer.Designer.cs | 31 +++++++++++++++- ShiftOS.WinForms/Applications/FileSkimmer.cs | 41 ++++++++++++++++++++++ ShiftOS.WinForms/Resources/Shiftorium.txt | 28 +++++++++++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/SkinCommands.cs | 24 +++++++++++++ ShiftOS_TheReturn/Paths.cs | 41 +++++++++++++++++++++- 7 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 ShiftOS.WinForms/SkinCommands.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index 2c6b28b..d35e5b7 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -173,6 +173,11 @@ namespace ShiftOS.Objects.ShiftFS t.Start(); } + public static event Action DirectoryCreated; + public static event Action DirectoryDeleted; + public static event Action FileWritten; + public static event Action FileDeleted; + public static void CreateDirectory(string path) { @@ -190,6 +195,7 @@ namespace ShiftOS.Objects.ShiftFS Name = pathlist[pathlist.Length - 1], permissions = CurrentUser, }); + DirectoryCreated?.Invoke(path); } else { @@ -231,7 +237,7 @@ namespace ShiftOS.Objects.ShiftFS var f = dir.FindFileByName(pathlist[pathlist.Length - 1]); f.Data = Encoding.UTF8.GetBytes(contents); } - + FileWritten?.Invoke(path); } @@ -248,10 +254,12 @@ namespace ShiftOS.Objects.ShiftFS if (FileExists(path)) { dir.RemoveFile(pathlist[pathlist.Length - 1]); + FileDeleted?.Invoke(path); } else { dir.RemoveDirectory(pathlist[pathlist.Length - 1]); + DirectoryDeleted?.Invoke(path); } } @@ -276,7 +284,7 @@ namespace ShiftOS.Objects.ShiftFS var f = dir.FindFileByName(pathlist[pathlist.Length - 1]); f.Data = contents; } - + FileWritten?.Invoke(path); } diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index b75f801..63b61cc 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -58,6 +58,9 @@ namespace ShiftOS.WinForms.Applications this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.newFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.connectToRemoteServerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.moveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.panel1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -70,6 +73,8 @@ namespace ShiftOS.WinForms.Applications this.lvitems.Size = new System.Drawing.Size(634, 332); this.lvitems.TabIndex = 0; this.lvitems.UseCompatibleStateImageBehavior = false; + this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged); + this.lvitems.SelectedIndexChanged += new System.EventHandler(this.lvitems_SelectedIndexChanged); this.lvitems.DoubleClick += new System.EventHandler(this.lvitems_DoubleClick); // // panel1 @@ -95,7 +100,10 @@ namespace ShiftOS.WinForms.Applications // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.newFolderToolStripMenuItem, - this.deleteToolStripMenuItem}); + this.deleteToolStripMenuItem, + this.connectToRemoteServerToolStripMenuItem, + this.copyToolStripMenuItem, + this.moveToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(634, 24); @@ -115,6 +123,24 @@ namespace ShiftOS.WinForms.Applications this.deleteToolStripMenuItem.Size = new System.Drawing.Size(52, 20); this.deleteToolStripMenuItem.Text = "Delete"; // + // connectToRemoteServerToolStripMenuItem + // + this.connectToRemoteServerToolStripMenuItem.Name = "connectToRemoteServerToolStripMenuItem"; + this.connectToRemoteServerToolStripMenuItem.Size = new System.Drawing.Size(153, 20); + this.connectToRemoteServerToolStripMenuItem.Text = "Connect to remote server"; + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.Size = new System.Drawing.Size(47, 20); + this.copyToolStripMenuItem.Text = "Copy"; + // + // moveToolStripMenuItem + // + this.moveToolStripMenuItem.Name = "moveToolStripMenuItem"; + this.moveToolStripMenuItem.Size = new System.Drawing.Size(49, 20); + this.moveToolStripMenuItem.Text = "Move"; + // // FileSkimmer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -140,5 +166,8 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem newFolderToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem connectToRemoteServerToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem; } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index b9040ae..689c718 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -259,6 +259,9 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + moveToolStripMenuItem.Visible = false; + copyToolStripMenuItem.Visible = false; + } private void newFolderToolStripMenuItem_Click(object sender, EventArgs e) @@ -283,6 +286,44 @@ namespace ShiftOS.WinForms.Applications } }); } + + private void lvitems_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + if (currentdir != "__system") + { + var itm = lvitems.SelectedItems[0]; + if (itm.Tag.ToString() != "__..") + { + if (DirectoryExists(currentdir + "/" + itm.Tag.ToString())) + { + moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move_folder"); + copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy_folder"); + } + else if (FileExists(currentdir + "/" + itm.Tag.ToString())) + { + moveToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_move"); + copyToolStripMenuItem.Visible = Shiftorium.UpgradeInstalled("fs_copy"); + } + } + } + } + catch + { + moveToolStripMenuItem.Visible = false; + copyToolStripMenuItem.Visible = false; + } + } + + private void lvitems_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) + { + if(lvitems.SelectedItems.Count == 0) + { + moveToolStripMenuItem.Visible = false; + copyToolStripMenuItem.Visible = false; + } + } } diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index c70f849..2cd9680 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -77,6 +77,34 @@ Category: "Enhancements", Description: "You can add numbers together, but it must be tiring to add the same number over and over. This multiplication button will make it easier for you!" }, + { + Name: "FS Copy", + Cost: 75, + Dependencies: "file_skimmer", + Description: "It is cool to be able to browse your files, but what if you need a new copy of a file? This upgrade adds a button to the File Skimmer that allows you to copy single files to new locations.", + Category: "Enhancements" + }, + { + Name: "FS Move", + Cost: 75, + Dependencies: "file_skimmer", + Description: "Want to move files from one place to another? This upgrade adds a button to the File Skimmer that does just that!", + Category: "Enhancements" + }, + { + Name: "FS Copy Folder", + Cost: 100, + Dependencies: "fs_copy", + Description: "You can copy single files, but what if you have a lot of files in a folder that you need to get copied over? This upgrade adds the ability to copy a folder to a new location in the File Skimmer.", + Category: "Enhancements" + }, + { + Name: "FS Move Folder", + Cost: 100, + Dependencies: "fs_move", + Description: "Being able to move single files is great, but it takes time to move all the files in a folder to a new location. This upgrade will cut down on that time!", + Category: "Enhancements" + }, { Name: "Calc Divide Button", Cost: 800, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index b9e6910..9dc3593 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -295,6 +295,7 @@ + diff --git a/ShiftOS.WinForms/SkinCommands.cs b/ShiftOS.WinForms/SkinCommands.cs new file mode 100644 index 0000000..1f32d96 --- /dev/null +++ b/ShiftOS.WinForms/SkinCommands.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using ShiftOS.Engine; +using ShiftOS.Objects.ShiftFS; + +namespace ShiftOS.WinForms +{ + [Namespace("skins")] + public static class SkinCommands + { + [Command("reset")] + [RequiresUpgrade("shifter")] + public static bool ResetSkin() + { + Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(new Skin())); + SkinEngine.LoadSkin(); + return true; + } + } +} diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index 2fc55fd..a7d32e7 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -40,7 +40,6 @@ namespace ShiftOS.Engine public static void Init() { Locations = new Dictionary(); - Locations.Add("classic", "C:\\ShiftOS"); Locations.Add("root", "0:"); AddPath("root", "system"); @@ -133,6 +132,46 @@ namespace ShiftOS.Engine mount.Name = "Shared"; Utils.Mount(JsonConvert.SerializeObject(mount)); ScanForDirectories(SharedFolder, 1); + Utils.DirectoryCreated += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (!System.IO.Directory.Exists(real)) + System.IO.Directory.CreateDirectory(real); + } + }; + + Utils.DirectoryDeleted += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (System.IO.Directory.Exists(real)) + System.IO.Directory.Delete(real, true); + } + }; + + Utils.FileWritten += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + System.IO.File.WriteAllBytes(real, ReadAllBytes(dir)); + } + }; + + Utils.FileDeleted += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (System.IO.File.Exists(real)) + System.IO.File.Delete(real); + } + }; + + } -- cgit v1.2.3 From f9f834b1c31f2b6c611f44b2eba8d7ec816145f5 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 21 Apr 2017 19:42:41 -0400 Subject: Add copying/moving of files/dirs --- ShiftOS.Objects/ShiftFS.cs | 57 ++++++++++++++++++++ ShiftOS.WinForms/Applications/FileDialog.cs | 47 ++++++++++++---- .../Applications/FileSkimmer.Designer.cs | 2 + ShiftOS.WinForms/Applications/FileSkimmer.cs | 63 ++++++++++++++++++++++ 4 files changed, 160 insertions(+), 9 deletions(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index d35e5b7..713bd17 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -401,6 +401,63 @@ namespace ShiftOS.Objects.ShiftFS return paths.ToArray(); } + /// + /// Copies a file or directory from one path to another, deleting the original. + /// + /// THe input path, must be a valid directory or file. + /// The output path. + public static void Move(string path, string target) + { + if (FileExists(path)) + { + WriteAllBytes(target, ReadAllBytes(path)); + Delete(path); + } + else if (DirectoryExists(path)) + { + if (!DirectoryExists(target)) + CreateDirectory(target); + foreach (var file in GetFiles(path)) + { + var name = GetFileInfo(file).Name; + Copy(file, target + "/" + name); + } + foreach (var dir in GetDirectories(path)) + { + string name = GetDirectoryInfo(dir).Name; + Copy(dir, target + "/" + name); + } + Delete(path); + } + } + + + /// + /// Copies a file or directory from one path to another. + /// + /// The input path, must be a valid directory or file. + /// The output path. + public static void Copy(string path, string target) + { + if (FileExists(path)) + WriteAllBytes(target, ReadAllBytes(path)); + else if (DirectoryExists(path)) + { + if (!DirectoryExists(target)) + CreateDirectory(target); + foreach(var file in GetFiles(path)) + { + var name = GetFileInfo(file).Name; + Copy(file, target + "/" + name); + } + foreach(var dir in GetDirectories(path)) + { + string name = GetDirectoryInfo(dir).Name; + Copy(dir, target + "/" + name); + } + } + } + public static string[] GetFiles(string path) { string[] pathlist = path.Split('/'); diff --git a/ShiftOS.WinForms/Applications/FileDialog.cs b/ShiftOS.WinForms/Applications/FileDialog.cs index 308be7d..ba92f08 100644 --- a/ShiftOS.WinForms/Applications/FileDialog.cs +++ b/ShiftOS.WinForms/Applications/FileDialog.cs @@ -60,9 +60,20 @@ namespace ShiftOS.WinForms.Applications try { var itm = lvitems.SelectedItems[0]; - if (FileExists(currentdir + "/" + itm.Text)) + if (cbfiletypes.Text != "Directory") { - txtfilename.Text = itm.Text; + if (FileExists(currentdir + "/" + itm.Text)) + { + txtfilename.Text = itm.Text; + } + } + else + { + if (DirectoryExists(currentdir + "/" + itm.Text)) + { + txtfilename.Text = itm.Text; + } + } } catch { } @@ -72,23 +83,41 @@ namespace ShiftOS.WinForms.Applications { string fname = ""; fname = (!string.IsNullOrWhiteSpace(txtfilename.Text)) ? txtfilename.Text : ""; - fname = (!fname.EndsWith(cbfiletypes.SelectedItem.ToString())) ? fname + cbfiletypes.SelectedItem.ToString() : fname; - fname = (fname == cbfiletypes.SelectedItem.ToString()) ? "" : fname; + if (cbfiletypes.Text != "Directory") + { + fname = (!fname.EndsWith(cbfiletypes.SelectedItem.ToString())) ? fname + cbfiletypes.SelectedItem.ToString() : fname; + fname = (fname == cbfiletypes.SelectedItem.ToString()) ? "" : fname; + } switch (style) { case FileOpenerStyle.Open: - - if(FileExists(currentdir + "/" + fname)) + if (cbfiletypes.Text == "Directory") { - callback?.Invoke(currentdir + "/" + fname); - this.Close(); + if (DirectoryExists(currentdir + "/" + fname)) + { + callback?.Invoke(currentdir + "/" + fname); + this.Close(); + } + else + { + Infobox.Show("{FILE_NOT_FOUND}", "{FILE_NOT_FOUND_EXP}"); + } + } else { - Infobox.Show("{FILE_NOT_FOUND}", "{FILE_NOT_FOUND_EXP}"); + if (FileExists(currentdir + "/" + fname)) + { + callback?.Invoke(currentdir + "/" + fname); + this.Close(); + } + else + { + Infobox.Show("{FILE_NOT_FOUND}", "{FILE_NOT_FOUND_EXP}"); + } } break; case FileOpenerStyle.Save: diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index 63b61cc..91a72da 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -134,12 +134,14 @@ namespace ShiftOS.WinForms.Applications this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; this.copyToolStripMenuItem.Size = new System.Drawing.Size(47, 20); this.copyToolStripMenuItem.Text = "Copy"; + this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); // // moveToolStripMenuItem // this.moveToolStripMenuItem.Name = "moveToolStripMenuItem"; this.moveToolStripMenuItem.Size = new System.Drawing.Size(49, 20); this.moveToolStripMenuItem.Text = "Move"; + this.moveToolStripMenuItem.Click += new System.EventHandler(this.moveToolStripMenuItem_Click); // // FileSkimmer // diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index 689c718..4b11d24 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -324,6 +324,69 @@ namespace ShiftOS.WinForms.Applications copyToolStripMenuItem.Visible = false; } } + + private void copyToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString(); + if (DirectoryExists(path)) + { + FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) => + { + Copy(path, newPath); + ResetList(); + }); + } + else if (FileExists(path)) + { + string[] psplit = path.Split('.'); + string ext = "." + psplit[psplit.Length - 1]; + FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) => + { + Copy(path, newPath); + ResetList(); + }); + + } + } + catch + { + + } + } + + private void moveToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + string path = currentdir + "/" + lvitems.SelectedItems[0].Tag.ToString(); + if (DirectoryExists(path)) + { + FileSkimmerBackend.GetFile(new[] { "Directory" }, FileOpenerStyle.Save, (newPath) => + { + Utils.Move(path, newPath); + ResetList(); + }); + } + else if (FileExists(path)) + { + string[] psplit = path.Split('.'); + string ext = psplit[psplit.Length - 1]; + FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, (newPath) => + { + Utils.Move(path, newPath); + ResetList(); + }); + + } + } + catch + { + + } + + } } -- 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.Objects') 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 a99711507970055e02dd678e613e9d8546e6742e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 30 Apr 2017 20:28:31 -0400 Subject: fix unite login and add multiuser support --- ShiftOS.Objects/ClientSave.cs | 9 +++ ShiftOS.Objects/Save.cs | 2 + ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/UniteLoginDialog.Designer.cs | 4 +- ShiftOS_TheReturn/SaveSystem.cs | 99 +++++++++++++++++++---- ShiftOS_TheReturn/TerminalBackend.cs | 110 ++++++++++++++++++-------- 6 files changed, 176 insertions(+), 49 deletions(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ClientSave.cs b/ShiftOS.Objects/ClientSave.cs index edbb7dc..fbe1044 100644 --- a/ShiftOS.Objects/ClientSave.cs +++ b/ShiftOS.Objects/ClientSave.cs @@ -34,5 +34,14 @@ namespace ShiftOS.Objects { public string Username { get; set; } public string Password { get; set; } + public UserPermissions Permissions { get; set; } + } + + public enum UserPermissions + { + Root, + Admin, + User, + Guest } } diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 7208de5..1adaf3b 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -93,6 +93,8 @@ namespace ShiftOS.Objects } return count; } + + public List Users = new List(); } public class SettingsObject : DynamicObject diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 3b1a020..d35f7e0 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -283,6 +283,7 @@ namespace ShiftOS.WinForms.Applications } TerminalBackend.LastCommand = text3; TextSent?.Invoke(text4); + TerminalBackend.SendText(text4); if (TerminalBackend.InStory == false) { if (text3 == "stop theme") diff --git a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs index daf385b..f510393 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs @@ -51,9 +51,9 @@ this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(16, 82); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(58, 13); + this.label2.Size = new System.Drawing.Size(35, 13); this.label2.TabIndex = 1; - this.label2.Text = "Username:"; + this.label2.Text = "Email:"; // // label3 // diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index bd9a14f..2df914e 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -50,6 +50,9 @@ namespace ShiftOS.Engine { public static bool ShuttingDown = false; + public static ClientSave CurrentUser { get; set; } + + public static Save CurrentSave { get; set; } /// @@ -189,28 +192,96 @@ namespace ShiftOS.Engine Thread.Sleep(50); Console.WriteLine("{SYSTEM_INITIATED}"); + + + if(CurrentSave.Users.Count == 0) + { + CurrentSave.Users.Add(new ClientSave + { + Username = "root", + Password = "", + Permissions = UserPermissions.Root + }); + Console.WriteLine("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 (progress == 0) + { + if (!string.IsNullOrWhiteSpace(text)) + { + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; + progress++; + } + else + { + Console.WriteLine("Username not provided."); + TerminalBackend.TextSent -= ev; + goback = true; + progress++; + } + } + else if (progress == 1) + { + 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; + } + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while(progress == 0) + { + Thread.Sleep(10); + } + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; + + 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(); - } + + Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); + GameReady?.Invoke(); } public delegate void EmptyEventHandler(); diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 318c818..3bfdeff 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -32,21 +32,26 @@ using System.Threading.Tasks; using Newtonsoft.Json; using static ShiftOS.Engine.SaveSystem; -namespace ShiftOS.Engine { - public static class TerminalBackend { +namespace ShiftOS.Engine +{ + public static class TerminalBackend + { public static event Action CommandProcessed; public static bool Elevated { get; set; } - public static Dictionary GetArgs(ref string text) { + public static Dictionary GetArgs(ref string text) + { bool shouldParse = false; int argStart = 0; - if (text.Contains("{")) { + if (text.Contains("{")) + { shouldParse = true; argStart = text.IndexOf('{'); } - if (shouldParse == false) { + if (shouldParse == false) + { string replacement = Regex.Replace(text, @"\t|\n|\r", ""); text = replacement + "{}"; shouldParse = true; @@ -61,15 +66,18 @@ namespace ShiftOS.Engine { public static string LastCommand = ""; - public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) { - try { + public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) + { + try + { if (string.IsNullOrWhiteSpace(ns)) return; bool commandWasClient = RunClient(ns, command, arguments, isRemote); - if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) { + if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) + { PrefixEnabled = false; ServerManager.SendMessage("script", $@"{{ @@ -80,23 +88,29 @@ namespace ShiftOS.Engine { } CommandProcessed?.Invoke(ns + "." + command, JsonConvert.SerializeObject(arguments)); - } catch (Exception ex) { + } + catch (Exception ex) + { Console.WriteLine($"Command parse error: {ex.Message}"); // This shouldn't ever be called now PrefixEnabled = true; } } - public static string GetSentArgs(Dictionary argss) { + public static string GetSentArgs(Dictionary argss) + { Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) { + foreach (KeyValuePair arg in argss) + { args[arg.Key] = arg.Value; } return JsonConvert.SerializeObject(args); } - public static void InvokeCommand(string text, bool isRemote = false) { - try { + public static void InvokeCommand(string text, bool isRemote = false) + { + try + { if (string.IsNullOrWhiteSpace(text)) return; @@ -104,7 +118,8 @@ namespace ShiftOS.Engine { bool commandWasClient = RunClient(text, args, isRemote); - if (!commandWasClient) { + if (!commandWasClient) + { PrefixEnabled = false; ServerManager.SendMessage("script", $@"{{ @@ -114,7 +129,9 @@ namespace ShiftOS.Engine { }}"); } CommandProcessed?.Invoke(text, GetSentArgs(args)); - } catch (Exception ex) { + } + catch (Exception ex) + { Console.WriteLine($"Command parse error: {ex.Message}"); PrefixEnabled = true; @@ -129,15 +146,18 @@ namespace ShiftOS.Engine { public static event EmptyEventHandler TerminalRequested; - internal static void OpenTerminal() { + internal static void OpenTerminal() + { TerminalRequested?.Invoke(); } - public static bool CanRunRemotely(MethodInfo mth, bool isRemote) { + public static bool CanRunRemotely(MethodInfo mth, bool isRemote) + { if (!isRemote) return true; - foreach (var attr in mth.GetCustomAttributes(false)) { + foreach (var attr in mth.GetCustomAttributes(false)) + { if (attr is RemoteLockAttribute) return false; } @@ -145,26 +165,32 @@ namespace ShiftOS.Engine { return true; } - public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) { + public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) + { return RunClient(ns + "." + cmd, args, isRemote); } - public static bool RunClient(string text, Dictionary argss, bool isRemote = false) { + public static bool RunClient(string text, Dictionary argss, bool isRemote = false) + { Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) { + foreach (KeyValuePair arg in argss) + { args[arg.Key] = arg.Value; } return RunClient(text, args, isRemote); } - public static bool RunClient(string text, Dictionary args, bool isRemote = false) { + public static bool RunClient(string text, Dictionary args, bool isRemote = false) + { latestCommmand = text; //Console.WriteLine(text + " " + "{" + string.Join(",", args.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}" + " " + isRemote); - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) { - try { + foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + try + { var asm = Assembly.LoadFile(asmExec); var types = asm.GetTypes(); @@ -315,7 +341,9 @@ namespace ShiftOS.Engine { } } - } else { + } + else + { Console.WriteLine(text + " cannot be ran in a remote session"); return true; } @@ -360,7 +388,8 @@ namespace ShiftOS.Engine { } } } - } catch { } + } + catch { } } return false; } @@ -375,7 +404,7 @@ namespace ShiftOS.Engine { ConsoleEx.ForegroundColor = ConsoleColor.Magenta; ConsoleEx.Bold = true; - Console.Write(SaveSystem.CurrentSave.Username); + Console.Write(SaveSystem.CurrentUser.Username); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.Gray; Console.Write("@"); @@ -410,26 +439,34 @@ namespace ShiftOS.Engine { string text3 = ""; string text4 = msg.Contents; - if (TerminalBackend.PrefixEnabled) { + if (TerminalBackend.PrefixEnabled) + { text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); } IsForwardingConsoleWrites = true; - if (TerminalBackend.InStory == false) { + if (TerminalBackend.InStory == false) + { TerminalBackend.InvokeCommand(text3, true); } - if (TerminalBackend.PrefixEnabled) { + if (TerminalBackend.PrefixEnabled) + { Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } IsForwardingConsoleWrites = false; - } else if (msg.Name == "pleasewrite") { + } + else if (msg.Name == "pleasewrite") + { Console.Write(msg.Contents); - } else if (msg.Name == "handshake_from") { + } + else if (msg.Name == "handshake_from") + { var a = JsonConvert.DeserializeObject>(msg.Contents); string uName = a["username"] as string; 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.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) + { ForwardGUID = guid; ServerManager.SendMessage("trm_handshake_accept", $@"{{ guid: ""{ServerManager.thisGuid}"", @@ -450,5 +487,12 @@ namespace ShiftOS.Engine { public static bool IsForwardingConsoleWrites { get; internal set; } public static string ForwardGUID { get; internal set; } + public static event TextSentEventHandler TextSent; + + public static void SendText(string text) + { + TextSent?.Invoke(text); + } + } } -- 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.Objects') 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 f893cbf3a11653132a802c57e75488991a312463 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Mon, 1 May 2017 20:09:46 +0000 Subject: Fix user persistence bug --- ShiftOS.Objects/Save.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 4f91db7..2a02bbc 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -98,7 +98,7 @@ namespace ShiftOS.Objects return count; } - public List Users = new List(); + public List Users { get; set; } } public class SettingsObject : DynamicObject -- cgit v1.2.3 From 14c5ba260fad4a9751630c5f5fc322bf7963602b Mon Sep 17 00:00:00 2001 From: william341 Date: Tue, 2 May 2017 17:52:10 -0700 Subject: fix some nres --- ShiftOS.Objects/ShiftFS.cs | 6 +++++- ShiftOS.WinForms/Tools/ControlManager.cs | 1 + ShiftOS.WinForms/WFLanguageProvider.cs | 7 ------- 3 files changed, 6 insertions(+), 8 deletions(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index 713bd17..c2121f0 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -230,7 +230,11 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + try + { + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + } + catch { } } else { diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 6d60f9d..3d66b2b 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -154,6 +154,7 @@ namespace ShiftOS.WinForms.Tools try { + if(ctrl.Tag != null) tag = ctrl.Tag.ToString(); } catch { } diff --git a/ShiftOS.WinForms/WFLanguageProvider.cs b/ShiftOS.WinForms/WFLanguageProvider.cs index c11b6dc..2a431f8 100644 --- a/ShiftOS.WinForms/WFLanguageProvider.cs +++ b/ShiftOS.WinForms/WFLanguageProvider.cs @@ -44,14 +44,7 @@ namespace ShiftOS.WinForms { try { - switch (SaveSystem.CurrentSave.Language) - { - case "deutsch": - return Properties.Resources.strings_de; - default: return getDefault(); - - } } catch (NullReferenceException) { -- cgit v1.2.3 From bbc5a738b1b3d86d2a71c1188fad89b533f251ce Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 5 May 2017 11:52:43 -0400 Subject: shiftfs permissions --- ShiftOS.Objects/ShiftFS.cs | 37 +++++++++++++++---------------------- ShiftOS_TheReturn/SaveSystem.cs | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-) (limited to 'ShiftOS.Objects') 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_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index c3289ea..f29e5b8 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)); } -- 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.Objects') 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 c0f0e99f9d2a092209e710107c1f061fc8a2eaca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 May 2017 10:22:51 -0400 Subject: Dithering, audio volume, and fix shutdown bug --- ShiftOS.Objects/Save.cs | 3 + ShiftOS.WinForms/Applications/Terminal.cs | 8 +- ShiftOS.WinForms/AudioManager.cs | 27 +++-- ShiftOS.WinForms/Program.cs | 6 +- ShiftOS.WinForms/Tools/DitheringEngine.cs | 160 ++++++++++++++++++++---------- ShiftOS_TheReturn/AppearanceManager.cs | 1 + ShiftOS_TheReturn/AudioManager.cs | 8 +- ShiftOS_TheReturn/Commands.cs | 34 +++++++ 8 files changed, 175 insertions(+), 72 deletions(-) (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 2a02bbc..cc19c79 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -35,6 +35,9 @@ namespace ShiftOS.Objects public class Save { + public int MusicVolume { get; set; } + public int SfxVolume { get; set; } + [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; } diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index a14cc58..02c4cc0 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -491,9 +491,9 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.InStory = false; TerminalBackend.PrintPrompt(); bool help_entered = false; - TerminalBackend.TextSent += (text) => + TerminalBackend.CommandProcessed += (text, args) => { - if (text == "sos.help" && help_entered == false) + if (text.EndsWith("sos.help") && help_entered == false) help_entered = true; }; while (help_entered == false) @@ -523,10 +523,10 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.InStory = false; bool winopenEntered = false; TerminalBackend.PrintPrompt(); - TerminalBackend.TextSent += (text) => + TerminalBackend.CommandProcessed += (text, args) => { if (help_entered == true) - if (text == "win.open" && winopenEntered == false) + if (text.EndsWith("win.open") && winopenEntered == false) winopenEntered = true; }; while (winopenEntered == false) diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs index eb0e798..ec12614 100644 --- a/ShiftOS.WinForms/AudioManager.cs +++ b/ShiftOS.WinForms/AudioManager.cs @@ -74,7 +74,19 @@ namespace ShiftOS.WinForms MemoryStream str = null; NAudio.Wave.Mp3FileReader mp3 = null; NAudio.Wave.WaveOut o = null; - while (!Engine.SaveSystem.ShuttingDown) + bool shuttingDown = false; + + Engine.AppearanceManager.OnExit += () => + { + shuttingDown = true; + o?.Stop(); + o?.Dispose(); + mp3?.Close(); + mp3?.Dispose(); + str?.Close(); + str?.Dispose(); + }; + while (shuttingDown == false) { str = new MemoryStream(GetRandomSong()); mp3 = new NAudio.Wave.Mp3FileReader(str); @@ -87,14 +99,15 @@ namespace ShiftOS.WinForms c = true; }; while (!c) + { + try + { + o.Volume = (float)Engine.SaveSystem.CurrentSave.MusicVolume / 100; + } + catch { } Thread.Sleep(10); - str.Dispose(); - o.Dispose(); - mp3.Dispose(); + } } - str?.Dispose(); - o?.Dispose(); - mp3?.Dispose(); }); athread.IsBackground = true; athread.Start(); diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 73215d4..8f65265 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -68,11 +68,7 @@ namespace ShiftOS.WinForms SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); Localization.RegisterProvider(new WFLanguageProvider()); - AppearanceManager.OnExit += () => - { - Environment.Exit(0); - }; - + TutorialManager.RegisterTutorial(new Oobe()); TerminalBackend.TerminalRequested += () => diff --git a/ShiftOS.WinForms/Tools/DitheringEngine.cs b/ShiftOS.WinForms/Tools/DitheringEngine.cs index f96a45a..d042a40 100644 --- a/ShiftOS.WinForms/Tools/DitheringEngine.cs +++ b/ShiftOS.WinForms/Tools/DitheringEngine.cs @@ -226,6 +226,53 @@ namespace ShiftOS.WinForms.Tools } #endif + public static int GetClosestColor(int gray, bool eightBits, bool sixBits, bool fourBits, bool twoBits) + { + int newgray = gray; + if (!eightBits) + { + if (sixBits) + { + newgray = gray >> 2; + } + else + { + if (fourBits) + { + newgray = (int)linear(gray, 0, 255, 0, 15) * 4; + } + else + { + if (twoBits) + { + if (gray > 127 + 63) + { + newgray = 255; + } + else if (gray > 127) + newgray = 127 + 63; + else if (gray > 63) + { + newgray = 127; + } + else if (gray > 0) + newgray = 63; + else + newgray = 0; + } + else + { + if (gray > 127) + newgray = 255; + else + newgray = 0; + } + } + } + } + return newgray; + } + #if FLOYDSTEINBERG public static Image DitherImage(Image source) { @@ -260,75 +307,78 @@ namespace ShiftOS.WinForms.Tools bool eightBits = Shiftorium.UpgradeInstalled("color_depth_8_bits"); bool color_depth_floydsteinberg = Shiftorium.UpgradeInstalled("color_depth_floyd-steinberg_dithering"); bool dithering = Shiftorium.UpgradeInstalled("color_depth_dithering"); - - if (!sixteenBits) + bool twentyfourbits = Shiftorium.UpgradeInstalled("color_depth_24_bits"); + if (twentyfourbits) + { + sourceArr.CopyTo(destArr, 0); + } + else { - if (dithering == true) + + if (!sixteenBits) { - if (false == true) + if (dithering == true) { + if (false == true) + { + + } + else + { + int error = 0; + for (int i = 0; i < destArr.Length; i += 3) + { + byte r = sourceArr[i]; + byte g = sourceArr[i + 1]; + byte b = sourceArr[i + 2]; + + if (SkinEngine.LoadedSkin.SystemKey == Color.FromArgb(r, g, b)) + { + destArr[i] = r; + destArr[i + 1] = g; + destArr[i + 2] = b; + continue; + } + + int gray = (((r + g + b) / 3) + error); + int newgray = gray; + newgray = GetClosestColor(gray, eightBits, sixBits, fourBits, twoBits); + if (newgray > 255) + newgray = 255; + if (newgray < 0) + newgray = 0; + error = gray - newgray; + destArr[i] = (byte)newgray; + destArr[i + 1] = (byte)newgray; + destArr[i + 2] = (byte)newgray; + + } + } } + else { - int error = 0; - for (int i = 0; i < destArr.Length; i += 3) + for (int i = 0; i < sourceArr.Length; i += 3) { byte r = sourceArr[i]; byte g = sourceArr[i + 1]; byte b = sourceArr[i + 2]; - - int gray = (((r + g + b) / 3) + error); - int newgray = gray; - if (!eightBits) + if (SkinEngine.LoadedSkin.SystemKey == Color.FromArgb(r, g, b)) { - if (sixBits) - { - newgray = gray >> 2; - } - else - { - if (fourBits) - { - newgray = (int)linear(gray, 0, 255, 0, 63) * 4; - } - else - { - if (twoBits) - { - if (gray > 127 + 63) - { - newgray = 255; - } - else if (gray > 127) - newgray = 127 + 63; - else if (gray > 63) - { - newgray = 127; - } - else if (gray > 0) - newgray = 63; - else - newgray = 0; - } - else - { - if (gray > 127) - newgray = 255; - else - newgray = 0; - } - } - } + destArr[i] = r; + destArr[i + 1] = g; + destArr[i + 2] = b; + continue; } - if (newgray > 255) - newgray = 255; - if (newgray < 0) - newgray = 0; - error = gray - newgray; + + int gray = (r + g + b) / 3; + int newgray = GetClosestColor(gray, eightBits, sixBits, fourBits, twoBits); destArr[i] = (byte)newgray; - destArr[i+1] = (byte)newgray; - destArr[i+2] = (byte)newgray; + destArr[i + 1] = (byte)newgray; + destArr[i + 2] = (byte)newgray; + + } } diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 42642f8..d8004bc 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -223,6 +223,7 @@ namespace ShiftOS.Engine ///
internal static void Exit() { + OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); Environment.Exit(0); diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index c50bd24..fff3369 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -88,7 +88,13 @@ namespace ShiftOS.Engine _reader = new AudioFileReader(file); _out = new WaveOut(); _out.Init(_reader); - _out.Volume = _provider.Volume; + try + { + _out.Volume = (float)SaveSystem.CurrentSave.SfxVolume / 100; + } + catch + { + } _out.Play(); _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; } diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 5b7674a..6e59311 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -378,6 +378,40 @@ namespace ShiftOS.Engine [Namespace("sos")] public static class ShiftOSCommands { + [Command("setsfxvolume", description = "Set the volume of various sound effects to a value between 1 and 100.")] + [RequiresArgument("value")] + public static bool SetSfxVolume(Dictionary args) + { + int value = int.Parse(args["value"].ToString()); + if (value >= 0 && value <= 100) + { + SaveSystem.CurrentSave.SfxVolume = value; + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("Volume must be between 0 and 100!"); + } + return true; + } + + [Command("setmusicvolume", description ="Set the music volume to a value between 1 and 100.")] + [RequiresArgument("value")] + public static bool SetMusicVolume(Dictionary args) + { + int value = int.Parse(args["value"].ToString()); + if(value >= 0 && value <= 100) + { + SaveSystem.CurrentSave.MusicVolume = value; + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("Volume must be between 0 and 100!"); + } + return true; + } + [RemoteLock] [Command("shutdown")] public static bool Shutdown() -- cgit v1.2.3 From 6eb764bd5c1342fc7d3d6f2bd46069462b2a48db Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 21 May 2017 08:31:48 -0400 Subject: Hmmmmmm --- ShiftOS.Objects/Save.cs | 27 +++- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UniteClient.cs | 236 ++++++++++++++++++++++++++++++++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 - ShiftOS_TheReturn/UniteClient.cs | 236 -------------------------------- 5 files changed, 263 insertions(+), 238 deletions(-) create mode 100644 ShiftOS.Objects/UniteClient.cs delete mode 100644 ShiftOS_TheReturn/UniteClient.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index cc19c79..f4e1e09 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -41,8 +41,33 @@ namespace ShiftOS.Objects [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; } + private long _cp = 0; + + public long Codepoints + { + get + { + if (!string.IsNullOrWhiteSpace(UniteAuthToken)) + { + var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken); + return uc.GetCodepoints(); + } + else + return _cp; + } + set + { + if (!string.IsNullOrWhiteSpace(UniteAuthToken)) + { + var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken); + uc.SetCodepoints(value); + } + else + _cp = value; + + } + } - public long Codepoints { get; set; } public Dictionary Upgrades { get; set; } public int StoryPosition { get; set; } public string Language { get; set; } diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index c2ef5ed..3c36d8c 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -56,6 +56,7 @@ + diff --git a/ShiftOS.Objects/UniteClient.cs b/ShiftOS.Objects/UniteClient.cs new file mode 100644 index 0000000..d8e34b7 --- /dev/null +++ b/ShiftOS.Objects/UniteClient.cs @@ -0,0 +1,236 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using ShiftOS.Objects; + +namespace ShiftOS.Unite +{ + public class UniteClient + { + /// + /// Gets a string represents the user token for this Unite Client. + /// + public string Token { get; private set; } + + /// + /// Gets the base URL used in all API calls. Retrieved from the user's servers.json file. + /// + public string BaseURL + { + get + { + return UserConfig.Get().UniteUrl; + } + } + + /// + /// Get the display name of a user. + /// + /// The user ID to look at. + /// + public string GetDisplayNameId(string id) + { + return MakeCall("/API/GetDisplayName/" + id); + } + + /// + /// Get the Pong highscore stats for all users. + /// + /// + public PongHighscoreModel GetPongHighscores() + { + return JsonConvert.DeserializeObject(MakeCall("/API/GetPongHighscores")); + } + + /// + /// Create a new instance of the object. + /// + /// Unused. + /// The user API token to use for this client (see http://getshiftos.ml/Manage and click "API" to see your tokens) + public UniteClient(string baseurl, string usertoken) + { + //Handled by the servers.json file + //BaseURL = baseurl; + Token = usertoken; + } + + /// + /// Make a call to the Unite API using the current user token and base URL. + /// + /// The path, relative to the base URL, to call. + /// The server's response. + internal string MakeCall(string url) + { + var webrequest = WebRequest.Create(BaseURL + url); + webrequest.Headers.Add("Authentication: Token " + Token); + using (var response = webrequest.GetResponse()) + { + using (var stream = response.GetResponseStream()) + { + using (var reader = new System.IO.StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + } + } + + /// + /// Get the Pong codepoint highscore for the current user. + /// + /// The amount of Codepoints returned by the server + public int GetPongCP() + { + return Convert.ToInt32(MakeCall("/API/GetPongCP")); + } + + /// + /// Get the pong highest level score for this user + /// + /// The highest level the user has reached. + public int GetPongLevel() + { + return Convert.ToInt32(MakeCall("/API/GetPongLevel")); + } + + /// + /// Set the user's highest level record for Pong. + /// + /// The level to set the record to. + public void SetPongLevel(int value) + { + MakeCall("/API/SetPongLevel/" + value.ToString()); + } + + /// + /// Set the pong Codepoints record for the user + /// + /// The amount of Codepoints to set the record to + public void SetPongCP(int value) + { + MakeCall("/API/SetPongCP/" + value.ToString()); + } + + /// + /// Get the user's email address. + /// + /// The user's email address. + public string GetEmail() + { + return MakeCall("/API/GetEmail"); + } + + /// + /// Get the user's system name. + /// + /// The user's system name. + public string GetSysName() + { + return MakeCall("/API/GetSysName"); + } + + /// + /// Set the user's system name. + /// + /// The system name to set the record to. + public void SetSysName(string value) + { + MakeCall("/API/SetSysName/" + value); + } + + /// + /// Get the user's display name. + /// + /// The user's display name. + public string GetDisplayName() + { + return MakeCall("/API/GetDisplayName"); + } + + /// + /// Set the user's display name. + /// + /// The display name to set the user's account to. + public void SetDisplayName(string value) + { + MakeCall("/API/SetDisplayName/" + value.ToString()); + } + + /// + /// Get the user's full name if they have set it in their profile. + /// + /// Empty string if the user hasn't set their fullname, else, a string representing their fullname. + public string GetFullName() + { + return MakeCall("/API/GetFullName"); + } + + /// + /// Set the user's fullname. + /// + /// The new fullname. + public void SetFullName(string value) + { + MakeCall("/API/SetFullName/" + value.ToString()); + } + + /// + /// Get the user's codepoints. + /// + /// The amount of codepoints stored on the server for this user. + public long GetCodepoints() + { + return Convert.ToInt64(MakeCall("/API/GetCodepoints")); + } + + /// + /// Set the user's codepoints. + /// + /// The amount of codepoints to set the user's codepoints value to. + public void SetCodepoints(long value) + { + MakeCall("/API/SetCodepoints/" + value.ToString()); + } + } + + /// + /// API data model for Unite pong highscores. + /// + public class PongHighscoreModel + { + /// + /// Amount of pages in this list. + /// + public int Pages { get; set; } + + /// + /// An array representing the highscores found on the server. + /// + public PongHighscore[] Highscores { get; set; } + } + + /// + /// API data model for a single Pong highscore. + /// + public class PongHighscore + { + /// + /// The user ID linked to this highscore. + /// + public string UserId { get; set; } + + /// + /// The highscore's level record. + /// + public int Level { get; set; } + + /// + /// The highscore's codepoint cashout record. + /// + public long CodepointsCashout { get; set; } + } +} diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index f0993a8..8b48023 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -132,7 +132,6 @@ - diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs deleted file mode 100644 index d8e34b7..0000000 --- a/ShiftOS_TheReturn/UniteClient.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using ShiftOS.Objects; - -namespace ShiftOS.Unite -{ - public class UniteClient - { - /// - /// Gets a string represents the user token for this Unite Client. - /// - public string Token { get; private set; } - - /// - /// Gets the base URL used in all API calls. Retrieved from the user's servers.json file. - /// - public string BaseURL - { - get - { - return UserConfig.Get().UniteUrl; - } - } - - /// - /// Get the display name of a user. - /// - /// The user ID to look at. - /// - public string GetDisplayNameId(string id) - { - return MakeCall("/API/GetDisplayName/" + id); - } - - /// - /// Get the Pong highscore stats for all users. - /// - /// - public PongHighscoreModel GetPongHighscores() - { - return JsonConvert.DeserializeObject(MakeCall("/API/GetPongHighscores")); - } - - /// - /// Create a new instance of the object. - /// - /// Unused. - /// The user API token to use for this client (see http://getshiftos.ml/Manage and click "API" to see your tokens) - public UniteClient(string baseurl, string usertoken) - { - //Handled by the servers.json file - //BaseURL = baseurl; - Token = usertoken; - } - - /// - /// Make a call to the Unite API using the current user token and base URL. - /// - /// The path, relative to the base URL, to call. - /// The server's response. - internal string MakeCall(string url) - { - var webrequest = WebRequest.Create(BaseURL + url); - webrequest.Headers.Add("Authentication: Token " + Token); - using (var response = webrequest.GetResponse()) - { - using (var stream = response.GetResponseStream()) - { - using (var reader = new System.IO.StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } - } - } - - /// - /// Get the Pong codepoint highscore for the current user. - /// - /// The amount of Codepoints returned by the server - public int GetPongCP() - { - return Convert.ToInt32(MakeCall("/API/GetPongCP")); - } - - /// - /// Get the pong highest level score for this user - /// - /// The highest level the user has reached. - public int GetPongLevel() - { - return Convert.ToInt32(MakeCall("/API/GetPongLevel")); - } - - /// - /// Set the user's highest level record for Pong. - /// - /// The level to set the record to. - public void SetPongLevel(int value) - { - MakeCall("/API/SetPongLevel/" + value.ToString()); - } - - /// - /// Set the pong Codepoints record for the user - /// - /// The amount of Codepoints to set the record to - public void SetPongCP(int value) - { - MakeCall("/API/SetPongCP/" + value.ToString()); - } - - /// - /// Get the user's email address. - /// - /// The user's email address. - public string GetEmail() - { - return MakeCall("/API/GetEmail"); - } - - /// - /// Get the user's system name. - /// - /// The user's system name. - public string GetSysName() - { - return MakeCall("/API/GetSysName"); - } - - /// - /// Set the user's system name. - /// - /// The system name to set the record to. - public void SetSysName(string value) - { - MakeCall("/API/SetSysName/" + value); - } - - /// - /// Get the user's display name. - /// - /// The user's display name. - public string GetDisplayName() - { - return MakeCall("/API/GetDisplayName"); - } - - /// - /// Set the user's display name. - /// - /// The display name to set the user's account to. - public void SetDisplayName(string value) - { - MakeCall("/API/SetDisplayName/" + value.ToString()); - } - - /// - /// Get the user's full name if they have set it in their profile. - /// - /// Empty string if the user hasn't set their fullname, else, a string representing their fullname. - public string GetFullName() - { - return MakeCall("/API/GetFullName"); - } - - /// - /// Set the user's fullname. - /// - /// The new fullname. - public void SetFullName(string value) - { - MakeCall("/API/SetFullName/" + value.ToString()); - } - - /// - /// Get the user's codepoints. - /// - /// The amount of codepoints stored on the server for this user. - public long GetCodepoints() - { - return Convert.ToInt64(MakeCall("/API/GetCodepoints")); - } - - /// - /// Set the user's codepoints. - /// - /// The amount of codepoints to set the user's codepoints value to. - public void SetCodepoints(long value) - { - MakeCall("/API/SetCodepoints/" + value.ToString()); - } - } - - /// - /// API data model for Unite pong highscores. - /// - public class PongHighscoreModel - { - /// - /// Amount of pages in this list. - /// - public int Pages { get; set; } - - /// - /// An array representing the highscores found on the server. - /// - public PongHighscore[] Highscores { get; set; } - } - - /// - /// API data model for a single Pong highscore. - /// - public class PongHighscore - { - /// - /// The user ID linked to this highscore. - /// - public string UserId { get; set; } - - /// - /// The highscore's level record. - /// - public int Level { get; set; } - - /// - /// The highscore's codepoint cashout record. - /// - public long CodepointsCashout { get; set; } - } -} -- cgit v1.2.3 From fde832b35763443afdc57dc8a5d82fb3bb25009b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 27 May 2017 12:11:36 -0400 Subject: simplesrc refurbishment --- ShiftOS.Objects/ChatRoom.cs | 16 +++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.WinForms/Applications/Chat.Designer.cs | 97 +++++++++++++ ShiftOS.WinForms/Applications/Chat.cs | 161 +++++++++++++--------- ShiftOS.WinForms/Applications/MUDControlCentre.cs | 3 +- ShiftOS_TheReturn/Story.cs | 7 +- 6 files changed, 220 insertions(+), 65 deletions(-) create mode 100644 ShiftOS.Objects/ChatRoom.cs (limited to 'ShiftOS.Objects') diff --git a/ShiftOS.Objects/ChatRoom.cs b/ShiftOS.Objects/ChatRoom.cs new file mode 100644 index 0000000..e4c89ce --- /dev/null +++ b/ShiftOS.Objects/ChatRoom.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class ChatRoom + { + public string Id { get; set; } + public string Name { get; set; } + + public List Messages { get; set; } + } +} diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 3c36d8c..9ed8c3b 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -45,6 +45,7 @@ + diff --git a/ShiftOS.WinForms/Applications/Chat.Designer.cs b/ShiftOS.WinForms/Applications/Chat.Designer.cs index d4b7211..d51b732 100644 --- a/ShiftOS.WinForms/Applications/Chat.Designer.cs +++ b/ShiftOS.WinForms/Applications/Chat.Designer.cs @@ -61,13 +61,23 @@ namespace ShiftOS.WinForms.Applications this.tsbottombar = new System.Windows.Forms.ToolStrip(); this.txtuserinput = new System.Windows.Forms.ToolStripTextBox(); this.btnsend = new System.Windows.Forms.ToolStripButton(); + this.pnlstart = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.txtchatid = new System.Windows.Forms.TextBox(); + this.btnjoin = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.tsbottombar.SuspendLayout(); + this.pnlstart.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // panel1 // + this.panel1.Controls.Add(this.pnlstart); this.panel1.Controls.Add(this.rtbchat); this.panel1.Controls.Add(this.toolStrip1); this.panel1.Controls.Add(this.tsbottombar); @@ -141,6 +151,82 @@ namespace ShiftOS.WinForms.Applications this.btnsend.Text = "Send"; this.btnsend.Click += new System.EventHandler(this.btnsend_Click); // + // pnlstart + // + this.pnlstart.Controls.Add(this.flowLayoutPanel1); + this.pnlstart.Controls.Add(this.label3); + this.pnlstart.Controls.Add(this.label2); + this.pnlstart.Controls.Add(this.label1); + this.pnlstart.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlstart.Location = new System.Drawing.Point(0, 25); + this.pnlstart.Name = "pnlstart"; + this.pnlstart.Size = new System.Drawing.Size(633, 268); + this.pnlstart.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(10); + this.label1.Size = new System.Drawing.Size(143, 33); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Welcome to SimpleSRC!"; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 33); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(10); + this.label2.Size = new System.Drawing.Size(633, 52); + this.label2.TabIndex = 1; + this.label2.Text = "SimpleSRC is a simple chat program that utilises the ShiftOS Relay Chat protocol." + + " All you have to do is enter a chat code or system name, and SimpleSRC will try " + + "to initiate a chat for you."; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Location = new System.Drawing.Point(0, 85); + this.label3.Name = "label3"; + this.label3.Padding = new System.Windows.Forms.Padding(10); + this.label3.Size = new System.Drawing.Size(79, 33); + this.label3.TabIndex = 2; + this.label3.Tag = "header3"; + this.label3.Text = "Join a chat"; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.txtchatid); + this.flowLayoutPanel1.Controls.Add(this.btnjoin); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 118); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(633, 29); + this.flowLayoutPanel1.TabIndex = 3; + // + // txtchatid + // + this.txtchatid.Location = new System.Drawing.Point(3, 3); + this.txtchatid.Name = "txtchatid"; + this.txtchatid.Size = new System.Drawing.Size(192, 20); + this.txtchatid.TabIndex = 0; + // + // btnjoin + // + this.btnjoin.Location = new System.Drawing.Point(201, 3); + this.btnjoin.Name = "btnjoin"; + this.btnjoin.Size = new System.Drawing.Size(75, 23); + this.btnjoin.TabIndex = 1; + this.btnjoin.Text = "Join"; + this.btnjoin.UseVisualStyleBackColor = true; + // // Chat // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -154,6 +240,10 @@ namespace ShiftOS.WinForms.Applications this.toolStrip1.PerformLayout(); this.tsbottombar.ResumeLayout(false); this.tsbottombar.PerformLayout(); + this.pnlstart.ResumeLayout(false); + this.pnlstart.PerformLayout(); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } @@ -168,5 +258,12 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.ToolStrip tsbottombar; private System.Windows.Forms.ToolStripTextBox txtuserinput; private System.Windows.Forms.ToolStripButton btnsend; + private System.Windows.Forms.Panel pnlstart; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.TextBox txtchatid; + private System.Windows.Forms.Button btnjoin; } } diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index caf8cd2..e150b1a 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -33,75 +33,26 @@ using System.Threading.Tasks; using System.Windows.Forms; using Newtonsoft.Json; using ShiftOS.Engine; +using System.Threading; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] + [WinOpen("simplesrc")] + [Launcher("SimpleSRC Client", false, null, "Networking")] + [DefaultTitle("SimpleSRC Client")] public partial class Chat : UserControl, IShiftOSWindow { - public Chat(string chatId) + public Chat() { InitializeComponent(); - id = chatId; - ServerManager.MessageReceived += (msg) => - { - if (msg.Name == "chat_msgreceived") - { - try - { - this.Invoke(new Action(() => - { - try - { - var args = JsonConvert.DeserializeObject>(msg.Contents); - var cmsg = new ShiftOS.Objects.ChatMessage(args["Username"] as string, args["SystemName"] as string, args["Message"] as string, args["Channel"] as string); - if (id == cmsg.Channel) - rtbchat.AppendText($"[{cmsg.Username}@{cmsg.SystemName}]: {cmsg.Message}{Environment.NewLine}"); - } - catch (Exception ex) - { - rtbchat.AppendText($"[system@multiuserdomain] Exception thrown by client: {ex}"); - } - })); - } - catch { } - } - else if(msg.Name == "chatlog") - { - try - { - this.Invoke(new Action(() => - { - rtbchat.AppendText(msg.Contents); - })); - } - catch { } - } - }; } - public void SendMessage(string msg) - { - if (!string.IsNullOrWhiteSpace(msg)) - { - rtbchat.AppendText($"[{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}] {msg}{Environment.NewLine}"); - - ServerManager.SendMessage("chat_send", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatMessage(SaveSystem.CurrentSave.Username, SaveSystem.CurrentSave.SystemName, msg, id))); - } - else - { - rtbchat.AppendText($"[sys@multiuserdomain] You can't send blank messages. (only you can see this)"); - } - } - - - private string id = ""; - public void OnLoad() { - ServerManager.SendMessage("chat_getlog", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatLogRequest(id, 50))); - - SendMessage("User has joined the chat."); + AllInstances.Add(this); + if (!string.IsNullOrWhiteSpace(ChatID)) + pnlstart.SendToBack(); RefreshUserInput(); } @@ -112,8 +63,8 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { - SendMessage("User has left the chat."); - id = null; + AllInstances.Remove(this); + ChatID = null; return true; } @@ -146,15 +97,101 @@ namespace ShiftOS.WinForms.Applications { rtbchat.SelectionStart = rtbchat.Text.Length; rtbchat.ScrollToCaret(); - tschatid.Text = id; - tsuserdata.Text = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}"; + tschatid.Text = ChatID; + AppearanceManager.SetWindowTitle(this, tschatid.Text + " - SimpleSRC Client"); + tsuserdata.Text = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}"; RefreshUserInput(); } + public static readonly List AllInstances = new List(); + + public static void SendMessage(string user, string destination, string msg) + { + foreach(var chat in AllInstances) + { + chat.PostMessage(user, destination, msg); + } + } + + public string ChatID = ""; + + public void PostMessage(string user, string destination, string message) + { + if (ChatID == destination) + { + this.Invoke(new Action(() => + { + rtbchat.SelectionFont = new Font(rtbchat.Font, FontStyle.Bold); + rtbchat.AppendText($"[{user}] "); + rtbchat.SelectionFont = rtbchat.Font; + rtbchat.AppendText(message); + rtbchat.AppendText(Environment.NewLine + Environment.NewLine); + })); + } + } + private void btnsend_Click(object sender, EventArgs e) { - SendMessage(txtuserinput.Text); + //Update ALL chat windows with this message if they're connected to this chat. + SendMessage($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}", ChatID, txtuserinput.Text); txtuserinput.Text = ""; } + + [Story("story_thefennfamily")] + public static void Story_TheFennFamily() + { + bool complete = false; + Infobox.Show("SimpleSRC", "A direct message has been sent to you on SimpleSRC from user \"maureenfenn@trisys\".", () => + { + string ch = "maureenfenn@trisys"; + var c = new Chat(); + c.ChatID = ch; + AppearanceManager.SetupWindow(c); + string you = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}"; + + var t = new Thread(() => + { + SendMessage(you, ch, "User has joined the chat."); + Thread.Sleep(2000); + SendMessage(ch, ch, "Hello, " + you + ". My name is Maureen. Maureen Fenn."); + Thread.Sleep(2500); + SendMessage(ch, ch, "I am the author of the various Tri applications you may see on Appscape."); + Thread.Sleep(2000); + SendMessage(ch, ch, "I need your help with something..."); + Thread.Sleep(2500); + SendMessage(ch, ch, "Firstly, a little backstory. There was a time in ShiftOS when none of us were connected."); + Thread.Sleep(2500); + SendMessage(ch, ch, "There wasn't a Digital Society, we didn't have chat applications or anything..."); + Thread.Sleep(2000); + SendMessage(ch, ch, "All we had was the Shiftnet."); + Thread.Sleep(2500); + SendMessage(ch, ch, "However, in 2016, something happened called the \"connected revolution\". It was like, the invention of the Internet - it was huge for the world of ShiftOS."); + Thread.Sleep(2500); + SendMessage(ch, ch, "Before this, the only way you could earn Codepoints was through playing games in ShiftOS."); + Thread.Sleep(2500); + SendMessage(ch, ch, "I was the one who coded those games, and I would put them on a Shiftnet website that you can still access today, shiftnet/main/shiftgames."); + Thread.Sleep(2500); + SendMessage(ch, ch, "But when the Connected Revolution took place, things got difficult. My son, Nalyr Fenn, was born, and people stopped using my software and instead moved on to hacking eachother and stealing peoples' Codepoints."); + Thread.Sleep(2500); + SendMessage(ch, ch, "When Nalyr's sentience levels reached near human - i.e, he grew up, we decided to start TriOffice. It was a huge success, thanks to Aiden Nirh, the guy who runs Appscape."); + Thread.Sleep(2500); + SendMessage(ch, ch, "However... a few months ago he cut contact with us and we stopped receiving Codepoints from TriOffice."); + Thread.Sleep(2500); + SendMessage(ch, ch, "I'm running low - I can't afford to keep my system running much longer. You have to help!"); + Thread.Sleep(2500); + SendMessage(ch, ch, "Perhaps, you could breach Aiden's server and look for clues as to why he's against us? I'll reward you with the last Codepoints I have."); + Thread.Sleep(2500); + SendMessage(you, ch, "Alright, I'm in - but I don't know where to begin..."); + Thread.Sleep(2500); + SendMessage(ch, ch, "A little birdie tells me you know about the RTS exploits going around... Try using that on Aiden's server. You can find his systemname on Appscape under \"Contact Us.\" He has a mailserver on Appscape - and also has RTS on the same server."); + Thread.Sleep(2500); + SendMessage(ch, ch, "Good luck... My life depends on you!"); + }); + t.IsBackground = true; + t.Start(); + }); + while (!complete) + Thread.Sleep(10); + } } } diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index b8ba5f3..ab89ffd 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -274,9 +274,10 @@ namespace ShiftOS.WinForms.Applications } + [Obsolete("MUD control center is dying! KILL IT!")] public void OpenChat(string id) { - AppearanceManager.SetupWindow(new Chat(id)); +// AppearanceManager.SetupWindow(new Chat(id)); } private Shop editingShop = null; diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index bcee49c..d62dae4 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -66,8 +66,11 @@ namespace ShiftOS.Engine var story = attrib as StoryAttribute; if(story.StoryID == stid) { - mth.Invoke(null, null); - SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + new Thread(() => + { + mth.Invoke(null, null); + SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + }).Start(); return; } } -- cgit v1.2.3