From b8137ee482961259ef23673119822cb2102dbb74 Mon Sep 17 00:00:00 2001 From: wvpm <24685035+wvpm@users.noreply.github.com> Date: Thu, 31 Oct 2024 00:01:47 +0100 Subject: Use actual output and revenue in UI --- .../src/openvic-extension/singletons/MenuSingleton.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'extension/src/openvic-extension/singletons/MenuSingleton.cpp') 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()); -- cgit v1.2.3-56-ga3b1