24 #include "eng3d/string.hpp"
25 #include "eng3d/ui/table.hpp"
26 #include "eng3d/ui/label.hpp"
27 #include "eng3d/ui/image.hpp"
36 const auto& needs_amounts = world->pop_types[pop.
type_id].basic_needs_amount;
37 auto total_factor = std::reduce(needs_amounts.begin(), needs_amounts.end());
38 for (
const auto& commodity : world->commodities) {
39 if (needs_amounts[commodity] == 0)
continue;
40 const auto need_factor = needs_amounts[commodity] / total_factor;
47 :
UI::Window(-400, -400, 0, 800),
61 for(
const auto province_id : nation.owned_provinces)
62 size += gs.
world->provinces[province_id].pops.size();
64 std::vector<int> sizes{ 75, 200, 100, 80, 80, 80, 50};
65 std::vector<std::string> header{
"Size",
"Province",
"Type",
"Militancy",
"Literacy",
"Budget",
"QOL" };
66 auto& table = this->make_widget<UI::Table<uint64_t>>(5, 5, 800 - 5, 35, sizes, header);
69 table.set_on_each_tick([
this, &nation, &table](
UI::Widget&) {
70 for(
const auto province_id : nation.owned_provinces) {
71 const auto& province = this->gs.
world->provinces[province_id];
72 for(
const auto& pop : province.pops) {
73 const auto id =
static_cast<size_t>(pop.type_id) + (
static_cast<uint64_t
>(province) << 32);
74 auto& row = table.get_row(
id);
77 auto size_label = row.get_element(row_index++);
79 size_label->set_key(pop.size);
81 auto prov_name = row.get_element(row_index++);
82 prov_name->set_text(province.name);
83 prov_name->set_key(province.name);
85 auto type_lable = row.get_element(row_index++);
86 type_lable->set_text(this->gs.
world->pop_types[pop.type_id].name);
87 type_lable->set_key(this->gs.
world->pop_types[pop.type_id].name);
89 auto militancy = row.get_element(row_index++);
91 militancy->set_key(pop.militancy);
93 auto literacy = row.get_element(row_index++);
94 literacy->set_text(
string_format(
"%2.0f%%", pop.literacy * 100));
95 literacy->set_key(pop.literacy);
97 auto budget = row.get_element(row_index++);
98 budget->set_text(
string_format(
"%.2f", pop.budget / pop.size));
99 budget->set_key(pop.budget / pop.size);
102 auto quality_of_life = row.get_element(row_index++);
103 quality_of_life->set_text(
string_format(
"%.2f", pop.life_needs_met));
104 quality_of_life->set_key(pop.life_needs_met);
105 quality_of_life->set_tooltip([pop,
this]{
111 table.on_each_tick(table);
void set_close_btn_function(std::function< void(Widget &)> on_click)
std::string string_format(const std::string_view format, Args &&... args)
String formatter.
std::string translate_format(const std::string_view format, Args &&... args)
String formatter, with translation.
std::string pop_qol_tooltip_text(const Pop &pop, const World *world)