68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "window.hpp"
|
|
#include "../trainer.hpp"
|
|
|
|
struct window_stack_t {
|
|
struct {
|
|
enum window_descriptor_t::type type;
|
|
window_t window;
|
|
} stack[16];
|
|
int8_t ix;
|
|
|
|
constexpr inline void
|
|
draw(const uint32_t base_pattern,
|
|
trainer_state_t& trainer_state);
|
|
|
|
constexpr inline void
|
|
update(const enum window_t::input_event event,
|
|
trainer_state_t& trainer_state);
|
|
};
|
|
|
|
constexpr inline void
|
|
window_stack_t::draw(const uint32_t base_pattern,
|
|
trainer_state_t& trainer_state)
|
|
{
|
|
if (ix < 0) return;
|
|
|
|
const window_descriptor_t& descriptor = \
|
|
window_descriptors[stack[ix].type];
|
|
|
|
descriptor.draw(base_pattern,
|
|
descriptor.data,
|
|
stack[ix].window,
|
|
trainer_state);
|
|
}
|
|
|
|
constexpr inline void
|
|
window_stack_t::update(const enum window_t::input_event event,
|
|
trainer_state_t& trainer_state)
|
|
{
|
|
if (ix < 0) return;
|
|
|
|
const window_descriptor_t& descriptor = \
|
|
window_descriptors[stack[ix].type];
|
|
|
|
const window_descriptor_t::result& result = \
|
|
descriptor.update(descriptor.data,
|
|
stack[ix].window,
|
|
trainer_state,
|
|
event);
|
|
|
|
switch (result.window_event) {
|
|
case window_t::spawn:
|
|
if (ix >= 15) return;
|
|
ix++;
|
|
stack[ix].type = result.type;
|
|
stack[ix].window.cursor = { 0 };
|
|
break;
|
|
case window_t::dismiss:
|
|
if (ix < 0) return;
|
|
ix--;
|
|
default:
|
|
break;
|
|
}
|
|
}
|