From 61ef55ca9fb94fadd94d45e42ffc62c825f79800 Mon Sep 17 00:00:00 2001 From: SWY1985 Date: Sun, 18 Mar 2018 15:45:44 +0100 Subject: [PATCH] #460: Initial Civilization PowerGraph implementation --- src/Screens/DebugOptions.cs | 13 +++++++-- src/Screens/PowerGraph.cs | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/Screens/PowerGraph.cs diff --git a/src/Screens/DebugOptions.cs b/src/Screens/DebugOptions.cs index 39539081..880d30b3 100644 --- a/src/Screens/DebugOptions.cs +++ b/src/Screens/DebugOptions.cs @@ -87,19 +87,25 @@ private void MenuBuildPalace(object sender, EventArgs args) Destroy(); } + private void MenuShowPowerGraph(object sender, EventArgs args) + { + GameTask.Enqueue(Show.Screen()); + 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(); - 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); @@ -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); @@ -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); } } } \ No newline at end of file diff --git a/src/Screens/PowerGraph.cs b/src/Screens/PowerGraph.cs new file mode 100644 index 00000000..c0c198f9 --- /dev/null +++ b/src/Screens/PowerGraph.cs @@ -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 . + +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)); + } + } + } +} \ No newline at end of file