summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/textcommandtype.h33
-rw-r--r--src/gui/windows/textcommandeditor.cpp11
-rw-r--r--src/spellmanager.cpp7
-rw-r--r--src/textcommand.cpp6
-rw-r--r--src/textcommand.h7
7 files changed, 49 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b5a1ee9f9..7100e9ef5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1100,6 +1100,7 @@ SET(SRCS
sprite.h
enums/screendensity.h
enums/state.h
+ enums/textcommandtype.h
enums/simpletypes/allowsort.h
enums/simpletypes/allplayers.h
enums/simpletypes/autorelease.h
diff --git a/src/Makefile.am b/src/Makefile.am
index bbdcdd6b6..148ae595d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -559,6 +559,7 @@ SRC += events/actionevent.h \
settings.h \
enums/screendensity.h \
enums/state.h \
+ enums/textcommandtype.h \
enums/simpletypes/allowsort.h \
enums/simpletypes/allplayers.h \
enums/simpletypes/autorelease.h \
diff --git a/src/enums/textcommandtype.h b/src/enums/textcommandtype.h
new file mode 100644
index 000000000..4557ca671
--- /dev/null
+++ b/src/enums/textcommandtype.h
@@ -0,0 +1,33 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_TEXTCOMMANDTYPE_H
+#define ENUMS_TEXTCOMMANDTYPE_H
+
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(TextCommandType)
+{
+ Magic = 0,
+ Text = 1
+}
+enumEnd(TextCommandType);
+
+#endif // ENUMS_TEXTCOMMANDTYPE_H
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index 32cc0959f..115a3bace 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -47,7 +47,8 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
Window(_("Command Editor"), Modal_false, nullptr, "commandeditor.xml"),
ActionListener(),
mIsMagicCommand(command ?
- (command->getCommandType() == TEXT_COMMAND_MAGIC) : false),
+ (command->getCommandType() == TextCommandType::Magic) :
+ false),
mCommand(command),
// TRANSLATORS: command editor button
mIsMagic(new RadioButton(this, _("magic"), "magic", mIsMagicCommand)),
@@ -131,7 +132,7 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
if (command)
{
- if (command->getCommandType() == TEXT_COMMAND_MAGIC)
+ if (command->getCommandType() == TextCommandType::Magic)
showControls(Visible_true);
else
showControls(Visible_false);
@@ -252,9 +253,9 @@ void TextCommandEditor::scheduleDelete()
void TextCommandEditor::save()
{
if (mIsMagicCommand)
- mCommand->setCommandType(TEXT_COMMAND_MAGIC);
+ mCommand->setCommandType(TextCommandType::Magic);
else
- mCommand->setCommandType(TEXT_COMMAND_TEXT);
+ mCommand->setCommandType(TextCommandType::Text);
mCommand->setSymbol(mSymbolTextField->getText());
mCommand->setCommand(mCommandTextField->getText());
@@ -273,7 +274,7 @@ void TextCommandEditor::save()
void TextCommandEditor::deleteCommand()
{
- mCommand->setCommandType(TEXT_COMMAND_TEXT);
+ mCommand->setCommandType(TextCommandType::Text);
mCommand->setSymbol("");
mCommand->setCommand("");
mCommand->setComment("");
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index 9409c6c1c..4383f9331 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -134,7 +134,7 @@ void SpellManager::invoke(const int spellId) const
if (!playerHandler || spell->getCommand().empty())
return;
- if (spell->getCommandType() == TEXT_COMMAND_TEXT
+ if (spell->getCommandType() == TextCommandType::Text
|| (playerHandler->canUseMagic()
&& PlayerInfo::getSkillLevel(static_cast<int>(MagicSchool::SkillMagic))
>= static_cast<signed>(spell->getBaseLvl())
@@ -148,7 +148,7 @@ void SpellManager::invoke(const int spellId) const
invokeSpell(spell);
}
if ((target && (target->getType() != ActorType::Monster
- || spell->getCommandType() == TEXT_COMMAND_TEXT))
+ || spell->getCommandType() == TextCommandType::Text))
&& (spell->getTargetType() == CommandTarget::AllowTarget
|| spell->getTargetType() == CommandTarget::NeedTarget))
{
@@ -284,7 +284,8 @@ void SpellManager::load(const bool oldConfig)
std::string icon = cfg->getValue("commandShortcutIcon"
+ toString(i), "");
- if (static_cast<TextCommandType>(commandType) == TEXT_COMMAND_MAGIC)
+ if (static_cast<TextCommandType>(commandType) ==
+ TextCommandType::Magic)
{
addSpell(new TextCommand(i, symbol, cmd, comment,
static_cast<CommandTargetT>(targetType), icon, basicLvl,
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index baca21090..04d479ece 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -54,7 +54,7 @@ TextCommand::TextCommand(const unsigned int id,
mSchool(school),
mBaseLvl(basicLvl),
mSchoolLvl(schoolLvl),
- mCommandType(TEXT_COMMAND_MAGIC),
+ mCommandType(TextCommandType::Magic),
mImage(nullptr)
{
loadImage();
@@ -75,7 +75,7 @@ TextCommand::TextCommand(const unsigned int id, const std::string &symbol,
mSchool(MagicSchool::SkillMagic),
mBaseLvl(0),
mSchoolLvl(0),
- mCommandType(TEXT_COMMAND_TEXT),
+ mCommandType(TextCommandType::Text),
mImage(nullptr)
{
loadImage();
@@ -92,7 +92,7 @@ TextCommand::TextCommand(const unsigned int id) :
mSchool(MagicSchool::SkillMagic),
mBaseLvl(0),
mSchoolLvl(0),
- mCommandType(TEXT_COMMAND_TEXT),
+ mCommandType(TextCommandType::Text),
mImage(nullptr)
{
loadImage();
diff --git a/src/textcommand.h b/src/textcommand.h
index d09a1b9be..cf7df586a 100644
--- a/src/textcommand.h
+++ b/src/textcommand.h
@@ -25,6 +25,7 @@
#include "enums/commandtarget.h"
#include "enums/magicschool.h"
+#include "enums/textcommandtype.h"
#include <string>
@@ -34,12 +35,6 @@ const unsigned int MAGIC_START_ID = 340;
class Image;
-enum TextCommandType
-{
- TEXT_COMMAND_MAGIC = 0,
- TEXT_COMMAND_TEXT = 1
-};
-
/**
* Represents one or more instances of a certain item type.
*/