aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------extension/deps/openvic-simulation0
-rw-r--r--extension/src/GameSingleton.cpp28
-rw-r--r--extension/src/GameSingleton.hpp12
-rw-r--r--game/localisation/en_GB/mapmodes.csv1
-rw-r--r--game/localisation/en_GB/menus.csv2
-rw-r--r--game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd4
-rw-r--r--game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd3
-rw-r--r--game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn10
8 files changed, 48 insertions, 12 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation
-Subproject 420c2dce47e74c01ff46be991058d543e0c70a6
+Subproject 8a08be3e7e8477973e243716d431ad7117acfa4
diff --git a/extension/src/GameSingleton.cpp b/extension/src/GameSingleton.cpp
index 2668700..efacb8e 100644
--- a/extension/src/GameSingleton.cpp
+++ b/extension/src/GameSingleton.cpp
@@ -1,5 +1,7 @@
#include "GameSingleton.hpp"
+#include <cassert>
+
#include <godot_cpp/variant/utility_functions.hpp>
#include "openvic/utility/Logger.hpp"
@@ -9,6 +11,16 @@
using namespace godot;
using namespace OpenVic;
+TerrainVariant::TerrainVariant(std::string const& new_identfier,
+ colour_t new_colour, Ref<Image> const& new_image)
+ : HasIdentifier { new_identfier },
+ HasColour { new_colour, true },
+ image { new_image } {}
+
+Ref<Image> TerrainVariant::get_image() const {
+ return image;
+}
+
GameSingleton* GameSingleton::singleton = nullptr;
void GameSingleton::_bind_methods() {
@@ -62,6 +74,7 @@ void GameSingleton::_bind_methods() {
ClassDB::bind_static_method("GameSingleton", D_METHOD("get_province_info_province_key"), &GameSingleton::get_province_info_province_key);
ClassDB::bind_static_method("GameSingleton", D_METHOD("get_province_info_region_key"), &GameSingleton::get_province_info_region_key);
ClassDB::bind_static_method("GameSingleton", D_METHOD("get_province_info_life_rating_key"), &GameSingleton::get_province_info_life_rating_key);
+ ClassDB::bind_static_method("GameSingleton", D_METHOD("get_province_info_total_population_key"), &GameSingleton::get_province_info_total_population_key);
ClassDB::bind_static_method("GameSingleton", D_METHOD("get_province_info_rgo_key"), &GameSingleton::get_province_info_rgo_key);
ClassDB::bind_static_method("GameSingleton", D_METHOD("get_province_info_buildings_key"), &GameSingleton::get_province_info_buildings_key);
@@ -83,7 +96,7 @@ void GameSingleton::_on_state_updated() {
}
/* REQUIREMENTS:
- * MAP-21, MAP-23, MAP-25, MAP-32
+ * MAP-21, MAP-23, MAP-25, MAP-32, MAP-33
*/
GameSingleton::GameSingleton() : game_manager { [this]() { _on_state_updated(); } },
terrain_variants { "terrain variants" } {
@@ -119,7 +132,7 @@ Error GameSingleton::_load_hardcoded_defines() {
} },
{ "mapmode_index",
[](Map const& map, Province const& province) -> colour_t {
- const colour_t f = fraction_to_colour_byte(province.get_index(), map.get_province_count());
+ const colour_t f = fraction_to_colour_byte(province.get_index(), map.get_province_count() + 1);
return HIGH_ALPHA_VALUE | (f << 16) | (f << 8) | f;
} },
{ "mapmode_rgo",
@@ -132,7 +145,7 @@ Error GameSingleton::_load_hardcoded_defines() {
[](Map const& map, Province const& province) -> colour_t {
Building const* railroad = province.get_building_by_identifier("building_railroad");
if (railroad != nullptr) {
- colour_t val = fraction_to_colour_byte(railroad->get_level(), railroad->get_type().get_max_level(), 0.5f, 1.0f);
+ colour_t val = fraction_to_colour_byte(railroad->get_level(), railroad->get_type().get_max_level() + 1, 0.5f, 1.0f);
switch (railroad->get_expansion_state()) {
case Building::ExpansionState::CannotExpand: val <<= 16; break;
case Building::ExpansionState::CanExpand: break;
@@ -141,6 +154,10 @@ Error GameSingleton::_load_hardcoded_defines() {
return HIGH_ALPHA_VALUE | val;
}
return HIGH_ALPHA_VALUE;
+ } },
+ { "mapmode_population",
+ [](Map const& map, Province const& province) -> colour_t {
+ return HIGH_ALPHA_VALUE | (fraction_to_colour_byte(province.get_total_population(), map.get_highest_province_population() + 1, 0.1f, 1.0f) << 8);
} }
};
for (mapmode_t const& mapmode : mapmodes)
@@ -187,6 +204,10 @@ StringName const& GameSingleton::get_province_info_life_rating_key() {
static const StringName key = "life_rating";
return key;
}
+StringName const& GameSingleton::get_province_info_total_population_key() {
+ static const StringName key = "total_population";
+ return key;
+}
StringName const& GameSingleton::get_province_info_rgo_key() {
static const StringName key = "rgo";
return key;
@@ -235,6 +256,7 @@ Dictionary GameSingleton::get_province_info_from_index(int32_t index) const {
if (rgo != nullptr) ret[get_province_info_rgo_key()] = std_to_godot_string(rgo->get_identifier());
ret[get_province_info_life_rating_key()] = province->get_life_rating();
+ ret[get_province_info_total_population_key()] = province->get_total_population();
std::vector<Building> const& buildings = province->get_buildings();
if (!buildings.empty()) {
diff --git a/extension/src/GameSingleton.hpp b/extension/src/GameSingleton.hpp
index 6c91de5..23eb334 100644
--- a/extension/src/GameSingleton.hpp
+++ b/extension/src/GameSingleton.hpp
@@ -7,20 +7,19 @@
namespace OpenVic {
struct TerrainVariant : HasIdentifier, HasColour {
+ friend class GameSingleton;
+
private:
const godot::Ref<godot::Image> image;
+ TerrainVariant(std::string const& new_identfier, colour_t new_colour,
+ godot::Ref<godot::Image> const& new_image);
public:
static constexpr size_t MAX_INDEX = 1 << (8 * sizeof(Map::terrain_t));
- TerrainVariant(std::string const& new_identfier, colour_t new_colour,
- godot::Ref<godot::Image> const& new_image)
- : HasIdentifier { new_identfier },
- HasColour { new_colour },
- image { new_image } {}
TerrainVariant(TerrainVariant&&) = default;
- godot::Ref<godot::Image> get_image() const { return image; }
+ godot::Ref<godot::Image> get_image() const;
};
class GameSingleton : public godot::Object {
GDCLASS(GameSingleton, godot::Object)
@@ -106,6 +105,7 @@ namespace OpenVic {
static godot::StringName const& get_province_info_province_key();
static godot::StringName const& get_province_info_region_key();
static godot::StringName const& get_province_info_life_rating_key();
+ static godot::StringName const& get_province_info_total_population_key();
static godot::StringName const& get_province_info_rgo_key();
static godot::StringName const& get_province_info_buildings_key();
diff --git a/game/localisation/en_GB/mapmodes.csv b/game/localisation/en_GB/mapmodes.csv
index 34c3890..3b7fd52 100644
--- a/game/localisation/en_GB/mapmodes.csv
+++ b/game/localisation/en_GB/mapmodes.csv
@@ -6,3 +6,4 @@ mapmode_terrain;Terrain
mapmode_index;Index
mapmode_rgo;RGO
mapmode_infrastructure;Infrastructure
+mapmode_population;Population Density
diff --git a/game/localisation/en_GB/menus.csv b/game/localisation/en_GB/menus.csv
index a086e85..1d16af6 100644
--- a/game/localisation/en_GB/menus.csv
+++ b/game/localisation/en_GB/menus.csv
@@ -123,6 +123,8 @@ DIALOG_SAVE_AND_QUIT;Save and Quit
province_MISSING;No Province
region_MISSING;No Region
LIFE_RATING_TOOLTIP;Liferating: {life_rating}
+total_population_MISSING;No Population
+PROVINCE_POPULATION_TOOLTIP;Province population
rgo_MISSING;No RGO
building_MISSING;No Building
building_fort;Fort
diff --git a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd
index c84f116..350c1a8 100644
--- a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd
+++ b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd
@@ -11,7 +11,7 @@ signal zoom_out_button_pressed
var _mapmode_button_group : ButtonGroup
# REQUIREMENTS:
-# * UI-550, UI-552, UI-554, UI-561
+# * UI-550, UI-552, UI-554, UI-561, UI-562
func _add_mapmode_button(identifier : String) -> void:
var button := Button.new()
button.text = identifier
@@ -37,7 +37,7 @@ func _on_game_session_menu_button_pressed() -> void:
# REQUIREMENTS:
# * SS-76
-# * UIFUN-129, UIFUN-131, UIFUN-133, UIFUN-140
+# * UIFUN-129, UIFUN-131, UIFUN-133, UIFUN-140, UIFUN-141
func _mapmode_pressed(button : BaseButton) -> void:
GameSingleton.set_mapmode(button.tooltip_text)
diff --git a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd
index 13418b6..9a3690e 100644
--- a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd
+++ b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd
@@ -3,6 +3,7 @@ extends PanelContainer
@export var _province_name_label : Label
@export var _region_name_label : Label
@export var _life_rating_bar : ProgressBar
+@export var _total_population_label : Label
@export var _rgo_icon_texture_rect : TextureRect
@export var _rgo_name_label : Label
@export var _buildings_container : Container
@@ -110,6 +111,8 @@ func _update_info() -> void:
"life_rating": Localisation.tr_number(_life_rating_bar.value)
})
+ _total_population_label.text = Localisation.tr_number(_province_info.get(GameSingleton.get_province_info_total_population_key(), 0))
+
_rgo_name_label.text = _province_info.get(GameSingleton.get_province_info_rgo_key(),
GameSingleton.get_province_info_rgo_key() + _missing_suffix)
_rgo_icon_texture_rect.texture = GameSingleton.get_good_icon_texture(_rgo_name_label.text)
diff --git a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn
index 896f8e9..7c82f10 100644
--- a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn
+++ b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn
@@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd" id="1_3n8k5"]
-[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")]
+[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_total_population_label", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")]
editor_description = "UI-56"
anchors_preset = 2
anchor_top = 1.0
@@ -15,6 +15,7 @@ script = ExtResource("1_3n8k5")
_province_name_label = NodePath("PanelList/TopBarList/NameList/ProvinceName")
_region_name_label = NodePath("PanelList/TopBarList/NameList/RegionName")
_life_rating_bar = NodePath("PanelList/TopBarList/NameList/LifeRatingBar")
+_total_population_label = NodePath("PanelList/InteractList/TotalPopulation")
_rgo_icon_texture_rect = NodePath("PanelList/InteractList/RGOInfo/RGOIcon")
_rgo_name_label = NodePath("PanelList/InteractList/RGOInfo/RGOName")
_buildings_container = NodePath("PanelList/InteractList/BuildingsContainer")
@@ -63,6 +64,13 @@ size_flags_vertical = 3
layout_mode = 2
mouse_filter = 1
+[node name="TotalPopulation" type="Label" parent="PanelList/InteractList"]
+editor_description = "UI-121"
+layout_mode = 2
+tooltip_text = "PROVINCE_POPULATION_TOOLTIP"
+mouse_filter = 1
+text = "total_population_MISSING"
+
[node name="RGOInfo" type="HBoxContainer" parent="PanelList/InteractList"]
editor_description = "UI-112"
layout_mode = 2