diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-22 10:00:20 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-22 10:02:01 -0700 |
commit | 57007e5ecadef9439998b229cb4b1427239f68eb (patch) | |
tree | 60658c0e9f9b675abc35cb0c7f0f6bd30b2c98b9 /src/gui | |
parent | ffaee35f99686709300b8d1977ade714d5a4e8af (diff) | |
download | mana-client-57007e5ecadef9439998b229cb4b1427239f68eb.tar.gz mana-client-57007e5ecadef9439998b229cb4b1427239f68eb.tar.bz2 mana-client-57007e5ecadef9439998b229cb4b1427239f68eb.tar.xz mana-client-57007e5ecadef9439998b229cb4b1427239f68eb.zip |
Allow percentage for exp displays
Diffstat (limited to 'src/gui')
-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; |