25 #include "eng3d/serializer.hpp"
26 #include "eng3d/ui/components.hpp"
27 #include "eng3d/ui/table.hpp"
28 #include "eng3d/texture.hpp"
36 :
UI::Window(0, 0, 512, 400, nullptr),
45 this->
set_text(
"Laws and goverment");
53 auto& ideology_lab = this->make_widget<UI::Label>(0, 0,
"");
54 ideology_lab.set_on_each_tick([
this](
UI::Widget& w) {
59 "Distributism %.2f\nMercantilist %.2f\nCapitalism %.2f\nIndividualism %.2f\nState power %.2f\nEqualitarianism %.2f\nSecular %.2f\nPluralism %.2f\n", subideology.economic.distributism, subideology.economic.mercantilist, subideology.economic.capitalism, subideology.political.individualism, subideology.political.state_power, subideology.political.equalitarianism, subideology.political.secular, subideology.political.pluralism));
61 ideology_lab.on_each_tick(ideology_lab);
63 auto& ideology_img = this->make_widget<UI::Image>(6, 38, 32, 32);
64 ideology_img.set_on_each_tick([
this](
UI::Widget& w) {
68 ideology_img.on_each_tick(ideology_img);
70 auto& ideology_pie_lab = this->make_widget<UI::Label>(0, 82,
"House");
71 auto& ideology_pie = this->make_widget<UI::PieChart>(0, 0, 128, 128);
72 ideology_pie.below_of(ideology_pie_lab);
73 ideology_pie.set_on_each_tick([
this](
UI::Widget& w) {
74 if(this->gs.
world->
time % this->gs.world->ticks_per_month)
return;
76 std::vector<UI::ChartData> ideology_data;
77 for(
const auto& ideology : this->gs.world->ideologies)
78 ideology_data.emplace_back(1.f, ideology.name, ideology.color);
88 ideology_pie.on_each_tick(ideology_pie);
90 auto& militancy_lab = this->make_widget<UI::Label>(0, 290,
" ");
91 militancy_lab.set_on_each_tick([
this](
UI::Widget& w) {
92 if(this->gs.
world->
time % this->gs.world->ticks_per_month)
return;
95 for(
const auto province_id : this->gs.curr_nation->owned_provinces)
96 for(
const auto& pop : this->gs.world->provinces[province_id].pops)
98 num /= this->gs.curr_nation->owned_provinces.size();
101 militancy_lab.on_each_tick(militancy_lab);
106 auto& tax_grp = this->make_widget<UI::Group>(207, 38, 196, this->
height - (this->
padding.y + 38 + 48));
108 tax_grp.is_scroll =
true;
110 tax_grp.make_widget<
UI::Label>(0, 0,
"Burgeoise income tax");
117 burgeoise_tax_sld.
set_tooltip(
"% of tax taken from the income of the higher class population");
118 burgeoise_tax_sld.
on_click(burgeoise_tax_sld);
120 tax_grp.make_widget<
UI::Label>(0, 0,
"Population income tax");
122 pop_tax_sld.set_value(this->new_policy.
pop_tax);
127 pop_tax_sld.
set_tooltip(
"% of tax taken from the income of the lower and middle class population");
130 tax_grp.make_widget<
UI::Label>(0, 0,
"Minimum wage");
132 min_wage_sld.set_value(this->new_policy.
min_wage);
137 min_wage_sld.
set_tooltip(
"Minimum wage (fixed) that factories are required to pay to workers");
138 min_wage_sld.
on_click(min_wage_sld);
142 tax_grp.make_widget<
UI::Label>(0, 0,
"Industry profit tax");
149 industry_profit_tax_sld.
set_tooltip(
"% of profits taken by the goverment from the industry's profits");
150 industry_profit_tax_sld.
on_click(industry_profit_tax_sld);
155 auto& investment_grp = this->make_widget<UI::Group>(207 + 196, 38, 196, this->
height - (this->
padding.y + 38 + 48));
157 investment_grp.is_scroll =
true;
159 investment_grp.make_widget<
UI::Label>(0, 0,
"Industry subsidies");
160 auto& industry_subsidies_budget_tax_sld = investment_grp.
make_widget<
UI::Slider>(0, 0, 128, 24, -1.f, 1.f);
166 industry_subsidies_budget_tax_sld.
set_tooltip(
"% of the national budget dedicated to subsidizing factories");
167 industry_subsidies_budget_tax_sld.
on_click(industry_subsidies_budget_tax_sld);
169 investment_grp.make_widget<
UI::Label>(0, 0,
"Education budget");
176 education_budget_tax_sld.
set_tooltip(
"% of the national budget dedicated to education");
177 education_budget_tax_sld.
on_click(education_budget_tax_sld);
179 investment_grp.make_widget<
UI::Label>(0, 0,
"Private ownership");
186 private_ownership_sld.
set_tooltip(
"Maximum allowed private ownership stake % for factories\nAllows private ownership of factories, where the burgeoise would profit from it instead of the industry itself");
187 private_ownership_sld.
on_click(private_ownership_sld);
189 investment_grp.make_widget<
UI::Label>(0, 0,
"Foreign ownership");
196 foreign_ownership_sld.
set_tooltip(
"Maximum allowed foreign ownership stake % for factories\nAllows foreign investment for the construction of factories");
197 foreign_ownership_sld.
on_click(foreign_ownership_sld);
199 investment_grp.make_widget<
UI::Label>(0, 0,
"Collective ownership");
206 collective_ownership_sld.
set_tooltip(
"Maximum allowed collective ownership stake % for factories\nA collective represents the workers that work on the industry itself; allowing laborers to profit from the industry");
207 collective_ownership_sld.
on_click(collective_ownership_sld);
209 investment_grp.make_widget<
UI::Label>(0, 0,
"Individual ownership");
216 individual_ownership_sld.
set_tooltip(
"Maximum allowed individual ownership stake % for factories\nIndividual ownership pertains to stakes of a industry owned by POPs, and allowing them to profit from factories with an incurred efficiency penalty");
217 individual_ownership_sld.
on_click(individual_ownership_sld);
222 auto& state_economy_grp = this->make_widget<UI::Group>(207 + 196 + 196, 38, 196, this->
height - (this->
padding.y + 38 + 48));
224 state_economy_grp.is_scroll =
true;
226 std::vector<int> sizes{ 120, 128 };
227 std::vector<std::string> header{
"Commodity",
"Scale" };
228 auto& commodity_table = state_economy_grp.make_widget<
UI::Table<uint32_t>>(0, 0, state_economy_grp.height, 32, sizes, header);
231 for(
const auto& commodity : this->gs.
world->commodities) {
232 auto& row = commodity_table.get_row(commodity.get_id());
233 auto* commodity_row = row.get_element(0);
234 commodity_row->set_key(commodity.name.c_str());
235 auto& commodity_img = commodity_row->make_widget<
UI::Image>(0, 0, 35, 35, commodity.get_icon_path(),
true);
238 auto* scale = row.get_element(1);
239 scale->set_key(commodity.name.c_str());
240 auto& scale_sld = scale->make_widget<
UI::Slider>(0, 0, 128, 24, 0.f, 1.f);
241 scale_sld.
set_value(this->commodity_production[commodity]);
242 scale_sld.set_on_click([
this, &commodity](
UI::Widget& w) {
243 this->commodity_production[commodity] =
static_cast<UI::Slider&
>(w).get_value();
246 w.
set_tooltip(
"Scale the production of this product (only applies to factories with a state stake on them)");
248 w.
set_tooltip(
"Scale the production of this product (applies to all factories regardless of stake)");
251 scale_sld.on_click(scale_sld);
254 auto& enact_btn = this->make_widget<UI::Button>(207, 0, 128, 24);
255 enact_btn.below_of(tax_grp);
256 enact_btn.set_text(
"Enact policy");
263 packet.data(ar.get_buffer(), ar.size());
265 this->gs.
client->send(packet);
270 this->gs.
ui_ctx.
prompt(
"Policy",
"New policy enacted!");
std::shared_ptr< Eng3D::IO::Asset::Base > get_unique(const Eng3D::IO::Path &path)
Obtaining an unique asset means the "first-found" policy applies.
Eng3D::TextureManager tex_man
Eng3D::IO::PackageManager package_man
std::shared_ptr< Eng3D::Texture > load(const std::string &path, TextureOptions options=default_options)
Finds a texture in the list of a texture manager if the texture is already in the list we load the sa...
std::unique_ptr< Client > client
PoliciesView(GameState &gs)
void set_policy(const Policies &policies)
Enacts a policy on a nation.
SubideologyId subideology_id
bool can_directly_control_factories() const
std::vector< float > commodity_production
void prompt(const std::string &title, const std::string &text)
Image widget, can display pictures or effects on the screen.
Simple widget for drawing text on the screen, no multiline support.
void set_data(std::vector< ChartData > data)
void set_value(const float _value)
A dynamic/smart table that can sort elements by ascending/descending order.
void reserve(size_t _size)
void set_close_btn_function(std::function< void(Widget &)> on_click)
void serialize(Eng3D::Deser::Archive &ar, const T &obj)
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.
Base class that serves as archiver, stores (in memory) the data required for serialization/deserializ...
float collective_ownership
float industry_profit_tax
float individual_ownership
float industry_subsidies_budget