23#include <ospp/event.h>
44std::atomic<bool> is_shutting_down{
false};
46void update_input_zone(
const renderer& rend, input_system&
input)
48 const auto& window = rend.get_main_window();
51 auto main_pos = window->get_window().get_position();
52 auto main_size = window->get_window().get_size();
55 window_zone.
x = main_pos.x;
56 window_zone.y = main_pos.y;
57 window_zone.w = int(main_size.w);
58 window_zone.h = int(main_size.h);
60 input.manager.set_window_zone(window_zone);
66 if(ctx.
has<init_error>())
68 const auto& error = ctx.
get<init_error>();
74void engine_interrupt_handler(
const crash::signal_info& info)
76 APPLOG_INFO(
"User interrupt ({}) -> {}", info.signal_number, info.signal_name);
83void engine_termination_handler(
const crash::signal_info& info)
85 APPLOG_INFO(
"Termination signal ({}) -> {}", info.signal_number, info.signal_name);
93void engine_crash_handler(
const crash::signal_info& info,
const crash::trace_info& trace)
96 APPLOG_CRITICAL(
"Crash signal ({}) -> {}\n{}", info.signal_number, info.signal_name, trace.formatted_trace);
104void engine_exception_handler(
const crash::exception_info& info,
const crash::trace_info& trace)
106 APPLOG_CRITICAL(
"{}\n{}", info.exception_message, trace.formatted_trace);
118 return *context_ptr();
123 context_ptr() = &ctx;
125 fs::path binary_path = fs::executable_path(parser.app_name().c_str()).parent_path();
128 fs::path engine_data = binary_path /
"data" /
"engine";
132 [](
const std::string& log,
const hpp::source_location& loc)
134 APPLOG_WARNING_LOC(loc.file_name(),
int(loc.line()), loc.function_name(),
"Serialization {}", log);
141 .interrupt_handler = engine_interrupt_handler,
142 .termination_handler = engine_termination_handler,
143 .crash_handler = engine_crash_handler,
144 .exception_handler = engine_exception_handler,
176 print_init_error(ctx);
182 print_init_error(ctx);
188 print_init_error(ctx);
194 print_init_error(ctx);
205 if(!ctx.get_cached<
ecs>().
init(ctx))
207 print_init_error(ctx);
213 print_init_error(ctx);
219 print_init_error(ctx);
225 print_init_error(ctx);
231 print_init_error(ctx);
237 print_init_error(ctx);
243 print_init_error(ctx);
249 print_init_error(ctx);
255 print_init_error(ctx);
261 print_init_error(ctx);
267 print_init_error(ctx);
273 print_init_error(ctx);
279 print_init_error(ctx);
406 bool empty = ctx.empty();
421 auto& ev = ctx.get_cached<
events>();
422 auto& rend = ctx.get_cached<
renderer>();
423 auto& thr = ctx.get_cached<
threader>();
428 sim.run_one_frame(
true);
430 auto dt = sim.get_delta_time();
434 if(ev.frames_playing == 0)
446 update_input_zone(rend,
input);
448 input.manager.before_events_update();
450 bool should_quit =
false;
453 while(os::poll_event(e))
455 ev.on_os_event(ctx, e);
457 input.manager.on_os_event(e);
459 should_quit = rend.get_main_window() ==
nullptr || is_shutting_down;
465 input.manager.after_events_update();
469 ev.set_play_mode(ctx,
false);
470 is_shutting_down =
false;
474 ev.on_frame_begin(ctx, dt);
478 ev.on_frame_update(ctx, dt);
480 ev.on_frame_before_render(ctx, dt);
482 ev.on_frame_render(ctx, dt);
484 ev.on_frame_end(ctx, dt);
492 is_shutting_down =
true;
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
Manages assets, including loading, unloading, and storage.
auto init(rtti::context &ctx) -> bool
Initializes the asset manager with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the asset manager with the given context.
Manages the audio operations and integrates with the audio backend.
auto init(rtti::context &ctx) -> bool
Initializes the audio system with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the audio system with the given context.
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
System that manages and updates particle emitters in the ECS.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the particle system.
auto init(rtti::context &ctx) -> bool
Initializes the particle system.
Manages the physics operations using the specified backend.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the physics system with the given context.
auto init(rtti::context &ctx) -> bool
Initializes the physics system with the given context.
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
Base class for different rendering paths in the ACE framework.
auto init(rtti::context &ctx) -> bool
Initializes the rendering path with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the rendering path with the given context.
std::chrono::duration< float > delta_t
#define APPLOG_CRITICAL(...)
#define APPLOG_WARNING_LOC(FILE_LOC, LINE_LOC, FUNC_LOC,...)
bool add_path_protocol(const std::string &protocol, const path &dir)
Allows us to map a protocol to a specific directory. A path protocol gives the caller the ability to ...
void update(seq_id_t id, duration_t delta)
Updates the elapsed duration of a specific action.
void set_warning_logger(const std::function< void(const std::string &, const hpp::source_location &loc)> &logger)
auto install_handlers(const crash_handlers &handlers) -> void
Install comprehensive crash handlers.
auto get_app_profiler() -> performance_profiler *
Provides default initialization and creation functions for various entities and assets.
static auto init(rtti::context &ctx) -> bool
Initializes default settings and assets.
static auto deinit(rtti::context &ctx) -> bool
Deinitializes default settings and assets.
Manages the entity-component-system (ECS) operations for the ACE framework.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the ECS with the given context.
auto init(rtti::context &ctx) -> bool
Initializes the ECS with the given context.
static auto process() -> int
static auto init_systems(const cmd_line::parser &parser) -> bool
static auto destroy() -> bool
static auto context() -> rtti::context &
static auto deinit() -> bool
static auto interrupt() -> bool
static auto create(rtti::context &ctx, cmd_line::parser &parser) -> bool
static auto init_core(const cmd_line::parser &parser) -> bool
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx, const cmd_line::parser &parser) -> bool
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
Class responsible for timers.
auto init(rtti::context &ctx) -> bool
auto deinit(rtti::context &ctx) -> bool
System responsible for managing user interface components and rendering.
auto init(rtti::context &ctx) -> bool
Initializes the UI system with the given context.
auto deinit(rtti::context &ctx) -> bool
Deinitializes the UI system with the given context.