diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/status.cpp | 30 | ||||
-rw-r--r-- | src/gui/status.h | 4 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 0f695b68..f5ec5c13 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -185,9 +185,9 @@ void StatusWindow::update() updateMPBar(mMpBar, true); - updateXPBar(mXpBar); + updateXPBar(mXpBar, false); - updateJobBar(mJobBar); + updateJobBar(mJobBar, false); // Stats Part // ---------- @@ -329,13 +329,21 @@ void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax) bar->setProgress((float) player_node->mMp / (float) player_node->mMaxMp); } -void StatusWindow::updateXPBar(ProgressBar *bar) +void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) { if (player_node->mXpForNextLevel == 0) { bar->setText(_("Max level")); bar->setProgress(1.0); } else { - bar->setText(toString(player_node->getXp()) + + if (percent) + { + float xp = (float) player_node->getXp() / + player_node->mXpForNextLevel; + bar->setText(toString((float) ((int) (xp * 10000.0f)) / 100.0f) + + "%"); + } + else + bar->setText(toString(player_node->getXp()) + "/" + toString(player_node->mXpForNextLevel)); bar->setProgress((float) player_node->getXp() / @@ -343,14 +351,22 @@ void StatusWindow::updateXPBar(ProgressBar *bar) } } -void StatusWindow::updateJobBar(ProgressBar *bar) +void StatusWindow::updateJobBar(ProgressBar *bar, bool percent) { if (player_node->mXpForNextLevel == 0) { bar->setText(_("Max level")); bar->setProgress(1.0); } else { - bar->setText(toString(player_node->mJobXp) + - "/" + toString(player_node->mJobXpForNextLevel)); + if (percent) + { + float xp = (float) player_node->mJobXp / + player_node->mJobXpForNextLevel; + bar->setText(toString((float) ((int) (xp * 10000.0f)) / 100.0f) + + "%"); + } + else + bar->setText(toString(player_node->mJobXp) + + "/" + toString(player_node->mJobXpForNextLevel)); bar->setProgress((float) player_node->mJobXp / (float) player_node->mJobXpForNextLevel); diff --git a/src/gui/status.h b/src/gui/status.h index 99facb28..f3f54f4e 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -59,8 +59,8 @@ class StatusWindow : public Window, public gcn::ActionListener static void updateHPBar(ProgressBar *bar, bool showMax = false); static void updateMPBar(ProgressBar *bar, bool showMax = false); - static void updateXPBar(ProgressBar *bar); - static void updateJobBar(ProgressBar *bar); + static void updateXPBar(ProgressBar *bar, bool percent = true); + static void updateJobBar(ProgressBar *bar, bool percent = true); private: LocalPlayer *mPlayer; |