From f2dba51be00b6c67b6d1b8924cac8019a3bcd000 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 May 2015 21:39:10 +0300 Subject: Add strong typed bool type Move. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/being/being.cpp | 9 +++++---- src/being/being.h | 4 +++- src/enums/simpletypes/move.h | 28 ++++++++++++++++++++++++++++ src/text.cpp | 5 +++-- src/text.h | 3 ++- 7 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 src/enums/simpletypes/move.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ca9bf2d0b..9d4934b16 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1068,6 +1068,7 @@ SET(SRCS enums/simpletypes/keep.h enums/simpletypes/modal.h enums/simpletypes/modifiable.h + enums/simpletypes/move.h enums/simpletypes/notify.h enums/simpletypes/npcnames.h enums/simpletypes/online.h diff --git a/src/Makefile.am b/src/Makefile.am index 44c4d1750..e97f60e9e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1197,6 +1197,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ enums/simpletypes/keep.h \ enums/simpletypes/modal.h \ enums/simpletypes/modifiable.h \ + enums/simpletypes/move.h \ enums/simpletypes/notify.h \ enums/simpletypes/npcnames.h \ enums/simpletypes/online.h \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 9c820f0c5..a4ffbbf3f 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -117,7 +117,7 @@ bool Being::mShowLevel = false; bool Being::mShowPlayersStatus = false; bool Being::mEnableReorderSprites = true; bool Being::mHideErased = false; -bool Being::mMoveNames = false; +Move Being::mMoveNames = Move_false; bool Being::mUseDiagonal = true; int Being::mAwayEffect = -1; @@ -457,8 +457,9 @@ void Being::setPosition(const Vector &pos) if (mText) { - mText->adviseXY(static_cast(pos.x), static_cast(pos.y) - - getHeight() - mText->getHeight() - 6, mMoveNames); + mText->adviseXY(static_cast(pos.x), + static_cast(pos.y) - getHeight() - mText->getHeight() - 6, + mMoveNames); } } @@ -2333,7 +2334,7 @@ void Being::reReadConfig() mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); mEnableReorderSprites = config.getBoolValue("enableReorderSprites"); mHideErased = config.getBoolValue("hideErased"); - mMoveNames = config.getBoolValue("moveNames"); + mMoveNames = fromBool(config.getBoolValue("moveNames"), Move); mUseDiagonal = config.getBoolValue("useDiagonalSpeed"); mUpdateConfigTime = cur_time; diff --git a/src/being/being.h b/src/being/being.h index 6fb26b620..03a69b986 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -23,6 +23,8 @@ #ifndef BEING_BEING_H #define BEING_BEING_H +#include "enums/simpletypes/move.h" + #include "resources/beinginfo.h" #include "position.h" @@ -1079,7 +1081,7 @@ class Being notfinal : public ActorSprite, static bool mShowPlayersStatus; static bool mEnableReorderSprites; static bool mHideErased; - static bool mMoveNames; + static Move mMoveNames; static bool mUseDiagonal; static int mAwayEffect; diff --git a/src/enums/simpletypes/move.h b/src/enums/simpletypes/move.h new file mode 100644 index 000000000..95c2ff4a0 --- /dev/null +++ b/src/enums/simpletypes/move.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 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 . + */ + +#ifndef ENUMS_SIMPLETYPES_MOVE_H +#define ENUMS_SIMPLETYPES_MOVE_H + +#include "enums/simpletypes/simpledefines.h" + +defBoolEnum(Move); + +#endif // ENUMS_SIMPLETYPES_MOVE_H diff --git a/src/text.cpp b/src/text.cpp index bec055f60..8dca7d366 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -134,9 +134,10 @@ void Text::setColor(const Color *const color) } } -void Text::adviseXY(const int x, const int y, const bool move) +void Text::adviseXY(const int x, const int y, + const Move move) { - if (textManager && move) + if (textManager && move == Move_true) { textManager->moveText(this, x - mXOffset, y); } diff --git a/src/text.h b/src/text.h index 916de924e..fc9b0f08c 100644 --- a/src/text.h +++ b/src/text.h @@ -24,6 +24,7 @@ #ifndef TEXT_H #define TEXT_H +#include "enums/simpletypes/move.h" #include "enums/simpletypes/speech.h" #include "gui/fonts/textchunk.h" @@ -67,7 +68,7 @@ class Text notfinal /** * Allows the originator of the text to specify the ideal coordinates. */ - void adviseXY(const int x, const int y, const bool move); + void adviseXY(const int x, const int y, const Move move); /** * Draws the text. -- cgit v1.2.3-70-g09d2