summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-15 12:18:28 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-15 12:18:28 +0300
commitf4af4cc1e21d95c6fed8245466bb589dbd7900b7 (patch)
tree8f4b374bc6034a594d6fa33a81ba2e1d900f196b
parent36a45d61e46b785a7f24597ff8ebbd3fe83b8c73 (diff)
downloadplus-f4af4cc1e21d95c6fed8245466bb589dbd7900b7.tar.gz
plus-f4af4cc1e21d95c6fed8245466bb589dbd7900b7.tar.bz2
plus-f4af4cc1e21d95c6fed8245466bb589dbd7900b7.tar.xz
plus-f4af4cc1e21d95c6fed8245466bb589dbd7900b7.zip
Show better stats line in chat from status window.
-rw-r--r--src/gui/statuswindow.cpp37
-rw-r--r--src/gui/statuswindow.h5
-rw-r--r--src/net/eathena/generalhandler.cpp37
-rw-r--r--src/net/tmwa/generalhandler.cpp37
4 files changed, 67 insertions, 49 deletions
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 691333703..d8974fce8 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -77,12 +77,17 @@ class AttrDisplay : public Container
return mValue->getCaption();
}
+ const std::string &getShortName() const
+ { return mShortName; }
+
protected:
AttrDisplay(const Widget2 *const widget,
- const int id, const std::string &name);
+ const int id, const std::string &name,
+ const std::string &shortName);
const int mId;
const std::string mName;
+ const std::string mShortName;
LayoutHelper *mLayout;
Label *mLabel;
@@ -93,7 +98,8 @@ class DerDisplay final : public AttrDisplay
{
public:
DerDisplay(const Widget2 *const widget,
- const int id, const std::string &name);
+ const int id, const std::string &name,
+ const std::string &shortName);
A_DELETE_COPY(DerDisplay)
@@ -105,7 +111,8 @@ class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
{
public:
ChangeDisplay(const Widget2 *const widget,
- const int id, const std::string &name);
+ const int id, const std::string &name,
+ const std::string &shortName);
A_DELETE_COPY(ChangeDisplay)
@@ -436,6 +443,7 @@ void StatusWindow::setPointsNeeded(const int id, const int needed)
}
void StatusWindow::addAttribute(const int id, const std::string &name,
+ const std::string &shortName,
const bool modifiable,
const std::string &description A_UNUSED)
{
@@ -443,12 +451,12 @@ void StatusWindow::addAttribute(const int id, const std::string &name,
if (modifiable)
{
- disp = new ChangeDisplay(this, id, name);
+ disp = new ChangeDisplay(this, id, name, shortName);
mAttrCont->add1(disp);
}
else
{
- disp = new DerDisplay(this, id, name);
+ disp = new DerDisplay(this, id, name, shortName);
mDAttrCont->add1(disp);
}
mAttrs[id] = disp;
@@ -743,7 +751,10 @@ void StatusWindow::action(const gcn::ActionEvent &event)
const ChangeDisplay *const attr = dynamic_cast<ChangeDisplay*>(
(*it).second);
if (attr)
- str += attr->getValue() + " ";
+ {
+ str += strprintf("%s:%s ", attr->getShortName().c_str(),
+ attr->getValue().c_str());
+ }
++ it;
}
chatWindow->addInputText(str);
@@ -751,10 +762,12 @@ void StatusWindow::action(const gcn::ActionEvent &event)
}
AttrDisplay::AttrDisplay(const Widget2 *const widget,
- const int id, const std::string &name) :
+ const int id, const std::string &name,
+ const std::string &shortName) :
Container(widget),
mId(id),
mName(name),
+ mShortName(shortName),
mLayout(new LayoutHelper(this)),
mLabel(new Label(this, name)),
mValue(new Label(this, "1 "))
@@ -785,8 +798,9 @@ std::string AttrDisplay::update()
}
DerDisplay::DerDisplay(const Widget2 *const widget,
- const int id, const std::string &name) :
- AttrDisplay(widget, id, name)
+ const int id, const std::string &name,
+ const std::string &shortName) :
+ AttrDisplay(widget, id, name, shortName)
{
ContainerPlacer place = mLayout->getPlacer(0, 0);
@@ -797,8 +811,9 @@ DerDisplay::DerDisplay(const Widget2 *const widget,
}
ChangeDisplay::ChangeDisplay(const Widget2 *const widget,
- const int id, const std::string &name) :
- AttrDisplay(widget, id, name),
+ const int id, const std::string &name,
+ const std::string &shortName) :
+ AttrDisplay(widget, id, name, shortName),
gcn::ActionListener(),
mNeeded(1),
mPoints(new Label(this, _("Max"))),
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 2efc4bfb2..26e181421 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -61,8 +61,9 @@ class StatusWindow final : public Window,
void setPointsNeeded(const int id, const int needed);
void addAttribute(const int id, const std::string &name,
- const bool modifiable,
- const std::string &description);
+ const std::string &shortName = "",
+ const bool modifiable = false,
+ const std::string &description = "");
static void updateHPBar(ProgressBar *const bar,
const bool showMax = false);
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index 91f567548..0e0bc5eeb 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -255,31 +255,32 @@ void GeneralHandler::processEvent(Channels channel,
// protection against double addition attributes.
statusWindow->clearAttributes();
- statusWindow->addAttribute(STR, _("Strength"), true, "");
- statusWindow->addAttribute(AGI, _("Agility"), true, "");
- statusWindow->addAttribute(VIT, _("Vitality"), true, "");
- statusWindow->addAttribute(INT, _("Intelligence"), true, "");
- statusWindow->addAttribute(DEX, _("Dexterity"), true, "");
- statusWindow->addAttribute(LUK, _("Luck"), true, "");
-
- statusWindow->addAttribute(ATK, _("Attack"), false, "");
- statusWindow->addAttribute(DEF, _("Defense"), false, "");
- statusWindow->addAttribute(MATK, _("M.Attack"), false, "");
- statusWindow->addAttribute(MDEF, _("M.Defense"), false, "");
+ statusWindow->addAttribute(STR, _("Strength"), "str", true, "");
+ statusWindow->addAttribute(AGI, _("Agility"), "agi", true, "");
+ statusWindow->addAttribute(VIT, _("Vitality"), "vit", true, "");
+ statusWindow->addAttribute(INT, _("Intelligence"),
+ "int", true, "");
+ statusWindow->addAttribute(DEX, _("Dexterity"), "dex", true, "");
+ statusWindow->addAttribute(LUK, _("Luck"), "luk", true, "");
+
+ statusWindow->addAttribute(ATK, _("Attack"));
+ statusWindow->addAttribute(DEF, _("Defense"));
+ statusWindow->addAttribute(MATK, _("M.Attack"));
+ statusWindow->addAttribute(MDEF, _("M.Defense"));
// xgettext:no-c-format
- statusWindow->addAttribute(HIT, _("% Accuracy"), false, "");
+ statusWindow->addAttribute(HIT, _("% Accuracy"));
// xgettext:no-c-format
- statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
+ statusWindow->addAttribute(FLEE, _("% Evade"));
// xgettext:no-c-format
- statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
+ statusWindow->addAttribute(CRIT, _("% Critical"));
statusWindow->addAttribute(PlayerInfo::ATTACK_DELAY,
- _("Attack Delay"), false, "");
+ _("Attack Delay"));
statusWindow->addAttribute(PlayerInfo::WALK_SPEED,
- _("Walk Delay"), false, "");
+ _("Walk Delay"));
statusWindow->addAttribute(PlayerInfo::ATTACK_RANGE,
- _("Attack Range"), false, "");
+ _("Attack Range"));
statusWindow->addAttribute(PlayerInfo::ATTACK_SPEED,
- _("Damage per sec."), false, "");
+ _("Damage per sec."));
}
else if (event.getName() == EVENT_GUIWINDOWSUNLOADING)
{
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 39e37f62e..4666b9507 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -264,31 +264,32 @@ void GeneralHandler::processEvent(Channels channel,
// protection against double addition attributes.
statusWindow->clearAttributes();
- statusWindow->addAttribute(STR, _("Strength"), true, "");
- statusWindow->addAttribute(AGI, _("Agility"), true, "");
- statusWindow->addAttribute(VIT, _("Vitality"), true, "");
- statusWindow->addAttribute(INT, _("Intelligence"), true, "");
- statusWindow->addAttribute(DEX, _("Dexterity"), true, "");
- statusWindow->addAttribute(LUK, _("Luck"), true, "");
-
- statusWindow->addAttribute(ATK, _("Attack"), false, "");
- statusWindow->addAttribute(DEF, _("Defense"), false, "");
- statusWindow->addAttribute(MATK, _("M.Attack"), false, "");
- statusWindow->addAttribute(MDEF, _("M.Defense"), false, "");
+ statusWindow->addAttribute(STR, _("Strength"), "str", true, "");
+ statusWindow->addAttribute(AGI, _("Agility"), "agi", true, "");
+ statusWindow->addAttribute(VIT, _("Vitality"), "vit", true, "");
+ statusWindow->addAttribute(INT, _("Intelligence"),
+ "int", true, "");
+ statusWindow->addAttribute(DEX, _("Dexterity"), "dex", true, "");
+ statusWindow->addAttribute(LUK, _("Luck"), "luk", true, "");
+
+ statusWindow->addAttribute(ATK, _("Attack"));
+ statusWindow->addAttribute(DEF, _("Defense"));
+ statusWindow->addAttribute(MATK, _("M.Attack"));
+ statusWindow->addAttribute(MDEF, _("M.Defense"));
// xgettext:no-c-format
- statusWindow->addAttribute(HIT, _("% Accuracy"), false, "");
+ statusWindow->addAttribute(HIT, _("% Accuracy"));
// xgettext:no-c-format
- statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
+ statusWindow->addAttribute(FLEE, _("% Evade"));
// xgettext:no-c-format
- statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
+ statusWindow->addAttribute(CRIT, _("% Critical"));
statusWindow->addAttribute(PlayerInfo::ATTACK_DELAY,
- _("Attack Delay"), false, "");
+ _("Attack Delay"));
statusWindow->addAttribute(PlayerInfo::WALK_SPEED,
- _("Walk Delay"), false, "");
+ _("Walk Delay"));
statusWindow->addAttribute(PlayerInfo::ATTACK_RANGE,
- _("Attack Range"), false, "");
+ _("Attack Range"));
statusWindow->addAttribute(PlayerInfo::ATTACK_SPEED,
- _("Damage per sec."), false, "");
+ _("Damage per sec."));
}
else if (event.getName() == EVENT_GUIWINDOWSUNLOADING)
{