#ifndef OBJECT_H #define OBJECT_H #include #ifndef WX_PRECOMP #include #endif #include #include class World; class MapObjectLoadException: public std::exception { public: MapObjectLoadException(std::string stuff) : stuff(stuff) {} virtual const char* what() const throw() { return ("An error occured loading map objects: " + stuff).c_str(); } private: std::string stuff; }; class MapObject { public: MapObject(std::string id); 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 getID() const; std::string getName() const; wxBitmap getSprite() 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: const std::string id; std::string name; wxBitmap sprite; int width; int height; std::map inputs; }; class MapObjectEntry { public: MapObjectEntry( const MapObject& object, int posx, int posy, size_t index); 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; size_t getIndex() 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; size_t index; }; 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