From 281bdf956a646fd8c9944e9a44f867c984792216 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 19 Mar 2015 11:42:54 -0400 Subject: Map editor can now edit properties for objects (breaks main game build) --- tools/mapedit/src/object.h | 91 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 9 deletions(-) (limited to 'tools/mapedit/src/object.h') 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 @@ #include #include +class World; + class MapObjectLoadException: public std::exception { public: - MapObjectLoadException(std::string mapname) : mapname(mapname) {} + MapObjectLoadException(std::string stuff) : stuff(stuff) {} virtual const char* what() const throw() { - return ("An error occured loading map object " + mapname).c_str(); + return ("An error occured loading map objects: " + stuff).c_str(); } private: - std::string mapname; + std::string stuff; }; class MapObject { public: - MapObject(const char* filename); + MapObject(std::string id); + + static const std::map& getAllObjects(); - static const std::map> getAllObjects(); + struct Input { + enum class Type { + Slider, + Choice + }; + + std::string name; + Type type; + int minvalue; + int maxvalue; + std::map choices; + }; - std::string getType() const; + std::string getID() const; + std::string getName() const; wxBitmap getSprite() const; - std::string getAction() const; int getWidth() const; int getHeight() const; + const std::map& getInputs() const; + const Input& getInput(std::string id) const; + + bool operator==(const MapObject& other) const; + bool operator!=(const MapObject& other) const; private: - std::string type; + const std::string id; + std::string name; wxBitmap sprite; - std::string action; int width; int height; + std::map inputs; +}; + +class MapObjectEntry { + public: + MapObjectEntry(const MapObject& object, int posx, int posy); + + struct Item { + MapObject::Input::Type type; + int intvalue; + }; + + const MapObject& getObject() const; + std::pair getPosition() const; + Item& getItem(std::string str); + const std::map& getItems() const; + + void setPosition(int x, int y); + void addItem(std::string id, Item& item); + + bool operator==(const MapObjectEntry& other) const; + bool operator!=(const MapObjectEntry& other) const; + + private: + const MapObject& object; + std::pair position; + std::map items; +}; + +class VariableChoiceValidator : public wxValidator { + public: + VariableChoiceValidator(World& world, MapObjectEntry::Item& item); + wxObject* Clone() const; + bool TransferFromWindow(); + bool TransferToWindow(); + bool Validate(wxWindow* parent); + + private: + World& world; + MapObjectEntry::Item& item; +}; + +class SliderItemValidator : public wxValidator { + public: + SliderItemValidator(World& world, MapObjectEntry::Item& item); + wxObject* Clone() const; + bool TransferFromWindow(); + bool TransferToWindow(); + bool Validate(wxWindow* parent); + + private: + World& world; + MapObjectEntry::Item& item; }; #endif -- cgit 1.4.1