diff options
Diffstat (limited to 'src/resources/map/maplayer.cpp')
-rw-r--r-- | src/resources/map/maplayer.cpp | 138 |
1 files changed, 1 insertions, 137 deletions
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp index 05013bf71..e5036676d 100644 --- a/src/resources/map/maplayer.cpp +++ b/src/resources/map/maplayer.cpp @@ -36,6 +36,7 @@ #include "resources/image.h" #include "resources/resourcemanager.h" +#include "resources/map/mapitem.h" #include "resources/map/mapobjectlist.h" #include "resources/map/maprowvertexes.h" #include "resources/map/speciallayer.h" @@ -582,143 +583,6 @@ int MapLayer::getTileDrawWidth(const Image *img, return c; } -MapItem::MapItem(): - mImage(nullptr), - mComment(), - mName(), - mType(EMPTY), - mX(-1), - mY(-1) -{ - setType(EMPTY); -} - -MapItem::MapItem(const int type): - mImage(nullptr), - mComment(), - mName(), - mType(type), - mX(-1), - mY(-1) -{ - setType(type); -} - -MapItem::MapItem(const int type, std::string comment): - mImage(nullptr), - mComment(comment), - mName(), - mType(type), - mX(-1), - mY(-1) -{ - setType(type); -} - -MapItem::MapItem(const int type, std::string comment, - const int x, const int y): - mImage(nullptr), - mComment(comment), - mName(), - mType(type), - mX(x), - mY(y) -{ - setType(type); -} - -MapItem::~MapItem() -{ - if (mImage) - { - mImage->decRef(); - mImage = nullptr; - } -} - -void MapItem::setType(const int type) -{ - std::string name; - mType = type; - if (mImage) - mImage->decRef(); - - switch (type) - { - case ARROW_UP: - name = "graphics/sprites/arrow_up.png"; - break; - case ARROW_DOWN: - name = "graphics/sprites/arrow_down.png"; - break; - case ARROW_LEFT: - name = "graphics/sprites/arrow_left.png"; - break; - case ARROW_RIGHT: - name = "graphics/sprites/arrow_right.png"; - break; - default: - break; - } - - if (!name.empty()) - { - ResourceManager *const resman = ResourceManager::getInstance(); - mImage = resman->getImage(name); - } - else - { - mImage = nullptr; - } -} - -void MapItem::setPos(const int x, const int y) -{ - mX = x; - mY = y; -} - -void MapItem::draw(Graphics *const graphics, const int x, const int y, - const int dx, const int dy) const -{ - BLOCK_START("MapItem::draw") - if (mImage) - graphics->drawImage(mImage, x, y); - - switch (mType) - { - case ROAD: - case CROSS: - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::ROAD_POINT)); - graphics->fillRectangle(Rect(x + dx / 3, y + dy / 3, - dx / 3, dy / 3)); - break; - case HOME: - { - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::HOME_PLACE)); - graphics->fillRectangle(Rect(x, y, dx, dy)); - graphics->setColor(userPalette->getColorWithAlpha( - UserPalette::HOME_PLACE_BORDER)); - graphics->drawRectangle(Rect(x, y, dx, dy)); - break; - } - default: - break; - } - if (!mName.empty() && mType != PORTAL && mType != EMPTY) - { - Font *const font = gui->getFont(); - if (font) - { - graphics->setColor(userPalette->getColor(UserPalette::BEING)); - font->drawString(graphics, mName, x, y); - } - } - BLOCK_END("MapItem::draw") -} - ObjectsLayer::ObjectsLayer(const unsigned width, const unsigned height) : mTiles(new MapObjectList*[width * height]), mWidth(width), |