Rework the editor to be more sane

This commit is contained in:
Tim Felgentreff 2020-12-12 17:22:57 +01:00
parent 30346f869c
commit 64b376de49
2 changed files with 453 additions and 549 deletions
src

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,8 @@
#ifndef __WIDGETS_H__
#define __WIDGETS_H__
#include <functional>
#include <guichan.h>
#include <guichan/gsdl.h>
#include "font.h"
@ -66,6 +68,21 @@ public:
virtual ~LuaActionListener();
};
class LambdaActionListener : public gcn::ActionListener
{
std::function<void(const std::string &)> lambda;
public:
LambdaActionListener(std::function<void(const std::string &)> l)
{
lambda = l;
}
virtual void action(const std::string &eventId)
{
lambda(eventId);
}
};
class ImageWidget : public gcn::Icon
{
public:
@ -260,6 +277,18 @@ private:
CGraphic *itemImage;
};
class StringListModel : public gcn::ListModel
{
std::vector<std::string> list;
public:
StringListModel(std::vector<std::string> l) {
list = l;
}
virtual int getNumberOfElements() { return list.size(); }
virtual std::string getElementAt(int i) { return list[i]; }
};
class LuaListModel : public gcn::ListModel
{
std::vector<std::string> list;