Project Alice
Loading...
Searching...
No Matches
gui_province_window.cpp
Go to the documentation of this file.
2
3namespace ui {
4
5void province_owner_rgo_draw_tooltip(sys::state& state, text::columnar_layout& contents, dcon::province_id prov_id) noexcept {
6 auto rgo_good = state.world.province_get_rgo(prov_id);
7 auto nat_id = state.world.province_get_nation_from_province_ownership(prov_id);
8
9 state.world.for_each_commodity([&](dcon::commodity_id c) {
10 auto production = province::rgo_production_quantity(state, prov_id, c);
11 auto profit = state.world.province_get_rgo_profit_per_good(prov_id, c);
12
13 if(production < 0.0001f) {
14 return;
15 }
16
17 auto base_box = text::open_layout_box(contents);
18 auto name_box = base_box;
19 name_box.x_size = 75;
20 auto production_box = base_box;
21 production_box.x_position += 90.f;
22
23 auto profit_box = base_box;
24 profit_box.x_position += 180.f;
25
27 text::add_to_layout_box(state, contents, production_box, text::fp_two_places{ production });
29 text::add_to_layout_box(state, contents, base_box, std::string(" "));
30 text::close_layout_box(contents, base_box);
31 });
32
33 if(rgo_good) {
34
35 text::add_line(state, contents, "provinceview_goodsincome", text::variable_type::goods, rgo_good.get_name(), text::variable_type::value,
36 text::fp_three_places{ province::rgo_income(state, prov_id) });
37
38 {
39 auto box = text::open_layout_box(contents, 0);
41 auto const production = province::rgo_production_quantity(state, prov_id, rgo_good);
42
44 text::localised_format_box(state, contents, box, std::string_view("production_output_goods_tooltip2"), sub_map);
45 text::localised_format_box(state, contents, box, std::string_view("production_output_explanation"));
46 text::close_layout_box(contents, box);
47 }
48
50
51 {
52 auto const production = province::rgo_production_quantity(state, prov_id, rgo_good);
53 auto const base_size = economy::rgo_effective_size(state, nat_id, prov_id, rgo_good) * state.world.commodity_get_rgo_amount(rgo_good);
54 text::add_line(state, contents, std::string_view("production_base_output_goods_tooltip"), text::variable_type::base, text::fp_two_places{ base_size });
55 }
56
57 {
58 auto box = text::open_layout_box(contents, 0);
59 bool const is_mine = state.world.commodity_get_is_mine(rgo_good);
60 auto const efficiency = 1.0f +
61 state.world.province_get_modifier_values(prov_id,
62 is_mine ? sys::provincial_mod_offsets::mine_rgo_eff : sys::provincial_mod_offsets::farm_rgo_eff) +
63 state.world.nation_get_modifier_values(nat_id,
64 is_mine ? sys::national_mod_offsets::mine_rgo_eff : sys::national_mod_offsets::farm_rgo_eff);
65 text::localised_format_box(state, contents, box, std::string_view("production_output_efficiency_tooltip"));
66 text::add_to_layout_box(state, contents, box, text::fp_percentage{ efficiency }, efficiency >= 0.0f ? text::text_color::green : text::text_color::red);
67 text::close_layout_box(contents, box);
68 }
69
71
72 {
73 auto box = text::open_layout_box(contents, 0);
74 auto const throughput = state.world.province_get_rgo_employment(prov_id);
75 text::localised_format_box(state, contents, box, std::string_view("production_throughput_efficiency_tooltip"));
76 text::add_to_layout_box(state, contents, box, text::fp_percentage{ throughput }, throughput >= 0.0f ? text::text_color::green : text::text_color::red);
77
78 text::close_layout_box(contents, box);
79 }
80 }
81}
82
84 auto province_window = static_cast<province_view_window*>(state.ui_state.province_window);
85 province_window->nf_win->set_visible(state, !province_window->nf_win->is_visible());
86}
87
88}
void set_visible(sys::state &state, bool vis)
void button_action(sys::state &state) noexcept override
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
float rgo_effective_size(sys::state const &state, dcon::nation_id n, dcon::province_id p, dcon::commodity_id c)
Definition: economy.cpp:909
float rgo_production_quantity(sys::state &state, dcon::province_id id, dcon::commodity_id c)
Definition: province.cpp:473
void add_to_layout_box(sys::state &state, layout_base &dest, layout_box &box, embedded_flag ico)
Definition: text.cpp:1165
std::string format_money(float num)
Definition: text.cpp:1029
std::string get_name_as_string(sys::state &state, T t)
Definition: text.hpp:954
layout_box open_layout_box(layout_base &dest, int32_t indent)
Definition: text.cpp:1799
void localised_format_box(sys::state &state, layout_base &dest, layout_box &box, std::string_view key, text::substitution_map const &sub)
Definition: text.cpp:1880
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
Definition: text.cpp:1899
void add_line_break_to_layout(sys::state &state, columnar_layout &dest)
Definition: text.cpp:1152
void add_to_substitution_map(substitution_map &mp, variable_type key, substitution value)
Definition: text.cpp:1068
ankerl::unordered_dense::map< uint32_t, substitution > substitution_map
Definition: text.hpp:794
void close_layout_box(columnar_layout &dest, layout_box &box)
Definition: text.cpp:1807
void province_owner_rgo_draw_tooltip(sys::state &state, text::columnar_layout &contents, dcon::province_id prov_id) noexcept
element_base * province_window