Skip to content

Commit

Permalink
Add province rgo income tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
fxrmi committed Dec 17, 2024
1 parent d663d8e commit 31c0679
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
46 changes: 45 additions & 1 deletion extension/src/openvic-extension/singletons/MenuSingleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
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_income_tooltip_key = "rgo_income_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 @@ -491,12 +492,18 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {

if (rgo.is_valid()) {
String amount_of_employees_by_pop_type;
String base_output_workers;
String throughput_workers;
for (auto const& [pop_type, employees_of_type] : rgo.get_employee_count_per_type_cache()) {
if (employees_of_type > 0) {
amount_of_employees_by_pop_type +=
" -" + GUILabel::get_colour_marker() + "Y" +
tr(Utilities::std_to_godot_string(pop_type.get_identifier())) + GUILabel::get_colour_marker() + "!:" +
String::num_int64(employees_of_type) + "\n";
throughput_workers = tr(Utilities::std_to_godot_string(pop_type.get_identifier()));
if (pop_type.get_identifier() == "Slaves") {
throughput_workers = Utilities::std_to_godot_string("TEST");
}
}
}

Expand All @@ -514,7 +521,7 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
static const StringName province_size_localisation_key = "FROM_PROV_SIZE";

ret[province_info_rgo_employment_tooltip_key] =
tr(employment_localisation_key).replace(value_replace_key, {}) + get_tooltip_separator() +
tr(employment_localisation_key) + get_tooltip_separator() +
tr(employee_count_localisation_key).replace(
employee_replace_key, String::num_int64(rgo.get_total_employees_count_cache())
).replace(
Expand All @@ -523,6 +530,43 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
String::num_int64(production_type.get_base_workforce_size()) + "\n" +
contributing_modifier_effects + "\n" + tr(province_size_localisation_key) + GUILabel::get_colour_marker() + "G" +
String::num_int64(static_cast<int32_t>(rgo.get_size_multiplier())); // TODO - remove cast once variable is an int32_t

static const StringName good_income_localisation_key = "PROVINCEVIEW_GOODSINCOME";
static const StringName good_replace_key = "$GOODS$";
static const StringName max_production_localisation_key = "PRODUCTION_OUTPUT_GOODS_TOOLTIP2";
static const StringName curr_replace_key = "$CURR$";
static const StringName production_output_explanation_localisation_key = "PRODUCTION_OUTPUT_EXPLANATION";
static const StringName production_output_key = "PRODUCTION_BASE_OUTPUT";
static const StringName production_base_output_key = "PRODUCTION_BASE_OUTPUT_GOODS_TOOLTIP";
static const StringName base_replace_key = "$BASE$";
static const StringName production_output_efficiency_key = "PRODUCTION_OUTPUT_EFFICIENCY_TOOLTIP";
static const StringName production_owner_key = "PRODUCTION_FACTOR_OWNER";
static const StringName rgo_output_tech_key = "RGO_OUTPUT_TECH";
static const StringName production_throughput_tooltip_key = "PRODUCTION_THROUGHPUT_EFFICIENCY_TOOLTIP";
static const StringName rgo_worker_key = "PRODUCTION_FACTOR_WORKER";
static const StringName rgo_input_tech_key = "RGO_INPUT_TECH";
static const StringName rgo_owner_pop_name = "Aristocrats";


ret[province_info_rgo_income_tooltip_key] =
tr(good_income_localisation_key).replace(
good_replace_key, Utilities::std_to_godot_string(province->get_rgo_good()->get_identifier())
).replace(
value_replace_key, Utilities::std_to_godot_string(rgo.get_revenue_yesterday().to_string(3))
) + "\n" +
tr(max_production_localisation_key).replace(
curr_replace_key, Utilities::std_to_godot_string(rgo.get_output_quantity_yesterday().to_string(3))) +
tr(production_output_explanation_localisation_key) + get_tooltip_separator() +
tr(production_base_output_key).replace(base_replace_key, "TEMP VALUE") + tr(production_output_efficiency_key) +
GUILabel::get_colour_marker() + "G" + "TEST" + GUILabel::get_colour_marker() + "!" +
"\n" + tr(production_output_key) + GUILabel::get_colour_marker() + "G" + "TEST" + GUILabel::get_colour_marker() + "!" +
"\n" + " -" + tr(production_owner_key) + ": " + GUILabel::get_colour_marker() + "Y" + tr(rgo_owner_pop_name) +
GUILabel::get_colour_marker() + "!:" + GUILabel::get_colour_marker() + "G" + "TEST" + GUILabel::get_colour_marker() + "!" +
"\n" + " -" + tr(rgo_output_tech_key) + ":" + GUILabel::get_colour_marker() + "G" + "TEST" + GUILabel::get_colour_marker() + "!"+ "\n" +
tr(production_throughput_tooltip_key) + GUILabel::get_colour_marker() + "G" + "TEST" + GUILabel::get_colour_marker() + "!" +"\n"
+ " -" + tr(rgo_worker_key) + ":" + GUILabel::get_colour_marker() + "G" + "TEST" + GUILabel::get_colour_marker() + "!" +
"\n" + " -" + tr(rgo_input_tech_key) + ":" + GUILabel::get_colour_marker() + "G" + GUILabel::get_colour_marker() +
throughput_workers;
}

GoodDefinition const* const rgo_good = province->get_rgo_good();
Expand Down
8 changes: 6 additions & 2 deletions game/src/Game/GameSession/ProvinceOverviewPanel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func _update_info() -> void:
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_employment_tooltip_key : StringName = &"rgo_employment_tooltip"
const _province_info_rgo_income_tooltip_key : StringName = &"rgo_income_tooltip"
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 Down Expand Up @@ -306,15 +307,18 @@ func _update_info() -> void:
_controller_flag.set_flag_country_name(_province_info.get(_province_info_controller_key, ""))

# Statistics
var rgo_income_tooltip : String = _province_info.get(_province_info_rgo_income_tooltip_key, "")
if _rgo_icon:
_rgo_icon.set_icon_index(_province_info.get(_province_info_rgo_icon_key, -1) + 2)

_rgo_icon.set_tooltip_string(rgo_income_tooltip)

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)
_rgo_produced_label.set_tooltip_string(rgo_income_tooltip)

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)

_rgo_income_label.set_tooltip_string(rgo_income_tooltip)
var rgo_employment_tooltip : String = _province_info.get(_province_info_rgo_employment_tooltip_key, "")

if _rgo_employment_percentage_icon:
Expand Down

0 comments on commit 31c0679

Please sign in to comment.