diff options
author | wvpm <24685035+wvpm@users.noreply.github.com> | 2024-11-01 21:25:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-01 21:25:40 +0100 |
commit | 7f7510cd3c3541b596d97eff8ade42e819d82c85 (patch) | |
tree | b42c822ccc42c1980a23251649b7e2e7760ae085 | |
parent | a866c4bad4119a420dbf6ebb117f3efc001503ef (diff) | |
parent | b8137ee482961259ef23673119822cb2102dbb74 (diff) |
Use real RGO data
-rw-r--r-- | extension/src/openvic-extension/singletons/MenuSingleton.cpp | 15 | ||||
-rw-r--r-- | game/src/Game/GameSession/ProvinceOverviewPanel.gd | 17 |
2 files changed, 24 insertions, 8 deletions
diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.cpp b/extension/src/openvic-extension/singletons/MenuSingleton.cpp index cabe82b..81582c2 100644 --- a/extension/src/openvic-extension/singletons/MenuSingleton.cpp +++ b/extension/src/openvic-extension/singletons/MenuSingleton.cpp @@ -436,6 +436,10 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const { static const StringName province_info_controller_key = "controller"; static const StringName province_info_rgo_name_key = "rgo_name"; static const StringName province_info_rgo_icon_key = "rgo_icon"; + static const StringName province_info_rgo_total_employees_key = "rgo_total_employees"; + static const StringName province_info_rgo_employment_percentage_key = "rgo_employment_percentage"; + static const StringName province_info_rgo_output_quantity_yesterday_key = "rgo_output_quantity_yesterday"; + static const StringName province_info_rgo_revenue_yesterday_key = "rgo_revenue_yesterday"; static const StringName province_info_crime_name_key = "crime_name"; static const StringName province_info_crime_icon_key = "crime_icon"; static const StringName province_info_total_population_key = "total_population"; @@ -474,6 +478,17 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const { ret[province_info_controller_key] = Utilities::std_to_godot_string(controller->get_identifier()); } + ResourceGatheringOperation const& rgo = province->get_rgo(); + ret[province_info_rgo_output_quantity_yesterday_key] = rgo.get_output_quantity_yesterday().to_float(); + ret[province_info_rgo_revenue_yesterday_key] = rgo.get_revenue_yesterday().to_float(); + ret[province_info_rgo_total_employees_key] = rgo.get_total_employees_count_cache(); + const Pop::pop_size_t max_employee_count = rgo.get_max_employee_count_cache(); + if (max_employee_count == 0) { + ret[province_info_rgo_employment_percentage_key] = 100.0f; + } else { + ret[province_info_rgo_employment_percentage_key] = (rgo.get_total_employees_count_cache() * fixed_point_t::_100() / max_employee_count).to_float_rounded(); + } + GoodDefinition const* const rgo_good = province->get_rgo_good(); if (rgo_good != nullptr) { ret[province_info_rgo_name_key] = Utilities::std_to_godot_string(rgo_good->get_identifier()); diff --git a/game/src/Game/GameSession/ProvinceOverviewPanel.gd b/game/src/Game/GameSession/ProvinceOverviewPanel.gd index 66fd463..a9f0ae2 100644 --- a/game/src/Game/GameSession/ProvinceOverviewPanel.gd +++ b/game/src/Game/GameSession/ProvinceOverviewPanel.gd @@ -240,6 +240,10 @@ func _update_info() -> void: const _province_info_controller_key : StringName = &"controller" const _province_info_rgo_name_key : StringName = &"rgo_name" const _province_info_rgo_icon_key : StringName = &"rgo_icon" + const _province_info_rgo_total_employees_key : StringName = &"rgo_total_employees" + const _province_info_rgo_employment_percentage_key : StringName = &"rgo_employment_percentage" + const _province_info_rgo_output_quantity_yesterday_key : StringName = &"rgo_output_quantity_yesterday" + const _province_info_rgo_revenue_yesterday_key : StringName = &"rgo_revenue_yesterday" const _province_info_crime_name_key : StringName = &"crime_name" const _province_info_crime_icon_key : StringName = &"crime_icon" const _province_info_total_population_key : StringName = &"total_population" @@ -305,22 +309,19 @@ func _update_info() -> void: _rgo_icon.set_icon_index(_province_info.get(_province_info_rgo_icon_key, -1) + 2) if _rgo_produced_label: - # TODO - replace name with amount produced - _rgo_produced_label.text = _province_info.get(_province_info_rgo_name_key, _province_info_rgo_name_key + _missing_suffix) + _rgo_produced_label.text = GUINode.float_to_string_dp(_province_info.get(_province_info_rgo_output_quantity_yesterday_key, 0), 3) if _rgo_income_label: - # TODO - add £ sign and replace placeholder with actual value - _rgo_income_label.text = "%s¤" % GUINode.float_to_string_dp(12.34567, 3) + _rgo_income_label.text = "%s¤" % GUINode.float_to_string_dp(_province_info.get(_province_info_rgo_revenue_yesterday_key, 0), 3) if _rgo_employment_percentage_icon: - pass + _rgo_employment_percentage_icon.set_icon_index(int(_province_info.get(_province_info_rgo_employment_percentage_key, 0) / 10) + 1) if _rgo_employment_population_label: - # TODO - replace placeholder with actual value - _rgo_employment_population_label.text = GUINode.int_to_string_suffixed(_province_info.get(_province_info_total_population_key, 0) / 10) + _rgo_employment_population_label.text = GUINode.int_to_string_suffixed(_province_info.get(_province_info_rgo_total_employees_key, 0)) if _rgo_employment_percentage_label: - pass + _rgo_employment_percentage_label.text = "%d%%" % _province_info.get(_province_info_rgo_employment_percentage_key, 0) if _crime_name_label: _crime_name_label.text = _province_info.get(_province_info_crime_name_key, "") |