From 4dbe7bd2c66394128fd9336cccf9438492fd461b Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 27 Feb 2017 16:31:55 -0500 Subject: Chatlogging (client) MUD Chat now requests last 50 lines of the chat log when the user joins. --- ShiftOS.WinForms/Applications/Chat.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ShiftOS.WinForms/Applications/Chat.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index 6c7528c..7f3fc04 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -65,6 +65,17 @@ namespace ShiftOS.WinForms.Applications } catch { } } + else if(msg.Name == "chatlog") + { + try + { + this.Invoke(new Action(() => + { + rtbchat.AppendText(msg.Contents); + })); + } + catch { } + } }; } @@ -87,6 +98,8 @@ namespace ShiftOS.WinForms.Applications public void OnLoad() { + ServerManager.SendMessage("chat_getlog", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatLogRequest(id, 50))); + SendMessage("User has joined the chat."); RefreshUserInput(); } -- cgit v1.2.3 From c1567f93f3a0bad3f8ef984bf980666cb31dfd87 Mon Sep 17 00:00:00 2001 From: lempamo Date: Mon, 6 Mar 2017 09:31:07 -0500 Subject: extremely minor chaange --- ShiftOS.WinForms/Applications/Chat.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/Applications/Chat.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index 7f3fc04..06a7873 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -55,7 +55,7 @@ namespace ShiftOS.WinForms.Applications 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}"); + rtbchat.AppendText($"[{cmsg.Username}@{cmsg.SystemName}]: {cmsg.Message}{Environment.NewLine}"); } catch (Exception ex) { -- cgit v1.2.3 From a9754b7df28795b6bb2c5cfe04c1b38b19fb0d05 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 10 Mar 2017 12:29:28 -0500 Subject: Lock certain apps away when system offline. --- ShiftOS.WinForms/Applications/Artpad.cs | 1 + ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Applications/Downloader.cs | 1 + ShiftOS.WinForms/Applications/FormatEditor.cs | 1 + ShiftOS.WinForms/Applications/GraphicPicker.cs | 1 + ShiftOS.WinForms/Applications/MUDControlCentre.cs | 1 + ShiftOS.WinForms/Applications/NameChanger.cs | 1 + ShiftOS.WinForms/Applications/Pong.cs | 1 + ShiftOS.WinForms/Applications/ShiftLetters.cs | 1 + ShiftOS.WinForms/Applications/ShiftLotto.cs | 1 + ShiftOS.WinForms/Applications/ShiftSweeper.cs | 1 + ShiftOS.WinForms/Applications/Shifter.cs | 1 + ShiftOS.WinForms/Applications/Shiftnet.cs | 1 + .../Applications/ShiftoriumFrontend.cs | 1 + ShiftOS.WinForms/HackerCommands.cs | 10 ++++++ ShiftOS.WinForms/WinformsWindowManager.cs | 18 ++++++++++ ShiftOS_TheReturn/AppLauncherDaemon.cs | 20 +++++++++--- ShiftOS_TheReturn/KernelWatchdog.cs | 38 +++++++++++++++++++++- ShiftOS_TheReturn/Scripting.cs | 7 ++-- 19 files changed, 100 insertions(+), 7 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Chat.cs') diff --git a/ShiftOS.WinForms/Applications/Artpad.cs b/ShiftOS.WinForms/Applications/Artpad.cs index 6c1bc1c..71f7afb 100644 --- a/ShiftOS.WinForms/Applications/Artpad.cs +++ b/ShiftOS.WinForms/Applications/Artpad.cs @@ -41,6 +41,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Artpad", true, "al_artpad", "Graphics")] [RequiresUpgrade("artpad")] [WinOpen("artpad")] diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index 06a7873..caf8cd2 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -36,6 +36,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] public partial class Chat : UserControl, IShiftOSWindow { public Chat(string chatId) diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs index da90c6d..1f240bf 100644 --- a/ShiftOS.WinForms/Applications/Downloader.cs +++ b/ShiftOS.WinForms/Applications/Downloader.cs @@ -41,6 +41,7 @@ using System.IO.Compression; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Downloader", false, null, "Networking")] [DefaultIcon("iconDownloader")] public partial class Downloader : UserControl, IShiftOSWindow diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs index ef44b47..56b0253 100644 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ b/ShiftOS.WinForms/Applications/FormatEditor.cs @@ -34,6 +34,7 @@ using System.Windows.Forms; using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("FormatEditor", true, "al_format_editor", "Games")] [RequiresUpgrade("format_editor")] [WinOpen("formateditor")] diff --git a/ShiftOS.WinForms/Applications/GraphicPicker.cs b/ShiftOS.WinForms/Applications/GraphicPicker.cs index 2dfe7ec..b3dd8bf 100644 --- a/ShiftOS.WinForms/Applications/GraphicPicker.cs +++ b/ShiftOS.WinForms/Applications/GraphicPicker.cs @@ -37,6 +37,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [DefaultTitle("Choose graphic")] [DefaultIcon("icongraphicpicker")] public partial class GraphicPicker : UserControl, IShiftOSWindow { diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index 02fe868..e2668bd 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [RequiresUpgrade("mud_fundamentals")] [Launcher("MUD Control Centre", true, "al_mud_control_centre", "Networking")] [WinOpen("mud_control_centre")] diff --git a/ShiftOS.WinForms/Applications/NameChanger.cs b/ShiftOS.WinForms/Applications/NameChanger.cs index ca76e57..d7c99f7 100644 --- a/ShiftOS.WinForms/Applications/NameChanger.cs +++ b/ShiftOS.WinForms/Applications/NameChanger.cs @@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Name Changer", true, "al_name_changer", "Customization")] [RequiresUpgrade("name_changer")] [WinOpen("name_changer")] diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index af1e156..157ce8c 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -37,6 +37,7 @@ using ShiftOS.Objects; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Pong", true, "al_pong", "Games")] [WinOpen("pong")] [DefaultIcon("iconPong")] diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index 700df7e..b5e9aa4 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -36,6 +36,7 @@ using System.Windows.Forms; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("ShiftLetters", false, null, "Games")] [RequiresUpgrade("shiftletters")] [WinOpen("shiftletters")] diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index 7acba3e..33f357f 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -35,6 +35,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftLotto", true, "al_shiftlotto", "Games")] + [MultiplayerOnly] [DefaultIcon("iconShiftLotto")] [RequiresUpgrade("shiftlotto")] [WinOpen("shiftlotto")] diff --git a/ShiftOS.WinForms/Applications/ShiftSweeper.cs b/ShiftOS.WinForms/Applications/ShiftSweeper.cs index b13880f..cf6d331 100644 --- a/ShiftOS.WinForms/Applications/ShiftSweeper.cs +++ b/ShiftOS.WinForms/Applications/ShiftSweeper.cs @@ -36,6 +36,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftSweeper", true, "al_shiftsweeper", "Games")] [RequiresUpgrade("shiftsweeper")] + [MultiplayerOnly] [WinOpen("shiftsweeper")] [DefaultIcon("iconShiftSweeper")] public partial class ShiftSweeper : UserControl, IShiftOSWindow { diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 1adc75a..fe2bf20 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -40,6 +40,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { + [MultiplayerOnly] [Launcher("Shifter", true, "al_shifter", "Customization")] [RequiresUpgrade("shifter")] [WinOpen("shifter")] diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 45f37d4..c1c81d5 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -38,6 +38,7 @@ using ShiftOS.WinForms.Tools; namespace ShiftOS.WinForms.Applications { [Launcher("Shiftnet", false, null, "Networking")] + [MultiplayerOnly] [DefaultIcon("iconShiftnet")] public partial class Shiftnet : UserControl, IShiftOSWindow { public Shiftnet() { diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index b3724ae..0580b47 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -39,6 +39,7 @@ namespace ShiftOS.WinForms.Applications { [Launcher("Shiftorium", true, "al_shiftorium", "Utilities")] [RequiresUpgrade("shiftorium_gui")] + [MultiplayerOnly] [WinOpen("shiftorium")] [DefaultTitle("Shiftorium")] [DefaultIcon("iconShiftorium")] diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 52d8568..d9504d3 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -668,5 +668,15 @@ namespace ShiftOS.WinForms return true; } + + [Command("experience", description = "Marks a story plot as experienced without triggering the plot.", usage ="{id:}")] + [RequiresArgument("id")] + [RemoteLock] + public static bool Experience(Dictionary args) + { + SaveSystem.CurrentSave.StoriesExperienced.Add(args["id"].ToString()); + SaveSystem.SaveGame(); + return true; + } } } diff --git a/ShiftOS.WinForms/WinformsWindowManager.cs b/ShiftOS.WinForms/WinformsWindowManager.cs index b8f0cae..eeaa6c9 100644 --- a/ShiftOS.WinForms/WinformsWindowManager.cs +++ b/ShiftOS.WinForms/WinformsWindowManager.cs @@ -106,6 +106,24 @@ namespace ShiftOS.WinForms return; } + foreach(var attr in form.GetType().GetCustomAttributes(true)) + { + if(attr is MultiplayerOnlyAttribute) + { + if(KernelWatchdog.MudConnected == false) + { + Infobox.PromptYesNo("Disconnected from MUD", "This application requires a connection to the MUD. Would you like to reconnect?", new Action((answer) => + { + if(answer == true) + { + KernelWatchdog.MudConnected = true; + SetupWindow(form); + } + })); + return; + } + } + } if (!Shiftorium.UpgradeAttributesUnlocked(form.GetType())) { diff --git a/ShiftOS_TheReturn/AppLauncherDaemon.cs b/ShiftOS_TheReturn/AppLauncherDaemon.cs index 7ef34c1..5e3bd72 100644 --- a/ShiftOS_TheReturn/AppLauncherDaemon.cs +++ b/ShiftOS_TheReturn/AppLauncherDaemon.cs @@ -66,12 +66,24 @@ namespace ShiftOS.Engine { foreach (var attr in type.GetCustomAttributes(false)) { - if (attr is LauncherAttribute) + bool isAllowed = true; + if(attr is MultiplayerOnlyAttribute) { - var launch = attr as LauncherAttribute; - if (launch.UpgradeInstalled) + if(KernelWatchdog.MudConnected == false) { - win.Add(new LauncherItem { DisplayData = launch, LaunchType = type }); + isAllowed = false; + + } + } + if (isAllowed == true) + { + if (attr is LauncherAttribute) + { + var launch = attr as LauncherAttribute; + if (launch.UpgradeInstalled) + { + win.Add(new LauncherItem { DisplayData = launch, LaunchType = type }); + } } } } diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs index 1b59b25..e69c9ba 100644 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -25,8 +25,44 @@ namespace ShiftOS.Engine } } + private static bool _mudConnected = true; + public static bool InKernelMode { get; private set; } - public static bool MudConnected { get; set; } + public static bool MudConnected + { + get + { + return _mudConnected; + } + set + { + if(value == false) + { + foreach(var win in AppearanceManager.OpenForms) + { + foreach(var attr in win.ParentWindow.GetType().GetCustomAttributes(true)) + { + if(attr is MultiplayerOnlyAttribute) + { + ConsoleEx.Bold = true; + ConsoleEx.Underline = false; + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.Red; + Console.Write("Error:"); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine("Cannot disconnect from multi-user domain because an app that depends on it is open."); + TerminalBackend.PrintPrompt(); + return; + } + } + } + } + + _mudConnected = value; + Desktop.PopulateAppLauncher(); + } + } public static bool IsSafe(Type type) { diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index bb65dc7..6768efb 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -67,11 +67,14 @@ namespace ShiftOS.Engine.Scripting { ServerManager.MessageReceived += (msg) => { - if(msg.Name == "run") + if (msg.Name == "run") { var cntnts = JsonConvert.DeserializeObject(msg.Contents); var interp = new LuaInterpreter(); - interp.Execute(cntnts.script.ToString()); + Desktop.InvokeOnWorkerThread(() => + { + interp.Execute(cntnts.script.ToString()); + }); } }; } -- 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.WinForms/Applications/Chat.cs') 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 From e841b168e13e0bd699c0e0d19857167aa725f1ca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 27 May 2017 16:59:54 -0400 Subject: stuff --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Controls/TerminalBox.cs | 11 ++++--- ShiftOS.WinForms/Stories/LegionStory.cs | 9 +----- ShiftOS.WinForms/WinformsDesktop.cs | 49 ++++++++++++++++++-------------- ShiftOS_TheReturn/AppearanceManager.cs | 2 +- 5 files changed, 35 insertions(+), 37 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Chat.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index e150b1a..f9e601f 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -186,6 +186,7 @@ namespace ShiftOS.WinForms.Applications 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!"); + complete = true; }); t.IsBackground = true; t.Start(); diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index a6dd610..7658c8c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -63,15 +63,12 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { - Thread.Sleep(5); - this.SuspendLayout(); this.HideSelection = true; this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; - this.ResumeLayout(); } private Font ConstructFont() @@ -89,8 +86,6 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { - Thread.Sleep(5); - this.SuspendLayout(); Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); @@ -99,11 +94,12 @@ namespace ShiftOS.WinForms.Controls this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; - this.ResumeLayout(); } bool quickCopying = false; + bool busy = false; + protected override void OnMouseDown(MouseEventArgs e) { //if right-clicking, then we initiate a quick-copy. @@ -255,8 +251,11 @@ namespace ShiftOS.WinForms.Controls } } + public string ThreadId = ""; + public TerminalBox() : base() { + ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); this.Tag = "keepbg keepfg keepfont"; } } diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 9b4966f..53d55fb 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -92,14 +92,7 @@ namespace ShiftOS.WinForms.Stories ConsoleEx.ForegroundColor = ConsoleColor.Gray; ConsoleEx.Bold = false; - foreach (var c in text) - { - Desktop.InvokeOnWorkerThread(() => - { - Console.Write(c); - }); - Thread.Sleep(75); - } + Console.WriteLine(text); Thread.Sleep(1000); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 15ecb7a..6ce8cc9 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -188,14 +188,40 @@ namespace ShiftOS.WinForms widget.OnSkinLoad(); } + SetupDesktop(); }; + + long lastcp = 0; + + var storythread = new Thread(() => + { + do + { + if (SaveSystem.CurrentSave != null) + { + if (SaveSystem.CurrentSave.Codepoints != lastcp) + lastcp = SaveSystem.CurrentSave.Codepoints; + if (lastcp >= 10000) + { + if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) + { + Story.Start("victortran_shiftnet"); + } + } + } + } while (!SaveSystem.ShuttingDown); + }); + storythread.IsBackground = true; + storythread.Start(); + time.Tick += (o, a) => { if (Shiftorium.IsInitiated == true) { - if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) + if (SaveSystem.CurrentSave != null) { + lbtime.Text = Applications.Terminal.GetTime(); lbtime.Left = pnlnotifications.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; @@ -230,27 +256,6 @@ namespace ShiftOS.WinForms }; time.Start(); - var ssThread = new Thread(() => - { - while(this.Visible == true) - { - var mousePos = Cursor.Position; - while(Cursor.Position == mousePos) - { - if(millisecondsUntilScreensaver <= 0) - { - ShowScreensaver(); - } - millisecondsUntilScreensaver--; - Thread.Sleep(1); - } - millisecondsUntilScreensaver = 300000; - HideScreensaver(); - } - }); - ssThread.IsBackground = true; - ssThread.Start(); - this.DoubleBuffered = true; } diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 81858d3..7cf06c9 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -190,7 +190,7 @@ namespace ShiftOS.Engine ServerManager.Disconnect(); Desktop.InvokeOnWorkerThread(() => { - Environment.Exit(0); //bye bye + Process.GetCurrentProcess().Kill(); //bye bye }); } -- cgit v1.2.3 From 03ebdf42d9f12b678d48f954736664f6f3eb1f84 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 12:40:06 -0400 Subject: Funny, disabling localization makes things easier... --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Applications/Terminal.cs | 6 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 5 +- ShiftOS.WinForms/Tools/ControlManager.cs | 139 +++++++++++------------------- ShiftOS.WinForms/WinformsDesktop.cs | 10 ++- ShiftOS_TheReturn/Localization.cs | 45 +--------- ShiftOS_TheReturn/TerminalTextWriter.cs | 1 + 7 files changed, 72 insertions(+), 135 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Chat.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index f9e601f..7a2de81 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -41,6 +41,7 @@ namespace ShiftOS.WinForms.Applications [WinOpen("simplesrc")] [Launcher("SimpleSRC Client", false, null, "Networking")] [DefaultTitle("SimpleSRC Client")] + [AppscapeEntry("SimpleSRC", "A simple ShiftOS Relay Chat client that allows you to talk with other ShiftOS users from all over the world.", 300, 145, "file_skimmer", "Networking")] public partial class Chat : UserControl, IShiftOSWindow { public Chat() diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index bfc4425..3d17d35 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -504,11 +504,11 @@ namespace ShiftOS.WinForms.Applications Thread.Sleep(2000); Console.WriteLine("As you know, ShiftOS doesn't have very many features."); Thread.Sleep(2000); - Console.WriteLine("Using the applications you have, I need you to earn 50,000 Codepoints."); + Console.WriteLine("Using the applications you have, I need you to earn as many Codepoints as you can."); Thread.Sleep(2000); - Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn Codepoints."); + Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn even more Codepoints."); Thread.Sleep(2000); - Console.WriteLine("Start small, try to earn 500. Once you do, I'll contact you with more details."); + Console.WriteLine("Once you earn 1,000 Codepoints, I will check back with you and see how well you've done."); Thread.Sleep(2000); Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); Thread.Sleep(2000); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 41b50a7..0eac58e 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -283,7 +283,7 @@ Name: "AL Widget Manager", Cost: 125, Description: "Desktop Widgets are a huge advancement in ShiftOS technology, allowing access to system information, and quick control of your system, without even opening a window. However, we still need to be able to modify each widget. This upgrade adds an App Launcher entry for the Desktop Widget Manager.", - Description: "app_launcher;desktop_widgets", + Dependencies: "app_launcher;desktop_widgets", Category: "GUI" }, { @@ -704,7 +704,8 @@ Name: "Artpad", Cost: 7500, Category: "Applications", - Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!" + Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!", + Dependencies: "color_depth_8_bits" }, { Name: "AL Artpad", diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 1643b23..83ab7fe 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -1,3 +1,5 @@ +#define SLOW_LOCALIZATION + /* * MIT License * @@ -144,77 +146,66 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - - if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) + Desktop.InvokeOnWorkerThread(() => { - string tag = ""; - - try + if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { - if(ctrl.Tag != null) - tag = ctrl.Tag.ToString(); - } - catch { } + string tag = ""; - if (!tag.Contains("keepbg")) - { - if (ctrl.BackColor != Control.DefaultBackColor) + try { - Desktop.InvokeOnWorkerThread(() => + if (ctrl.Tag != null) + tag = ctrl.Tag.ToString(); + } + catch { } + + if (!tag.Contains("keepbg")) + { + if (ctrl.BackColor != Control.DefaultBackColor) { ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; - }); + } } - } - if (!tag.Contains("keepfont")) - { - Desktop.InvokeOnWorkerThread(() => + if (!tag.Contains("keepfont")) { ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; ctrl.Font = SkinEngine.LoadedSkin.MainFont; - }); - if (tag.Contains("header1")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header1")) { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - }); - } + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; + }); + } - if (tag.Contains("header2")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header2")) { ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - }); - } + } - if (tag.Contains("header3")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header3")) { ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - }); + } } - } - try - { - string ctrlText = Localization.Parse(ctrl.Text); - Desktop.InvokeOnWorkerThread(() => + try + { +#if !SLOW_LOCALIZATION + if (!string.IsNullOrWhiteSpace(ctrl.Text)) + { + string ctrlText = Localization.Parse(ctrl.Text); + ctrl.Text = ctrlText; + } +#endif + } + catch { - ctrl.Text = ctrlText; - }); - } - catch - { - } + } - if(ctrl is Button) - { - Desktop.InvokeOnWorkerThread(() => + if (ctrl is Button) { Button b = ctrl as Button; if (!b.Tag.ToString().ToLower().Contains("keepbg")) @@ -229,7 +220,7 @@ namespace ShiftOS.WinForms.Tools b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if(!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!b.Tag.ToString().ToLower().Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; @@ -260,15 +251,12 @@ namespace ShiftOS.WinForms.Tools b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed"); }; - }); + } } - if(ctrl is TextBox) + if (ctrl is TextBox) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; - }); + (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; } ctrl.KeyDown += (o, a) => @@ -286,27 +274,19 @@ namespace ShiftOS.WinForms.Tools }; if (ctrl is Button) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as Button).FlatStyle = FlatStyle.Flat; - }); + (ctrl as Button).FlatStyle = FlatStyle.Flat; } else if (ctrl is WindowBorder) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as WindowBorder).Setup(); - }); + (ctrl as WindowBorder).Setup(); } - } - Desktop.InvokeOnWorkerThread(() => - { - MakeDoubleBuffered(ctrl); + ControlSetup?.Invoke(ctrl); }); - ControlSetup?.Invoke(ctrl); } + + public static event Action ControlSetup; public static void MakeDoubleBuffered(Control c) @@ -330,27 +310,12 @@ namespace ShiftOS.WinForms.Tools { Desktop.HideAppLauncher(); }; - ThreadStart ts = () => - { - var ctrls = frm.Controls.ToList(); - for (int i = 0; i < ctrls.Count(); i++) - { - SetupControls(ctrls[i]); - } - SetupControl(frm); - - }; - - if (runInThread == true) - { - var t = new Thread(ts); - t.IsBackground = true; - t.Start(); - } - else + var ctrls = frm.Controls.ToList(); + for (int i = 0; i < ctrls.Count(); i++) { - ts?.Invoke(); + SetupControls(ctrls[i]); } + SetupControl(frm); } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6ce8cc9..85eab55 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -202,13 +202,21 @@ namespace ShiftOS.WinForms { if (SaveSystem.CurrentSave.Codepoints != lastcp) lastcp = SaveSystem.CurrentSave.Codepoints; - if (lastcp >= 10000) + if (lastcp >= 2500) { if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) { Story.Start("victortran_shiftnet"); } } + if(lastcp >= 5000) + { + if(Shiftorium.UpgradeInstalled("triwrite") && Shiftorium.UpgradeInstalled("simplesrc") && Shiftorium.UpgradeInstalled("victortran_shiftnet") && Shiftorium.UpgradeInstalled("story_hacker101_breakingthebonds")) + { + if (!Shiftorium.UpgradeInstalled("story_thefennfamily")) + Story.Start("story_thefennfamily"); + } + } } } while (!SaveSystem.ShuttingDown); }); diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 5d848b0..c542c2a 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -111,50 +111,11 @@ namespace ShiftOS.Engine localizationStrings = JsonConvert.DeserializeObject>(Utils.ReadAllText(Paths.GetPath("english.local"))); //if no provider fall back to english } - foreach (var kv in localizationStrings) + foreach (var kv in localizationStrings.Where(x=>original.Contains(x.Key))) { original = original.Replace(kv.Key, kv.Value); // goes through and replaces all the localization blocks } - List orphaned = new List(); - - - int start_index = 0; - int length = 0; - bool indexing = false; - - foreach (var c in original) - { - // start paying attenion when you see a "{" - if (c == '{') - { - start_index = original.IndexOf(c); - indexing = true; - } - - if (indexing == true) - { - // stop paying attention when you see a "}" after seeing a "{" - length++; - if (c == '}') - { - indexing = false; - string o = original.Substring(start_index, length); - if (!orphaned.Contains(o)) - { - orphaned.Add(o); - } - start_index = 0; - length = 0; - } - } - } - - if (orphaned.Count > 0) - { - Utils.WriteAllText("0:/dev_orphaned_lang.txt", JsonConvert.SerializeObject(orphaned, Formatting.Indented)); //format if from this txt file - } - //string original2 = Parse(original); string usernameReplace = ""; @@ -203,13 +164,13 @@ namespace ShiftOS.Engine }; // actually do the replacement - foreach (KeyValuePair replacement in replace) + foreach (KeyValuePair replacement in replace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, Parse(replacement.Value)); } // do the replacement but default - foreach (KeyValuePair replacement in defaultReplace) + foreach (KeyValuePair replacement in defaultReplace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, replacement.Value); } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 4c0c3a0..63e88eb 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -42,6 +42,7 @@ namespace ShiftOS.Engine { ConsoleEx.OnFlush = () => { + System.Diagnostics.Debug.WriteLine("[terminal] " + buffer); Desktop.InvokeOnWorkerThread(() => { UnderlyingControl?.Write(buffer); -- cgit v1.2.3