Skip to content

Commit

Permalink
Add tooltip for RGO_employment
Browse files Browse the repository at this point in the history
  • Loading branch information
fxrmi committed Nov 28, 2024
1 parent ad5067e commit ba61ec6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
25 changes: 25 additions & 0 deletions extension/src/openvic-extension/singletons/MenuSingleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
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_employment_tooltip_key = "rgo_employment_tooltip";
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";
Expand Down Expand Up @@ -489,6 +490,30 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
ret[province_info_rgo_employment_percentage_key] = (rgo.get_total_employees_count_cache() * fixed_point_t::_100() / max_employee_count).to_float_rounded();
}

String amount_of_employees_by_pop_type;
auto const& employee_count_per_type_cache = rgo.get_employee_count_per_type_cache();
for (PopType const& pop_type : *employee_count_per_type_cache.get_keys()) {
const pop_size_t employees_of_type = employee_count_per_type_cache[pop_type];
if (employees_of_type > 0) {
amount_of_employees_by_pop_type += static_cast<String>(static_cast<Variant>(pop_type.get_identifier().data())) + ": " +
static_cast<String>(static_cast<Variant>(std::to_string(employees_of_type).c_str())) + "\n";
}
}
String base_work_force;
if (rgo.get_production_type_nullable() == nullptr) {
base_work_force = "ERROR PRODUCTION_TYPE IS NULL";
} else {
base_work_force = static_cast<String>(static_cast<Variant>(rgo.get_production_type_nullable()->get_base_workforce_size()));
}
ret[province_info_rgo_employment_tooltip_key] =
tr("Current employees in RGO")
+"\n" +
"--------------\n" +
tr("Current employees") + ": " + static_cast<String>(ret[province_info_rgo_total_employees_key]) + "/" +static_cast<String>(static_cast<Variant>(rgo.get_max_employee_count_cache())) + "\n" +
amount_of_employees_by_pop_type +
tr("Base Workforce") + ": " + base_work_force +
"\n" + "From technology" + ":" + "\n" + "Province Size: x " + static_cast<String>(static_cast<Variant>(rgo.get_size_multiplier().to_float()));

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());
Expand Down
22 changes: 15 additions & 7 deletions game/src/Game/GameSession/ProvinceOverviewPanel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ 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_total_employees_key : StringName = &"rgo_total_employees" #this one
const _province_info_rgo_employment_percentage_key : StringName = &"rgo_employment_percentage" #this one
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"
Expand All @@ -252,6 +252,7 @@ func _update_info() -> void:
const _province_info_pop_cultures_key : StringName = &"pop_cultures"
const _province_info_cores_key : StringName = &"cores"
const _province_info_buildings_key : StringName = &"buildings"
const _province_info_rgo_employment_tooltip_key : StringName = &"rgo_employment_tooltip"

const _missing_suffix : String = "_MISSING"

Expand Down Expand Up @@ -307,23 +308,30 @@ func _update_info() -> void:
# Statistics
if _rgo_icon:
_rgo_icon.set_icon_index(_province_info.get(_province_info_rgo_icon_key, -1) + 2)
print(_province_info.get(_province_info_rgo_name_key))

if _rgo_produced_label:
_rgo_produced_label.text = GUINode.float_to_string_dp(_province_info.get(_province_info_rgo_output_quantity_yesterday_key, 0), 3)

print()

if _rgo_income_label:
_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:
if _rgo_employment_percentage_icon:
_rgo_employment_percentage_icon.set_icon_index(int(_province_info.get(_province_info_rgo_employment_percentage_key, 0) / 10) + 1)

_rgo_employment_percentage_icon.set_tooltip_string("TEST")

if _rgo_employment_population_label:
_rgo_employment_population_label.text = GUINode.int_to_string_suffixed(_province_info.get(_province_info_rgo_total_employees_key, 0))

_rgo_employment_population_label.set_tooltip_string(_province_info.get(_province_info_rgo_employment_tooltip_key))

if _rgo_employment_percentage_label:
_rgo_employment_percentage_label.text = "%d%%" % _province_info.get(_province_info_rgo_employment_percentage_key, 0)
print( _province_info)
_rgo_employment_percentage_label.set_tooltip_string("TEST")
print(_province_info.get(_province_info_rgo_total_employees_key))

if _crime_name_label:
if _crime_name_label:
_crime_name_label.text = _province_info.get(_province_info_crime_name_key, "")

if _crime_icon:
Expand Down

0 comments on commit ba61ec6

Please sign in to comment.