Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltip for RGO_employment #311

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions extension/src/openvic-extension/classes/GUILabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ std::vector<GUILabel::line_t> GUILabel::generate_lines_and_segments(
unwrapped_lines.emplace_back();

for (int64_t idx = 0; idx < display_text.length(); ++idx) {
if (colour_it != colour_instructions.end() && idx == colour_it->first) {
Color new_colour = current_colour;
Color new_colour = current_colour;
while (colour_it != colour_instructions.end() && idx == colour_it->first) {
if (colour_it->second == RESET_COLOUR_CODE) {
new_colour = default_colour;
} else {
Expand All @@ -598,16 +598,16 @@ std::vector<GUILabel::line_t> GUILabel::generate_lines_and_segments(
}
}
++colour_it;
}

if (current_colour != new_colour) {
if (section_start < idx) {
separate_lines(
display_text.substr(section_start, idx - section_start), current_colour, unwrapped_lines
);
section_start = idx;
}
current_colour = new_colour;
if (current_colour != new_colour) {
if (section_start < idx) {
separate_lines(
display_text.substr(section_start, idx - section_start), current_colour, unwrapped_lines
);
section_start = idx;
}
current_colour = new_colour;
}
}

Expand Down
40 changes: 39 additions & 1 deletion 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 @@ -486,7 +487,44 @@ Dictionary MenuSingleton::get_province_info_from_index(int32_t index) const {
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();
ret[province_info_rgo_employment_percentage_key] =
(rgo.get_total_employees_count_cache() * fixed_point_t::_100() / max_employee_count).to_float_rounded();
}

if (rgo.is_valid()) {
String amount_of_employees_by_pop_type;
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";
}
}

ProductionType const& production_type = *rgo.get_production_type_nullable();

String contributing_modifier_effects;
// TODO - generate list of contributing modifier effects (including combined "From Technology" effeects)

static const StringName employment_localisation_key = "PROVINCEVIEW_EMPLOYMENT";
static const String value_replace_key = "$VALUE$";
static const StringName employee_count_localisation_key = "PRODUCTION_FACTORY_EMPLOYEECOUNT_TOOLTIP2";
static const String employee_replace_key = "$EMPLOYEES$";
static const String employee_max_replace_key = "$EMPLOYEE_MAX$";
static const StringName rgo_workforce_localisation_key = "BASE_RGO_SIZE";
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(employee_count_localisation_key).replace(
employee_replace_key, String::num_int64(rgo.get_total_employees_count_cache())
).replace(
employee_max_replace_key, String::num_int64(rgo.get_max_employee_count_cache())
) + "\n" + amount_of_employees_by_pop_type + tr(rgo_workforce_localisation_key) +
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
}

GoodDefinition const* const rgo_good = province->get_rgo_good();
Expand Down
6 changes: 6 additions & 0 deletions game/src/Game/GameSession/ProvinceOverviewPanel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func _update_info() -> void:
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_employment_tooltip_key : StringName = &"rgo_employment_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 @@ -314,14 +315,19 @@ func _update_info() -> void:
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)

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

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(rgo_employment_tooltip)

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(rgo_employment_tooltip)

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

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