From 77be9662213a13b4545a990f8fda969160da4de5 Mon Sep 17 00:00:00 2001 From: Paul Nakonechnyy Date: Fri, 24 Jan 2025 10:48:21 +0200 Subject: [PATCH] GUI improvements --- src/gui/gui_unit_grid_box.hpp | 5 ++- src/gui/gui_unit_panel.hpp | 36 +++++++++++++++++++ .../gui_diplomacy_window.hpp | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/gui/gui_unit_grid_box.hpp b/src/gui/gui_unit_grid_box.hpp index 628a5ec2b..14d8892d1 100644 --- a/src/gui/gui_unit_grid_box.hpp +++ b/src/gui/gui_unit_grid_box.hpp @@ -433,13 +433,16 @@ inline outline_color to_color(sys::state& state, unit_var display_unit) { return outline_color::gray; } + auto subjects = nations::nation_get_subjects(state, state.local_player_nation); + auto is_subject = std::find(subjects.begin(), subjects.end(), controller) != subjects.end(); + if(selected && controller == state.local_player_nation) { return outline_color::gold; } else if(controller == state.local_player_nation) { return outline_color::blue; } else if(!controller || military::are_at_war(state, controller, state.local_player_nation)) { return outline_color::red; - } else if(military::are_allied_in_war(state, controller, state.local_player_nation)) { + } else if(military::are_allied_in_war(state, controller, state.local_player_nation) || is_subject) { return outline_color::cyan; } else { return outline_color::gray; diff --git a/src/gui/gui_unit_panel.hpp b/src/gui/gui_unit_panel.hpp index 4a7e3aaed..7f006fbf3 100644 --- a/src/gui/gui_unit_panel.hpp +++ b/src/gui/gui_unit_panel.hpp @@ -1848,6 +1848,42 @@ class unit_type_listbox_entry_label : public button_element_base { auto new_type = retrieve(state, parent); auto const& ut = state.military_definitions.unit_base_definitions[new_type]; + if(ut.is_land) { + if(state.world.nation_get_unit_stats(state.local_player_nation, new_type).reconnaissance_or_fire_range > 0) { + text::add_line(state, contents, "unit_recon", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).reconnaissance_or_fire_range, 2)); + } + if(state.world.nation_get_unit_stats(state.local_player_nation, new_type).siege_or_torpedo_attack > 0) { + text::add_line(state, contents, "unit_siege", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).siege_or_torpedo_attack, 2)); + } + + text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).attack_or_gun_power, 2)); + text::add_line(state, contents, "unit_defence", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).defence_or_hull, 2)); + text::add_line(state, contents, "unit_discipline", text::variable_type::x, text::format_percentage(ut.discipline_or_evasion, 0)); + if(ut.support > 0) { + text::add_line(state, contents, "unit_support", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).support, 0)); + } + text::add_line(state, contents, "unit_maneuver", text::variable_type::x, text::format_float(ut.maneuver, 0)); + text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).maximum_speed, 2)); + text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).supply_consumption * 100, 0)); + text::add_line(state, contents, "unit_supply_load", text::variable_type::x, ut.supply_consumption_score); + } + else { + text::add_line(state, contents, "unit_max_speed", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).maximum_speed, 2)); + text::add_line(state, contents, "unit_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).attack_or_gun_power, 2)); + if(state.world.nation_get_unit_stats(state.local_player_nation, new_type).siege_or_torpedo_attack > 0) { + text::add_line(state, contents, "unit_torpedo_attack", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).siege_or_torpedo_attack, 2)); + } + text::add_line(state, contents, "unit_hull", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).defence_or_hull, 2)); + text::add_line(state, contents, "unit_fire_range", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).reconnaissance_or_fire_range, 2)); + if(ut.discipline_or_evasion > 0) { + text::add_line(state, contents, "unit_evasion", text::variable_type::x, text::format_percentage(ut.discipline_or_evasion, 0)); + } + text::add_line(state, contents, "unit_supply_consumption", text::variable_type::x, text::format_float(state.world.nation_get_unit_stats(state.local_player_nation, new_type).supply_consumption * 100, 0)); + text::add_line(state, contents, "unit_supply_load", text::variable_type::x, ut.supply_consumption_score); + } + + text::add_line_break_to_layout(state, contents); + text::add_line_with_condition(state, contents, "unit_upgrade_explain_1", !state.selected_regiments[0] || !state.selected_ships[0]); text::add_line_with_condition(state, contents, "unit_upgrade_explain_2", ut.active || state.world.nation_get_active_unit(state.local_player_nation, new_type)); diff --git a/src/gui/topbar_subwindows/gui_diplomacy_window.hpp b/src/gui/topbar_subwindows/gui_diplomacy_window.hpp index 52dcf7c42..765adea61 100644 --- a/src/gui/topbar_subwindows/gui_diplomacy_window.hpp +++ b/src/gui/topbar_subwindows/gui_diplomacy_window.hpp @@ -442,7 +442,7 @@ class diplomacy_industry_size : public standard_nation_text { text::add_line(state, contents, "factory_consumer_count", text::variable_type::val, consumer); text::add_line(state, contents, "factory_heavy_count", text::variable_type::val, heavy); text::add_line(state, contents, "factory_military_count", text::variable_type::val, mils); - text::add_line(state, contents, "factory_processing_count", text::variable_type::val, mils); + text::add_line(state, contents, "factory_processing_count", text::variable_type::val, processing); if(indandconsumer > 0) { text::add_line(state, contents, "factory_industrial_and_consumer_count", text::variable_type::val, mils); }