Support selecting a menu and terminate execution if so
This commit is contained in:
@@ -21,38 +21,78 @@ static const Menu::SimpleMenu::Entry MenuEntries[] = {
|
||||
// Do we want Paco to be HERE?!
|
||||
static object::Paco paco;
|
||||
static Menu::SimpleMenu menu;
|
||||
static bool enter_loading = false;
|
||||
|
||||
static void setup() {
|
||||
Assets::Main::load();
|
||||
FontWriter::setup();
|
||||
paco.setup();
|
||||
menu.setup(MenuEntries);
|
||||
menu.setup([](uint32_t selection) {
|
||||
enter_loading = true;
|
||||
},MenuEntries);
|
||||
}
|
||||
|
||||
static void update() {
|
||||
static const char Title[] = "Pool Box";
|
||||
static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.font_size.width;
|
||||
namespace NormalScene {
|
||||
static void update() {
|
||||
static const char Title[] = "Pool Box";
|
||||
static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.font_size.width;
|
||||
|
||||
Periphery::query_controller();
|
||||
auto cursor = FontWriter::update(JabyEngine::Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16));
|
||||
paco.update();
|
||||
Periphery::query_controller();
|
||||
auto cursor = FontWriter::update(JabyEngine::Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16));
|
||||
paco.update();
|
||||
|
||||
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(), &FontWriter::wiggle);
|
||||
menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64));
|
||||
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(), &FontWriter::wiggle);
|
||||
menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64));
|
||||
}
|
||||
|
||||
static void render() {
|
||||
FontWriter::new_font_writer.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
paco.render();
|
||||
}
|
||||
|
||||
static void run() {
|
||||
update();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
static void render() {
|
||||
FontWriter::new_font_writer.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
paco.render();
|
||||
namespace LoadingScene {
|
||||
static void update() {
|
||||
static const char Title[] = "Loading...";
|
||||
static constexpr auto TitleLength = (sizeof(Title) - 1)*DefaultFont::Info.font_size.width;
|
||||
|
||||
auto cursor = FontWriter::update(JabyEngine::Make::PositionI16((GPU::Display::Width-TitleLength)/2, (GPU::Display::Height-16)/2));
|
||||
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Blue());
|
||||
}
|
||||
|
||||
static void render() {
|
||||
FontWriter::new_font_writer.render();
|
||||
}
|
||||
|
||||
static void run() {
|
||||
enter_loading = false;
|
||||
update();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
|
||||
printf("End of execution!\n");
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
update();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
if(enter_loading) {
|
||||
LoadingScene::run();
|
||||
}
|
||||
|
||||
else {
|
||||
NormalScene::run();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user