- Added translation mechanism, and basic french translation as an example
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-05-16 15:23:26 +00:00
parent 94bebd795c
commit f94df3862b
23 changed files with 242 additions and 60 deletions

View File

@@ -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)

View File

@@ -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"

View File

@@ -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

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -0,0 +1,23 @@
#ifndef _TRANSLATE_H_
#define _TRANSLATE_H_
#include <string>
#include <map>
using namespace std;
class Translator{
protected:
static Translator * mInstance;
public:
map<string,string> values;
string translate(string toTranslate);
Translator();
int Add(string from, string to);
static Translator * GetInstance();
static void EndInstance();
};
string _(string toTranslate);
#endif

View File

@@ -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<int>(timer));
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(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.

View File

@@ -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 <Vector2D.h>
@@ -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);

View File

@@ -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();

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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{

View File

@@ -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(){

View File

@@ -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);
}

View File

@@ -2,13 +2,13 @@
#include "../include/GameApp.h"
#include <JGE.h>
#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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -0,0 +1,51 @@
#include "../include/Translate.h"
#include "../include/config.h"
#include <JGE.h>
#include <fstream>
#include <iostream>
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<string,string>::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);
}

View File

@@ -492,6 +492,10 @@
RelativePath=".\src\Token.cpp"
>
</File>
<File
RelativePath=".\src\Translate.cpp"
>
</File>
<File
RelativePath=".\src\utils.cpp"
>
@@ -785,6 +789,10 @@
RelativePath=".\include\Token.h"
>
</File>
<File
RelativePath=".\include\Translate.h"
>
</File>
<File
RelativePath=".\include\utils.h"
>