diff --git a/projects/mtg/Makefile b/projects/mtg/Makefile index 8ccc3c822..509ddc414 100644 --- a/projects/mtg/Makefile +++ b/projects/mtg/Makefile @@ -1,4 +1,4 @@ -OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TexturesCache.o objs/Token.o objs/utils.o objs/WEvent.o +OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS)) RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache) diff --git a/projects/mtg/bin/Res/lang/README.txt b/projects/mtg/bin/Res/lang/README.txt new file mode 100644 index 000000000..8587119a0 --- /dev/null +++ b/projects/mtg/bin/Res/lang/README.txt @@ -0,0 +1 @@ +To translate Wagic into the language of your choice, rename the file xx.txt (where "xx" is your chosen language) into "_lang.txt" \ No newline at end of file diff --git a/projects/mtg/bin/Res/lang/fr.txt b/projects/mtg/bin/Res/lang/fr.txt new file mode 100644 index 000000000..d8107e6f9 --- /dev/null +++ b/projects/mtg/bin/Res/lang/fr.txt @@ -0,0 +1,87 @@ +#Fichier de traduction Francais pour Wagic The Homebrew 0.6.0 +#Renommez ce fichier "_lang.txt" et redemarrez le jeu, la traduction devrait etre automatique + +#Note to translators: +#If you want to translate cards, I suggest you translate their text (the "text=" line) directly in _cards.dat, +# BUT DO NOT TOUCH ANYTHING ELSE in the _cards.dat files (names and types of creatures are used by the game!) +# If you want to translate creature types and other game elements, do it in this file. Only the "text=" can be done directly in _cards.dat +#Limitation: Special characters that are not in the limited 128 ASCII set CAN NOT be put in this file, it will display as garbage + +#Game menus/texts +Play=Jouer +Deck Editor=Editeur de Deck +Shop=Magasin +Exit=Quitter +1 Player=1 Joueur +2 Players=2 Joueurs +Player=Joueur +Cancel=Annuler +Classic=Classique +Music volume=Volume Musique +SFX volume=Volume Sons +Seconds to pause for an Interrupt=Secondes pour interruption +Difficulty=Difficulte +Image Cache Size=Taille du cache images +Save & Back to Main Menu=Sauver & retour au Menu +Back to Main Menu=Retour au menu +Back to main menu=Retour au menu +--NEW--=--NOUVEAU-- +Save=Sauver +Choose a Deck=Choix du deck +Choose Opponent=Choix de l'adversaire +(easy)=(facile) +(hard)=(difficile) +Random=Aleatoire + +#Phases +Untap=Degagement +Upkeep=Entretien +Draw=Pioche +Main phase 1=Phase principale 1 +Combat begins=Debut du combat +Attackers=Attaquants +Blockers=Bloqueurs +Combat damage=Blessures +Combat ends=Fin du combat +Main phase 2=Phase principale 2 +End of turn=Fin du tour +Cleanup=Nettoyage + +#Deck Editor +Prev.=Prec. +card=carte +cards=cartes +Next=Suiv. +Next color=Couleur suiv. +Prev. color=Couleur prec. +Add card=Ajouter carte +Display Deck=Afficher deck +Remove Card=Enlever carte +Display collection=Afficher collection +Your Deck=Votre deck +You are currently viewing your=Vous etes sur votre +collection. Press TRIANGLE=collection. Appuyez sur TRIANGLE +to switch to your deck=pour voir votre deck +deck. Press TRIANGLE to=deck. Appuyez sur TRIANGLE +switch to your collection= pour voire votre collection + +Deck info=Info deck +Sell card=Vendre carte +#types +artifact=artefact +enchantment=enchantement +sorcey=rituel +instant=ephemere +land=terrain + +#subtypes +#please keep the english alphabetical order, makes it easier to update! +angel=ange +elf=elfe +human=humain +sorcerer=sorcier +wurm=guivre + +#card names +#please keep this alphabetized +Black Knight=Chevalier Noir \ No newline at end of file diff --git a/projects/mtg/include/ActionStack.h b/projects/mtg/include/ActionStack.h index 3b584492e..905a70144 100644 --- a/projects/mtg/include/ActionStack.h +++ b/projects/mtg/include/ActionStack.h @@ -124,7 +124,7 @@ class ActionStack :public GuiLayer{ Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0 , int display = -1); int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1); void Fizzle(Interruptible * action); - Interruptible * _(int id); + Interruptible * getAt(int id); void cancelInterruptOffer(int cancelMode = 1); void endOfInterruption(); Interruptible * getLatest(int state); diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index a3b87dd06..4193148d8 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -538,7 +538,7 @@ class ASpellCastLife:public MTGAbility{ int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL){ if (_card == source && game->currentlyActing()->game->inPlay->hasCard(source)){ if (game->currentlyActing()->getManaPool()->canAfford(cost)){ - Interruptible * laststackitem = game->mLayers->stackLayer()->_(-1); + Interruptible * laststackitem = game->mLayers->stackLayer()->getAt(-1); if (laststackitem && laststackitem->type == ACTION_SPELL){ Spell * spell = (Spell*)laststackitem; if (spell->source != lastUsedOn && trigger.match(spell->source)){ @@ -2517,7 +2517,7 @@ class AIslandSanctuary:public MTGAbility{ int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){ if (card==source && game->currentPlayer == card->controller() && currentPhase == Constants::MTG_PHASE_DRAW){ - Interruptible * action = game->mLayers->stackLayer()->_(-1); + Interruptible * action = game->mLayers->stackLayer()->getAt(-1); if (action->type == ACTION_DRAW) return 1; } return 0; @@ -2526,7 +2526,7 @@ class AIslandSanctuary:public MTGAbility{ int reactToClick(MTGCardInstance * card){ if (!isReactingToClick(card)) return 0; - game->mLayers->stackLayer()->Remove(game->mLayers->stackLayer()->_(-1)); + game->mLayers->stackLayer()->Remove(game->mLayers->stackLayer()->getAt(-1)); initThisTurn = 1; return 1; } diff --git a/projects/mtg/include/GameStateDeckViewer.h b/projects/mtg/include/GameStateDeckViewer.h index 0487ae96b..be63b9796 100644 --- a/projects/mtg/include/GameStateDeckViewer.h +++ b/projects/mtg/include/GameStateDeckViewer.h @@ -13,6 +13,7 @@ #include "../include/PriceList.h" #include "../include/PlayerData.h" #include "../include/DeckDataWrapper.h" +#include "../include/Translate.h" #define NO_USER_ACTIVITY_HELP_DELAY 10 #define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1 @@ -330,7 +331,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener int rnd = (rand() % 20); price = pricelist->getPrice(card->getMTGId()) / 2; price = price - price * (rnd -10)/100; - sprintf(buffer,"%s : %i credits",card->getName(),price); + sprintf(buffer,"%s : %i %s",_(card->getName()).c_str(),price,_("credits").c_str()); sellMenu = NEW SimpleMenu(2,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer); sellMenu->Add(20,"Yes"); sellMenu->Add(21,"No"); @@ -534,12 +535,12 @@ class GameStateDeckViewer: public GameState, public JGuiListener r->RenderQuad(pspIcons[3],leftPspX + 20, leftPspY,0,pspIconsSize,pspIconsSize); - font->DrawString("Prev.", leftPspX - 35, leftPspY-15); - font->DrawString("Next", leftPspX + 15, leftPspY-15); - font->DrawString("card", leftPspX - 35, leftPspY); - font->DrawString("card", leftPspX + 15, leftPspY); - font->DrawString("Next color", leftPspX - 33, leftPspY - 35); - font->DrawString("Prev. color", leftPspX -33 , leftPspY +25); + font->DrawString(_("Prev.").c_str(), leftPspX - 35, leftPspY-15); + font->DrawString(_("Next").c_str(), leftPspX + 15, leftPspY-15); + font->DrawString(_("card").c_str(), leftPspX - 35, leftPspY); + font->DrawString(_("card").c_str(), leftPspX + 15, leftPspY); + font->DrawString(_("Next color").c_str(), leftPspX - 33, leftPspY - 35); + font->DrawString(_("Prev. color").c_str(), leftPspX -33 , leftPspY +25); //RIGHT PSP CIRCLE render r->FillCircle(rightPspX+(onScreenTransition*204),rightPspY,40,ARGB(128,50,50,50)); @@ -549,16 +550,16 @@ class GameStateDeckViewer: public GameState, public JGuiListener r->RenderQuad(pspIcons[7],rightPspX, rightPspY + 20,0,pspIconsSize,pspIconsSize); if (displayed_deck == myCollection){ - font->DrawString("Add card", rightPspX + 20, rightPspY-15); - font->DrawString("Display Deck", rightPspX - 35, rightPspY - 40); + font->DrawString(_("Add card").c_str(), rightPspX + 20, rightPspY-15); + font->DrawString(_("Display Deck").c_str(), rightPspX - 35, rightPspY - 40); }else{ - font->DrawString("Remove card", rightPspX + 20, rightPspY-15); - font->DrawString("Display Collection", rightPspX - 35, rightPspY - 40); + font->DrawString(_("Remove card").c_str(), rightPspX + 20, rightPspY-15); + font->DrawString(_("Display Collection").c_str(), rightPspX - 35, rightPspY - 40); } - font->DrawString("Deck info", rightPspX - 70 , rightPspY-15); - font->DrawString("Sell card", rightPspX - 30 , rightPspY+20); + font->DrawString(_("Deck info").c_str(), rightPspX - 70 , rightPspY-15); + font->DrawString(_("Sell card").c_str(), rightPspX - 30 , rightPspY+20); //Bottom menus - font->DrawString("menu", SCREEN_WIDTH-35 +rightTransition, SCREEN_HEIGHT-15); + font->DrawString(_("menu").c_str(), SCREEN_WIDTH-35 +rightTransition, SCREEN_HEIGHT-15); @@ -575,7 +576,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener } } int value = myDeck->getCount(); - sprintf(buffer, "Your Deck: %i cards", value); + sprintf(buffer, "%s: %i %s", _("Your Deck").c_str(), value, _("cards").c_str()); font->DrawString(buffer, SCREEN_WIDTH-200+rightTransition, SCREEN_HEIGHT/2 + 25); //TODO, put back ! @@ -587,13 +588,13 @@ class GameStateDeckViewer: public GameState, public JGuiListener */ - font->DrawString("You are currently viewing your", SCREEN_WIDTH-200+rightTransition, 5); + font->DrawString(_("You are currently viewing your").c_str(), SCREEN_WIDTH-200+rightTransition, 5); if (displayed_deck == myCollection){ - font->DrawString("collection. Press TRIANGLE", SCREEN_WIDTH-200+rightTransition, 20); - font->DrawString("to switch to your deck", SCREEN_WIDTH-200+rightTransition, 35); + font->DrawString(_("collection. Press TRIANGLE").c_str(), SCREEN_WIDTH-200+rightTransition, 20); + font->DrawString(_("to switch to your deck").c_str(), SCREEN_WIDTH-200+rightTransition, 35); }else{ - font->DrawString("deck. Press TRIANGLE to", SCREEN_WIDTH-200+rightTransition, 20); - font->DrawString("switch to your collection", SCREEN_WIDTH-200+rightTransition, 35); + font->DrawString(_("deck. Press TRIANGLE to").c_str(), SCREEN_WIDTH-200+rightTransition, 20); + font->DrawString(_("switch to your collection").c_str(), SCREEN_WIDTH-200+rightTransition, 35); } } diff --git a/projects/mtg/include/MenuItem.h b/projects/mtg/include/MenuItem.h index 75fe2ac84..96ecd48d9 100644 --- a/projects/mtg/include/MenuItem.h +++ b/projects/mtg/include/MenuItem.h @@ -15,7 +15,7 @@ class MenuItem: public JGuiObject private: bool mHasFocus; JLBFont *mFont; - const char* const mText; + string mText; int mX; int mY; int updatedSinceLastRender; @@ -29,7 +29,7 @@ class MenuItem: public JGuiObject public: - MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false); + MenuItem(int id, JLBFont *font, string text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false); ~MenuItem(); virtual void Render(); virtual void Update(float dt); diff --git a/projects/mtg/include/SimpleMenuItem.h b/projects/mtg/include/SimpleMenuItem.h index 933f0581b..fdba3118b 100644 --- a/projects/mtg/include/SimpleMenuItem.h +++ b/projects/mtg/include/SimpleMenuItem.h @@ -24,7 +24,7 @@ class SimpleMenuItem: public JGuiObject float mTargetScale; public: - SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, const char* text, int x, int y, bool hasFocus = false); + SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus = false); int mX; int mY; diff --git a/projects/mtg/include/Translate.h b/projects/mtg/include/Translate.h new file mode 100644 index 000000000..5a7dda9d9 --- /dev/null +++ b/projects/mtg/include/Translate.h @@ -0,0 +1,23 @@ +#ifndef _TRANSLATE_H_ +#define _TRANSLATE_H_ + +#include +#include + +using namespace std; + +class Translator{ + protected: + static Translator * mInstance; +public: + map values; + string translate(string toTranslate); + Translator(); + int Add(string from, string to); + static Translator * GetInstance(); + static void EndInstance(); +}; + +string _(string toTranslate); + +#endif \ No newline at end of file diff --git a/projects/mtg/src/ActionStack.cpp b/projects/mtg/src/ActionStack.cpp index 6e2224c08..316e4aa07 100644 --- a/projects/mtg/src/ActionStack.cpp +++ b/projects/mtg/src/ActionStack.cpp @@ -10,7 +10,7 @@ #include "../include/GameOptions.h" // WALDORF - added to support drawing big cards during interrupts #include "../include/CardGui.h" - +#include "../include/Translate.h" /* NextGamePhase requested by user @@ -29,7 +29,7 @@ void NextGamePhase::Render(){ char buffer[200]; int playerId = 1; if (GameObserver::GetInstance()->currentActionPlayer == GameObserver::GetInstance()->players[1]) playerId = 2; - sprintf(buffer, "Player %i : -> %s", playerId, Constants::MTGPhaseNames[nextPhase]); + sprintf(buffer, "%s %i : -> %s", _("Player").c_str(), playerId, _(Constants::MTGPhaseNames[nextPhase]).c_str()); mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT); } @@ -48,7 +48,7 @@ void StackAbility::Render(){ mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); char buffer[200]; - sprintf(buffer, "%s", ability->getMenuText()); + sprintf(buffer, "%s", _(ability->getMenuText()).c_str()); mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = ability->source->getThumb(); @@ -57,7 +57,7 @@ void StackAbility::Render(){ float scale = 30 / quad->mHeight; renderer->RenderQuad(quad, x , y , 0,scale,scale); }else{ - mFont->DrawString(ability->source->getName(),x,y-15); + mFont->DrawString(_(ability->source->getName()).c_str(),x,y-15); } } StackAbility::StackAbility(int id,MTGAbility * _ability): Interruptible(id),ability(_ability){ @@ -111,7 +111,7 @@ void Spell::Render(){ JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT); mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); - mFont->DrawString(source->getName(), x + 30 , y, JGETEXT_LEFT); + mFont->DrawString(_(source->getName()).c_str(), x + 30 , y, JGETEXT_LEFT); JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = source->getThumb(); if (quad){ @@ -162,7 +162,7 @@ void Spell::Render(){ renderer->RenderQuad(quad, x + 150 , y , 0,scale,scale); }else{ if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE) - mFont->DrawString(((MTGCardInstance *)target)->getName(),x+120,y); + mFont->DrawString(_(((MTGCardInstance *)target)->getName()).c_str(),x+120,y); } } } @@ -191,9 +191,9 @@ void PutInGraveyard::Render(){ mFont->SetBase(0); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); if (!removeFromGame){ - mFont->DrawString("goes to graveyard", x + 30 , y, JGETEXT_LEFT); + mFont->DrawString(_("goes to graveyard").c_str(), x + 30 , y, JGETEXT_LEFT); }else{ - mFont->DrawString("is removed from game", x + 30 , y, JGETEXT_LEFT); + mFont->DrawString(_("is removed from game").c_str(), x + 30 , y, JGETEXT_LEFT); } JRenderer * renderer = JRenderer::GetInstance(); JQuad * quad = card->getThumb(); @@ -295,7 +295,7 @@ int ActionStack::addSpell(MTGCardInstance * _source, Targetable * _targets[], in } -Interruptible * ActionStack::_(int id){ +Interruptible * ActionStack::getAt(int id){ if (id < 0) id = mCount + id; if (id > mCount -1) return NULL; return (Interruptible *)mObjects[id]; @@ -760,9 +760,9 @@ void ActionStack::Render(){ // seconds if the user disables auto progressing interrupts by setting the seconds // value to zero in Options. if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0) - sprintf(buffer, "Interrupt?"); + sprintf(buffer, _("Interrupt?").c_str()); else - sprintf(buffer, "Interrupt? %i", static_cast(timer)); + sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast(timer)); //WALDORF - removed all the unnecessary math. just display the prompt at the // top of the box. @@ -770,8 +770,8 @@ void ActionStack::Render(){ mFont->DrawString(buffer, x0 + 5, y0); - if (mCount > 1) sprintf(buffer, "X Interrupt - 0 No - [] No to All"); - else sprintf(buffer, "X Interrupt - 0 No"); + if (mCount > 1) sprintf(buffer, _("X Interrupt - 0 No - [] No to All").c_str()); + else sprintf(buffer, _("X Interrupt - 0 No").c_str()); // WALDORF - puts the button legend right under the prompt. the stack // will be displayed below it now. no more need to do wierd currY math. diff --git a/projects/mtg/src/CardGui.cpp b/projects/mtg/src/CardGui.cpp index 36e4bf210..918e53fdf 100644 --- a/projects/mtg/src/CardGui.cpp +++ b/projects/mtg/src/CardGui.cpp @@ -2,6 +2,7 @@ #include "../include/CardGui.h" #include "../include/ManaCostHybrid.h" #include "../include/Subtypes.h" +#include "../include/Translate.h" #include "../include/MTGDefinitions.h" #include @@ -112,6 +113,7 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float if (!card->formattedTextInit){ std::string s(card->getText()); + s = _(s); std::string::size_type found=s.find_first_of("{}"); while (found!=string::npos) { @@ -160,7 +162,7 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float v.x = ((-width/2)+10) * scale; v.y = ((-height/2) + 25) * scale; v.Rotate(rotation); - int over = strlen(card->getName()) - 23; + int over = strlen(_(card->getName()).c_str()) - 23; float multiply = 1.4; if (over > 0){ multiply = 1.1; @@ -168,7 +170,7 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float mFont->SetScale(scale * multiply); mFont->SetColor(ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color])); - mFont->DrawString(card->getName(),x+v.x,y+v.y); + mFont->DrawString(_(card->getName()).c_str(),x+v.x,y+v.y); mFont->SetScale(scale); mFont->SetColor(ARGB(255,255,255,255)); @@ -186,7 +188,7 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float v.y = (height/2-20 - 12 * i) * scale; v.Rotate(rotation); string s = Subtypes::subtypesList->find(card->types[i]); - mFont->DrawString(s.c_str(),x+v.x,y+v.y); + mFont->DrawString(_(s).c_str(),x+v.x,y+v.y); } mFont->SetScale(backup); diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index 1c4af85f4..f54dc1252 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -15,6 +15,7 @@ #include "../include/GameStateOptions.h" #include "../include/GameStateShop.h" #include "../include/DeckStats.h" +#include "../include/Translate.h" const char * const GameState::menuTexts[]= {"--NEW--","Deck 1", "Deck 2", "Deck 3", "Deck 4", "Deck 5", "Deck 6"} ; JResourceManager* GameApp::CommonRes = NEW JResourceManager(); @@ -190,7 +191,7 @@ void GameApp::Destroy() SAFE_DELETE(MtgSets::SetsList); SAFE_DELETE(music); - + Translator::EndInstance(); SimpleMenu::destroy(); diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index d1a3449f5..5bbe19b73 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -8,6 +8,7 @@ #include "../include/DeckStats.h" #include "../include/MTGRules.h" #include "../include/Credits.h" +#include "../include/Translate.h" #ifdef TESTSUITE #include "../include/TestSuiteAI.h" @@ -285,7 +286,7 @@ void GameStateDuel::Update(float dt) }else{ difficulty = "(easy)"; } - sprintf(deckDesc, "Deck %i %s",nbAIDecks, difficulty.c_str()); + sprintf(deckDesc, "Deck %i %s",nbAIDecks, _(difficulty).c_str()); opponentMenu->Add(nbAIDecks,deckDesc); } } diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 690d7ec01..0112fcef9 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -5,6 +5,8 @@ #include "../include/GameOptions.h" #include "../include/GameApp.h" #include "../include/MTGCard.h" +#include "../include/Translate.h" + static const char* GAME_VERSION = "WTH?! 0.6.2 - by WilLoW"; #define ALPHA_WARNING 0 diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index 36ca6093b..453814485 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -4,6 +4,7 @@ #include "../include/OptionItem.h" #include "../include/SimpleMenu.h" #include "../include/GameOptions.h" +#include "../include/Translate.h" GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent) { optionsList = NULL; @@ -31,7 +32,7 @@ void GameStateOptions::Start() if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) { optionsList->Add(NEW OptionItem(OPTIONS_DIFFICULTY, "Difficulty", 3, 1)); } - optionsList->Add(NEW OptionItem(OPTIONS_CACHESIZE, "Cache Size", 60, 5)); + optionsList->Add(NEW OptionItem(OPTIONS_CACHESIZE, "Image Cache Size", 60, 5)); JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170); optionsMenu->Add(1, "Save & Back to Main Menu"); @@ -102,7 +103,7 @@ void GameStateOptions::Render() for (int i = 0; i < size; i++){ pos = startpos +20*i; if (pos > -20){ - mFont->DrawString(CreditsText[i],SCREEN_WIDTH/2,pos ,JGETEXT_CENTER); + mFont->DrawString(_(CreditsText[i]).c_str(),SCREEN_WIDTH/2,pos ,JGETEXT_CENTER); } } diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index dfed66980..396690cc5 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -6,6 +6,7 @@ #include "../include/GameStateShop.h" #include "../include/GameApp.h" #include "../include/MTGDeck.h" +#include "../include/Translate.h" GameStateShop::GameStateShop(GameApp* parent): GameState(parent) {} @@ -63,7 +64,7 @@ void GameStateShop::Start() shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds); for (int i = 0; i < SHOP_BOOSTERS; i++){ - sprintf(setNames[i], "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[i]].c_str()); + sprintf(setNames[i], "%s Booster (15 %s)",MtgSets::SetsList->values[setIds[i]].c_str(), _("cards").c_str()); shop->Add(setNames[i],mBack,mBackThumb, 1200); } @@ -96,7 +97,7 @@ void GameStateShop::Update(float dt) menu->Update(dt); }else{ menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20); - menu->Add(12,"Save & Back to main menu"); + menu->Add(12,"Save & Back to Main Menu"); menu->Add(13, "Cancel"); } }else{ diff --git a/projects/mtg/src/MTGGuiPlay.cpp b/projects/mtg/src/MTGGuiPlay.cpp index b8db82a74..66c9a0321 100644 --- a/projects/mtg/src/MTGGuiPlay.cpp +++ b/projects/mtg/src/MTGGuiPlay.cpp @@ -7,6 +7,7 @@ #include "../include/MTGCardInstance.h" #include "../include/CardGui.h" #include "../include/CardDisplay.h" +#include "../include/Translate.h" #define ZX_MAIN 100 #define ZY_MAIN 22 @@ -329,7 +330,7 @@ void MTGGuiPlay::RenderPhaseBar(){ mFont->SetColor(ARGB(255,255,255,255)); } mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); - mFont->DrawString(Constants::MTGPhaseNames[currentPhase], 375, 2); + mFont->DrawString(_(Constants::MTGPhaseNames[currentPhase]).c_str(), 375, 2); } void MTGGuiPlay::Render(){ diff --git a/projects/mtg/src/MenuItem.cpp b/projects/mtg/src/MenuItem.cpp index dc743b5e8..338115e16 100644 --- a/projects/mtg/src/MenuItem.cpp +++ b/projects/mtg/src/MenuItem.cpp @@ -1,9 +1,10 @@ #include "../include/config.h" #include "../include/MenuItem.h" +#include "../include/Translate.h" - -MenuItem::MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mText(text), mX(x), mY(y) +MenuItem::MenuItem(int id, JLBFont *font, string text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y) { + mText = _(text); updatedSinceLastRender = 1; mParticleSys = NEW hgeParticleSystem(particle, particleTex); mParticleSys->MoveTo(mX, mY); @@ -41,7 +42,7 @@ void MenuItem::Render() onQuad->SetColor(ARGB(70,255,255,255)); renderer->RenderQuad(onQuad, SCREEN_WIDTH , SCREEN_HEIGHT/2 , 0,8,8); onQuad->SetColor(ARGB(255,255,255,255)); - mFont->DrawString(mText, SCREEN_WIDTH/2, 20 + 3*SCREEN_HEIGHT/4, JGETEXT_CENTER); + mFont->DrawString(mText.c_str(), SCREEN_WIDTH/2, 20 + 3*SCREEN_HEIGHT/4, JGETEXT_CENTER); renderer->RenderQuad(onQuad, mX , mY , 0,mScale,mScale); } diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index ff6c19a36..9c6f44045 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -2,13 +2,13 @@ #include "../include/GameApp.h" #include #include "../include/GameOptions.h" - +#include "../include/Translate.h" OptionItem::OptionItem(string _id, string _displayValue, int _maxValue, int _increment):JGuiObject(0){ id = _id; maxValue = _maxValue; increment = _increment; - displayValue = _displayValue; + displayValue = _(_displayValue); value = GameOptions::GetInstance()->values[id].getIntValue(); hasFocus = 0; x = 0; diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 40447f351..7e6e28b8d 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -3,6 +3,7 @@ #include "../include/SimpleMenuItem.h" #include "JTypes.h" #include "../include/GameApp.h" +#include "../include/Translate.h" const unsigned SimpleMenu::SIDE_SIZE = 7; const unsigned SimpleMenu::VMARGIN = 16; @@ -37,7 +38,7 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int mX = x; mY = y; mFont = font; - title = _title; + title = _(_title); startId = 0; maxItems = _maxItems; selectionT = 0; diff --git a/projects/mtg/src/SimpleMenuItem.cpp b/projects/mtg/src/SimpleMenuItem.cpp index 0abf28905..ae0edc6a3 100644 --- a/projects/mtg/src/SimpleMenuItem.cpp +++ b/projects/mtg/src/SimpleMenuItem.cpp @@ -1,10 +1,10 @@ #include "../include/config.h" #include "../include/SimpleMenuItem.h" +#include "../include/Translate.h" - -SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, const char* text, int x, int y, bool hasFocus): JGuiObject(id), parent(_parent), mFont(font), mX(x), mY(y) +SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus): JGuiObject(id), parent(_parent), mFont(font), mX(x), mY(y) { - mText = text; + mText = _(text); mHasFocus = hasFocus; mScale = 1.0f; diff --git a/projects/mtg/src/Translate.cpp b/projects/mtg/src/Translate.cpp new file mode 100644 index 000000000..2ba62252e --- /dev/null +++ b/projects/mtg/src/Translate.cpp @@ -0,0 +1,51 @@ +#include "../include/Translate.h" +#include "../include/config.h" +#include +#include +#include + +Translator * Translator::mInstance = NULL; + +Translator * Translator::GetInstance(){ + if (!mInstance) mInstance = NEW Translator(); + return mInstance; +} + +void Translator::EndInstance(){ + SAFE_DELETE(mInstance); +} + +int Translator::Add(string from, string to){ + values[from] = to; + return 1; +} + +string Translator::translate(string value){ + map::iterator it = values.find(value); + if (it != values.end()) return it->second; + return value; +} + +Translator::Translator(){ + std::ifstream file("Res/lang/_lang.txt"); + std::string s; + + if(file){ + while(std::getline(file,s)){ + if (!s.size()) continue; + if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files + size_t found = s.find('='); + if (found == string::npos) continue; + string s1 = s.substr(0,found); + string s2 = s.substr(found+1); + Add(s1,s2); + } + file.close(); + } +} + +string _(string toTranslate){ + Translator * t = Translator::GetInstance(); + return t->translate(toTranslate); +} + diff --git a/projects/mtg/template.vcproj b/projects/mtg/template.vcproj index 936bd49b1..81506693a 100644 --- a/projects/mtg/template.vcproj +++ b/projects/mtg/template.vcproj @@ -492,6 +492,10 @@ RelativePath=".\src\Token.cpp" > + + @@ -785,6 +789,10 @@ RelativePath=".\include\Token.h" > + +