Merge branch 'GuiManuel'
Conflicts: inf3.csproj
This commit is contained in:
@@ -76,7 +76,9 @@
|
|||||||
<Compile Include="src\Gui\MapPanel.cs" />
|
<Compile Include="src\Gui\MapPanel.cs" />
|
||||||
<Compile Include="src\Pathfinder.cs" />
|
<Compile Include="src\Pathfinder.cs" />
|
||||||
<Compile Include="src\Gui\IEntity.cs" />
|
<Compile Include="src\Gui\IEntity.cs" />
|
||||||
<Compile Include="src\Gui\SplashScreen.cs" />
|
<Compile Include="src\Gui\SplashScreen.cs" /
|
||||||
|
<Compile Include="src\Gui\OnlinePlayerList.cs" />
|
||||||
|
<Compile Include="src\Gui\IPlayer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace WorldOfPeacecraft
|
|||||||
return Dragons.Values;
|
return Dragons.Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IEntity> GetPlayers ()
|
public IEnumerable<IPlayer> GetPlayers ()
|
||||||
{
|
{
|
||||||
return Players.Values;
|
return Players.Values;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ namespace WorldOfPeacecraft
|
|||||||
class Gui : Form, IGui
|
class Gui : Form, IGui
|
||||||
{
|
{
|
||||||
private const int ChatWidth = 300;
|
private const int ChatWidth = 300;
|
||||||
|
private const int OnlinePlayerWidth = 100;
|
||||||
private IBackend Backend;
|
private IBackend Backend;
|
||||||
|
|
||||||
private MapPanel MapPanel;
|
private MapPanel MapPanel;
|
||||||
private ChatPanel ChatPanel;
|
private ChatPanel ChatPanel;
|
||||||
|
private OnlinePlayerList OnlinePlayerList;
|
||||||
|
|
||||||
public Gui ()
|
public Gui ()
|
||||||
{
|
{
|
||||||
@@ -40,11 +42,14 @@ namespace WorldOfPeacecraft
|
|||||||
{
|
{
|
||||||
ChatPanel = new ChatPanel (Backend);
|
ChatPanel = new ChatPanel (Backend);
|
||||||
MapPanel = new MapPanel (Backend);
|
MapPanel = new MapPanel (Backend);
|
||||||
|
OnlinePlayerList = new OnlinePlayerList (Backend);
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
this.Size = new Size(400 + ChatWidth, 400);
|
this.Size = new Size(OnlinePlayerWidth + 400 + ChatWidth, 400);
|
||||||
MapPanel.Location = new Point(0,0);
|
OnlinePlayerList.Location = new Point(0,0);
|
||||||
|
OnlinePlayerList.Size = new Size(OnlinePlayerWidth, 400);
|
||||||
|
MapPanel.Location = new Point(OnlinePlayerWidth,0);
|
||||||
MapPanel.Size = new Size(400, 400);
|
MapPanel.Size = new Size(400, 400);
|
||||||
ChatPanel.Location = new Point (400, 0);
|
ChatPanel.Location = new Point (OnlinePlayerWidth + 400, 0);
|
||||||
ChatPanel.Size = new Size (300, 400);
|
ChatPanel.Size = new Size (300, 400);
|
||||||
this.DoubleBuffered = true;
|
this.DoubleBuffered = true;
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
@@ -52,6 +57,7 @@ namespace WorldOfPeacecraft
|
|||||||
this.Text = "World of Peacecraft";
|
this.Text = "World of Peacecraft";
|
||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
|
|
||||||
|
this.Controls.Add (OnlinePlayerList);
|
||||||
this.Controls.Add (MapPanel);
|
this.Controls.Add (MapPanel);
|
||||||
this.Controls.Add (ChatPanel);
|
this.Controls.Add (ChatPanel);
|
||||||
|
|
||||||
@@ -70,8 +76,10 @@ namespace WorldOfPeacecraft
|
|||||||
{
|
{
|
||||||
MapPanel.PerformLayout ();
|
MapPanel.PerformLayout ();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
this.SetClientSizeCore(MapPanel.Width + ChatWidth, MapPanel.Height);
|
this.SetClientSizeCore(OnlinePlayerWidth + MapPanel.Width + ChatWidth, MapPanel.Height);
|
||||||
ChatPanel.Location = new Point (MapPanel.Width, 0);
|
OnlinePlayerList.Size = new Size(OnlinePlayerWidth, MapPanel.Height);
|
||||||
|
MapPanel.Location = new Point(OnlinePlayerWidth, 0);
|
||||||
|
ChatPanel.Location = new Point (OnlinePlayerWidth + MapPanel.Width, 0);
|
||||||
ChatPanel.Size = new Size (ChatWidth, MapPanel.Height);
|
ChatPanel.Size = new Size (ChatWidth, MapPanel.Height);
|
||||||
this.ResumeLayout();
|
this.ResumeLayout();
|
||||||
ChatPanel.UpdateData ();
|
ChatPanel.UpdateData ();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace WorldOfPeacecraft
|
|||||||
{
|
{
|
||||||
ITile[,] GetMap();
|
ITile[,] GetMap();
|
||||||
|
|
||||||
IEnumerable<IEntity> GetPlayers();
|
IEnumerable<IPlayer> GetPlayers();
|
||||||
|
|
||||||
IEnumerable<IEntity> GetDragons();
|
IEnumerable<IEntity> GetDragons();
|
||||||
|
|
||||||
|
|||||||
7
src/Gui/IPlayer.cs
Normal file
7
src/Gui/IPlayer.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace WorldOfPeacecraft
|
||||||
|
{
|
||||||
|
public interface IPlayer : IEntity
|
||||||
|
{
|
||||||
|
string GetName();
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/Gui/OnlinePlayerList.cs
Normal file
33
src/Gui/OnlinePlayerList.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace WorldOfPeacecraft
|
||||||
|
{
|
||||||
|
public class OnlinePlayerList : Panel
|
||||||
|
{
|
||||||
|
private IBackend Backend;
|
||||||
|
|
||||||
|
public OnlinePlayerList(IBackend backend)
|
||||||
|
{
|
||||||
|
this.Backend = backend;
|
||||||
|
SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
|
||||||
|
Font = new Font(Font, FontStyle.Bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaint (PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaint (e);
|
||||||
|
Graphics g = e.Graphics;
|
||||||
|
g.FillRectangle (new SolidBrush (Color.White), this.DisplayRectangle);
|
||||||
|
g.DrawRectangle (new Pen(new SolidBrush (Color.Black)), 0, 0, Width - 1, Height - 1);
|
||||||
|
IEnumerable<IPlayer> players = Backend.GetPlayers ();
|
||||||
|
int count = 0;
|
||||||
|
Brush brush = new SolidBrush(Color.Black);
|
||||||
|
foreach (IPlayer player in players) {
|
||||||
|
g.DrawString(player.GetName(), Font, brush, 20, 10 + 20 * count);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace WorldOfPeacecraft
|
namespace WorldOfPeacecraft
|
||||||
{
|
{
|
||||||
public class Player : Entity
|
public class Player : Entity, IPlayer
|
||||||
{
|
{
|
||||||
private int Score;
|
private int Score;
|
||||||
|
|
||||||
@@ -19,6 +19,11 @@ namespace WorldOfPeacecraft
|
|||||||
return Score;
|
return Score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetName ()
|
||||||
|
{
|
||||||
|
return Desc;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return "Player: " + Id + " " + Coord.X + " " + Coord.Y + " " + Desc + " " + Busy + " " + Score;
|
return "Player: " + Id + " " + Coord.X + " " + Coord.Y + " " + Desc + " " + Busy + " " + Score;
|
||||||
|
|||||||
Reference in New Issue
Block a user