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. --- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + 1 file changed, 1 insertion(+) (limited to 'ShiftOS.Objects/ShiftOS.Objects.csproj') 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 @@ + -- 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/ShiftOS.Objects.csproj') 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/ShiftOS.Objects.csproj') 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