summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-18 21:23:47 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-18 21:23:47 +0300
commit2f548dd7865863a8cc774d485bef30bfc9b50b6d (patch)
tree5c0bb522b5f5ddd2171cdbe64127122c23d57f82
parente9c0ad590dc46f70e0ab8f48b4fa3c0532314d7f (diff)
downloadmanaverse-2f548dd7865863a8cc774d485bef30bfc9b50b6d.tar.gz
manaverse-2f548dd7865863a8cc774d485bef30bfc9b50b6d.tar.bz2
manaverse-2f548dd7865863a8cc774d485bef30bfc9b50b6d.tar.xz
manaverse-2f548dd7865863a8cc774d485bef30bfc9b50b6d.zip
improve questswindow class.
-rw-r--r--src/gui/questswindow.cpp30
-rw-r--r--src/gui/questswindow.h11
2 files changed, 13 insertions, 28 deletions
diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp
index 639d4c358..541768fa7 100644
--- a/src/gui/questswindow.cpp
+++ b/src/gui/questswindow.cpp
@@ -56,7 +56,7 @@ enum QuestType
struct QuestItemText final
{
- QuestItemText(std::string text0, const int type0) :
+ QuestItemText(const std::string &text0, const int type0) :
text(text0), type(type0)
{
}
@@ -247,7 +247,7 @@ void QuestsWindow::loadXml()
void QuestsWindow::loadQuest(const int var, const XmlNodePtr node)
{
- QuestItem *quest = new QuestItem();
+ QuestItem *const quest = new QuestItem();
// TRANSLATORS: quests window quest name
quest->name = XML::langProperty(node, "name", _("unknown"));
quest->group = XML::getProperty(node, "group", "");
@@ -293,7 +293,6 @@ void QuestsWindow::loadQuest(const int var, const XmlNodePtr node)
void QuestsWindow::loadEffect(const int var, const XmlNodePtr node)
{
QuestEffect *const effect = new QuestEffect;
-
effect->map = XML::getProperty(node, "map", "");
effect->id = XML::getProperty(node, "npc", -1);
effect->effectId = XML::getProperty(node, "effect", -1);
@@ -416,33 +415,27 @@ void QuestsWindow::rebuild(const bool playSound)
}
FOR_EACH (std::vector<QuestItem*>::const_iterator, it, hidden)
- {
- QuestItem *const quest = *it;
- quest->completeFlag = -1;
- }
+ (*it)->completeFlag = -1;
- if (updatedQuest == -1)
- updatedQuest = static_cast<int>(mQuestLinks.size() - 1);
- else if (updatedQuest >= static_cast<int>(mQuestLinks.size()))
+ if (updatedQuest == -1 || updatedQuest >= static_cast<int>(
+ mQuestLinks.size()))
+ {
updatedQuest = static_cast<int>(mQuestLinks.size() - 1);
+ }
if (updatedQuest >= 0)
{
mQuestsListBox->setSelected(updatedQuest);
showQuest(mQuestLinks[updatedQuest]);
- if (playSound)
+ if (playSound && effectManager)
{
switch (newCompleteStatus)
{
case 0:
- if (effectManager)
- effectManager->trigger(mNewQuestEffectId, player_node);
+ effectManager->trigger(mNewQuestEffectId, player_node);
break;
case 1:
- if (effectManager)
- {
- effectManager->trigger(mCompleteQuestEffectId,
- player_node);
- }
+ effectManager->trigger(mCompleteQuestEffectId,
+ player_node);
break;
default:
break;
@@ -487,7 +480,6 @@ void QuestsWindow::setMap(const Map *const map)
return;
const std::string name = mMap->getProperty("shortName");
- logger->log("current map: " + name);
FOR_EACH (std::vector<QuestEffect*>::const_iterator, it, mAllEffects)
{
const QuestEffect *const effect = *it;
diff --git a/src/gui/questswindow.h b/src/gui/questswindow.h
index 8872189cb..c38522172 100644
--- a/src/gui/questswindow.h
+++ b/src/gui/questswindow.h
@@ -47,23 +47,16 @@ struct QuestItem;
typedef std::map<int, const QuestEffect*> NpcQuestEffectMap;
typedef NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter;
-class QuestsWindow final : public Window, public gcn::ActionListener
+class QuestsWindow final : public Window,
+ public gcn::ActionListener
{
public:
- /**
- * Constructor.
- *
- * @see Window::Window
- */
QuestsWindow();
A_DELETE_COPY(QuestsWindow)
~QuestsWindow();
- /**
- * Called when receiving actions from the widgets.
- */
void action(const gcn::ActionEvent &event) override;
void updateQuest(const int var, const int val);