aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-08 18:55:42 +0200
committer hop311 <hop3114@gmail.com>2024-09-10 00:29:16 +0200
commit6d4b8b087b62b5487d72cc6c2265b3e00afb9c8a (patch)
tree95518129dcaf6116c71b8c9f0e819675c31b99fd
parenta3b34e2d6a9bf2bc59619390e0490a5b45d75337 (diff)
Ranking + army topbar inforanking
m---------extension/deps/openvic-simulation0
-rw-r--r--extension/src/openvic-extension/classes/GUILabel.cpp6
-rw-r--r--extension/src/openvic-extension/classes/GUILabel.hpp1
-rw-r--r--extension/src/openvic-extension/singletons/GameSingleton.cpp29
-rw-r--r--extension/src/openvic-extension/singletons/GameSingleton.hpp5
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.cpp201
-rw-r--r--extension/src/openvic-extension/singletons/MenuSingleton.hpp7
-rw-r--r--extension/src/openvic-extension/singletons/PopulationMenu.cpp6
-rw-r--r--game/src/Game/GameSession/MapView.gd6
-rw-r--r--game/src/Game/GameSession/Topbar.gd156
10 files changed, 375 insertions, 42 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation
-Subproject d36045735fc56e8cfe772713c2ef5012dad94ae
+Subproject 7a9206e3869fbb659d296b854c90f5c81755a5c
diff --git a/extension/src/openvic-extension/classes/GUILabel.cpp b/extension/src/openvic-extension/classes/GUILabel.cpp
index 732dec2..4b6b1c1 100644
--- a/extension/src/openvic-extension/classes/GUILabel.cpp
+++ b/extension/src/openvic-extension/classes/GUILabel.cpp
@@ -31,12 +31,18 @@ String const& GUILabel::get_substitution_marker() {
return SUBSTITUTION_MARKER;
}
+String const& GUILabel::get_flag_marker() {
+ static const String FLAG_MARKER = String::chr(0x40); // @
+ return FLAG_MARKER;
+}
+
void GUILabel::_bind_methods() {
GUI_TOOLTIP_BIND_METHODS(GUILabel)
OV_BIND_SMETHOD(get_colour_marker);
OV_BIND_SMETHOD(get_currency_marker);
OV_BIND_SMETHOD(get_substitution_marker);
+ OV_BIND_SMETHOD(get_flag_marker);
OV_BIND_METHOD(GUILabel::clear);
OV_BIND_METHOD(GUILabel::get_gui_text_name);
diff --git a/extension/src/openvic-extension/classes/GUILabel.hpp b/extension/src/openvic-extension/classes/GUILabel.hpp
index 102ad94..67981d7 100644
--- a/extension/src/openvic-extension/classes/GUILabel.hpp
+++ b/extension/src/openvic-extension/classes/GUILabel.hpp
@@ -61,6 +61,7 @@ namespace OpenVic {
static godot::String const& get_colour_marker();
static godot::String const& get_currency_marker();
static godot::String const& get_substitution_marker();
+ static godot::String const& get_flag_marker();
GUILabel();
diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp
index 24d8a73..f258fe1 100644
--- a/extension/src/openvic-extension/singletons/GameSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp
@@ -69,6 +69,8 @@ void GameSingleton::_bind_methods() {
OV_BIND_METHOD(GameSingleton::set_selected_province, { "index" });
OV_BIND_METHOD(GameSingleton::unset_selected_province);
+ OV_BIND_METHOD(GameSingleton::set_viewed_country_by_province_index, { "province_index" });
+
OV_BIND_METHOD(GameSingleton::update_clock);
ADD_SIGNAL(MethodInfo(_signal_gamestate_updated()));
@@ -95,7 +97,7 @@ void GameSingleton::_on_clock_state_changed() {
GameSingleton::GameSingleton()
: game_manager {
std::bind(&GameSingleton::_on_gamestate_updated, this), std::bind(&GameSingleton::_on_clock_state_changed, this)
- } {
+ }, viewed_country { nullptr } {
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
}
@@ -139,6 +141,10 @@ Error GameSingleton::setup_game(int32_t bookmark_index) {
ERR_FAIL_NULL_V(menu_singleton, FAILED);
ret &= menu_singleton->_population_menu_update_provinces() == OK;
+ // TODO - replace with actual starting country
+ set_viewed_country(instance_manager->get_country_instance_manager().get_country_instance_by_identifier("ENG"));
+ ERR_FAIL_NULL_V(viewed_country, FAILED);
+
return ERR(ret);
}
@@ -349,6 +355,27 @@ void GameSingleton::unset_selected_province() {
set_selected_province(ProvinceDefinition::NULL_INDEX);
}
+void GameSingleton::set_viewed_country(CountryInstance const* new_viewed_country) {
+ if (viewed_country != new_viewed_country) {
+ viewed_country = new_viewed_country;
+
+ Logger::info("Set viewed country to: ", viewed_country != nullptr ? viewed_country->get_identifier() : "NULL");
+
+ _on_gamestate_updated();
+ }
+}
+
+void GameSingleton::set_viewed_country_by_province_index(int32_t province_index) {
+ InstanceManager* instance_manager = get_instance_manager();
+ ERR_FAIL_NULL(instance_manager);
+
+ ProvinceInstance const* province_instance =
+ instance_manager->get_map_instance().get_province_instance_by_index(province_index);
+ ERR_FAIL_NULL(province_instance);
+
+ set_viewed_country(province_instance->get_owner());
+}
+
Error GameSingleton::update_clock() {
return ERR(game_manager.update_clock());
}
diff --git a/extension/src/openvic-extension/singletons/GameSingleton.hpp b/extension/src/openvic-extension/singletons/GameSingleton.hpp
index e0eb5fc..e737643 100644
--- a/extension/src/openvic-extension/singletons/GameSingleton.hpp
+++ b/extension/src/openvic-extension/singletons/GameSingleton.hpp
@@ -15,6 +15,8 @@ namespace OpenVic {
GameManager game_manager;
+ CountryInstance const* PROPERTY(viewed_country);
+
godot::Vector2i image_subdivisions;
godot::Ref<godot::Texture2DArray> province_shape_texture;
godot::Ref<godot::Image> province_colour_image;
@@ -124,6 +126,9 @@ namespace OpenVic {
void set_selected_province(int32_t index);
void unset_selected_province();
+ void set_viewed_country(CountryInstance const* new_viewed_country);
+ void set_viewed_country_by_province_index(int32_t province_index);
+
godot::Error update_clock();
};
}
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.cpp b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
index 367462b..5074507 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.cpp
@@ -107,6 +107,10 @@ String MenuSingleton::get_country_adjective(CountryInstance const& country) cons
}
void MenuSingleton::_bind_methods() {
+ OV_BIND_SMETHOD(get_tooltip_separator);
+ OV_BIND_METHOD(MenuSingleton::get_country_name_from_identifier, { "country_identifier" });
+ OV_BIND_METHOD(MenuSingleton::get_country_adjective_from_identifier, { "country_identifier" });
+
/* TOOLTIP */
OV_BIND_METHOD(MenuSingleton::show_tooltip, { "text", "substitution_dict", "position" });
OV_BIND_METHOD(MenuSingleton::show_control_tooltip, { "text", "substitution_dict", "control" });
@@ -126,6 +130,9 @@ void MenuSingleton::_bind_methods() {
OV_BIND_METHOD(MenuSingleton::get_administrative_pop_icon_index);
OV_BIND_METHOD(MenuSingleton::get_rgo_owner_pop_icon_index);
+ /* TOPBAR */
+ OV_BIND_METHOD(MenuSingleton::get_topbar_info);
+
/* TIME/SPEED CONTROL PANEL */
OV_BIND_METHOD(MenuSingleton::set_paused, { "paused" });
OV_BIND_METHOD(MenuSingleton::toggle_paused);
@@ -219,6 +226,49 @@ MenuSingleton::~MenuSingleton() {
singleton = nullptr;
}
+String MenuSingleton::get_tooltip_separator() {
+ static const String tooltip_separator = "\n" + String { "-" }.repeat(14) + "\n";
+ return tooltip_separator;
+}
+
+String MenuSingleton::get_country_name_from_identifier(String const& country_identifier) const {
+ if (country_identifier.is_empty()) {
+ return {};
+ }
+
+ GameSingleton const* game_singleton = GameSingleton::get_singleton();
+ ERR_FAIL_NULL_V(game_singleton, {});
+
+ InstanceManager const* instance_manager = game_singleton->get_instance_manager();
+ ERR_FAIL_NULL_V(instance_manager, {});
+
+ CountryInstance const* country = instance_manager->get_country_instance_manager().get_country_instance_by_identifier(
+ Utilities::godot_to_std_string(country_identifier)
+ );
+ ERR_FAIL_NULL_V(country, {});
+
+ return get_country_name(*country);
+}
+
+String MenuSingleton::get_country_adjective_from_identifier(String const& country_identifier) const {
+ if (country_identifier.is_empty()) {
+ return {};
+ }
+
+ GameSingleton const* game_singleton = GameSingleton::get_singleton();
+ ERR_FAIL_NULL_V(game_singleton, {});
+
+ InstanceManager const* instance_manager = game_singleton->get_instance_manager();
+ ERR_FAIL_NULL_V(instance_manager, {});
+
+ CountryInstance const* country = instance_manager->get_country_instance_manager().get_country_instance_by_identifier(
+ Utilities::godot_to_std_string(country_identifier)
+ );
+ ERR_FAIL_NULL_V(country, {});
+
+ return get_country_adjective(*country);
+}
+
/* TOOLTIP */
void MenuSingleton::show_tooltip(String const& text, Dictionary const& substitution_dict, Vector2 const& position) {
@@ -452,6 +502,157 @@ int32_t MenuSingleton::get_rgo_owner_pop_icon_index() const {
return sprite;
}
+/* TOPBAR */
+
+Dictionary MenuSingleton::get_topbar_info() const {
+ GameSingleton const* game_singleton = GameSingleton::get_singleton();
+ ERR_FAIL_NULL_V(game_singleton, {});
+
+ CountryInstance const* country = game_singleton->get_viewed_country();
+ if (country == nullptr) {
+ return {};
+ }
+
+ Dictionary ret;
+
+ // Country / Ranking
+ static const StringName country_key = "country";
+ static const StringName country_status_key = "country_status";
+ static const StringName total_rank_key = "total_rank";
+
+ ret[country_key] = Utilities::std_to_godot_string(country->get_identifier());
+ ret[country_status_key] = static_cast<int32_t>(country->get_country_status());
+ ret[total_rank_key] = static_cast<uint64_t>(country->get_total_rank());
+
+ static const StringName prestige_key = "prestige";
+ static const StringName prestige_rank_key = "prestige_rank";
+ static const StringName prestige_tooltip_key = "prestige_tooltip";
+
+ ret[prestige_key] = country->get_prestige().to_int32_t();
+ ret[prestige_rank_key] = static_cast<uint64_t>(country->get_prestige_rank());
+ ret[prestige_tooltip_key] = String {}; // TODO - list prestige sources (e.g. power status)
+
+ static const StringName industrial_power_key = "industrial_power";
+ static const StringName industrial_rank_key = "industrial_rank";
+ static const StringName industrial_power_tooltip_key = "industrial_power_tooltip";
+
+ ret[industrial_power_key] = country->get_industrial_power().to_int32_t();
+ ret[industrial_rank_key] = static_cast<uint64_t>(country->get_industrial_rank());
+ {
+ String industrial_power_tooltip;
+
+ // Pair: State name / Power
+ std::vector<std::pair<String, fixed_point_t>> industrial_power_states;
+ for (auto const& [state, power] : country->get_industrial_power_from_states()) {
+ industrial_power_states.emplace_back(get_state_name(*state), power);
+ }
+ std::sort(
+ industrial_power_states.begin(), industrial_power_states.end(),
+ [](auto const& a, auto const& b) -> bool {
+ // Sort by greatest power, then by state name alphabetically
+ return a.second != b.second ? a.second > b.second : a.first < b.first;
+ }
+ );
+ for (auto const& [state_name, power] : industrial_power_states) {
+ industrial_power_tooltip += "\n" + state_name + ": " + GUILabel::get_colour_marker() + "Y"
+ + GUINode::float_to_string_dp(power, 3) + GUILabel::get_colour_marker() + "!";
+ }
+
+ // Tuple: Country identifier / Country name / Power
+ std::vector<std::tuple<String, String, fixed_point_t>> industrial_power_from_investments;
+ for (auto const& [country, power] : country->get_industrial_power_from_investments()) {
+ industrial_power_from_investments.emplace_back(
+ Utilities::std_to_godot_string(country->get_identifier()), get_country_name(*country), power
+ );
+ }
+ std::sort(
+ industrial_power_from_investments.begin(), industrial_power_from_investments.end(),
+ [](auto const& a, auto const& b) -> bool {
+ // Sort by greatest power, then by country name alphabetically
+ return std::get<2>(a) != std::get<2>(b) ? std::get<2>(a) > std::get<2>(b) : std::get<1>(a) < std::get<1>(b);
+ }
+ );
+ for (auto const& [country_identifier, country_name, power] : industrial_power_from_investments) {
+ industrial_power_tooltip += "\n" + GUILabel::get_flag_marker() + country_identifier + country_name + ": "
+ + GUILabel::get_colour_marker() + "Y" + GUINode::float_to_string_dp(power, 3) + GUILabel::get_colour_marker()
+ + "!";
+ }
+
+ ret[industrial_power_tooltip_key] = std::move(industrial_power_tooltip);
+ }
+
+ static const StringName military_power_key = "military_power";
+ static const StringName military_rank_key = "military_rank";
+ static const StringName military_power_tooltip_key = "military_power_tooltip";
+
+ ret[military_power_key] = country->get_military_power().to_int32_t();
+ ret[military_rank_key] = static_cast<uint64_t>(country->get_military_rank());
+ {
+ String military_power_tooltip;
+
+ for (auto const& [source, power] : {
+ std::pair
+ { "MIL_FROM_TROOPS", country->get_military_power_from_land() },
+ { "MIL_FROM_CAP_SHIPS", country->get_military_power_from_sea() },
+ { "MIL_FROM_LEADERS", country->get_military_power_from_leaders() }
+ }) {
+ if (power != 0) {
+ military_power_tooltip += "\n" + tr(source) + ": " + GUILabel::get_colour_marker() + "Y"
+ + GUINode::float_to_string_dp(power, 3) + GUILabel::get_colour_marker() + "!";
+ }
+ }
+
+ ret[military_power_tooltip_key] = std::move(military_power_tooltip);
+ }
+
+ static const StringName colonial_power_available_key = "colonial_power_available";
+ static const StringName colonial_power_max_key = "colonial_power_max";
+ static const StringName colonial_power_tooltip_key = "colonial_power_tooltip";
+ // TODO - colonial power info
+ ret[colonial_power_available_key] = 0;
+ ret[colonial_power_max_key] = 0;
+ ret[colonial_power_tooltip_key] = String {};
+
+ // Production
+
+ // Budget
+
+ // Technology
+
+ // Politics
+
+ // Population
+
+ // Trade
+
+ // Diplomacy
+
+ // Military
+ static const StringName regiment_count_key = "regiment_count";
+ static const StringName max_supported_regiments_key = "max_supported_regiments";
+
+ ret[regiment_count_key] = static_cast<uint64_t>(country->get_regiment_count());
+ ret[max_supported_regiments_key] = static_cast<uint64_t>(country->get_max_supported_regiment_count());
+
+ static const StringName mobilised_key = "mobilised";
+ static const StringName mobilisation_regiments_key = "mobilisation_regiments";
+ static const StringName mobilisation_impact_key = "mobilisation_impact";
+ static const StringName war_policy_key = "war_policy";
+ static const StringName mobilisation_max_regiments_key = "mobilisation_max_regiments";
+
+ if (country->is_mobilised()) {
+ ret[mobilised_key] = true;
+ } else {
+ ret[mobilised_key] = false;
+ ret[mobilisation_regiments_key] = static_cast<uint64_t>(country->get_mobilisation_potential_regiment_count());
+ ret[mobilisation_impact_key] = country->get_mobilisation_impact().to_float();
+ ret[war_policy_key] = String {}; // TODO - get ruling party's war policy
+ ret[mobilisation_max_regiments_key] = static_cast<uint64_t>(country->get_mobilisation_max_regiment_count());
+ }
+
+ return ret;
+}
+
/* TIME/SPEED CONTROL PANEL */
void MenuSingleton::set_paused(bool paused) {
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.hpp b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
index 022bce5..3f07583 100644
--- a/extension/src/openvic-extension/singletons/MenuSingleton.hpp
+++ b/extension/src/openvic-extension/singletons/MenuSingleton.hpp
@@ -115,6 +115,10 @@ namespace OpenVic {
MenuSingleton();
~MenuSingleton();
+ static godot::String get_tooltip_separator();
+ godot::String get_country_name_from_identifier(godot::String const& country_identifier) const;
+ godot::String get_country_adjective_from_identifier(godot::String const& country_identifier) const;
+
/* TOOLTIP */
void show_tooltip(
godot::String const& text, godot::Dictionary const& substitution_dict, godot::Vector2 const& position
@@ -134,6 +138,9 @@ namespace OpenVic {
int32_t get_administrative_pop_icon_index() const;
int32_t get_rgo_owner_pop_icon_index() const;
+ /* TOPBAR */
+ godot::Dictionary get_topbar_info() const;
+
/* TIME/SPEED CONTROL PANEL */
void set_paused(bool paused);
void toggle_paused();
diff --git a/extension/src/openvic-extension/singletons/PopulationMenu.cpp b/extension/src/openvic-extension/singletons/PopulationMenu.cpp
index 271068b..c96ef02 100644
--- a/extension/src/openvic-extension/singletons/PopulationMenu.cpp
+++ b/extension/src/openvic-extension/singletons/PopulationMenu.cpp
@@ -393,12 +393,12 @@ Error MenuSingleton::_population_menu_update_filtered_pops() {
population_menu.distributions[0][&pop->get_type()] += pop->get_size();
population_menu.distributions[1][&pop->get_religion()] += pop->get_size();
population_menu.distributions[2] +=
- pop->get_ideologies() * static_cast<fixed_point_t>(static_cast<int32_t>(pop->get_size()));
+ pop->get_ideologies() * fixed_point_t::parse(pop->get_size());
population_menu.distributions[3][&pop->get_culture()] += pop->get_size();
population_menu.distributions[4] +=
- cast_map<HasIdentifierAndColour>(pop->get_issues() * static_cast<int32_t>(pop->get_size()));
+ cast_map<HasIdentifierAndColour>(pop->get_issues() * fixed_point_t::parse(pop->get_size()));
population_menu.distributions[5] +=
- pop->get_votes() * static_cast<fixed_point_t>(static_cast<int32_t>(pop->get_size()));
+ pop->get_votes() * fixed_point_t::parse(pop->get_size());
}
for (fixed_point_map_t<HasIdentifierAndColour const*>& distribution : population_menu.distributions) {
diff --git a/game/src/Game/GameSession/MapView.gd b/game/src/Game/GameSession/MapView.gd
index 171374c..6bf84f3 100644
--- a/game/src/Game/GameSession/MapView.gd
+++ b/game/src/Game/GameSession/MapView.gd
@@ -225,7 +225,11 @@ func _unhandled_input(event : InputEvent) -> void:
elif event.is_action_pressed(_action_right_click):
if _mouse_over_viewport:
if _map_mesh.is_valid_uv_coord(_mouse_pos_map):
- Events.NationManagementScreens.open_nation_management_screen(NationManagement.Screen.DIPLOMACY)
+ # TODO - open diplomacy screen on province owner or viewed country if province has no owner
+ #Events.NationManagementScreens.open_nation_management_screen(NationManagement.Screen.DIPLOMACY)
+ GameSingleton.set_viewed_country_by_province_index(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map))
+ else:
+ print("Right-clicked outside the map!")
elif event.is_action_pressed(_action_drag):
if _drag_active:
push_warning("Drag being activated while already active!")
diff --git a/game/src/Game/GameSession/Topbar.gd b/game/src/Game/GameSession/Topbar.gd
index e3e0809..2f1fdbf 100644
--- a/game/src/Game/GameSession/Topbar.gd
+++ b/game/src/Game/GameSession/Topbar.gd
@@ -263,9 +263,19 @@ func _ready() -> void:
# Military
_military_army_size_label = get_gui_label_from_nodepath(^"./topbar/military_army_value")
+ if _military_army_size_label:
+ _military_army_size_label.set_mouse_filter(MOUSE_FILTER_PASS)
+ _military_army_size_label.set_text("§Y$CURR$/$MAX$")
+ _military_army_size_label.set_tooltip_string("TOPBAR_ARMY_TOOLTIP")
_military_navy_size_label = get_gui_label_from_nodepath(^"./topbar/military_navy_value")
+ if _military_navy_size_label:
+ _military_navy_size_label.set_mouse_filter(MOUSE_FILTER_PASS)
_military_mobilisation_size_label = get_gui_label_from_nodepath(^"./topbar/military_manpower_value")
+ if _military_mobilisation_size_label:
+ _military_mobilisation_size_label.set_mouse_filter(MOUSE_FILTER_PASS)
_military_leadership_points_label = get_gui_label_from_nodepath(^"./topbar/military_leadership_value")
+ if _military_leadership_points_label:
+ _military_leadership_points_label.set_mouse_filter(MOUSE_FILTER_PASS)
_update_info()
_update_speed_controls()
@@ -276,72 +286,115 @@ func _notification(what : int) -> void:
_update_info()
_update_speed_controls()
+enum CountryStatus {
+ GREAT_POWER,
+ SECONDARY_POWER,
+ CIVILISED,
+ PARTIALLY_CIVILISED,
+ UNCIVILISED,
+ PRIMITIVE
+}
+
func _update_info() -> void:
- # Placeholder data
- const player_country : String = "ENG"
- const player_rank : int = 0
+ var topbar_info : Dictionary = MenuSingleton.get_topbar_info()
+
+ ## Country info
+ const country_key : StringName = &"country"
+ const country_status_key : StringName = &"country_status"
+ const total_rank_key : StringName = &"total_rank"
- const RANK_NAMES : PackedStringArray = [
+ const prestige_key : StringName = &"prestige"
+ const prestige_rank_key : StringName = &"prestige_rank"
+ const prestige_tooltip_key : StringName = &"prestige_tooltip"
+
+ const industrial_power_key : StringName = &"industrial_power"
+ const industrial_rank_key : StringName = &"industrial_rank"
+ const industrial_power_tooltip_key : StringName = &"industrial_power_tooltip"
+
+ const military_power_key : StringName = &"military_power"
+ const military_rank_key : StringName = &"military_rank"
+ const military_power_tooltip_key : StringName = &"military_power_tooltip"
+
+ const colonial_power_available_key : StringName = &"colonial_power_available"
+ const colonial_power_max_key : StringName = &"colonial_power_max"
+ const colonial_power_tooltip_key : StringName = &"colonial_power_tooltip"
+
+ const COUNTRY_STATUS_NAMES : PackedStringArray = [
"DIPLOMACY_GREATNATION_STATUS",
"DIPLOMACY_COLONIALNATION_STATUS",
"DIPLOMACY_CIVILIZEDNATION_STATUS",
- "DIPLOMACY_UNCIVILIZEDNATION_STATUS"
+ "DIPLOMACY_ALMOST_WESTERN_NATION_STATUS",
+ "DIPLOMACY_UNCIVILIZEDNATION_STATUS",
+ "DIPLOMACY_PRIMITIVENATION_STATUS"
]
- ## Country info
+ var country_identifier : String = topbar_info.get(country_key, "")
+ var country_name : String = MenuSingleton.get_country_name_from_identifier(country_identifier)
+ var country_status : int = topbar_info.get(country_status_key, CountryStatus.UNCIVILISED)
+
+ var country_name_rank_tooltip : String = tr("PLAYER_COUNTRY_TOPBAR_RANK") + MenuSingleton.get_tooltip_separator() + tr("RANK_TOTAL_D")
+ var country_name_rank_dict : Dictionary = {
+ "NAME": country_name,
+ "RANK": COUNTRY_STATUS_NAMES[country_status]
+ }
+
if _country_flag_button:
- _country_flag_button.set_flag_country_name(player_country)
- _country_flag_button.set_tooltip_string_and_substitution_dict("PLAYER_COUNTRY_TOPBAR_RANK", {
- "NAME": player_country, "RANK": RANK_NAMES[player_rank]
- })
+ _country_flag_button.set_flag_country_name(country_identifier)
+ _country_flag_button.set_tooltip_string_and_substitution_dict(country_name_rank_tooltip, country_name_rank_dict)
if _country_flag_overlay_icon:
# 1 - Great Power
# 2 - Secondary Power
# 3 - Civilised
- # 4 - Uncivilised
- _country_flag_overlay_icon.set_icon_index(1 + player_rank)
+ # 4 - All Uncivilised
+ _country_flag_overlay_icon.set_icon_index(1 + min(country_status, CountryStatus.PARTIALLY_CIVILISED))
if _country_name_label:
- _country_name_label.set_text(player_country)
+ _country_name_label.set_text(country_name)
if _country_rank_label:
- _country_rank_label.set_text(str(1))
- _country_rank_label.set_tooltip_string_and_substitution_dict("PLAYER_COUNTRY_TOPBAR_RANK", {
- "NAME": player_country, "RANK": RANK_NAMES[player_rank]
- })
+ _country_rank_label.set_text(str(topbar_info.get(total_rank_key, 0)))
+ _country_rank_label.set_tooltip_string_and_substitution_dict(country_name_rank_tooltip, country_name_rank_dict)
+
+ var prestige_tooltip : String = tr("RANK_PRESTIGE") + topbar_info.get(prestige_tooltip_key, "") + MenuSingleton.get_tooltip_separator() + tr("RANK_PRESTIGE_D")
if _country_prestige_label:
- _country_prestige_label.set_text(str(11))
- _country_military_power_label.set_tooltip_string("RANK_PRESTIGE")
+ _country_prestige_label.set_text(str(topbar_info.get(prestige_key, 0)))
+ _country_prestige_label.set_tooltip_string(prestige_tooltip)
if _country_prestige_rank_label:
- _country_prestige_rank_label.set_text(str(1))
- _country_military_power_label.set_tooltip_string("RANK_PRESTIGE")
+ _country_prestige_rank_label.set_text(str(topbar_info.get(prestige_rank_key, 0)))
+ _country_prestige_rank_label.set_tooltip_string(prestige_tooltip)
+
+ var industrial_power_tooltip : String = tr("RANK_INDUSTRY") + MenuSingleton.get_tooltip_separator() + tr("RANK_INDUSTRY_D") + topbar_info.get(industrial_power_tooltip_key, "")
if _country_industrial_power_label:
- _country_industrial_power_label.set_text(str(22))
- _country_military_power_label.set_tooltip_string("RANK_INDUSTRY")
+ _country_industrial_power_label.set_text(str(topbar_info.get(industrial_power_key, 0)))
+ _country_industrial_power_label.set_tooltip_string(industrial_power_tooltip)
if _country_industrial_power_rank_label:
- _country_industrial_power_rank_label.set_text(str(2))
- _country_military_power_label.set_tooltip_string("RANK_INDUSTRY")
+ _country_industrial_power_rank_label.set_text(str(topbar_info.get(industrial_rank_key, 0)))
+ _country_industrial_power_rank_label.set_tooltip_string(industrial_power_tooltip)
+
+ var military_power_tooltip : String = tr("RANK_MILITARY") + MenuSingleton.get_tooltip_separator() + tr("RANK_MILITARY_D") + topbar_info.get(military_power_tooltip_key, "")
if _country_military_power_label:
- _country_military_power_label.set_text(str(33))
- _country_military_power_label.set_tooltip_string("RANK_MILITARY")
+ _country_military_power_label.set_text(str(topbar_info.get(military_power_key, 0)))
+ _country_military_power_label.set_tooltip_string(military_power_tooltip)
if _country_military_power_rank_label:
- _country_military_power_rank_label.set_text(str(3))
- _country_military_power_rank_label.set_tooltip_string("RANK_MILITARY")
+ _country_military_power_rank_label.set_text(str(topbar_info.get(military_rank_key, 0)))
+ _country_military_power_rank_label.set_tooltip_string(military_power_tooltip)
if _country_colonial_power_label:
- var available_colonial_power : int = 123
- var total_colonial_power : int = 456
+ var available_colonial_power : int = topbar_info.get(colonial_power_available_key, 0)
+ var max_colonial_power : int = topbar_info.get(colonial_power_max_key, 0)
_country_colonial_power_label.set_text(
- "§%s%s§!/%s" % ["W" if available_colonial_power > 0 else "R", available_colonial_power, total_colonial_power]
+ "§%s%s§!/%s" % ["W" if available_colonial_power > 0 else "R", available_colonial_power, max_colonial_power]
)
- _country_colonial_power_label.set_tooltip_string("COLONIAL_POINTS")
+ _country_colonial_power_label.set_tooltip_string(tr("COLONIAL_POINTS") + MenuSingleton.get_tooltip_separator() + (
+ topbar_info.get(colonial_power_tooltip_key, "") if country_status <= CountryStatus.SECONDARY_POWER else tr("NON_COLONIAL_POWER")
+ ))
## Time control
if _date_label:
@@ -472,17 +525,46 @@ func _update_info() -> void:
_diplomacy_alert_great_power_icon.set_icon_index(2)
## Military
+ const regiment_count_key : StringName = &"regiment_count";
+ const max_supported_regiments_key : StringName = &"max_supported_regiments";
+
+ var regiment_count : String = str(topbar_info.get(regiment_count_key, 0))
+
if _military_army_size_label:
- _military_army_size_label.set_text("§Y%d/%d" % [57, 120])
+ var army_size_dict : Dictionary = {
+ "CURR": regiment_count, "MAX": str(topbar_info.get(max_supported_regiments_key, 0))
+ }
+ _military_army_size_label.set_substitution_dict(army_size_dict)
+ _military_army_size_label.set_tooltip_substitution_dict(army_size_dict)
if _military_navy_size_label:
- _military_navy_size_label.set_text("§Y%d/%d" % [123, 267])
+ _military_navy_size_label.set_text("§Y%d/%d" % [0, 0])
+
+ const mobilised_key : StringName = &"mobilised"
+ const mobilisation_regiments_key : StringName = &"mobilisation_regiments"
+ const mobilisation_impact_key : StringName = &"mobilisation_impact"
+ const war_policy_key : StringName = &"war_policy"
+ const mobilisation_max_regiments_key : StringName = &"mobilisation_max_regiments"
if _military_mobilisation_size_label:
- _military_mobilisation_size_label.set_text("§Y%d" % 38)
+ if topbar_info.get(mobilised_key, false):
+ _military_mobilisation_size_label.set_text("§R-")
+ _military_mobilisation_size_label.set_tooltip_string("TOPBAR_MOBILIZED")
+ else:
+ var mobilisation_regiments : String = str(topbar_info.get(mobilisation_regiments_key, 0))
+ var mobilisation_impact : String = GUINode.float_to_string_dp(topbar_info.get(mobilisation_impact_key, 0), 1) + "%"
+
+ _military_mobilisation_size_label.set_text("§Y" + mobilisation_regiments)
+ _military_mobilisation_size_label.set_tooltip_string_and_substitution_dict(
+ tr("TOPBAR_MOBILIZE_TOOLTIP") + "\n\n" + tr("MOBILIZATION_IMPACT_LIMIT_DESC") + "\n" + tr("MOBILIZATION_IMPACT_LIMIT_DESC2").replace("$CURR$", "$CURR2$"),
+ {
+ "CURR": mobilisation_regiments, "IMPACT": mobilisation_impact, "POLICY": topbar_info.get(war_policy_key, ""),
+ "UNITS": str(topbar_info.get(mobilisation_max_regiments_key, 0)), "CURR2": regiment_count
+ }
+ )
if _military_leadership_points_label:
- _military_leadership_points_label.set_text("§Y%d" % 15)
+ _military_leadership_points_label.set_text("§Y%d" % 0)
func _update_speed_controls() -> void:
var paused : bool = MenuSingleton.is_paused()