summary refs log tree commit diff stats
path: root/tools/mapedit/src/object.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mapedit/src/object.h')
-rw-r--r--tools/mapedit/src/object.h91
1 files changed, 82 insertions, 9 deletions
diff --git a/tools/mapedit/src/object.h b/tools/mapedit/src/object.h index bfb493c..a870a2e 100644 --- a/tools/mapedit/src/object.h +++ b/tools/mapedit/src/object.h
@@ -10,38 +10,111 @@
10#include <string> 10#include <string>
11#include <map> 11#include <map>
12 12
13class World;
14
13class MapObjectLoadException: public std::exception 15class MapObjectLoadException: public std::exception
14{ 16{
15 public: 17 public:
16 MapObjectLoadException(std::string mapname) : mapname(mapname) {} 18 MapObjectLoadException(std::string stuff) : stuff(stuff) {}
17 19
18 virtual const char* what() const throw() 20 virtual const char* what() const throw()
19 { 21 {
20 return ("An error occured loading map object " + mapname).c_str(); 22 return ("An error occured loading map objects: " + stuff).c_str();
21 } 23 }
22 24
23 private: 25 private:
24 std::string mapname; 26 std::string stuff;
25}; 27};
26 28
27class MapObject { 29class MapObject {
28 public: 30 public:
29 MapObject(const char* filename); 31 MapObject(std::string id);
32
33 static const std::map<std::string, MapObject>& getAllObjects();
30 34
31 static const std::map<std::string, std::shared_ptr<MapObject>> getAllObjects(); 35 struct Input {
36 enum class Type {
37 Slider,
38 Choice
39 };
40
41 std::string name;
42 Type type;
43 int minvalue;
44 int maxvalue;
45 std::map<int, std::string> choices;
46 };
32 47
33 std::string getType() const; 48 std::string getID() const;
49 std::string getName() const;
34 wxBitmap getSprite() const; 50 wxBitmap getSprite() const;
35 std::string getAction() const;
36 int getWidth() const; 51 int getWidth() const;
37 int getHeight() const; 52 int getHeight() const;
53 const std::map<std::string, Input>& getInputs() const;
54 const Input& getInput(std::string id) const;
55
56 bool operator==(const MapObject& other) const;
57 bool operator!=(const MapObject& other) const;
38 58
39 private: 59 private:
40 std::string type; 60 const std::string id;
61 std::string name;
41 wxBitmap sprite; 62 wxBitmap sprite;
42 std::string action;
43 int width; 63 int width;
44 int height; 64 int height;
65 std::map<std::string, Input> inputs;
66};
67
68class MapObjectEntry {
69 public:
70 MapObjectEntry(const MapObject& object, int posx, int posy);
71
72 struct Item {
73 MapObject::Input::Type type;
74 int intvalue;
75 };
76
77 const MapObject& getObject() const;
78 std::pair<int, int> getPosition() const;
79 Item& getItem(std::string str);
80 const std::map<std::string, Item>& getItems() const;
81
82 void setPosition(int x, int y);
83 void addItem(std::string id, Item& item);
84
85 bool operator==(const MapObjectEntry& other) const;
86 bool operator!=(const MapObjectEntry& other) const;
87
88 private:
89 const MapObject& object;
90 std::pair<int, int> position;
91 std::map<std::string, Item> items;
92};
93
94class VariableChoiceValidator : public wxValidator {
95 public:
96 VariableChoiceValidator(World& world, MapObjectEntry::Item& item);
97 wxObject* Clone() const;
98 bool TransferFromWindow();
99 bool TransferToWindow();
100 bool Validate(wxWindow* parent);
101
102 private:
103 World& world;
104 MapObjectEntry::Item& item;
105};
106
107class SliderItemValidator : public wxValidator {
108 public:
109 SliderItemValidator(World& world, MapObjectEntry::Item& item);
110 wxObject* Clone() const;
111 bool TransferFromWindow();
112 bool TransferToWindow();
113 bool Validate(wxWindow* parent);
114
115 private:
116 World& world;
117 MapObjectEntry::Item& item;
45}; 118};
46 119
47#endif 120#endif