Aktuelle Version der DefaultGui
This commit is contained in:
87
DefaultGui/DefaultGui.Designer.cs
generated
Normal file
87
DefaultGui/DefaultGui.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
/// <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.
|
||||
@@ -27,8 +27,7 @@ namespace DefaultGui
|
||||
public partial class DefaultGui : Form
|
||||
{
|
||||
private IBackend backend;
|
||||
public DefaultGui(IBackend backend)
|
||||
: base()
|
||||
public DefaultGui(IBackend backend) : base()
|
||||
{
|
||||
if (backend == null)
|
||||
{
|
||||
@@ -54,24 +53,24 @@ namespace DefaultGui
|
||||
/// <param name="e"></param>
|
||||
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();
|
||||
this.chatInput.Text = "";
|
||||
// ignore empty input
|
||||
if (input != "")
|
||||
{
|
||||
if (input.StartsWith("/"))
|
||||
string input = this.chatInput.Text.Trim();
|
||||
this.chatInput.Text = "";
|
||||
// ignore empty input
|
||||
if (input != "")
|
||||
{
|
||||
input = input.Substring(1, input.Length - 1);
|
||||
this.backend.sendCommand(input);
|
||||
if (input.StartsWith("/"))
|
||||
{
|
||||
input = input.Substring(1, input.Length-1);
|
||||
this.backend.sendCommand(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.backend.sendChat(input);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.backend.sendChat(input);
|
||||
}
|
||||
}
|
||||
this.board.Focus();
|
||||
this.board.Focus();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -119,18 +118,15 @@ namespace DefaultGui
|
||||
/// </summary>
|
||||
/// <param name="sender"></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();
|
||||
ITile[][] cells = this.backend.getMap();
|
||||
// validity checked beforehand in getTileSize
|
||||
Debug.Assert(cells != null);
|
||||
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(this.board.CreateGraphics(), this.board.DisplayRectangle);
|
||||
Graphics g = this.CreateGraphics();
|
||||
for (int x = 0; x < cells.Length; x++)
|
||||
{
|
||||
for (int y = 0; y < cells[x].Length; y++)
|
||||
{
|
||||
for(int x = 0; x < cells.Length; x++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -210,8 +206,8 @@ namespace DefaultGui
|
||||
g.FillRectangle(new SolidBrush(Color.DarkGoldenrod),
|
||||
player.getXPosition() * tileSize.Width + tileSize.Width / 2 - tileSize.Width / 4,
|
||||
player.getYPosition() * tileSize.Height + tileSize.Height / 2 - tileSize.Height / 4,
|
||||
tileSize.Width / 2,
|
||||
tileSize.Height / 2);
|
||||
tileSize.Width/2,
|
||||
tileSize.Height/2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
39
DefaultGui/DefaultGui/DefaultGui.Designer.cs
generated
39
DefaultGui/DefaultGui/DefaultGui.Designer.cs
generated
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that should be implemented by the class that represents your backend.
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface your positionable objects should implement. Such as the dragons and players.
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface that should be implemented by your class that represents one field in the grid.
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
/// <summary>
|
||||
/// All classes in the test-directory are just classes to illustrate the concept of the frontend and its interfaces.
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
public class Entity : IPositionable
|
||||
{
|
||||
@@ -4,11 +4,11 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DefaultGui
|
||||
namespace Frontend
|
||||
{
|
||||
public class MapCell : ITile
|
||||
{
|
||||
private int x, y;
|
||||
private int x,y;
|
||||
private 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}
|
||||
}
|
||||
Reference in New Issue
Block a user