Support selecting a menu and terminate execution if so
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace Menu {
|
||||
void SimpleMenu :: setup(const Entry* entries, size_t size) {
|
||||
this->entries = entries;
|
||||
this->size = size;
|
||||
this->cur_selection = 0;
|
||||
void SimpleMenu :: setup(Callback callback, const Entry* entries, size_t size) {
|
||||
this->selection_callback = callback;
|
||||
this->entries = entries;
|
||||
this->size = size;
|
||||
this->cur_selection = 0;
|
||||
}
|
||||
|
||||
void SimpleMenu :: update(JabyEngine::FontWriter& font_writer, State& cursor, const GPU::PositionI16& start) {
|
||||
@@ -20,6 +21,10 @@ namespace Menu {
|
||||
this->cur_selection += 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Cross)) {
|
||||
this->selection_callback(this->cur_selection);
|
||||
}
|
||||
|
||||
cursor.pos = Make::PositionI16(8, 64);
|
||||
for(size_t n = 0; n < this->size; n++) {
|
||||
const auto& cur_entry = this->entries[n];
|
||||
|
||||
Reference in New Issue
Block a user