summaryrefslogtreecommitdiff
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
parentf3fdd048e6265ab2c6e88ddff21dffd9409c03db (diff)
downloadmv-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.tar.gz
mv-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.tar.bz2
mv-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.tar.xz
mv-7b6b389fe156b8ff1fc1f35ee776a2e65f160921.zip
Move mapitemtype into separate file.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/localplayer.cpp35
-rw-r--r--src/gui/popups/popupmenu.cpp11
-rw-r--r--src/gui/viewport.cpp4
-rw-r--r--src/gui/widgets/avatarlistbox.cpp19
-rw-r--r--src/gui/widgets/tabs/socialtabbase.h6
-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
14 files changed, 122 insertions, 78 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index db6655678..b5e0e47b9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -563,6 +563,7 @@ SET(SRCS
resources/db/moddb.cpp
resources/db/moddb.h
resources/mapinfo.h
+ resources/mapitemtype.h
resources/mapreader.cpp
resources/mapreader.h
resources/modinfo.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index bffceb704..51af85cf9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -672,6 +672,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
resources/db/moddb.cpp \
resources/db/moddb.h \
resources/mapinfo.h \
+ resources/mapitemtype.h \
resources/mapreader.cpp \
resources/mapreader.h \
resources/modinfo.cpp \
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index ea35660d8..4e6b7615e 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -68,6 +68,7 @@
#include "resources/iteminfo.h"
#include "resources/itemslot.h"
+#include "resources/mapitemtype.h"
#include "resources/db/emotedb.h"
#include "resources/db/weaponsdb.h"
@@ -2810,7 +2811,7 @@ void LocalPlayer::setHome()
if (iter != mHomes.end() && mX == static_cast<int>(pos.x)
&& mY == static_cast<int>(pos.y))
{
- mMap->updatePortalTile("", MapItem::EMPTY,
+ mMap->updatePortalTile("", MapItemType::EMPTY,
static_cast<int>(pos.x), static_cast<int>(pos.y));
mHomes.erase(key);
@@ -2822,13 +2823,13 @@ void LocalPlayer::setHome()
if (iter != mHomes.end())
{
specialLayer->setTile(static_cast<int>(pos.x),
- static_cast<int>(pos.y), MapItem::EMPTY);
+ static_cast<int>(pos.y), MapItemType::EMPTY);
}
pos.x = static_cast<float>(mX);
pos.y = static_cast<float>(mY);
mHomes[key] = pos;
- mMap->updatePortalTile("home", MapItem::HOME,
+ mMap->updatePortalTile("home", MapItemType::HOME,
mX, mY);
socialWindow->addPortal(mX, mY);
}
@@ -2853,24 +2854,24 @@ void LocalPlayer::setHome()
saveHomes();
}
- if (!mapItem || mapItem->getType() == MapItem::EMPTY)
+ if (!mapItem || mapItem->getType() == MapItemType::EMPTY)
{
if (mDirection & BeingDirection::UP)
- type = MapItem::ARROW_UP;
+ type = MapItemType::ARROW_UP;
else if (mDirection & BeingDirection::LEFT)
- type = MapItem::ARROW_LEFT;
+ type = MapItemType::ARROW_LEFT;
else if (mDirection & BeingDirection::DOWN)
- type = MapItem::ARROW_DOWN;
+ type = MapItemType::ARROW_DOWN;
else if (mDirection & BeingDirection::RIGHT)
- type = MapItem::ARROW_RIGHT;
+ type = MapItemType::ARROW_RIGHT;
}
else
{
- type = MapItem::EMPTY;
+ type = MapItemType::EMPTY;
}
mMap->updatePortalTile("", type, mX, mY);
- if (type != MapItem::EMPTY)
+ if (type != MapItemType::EMPTY)
{
socialWindow->addPortal(mX, mY);
mapItem = specialLayer->getTile(mX, mY);
@@ -2883,7 +2884,7 @@ void LocalPlayer::setHome()
}
else
{
- specialLayer->setTile(mX, mY, MapItem::EMPTY);
+ specialLayer->setTile(mX, mY, MapItemType::EMPTY);
socialWindow->removePortal(mX, mY);
}
}
@@ -3138,7 +3139,7 @@ void LocalPlayer::updateCoords()
if (mMap)
{
std::string str = mMap->getObjectData(mX, mY,
- MapItem::MUSIC);
+ MapItemType::MUSIC);
if (str.empty())
str = mMap->getMusicFile();
if (str != soundManager.getCurrentMusicFile())
@@ -3592,16 +3593,16 @@ void LocalPlayer::setRealPos(const int x, const int y)
if ((mCrossX || mCrossY)
&& layer->getTile(mCrossX, mCrossY)
- && layer->getTile(mCrossX, mCrossY)->getType() == MapItem::CROSS)
+ && layer->getTile(mCrossX, mCrossY)->getType() == MapItemType::CROSS)
{
- layer->setTile(mCrossX, mCrossY, MapItem::EMPTY);
+ layer->setTile(mCrossX, mCrossY, MapItemType::EMPTY);
}
if (mShowServerPos && (!layer->getTile(x, y)
- || layer->getTile(x, y)->getType() == MapItem::EMPTY))
+ || layer->getTile(x, y)->getType() == MapItemType::EMPTY))
{
if (getTileX() != x && getTileY() != y)
- layer->setTile(x, y, MapItem::CROSS);
+ layer->setTile(x, y, MapItemType::CROSS);
}
mCrossX = x;
@@ -3657,7 +3658,7 @@ void LocalPlayer::updateNavigateList()
const Vector &pos = mHomes[(*iter).first];
if (pos.x && pos.y)
{
- mMap->addPortalTile("home", MapItem::HOME,
+ mMap->addPortalTile("home", MapItemType::HOME,
static_cast<int>(pos.x), static_cast<int>(pos.y));
}
}
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 7e9925039..00cae3ee3 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -76,6 +76,7 @@
#include "net/tradehandler.h"
#include "resources/iteminfo.h"
+#include "resources/mapitemtype.h"
#include "resources/skillconsts.h"
#include "resources/map/map.h"
@@ -1356,11 +1357,11 @@ void PopupMenu::handleLink(const std::string &link,
if (specialLayer)
{
const bool isHome = (mMapItem->getType()
- == static_cast<int>(MapItem::HOME));
+ == static_cast<int>(MapItemType::HOME));
const int x = static_cast<const int>(mMapItem->getX());
const int y = static_cast<const int>(mMapItem->getY());
specialLayer->setTile(x, y,
- static_cast<int>(MapItem::EMPTY));
+ static_cast<int>(MapItemType::EMPTY));
if (socialWindow)
socialWindow->removePortal(x, y);
if (isHome && player_node)
@@ -2284,7 +2285,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
}
switch (type)
{
- case MapItem::ATTACK:
+ case MapItemType::ATTACK:
{
const int idx = actorManager->getAttackMobIndex(name);
const int size = actorManager->getAttackMobsSize();
@@ -2302,7 +2303,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
}
break;
}
- case MapItem::PRIORITY:
+ case MapItemType::PRIORITY:
{
const int idx = actorManager->
getPriorityAttackMobIndex(name);
@@ -2321,7 +2322,7 @@ void PopupMenu::showAttackMonsterPopup(const int x, const int y,
}
break;
}
- case MapItem::IGNORE_:
+ case MapItemType::IGNORE_:
break;
default:
break;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index b6d805b11..fbe056d2a 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -28,6 +28,8 @@
#include "sdlshared.h"
#include "textmanager.h"
+#include "resources/mapitemtype.h"
+
#include "resources/map/map.h"
#include "resources/map/mapitem.h"
#include "resources/map/maptype.h"
@@ -928,7 +930,7 @@ void Viewport::mouseMoved(MouseEvent &event A_UNUSED)
/ mMap->getTileHeight();
mHoverSign = specialLayer->getTile(mouseTileX, mouseTileY);
- if (mHoverSign && mHoverSign->getType() != MapItem::EMPTY)
+ if (mHoverSign && mHoverSign->getType() != MapItemType::EMPTY)
{
if (!mHoverSign->getComment().empty())
{
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 4bbc85a94..41a190daa 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -38,6 +38,7 @@
#include "gui/windows/chatwindow.h"
#include "resources/image.h"
+#include "resources/mapitemtype.h"
#include "resources/map/map.h"
#include "resources/map/mapitem.h"
@@ -128,7 +129,7 @@ void AvatarListBox::draw(Graphics *graphics)
if (!a)
continue;
- if (a->getType() != MapItem::SEPARATOR)
+ if (a->getType() != MapItemType::SEPARATOR)
{
// Draw online status
const Image *const icon = a->getOnline()
@@ -286,7 +287,7 @@ void AvatarListBox::draw(Graphics *graphics)
// Draw Name
if (a->getDisplayBold())
{
- if (a->getType() == MapItem::SEPARATOR)
+ if (a->getType() == MapItemType::SEPARATOR)
{
boldFont->drawString(graphics, text,
mImagePadding + mPadding, y + mPadding);
@@ -299,7 +300,7 @@ void AvatarListBox::draw(Graphics *graphics)
}
else
{
- if (a->getType() == MapItem::SEPARATOR)
+ if (a->getType() == MapItemType::SEPARATOR)
{
font->drawString(graphics, text, mImagePadding + mPadding,
y + mPadding);
@@ -363,7 +364,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
switch (ava->getType())
{
// AVATAR_PLAYER
- case MapItem::EMPTY:
+ case MapItemType::EMPTY:
{
const Avatar *const avatar = model->getAvatarAt(selected);
if (avatar)
@@ -377,9 +378,9 @@ void AvatarListBox::mousePressed(MouseEvent &event)
}
break;
}
- case MapItem::ATTACK:
- case MapItem::PRIORITY:
- case MapItem::IGNORE_:
+ case MapItemType::ATTACK:
+ case MapItemType::PRIORITY:
+ case MapItemType::IGNORE_:
{
std::string name;
if (model->getAvatarAt(selected)->getLevel() == 0)
@@ -391,8 +392,8 @@ void AvatarListBox::mousePressed(MouseEvent &event)
model->getAvatarAt(selected)->getType());
break;
}
- case MapItem::PICKUP:
- case MapItem::NOPICKUP:
+ case MapItemType::PICKUP:
+ case MapItemType::NOPICKUP:
{
std::string name;
if (model->getAvatarAt(selected)->getLevel() == 0)
diff --git a/src/gui/widgets/tabs/socialtabbase.h b/src/gui/widgets/tabs/socialtabbase.h
index 6a64ad9f0..d15f39a6c 100644
--- a/src/gui/widgets/tabs/socialtabbase.h
+++ b/src/gui/widgets/tabs/socialtabbase.h
@@ -23,6 +23,8 @@
#include "actormanager.h"
+#include "resources/mapitemtype.h"
+
#include "resources/map/mapitem.h"
#define addAvatars(mob, str, type) \
@@ -30,7 +32,7 @@
ava = new Avatar(str);\
ava->setOnline(false);\
ava->setLevel(-1);\
- ava->setType(MapItem::SEPARATOR);\
+ ava->setType(MapItemType::SEPARATOR);\
ava->setX(0);\
ava->setY(0);\
avatars->push_back(ava);\
@@ -53,7 +55,7 @@
ava = new Avatar(name);\
ava->setOnline(true);\
ava->setLevel(level);\
- ava->setType(MapItem::type);\
+ ava->setType(MapItemType::type);\
ava->setX(0);\
ava->setY(0);\
avatars->push_back(ava);\
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