Files
integration/luprex/core/cpp/gui.hpp

58 lines
1.3 KiB
C++

#ifndef GUI_HPP
#define GUI_HPP
#include "wrap-string.hpp"
#include "wrap-map.hpp"
#include "wrap-vector.hpp"
#include "luastack.hpp"
#include "streambuffer.hpp"
class GuiElt {
friend class Gui;
public:
enum Type {
TYPE_MENU_ITEM,
};
private:
Type type_;
std::string action_;
std::string label_;
GuiElt() {}
public:
~GuiElt() {}
Type type() const { return type_; }
const std::string &action() const { return action_; }
const std::string &label() const { return label_; }
};
class Gui {
public:
using EltVec = std::vector<GuiElt>;
private:
int64_t place_;
EltVec elts_;
public:
Gui() { place_ = 0; }
int64_t place() { return place_; }
const EltVec &elts() const { return elts_; }
void clear(int64_t p) { place_ = p; elts_.clear(); }
bool has_action(const std::string &action) const;
void menu_item(const std::string &action, const std::string &label);
std::string get_action(int index);
std::string menu_debug_string() const;
// Put a pointer to a gui into the lua registry.
//
// All lua commands that manipulate the GUI implicitly
// operate on this global gui pointer.
//
static void store_global_pointer(lua_State *L, Gui *g);
static Gui *fetch_global_pointer(lua_State *L);
};
#endif // GUI_HPP