50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#pragma once
|
|
#include "font_writer.hpp"
|
|
#include <FontWriter/font_writer.hpp>
|
|
#include <PSX/Timer/frame_timer.hpp>
|
|
|
|
namespace Menu {
|
|
using namespace JabyEngine;
|
|
|
|
class SimpleMenu {
|
|
public:
|
|
struct Entry {
|
|
const char* name;
|
|
};
|
|
|
|
typedef void (*Callback)(uint32_t selection);
|
|
|
|
private:
|
|
Callback selection_callback;
|
|
const Entry* entries;
|
|
size_t size;
|
|
uint8_t cur_selection;
|
|
|
|
public:
|
|
void setup(Callback callback, const Entry* entries, size_t size);
|
|
|
|
template<size_t N>
|
|
void setup(Callback callback, const Entry (&entries)[N]) {
|
|
SimpleMenu::setup(callback, entries, N);
|
|
}
|
|
|
|
void update(JabyEngine::FontWriter& font_writer, State& cursor, const GPU::PositionI16& start);
|
|
};
|
|
|
|
class BackMenu {
|
|
private:
|
|
JabyEngine::FontWriter* font_writer;
|
|
SimpleTimer<uint32_t> timeout;
|
|
bool waiting;
|
|
|
|
public:
|
|
void setup(JabyEngine::FontWriter* font_writer);
|
|
void reset() {
|
|
this->timeout.reset();
|
|
this->waiting = false;
|
|
}
|
|
|
|
bool update(const GPU::PositionI16& position, bool auto_clear = true);
|
|
void render();
|
|
};
|
|
} |