25 #include "eng3d/texture.hpp"
26 #include "eng3d/ui/components.hpp"
27 #include "eng3d/ttf.hpp"
28 #include "eng3d/string.hpp"
55 auto& flag_img = this->make_widget<UI::Image>(5, 4, 138, 88, this->gs.
tex_man.
get_white());
56 flag_img.set_on_each_tick([
this](
UI::Widget& w) {
59 flag_img.on_each_tick(flag_img);
61 this->make_widget<UI::Image>(5, 4, flag_img.width, flag_img.height,
"gfx/drop_shadow.png");
64 auto& event_tray_grp = this->make_widget<UI::Image>(150, 32, 356 + 256, 32,
"gfx/background2.png",
true);
68 auto& stats_grp = this->make_widget<UI::Image>(150, 0, 356 + 256, 32,
"gfx/background2.png",
true);
71 auto& money_grp = stats_grp.make_widget<
UI::Div>(0, 0, 24 + 96, 24);
73 auto& money_img = money_grp.make_widget<
UI::Image>(0, 0, 24, 24,
"gfx/economy.png",
true);
75 auto& money_lab = money_grp.make_widget<
UI::Label>(0, 0,
" ");
79 money_lab.on_each_tick(money_lab);
81 auto& population_grp = stats_grp.make_widget<
UI::Div>(0, 0, 24 + 96, 24);
83 auto& population_img = population_grp.make_widget<
UI::Image>(0, 0, 24, 24,
"gfx/pop.png",
true);
85 auto& population_lab = population_grp.make_widget<
UI::Label>(0, 0,
" ");
88 return a + gs.world->provinces[province_id].total_pops();
93 return gs.world->provinces[province_id].total_pops() < gs.world->provinces[other_province_id].total_pops();
95 const auto& smallest_province = gs.
world->provinces[*it1];
96 const auto& largest_province = gs.
world->provinces[*it2];
98 w.
set_tooltip(
Eng3D::string_format(
"Average population density: %.0f\nLargest province: %s (%.0f)\nSmallest province: %s (%.0f)", total / gs.
curr_nation->
owned_provinces.size(), largest_province.name.c_str(), largest_province.total_pops(), smallest_province.name.c_str(), smallest_province.total_pops()));
100 population_lab.on_each_tick(population_lab);
102 auto& military_score_grp = stats_grp.make_widget<
UI::Div>(0, 0, 24 + 64, 24);
104 auto& military_score_img = military_score_grp.make_widget<
UI::Image>(0, 0, 24, 24,
"gfx/military_score.png",
true);
106 auto& military_score_lab = military_score_grp.make_widget<
UI::Label>(0, 0,
" ");
109 const auto& province = this->gs.world->provinces[province_id];
110 const auto& units = this->gs.world->unit_manager.get_province_units(province.get_id());
111 return a + std::accumulate(units.cbegin(), units.cend(), 0, [this](const auto a2, const auto unit_id) {
112 const auto& unit = this->gs.world->unit_manager.units[unit_id];
113 return a2 + (unit.owner_id == this->gs.curr_nation->get_id() ? unit.get_strength() : 0.f);
118 military_score_lab.on_each_tick(military_score_lab);
120 auto& industrial_score_grp = stats_grp.make_widget<
UI::Div>(0, 0, 24 + 64, 24);
122 auto& industrial_score_img = industrial_score_grp.make_widget<
UI::Image>(0, 0, 24, 24,
"gfx/industry.png",
true);
123 industrial_score_img.
set_tooltip(
"Industrial score");
124 auto& industrial_score_lab = industrial_score_grp.make_widget<
UI::Label>(0, 0,
" ");
126 const auto total = std::accumulate(gs.curr_nation->owned_provinces.cbegin(), gs.curr_nation->owned_provinces.cend(), 0.f, [
this](
const auto a,
const auto province_id) ->
float {
127 const auto& province = this->gs.world->provinces[province_id];
128 const auto& buildings = province.get_buildings();
129 return a + std::accumulate(buildings.cbegin(), buildings.cend(), 0.f, [](const auto a2, const auto& building) {
130 return a2 + (building.production_scale * building.level);
135 industrial_score_lab.on_each_tick(industrial_score_lab);
137 auto& prestige_score_grp = stats_grp.make_widget<
UI::Div>(0, 0, 24 + 64, 24);
139 auto& prestige_score_img = prestige_score_grp.make_widget<
UI::Image>(0, 0, 24, 24,
"gfx/prestige.png",
true);
141 auto& prestige_score_lab = prestige_score_grp.make_widget<
UI::Label>(0, 0,
" ");
145 prestige_score_lab.on_each_tick(prestige_score_lab);
147 auto& flex_column = this->make_widget<UI::Div>(3, 96, 42, 390);
154 auto& policy_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/book.png",
true);
158 policy_ibtn.set_tooltip(
"Laws & Policies");
160 auto& economy_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/economy.png",
true);
164 economy_ibtn.set_tooltip(
"Economy");
166 auto& pops_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/pop.png",
true);
170 pops_ibtn.set_tooltip(
"Population");
172 auto& industry_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/industry.png",
true);
176 industry_ibtn.set_tooltip(
"Factories");
178 auto& military_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/military_score.png",
true);
182 military_ibtn.set_tooltip(
"Military");
184 auto& research_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/tech.png",
true);
188 research_ibtn.set_tooltip(
"Research");
190 auto& save_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/save.png",
true);
192 LUA_util::save(this->gs,
string_format(
"%s_%zu-%zu-%zu.sc4", gs.curr_nation->ref_name.c_str(), gs.world->get_year(), gs.world->get_month(), gs.world->get_day()));
194 save_ibtn.set_tooltip(
"Saves the current game");
196 auto& load_ibtn = flex_column.make_widget<
UI::Image>(9, 275, 25, 25,
"gfx/top_bar/save.png",
true);
200 load_ibtn.set_tooltip(
"Load latest autosave");
202 auto& exit_ibtn = flex_column.make_widget<
UI::Image>(0, 0, icon_size, icon_size,
"gfx/exit.png",
true);
204 this->gs.ui_ctx.clear();
205 this->gs.ui_ctx.use_tooltip(
nullptr, { 0, 0 });
206 this->gs.paused =
true;
207 this->gs.client.reset();
208 this->gs.server.reset();
211 exit_ibtn.set_tooltip(
"Back to the main menu");
215 :
UI::Group(-480, 0),
226 auto& btn_group = this->make_widget<UI::Group>(320, 12);
227 auto& speed0_btn = btn_group.make_widget<
UI::Image>(0, 0, btn_size, btn_size,
"gfx/ui/button/time_control_pause.png",
true);
231 speed0_btn.set_tooltip(
translate(
"Pause"));
232 auto& speed1_btn = btn_group.make_widget<
UI::Image>(45, 0, btn_size, btn_size,
"gfx/ui/button/time_control_1.png",
true);
237 speed1_btn.set_tooltip(
translate(
"Turtle speed"));
238 auto& speed2_btn = btn_group.make_widget<
UI::Image>(80, 0, btn_size, btn_size,
"gfx/ui/button/time_control_2.png",
true);
243 speed2_btn.set_tooltip(
translate(
"Horse speed"));
244 auto& speed3_btn = btn_group.make_widget<
UI::Image>(115, 0, btn_size, btn_size,
"gfx/ui/button/time_control_3.png",
true);
249 speed3_btn.set_tooltip(
translate(
"Fire speed"));
252 auto& time_lab = this->make_widget<UI::Label>(50, 30,
" ");
255 time_lab.set_on_each_tick([
this](
UI::Widget& w) {
261 std::strftime(mbstr,
sizeof mbstr,
"%x", &tm);
264 time_lab.on_each_tick(time_lab);
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::TrueType::Manager ttf_man
Eng3D::TextureManager tex_man
Eng3D::IO::PackageManager package_man
std::shared_ptr< Eng3D::Texture > get_white()
std::shared_ptr< Eng3D::TrueType::Font > load(std::shared_ptr< Eng3D::IO::Asset::Base > asset)
UI::Widget * event_tray_grp
std::atomic< bool > paused
std::shared_ptr< Eng3D::Texture > get_nation_flag(const Nation &nation)
std::atomic< int > ms_delay_speed
std::vector< ProvinceId > owned_provinces
Image widget, can display pictures or effects on the screen.
static Image * make_transparent(int x, int y, unsigned w, unsigned h, const std::string &tex_path, Widget *parent=nullptr)
Simple widget for drawing text on the screen, no multiline support.
int get_month(void) const
std::string translate(const std::string_view str)
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.
void save(GameState &gs, const std::string &savefile_path)
void load(GameState &gs, const std::string &savefile_path)
Primitive color type used through the engine.
A basic widget without any presets.