- Language is now an option at startup
- "text" line translation for cards made easier, check Res/lang/xx_cards.txt
- TODO: test on PSP/Linux, performance issues ? Allow possibility to change language in options menu
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-11-13 16:10:06 +00:00
parent 3b49f65958
commit 8390a94440
15 changed files with 13549 additions and 10923 deletions

View File

@@ -1 +0,0 @@
To translate Wagic into the language of your choice, rename the file xx.txt (where "xx" is your chosen language) into "_lang.txt"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
#LANG:English
#this file is here only to allow people to choose english

View File

@@ -1,3 +1,4 @@
#LANG:Espanol
#Traducción de Wagic The Homebrew 0.7.0 al Español
#Renombra este archivo a "_lang.txt" o substituye spa por _lang en el nombre del archivo para disfrutar de Wagic en Español

View File

@@ -1,3 +1,4 @@
#LANG:Francais
#Fichier de traduction Francais pour Wagic The Homebrew
#Placez ce fichier dans Res/lang.txt (renommez-le si necessaire), la traduction devrait etre automatique

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
#LANG:Italiano
#File di traduzione in Italiano per Wagic 0.8.1 - by Icarus
#Metti questo file nella cartella WTH/Res e rinominalo come _lang.txt
#Al prossimo avvio del gioco avrai il tutto tradotto
#Metti questo file nella cartella WTH/Res e rinominalo come _lang.txt
#Al prossimo avvio del gioco avrai il tutto tradotto
#Buon divertimento
#Note to translators:
@@ -13,7 +14,7 @@
LOADING SET: %s=CARICAMENTO SET: %s
Play=Gioca
Deck Editor=Deck Editor
Shop=Negozio
Shop=Negozio
Options=Opzioni
Exit=Esci
1 Player=1 Giocatore
@@ -22,12 +23,12 @@ Player=Giocatore
Cancel=Annulla
Classic=Classico
Music volume=Volume Musica
SFX volume=Volume Suoni
SFX volume=Volume Suoni
Interrupt my spells=Interrompi le mie magie
Interrupt my spells=Interrompi le mie magie
Interrupt my abilities=Interrompi le mie abilita'
Display InGame extra information=Mostra informazioni extra in gioco
Seconds to pause for an Interrupt=Secondi di pausa per Istantaneo
Difficulty=Difficolta'
@@ -47,7 +48,7 @@ You have played %i games with Deck%i=Hai giocato %i partite con il mazzo %i
You have played a total of %i games=Hai giocato in tutto %i partite
Unlock the difficult mode for more challenging duels!=Sblocca la modalita' difficile per partite piu' competitive!
Interested in playing Momir Basic? You'll have to unlock it first :)=Conosci Momir Basic? Sblocca questa modalita' per poterla provare
You have a total of %i cards in your collection=Hai un totale di %i carte nella tua collezione
You have a total of %i cards in your collection=Hai un totale di %i carte nella tua collezione
The cards in your collection have an average value of %i credits=Le carte nella tua collezione hanno un valore medio di %i crediti
The shopkeeper would buy your entire collection for around %i credits=Potresti vendere la tua intera collezione per circa %i crediti
@@ -60,7 +61,7 @@ NO DECK AVAILABLE,=NESSUN DECK DISPONIBILE,
PRESS CIRCLE TO GO TO THE DECK EDITOR!=PREMI CERCHIO PER TORNARE AL DECK EDITOR!
You haven't unlocked the random deck mode yet=Non hai ancora sbloccato la modalita' mazzo casuale
You haven't locked the random deck mode yet=Non hai ancora bloccato la modalita' mazzo casuale
You haven't unlocked the evil twin mode yet=Non hai ancora sbloccato la modalità evil twin
You haven't unlocked the evil twin mode yet=Non hai ancora sbloccato la modalit<EFBFBD>Eevil twin
You have unlocked %i expansions out of %i=Hai sbloccato %i espansioni su %i
Premade G/R=Mazzo Iniziale V/R
@@ -127,15 +128,15 @@ End=Fine
Cleanup=Fase di Scarto
#Stack
Deals %i damage to= Fa %i danno/i a
Deals %i damage to= Fa %i danno/i a
goes to graveyard= va' nel cimitero
%s goes to graveyard=%s va' nel cimitero
Deplete= Mette nel cimitero
Player %i draws %i card= Il Giocatore %i pesca %i carta
Deplete= Mette nel cimitero
Player %i draws %i card= Il Giocatore %i pesca %i carta
Damage=Danno
Ability=Abilita'
@@ -169,8 +170,8 @@ switch to your collection.=per vedere la collezione.
Press L/R to cycle through=Premi L/R per scorrere le
deck statistics.=statistiche del mazzo.
Deck info=Info Mazzo
Sell card=Vendi carta
Sell card=Vendi carta
No Card=Nessuna Carta
Your Deck: %i cards=Tuo Mazzo: %i carte
@@ -217,36 +218,36 @@ opponent's turn=turno avversario
opponent's turn - you play=turno avvers. - tocca a te
#Others
Add %i=Aggiungi %i
Add %i mana=Aggiungi %i mana
#Shop
press [] to refresh=premi [] per cambiare
credits: %i=crediti: %i
credits: %i=crediti: %i
#Not Working Lines - maybe not yet implemented for translation
#Linee non funzionanti - probabilmente non sono ancora state implementate per essere tradotte
#Your Deck:=Mazzo:
#Your Deck:=Mazzo:
#Your Deck=Mazzo
#Database: %i cards=Database: %i carte
#Database: %i cards=Database: %i carte
Collection=Collezione
Collection - %i/%i=Collezione - %i/%i
DECK: %i=MAZZO: %i
DECK:%i=MAZZO:%i
DECK: %i=MAZZO: %i
DECK:%i=MAZZO:%i
#types
@@ -268,7 +269,7 @@ forest=foresta
hound=segugio
human=umano
island=isola
knight=cavaliere
knight=cavaliere
mountain=montagna
plains=pianura
sliver=tramutante

