summaryrefslogtreecommitdiff
path: root/src/gui/status.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/status.cpp')
-rw-r--r--src/gui/status.cpp227
1 files changed, 67 insertions, 160 deletions
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 526fa6b1..21087fad 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -26,6 +26,8 @@
#include "status.h"
#include "windowcontainer.h"
+#include "widgets/layout.h"
+
#include "../localplayer.h"
#include "../utils/gettext.h"
@@ -39,83 +41,27 @@ StatusWindow::StatusWindow(LocalPlayer *player):
setWindowName(_("Status"));
setCloseButton(true);
setDefaultSize((windowContainer->getWidth() - 365) / 2,
- (windowContainer->getHeight() - 255) / 2, 400, 275);
- loadWindowState();
+ (windowContainer->getHeight() - 255) / 2, 400, 335);
// ----------------------
// Status Part
// ----------------------
mLvlLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
- mGpLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
- mJobLvlLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
+ mJobLvlLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
+ mGpLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
mHpLabel = new gcn::Label(_("HP:"));
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
- mHpValueLabel = new gcn::Label;
mXpLabel = new gcn::Label(_("Exp:"));
mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211);
- mXpValueLabel = new gcn::Label;
mMpLabel = new gcn::Label(_("MP:"));
mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230);
- mMpValueLabel = new gcn::Label;
-
- mJobXpLabel = new gcn::Label(_("Job:"));
- mJobXpBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
- mJobValueLabel = new gcn::Label;
-
- int y = 3;
- int x = 5;
-
- mLvlLabel->setPosition(x, y);
- x += mLvlLabel->getWidth() + 40;
- mJobLvlLabel->setPosition(x, y);
- x += mJobLvlLabel->getWidth() + 40;
- mGpLabel->setPosition(x, y);
-
- y += mLvlLabel->getHeight() + 5; // Next Row
- x = 5;
-
- mHpLabel->setPosition(x, y);
- x += mHpLabel->getWidth() + 5;
- mHpBar->setPosition(x, y);
- x += mHpBar->getWidth() + 5;
- mHpValueLabel->setPosition(x, y);
-
- mXpLabel->setPosition(175, y);
- mXpBar->setPosition(205, y);
- mXpValueLabel->setPosition(290, y);
-
- y += mHpLabel->getHeight() + 5; // Next Row
- x = 5;
-
- mMpLabel->setPosition(x, y);
- x += mMpLabel->getWidth() + 5;
- mMpBar->setPosition(x, y);
- x += mMpBar->getWidth() + 5;
- mMpValueLabel->setPosition(x, y);
-
- mJobXpLabel->setPosition(175, y);
- mJobXpBar->setPosition(205, y);
- mJobValueLabel->setPosition(290, y);
-
- add(mLvlLabel);
- add(mJobLvlLabel);
- add(mGpLabel);
- add(mHpLabel);
- add(mHpValueLabel);
- add(mMpLabel);
- add(mMpValueLabel);
- add(mXpLabel);
- add(mXpValueLabel);
- add(mJobXpLabel);
- add(mJobValueLabel);
- add(mHpBar);
- add(mMpBar);
- add(mXpBar);
- add(mJobXpBar);
+
+ mJobLabel = new gcn::Label(_("Job:"));
+ mJobBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
// ----------------------
// Stats Part
@@ -125,6 +71,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
gcn::Label *mStatsTitleLabel = new gcn::Label(_("Stats"));
gcn::Label *mStatsTotalLabel = new gcn::Label(_("Total"));
gcn::Label *mStatsCostLabel = new gcn::Label(_("Cost"));
+ mStatsTotalLabel->setAlignment(gcn::Graphics::CENTER);
// Derived Stats
mStatsAttackLabel = new gcn::Label(_("Attack:"));
@@ -147,10 +94,13 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsReflexPoints = new gcn::Label;
// New labels
- for (int i = 0; i < 6; i++) {
- mStatsLabel[i] = new gcn::Label;
+ for (int i = 0; i < 6; i++)
+ {
+ mStatsLabel[i] = new gcn::Label("0");
+ mStatsLabel[i]->setAlignment(gcn::Graphics::CENTER);
mStatsDisplayLabel[i] = new gcn::Label;
mPointsLabel[i] = new gcn::Label("0");
+ mPointsLabel[i]->setAlignment(gcn::Graphics::CENTER);
}
mRemainingStatsPointsLabel = new gcn::Label;
@@ -162,68 +112,53 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsButton[4] = new Button("+", "DEX", this);
mStatsButton[5] = new Button("+", "LUK", this);
-
- // Set position
- mStatsTitleLabel->setPosition(mMpLabel->getX(), mMpLabel->getY() + 23 );
- mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
- int totalLabelY = mStatsTotalLabel->getY();
- mStatsCostLabel->setPosition(170, totalLabelY);
-
- for (int i = 0; i < 6; i++)
- {
- mStatsLabel[i]->setPosition(5, mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(115,
- totalLabelY + (i * 23) + 15);
- mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10);
- mPointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15);
- }
-
- mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[5]->getY() + 25);
-
- mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY());
- mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY());
- mStatsMagicAttackLabel->setPosition(220, mStatsLabel[2]->getY());
- mStatsMagicDefenseLabel->setPosition(220, mStatsLabel[3]->getY());
- mStatsAccuracyLabel->setPosition(220, mStatsLabel[4]->getY());
- mStatsEvadeLabel->setPosition(220, mStatsLabel[5]->getY());
- mStatsReflexLabel->setPosition(220, mRemainingStatsPointsLabel->getY());
-
- mStatsAttackPoints->setPosition(310, mStatsLabel[0]->getY());
- mStatsDefensePoints->setPosition(310, mStatsLabel[1]->getY());
- mStatsMagicAttackPoints->setPosition(310, mStatsLabel[2]->getY());
- mStatsMagicDefensePoints->setPosition(310, mStatsLabel[3]->getY());
- mStatsAccuracyPoints->setPosition(310, mStatsLabel[4]->getY());
- mStatsEvadePoints->setPosition(310, mStatsLabel[5]->getY());
- mStatsReflexPoints->setPosition(310, mRemainingStatsPointsLabel->getY());
-
// Assemble
- add(mStatsTitleLabel);
- add(mStatsTotalLabel);
- add(mStatsCostLabel);
- for (int i = 0; i < 6; i++)
+ ContainerPlacer place;
+ place = getPlacer(0, 0);
+
+ place(0, 0, mLvlLabel, 3);
+ place(5, 0, mJobLvlLabel, 3);
+ place(8, 0, mGpLabel, 3);
+ place(1, 1, mHpLabel);
+ place(2, 1, mHpBar, 3);
+ place(6, 1, mXpLabel);
+ place(7, 1, mXpBar, 3);
+ place(1, 2, mMpLabel);
+ place(2, 2, mMpBar, 3);
+ place(6, 2, mJobLabel);
+ place(7, 2, mJobBar, 3);
+ place.getCell().matchColWidth(0, 1);
+ place = getPlacer(0, 3);
+ place(0, 0, mStatsTitleLabel, 5);
+ place(5, 1, mStatsTotalLabel, 5);
+ place(12, 1, mStatsCostLabel, 5);
+ for(int i = 0; i < 6; i++)
{
- add(mStatsLabel[i]);
- add(mStatsDisplayLabel[i]);
- add(mStatsButton[i]);
- add(mPointsLabel[i]);
+ place(0, 2 + i, mStatsLabel[i], 7).setPadding(5);
+ place(7, 2 + i, mStatsDisplayLabel[i]).setPadding(5);
+ place(10, 2 + i, mStatsButton[i]);
+ place(12, 2 + i, mPointsLabel[i]).setPadding(5);
}
- add(mStatsAttackLabel);
- add(mStatsDefenseLabel);
- add(mStatsMagicAttackLabel);
- add(mStatsMagicDefenseLabel);
- add(mStatsAccuracyLabel);
- add(mStatsEvadeLabel);
- add(mStatsReflexLabel);
-
- add(mStatsAttackPoints);
- add(mStatsDefensePoints);
- add(mStatsMagicAttackPoints);
- add(mStatsMagicDefensePoints);
- add(mStatsAccuracyPoints);
- add(mStatsEvadePoints);
- add(mStatsReflexPoints);
-
- add(mRemainingStatsPointsLabel);
+ place(14, 2, mStatsAttackLabel, 7).setPadding(5);
+ place(14, 3, mStatsDefenseLabel, 7).setPadding(5);
+ place(14, 4, mStatsMagicAttackLabel, 7).setPadding(5);
+ place(14, 5, mStatsMagicDefenseLabel, 7).setPadding(5);
+ place(14, 6, mStatsAccuracyLabel, 7).setPadding(5);
+ place(14, 7, mStatsEvadeLabel, 7).setPadding(5);
+ place(14, 8, mStatsReflexLabel, 7).setPadding(5);
+ place(21, 2, mStatsAttackPoints, 3).setPadding(5);
+ place(21, 3, mStatsDefensePoints, 3).setPadding(5);
+ place(21, 4, mStatsMagicAttackPoints, 3).setPadding(5);
+ place(21, 5, mStatsMagicDefensePoints, 3).setPadding(5);
+ place(21, 6, mStatsAccuracyPoints, 3).setPadding(5);
+ place(21, 7, mStatsEvadePoints, 3).setPadding(5);
+ place(21, 8, mStatsReflexPoints, 3).setPadding(5);
+ place(0, 8, mRemainingStatsPointsLabel, 3).setPadding(5);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, Layout::AUTO_SET);
+
+ loadWindowState();
}
void StatusWindow::update()
@@ -239,21 +174,17 @@ void StatusWindow::update()
mGpLabel->setCaption(strprintf(_("Money: %d GP"), mPlayer->mGp));
mGpLabel->adjustSize();
- mHpValueLabel->setCaption(toString(mPlayer->mHp) +
- "/" + toString(mPlayer->mMaxHp));
- mHpValueLabel->adjustSize();
+ mHpBar->setText(toString(mPlayer->mHp) +
+ "/" + toString(mPlayer->mMaxHp));
- mMpValueLabel->setCaption(toString(mPlayer->mMp) +
- "/" + toString(mPlayer->mMaxMp));
- mMpValueLabel->adjustSize();
+ mMpBar->setText(toString(mPlayer->mMp) +
+ "/" + toString(mPlayer->mMaxMp));
- mXpValueLabel->setCaption(toString(mPlayer->getXp()) +
- "/" + toString(mPlayer->mXpForNextLevel));
- mXpValueLabel->adjustSize();
+ mXpBar->setText(toString(mPlayer->getXp()) +
+ "/" + toString(mPlayer->mXpForNextLevel));
- mJobValueLabel->setCaption(toString(mPlayer->mJobXp) +
- "/" + toString(mPlayer->mJobXpForNextLevel));
- mJobValueLabel->adjustSize();
+ mJobBar->setText(toString(mPlayer->mJobXp) +
+ "/" + toString(mPlayer->mJobXpForNextLevel));
// HP Bar coloration
if (mPlayer->mHp < int(mPlayer->mMaxHp / 3))
@@ -274,7 +205,7 @@ void StatusWindow::update()
mXpBar->setProgress(
(float) mPlayer->getXp() / (float) mPlayer->mXpForNextLevel);
- mJobXpBar->setProgress(
+ mJobBar->setProgress(
(float) mPlayer->mJobXp / (float) mPlayer->mJobXpForNextLevel);
// Stats Part
@@ -339,30 +270,6 @@ void StatusWindow::update()
// Reflex %
mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
-
- // Update Second column widgets position
- mJobLvlLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
- mLvlLabel->getY());
- mGpLabel->setPosition(mJobLvlLabel->getX() + mJobLvlLabel->getWidth() + 20,
- mJobLvlLabel->getY());
-
- mXpLabel->setPosition(
- mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
- mHpLabel->getY());
- mXpBar->setPosition(
- mXpLabel->getX() + mXpLabel->getWidth() + 5,
- mXpLabel->getY());
- mXpValueLabel->setPosition(
- mXpBar->getX() + mXpBar->getWidth() + 5,
- mXpLabel->getY());
-
- mJobXpLabel->setPosition(mXpBar->getX() - mJobXpLabel->getWidth() - 5,
- mMpLabel->getY());
- mJobXpBar->setPosition(
- mJobXpLabel->getX() + mJobXpLabel->getWidth() + 5,
- mJobXpLabel->getY());
- mJobValueLabel->setPosition(mJobXpBar->getX() + mJobXpBar->getWidth() + 5,
- mJobXpLabel->getY());
}
void StatusWindow::draw(gcn::Graphics *g)