summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-19 18:29:03 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-19 18:29:03 +0300
commit7b6b389fe156b8ff1fc1f35ee776a2e65f160921 (patch)
tree81e893b9e57ff483492df3dd4b645157a02173b3 /src/resources
parentf3fdd048e6265ab2c6e88ddff21dffd9409c03db (diff)
downloadmanaplus-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.tar.gz
manaplus-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.tar.bz2
manaplus-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.tar.xz
manaplus-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.zip
Move mapitemtype into separate file.
Diffstat (limited to 'src/resources')
-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
-rw-r--r--src/resources/mapitemtype.h47
-rw-r--r--src/resources/mapreader.cpp7
7 files changed, 79 insertions, 44 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);
}
}
diff --git a/src/resources/mapitemtype.h b/src/resources/mapitemtype.h
new file mode 100644
index 000000000..34bb1744a
--- /dev/null
+++ b/src/resources/mapitemtype.h
@@ -0,0 +1,47 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_MAPITEMTYPE_H
+#define RESOURCES_MAPITEMTYPE_H
+
+namespace MapItemType
+{
+ enum Type
+ {
+ 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
+ };
+} // namespace MapItemType
+
+#endif // RESOURCES_MAPITEMTYPE_H
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 6a15555d9..cc8b14a30 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -36,6 +36,7 @@
#include "resources/animation.h"
#include "resources/beingcommon.h"
#include "resources/image.h"
+#include "resources/mapitemtype.h"
#include "resources/resourcemanager.h"
#include "resources/db/mapdb.h"
@@ -422,17 +423,17 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path)
map->addParticleEffect(warpPath,
objX, objY, objW, objH);
}
- map->addPortal(objName, MapItem::PORTAL,
+ map->addPortal(objName, MapItemType::PORTAL,
objX, objY, objW, objH);
}
else if (objType == "SPAWN")
{
-// map->addPortal(_("Spawn: ") + objName, MapItem::PORTAL,
+// map->addPortal(_("Spawn: ") + objName, MapItemType::PORTAL,
// objX, objY, objW, objH);
}
else if (objType == "MUSIC")
{
- map->addRange(objName, MapItem::MUSIC,
+ map->addRange(objName, MapItemType::MUSIC,
objX, objY, objW, objH);
}
else