Aktuelle Version der DefaultGui

This commit is contained in:
2014-04-01 11:07:06 +02:00
parent a7a6c36aa8
commit 4a2a01853a
10 changed files with 631 additions and 587 deletions

87
DefaultGui/DefaultGui.Designer.cs generated Normal file
View File

@@ -0,0 +1,87 @@
namespace Frontend
{
partial class DefaultGui
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.chatInput = new System.Windows.Forms.TextBox();
this.chatWindow = new System.Windows.Forms.RichTextBox();
this.board = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// chatInput
//
this.chatInput.BackColor = System.Drawing.SystemColors.Window;
this.chatInput.Location = new System.Drawing.Point(23, 455);
this.chatInput.Name = "chatInput";
this.chatInput.Size = new System.Drawing.Size(350, 20);
this.chatInput.TabIndex = 0;
//
// chatWindow
//
this.chatWindow.Location = new System.Drawing.Point(23, 368);
this.chatWindow.Name = "chatWindow";
this.chatWindow.ReadOnly = true;
this.chatWindow.Size = new System.Drawing.Size(350, 81);
this.chatWindow.TabIndex = 1;
this.chatWindow.Text = "";
//
// board
//
this.board.Location = new System.Drawing.Point(23, 12);
this.board.Name = "board";
this.board.Size = new System.Drawing.Size(350, 350);
this.board.TabIndex = 2;
//
// DefaultGui
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(398, 487);
this.Controls.Add(this.board);
this.Controls.Add(this.chatWindow);
this.Controls.Add(this.chatInput);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "DefaultGui";
this.ShowIcon = false;
this.Text = "Default GUI";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox chatInput;
private System.Windows.Forms.RichTextBox chatWindow;
private System.Windows.Forms.Panel board;
}
}

View File

@@ -10,7 +10,7 @@ using System.Windows.Forms;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Diagnostics; using System.Diagnostics;
namespace DefaultGui namespace Frontend
{ {
/// <summary> /// <summary>
/// This is a very, very basic GUI. It communicates with any IBackend, takes the map and existing entities and renders them in a generic fashion. /// This is a very, very basic GUI. It communicates with any IBackend, takes the map and existing entities and renders them in a generic fashion.
@@ -27,8 +27,7 @@ namespace DefaultGui
public partial class DefaultGui : Form public partial class DefaultGui : Form
{ {
private IBackend backend; private IBackend backend;
public DefaultGui(IBackend backend) public DefaultGui(IBackend backend) : base()
: base()
{ {
if (backend == null) if (backend == null)
{ {
@@ -54,24 +53,24 @@ namespace DefaultGui
/// <param name="e"></param> /// <param name="e"></param>
private void chat_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) private void chat_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{ {
if (e.KeyChar == (char)Keys.Enter) if(e.KeyChar == (char)Keys.Enter)
{ {
string input = this.chatInput.Text.Trim(); string input = this.chatInput.Text.Trim();
this.chatInput.Text = ""; this.chatInput.Text = "";
// ignore empty input // ignore empty input
if (input != "") if (input != "")
{
if (input.StartsWith("/"))
{ {
input = input.Substring(1, input.Length - 1); if (input.StartsWith("/"))
this.backend.sendCommand(input); {
input = input.Substring(1, input.Length-1);
this.backend.sendCommand(input);
}
else
{
this.backend.sendChat(input);
}
} }
else this.board.Focus();
{
this.backend.sendChat(input);
}
}
this.board.Focus();
} }
} }
@@ -119,18 +118,15 @@ namespace DefaultGui
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void board_PaintMap(object sender, System.Windows.Forms.PaintEventArgs e) private void board_PaintMap(object sender, System.Windows.Forms.PaintEventArgs e) {
{
Size tileSize = this.getTileSize(); Size tileSize = this.getTileSize();
ITile[][] cells = this.backend.getMap(); ITile[][] cells = this.backend.getMap();
// validity checked beforehand in getTileSize // validity checked beforehand in getTileSize
Debug.Assert(cells != null); Debug.Assert(cells != null);
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(this.board.CreateGraphics(), this.board.DisplayRectangle); BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(this.board.CreateGraphics(), this.board.DisplayRectangle);
Graphics g = this.CreateGraphics(); Graphics g = this.CreateGraphics();
for (int x = 0; x < cells.Length; x++) for(int x = 0; x < cells.Length; x++) {
{ for(int y = 0; y < cells[x].Length; y++) {
for (int y = 0; y < cells[x].Length; y++)
{
this.drawMapTile(buffer.Graphics, cells[x][y], x * tileSize.Width, y * tileSize.Height, tileSize.Width, tileSize.Height); this.drawMapTile(buffer.Graphics, cells[x][y], x * tileSize.Width, y * tileSize.Height, tileSize.Width, tileSize.Height);
} }
} }
@@ -210,8 +206,8 @@ namespace DefaultGui
g.FillRectangle(new SolidBrush(Color.DarkGoldenrod), g.FillRectangle(new SolidBrush(Color.DarkGoldenrod),
player.getXPosition() * tileSize.Width + tileSize.Width / 2 - tileSize.Width / 4, player.getXPosition() * tileSize.Width + tileSize.Width / 2 - tileSize.Width / 4,
player.getYPosition() * tileSize.Height + tileSize.Height / 2 - tileSize.Height / 4, player.getYPosition() * tileSize.Height + tileSize.Height / 2 - tileSize.Height / 4,
tileSize.Width / 2, tileSize.Width/2,
tileSize.Height / 2); tileSize.Height/2);
} }
/// <summary> /// <summary>

View File

@@ -1,39 +0,0 @@
namespace DefaultGui
{
partial class DefaultGui
{
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
}
#endregion
}
}

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DefaultGui namespace Frontend
{ {
/// <summary> /// <summary>
/// Interface that should be implemented by the class that represents your backend. /// Interface that should be implemented by the class that represents your backend.

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DefaultGui namespace Frontend
{ {
/// <summary> /// <summary>
/// Interface your positionable objects should implement. Such as the dragons and players. /// Interface your positionable objects should implement. Such as the dragons and players.

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DefaultGui namespace Frontend
{ {
/// <summary> /// <summary>
/// Interface that should be implemented by your class that represents one field in the grid. /// Interface that should be implemented by your class that represents one field in the grid.

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace DefaultGui namespace Frontend
{ {
static class Program static class Program
{ {

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DefaultGui namespace Frontend
{ {
/// <summary> /// <summary>
/// All classes in the test-directory are just classes to illustrate the concept of the frontend and its interfaces. /// All classes in the test-directory are just classes to illustrate the concept of the frontend and its interfaces.

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DefaultGui namespace Frontend
{ {
public class Entity : IPositionable public class Entity : IPositionable
{ {

View File

@@ -4,11 +4,11 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DefaultGui namespace Frontend
{ {
public class MapCell : ITile public class MapCell : ITile
{ {
private int x, y; private int x,y;
private List<MapCellAttribute> attributes; private List<MapCellAttribute> attributes;
public MapCell(int x, int y, List<MapCellAttribute> attributes) public MapCell(int x, int y, List<MapCellAttribute> attributes)
{ {
@@ -49,5 +49,5 @@ namespace DefaultGui
} }
} }
public enum MapCellAttribute { UNWALKABLE, WATER, FOREST, HUNTABLE } public enum MapCellAttribute {UNWALKABLE, WATER, FOREST, HUNTABLE}
} }