summaryrefslogtreecommitdiff
path: root/src/resources/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/map')
-rw-r--r--src/resources/map/map.cpp13
-rw-r--r--src/resources/map/mapitem.cpp23
-rw-r--r--src/resources/map/mapitem.h20
-rw-r--r--src/resources/map/maplayer.cpp5
-rw-r--r--src/resources/map/speciallayer.cpp8
5 files changed, 28 insertions, 41 deletions
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 6e7a7cec6..d6fc7db8e 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -43,6 +43,7 @@
#include "resources/ambientlayer.h"
#include "resources/image.h"
+#include "resources/mapitemtype.h"
#include "resources/resourcemanager.h"
#include "resources/subimage.h"
@@ -1031,18 +1032,18 @@ void Map::addExtraLayer()
if (comment.empty())
{
- if (type < MapItem::ARROW_UP
- || type > MapItem::ARROW_RIGHT)
+ if (type < MapItemType::ARROW_UP
+ || type > MapItemType::ARROW_RIGHT)
{
comment = "unknown";
}
}
- if (type == MapItem::PORTAL)
+ if (type == MapItemType::PORTAL)
{
updatePortalTile(comment, type, atoi(x.c_str()),
atoi(y.c_str()), false);
}
- else if (type == MapItem::HOME)
+ else if (type == MapItemType::HOME)
{
updatePortalTile(comment, type, atoi(x.c_str()),
atoi(y.c_str()));
@@ -1092,8 +1093,8 @@ void Map::saveExtraLayer() const
for (int y = 0; y < height; y ++)
{
const MapItem *const item = mSpecialLayer->getTile(x, y);
- if (item && item->mType != MapItem::EMPTY
- && item->mType != MapItem::HOME)
+ if (item && item->mType != MapItemType::EMPTY
+ && item->mType != MapItemType::HOME)
{
mapFile << x << " " << y << " "
<< static_cast<int>(item->mType) << " "
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
index 967b851a5..e035d88b3 100644
--- a/src/resources/map/mapitem.cpp
+++ b/src/resources/map/mapitem.cpp
@@ -26,6 +26,7 @@
#include "gui/fonts/font.h"
#include "resources/image.h"
+#include "resources/mapitemtype.h"
#include "resources/resourcemanager.h"
#include "render/graphics.h"
@@ -36,11 +37,11 @@ MapItem::MapItem():
mImage(nullptr),
mComment(),
mName(),
- mType(EMPTY),
+ mType(MapItemType::EMPTY),
mX(-1),
mY(-1)
{
- setType(EMPTY);
+ setType(MapItemType::EMPTY);
}
MapItem::MapItem(const int type):
@@ -95,16 +96,16 @@ void MapItem::setType(const int type)
switch (type)
{
- case ARROW_UP:
+ case MapItemType::ARROW_UP:
name = "graphics/sprites/arrow_up.png";
break;
- case ARROW_DOWN:
+ case MapItemType::ARROW_DOWN:
name = "graphics/sprites/arrow_down.png";
break;
- case ARROW_LEFT:
+ case MapItemType::ARROW_LEFT:
name = "graphics/sprites/arrow_left.png";
break;
- case ARROW_RIGHT:
+ case MapItemType::ARROW_RIGHT:
name = "graphics/sprites/arrow_right.png";
break;
default:
@@ -137,14 +138,14 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
switch (mType)
{
- case ROAD:
- case CROSS:
+ case MapItemType::ROAD:
+ case MapItemType::CROSS:
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::ROAD_POINT));
graphics->fillRectangle(Rect(x + dx / 3, y + dy / 3,
dx / 3, dy / 3));
break;
- case HOME:
+ case MapItemType::HOME:
{
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::HOME_PLACE));
@@ -157,7 +158,9 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
default:
break;
}
- if (!mName.empty() && mType != PORTAL && mType != EMPTY)
+ if (!mName.empty()
+ && mType != MapItemType::PORTAL
+ && mType != MapItemType::EMPTY)
{
Font *const font = gui->getFont();
if (font)
diff --git a/src/resources/map/mapitem.h b/src/resources/map/mapitem.h
index 3e92c536e..b83c26729 100644
--- a/src/resources/map/mapitem.h
+++ b/src/resources/map/mapitem.h
@@ -34,26 +34,6 @@ class MapItem final
friend class Map;
friend class MapLayer;
- enum ItemType
- {
- EMPTY = 0,
- HOME = 1,
- ROAD = 2,
- CROSS = 3,
- ARROW_UP = 4,
- ARROW_DOWN = 5,
- ARROW_LEFT = 6,
- ARROW_RIGHT = 7,
- PORTAL = 8,
- MUSIC = 9,
- ATTACK = 10,
- PRIORITY = 11,
- IGNORE_ = 12,
- PICKUP = 13,
- NOPICKUP = 14,
- SEPARATOR = 15
- };
-
MapItem();
explicit MapItem(const int type);
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index 97d3a8020..a5f2f056d 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -34,6 +34,7 @@
#include "render/graphics.h"
#include "resources/image.h"
+#include "resources/mapitemtype.h"
#include "resources/map/mapitem.h"
#include "resources/map/maprowvertexes.h"
@@ -488,13 +489,13 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
if (item1 || item2)
{
const int px2 = px1 + (x1 * mapTileSize);
- if (item1 && item1->mType != MapItem::EMPTY)
+ if (item1 && item1->mType != MapItemType::EMPTY)
{
item1->draw(graphics, px2, py1,
mapTileSize, mapTileSize);
}
- if (item2 && item2->mType != MapItem::EMPTY)
+ if (item2 && item2->mType != MapItemType::EMPTY)
{
item2->draw(graphics, px2, py1,
mapTileSize, mapTileSize);
diff --git a/src/resources/map/speciallayer.cpp b/src/resources/map/speciallayer.cpp
index 1c4662797..bd54affbd 100644
--- a/src/resources/map/speciallayer.cpp
+++ b/src/resources/map/speciallayer.cpp
@@ -20,6 +20,8 @@
#include "resources/map/speciallayer.h"
+#include "resources/mapitemtype.h"
+
#include "resources/map/mapconsts.h"
#include "resources/map/mapitem.h"
@@ -96,9 +98,9 @@ void SpecialLayer::addRoad(const Path &road)
const Position &pos = (*i);
MapItem *const item = getTile(pos.x, pos.y);
if (!item)
- setTile(pos.x, pos.y, new MapItem(MapItem::ROAD));
+ setTile(pos.x, pos.y, new MapItem(MapItemType::ROAD));
else
- item->setType(MapItem::ROAD);
+ item->setType(MapItemType::ROAD);
}
}
@@ -111,7 +113,7 @@ void SpecialLayer::clean() const
{
MapItem *const item = mTiles[f];
if (item)
- item->setType(MapItem::EMPTY);
+ item->setType(MapItemType::EMPTY);
}
}