Skip to content

Commit

Permalink
Added chat, icon
Browse files Browse the repository at this point in the history
  • Loading branch information
thquinn committed Feb 27, 2015
1 parent 0aa3614 commit 5b75864
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 6 deletions.
1 change: 1 addition & 0 deletions ConnectWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public partial class ConnectWindow : Form
{
public ConnectWindow()
{
this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
InitializeComponent();
MaximizeBox = false;
#if DEBUG
Expand Down
9 changes: 9 additions & 0 deletions DraftClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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("|", ""));
}
}
}
8 changes: 8 additions & 0 deletions DraftServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
17 changes: 16 additions & 1 deletion DraftWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 32 additions & 3 deletions DraftWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ public partial class DraftWindow : Form
private static Dictionary<string, Image> cardImages = new Dictionary<string, Image>();
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();
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -248,6 +277,6 @@ private void UnCheckWindowSize()
toolStripMenuItem8.Checked = false;
toolStripMenuItem9.Checked = false;
toolStripMenuItem10.Checked = false;
}
}
}
}
7 changes: 6 additions & 1 deletion IsochronDrafter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>isochron.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -133,7 +136,9 @@
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="isochron.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
1 change: 1 addition & 0 deletions ServerWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public partial class ServerWindow : Form

public ServerWindow()
{
this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
InitializeComponent();
MaximizeBox = false;
#if DEBUG
Expand Down
2 changes: 1 addition & 1 deletion Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace IsochronDrafter
{
public class Util
{
public static readonly int version = 3;
public static readonly int version = 4;
public static string imageDirectory;
public static Random random = new Random();

Expand Down
Binary file added isochron.ico
Binary file not shown.

0 comments on commit 5b75864

Please sign in to comment.