34 #include "eng3d/serializer.hpp"
35 #include "eng3d/audio.hpp"
36 #include "eng3d/state.hpp"
37 #include "eng3d/event.hpp"
43 #include "eventpp/callbacklist.h"
57 eventpp::CallbackList<void (
const std::vector<UnitId>)> on_update_units;
58 std::vector<UnitId> selected_units;
61 return selected_units;
65 return std::count(selected_units.begin(), selected_units.end(),
id);
69 auto it = std::lower_bound(selected_units.begin(), selected_units.end(),
id);
70 if(it == selected_units.end() || *it !=
id) {
71 selected_units.insert(it,
id);
72 on_update_units(selected_units);
77 std::erase(selected_units,
id);
78 on_update_units(selected_units);
82 selected_units.clear();
83 on_update_units(selected_units);
86 inline auto add_listener(std::function<
void(std::vector<UnitId>)> callback) {
87 return on_update_units.append(callback);
90 inline void remove_listener(eventpp::CallbackList<
void (
const std::vector<UnitId>)>::Handle handle) {
91 on_update_units.remove(handle);
void unselect_unit(UnitId id)
const std::vector< UnitId > get_selected_units() const
void select_unit(UnitId id)
void remove_listener(eventpp::CallbackList< void(const std::vector< UnitId >)>::Handle handle)
bool is_selected_unit(UnitId id) const
void clear_selected_units()
auto add_listener(std::function< void(std::vector< UnitId >)> callback)
State(const std::vector< std::string > &pkg_paths)
void handle_mouse_btn(const Eng3D::Event::MouseButton &) override
UI::Widget * event_tray_grp
void handle_mouse_wheel(const Eng3D::Event::MouseWheel &) override
std::unique_ptr< Client > client
std::atomic< bool > paused
std::unique_ptr< Server > server
void handle_resize() override
void handle_mouse_motion(const Eng3D::Event::MouseMotion &) override
void handle_key(const Eng3D::Event::Key &) override
std::atomic< bool > loaded_world
Interface::LobbySelectView * select_nation
std::atomic< bool > update_tick
std::atomic< bool > loaded_map
UI::Widget * profiler_view
std::vector< std::shared_ptr< Eng3D::Texture > > nation_flags
std::unique_ptr< Map > map
std::vector< Eng3D::StringRef > decision_autodo
std::shared_ptr< Eng3D::Texture > get_nation_flag(const Nation &nation)
GameState(const std::vector< std::string > &pkg_paths)
UI::Widget * lower_left_panel
std::atomic< int > ms_delay_speed
UI::Widget * right_side_panel
std::vector< UnitTypeId > production_queue
The UI context that handles all the ui widgets.
void game_main(int argc, char **argv)
A military outpost, on land serves as a "spawn" place for units When adjacent to a water tile this se...
Defines a type of unit, it can be a tank, garrison, infantry, etc this is moddable via a lua script a...