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.cpp402
1 files changed, 176 insertions, 226 deletions
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 283a771b..3c48d045 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -1,226 +1,204 @@
/*
* The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Copyright (C) 2004 The Mana World Development Team
*
* This file is part of The Mana World.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with The Mana World; if not, write to the Free Software
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "status.h"
-
#include <guichan/widgets/label.hpp>
#include "button.h"
#include "progressbar.h"
+#include "status.h"
#include "windowcontainer.h"
+#include "widgets/layout.h"
+
#include "../localplayer.h"
+#include "../units.h"
+#include "../utils/gettext.h"
#include "../utils/strprintf.h"
-#include "../utils/tostring.h"
+#include "../utils/stringutils.h"
StatusWindow::StatusWindow(LocalPlayer *player):
Window(player->getName()),
- mPlayer(player)
+ mPlayer(player),
+ mCurrency(0)
{
setWindowName("Status");
- setResizable(true);
setCloseButton(true);
setDefaultSize((windowContainer->getWidth() - 365) / 2,
- (windowContainer->getHeight() - 255) / 2, 365, 275);
- loadWindowState();
+ (windowContainer->getHeight() - 255) / 2, 400, 345);
// ----------------------
// Status Part
// ----------------------
- mLvlLabel = new gcn::Label("Level:");
- mMoneyLabel = new gcn::Label("Money:");
+ mLvlLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
+ mJobLvlLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
+ mGpLabel = new gcn::Label(strprintf(_("Money: %s"),
+ Units::formatCurrency(mCurrency).c_str()));
- mHpLabel = new gcn::Label("HP:");
+ mHpLabel = new gcn::Label(_("HP:"));
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
- mHpValueLabel = new gcn::Label("");
-
- int y = 3;
- int x = 5;
-
- mLvlLabel->setPosition(x, y);
- x += mLvlLabel->getWidth() + 40;
- mMoneyLabel->setPosition(x, y);
- y += mLvlLabel->getHeight() + 5; // Next Row
- x = 5;
+ mXpLabel = new gcn::Label(_("Exp:"));
+ mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211);
- mHpLabel->setPosition(x, y);
- x += mHpLabel->getWidth() + 5;
- mHpBar->setPosition(x, y);
- x += mHpBar->getWidth() + 5;
- mHpValueLabel->setPosition(x, y);
+ mMpLabel = new gcn::Label(_("MP:"));
+ mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230);
- y += mHpLabel->getHeight() + 5; // Next Row
- x = 5;
-
- add(mLvlLabel);
- add(mMoneyLabel);
- add(mHpLabel);
- add(mHpValueLabel);
- add(mHpBar);
+ mJobLabel = new gcn::Label(_("Job:"));
+ mJobBar = new ProgressBar(1.0f, 80, 15, 220, 135, 203);
// ----------------------
// Stats Part
// ----------------------
// Static Labels
- gcn::Label *mStatsTitleLabel = new gcn::Label("Stats");
- gcn::Label *mStatsTotalLabel = new gcn::Label("Total");
+ 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:");
- mStatsDefenseLabel= new gcn::Label("Defense:");
- mStatsMagicAttackLabel = new gcn::Label("M.Attack:");
- mStatsMagicDefenseLabel = new gcn::Label("M.Defense:");
- mStatsAccuracyLabel = new gcn::Label("% Accuracy:");
- mStatsEvadeLabel = new gcn::Label("% Evade:");
- mStatsReflexLabel = new gcn::Label("% Reflex:");
-
- mStatsAttackPoints = new gcn::Label("");
- mStatsDefensePoints = new gcn::Label("");
- mStatsMagicAttackPoints = new gcn::Label("");
- mStatsMagicDefensePoints = new gcn::Label("");
- mStatsAccuracyPoints = new gcn::Label("% Accuracy:");
- mStatsEvadePoints = new gcn::Label("% Evade:");
- mStatsReflexPoints = new gcn::Label("% Reflex:");
-*/
+ mStatsAttackLabel = new gcn::Label(_("Attack:"));
+ mStatsDefenseLabel= new gcn::Label(_("Defense:"));
+ mStatsMagicAttackLabel = new gcn::Label(_("M.Attack:"));
+ mStatsMagicDefenseLabel = new gcn::Label(_("M.Defense:"));
+ // Gettext flag for next line: xgettext:no-c-format
+ mStatsAccuracyLabel = new gcn::Label(_("% Accuracy:"));
+ // Gettext flag for next line: xgettext:no-c-format
+ mStatsEvadeLabel = new gcn::Label(_("% Evade:"));
+ // Gettext flag for next line: xgettext:no-c-format
+ mStatsReflexLabel = new gcn::Label(_("% Reflex:"));
+
+ mStatsAttackPoints = new gcn::Label;
+ mStatsDefensePoints = new gcn::Label;
+ mStatsMagicAttackPoints = new gcn::Label;
+ mStatsMagicDefensePoints = new gcn::Label;
+ mStatsAccuracyPoints = new gcn::Label;
+ mStatsEvadePoints = new gcn::Label;
+ mStatsReflexPoints = new gcn::Label;
+
// New labels
- for (int i = 0; i < 6; i++) {
- mStatsLabel[i] = new gcn::Label();
- mStatsDisplayLabel[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);
}
- mCharacterPointsLabel = new gcn::Label();
- mCorrectionPointsLabel = new gcn::Label();
+ mRemainingStatsPointsLabel = new gcn::Label;
// Set button events Id
- mStatsPlus[0] = new Button("+", "STR+", this);
- mStatsPlus[1] = new Button("+", "AGI+", this);
- mStatsPlus[2] = new Button("+", "DEX+", this);
- mStatsPlus[3] = new Button("+", "VIT+", this);
- mStatsPlus[4] = new Button("+", "INT+", this);
- mStatsPlus[5] = new Button("+", "WIL+", this);
-
- mStatsMinus[0] = new Button("-", "STR-", this);
- mStatsMinus[1] = new Button("-", "AGI-", this);
- mStatsMinus[2] = new Button("-", "DEX-", this);
- mStatsMinus[3] = new Button("-", "VIT-", this);
- mStatsMinus[4] = new Button("-", "INT-", this);
- mStatsMinus[5] = new Button("-", "WIL-", this);
-
-
-
- // Set position
- mStatsTitleLabel->setPosition(mHpLabel->getX(), mHpLabel->getY() + 23 );
- mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
- int totalLabelY = mStatsTotalLabel->getY();
+ mStatsButton[0] = new Button("+", "STR", this);
+ mStatsButton[1] = new Button("+", "AGI", this);
+ mStatsButton[2] = new Button("+", "VIT", this);
+ mStatsButton[3] = new Button("+", "INT", this);
+ mStatsButton[4] = new Button("+", "DEX", this);
+ mStatsButton[5] = new Button("+", "LUK", this);
+ // Assemble
+ 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).setPadding(3);
+ place(2, 1, mHpBar, 3);
+ place(6, 1, mXpLabel).setPadding(3);
+ place(7, 1, mXpBar, 3);
+ place(1, 2, mMpLabel).setPadding(3);
+ place(2, 2, mMpBar, 3);
+ place(6, 2, mJobLabel).setPadding(3);
+ 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++)
{
- mStatsLabel[i]->setPosition(5,
- mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsMinus[i]->setPosition(85, totalLabelY + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(125,
- totalLabelY + (i * 23) + 15);
- mStatsPlus[i]->setPosition(185, totalLabelY + (i * 23) + 15);
+ 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);
}
+ 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);
- mCharacterPointsLabel->setPosition(5, mStatsDisplayLabel[5]->getY() + 25);
- mCorrectionPointsLabel->setPosition(5, mStatsDisplayLabel[5]->getY() + 35);
-/*
- 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, mStatsLabel[6]->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, mStatsLabel[6]->getY());
-*/
- // Assemble
- add(mStatsTitleLabel);
- add(mStatsTotalLabel);
- for(int i = 0; i < 6; i++)
- {
- add(mStatsLabel[i]);
- add(mStatsDisplayLabel[i]);
- add(mStatsPlus[i]);
- add(mStatsMinus[i]);
- }/*
- 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(mCharacterPointsLabel);
- add(mCorrectionPointsLabel);
+ loadWindowState();
}
void StatusWindow::update()
{
// Status Part
// -----------
- mLvlLabel->setCaption( "Level: " +
- toString(mPlayer->getLevel()) +
- " (" +
- toString(mPlayer->getLevelProgress()) +
- "%)");
+ mLvlLabel->setCaption(strprintf(_("Level: %d"), mPlayer->getLevel()));
mLvlLabel->adjustSize();
- mMoneyLabel->setCaption("Money: " + toString(mPlayer->getMoney()) + " GP");
- mMoneyLabel->adjustSize();
+ mJobLvlLabel->setCaption(strprintf(_("Job: %d"), mPlayer->mJobLevel));
+ mJobLvlLabel->adjustSize();
- int hp = mPlayer->getHP();
- int maxHp = mPlayer->getMaxHP();
+ if (mCurrency != mPlayer->getMoney()) {
+ mCurrency = mPlayer->getMoney();
+ mGpLabel->setCaption(strprintf(_("Money: %s"),
+ Units::formatCurrency(mCurrency).c_str()));
+ mGpLabel->adjustSize();
+ }
+
+ mHpBar->setText(toString(mPlayer->getHp()) +
+ "/" + toString(mPlayer->getMaxHp()));
+
+ mMpBar->setText(toString(mPlayer->mMp) +
+ "/" + toString(mPlayer->mMaxMp));
- mHpValueLabel->setCaption(toString(hp) +
- " / " + toString(maxHp));
- mHpValueLabel->adjustSize();
+ mXpBar->setText(toString(mPlayer->getXp()) +
+ "/" + toString(mPlayer->mXpForNextLevel));
+
+ mJobBar->setText(toString(mPlayer->mJobXp) +
+ "/" + toString(mPlayer->mJobXpForNextLevel));
// HP Bar coloration
- if (hp < int(maxHp / 3))
+ if (mPlayer->getHp() < int(mPlayer->getMaxHp() / 3))
{
mHpBar->setColor(223, 32, 32); // Red
}
- else if (hp < int((maxHp / 3) * 2))
+ else if (mPlayer->getHp() < int((mPlayer->getMaxHp() / 3) * 2))
{
mHpBar->setColor(230, 171, 34); // Orange
}
@@ -229,43 +207,43 @@ void StatusWindow::update()
mHpBar->setColor(0, 171, 34); // Green
}
- mHpBar->setProgress((float) hp / maxHp);
+ mHpBar->setProgress((float) mPlayer->getHp() / (float) mPlayer->getMaxHp());
+ mMpBar->setProgress((float) mPlayer->mMp / (float) mPlayer->mMaxMp);
+
+ mXpBar->setProgress(
+ (float) mPlayer->getXp() / (float) mPlayer->mXpForNextLevel);
+ mJobBar->setProgress(
+ (float) mPlayer->mJobXp / (float) mPlayer->mJobXpForNextLevel);
// Stats Part
// ----------
- const std::string attrNames[6] = {
- "Strength",
- "Agility",
- "Dexterity",
- "Vitality",
- "Intelligence",
- "Willpower"
+ static const char *attrNames[6] = {
+ N_("Strength"),
+ N_("Agility"),
+ N_("Vitality"),
+ N_("Intelligence"),
+ N_("Dexterity"),
+ N_("Luck")
};
- int characterPoints = mPlayer->getCharacterPoints();
- int correctionPoints = mPlayer->getCorrectionPoints();
+ int statusPoints = mPlayer->mStatsPointsToAttribute;
+
// Update labels
for (int i = 0; i < 6; i++)
{
- mStatsLabel[i]->setCaption(attrNames[i]);
- mStatsDisplayLabel[i]->setCaption(
- strprintf("%d / %d",
- mPlayer->getAttributeEffective(CHAR_ATTR_BEGIN + i),
- mPlayer->getAttributeBase(CHAR_ATTR_BEGIN + i)));
+ mStatsLabel[i]->setCaption(gettext(attrNames[i]));
+ mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i]));
+ mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i]));
mStatsLabel[i]->adjustSize();
mStatsDisplayLabel[i]->adjustSize();
+ mPointsLabel[i]->adjustSize();
- mStatsPlus[i]->setEnabled(characterPoints);
- mStatsMinus[i]->setEnabled(correctionPoints);
+ mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints);
}
- mCharacterPointsLabel->setCaption("Character Points: " +
- toString(characterPoints));
- mCharacterPointsLabel->adjustSize();
+ mRemainingStatsPointsLabel->setCaption(
+ strprintf(_("Remaining Status Points: %d"), statusPoints));
+ mRemainingStatsPointsLabel->adjustSize();
- mCorrectionPointsLabel->setCaption("Correction Points: " +
- toString(correctionPoints));
- mCorrectionPointsLabel->adjustSize();
-/*
// Derived Stats Points
// Attack TODO: Count equipped Weapons and items attack bonuses
@@ -299,11 +277,6 @@ void StatusWindow::update()
// Reflex %
mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
-*/
- // Update Second column widgets position
- mMoneyLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
- mLvlLabel->getY());
-
}
void StatusWindow::draw(gcn::Graphics *g)
@@ -315,56 +288,33 @@ void StatusWindow::draw(gcn::Graphics *g)
void StatusWindow::action(const gcn::ActionEvent &event)
{
- const std::string &eventId = event.getId();
-
// Stats Part
- if (eventId == "STR+")
- {
- mPlayer->raiseAttribute(LocalPlayer::STR);
- }
- else if (eventId == "AGI+")
- {
- mPlayer->raiseAttribute(LocalPlayer::AGI);
- }
- else if (eventId == "DEX+")
+ if (event.getId().length() == 3)
{
- mPlayer->raiseAttribute(LocalPlayer::DEX);
- }
- else if (eventId == "VIT+")
- {
- mPlayer->raiseAttribute(LocalPlayer::VIT);
- }
- else if (eventId == "INT+")
- {
- mPlayer->raiseAttribute(LocalPlayer::INT);
- }
- else if (eventId == "WIL+")
- {
- mPlayer->raiseAttribute(LocalPlayer::WIL);
- }
-
- else if (eventId == "STR-")
- {
- mPlayer->lowerAttribute(LocalPlayer::STR);
- }
- else if (eventId == "AGI-")
- {
- mPlayer->lowerAttribute(LocalPlayer::AGI);
- }
- else if (eventId == "DEX-")
- {
- mPlayer->lowerAttribute(LocalPlayer::DEX);
- }
- else if (eventId == "VIT-")
- {
- mPlayer->lowerAttribute(LocalPlayer::VIT);
- }
- else if (eventId == "INT-")
- {
- mPlayer->lowerAttribute(LocalPlayer::INT);
- }
- else if (eventId == "WIL-")
- {
- mPlayer->lowerAttribute(LocalPlayer::WIL);
+ if (event.getId() == "STR")
+ {
+ player_node->raiseAttribute(LocalPlayer::STR);
+ }
+ if (event.getId() == "AGI")
+ {
+ player_node->raiseAttribute(LocalPlayer::AGI);
+ }
+ if (event.getId() == "VIT")
+ {
+ player_node->raiseAttribute(LocalPlayer::VIT);
+ }
+ if (event.getId() == "INT")
+ {
+ player_node->raiseAttribute(LocalPlayer::INT);
+ }
+ if (event.getId() == "DEX")
+ {
+ player_node->raiseAttribute(LocalPlayer::DEX);
+ }
+ if (event.getId() == "LUK")
+ {
+ player_node->raiseAttribute(LocalPlayer::LUK);
+ }
}
}
+