Skip to content

Commit

Permalink
GUI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
SneakBug8 committed Jan 24, 2025
1 parent b9bfd84 commit 77be966
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/gui/gui_unit_grid_box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 36 additions & 0 deletions src/gui/gui_unit_panel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,42 @@ class unit_type_listbox_entry_label : public button_element_base {
auto new_type = retrieve<dcon::unit_type_id>(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));

Expand Down
2 changes: 1 addition & 1 deletion src/gui/topbar_subwindows/gui_diplomacy_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 77be966

Please sign in to comment.