From 4c50ceab1c15545c0c643e2e82650a86b4c1f27b Mon Sep 17 00:00:00 2001 From: lempamo Date: Fri, 31 Mar 2017 14:28:34 -0400 Subject: make message parser --- TimeHACK.Engine/WCMessageParser.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 TimeHACK.Engine/WCMessageParser.cs (limited to 'TimeHACK.Engine/WCMessageParser.cs') diff --git a/TimeHACK.Engine/WCMessageParser.cs b/TimeHACK.Engine/WCMessageParser.cs new file mode 100644 index 0000000..ed16afd --- /dev/null +++ b/TimeHACK.Engine/WCMessageParser.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TimeHACK.Engine +{ + class WCMessageParser + { + public string ParseMessage(string json, int index, string user) + { + JObject message = JObject.Parse(JObject.Parse(json)["messages"][index].ToString()); + string newmsg = message["message"].ToString().Replace("@user", user); + return message["user"].ToString() + ": " + newmsg; + } + public int GetMessageDelay(string json, int index) + { + JObject message = JObject.Parse(JObject.Parse(json)["messages"][index].ToString()); + return message["delay"].ToObject(); + } + } +} -- cgit v1.2.3 From 27419aa0dce06f9af5ee28f64aace365dcb7d816 Mon Sep 17 00:00:00 2001 From: lempamo Date: Fri, 31 Mar 2017 17:44:01 -0400 Subject: webchat things --- .vs/TimeHACK/v14/.suo | Bin 122368 -> 122368 bytes TimeHACK.Engine/WCMessageParser.cs | 8 ++++- TimeHACK.Engine/WindowManager.cs | 2 +- .../OS/Win95/Win95Apps/WebChat1998.Designer.cs | 1 + TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs | 7 ++++ TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx | 39 +++++++++++++++++++-- 6 files changed, 53 insertions(+), 4 deletions(-) (limited to 'TimeHACK.Engine/WCMessageParser.cs') diff --git a/.vs/TimeHACK/v14/.suo b/.vs/TimeHACK/v14/.suo index 363d666..c679976 100644 Binary files a/.vs/TimeHACK/v14/.suo and b/.vs/TimeHACK/v14/.suo differ diff --git a/TimeHACK.Engine/WCMessageParser.cs b/TimeHACK.Engine/WCMessageParser.cs index ed16afd..44c9002 100644 --- a/TimeHACK.Engine/WCMessageParser.cs +++ b/TimeHACK.Engine/WCMessageParser.cs @@ -13,12 +13,18 @@ namespace TimeHACK.Engine { JObject message = JObject.Parse(JObject.Parse(json)["messages"][index].ToString()); string newmsg = message["message"].ToString().Replace("@user", user); - return message["user"].ToString() + ": " + newmsg; + if (message["userchat"].ToObject()) return message["user"].ToString() + ": " + newmsg; + else return newmsg; } public int GetMessageDelay(string json, int index) { JObject message = JObject.Parse(JObject.Parse(json)["messages"][index].ToString()); return message["delay"].ToObject(); } + public string GetSpecial(string json, int index) + { + JObject message = JObject.Parse(JObject.Parse(json)["messages"][index].ToString()); + return message["special"].ToString(); + } } } diff --git a/TimeHACK.Engine/WindowManager.cs b/TimeHACK.Engine/WindowManager.cs index 193985a..4a1cf4e 100644 --- a/TimeHACK.Engine/WindowManager.cs +++ b/TimeHACK.Engine/WindowManager.cs @@ -9,7 +9,7 @@ namespace TimeHACK.Engine { public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection(); - public WinClassic startWinClassic(UserControl content, String title, PictureBox icon, Boolean MaxButton, Boolean MinButton) + public WinClassic startWinClassic(UserControl content, string title, PictureBox icon, bool MaxButton, bool MinButton) { // Setup Window WinClassic app = new WinClassic(); diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs index c3a5964..80aab11 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs @@ -269,6 +269,7 @@ this.Controls.Add(this.listBox1); this.Name = "WebChat1998"; this.Size = new System.Drawing.Size(724, 462); + this.Load += new System.EventHandler(this.WebChat1998_Load); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.login.ResumeLayout(false); diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs index ce87665..3f4810e 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs @@ -16,5 +16,12 @@ namespace TimeHACK.OS.Win95.Win95Apps { InitializeComponent(); } + private void WebChat1998_Load(object sender, EventArgs e) + { + button5.Hide(); + button4.Hide(); + button3.Hide(); + label5.Hide(); + } } } diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx index 61225ed..cb2c52a 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx @@ -117,9 +117,44 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 17, 17 - + + + { + "messages": [ + { + "user": "System", + "delay": 5000, + "message": "SkyHigh has joined the chat.", + "special": "addsh", + "userchat": true + }, + { + "user": "SkyHigh", + "delay": 6000, + "message": "damn", + "special": null, + "userchat": true + }, + { + "user": "SkyHigh", + "delay": 6000, + "message": "I thought my friend rain49 was going to be on...", + "special": null, + "userchat": true + }, + { + "user": "SkyHigh", + "delay": 6000, + "message": "hmm... how about we play a game while we wait for my friend to come", + "special": null, + "userchat": true + } + ] +} + If you do not agree to the following rules below DO NOT log into the chat: -- cgit v1.2.3 From 7841180fc0f60f6eb1fff1503f89ff2cad117e85 Mon Sep 17 00:00:00 2001 From: lempamo Date: Fri, 31 Mar 2017 20:22:59 -0400 Subject: webchat98 things --- .vs/TimeHACK/v14/.suo | Bin 131584 -> 131072 bytes TimeHACK.Engine/WCMessageParser.cs | 2 +- TimeHACK.Main/OS/Win95/Win95.Designer.cs | 1 + TimeHACK.Main/OS/Win95/Win95.cs | 8 +++++++ .../OS/Win95/Win95Apps/WebChat1998.Designer.cs | 3 ++- TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs | 24 ++++++++++++++++++++- TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx | 16 +++++++++++++- .../OS/Win95/Win95Apps/WinClassicIE4.Designer.cs | 2 +- TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.cs | 2 +- TimeHACK.Main/TitleScreen.cs | 1 + 10 files changed, 53 insertions(+), 6 deletions(-) (limited to 'TimeHACK.Engine/WCMessageParser.cs') diff --git a/.vs/TimeHACK/v14/.suo b/.vs/TimeHACK/v14/.suo index 930f2b8..dc49232 100644 Binary files a/.vs/TimeHACK/v14/.suo and b/.vs/TimeHACK/v14/.suo differ diff --git a/TimeHACK.Engine/WCMessageParser.cs b/TimeHACK.Engine/WCMessageParser.cs index 44c9002..ef7efd0 100644 --- a/TimeHACK.Engine/WCMessageParser.cs +++ b/TimeHACK.Engine/WCMessageParser.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace TimeHACK.Engine { - class WCMessageParser + public class WCMessageParser { public string ParseMessage(string json, int index, string user) { diff --git a/TimeHACK.Main/OS/Win95/Win95.Designer.cs b/TimeHACK.Main/OS/Win95/Win95.Designer.cs index 0bacc55..2d58db3 100644 --- a/TimeHACK.Main/OS/Win95/Win95.Designer.cs +++ b/TimeHACK.Main/OS/Win95/Win95.Designer.cs @@ -322,6 +322,7 @@ this.NetMeetingToolStripMenuItem.Name = "NetMeetingToolStripMenuItem"; this.NetMeetingToolStripMenuItem.Size = new System.Drawing.Size(229, 22); this.NetMeetingToolStripMenuItem.Text = "NetMeeting"; + this.NetMeetingToolStripMenuItem.Click += new System.EventHandler(this.WebChatToolStripMenuItem_Click); // // MultimediaToolStripMenuItem // diff --git a/TimeHACK.Main/OS/Win95/Win95.cs b/TimeHACK.Main/OS/Win95/Win95.cs index f0e9174..260d909 100644 --- a/TimeHACK.Main/OS/Win95/Win95.cs +++ b/TimeHACK.Main/OS/Win95/Win95.cs @@ -4,6 +4,7 @@ using System.IO; using System.Media; using System.Windows.Forms; using TimeHACK.Engine; +using TimeHACK.OS.Win95.Win95Apps; using TimeHACK.WinClassicForms; namespace TimeHACK.OS.Win95 @@ -185,6 +186,13 @@ namespace TimeHACK.OS.Win95 { wm.startInfobox95("AShifter's Infobox", "This is the very first TimeHACK Infobox. It's really easy to call, too! \n Just use wm.startInfobox95(String title, String text)!"); } + private void WebChatToolStripMenuItem_Click(object sender, EventArgs e) + { + WebChat1998 wc = new WebChat1998(); + Engine.Template.WinClassic app = wm.startWin95(wc, "Web Chat 1998", null, true, true); + app.BringToFront(); + startmenu.Hide(); + } } } diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs index 2b8a48d..b849893 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WebChat1998)); + this.resources = new System.ComponentModel.ComponentResourceManager(typeof(WebChat1998)); this.Chat = new System.Windows.Forms.Timer(this.components); this.listBox1 = new System.Windows.Forms.ListBox(); this.label1 = new System.Windows.Forms.Label(); @@ -302,5 +302,6 @@ private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; + private System.ComponentModel.ComponentResourceManager resources; } } diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs index 8df610f..94179d6 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using TimeHACK.Engine; +using System.Threading; namespace TimeHACK.OS.Win95.Win95Apps { @@ -29,7 +30,28 @@ namespace TimeHACK.OS.Win95.Win95Apps if (txtscreenname.Text == "") { WindowManager wm = new WindowManager(); - wm.startInfobox95("test", "test"); + wm.startInfobox95("Invalid Username", "Your username cannot be blank."); + return; + } + TitleScreen.username = txtscreenname.Text; + login.Hide(); + listBox1.Items.Add(TitleScreen.username); + chatLoop(); + } + + private void chatLoop() + { + WCMessageParser wcmp = new WCMessageParser(); + Thread.Sleep(15000); + for (int i = 0; i < 200; i++) + { + history.Text = wcmp.ParseMessage(resources.GetString("convo"), i, TitleScreen.username); + switch (wcmp.GetSpecial(resources.GetString("convo"), i)) + { + default: + break; + } + Thread.Sleep(wcmp.GetMessageDelay(resources.GetString("convo"), i)); } } } diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx index cb2c52a..db61d93 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WebChat1998.resx @@ -148,9 +148,23 @@ { "user": "SkyHigh", "delay": 6000, - "message": "hmm... how about we play a game while we wait for my friend to come", + "message": "hmm... how about we play a game while we wait for my friend to come?", "special": null, "userchat": true + }, + { + "user": "SkyHigh", + "delay": 5000, + "message": "alright, go ahead and guess what my name is!", + "special": null, + "userchat": true + }, + { + "user": "SkyHigh", + "delay": 500, + "message": "ill make 2 buttons pop up, you click the one you want to guess", + "special": "nameguess", + "userchat": true } ] } diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.Designer.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.Designer.cs index 1445e04..1e9affc 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.Designer.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.Designer.cs @@ -1,4 +1,4 @@ -namespace TimeHACK.WinClassicForms +namespace TimeHACK.OS.Win95.Win95Apps { partial class WinClassicIE4 { diff --git a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.cs b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.cs index 2b2fc4e..912fc8f 100644 --- a/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.cs +++ b/TimeHACK.Main/OS/Win95/Win95Apps/WinClassicIE4.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using System.Windows.Forms; using TimeHACK.Engine; -namespace TimeHACK.WinClassicForms +namespace TimeHACK.OS.Win95.Win95Apps { public partial class WinClassicIE4 : UserControl { diff --git a/TimeHACK.Main/TitleScreen.cs b/TimeHACK.Main/TitleScreen.cs index 8f3a3aa..4cd9043 100644 --- a/TimeHACK.Main/TitleScreen.cs +++ b/TimeHACK.Main/TitleScreen.cs @@ -11,6 +11,7 @@ namespace TimeHACK { public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection(); public static Windows95 frm95; + public static string username; public TitleScreen() { -- cgit v1.2.3