View File

@@ -23,6 +23,7 @@ public:
enum {
//Global settings
ACTIVE_PROFILE,
LANG,
DIFFICULTY_MODE_UNLOCKED,
MOMIR_MODE_UNLOCKED,
EVILTWIN_MODE_UNLOCKED,

View File

@@ -26,6 +26,7 @@ class GameStateMenu: public GameState, public JGuiListener
//JMusic * bgMusic;
int mVolume;
char nbcardsStr[400];
vector<string> langs;
DIR *mDip;
struct dirent *mDit;
@@ -38,6 +39,11 @@ class GameStateMenu: public GameState, public JGuiListener
float angleW;
float yW;
void fillScroller();
void setLang(int id);
string getLang(string s);
void loadLangMenu();
public:
GameStateMenu(GameApp* parent);
virtual ~GameStateMenu();

View File

@@ -14,8 +14,12 @@ using namespace std;
class Translator{
protected:
static Translator * mInstance;
bool initDone;
void load(string filename, map<string,string> * dictionary);
public:
map<string,string> values;
map<string,string> tempValues;
#if defined DEBUG_TRANSLATE
map<string,int> missingValues;
map<string,int> dontCareValues;
@@ -25,6 +29,8 @@ public:
Translator();
~Translator();
int Add(string from, string to);
void initCards();
void init();
static Translator * GetInstance();
static void EndInstance();
};

View File

@@ -12,6 +12,7 @@
const char * Options::optionNames[] = {
//Global options
"Profile",
"Lang",
"prx_handler",
"prx_rimom",
"prx_eviltwin",

View File

@@ -27,6 +27,7 @@ enum ENUM_MENU_STATE_MAJOR
MENU_STATE_MAJOR_LOADING_CARDS = 0x04,
MENU_STATE_MAJOR_FIRST_TIME = 0x05,
MENU_STATE_MAJOR_DUEL = 0x06,
MENU_STATE_MAJOR_LANG = 0x07,
MENU_STATE_MAJOR = 0xFF
};
@@ -98,6 +99,15 @@ void GameStateMenu::Create()
}
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_NONE;
bool langChosen = false;
string lang = options[Options::LANG].str;
if (lang.size()){
lang = "Res/lang/" + lang + ".txt";
if (fileExists(lang.c_str())) langChosen = true;
}
if (!langChosen){
currentState = MENU_STATE_MAJOR_LANG | MENU_STATE_MINOR_NONE;
}
scroller = NEW TextScroller(resources.GetJLBFont(Constants::MAIN_FONT), SCREEN_WIDTH/2 - 90 , SCREEN_HEIGHT-17,180);
scrollerSet = 0;
}
@@ -117,18 +127,6 @@ void GameStateMenu::Start(){
JRenderer::GetInstance()->EnableVSync(true);
subMenuController = NULL;
SAFE_DELETE(mGuiController);
mGuiController = NEW JGuiController(100, this);
if (mGuiController)
{
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
mFont->SetColor(ARGB(255,255,255,255));
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"particle3.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"particle4.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"particle5.psi",resources.GetQuad("particles")));
}
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
GameApp::music = resources.ssLoadMusic("Track0.mp3");
@@ -258,10 +256,7 @@ int GameStateMenu::nextDirectory(const char * root, const char * file){
found = 1;
}
}
if (!mDit) {
closedir(mDip);
mDip = NULL;
}
if (!found) resetDirectory();
return found;
}
@@ -273,20 +268,69 @@ void GameStateMenu::End()
SAFE_DELETE(mGuiController);
}
string GameStateMenu::getLang(string s){
if (!s.size()) return "";
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
size_t found = s.find("#LANG:");
if (found != 0) return "";
return s.substr(6);
}
void GameStateMenu::setLang(int id){
options[Options::LANG].str = langs[id-1];
options.save();
}
void GameStateMenu::loadLangMenu(){
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(103, this, mFont, 150,60);
if (!subMenuController) return;
resetDirectory();
if (!mDip){
mDip = opendir("Res/lang");
}
while (mDit = readdir(mDip)){
string filename = "Res/lang/";
filename += mDit->d_name;
std::ifstream file(filename.c_str());
string s;
string lang;
if(file){
if(std::getline(file,s)){
lang = getLang(s);
}
file.close();
}
if (lang.size()){
string filen = mDit->d_name;
langs.push_back(filen.substr(0,filen.size()-4));
subMenuController->Add(langs.size(),lang.c_str());
}
}
resetDirectory();
}
void GameStateMenu::Update(float dt)
{
timeIndex += dt * 2;
switch (MENU_STATE_MAJOR & currentState)
{
switch (MENU_STATE_MAJOR & currentState) {
case MENU_STATE_MAJOR_LANG :
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) {
if (!subMenuController) loadLangMenu();
}
subMenuController->Update(dt);
break;
case MENU_STATE_MAJOR_LOADING_CARDS :
if (mReadConf){
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
}else{
mReadConf = 1;
Translator::GetInstance()->init();
}
if (!nextDirectory(RESPATH"/sets/","_cards.dat")){
//Remove temporary translations
Translator::GetInstance()->tempValues.clear();
//Force default, if necessary.
if(options[Options::ACTIVE_PROFILE].str == "")
@@ -301,9 +345,9 @@ void GameStateMenu::Update(float dt)
std::ifstream file(options.profileFile(PLAYER_COLLECTION).c_str());
if(file){
file.close();
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
currentState = MENU_STATE_MAJOR_MAINMENU;
}else{
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
currentState = MENU_STATE_MAJOR_FIRST_TIME;
}
//Reload list of unlocked sets, now that we know about the sets.
@@ -322,12 +366,24 @@ void GameStateMenu::Update(float dt)
}
break;
case MENU_STATE_MAJOR_FIRST_TIME :
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
currentState &= MENU_STATE_MAJOR_MAINMENU;
options.checkProfile(); //Handles building a new deck, if needed.
break;
case MENU_STATE_MAJOR_MAINMENU :
if (!scrollerSet) fillScroller();
if (NULL != mGuiController)
if (!mGuiController) {
mGuiController = NEW JGuiController(100, this);
if (mGuiController) {
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
mFont->SetColor(ARGB(255,255,255,255));
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true));
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"particle3.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"particle4.psi",resources.GetQuad("particles")));
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"particle5.psi",resources.GetQuad("particles")));
}
}
if (mGuiController)
mGuiController->Update(dt);
break;
case MENU_STATE_MAJOR_SUBMENU :
@@ -335,38 +391,35 @@ void GameStateMenu::Update(float dt)
mGuiController->Update(dt);
break;
case MENU_STATE_MAJOR_DUEL :
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
{
if (!hasChosenGameType){
currentState = MENU_STATE_MAJOR_SUBMENU;
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
if (subMenuController){
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (options[Options::MOMIR_MODE_UNLOCKED].number)
subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic");
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number){
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) {
if (!hasChosenGameType){
currentState = MENU_STATE_MAJOR_SUBMENU;
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
if (subMenuController){
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (options[Options::MOMIR_MODE_UNLOCKED].number)
subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic");
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number){
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
}
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
}
}else{
mParent->SetNextState(GAME_STATE_DUEL);
currentState = MENU_STATE_MAJOR_MAINMENU;
}
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
}
}else{
mParent->SetNextState(GAME_STATE_DUEL);
currentState = MENU_STATE_MAJOR_MAINMENU;
}
}
}
switch (MENU_STATE_MINOR & currentState)
{
}
switch (MENU_STATE_MINOR & currentState){
case MENU_STATE_MINOR_SUBMENU_CLOSING :
if (subMenuController->closed)
{
SAFE_DELETE(subMenuController);
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
}
else
subMenuController->Update(dt);
if (subMenuController->closed) {
SAFE_DELETE(subMenuController);
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
} else
subMenuController->Update(dt);
break;
case MENU_STATE_MINOR_NONE :
;// Nothing to do.
@@ -411,7 +464,8 @@ void GameStateMenu::Render()
JRenderer * renderer = JRenderer::GetInstance();
renderer->ClearScreen(ARGB(0,0,0,0));
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LANG){
}else if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
if(!splashTex){
splashTex = resources.RetrieveTexture("splash.jpg",RETRIEVE_LOCK);
mSplash = resources.RetrieveTempQuad("splash.jpg");
@@ -420,7 +474,12 @@ void GameStateMenu::Render()
renderer->RenderQuad(mSplash,0,0);
}else{
char text[512];
sprintf(text, _("LOADING SET: %s").c_str(), mCurrentSetName);
mFont->SetColor(ARGB(255,255,255,255));
if (mCurrentSetName[0]) {
sprintf(text, _("LOADING SET: %s").c_str(), mCurrentSetName);
}else{
sprintf(text,"LOADING...");
}
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
}
}else{
@@ -449,10 +508,11 @@ void GameStateMenu::Render()
scroller->Render();
renderer->RenderQuad(mBg, SCREEN_WIDTH/2, 50);
if (subMenuController){
subMenuController->Render();
}
}
if (subMenuController){
subMenuController->Render();
}
}
@@ -466,6 +526,11 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
OutputDebugString(buf);
#endif
switch (controllerId){
case 103:
setLang(controlId);
subMenuController->Close();
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_SUBMENU_CLOSING;
break;
case 101:
options.createUsersFirstDeck(controlId);
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;

View File

@@ -1,6 +1,7 @@
#include "../include/config.h"
#include "../include/MTGDeck.h"
#include "../include/utils.h"
#include "../include/Translate.h"
#include <algorithm>
#include <string>
using std::string;
@@ -320,6 +321,13 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
SAFE_DELETE(tempCard);
}else{
ids.push_back(newId);
//translate cards text
Translator * t = Translator::GetInstance();
map<string,string>::iterator it = t->tempValues.find(tempCard->name);
if (it != t->tempValues.end()) {
tempCard->setText(it->second);
}
collection[newId] = tempCard;
total_cards++;
#if defined (_DEBUG)

View File

@@ -1,5 +1,6 @@
#include "../include/Translate.h"
#include "../include/config.h"
#include "../include/GameOptions.h"
#include <JGE.h>
#include <fstream>
#include <iostream>
@@ -21,6 +22,7 @@ int Translator::Add(string from, string to){
}
string Translator::translate(string value){
//if (!initDone) init();
map<string,string>::iterator it = values.find(value);
if (it != values.end()) return it->second;
#if defined DEBUG_TRANSLATE
@@ -50,13 +52,16 @@ Translator::~Translator(){
#endif
}
Translator::Translator(){
#if defined DEBUG_TRANSLATE
checkMisses = 0;
#endif
std::ifstream file("Res/lang/_lang.txt");
std::string s;
initDone = false;
//init();
}
void Translator::load(string filename, map<string,string> * dictionary) {
std::ifstream file(filename.c_str());
if(file){
string s;
initDone = true;
#if defined DEBUG_TRANSLATE
checkMisses = 1;
#endif
@@ -67,7 +72,7 @@ Translator::Translator(){
if (found == string::npos) continue;
string s1 = s.substr(0,found);
string s2 = s.substr(found+1);
Add(s1,s2);
(*dictionary)[s1] = s2;
}
file.close();
}
@@ -77,6 +82,7 @@ Translator::Translator(){
std::ifstream file2("Res/lang/dontcare.txt");
if(file2){
string s;
while(std::getline(file2,s)){
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
@@ -88,7 +94,30 @@ Translator::Translator(){
file2.close();
}
#endif
}
void Translator::initCards(){
string lang = options[Options::LANG].str;
if (!lang.size()) return;
string cards_dict = "Res/lang/" + lang + "_cards.txt";
load(cards_dict,&tempValues);
}
void Translator::init() {
#if defined DEBUG_TRANSLATE
checkMisses = 0;
#endif
string lang = options[Options::LANG].str;
if (!lang.size()) return;
string name = "Res/lang/" + lang + ".txt";
if (fileExists(name.c_str())){
initDone = true;
load(name,&values);
}
initCards();
}
string _(string toTranslate){