summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-29 21:56:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-30 00:03:20 +0300
commitd0a72be7362cfad41187b6e9544ac44802a66ebd (patch)
tree76ca7130307a6f9b9b648ffd019fe0bba5cfda67
parente2c1b87e38e5c921912b334ca971e92b7989f8a8 (diff)
downloadManaVerse-d0a72be7362cfad41187b6e9544ac44802a66ebd.tar.gz
ManaVerse-d0a72be7362cfad41187b6e9544ac44802a66ebd.tar.bz2
ManaVerse-d0a72be7362cfad41187b6e9544ac44802a66ebd.tar.xz
ManaVerse-d0a72be7362cfad41187b6e9544ac44802a66ebd.zip
Remove basic attributes usage from generalhandler and move to statuswindow and statdb.
-rw-r--r--src/gui/windows/statuswindow.cpp15
-rw-r--r--src/gui/windows/statuswindow.h2
-rw-r--r--src/net/eathena/generalhandler.cpp19
-rw-r--r--src/net/tmwa/generalhandler.cpp20
-rw-r--r--src/resources/basicstat.h14
-rw-r--r--src/resources/db/statdb.cpp48
6 files changed, 67 insertions, 51 deletions
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index cc50c719e..f4ca38195 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -49,6 +49,8 @@
#include "net/playerhandler.h"
#include "net/serverfeatures.h"
+#include "resources/db/statdb.h"
+
#include "resources/item/item.h"
#include "utils/delete2.h"
@@ -228,6 +230,19 @@ StatusWindow::StatusWindow() :
updateLevelLabel();
}
+void StatusWindow::addBasicAttributes()
+{
+ const std::vector<BasicStat> &stats = StatDb::getExtraStats();
+ FOR_EACH (std::vector<BasicStat>::const_iterator, it, stats)
+ {
+ const BasicStat &stat = *it;
+ addAttribute(stat.attr,
+ stat.name,
+ stat.tag,
+ Modifiable_true);
+ }
+}
+
void StatusWindow::updateLevelLabel()
{
if (localPlayer && localPlayer->isGM())
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index 00b468d07..a11ea62b4 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -99,6 +99,8 @@ class StatusWindow final : public Window,
void updateLevelLabel();
+ void addBasicAttributes();
+
private:
static std::string translateLetter(const char *const letters);
static std::string translateLetter2(const std::string &letters);
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index fb78e800f..029b7123a 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -200,24 +200,7 @@ void GeneralHandler::gameStarted() const
// protection against double addition attributes.
statusWindow->clearAttributes();
- statusWindow->addAttribute(Attributes::STR,
- // TRANSLATORS: player stat
- _("Strength"), "str", Modifiable_true);
- statusWindow->addAttribute(Attributes::AGI,
- // TRANSLATORS: player stat
- _("Agility"), "agi", Modifiable_true);
- statusWindow->addAttribute(Attributes::VIT,
- // TRANSLATORS: player stat
- _("Vitality"), "vit", Modifiable_true);
- statusWindow->addAttribute(Attributes::INT,
- // TRANSLATORS: player stat
- _("Intelligence"), "int", Modifiable_true);
- statusWindow->addAttribute(Attributes::DEX,
- // TRANSLATORS: player stat
- _("Dexterity"), "dex", Modifiable_true);
- statusWindow->addAttribute(Attributes::LUK,
- // TRANSLATORS: player stat
- _("Luck"), "luk", Modifiable_true);
+ statusWindow->addBasicAttributes();
// TRANSLATORS: player stat
statusWindow->addAttribute(Attributes::ATK, _("Attack"));
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 390c2d021..f7515de02 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -211,24 +211,8 @@ void GeneralHandler::gameStarted() const
// protection against double addition attributes.
statusWindow->clearAttributes();
- statusWindow->addAttribute(Attributes::STR,
- // TRANSLATORS: player stat
- _("Strength"), "str", Modifiable_true);
- statusWindow->addAttribute(Attributes::AGI,
- // TRANSLATORS: player stat
- _("Agility"), "agi", Modifiable_true);
- statusWindow->addAttribute(Attributes::VIT,
- // TRANSLATORS: player stat
- _("Vitality"), "vit", Modifiable_true);
- statusWindow->addAttribute(Attributes::INT,
- // TRANSLATORS: player stat
- _("Intelligence"), "int", Modifiable_true);
- statusWindow->addAttribute(Attributes::DEX,
- // TRANSLATORS: player stat
- _("Dexterity"), "dex", Modifiable_true);
- statusWindow->addAttribute(Attributes::LUK,
- // TRANSLATORS: player stat
- _("Luck"), "luk", Modifiable_true);
+ statusWindow->addBasicAttributes();
+
// TRANSLATORS: player stat
statusWindow->addAttribute(Attributes::ATK, _("Attack"));
// TRANSLATORS: player stat
diff --git a/src/resources/basicstat.h b/src/resources/basicstat.h
index 598e9dc8b..a57581ffe 100644
--- a/src/resources/basicstat.h
+++ b/src/resources/basicstat.h
@@ -23,20 +23,28 @@
#ifndef RESOURCES_BASICSTAT_H
#define RESOURCES_BASICSTAT_H
+#include "enums/being/attributes.h"
+
#include <string>
#include "localconsts.h"
struct BasicStat final
{
- BasicStat(const std::string &tag0,
- const std::string &format0) :
+ BasicStat(const AttributesT attr0,
+ const std::string &tag0,
+ const std::string &name0,
+ const std::string &format0) :
tag(tag0),
- format(format0)
+ name(name0),
+ format(format0),
+ attr(attr0)
{}
std::string tag;
+ std::string name;
std::string format;
+ AttributesT attr;
};
#endif // RESOURCES_BASICSTAT_H
diff --git a/src/resources/db/statdb.cpp b/src/resources/db/statdb.cpp
index 0d25b07dd..36748c476 100644
--- a/src/resources/db/statdb.cpp
+++ b/src/resources/db/statdb.cpp
@@ -41,18 +41,42 @@ namespace
void StatDb::addBasicStats()
{
- // TRANSLATORS: player stat
- mBasicStats.push_back(BasicStat("str", _("Strength %s")));
- // TRANSLATORS: player stat
- mBasicStats.push_back(BasicStat("agi", _("Agility %s")));
- // TRANSLATORS: player stat
- mBasicStats.push_back(BasicStat("vit", _("Vitality %s")));
- // TRANSLATORS: player stat
- mBasicStats.push_back(BasicStat("int", _("Intelligence %s")));
- // TRANSLATORS: player stat
- mBasicStats.push_back(BasicStat("dex", _("Dexterity %s")));
- // TRANSLATORS: player stat
- mBasicStats.push_back(BasicStat("luck", _("Luck %s")));
+ mBasicStats.push_back(BasicStat(Attributes::STR,
+ "str",
+ // TRANSLATORS: player stat
+ _("Strength"),
+ // TRANSLATORS: player stat
+ _("Strength %s")));
+ mBasicStats.push_back(BasicStat(Attributes::AGI,
+ "agi",
+ // TRANSLATORS: player stat
+ _("Agility"),
+ // TRANSLATORS: player stat
+ _("Agility %s")));
+ mBasicStats.push_back(BasicStat(Attributes::VIT,
+ "vit",
+ // TRANSLATORS: player stat
+ _("Vitality"),
+ // TRANSLATORS: player stat
+ _("Vitality %s")));
+ mBasicStats.push_back(BasicStat(Attributes::INT,
+ "int",
+ // TRANSLATORS: player stat
+ _("Intelligence"),
+ // TRANSLATORS: player stat
+ _("Intelligence %s")));
+ mBasicStats.push_back(BasicStat(Attributes::DEX,
+ "dex",
+ // TRANSLATORS: player stat
+ _("Dexterity"),
+ // TRANSLATORS: player stat
+ _("Dexterity %s")));
+ mBasicStats.push_back(BasicStat(Attributes::LUK,
+ "luk",
+ // TRANSLATORS: player stat
+ _("Luck"),
+ // TRANSLATORS: player stat
+ _("Luck %s")));
}
const std::vector<BasicStat> &StatDb::getExtraStats()