Skip to content

Commit

Permalink
#460: Draw year lines/labels in PowerGraph screen
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanWouters committed Mar 20, 2018
1 parent 7602239 commit 1dbcc7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ public static int TurnToYear(ushort turn)
return (turn - 400) + 1850;
}

public static string YearString(ushort turn)
public static string YearString(ushort turn, bool zeroAd = false)
{
int year = TurnToYear(turn);
if (zeroAd && year == 1) year = 0;
if (year < 0)
return string.Format("{0} BC", -year);
return string.Format("{0} AD", year);
Expand Down
13 changes: 11 additions & 2 deletions src/Screens/PowerGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ public PowerGraph() : base(MouseCursor.None)
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);
.DrawRectangle(4, 9, 312, 184);

for (int i = 0; i < 13; i++)
{
int xx = 4 + (i * 25);
ushort turn = (ushort)(i * 50);
if (turn > Game.GameTurn) break;
this.DrawLine(xx, 9, xx, 192);
if (turn % 100 != 0) continue;
this.DrawText(Common.YearString(turn).Replace(" ", ""), 1, 15, xx - 4, 194);
}

Player[] players = Game.Players.Where(x => !(x.Civilization is Barbarian)).ToArray();
for (int i = 0; i < players.Length; i++)
Expand Down

0 comments on commit 1dbcc7e

Please sign in to comment.