Die Gui hat nun ein Chatfenster. Bisher können lediglich nachrichten
versandt, jedoch nicht empfangen werden.
This commit is contained in:
@@ -8,11 +8,13 @@ namespace WorldOfPeacecraft
|
||||
{
|
||||
class Gui : Form, IGui
|
||||
{
|
||||
private const int tileSize = 32;
|
||||
private const int entitySize = 10;
|
||||
private const int TileSize = 32;
|
||||
private const int EntitySize = 10;
|
||||
private const int ChatWidth = 300;
|
||||
private IBackend Backend;
|
||||
|
||||
private Panel Board = new Panel();
|
||||
private ChatPanel ChatPanel;
|
||||
|
||||
public Gui ()
|
||||
{
|
||||
@@ -33,18 +35,23 @@ namespace WorldOfPeacecraft
|
||||
|
||||
public void InitializeComponents ()
|
||||
{
|
||||
ChatPanel = new ChatPanel (Backend);
|
||||
this.SuspendLayout();
|
||||
this.Size = new Size(400, 400);
|
||||
this.Size = new Size(400 + ChatWidth, 400);
|
||||
Board.Location = new Point(0,0);
|
||||
Board.Size = new Size(400, 400);
|
||||
Board.Paint += DoPaint;
|
||||
ChatPanel.Location = new Point (400, 0);
|
||||
ChatPanel.Size = new Size (300, 400);
|
||||
this.DoubleBuffered = true;
|
||||
this.MaximizeBox = false;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Name = "WorldOfPeacecraft";
|
||||
this.ShowIcon = false;
|
||||
|
||||
this.Controls.Add(Board);
|
||||
this.Controls.Add (Board);
|
||||
this.Controls.Add (ChatPanel);
|
||||
|
||||
this.ResumeLayout();
|
||||
}
|
||||
|
||||
@@ -82,8 +89,8 @@ namespace WorldOfPeacecraft
|
||||
|
||||
public void PaintTile (Graphics g, ITile tile, int x, int y)
|
||||
{
|
||||
int posx = x * tileSize;
|
||||
int posy = y * tileSize;
|
||||
int posx = x * TileSize;
|
||||
int posy = y * TileSize;
|
||||
Color color;
|
||||
if (tile.IsForest ()) {
|
||||
color = Color.Green;
|
||||
@@ -99,7 +106,7 @@ namespace WorldOfPeacecraft
|
||||
} else {
|
||||
color = Color.Black;
|
||||
}
|
||||
g.FillRectangle(new SolidBrush(color), posx, posy, tileSize, tileSize);
|
||||
g.FillRectangle(new SolidBrush(color), posx, posy, TileSize, TileSize);
|
||||
}
|
||||
|
||||
public void PaintEntities (Graphics g)
|
||||
@@ -116,10 +123,10 @@ namespace WorldOfPeacecraft
|
||||
|
||||
public void PaintEntity (Graphics g, IPositionable entity)
|
||||
{
|
||||
int x = entity.GetX () * tileSize + tileSize / 2 - entitySize / 2;
|
||||
int y = entity.GetY () * tileSize + tileSize / 2 - entitySize / 2;
|
||||
g.FillRectangle (new SolidBrush (Color.Red), x, y, entitySize, entitySize);
|
||||
g.DrawRectangle (new Pen( new SolidBrush (Color.Black)), x, y, entitySize, entitySize);
|
||||
int x = entity.GetX () * TileSize + TileSize / 2 - EntitySize / 2;
|
||||
int y = entity.GetY () * TileSize + TileSize / 2 - EntitySize / 2;
|
||||
g.FillRectangle (new SolidBrush (Color.Red), x, y, EntitySize, EntitySize);
|
||||
g.DrawRectangle (new Pen( new SolidBrush (Color.Black)), x, y, EntitySize, EntitySize);
|
||||
}
|
||||
|
||||
public void PerformRefresh ()
|
||||
@@ -130,11 +137,13 @@ namespace WorldOfPeacecraft
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
int mapWidth = (map.GetLength(0)) * tileSize;
|
||||
int mapHeight = (map.GetLength(1)) * tileSize;
|
||||
int mapWidth = (map.GetLength(0)) * TileSize;
|
||||
int mapHeight = (map.GetLength(1)) * TileSize;
|
||||
this.SuspendLayout();
|
||||
this.SetClientSizeCore(mapWidth, mapHeight);
|
||||
this.SetClientSizeCore(mapWidth + ChatWidth, mapHeight);
|
||||
Board.Size = new Size(mapWidth, mapHeight);
|
||||
ChatPanel.Location = new Point (mapWidth, 0);
|
||||
ChatPanel.Size = new Size (ChatWidth, mapHeight);
|
||||
this.ResumeLayout();
|
||||
this.PerformLayout();
|
||||
this.Refresh();
|
||||
|
||||
Reference in New Issue
Block a user