25 #include "eng3d/ttf.hpp"
26 #include "eng3d/log.hpp"
27 #include "eng3d/texture.hpp"
28 #include "eng3d/ui/button.hpp"
29 #include "eng3d/ui/input.hpp"
30 #include "eng3d/ui/tooltip.hpp"
31 #include "eng3d/ui/ui.hpp"
32 #include "eng3d/ui/slider.hpp"
33 #include "eng3d/ui/checkbox.hpp"
34 #include "eng3d/ui/group.hpp"
35 #include "eng3d/ui/image.hpp"
36 #include "eng3d/ui/close_button.hpp"
50 :
UI::Window(0, 0, 512, 128),
54 this->
set_text(
"Internet multiplayer");
62 "127.x.x.x: Local host\n"
63 "192.x.x.x: LAN IP range");
80 this->gs.
client = std::make_unique<Client>(this->gs, this->ip_addr_inp->get_buffer(), 1836);
82 this->gs.
client->wait_for_snapshot();
99 :
UI::Div(250, -270, 300, 540),
111 this->
border =
UI::Border(main_menu_border, glm::ivec2(16), glm::ivec2(16));
112 this->make_widget<UI::Image>(0, 0, 300, 120,
"gfx/ui/image/logo.png");
116 glm::ivec2 size(3, 3);
117 glm::ivec2 texture_size(3, 3);
118 auto button_border =
UI::Border(button_border_image, size, texture_size);
120 auto& button_list = this->make_widget<UI::Div>(0, 200, 300, 320);
123 button_list.flex_gap = 8;
128 auto& demo_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
129 demo_btn.
border = button_border;
130 demo_btn.current_texture = button_image;
131 demo_btn.font = menu_font;
132 demo_btn.text_color = menu_text_color;
135 demo_btn.set_text(
"Pre-alpha demo");
143 for(
auto& nation : this->
gs.
world->nations)
144 if(nation.ref_name.get_string() ==
"netherlands")
155 auto& single_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
156 single_btn.
border = button_border;
157 single_btn.current_texture = button_image;
158 single_btn.font = menu_font;
159 single_btn.text_color = menu_text_color;
161 single_btn.set_text(
"Singleplayer");
171 auto& mp_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
172 mp_btn.
border = button_border;
173 mp_btn.current_texture = button_image;
174 mp_btn.font = menu_font;
175 mp_btn.text_color = menu_text_color;
177 mp_btn.set_text(
"Multiplayer");
183 auto& host_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
184 host_btn.
border = button_border;
185 host_btn.current_texture = button_image;
186 host_btn.font = menu_font;
187 host_btn.text_color = menu_text_color;
189 host_btn.set_text(
"Host");
199 auto& edit_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
200 edit_btn.
border = button_border;
201 edit_btn.current_texture = button_image;
202 edit_btn.font = menu_font;
203 edit_btn.text_color = menu_text_color;
205 edit_btn.set_text(
"Editor");
219 auto& cfg_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
220 cfg_btn.
border = button_border;
221 cfg_btn.current_texture = button_image;
222 cfg_btn.font = menu_font;
223 cfg_btn.text_color = menu_text_color;
225 cfg_btn.set_text(
"Settings");
230 auto& exit_btn = button_list.make_widget<
UI::Button>(0, 0, b_width, b_height);
231 exit_btn.
border = button_border;
232 exit_btn.current_texture = button_image;
233 exit_btn.font = menu_font;
234 exit_btn.text_color = menu_text_color;
236 exit_btn.set_text(
"Exit");
239 this->
gs.
run =
false;
244 if(connect_window !=
nullptr)
245 connect_window->kill();
std::shared_ptr< Eng3D::IO::Asset::Base > get_unique(const Eng3D::IO::Path &path)
Obtaining an unique asset means the "first-found" policy applies.
virtual const char * what() const noexcept
std::atomic< bool > run
Variable telling if the game should quit, honored by most event loops but should be used explicitly i...
Eng3D::TrueType::Manager ttf_man
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::shared_ptr< Eng3D::TrueType::Font > load(std::shared_ptr< Eng3D::IO::Asset::Base > asset)
std::unique_ptr< Client > client
std::atomic< bool > paused
std::unique_ptr< Server > server
Interface::LobbySelectView * select_nation
MainMenuConnectServer(GameState &gs)
MainMenuConnectServer * connect_window
Border class that defines the texture and size of borders of the widgets.
void prompt(const std::string &title, const std::string &text)
void clear()
Removes all widgets.
void set_close_btn_function(std::function< void(Widget &)> on_click)
void debug(const std::string_view category, const std::string_view msg)
std::string translate_format(const std::string_view format, Args &&... args)
String formatter, with translation.
Primitive color type used through the engine.
void invoke_registered_callback(const std::string &name)
Some UI functions are hardcoded, for example the main menu is hardcoded to appear when the game start...