]> git.localhorst.tv Git - l2e.git/commitdiff
put victory strings in battle resources
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 13 Feb 2013 17:39:57 +0000 (18:39 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 13 Feb 2013 18:44:18 +0000 (19:44 +0100)
src/battle/Resources.cpp
src/battle/Resources.h
src/battle/states/VictoryState.cpp
test-data/test.l2s

index d50571f10bb3fd1c20686b3174ac61ff49b0d0ef..621f61ed745186bbf1a44bbb407167d00f61a666 100644 (file)
@@ -84,6 +84,23 @@ Resources::Resources()
 , ikariLabelCol(0)
 , ikariLabelRow(0)
 
+, victoryGetsText(0)
+, victoryExpText(0)
+, victoryGoldText(0)
+, victoryLevelUpText(0)
+, victoryUpgradeText(0)
+, victoryNextLevelText(0)
+
+, victoryMHPText(0)
+, victoryMMPText(0)
+, victoryATPText(0)
+, victoryDFPText(0)
+, victorySTRText(0)
+, victoryAGLText(0)
+, victoryINTText(0)
+, victoryGUTText(0)
+, victoryMGRText(0)
+
 { }
 
 
@@ -160,6 +177,23 @@ void Resources::CreateTypeDescription() {
        td.AddField("ikariLabelCol", FieldDescription(((char *)&r.ikariLabelCol) - ((char *)&r), Interpreter::NUMBER_ID).SetDescription("row of the ikari label in heroTagLabels"));
 
        td.AddField("heroesBgColor", FieldDescription(((char *)&r.heroesBgColor) - ((char *)&r), Interpreter::COLOR_ID).SetDescription("background color of the small tags during attack animation"));
+
+       td.AddField("victoryGetsText", FieldDescription(((char *)&r.victoryGetsText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryExpText", FieldDescription(((char *)&r.victoryExpText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryGoldText", FieldDescription(((char *)&r.victoryGoldText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryLevelUpText", FieldDescription(((char *)&r.victoryLevelUpText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryUpgradeText", FieldDescription(((char *)&r.victoryUpgradeText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryNextLevelText", FieldDescription(((char *)&r.victoryNextLevelText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+
+       td.AddField("victoryMHPText", FieldDescription(((char *)&r.victoryMHPText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryMMPText", FieldDescription(((char *)&r.victoryMMPText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryATPText", FieldDescription(((char *)&r.victoryATPText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryDFPText", FieldDescription(((char *)&r.victoryDFPText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victorySTRText", FieldDescription(((char *)&r.victorySTRText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryAGLText", FieldDescription(((char *)&r.victoryAGLText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryINTText", FieldDescription(((char *)&r.victoryINTText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryGUTText", FieldDescription(((char *)&r.victoryGUTText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
+       td.AddField("victoryMGRText", FieldDescription(((char *)&r.victoryMGRText) - ((char *)&r), Interpreter::STRING_ID).SetReferenced());
 }
 
 void Resources::Construct(void *data) {
index 1500378ab75b0b370d391d352c7ff34310c61170..0a8a1e8db444a618be0cc43a37284f965245051e 100644 (file)
@@ -88,6 +88,23 @@ struct Resources {
 
        graphics::Color heroesBgColor;
 
+       const char *victoryGetsText;
+       const char *victoryExpText;
+       const char *victoryGoldText;
+       const char *victoryLevelUpText;
+       const char *victoryUpgradeText;
+       const char *victoryNextLevelText;
+
+       const char *victoryMHPText;
+       const char *victoryMMPText;
+       const char *victoryATPText;
+       const char *victoryDFPText;
+       const char *victorySTRText;
+       const char *victoryAGLText;
+       const char *victoryINTText;
+       const char *victoryGUTText;
+       const char *victoryMGRText;
+
 
        Resources();
 
index e2cc99fb27cc3e7799d0dde3728958c4a1f45538..59d4495f68c5d4c0c4ef7349b229016235dc83f2 100644 (file)
@@ -3,6 +3,7 @@
 #include "../Battle.h"
 #include "../BattleState.h"
 #include "../Hero.h"
+#include "../Resources.h"
 #include "../../app/Application.h"
 #include "../../app/Input.h"
 #include "../../common/Capsule.h"
@@ -13,6 +14,7 @@
 #include "../../graphics/Font.h"
 #include "../../graphics/Frame.h"
 
+#include <iomanip>
 #include <sstream>
 
 using app::Application;
@@ -22,7 +24,12 @@ using common::Upgrade;
 using graphics::Font;
 using graphics::Frame;
 using math::Vector;
+using std::left;
+using std::right;
+using std::setfill;
+using std::setw;
 using std::string;
+using std::stringstream;
 using std::vector;
 
 namespace battle {
@@ -33,15 +40,19 @@ void VictoryState::OnEnterState(SDL_Surface *screen) {
 }
 
 void VictoryState::LoadResults() {
-       // TODO: localization
+       const Resources &res = parent->Res();
        lines.clear();
 
-       std::stringstream s;
-       s << "Gets " << battle->ExpReward() << " EXP";
+       stringstream s;
+       s << res.victoryGetsText << ' '
+                       << battle->ExpReward() << ' '
+                       << res.victoryExpText << '.';
        lines.push_back(s.str());
 
        s.str("");
-       s << "Gets " << battle->GoldReward() << " gold";
+       s << res.victoryGetsText << ' '
+                       << battle->GoldReward() << ' '
+                       << res.victoryGoldText << '.';
        lines.push_back(s.str());
 
        lines.push_back("");
@@ -49,55 +60,82 @@ void VictoryState::LoadResults() {
        GameState &state = *parent->Game().state;
        vector<Upgrade> upgrade;
        battle->ApplyRewards(state, upgrade);
-       for (std::vector<Upgrade>::const_iterator
+       for (vector<Upgrade>::const_iterator
                        i(upgrade.begin()), end(upgrade.end());
                        i != end; ++i) {
                LoadResult(*i, lines);
        }
 
+       s.str("");
+       s << state.money << ' ' << res.victoryGoldText;
+       string goldStr = s.str();
+
        lines.push_back("");
        s.str("");
-       s << state.money << " gold";
+       s << right << setw(28) << setfill(' ') << goldStr;
        lines.push_back(s.str());
 }
 
 void VictoryState::LoadResult(
                const Upgrade &u,
                vector<string> &lines) {
-       std::stringstream s;
+       const Resources &res = parent->Res();
+       stringstream s;
        switch (u.GetType()) {
                case Upgrade::LEVEL_UP:
-                       s << u.Name() << " levels up.";
+                       s << left << setw(6) << setfill(' ') << u.Name()
+                                       << res.victoryLevelUpText << '.';
                        break;
                case Upgrade::MAX_HEALTH:
-                       s << "Max. HP increases by " << u.Amount();
+                       s << res.victoryMHPText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::MAX_MAGIC:
-                       s << "Max. MP increases by " << u.Amount();
+                       s << res.victoryMMPText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::ATTACK:
-                       s << "ATP increases by " << u.Amount();
+                       s << res.victoryATPText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::DEFENSE:
-                       s << "DFP increases by " << u.Amount();
+                       s << res.victoryDFPText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::STRENGTH:
-                       s << "STR increases by " << u.Amount();
+                       s << res.victorySTRText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::AGILITY:
-                       s << "AGL increases by " << u.Amount();
+                       s << res.victoryAGLText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::INTELLIGENCE:
-                       s << "INT increases by " << u.Amount();
+                       s << res.victoryINTText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::GUT:
-                       s << "GUT increases by " << u.Amount();
+                       s << res.victoryGUTText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::MAGIC_RESISTANCE:
-                       s << "MGR increases by " << u.Amount();
+                       s << res.victoryMGRText << ' '
+                                       << res.victoryUpgradeText << ' '
+                                       << u.Amount() << '.';
                        break;
                case Upgrade::LEVEL_NEXT:
-                       s << u.Name() << " next level " << u.Amount();
+                       s << setw(7) << setfill(' ')
+                                       << left << u.Name() << ' '
+                                       << res.victoryNextLevelText
+                                       << ' ' << u.Amount();
                        break;
                default:
                        s << "unknown upgrade type " << u.GetType();
index 7b187aafbeaf4d62228c57a90afb8fe818818162..500039f8e5756048daf9638b3fca42c40f994483 100644 (file)
@@ -650,7 +650,24 @@ export BattleResources battleResources {
        },
        noEquipmentText: "No equip",
 
-       escapeText: "Escapes."
+       escapeText: "Escapes.",
+
+       victoryGetsText: "Gets",
+       victoryExpText: "EXP",
+       victoryGoldText: "GOLD",
+       victoryLevelUpText: "levels up",
+       victoryUpgradeText: "increases by",
+       victoryNextLevelText: "NXT.LEVEL",
+
+       victoryMHPText: "Max. HP",
+       victoryMMPText: "Max. MP",
+       victoryATPText: "ATP",
+       victoryDFPText: "DFP",
+       victorySTRText: "STR",
+       victoryAGLText: "AGL",
+       victoryINTText: "INT",
+       victoryGUTText: "GUT",
+       victoryMGRText: "MGR"
 }
 
 Font menuFont {