summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-01-19 18:46:30 +0200
committerAndrei Karas <akaras@inbox.ru>2011-01-19 18:46:30 +0200
commit4fb5f3455e1f817348c02e6f5c42e3979dd51d64 (patch)
treed5da0b09088964c68cc8391ced5113129ab89990
parent2db104b657d0403f1b8ce2eb2dc8ada4ee9d7f73 (diff)
downloadplus-4fb5f3455e1f817348c02e6f5c42e3979dd51d64.tar.gz
plus-4fb5f3455e1f817348c02e6f5c42e3979dd51d64.tar.bz2
plus-4fb5f3455e1f817348c02e6f5c42e3979dd51d64.tar.xz
plus-4fb5f3455e1f817348c02e6f5c42e3979dd51d64.zip
Add job bar to ministatus window.
-rw-r--r--src/gui/ministatus.cpp48
-rw-r--r--src/gui/ministatus.h1
-rw-r--r--src/gui/statuswindow.cpp10
-rw-r--r--src/gui/statuswindow.h1
4 files changed, 57 insertions, 3 deletions
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 406ad7ddd..f892cdc8b 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -67,22 +67,50 @@ MiniStatusWindow::MiniStatusWindow():
mMpBar = 0;
}
+ int job = Net::getPlayerHandler()->getJobLocation()
+ && serverConfig.getValueBool("showJob", false);
+
mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP);
StatusWindow::updateXPBar(mXpBar);
+ if (job)
+ {
+ mJobBar = new ProgressBar(0, 100, 20, Theme::PROG_JOB);
+ StatusWindow::updateJobBar(mJobBar);
+ }
+ else
+ {
+ mJobBar = 0;
+ }
+
mStatusBar = new ProgressBar(100, 150, 20, Theme::PROG_EXP);
mHpBar->setPosition(0, 3);
if (mMpBar)
+ {
mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
- mXpBar->setPosition(mMpBar ? mMpBar->getX() + mMpBar->getWidth() + 3 :
- mHpBar->getX() + mHpBar->getWidth() + 3, 3);
- mStatusBar->setPosition(mXpBar->getX() + mXpBar->getWidth() + 3, 3);
+ mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3);
+ }
+ else
+ {
+ mXpBar->setPosition(mHpBar->getX() + mHpBar->getWidth() + 3, 3);
+ }
+ if (mJobBar)
+ {
+ mJobBar->setPosition(mXpBar->getX() + mXpBar->getWidth() + 3, 3);
+ mStatusBar->setPosition(mJobBar->getX() + mJobBar->getWidth() + 3, 3);
+ }
+ else
+ {
+ mStatusBar->setPosition(mXpBar->getX() + mXpBar->getWidth() + 3, 3);
+ }
add(mHpBar);
if (mMpBar)
add(mMpBar);
add(mXpBar);
+ if (mJobBar)
+ add(mJobBar);
add(mStatusBar);
setContentSize(mStatusBar->getX() + mStatusBar->getWidth(),
@@ -150,6 +178,7 @@ void MiniStatusWindow::event(Channels channel _UNUSED_,
else if (event.getName() == EVENT_UPDATESTAT)
{
StatusWindow::updateMPBar(mMpBar);
+ StatusWindow::updateJobBar(mJobBar);
}
}
@@ -212,6 +241,19 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
PlayerInfo::getAttribute(MAX_MP)));
mStatusPopup->hide();
}
+ else if (event.getSource() == mJobBar)
+ {
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ Net::getPlayerHandler()->getJobLocation());
+
+ mTextPopup->show(x + getX(), y + getY(),
+ strprintf("%u/%u", exp.first,
+ exp.second),
+ strprintf("%s: %u", _("Need"),
+ exp.second
+ - exp.first));
+ mStatusPopup->hide();
+ }
else
{
mTextPopup->hide();
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index 080beece3..d30a38a9e 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -82,6 +82,7 @@ class MiniStatusWindow : public Popup, public Mana::Listener
ProgressBar *mHpBar;
ProgressBar *mMpBar;
ProgressBar *mXpBar;
+ ProgressBar *mJobBar;
ProgressBar *mStatusBar;
TextPopup *mTextPopup;
StatusPopup *mStatusPopup;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 02436c179..853ea1789 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -469,6 +469,16 @@ void StatusWindow::updateXPBar(ProgressBar *bar, bool percent)
PlayerInfo::getAttribute(EXP_NEEDED), percent);
}
+void StatusWindow::updateJobBar(ProgressBar *bar, bool percent)
+{
+ if (!bar)
+ return;
+
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ Net::getPlayerHandler()->getJobLocation());
+ updateProgressBar(bar, exp.first, exp.second, percent);
+}
+
void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent)
{
std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 4b324073e..859ac613b 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -64,6 +64,7 @@ class StatusWindow : public Window, public Mana::Listener
static void updateHPBar(ProgressBar *bar, bool showMax = false);
static void updateMPBar(ProgressBar *bar, bool showMax = false);
+ static void updateJobBar(ProgressBar *bar, bool percent = true);
static void updateXPBar(ProgressBar *bar, bool percent = true);
static void updateStatusBar(ProgressBar *bar, bool percent = true);
static void updateProgressBar(ProgressBar *bar, int value, int max,