diff --git a/ConnectWindow.cs b/ConnectWindow.cs index e587662..af80f7a 100644 --- a/ConnectWindow.cs +++ b/ConnectWindow.cs @@ -13,6 +13,7 @@ public partial class ConnectWindow : Form { public ConnectWindow() { + this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); InitializeComponent(); MaximizeBox = false; #if DEBUG diff --git a/DraftClient.cs b/DraftClient.cs index 74c6a4d..9ace98b 100644 --- a/DraftClient.cs +++ b/DraftClient.cs @@ -139,6 +139,10 @@ private void HandleMessage(string msg) draftWindow.AddCardToPool(parts[i]); draftWindow.PrintLine("Loaded draft."); } + else if (parts[0] == "CHAT") + { + draftWindow.PrintLine("<" + parts[1] + ">: " + parts[2]); + } else if (parts[0] == "DONE") { draftDone = true; @@ -154,5 +158,10 @@ public void Pick(int index, string cardName) client.Send("PICK|" + index); draftWindow.AddCardToPool(cardName); } + public void Chat(string message) + { + if (client.ConnectionState == EventDrivenTCPClient.ConnectionStatus.Connected) + client.Send("CHAT|" + message.Replace(";", "").Replace("|", "")); + } } } diff --git a/DraftServer.cs b/DraftServer.cs index 92cbfaf..8f97b9f 100644 --- a/DraftServer.cs +++ b/DraftServer.cs @@ -215,6 +215,14 @@ private void HandleMessage(TcpServerConnection connection, string msg) // Send message with pack count of each player. SendPackCounts(); } + else if (parts[0] == "CHAT") + { + if (aliases.ContainsKey(connection)) + { + TrySendMessage("CHAT|" + GetAlias(connection) + "|" + parts[1]); + serverWindow.PrintLine("<" + GetAlias(connection) + ">: " + parts[1]); + } + } else serverWindow.PrintLine("<" + GetAlias(connection) + "> Unknown message: " + msg); } diff --git a/DraftWindow.Designer.cs b/DraftWindow.Designer.cs index dfc3220..8cbd734 100644 --- a/DraftWindow.Designer.cs +++ b/DraftWindow.Designer.cs @@ -47,6 +47,7 @@ private void InitializeComponent() this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem(); this.deckBuilder = new IsochronDrafter.DeckBuilder(); this.draftPicker = new IsochronDrafter.DraftPicker(); + this.chatBox = new System.Windows.Forms.TextBox(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -57,7 +58,7 @@ private void InitializeComponent() this.statusTextBox.Multiline = true; this.statusTextBox.Name = "statusTextBox"; this.statusTextBox.ReadOnly = true; - this.statusTextBox.Size = new System.Drawing.Size(334, 447); + this.statusTextBox.Size = new System.Drawing.Size(334, 420); this.statusTextBox.TabIndex = 5; // // menuStrip1 @@ -221,11 +222,24 @@ private void InitializeComponent() this.draftPicker.TabIndex = 3; this.draftPicker.DoubleClick += new System.EventHandler(this.draftPicker1_DoubleClick); // + // chatBox + // + this.chatBox.ForeColor = System.Drawing.Color.Gray; + this.chatBox.Location = new System.Drawing.Point(919, 953); + this.chatBox.Name = "chatBox"; + this.chatBox.Size = new System.Drawing.Size(333, 20); + this.chatBox.TabIndex = 8; + this.chatBox.Text = "Chat"; + this.chatBox.Enter += new System.EventHandler(this.chatBox_Enter); + this.chatBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.chatBox_KeyDown); + this.chatBox.Leave += new System.EventHandler(this.chatBox_Leave); + // // DraftWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1264, 986); + this.Controls.Add(this.chatBox); this.Controls.Add(this.deckBuilder); this.Controls.Add(this.statusTextBox); this.Controls.Add(this.draftPicker); @@ -263,6 +277,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem8; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem10; + private System.Windows.Forms.TextBox chatBox; } } diff --git a/DraftWindow.cs b/DraftWindow.cs index 87f08c4..6b818e7 100644 --- a/DraftWindow.cs +++ b/DraftWindow.cs @@ -18,11 +18,12 @@ public partial class DraftWindow : Form private static Dictionary cardImages = new Dictionary(); public CardWindow cardWindow; public DraftClient draftClient; - public bool canPick = true; + public bool canPick = true, chatBlank = true; public string packCounts = "", statusText = "", cardCounts = ""; public DraftWindow() { + this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); InitializeComponent(); MaximizeBox = false; cardWindow = new CardWindow(); @@ -156,6 +157,32 @@ private void draftPicker1_DoubleClick(object sender, EventArgs e) } } + private void chatBox_Enter(object sender, EventArgs e) + { + if (chatBlank) + { + chatBox.Text = ""; + chatBox.ForeColor = Color.Black; + } + } + private void chatBox_Leave(object sender, EventArgs e) + { + chatBlank = chatBox.Text.Length == 0; + if (chatBlank) + { + chatBox.ForeColor = Color.Gray; + chatBox.Text = "Chat"; + } + } + private void chatBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter && chatBox.Text.Length > 0) + { + draftClient.Chat(chatBox.Text); + chatBox.Text = ""; + } + } + // Menu items. private void quitToolStripMenuItem_Click(object sender, EventArgs e) { @@ -214,7 +241,9 @@ private void DraftWindow_Resize(object sender, EventArgs e) deckBuilder.Location = new Point(12, draftPicker.Bottom + 6); deckBuilder.Size = new Size(contentWidth - statusWidth, contentHeight - draftPicker.Height); statusTextBox.Location = new Point(deckBuilder.Right + 6, deckBuilder.Top); - statusTextBox.Size = new Size(statusWidth, deckBuilder.Height); + statusTextBox.Size = new Size(statusWidth, deckBuilder.Height - 26); + chatBox.Location = new Point(statusTextBox.Left, statusTextBox.Bottom + 6); + chatBox.Size = new Size(statusWidth, 20); draftPicker.Invalidate(); deckBuilder.Invalidate(); } @@ -248,6 +277,6 @@ private void UnCheckWindowSize() toolStripMenuItem8.Checked = false; toolStripMenuItem9.Checked = false; toolStripMenuItem10.Checked = false; - } + } } } diff --git a/IsochronDrafter.csproj b/IsochronDrafter.csproj index 1714345..cce18f9 100644 --- a/IsochronDrafter.csproj +++ b/IsochronDrafter.csproj @@ -33,6 +33,9 @@ prompt 4 + + isochron.ico + @@ -133,7 +136,9 @@ - + + +