diff options
Diffstat (limited to 'src/level-init.cpp')
| -rw-r--r-- | src/level-init.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/level-init.cpp b/src/level-init.cpp new file mode 100644 index 0000000..98493e2 --- /dev/null +++ b/src/level-init.cpp @@ -0,0 +1,39 @@ + +#include "level-init.hpp" +#include "level-main.hpp" + +#include <pke/pke.hpp> + +struct pke_level_init_master { + pke_level *level = nullptr; +} init_mstr; + +pke_level *pke_at_level_init_create() { + init_mstr.level = pke_level_create("init", pk_uuid_zed, pk_uuid_zed); + init_mstr.level->pke_cb_spinup.func = pke_at_level_init_init; + init_mstr.level->pke_cb_tick.func = (void(*)())pke_at_level_init_tick; + init_mstr.level->pke_cb_teardown.func = pke_at_level_init_teardown; + return init_mstr.level; +} + +void pke_at_level_init_init() { } + +void pke_at_level_init_tick(double delta) { + (void)delta; + /* 2025-09-29 JCB + * This is a little goofy, but the engine needs to process 1(one) entire + * tick before we actually want to start the application. + * Specifically, the issue I was running into was that the editor plugin + * activates its player inputs on its very first tick, which happens *after* + * both the first level's init function and the first level's first tick. + * This means that certain ui actions are being swallowed because they do not + * have the desired priority in the input handler. + * I am unconvinced that this qualifies as a bug; perhaps a quirk at worst. + * The fix is to just register things in the right order, which we are doing + * with this fake level that immediately passes off being the active level, + * allowing the needed 1(one) tick to pass. + */ + pkeSettings.rt.nextLevel = pke_at_level_main_create(); +} + +void pke_at_level_init_teardown() { } |
