Skip to content

Commit

Permalink
Display the tech icons and names in the science advisor screen
Browse files Browse the repository at this point in the history
  • Loading branch information
TomWerner committed Jan 22, 2025
1 parent c2582f6 commit 5998531
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
11 changes: 1 addition & 10 deletions C7/UIElements/Advisors/ScienceAdvisor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ private void CreateUI() {
AddChild(GoBackButton);
GoBackButton.Pressed += ReturnToMenu;

// TODO: Figure out how to pick which of the different sized tech boxes
// we should use for a given tech.
//
// NOTE: this pcx has 4 columns (discovered, planned, possible,
// not yet researchable), and 16 rows, 4 per era, with different sizes.
ImageTexture techBox = Util.LoadTextureFromPCX("Art/Advisors/techboxes.pcx", 1, 1, 180, 80);
using (UIGameDataAccess gameDataAccess = new()) {
List<Tech> techs = gameDataAccess.gameData.techs;

Expand All @@ -64,10 +58,7 @@ private void CreateUI() {
continue;
}

// TODO: draw the icon, name, etc. Consider sticking that in
// its own class.
TextureButton techButton = new();
techButton.TextureNormal = techBox;
TechBox techButton = new(tech);
techButton.SetPosition(new Vector2(tech.X, tech.Y));
AddChild(techButton);
}
Expand Down
36 changes: 36 additions & 0 deletions C7/UIElements/Advisors/TechBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

using C7GameData;
using Godot;

public partial class TechBox : TextureButton {
private Tech tech;

public TechBox(Tech tech) {
this.tech = tech;
}

public override void _Ready() {
// TODO: Figure out how to pick which of the different sized tech boxes
// we should use for a given tech.
//
// NOTE: this pcx has 4 columns (discovered, planned, possible,
// not yet researchable), and 16 rows, 4 per era, with different sizes.
ImageTexture techBox = Util.LoadTextureFromPCX("Art/Advisors/techboxes.pcx", 1, 1, 180, 80);
TextureNormal = techBox;

ImageTexture iconTexture = Util.LoadTextureFromPCX(tech.SmallIconPath);
TextureRect icon = new() {
Texture = iconTexture
};
icon.SetPosition(new Vector2(12, 32));
AddChild(icon);

// TODO: Have the name trail off if it is too large for the box.
Label techName = new() {
Text = tech.Name,
OffsetLeft = 12,
OffsetTop = 12
};
AddChild(techName);
}
}

0 comments on commit 5998531

Please sign in to comment.