You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3coop/apps/openmw-mp/GUI.hpp

124 lines
3.1 KiB
C++

//
// Created by koncord on 15.08.17.
//
#pragma once
#include <queue>
#include "Window.hpp"
#include "BaseMgr.hpp"
class LuaState;
class Player;
class GUI final: public BaseMgr
{
public:
static void Init(LuaState &lua);
public:
explicit GUI(Player *player);
void messageBox(sol::function fn, const char *label, sol::this_environment te);
void customMessageBox(sol::function fn, const char *label, const char *buttons, sol::this_environment te);
void inputDialog(sol::function fn, const char *label, sol::this_environment te);
void passwordDialog(sol::function fn, const char *label, const char *note, sol::this_environment te);
void listBox(sol::function fn, const char *label, const char *items, sol::this_environment te);
void onGUIAction();
//state 0 - disallow, 1 - allow
void setMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state);
void setMapVisibilityAll(unsigned short targetPID, unsigned short state);
std::shared_ptr<Window> createWindow(short x, short y, sol::function fn, sol::this_environment te);
void deleteWindow(std::shared_ptr<Window> window);
void onGUIWindowAction();
void addQuickKey(unsigned short slot, int type, const std::string &itemId);
std::string getTopicId(unsigned int i) const;
unsigned int getChanges() const;
private:
uint64_t generateGuiId();
void processUpdate() final;
std::unordered_map<int, std::shared_ptr<Window>> windows;
std::queue<std::pair<mwmp::BasePlayer::GUIMessageBox, sol::function>> guiQueue;
int lastWindowId;
};
class QuickKey
{
friend class QuickKeys;
public:
static void Init(LuaState &lua);
public:
explicit QuickKey(mwmp::QuickKey &quickKey);
int getSlot() const;
void setSlot(unsigned short slot);
mwmp::QuickKey::Type getType() const;
void setType(mwmp::QuickKey::Type slot);
std::string getItemId() const;
void setItemId(const std::string &itemId);
mwmp::QuickKey quickKey;
};
class QuickKeys final: public BaseMgr
{
public:
static void Init(LuaState &lua);
public:
explicit QuickKeys(Player *player);
void addQuickKey(const QuickKey &quickKey);
QuickKey getQuickKey(int id) const;
void setQuickKey(int id, const QuickKey &quickKey);
size_t size() const;
void clear();
private:
void processUpdate() final;
};
class MapTile
{
friend class MapTiles;
public:
static void Init(LuaState &lua);
public:
explicit MapTile(mwmp::MapTile &mapTile);
int getCellX() const;
void setCellX(int cellX);
int getCellY() const;
void setCellY(int cellY);
void loadImageFile(const char* filePath);
void saveImageFile(const char *filePath);
mwmp::MapTile mapTile;
};
class MapTiles final: public BaseMgr
{
public:
static void Init(LuaState &lua);
public:
explicit MapTiles(Player *player);
void addMapTile(const MapTile &mapTile);
MapTile getMapTile(int id) const;
void setMapTile(int id, const MapTile &mapTile);
size_t size() const;
void clear();
private:
void processUpdate() final;
};