22#include <ospp/event.h>
43std::atomic<bool> is_shutting_down{
false};
45void update_input_zone(
const renderer& rend, input_system&
input)
47 const auto& window = rend.get_main_window();
50 auto main_pos = window->get_window().get_position();
51 auto main_size = window->get_window().get_size();
54 window_zone.
x = main_pos.x;
55 window_zone.y = main_pos.y;
56 window_zone.w = int(main_size.w);
57 window_zone.h = int(main_size.h);
59 input.manager.set_window_zone(window_zone);
65 if(ctx.
has<init_error>())
67 const auto& error = ctx.
get<init_error>();
73void engine_interrupt_handler(
const crash::signal_info& info)
75 APPLOG_INFO(
"User interrupt ({}) -> {}", info.signal_number, info.signal_name);
82void engine_termination_handler(
const crash::signal_info& info)
84 APPLOG_INFO(
"Termination signal ({}) -> {}", info.signal_number, info.signal_name);
92void engine_crash_handler(
const crash::signal_info& info,
const crash::trace_info& trace)
95 APPLOG_CRITICAL(
"Crash signal ({}) -> {}\n{}", info.signal_number, info.signal_name, trace.formatted_trace);
103void engine_exception_handler(
const crash::exception_info& info,
const crash::trace_info& trace)
105 APPLOG_CRITICAL(
"{}\n{}", info.exception_message, trace.formatted_trace);
117 return *context_ptr();
122 context_ptr() = &ctx;
124 fs::path binary_path = fs::executable_path(parser.app_name().c_str()).parent_path();
127 fs::path engine_data = binary_path /
"data" /
"engine";
131 [](
const std::string& log,
const hpp::source_location& loc)
133 APPLOG_WARNING_LOC(loc.file_name(),
int(loc.line()), loc.function_name(),
"Serialization {}", log);
140 .interrupt_handler = engine_interrupt_handler,
141 .termination_handler = engine_termination_handler,
142 .crash_handler = engine_crash_handler,
143 .exception_handler = engine_exception_handler,
175 print_init_error(ctx);
181 print_init_error(ctx);
187 print_init_error(ctx);
193 print_init_error(ctx);
204 if(!ctx.get_cached<
ecs>().
init(ctx))
206 print_init_error(ctx);
212 print_init_error(ctx);
218 print_init_error(ctx);
224 print_init_error(ctx);
230 print_init_error(ctx);
236 print_init_error(ctx);
242 print_init_error(ctx);
248 print_init_error(ctx);
254 print_init_error(ctx);
260 print_init_error(ctx);
266 print_init_error(ctx);
272 print_init_error(ctx);
393 bool empty = ctx.empty();
408 auto& ev = ctx.get_cached<
events>();
409 auto& rend = ctx.get_cached<
renderer>();
410 auto& thr = ctx.get_cached<
threader>();
415 sim.run_one_frame(
true);
417 auto dt = sim.get_delta_time();
421 if(ev.frames_playing == 0)
433 update_input_zone(rend,
input);
435 input.manager.before_events_update();
437 bool should_quit =
false;
440 while(os::poll_event(e))
442 ev.on_os_event(ctx, e);
444 input.manager.on_os_event(e);
446 should_quit = rend.get_main_window() ==
nullptr || is_shutting_down;
452 input.manager.after_events_update();
456 ev.set_play_mode(ctx,
false);
457 is_shutting_down =
false;
461 ev.on_frame_begin(ctx, dt);
465 ev.on_frame_update(ctx, dt);
467 ev.on_frame_before_render(ctx, dt);
469 ev.on_frame_render(ctx, dt);
471 ev.on_frame_end(ctx, dt);
479 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
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.