diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr> | 2010-06-01 01:20:56 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_fr> | 2010-06-01 01:31:32 +0200 |
commit | 64776c1b4c6ccdd3e46897a59c201dd749de9dff (patch) | |
tree | 45ea4c97b4acc9d1dd9819408659aa1e5a3a336b | |
parent | 34e7725106500af8f4ed4f148e60005b9738c04a (diff) | |
download | mana-64776c1b4c6ccdd3e46897a59c201dd749de9dff.tar.gz mana-64776c1b4c6ccdd3e46897a59c201dd749de9dff.tar.bz2 mana-64776c1b4c6ccdd3e46897a59c201dd749de9dff.tar.xz mana-64776c1b4c6ccdd3e46897a59c201dd749de9dff.zip |
Made the MP bar be shown only if the protocol is using it.
Reviewed-by: Jaxad0127.
-rw-r--r-- | src/gui/ministatus.cpp | 20 | ||||
-rw-r--r-- | src/gui/statuswindow.cpp | 36 | ||||
-rw-r--r-- | src/net/gamehandler.h | 5 | ||||
-rw-r--r-- | src/net/manaserv/gamehandler.h | 6 | ||||
-rw-r--r-- | src/net/tmwa/gamehandler.h | 3 |
5 files changed, 55 insertions, 15 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 90581f61..c8c942fd 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -35,6 +35,7 @@ #include "net/net.h" #include "net/playerhandler.h" +#include "net/gamehandler.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -47,19 +48,28 @@ MiniStatusWindow::MiniStatusWindow(): int max = player_node->getMaxHp(); mHpBar = new ProgressBar(max ? (float) player_node->getHp() / max : 0, 100, 20, Theme::PROG_HP); - max = player_node->getMaxMP(); - mMpBar = new ProgressBar(max ? (float) player_node->getMP() / max : 0, + if (Net::getGameHandler()->canUseMagicBar()) + { + max = player_node->getMaxMP(); + mMpBar = new ProgressBar(max ? (float) player_node->getMaxMP() / max : 0, 100, 20, Net::getPlayerHandler()->canUseMagic() ? Theme::PROG_MP : Theme::PROG_NO_MP); + } + else + mMpBar = 0; + max = player_node->getExpNeeded(); mXpBar = new ProgressBar(max ? (float) player_node->getExp() / max : 0, 100, 20, Theme::PROG_EXP); mHpBar->setPosition(0, 3); - mMpBar->setPosition(mHpBar->getWidth() + 3, 3); - mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3); + if (mMpBar) + mMpBar->setPosition(mHpBar->getWidth() + 3, 3); + mXpBar->setPosition(mMpBar ? mMpBar->getX() + mMpBar->getWidth() + 3 : + mHpBar->getX() + mHpBar->getWidth() + 3, 3); add(mHpBar); - add(mMpBar); + if (mMpBar) + add(mMpBar); add(mXpBar); setContentSize(mXpBar->getX() + mXpBar->getWidth(), diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 2439a213..ad9c0ed7 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -38,6 +38,7 @@ #include "net/net.h" #include "net/playerhandler.h" +#include "net/gamehandler.h" #include "utils/gettext.h" #include "utils/mathutils.h" @@ -117,11 +118,15 @@ StatusWindow::StatusWindow(): mXpBar = new ProgressBar(max ? (float) player_node->getExp() / max : 0, 80, 15, Theme::PROG_EXP); - max = player_node->getMaxMP(); - mMpLabel = new Label(_("MP:")); - mMpBar = new ProgressBar(max ? (float) player_node->getMaxMP() / max : 0, + bool magicBar = Net::getGameHandler()->canUseMagicBar(); + if (magicBar) + { + max = player_node->getMaxMP(); + mMpLabel = new Label(_("MP:")); + mMpBar = new ProgressBar(max ? (float) player_node->getMaxMP() / max : 0, 80, 15, Net::getPlayerHandler()->canUseMagic() ? Theme::PROG_MP : Theme::PROG_NO_MP); + } place(0, 0, mLvlLabel, 3); // 5, 0 Job Level @@ -130,9 +135,12 @@ StatusWindow::StatusWindow(): place(1, 1, mHpBar, 4); place(5, 1, mXpLabel).setPadding(3); place(6, 1, mXpBar, 5); - place(0, 2, mMpLabel).setPadding(3); - // 5, 2 and 6, 2 Job Progress Bar - place(1, 2, mMpBar, 4); + if (magicBar) + { + place(0, 2, mMpLabel).setPadding(3); + // 5, 2 and 6, 2 Job Progress Bar + place(1, 2, mMpBar, 4); + } if (Net::getPlayerHandler()->getJobLocation() > 0) { @@ -177,16 +185,15 @@ StatusWindow::StatusWindow(): loadWindowState(); update(HP); - update(MP); + if (magicBar) + update(MP); update(EXP); update(MONEY); update(CHAR_POINTS); // This also updates all attributes (none atm) update(LEVEL); int job = Net::getPlayerHandler()->getJobLocation(); if (job > 0) - { update(job); - } } std::string StatusWindow::update(int id) @@ -304,6 +311,8 @@ void StatusWindow::addAttribute(int id, const std::string &name, void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) { + if (!bar) + return; if (showMax) bar->setText(toString(player_node->getHp()) + @@ -320,6 +329,9 @@ void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) { + if (!bar) + return; + if (showMax) bar->setText(toString(player_node->getMP()) + "/" + toString(player_node->getMaxMP())); @@ -342,6 +354,9 @@ void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, bool percent) { + if (!bar) + return; + if (max == 0) { bar->setText(_("Max")); @@ -362,6 +377,9 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) { + if (!bar) + return; + updateProgressBar(bar, player_node->getExp(), player_node->getExpNeeded(), percent); } diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h index 774de16c..8d29a55b 100644 --- a/src/net/gamehandler.h +++ b/src/net/gamehandler.h @@ -49,6 +49,11 @@ class GameHandler virtual bool removeDeadBeings() const = 0; + /** + * Tells whether the protocol is using the MP statu bar + */ + virtual bool canUseMagicBar() const = 0; + virtual ~GameHandler() {} }; diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index dde1748f..912b308e 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -53,12 +53,16 @@ class GameHandler : public MessageHandler, public Net::GameHandler void quit() { quit(false); } void ping(int tick); - + bool removeDeadBeings() const { return false; } void clear(); void gameLoading(); + + /** The ManaServ protocol doesn't use the Mp Main status bar. */ + bool canUseMagicBar() const { return false; } + }; } // namespace ManaServ diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h index ca8d27e6..101e7972 100644 --- a/src/net/tmwa/gamehandler.h +++ b/src/net/tmwa/gamehandler.h @@ -60,6 +60,9 @@ class GameHandler : public MessageHandler, public Net::GameHandler void setMap(const std::string map); + /** The tmwa protocol is making use of the Mp Main status bar. */ + bool canUseMagicBar() const { return true; } + private: std::string mMap; int mCharID; /// < Saved for map-server switching |