Skip to content

Commit

Permalink
GameStatus displays the current controller player's civ instead of ha…
Browse files Browse the repository at this point in the history
…rdcoded string
  • Loading branch information
pcen committed Sep 26, 2023
1 parent c046148 commit a6f720d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
6 changes: 4 additions & 2 deletions C7/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ public override void _Ready() {
GetTree().AutoAcceptQuit = false;
Global = GetNode<GlobalSingleton>("/root/GlobalSingleton");
try {
var animSoundPlayer = new AudioStreamPlayer();
AudioStreamPlayer animSoundPlayer = new();
AddChild(animSoundPlayer);
civ3AnimData = new AnimationManager(animSoundPlayer);
animTracker = new AnimationTracker(civ3AnimData);

controller = CreateGame.createGame(Global.LoadGamePath, Global.DefaultBicPath); // Spawns engine thread
GetNode<GameStatus>("CanvasLayer/Control/GameStatus").CurrentPlayer = controller;

Global.ResetLoadGamePath();
camera = GetNode<MapViewCamera>("MapViewCamera");

using (var gameDataAccess = new UIGameDataAccess()) {
using (UIGameDataAccess gameDataAccess = new()) {
GameMap map = gameDataAccess.gameData.map;
Util.setModPath(gameDataAccess.gameData.scenarioSearchPath);
log.Debug("RelativeModPath ", map.RelativeModPath);
Expand Down
12 changes: 9 additions & 3 deletions C7/UIElements/GameStatus/GameStatus.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
using Godot;
using System;
using C7GameData;
using Serilog;

public partial class GameStatus : MarginContainer
{

private ILogger log = LogManager.ForContext<GameStatus>();

LowerRightInfoBox LowerRightInfoBox = new LowerRightInfoBox();
Timer endTurnAlertTimer;

private Player player;
public Player CurrentPlayer {
get => player;
set {
player = value;
LowerRightInfoBox.PlayerCivilization = player.civilization.name;
}
}

[Signal] public delegate void BlinkyEndTurnButtonPressedEventHandler();

Expand Down
28 changes: 19 additions & 9 deletions C7/UIElements/GameStatus/LowerRightInfoBox.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Godot;
using System;
using ConvertCiv3Media;
using C7GameData;
using Serilog;
Expand All @@ -17,16 +16,33 @@ public partial class LowerRightInfoBox : TextureRect
Label attackDefenseMovement = new Label();
Label terrainType = new Label();
Label yearAndGold = new Label();
Label civAndGovt = new Label(){
Position = new Vector2(0, 90),
AnchorLeft = 0.5f,
AnchorRight = 0.5f,
HorizontalAlignment = HorizontalAlignment.Center,
};

Timer blinkingTimer = new Timer();
Boolean timerStarted = false; //This "isStopped" returns false if it's never been started. So we need this to know if we've ever started it.

bool timerStarted = false; //This "isStopped" returns false if it's never been started. So we need this to know if we've ever started it.

// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
this.CreateUI();
}

private string displayCiv;
public string PlayerCivilization {
get => displayCiv;
set {
displayCiv = value;
civAndGovt.Text = $"{displayCiv} - Despotism (5.5.0)";
civAndGovt.OffsetLeft = -1 * (civAndGovt.Size.X/2.0f);
}
}

private void CreateUI() {
Pcx boxRightColor = new Pcx(Util.Civ3MediaPath("Art/interface/box right color.pcx"));
Pcx boxRightAlpha = new Pcx(Util.Civ3MediaPath("Art/interface/box right alpha.pcx"));
Expand Down Expand Up @@ -75,14 +91,8 @@ private void CreateUI() {
//Then, when they are visible, we add a left margin that's negative and equal to half
//their width.
//Seems like there probably is an easier way, but I haven't found it yet.
Label civAndGovt = new Label();
civAndGovt.Text = "Carthage - Despotism (5.5.0)";
civAndGovt.HorizontalAlignment = HorizontalAlignment.Center;
civAndGovt.SetPosition(new Vector2(0, 90));
civAndGovt.AnchorLeft = 0.5f;
civAndGovt.AnchorRight = 0.5f;
boxRightRectangle.AddChild(civAndGovt);
civAndGovt.OffsetLeft = -1 * (civAndGovt.Size.X/2.0f);
PlayerCivilization = ""; // set empty string as placeholder

yearAndGold.Text = "Turn 0 10 Gold (+0 per turn)";
yearAndGold.HorizontalAlignment = HorizontalAlignment.Center;
Expand Down

0 comments on commit a6f720d

Please sign in to comment.