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

53 lines
1.1 KiB
C++
Raw Normal View History

2021-02-07 13:38:29 -05:00
#ifndef GUI_HPP
#define GUI_HPP
#include <string>
2021-02-25 14:09:16 -05:00
#include <map>
2021-02-07 13:38:29 -05:00
#include <vector>
#include "luastack.hpp"
#include "streambuffer.hpp"
2021-02-07 13:38:29 -05:00
class GuiElt {
friend class Gui;
public:
enum Type {
TYPE_MENU_ITEM,
};
private:
Type type_;
2021-02-16 13:31:34 -05:00
std::string action_;
2021-02-07 13:38:29 -05:00
std::string label_;
GuiElt() {}
public:
~GuiElt() {}
Type type() const { return type_; }
2021-02-16 13:31:34 -05:00
const std::string &action() const { return action_; }
2021-02-07 13:38:29 -05:00
const std::string &label() const { return label_; }
};
class Gui {
public:
using EltVec = std::vector<GuiElt>;
private:
EltVec elts_;
public:
const EltVec &elts() const { return elts_; }
void clear() { elts_.clear(); }
2021-02-16 14:15:40 -05:00
bool has_action(const std::string &action) const;
2021-02-16 13:31:34 -05:00
void menu_item(const std::string &action, const std::string &label);
2021-11-16 12:20:11 -05:00
std::string get_action(int index);
2021-02-25 14:09:16 -05:00
// 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);
2021-02-07 13:38:29 -05:00
};
2021-02-25 14:09:16 -05:00
2021-02-07 13:38:29 -05:00
#endif // GUI_HPP