Support exiting GPU Test
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace Menu {
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
|
||||
void SimpleMenu :: setup(Callback callback, const Entry* entries, size_t size) {
|
||||
this->selection_callback = callback;
|
||||
this->entries = entries;
|
||||
@@ -10,7 +12,6 @@ namespace Menu {
|
||||
}
|
||||
|
||||
void SimpleMenu :: update(JabyEngine::FontWriter& font_writer, State& cursor, const GPU::PositionI16& start) {
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Up) && this->cur_selection > 0) {
|
||||
@@ -38,4 +39,40 @@ namespace Menu {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BackMenu :: setup(JabyEngine::FontWriter* font_writer) {
|
||||
this->font_writer = font_writer;
|
||||
this->timeout.reset();
|
||||
this->waiting = false;
|
||||
}
|
||||
|
||||
bool BackMenu :: update(const GPU::PositionI16& position) {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(controller.button.is_down(DigitalButton::Circle)) {
|
||||
this->waiting = true;
|
||||
if(this->timeout.is_expired_for(2500_ms)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
this->waiting = false;
|
||||
this->timeout.reset();
|
||||
}
|
||||
|
||||
if(this->waiting) {
|
||||
auto state = JabyEngine::State::create(position);
|
||||
this->font_writer->write(state, "Press and hold ()\nto get back", GPU::Color24::Red());
|
||||
}
|
||||
|
||||
else {
|
||||
this->font_writer->clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BackMenu :: render() {
|
||||
this->font_writer->render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user