Skip to content

Commit

Permalink
#460: Initial Civilization PowerGraph implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SWY1985 committed Mar 18, 2018
1 parent 28b0dc1 commit 61ef55c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Screens/DebugOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,25 @@ private void MenuBuildPalace(object sender, EventArgs args)
Destroy();
}

private void MenuShowPowerGraph(object sender, EventArgs args)
{
GameTask.Enqueue(Show.Screen<PowerGraph>());
Destroy();
}

protected override bool HasUpdate(uint gameTick)
{
if (_update)
{
_update = false;

Picture menuGfx = new Picture(131, 95)
Picture menuGfx = new Picture(131, 103)
.Tile(Pattern.PanelGrey)
.DrawRectangle3D()
.DrawText("Debug Options:", 0, 15, 4, 4)
.As<Picture>();

IBitmap menuBackground = menuGfx[2, 11, 128, 80].ColourReplace((7, 11), (22, 3));
IBitmap menuBackground = menuGfx[2, 11, 128, 88].ColourReplace((7, 11), (22, 3));

this.AddLayer(menuGfx, 25, 17);

Expand Down Expand Up @@ -127,6 +133,7 @@ protected override bool HasUpdate(uint gameTick)
menu.Items.Add("Meet With King").OnSelect(MenuMeetWithKing);
menu.Items.Add("Toggle Reveal World").OnSelect(MenuRevealWorld);
menu.Items.Add("Build Palace").OnSelect(MenuBuildPalace);
menu.Items.Add("Show PowerGraph").OnSelect(MenuShowPowerGraph);

this.FillRectangle(24, 16, 105, menu.RowHeight * (menu.Items.Count + 1), 5);

Expand All @@ -139,7 +146,7 @@ public DebugOptions() : base(MouseCursor.Pointer)
{
Palette = Common.DefaultPalette;
this.AddLayer(Common.Screens.Last(), 0, 0)
.FillRectangle(24, 16, 133, 97, 5);
.FillRectangle(24, 16, 133, 105, 5);
}
}
}
58 changes: 58 additions & 0 deletions src/Screens/PowerGraph.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// CivOne
//
// To the extent possible under law, the person who associated CC0 with
// CivOne has waived all copyright and related or neighboring rights
// to CivOne.
//
// You should have received a copy of the CC0 legalcode along with this
// work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

using System.Linq;
using CivOne.Civilizations;
using CivOne.Enums;
using CivOne.Events;
using CivOne.Graphics;

namespace CivOne.Screens
{
internal class PowerGraph : BaseScreen
{
private bool _update = true;

protected override bool HasUpdate(uint gameTick)
{
if (!_update) return false;
_update = false;
return true;
}

public override bool KeyDown(KeyboardEventArgs args)
{
Destroy();
return true;
}

public override bool MouseDown(ScreenEventArgs args)
{
Destroy();
return true;
}

public PowerGraph() : base(MouseCursor.None)
{
Palette = Common.TopScreen.Palette.Copy();

this.Clear(8)
.DrawText("CIVILIZATION POWERGraph", 0, 5, 100, 3)
.DrawText("CIVILIZATION POWERGraph", 0, 15, 100, 2)
.DrawRectangle(4, 9, 312, 184)
.DrawText("4000BC", 1, 15, 0, 194);

Player[] players = Game.Players.Where(x => !(x.Civilization is Barbarian)).ToArray();
for (int i = 0; i < players.Length; i++)
{
this.DrawText(players[i].TribeName, 0, Common.ColourLight[Game.PlayerNumber(players[i])], 8, 12 + (i * 8));
}
}
}
}

0 comments on commit 61ef55c

Please sign in to comment.