multi lang support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include "utils.h"
|
||||
#include "lang.h"
|
||||
#include <string>
|
||||
|
||||
#ifndef CONST_H
|
||||
@@ -257,6 +258,9 @@ const int MULTIPLIER_NUMBER_Y = SCREEN_HEIGHT - (2 * BLOCK) + 2;
|
||||
#define BALLOON_WIDTH_3 21
|
||||
#define BALLOON_WIDTH_4 37
|
||||
|
||||
// PowerBall
|
||||
#define POWERBALL_SCREENPOWER_MINIMUM 10
|
||||
|
||||
// Tipos de bala
|
||||
#define BULLET_UP 1
|
||||
#define BULLET_LEFT 2
|
||||
|
||||
@@ -37,9 +37,6 @@ Director::Director(std::string path)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Carga recursos
|
||||
loadConfigFile();
|
||||
|
||||
// Inicializa el resto de variables
|
||||
init();
|
||||
}
|
||||
@@ -65,9 +62,21 @@ Director::~Director()
|
||||
// Inicia las variables necesarias para arrancar el programa
|
||||
void Director::init()
|
||||
{
|
||||
// Carga el fichero de configuración
|
||||
if (!loadConfigFile())
|
||||
{
|
||||
mOptions->fullScreenMode = 0;
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
}
|
||||
|
||||
// Sección
|
||||
mSection.name = PROG_SECTION_LOGO;
|
||||
mSection.subsection = 0;
|
||||
|
||||
// Textos
|
||||
initTextStrings(mTextStrings, mOptions->language);
|
||||
|
||||
// Teclado
|
||||
mInput->bindKey(INPUT_UP, SDL_SCANCODE_UP);
|
||||
mInput->bindKey(INPUT_DOWN, SDL_SCANCODE_DOWN);
|
||||
@@ -291,6 +300,11 @@ bool Director::checkFileList()
|
||||
// Carga el fichero de configuración
|
||||
bool Director::loadConfigFile()
|
||||
{
|
||||
// Pone unos valores por defecto
|
||||
mOptions->fullScreenMode = 0;
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
|
||||
@@ -303,20 +317,18 @@ bool Director::loadConfigFile()
|
||||
{
|
||||
printf("Warning: Unable to open %s file\n", filename.c_str());
|
||||
|
||||
// Creamos el fichero para escritura
|
||||
// Crea el fichero para escritura
|
||||
file = SDL_RWFromFile(p.c_str(), "w+b");
|
||||
if (file != NULL)
|
||||
{
|
||||
printf("New file (%s) created!\n", filename.c_str());
|
||||
|
||||
// Inicializamos los datos
|
||||
mOptions->fullScreenMode = 0;
|
||||
// Escribe los datos
|
||||
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
|
||||
|
||||
mOptions->windowSize = 3;
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
|
||||
// Cerramos el fichero
|
||||
// Cierra el fichero
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
else
|
||||
@@ -332,10 +344,22 @@ bool Director::loadConfigFile()
|
||||
printf("Reading file %s\n", filename.c_str());
|
||||
SDL_RWread(file, &mOptions->fullScreenMode, sizeof(mOptions->fullScreenMode), 1);
|
||||
SDL_RWread(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWread(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
|
||||
// Normaliza los valores
|
||||
if (!((mOptions->fullScreenMode == 0) ||
|
||||
(mOptions->fullScreenMode == SDL_WINDOW_FULLSCREEN) ||
|
||||
(mOptions->fullScreenMode == SDL_WINDOW_FULLSCREEN_DESKTOP)))
|
||||
mOptions->fullScreenMode = 0;
|
||||
if ((mOptions->windowSize < 1) || (mOptions->windowSize > 4))
|
||||
mOptions->windowSize = 3;
|
||||
if ((mOptions->language < 0) || (mOptions->language > MAX_LANGUAGES))
|
||||
mOptions->language = en_UK;
|
||||
|
||||
// Aplica las opciones
|
||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||
initTextStrings(mTextStrings, mOptions->language);
|
||||
|
||||
// Cierra el fichero
|
||||
SDL_RWclose(file);
|
||||
@@ -356,6 +380,7 @@ bool Director::saveConfigFile()
|
||||
// Guarda los datos
|
||||
SDL_RWwrite(file, &mOptions->fullScreenMode, sizeof(Uint32), 1);
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(Uint8), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(Uint8), 1);
|
||||
|
||||
printf("Writing file %s\n", filename.c_str());
|
||||
|
||||
@@ -402,35 +427,27 @@ void Director::runLogo()
|
||||
|
||||
void Director::runIntro()
|
||||
{
|
||||
mIntro = new Intro(mRenderer, mFileList);
|
||||
mIntro = new Intro(mRenderer, mFileList, mTextStrings);
|
||||
setSection(mIntro->run());
|
||||
delete mIntro;
|
||||
}
|
||||
|
||||
void Director::runTitle()
|
||||
{
|
||||
mTitle = new Title(mWindow, mRenderer, mInput, mFileList, mOptions);
|
||||
mTitle = new Title(mWindow, mRenderer, mInput, mFileList, mOptions, mTextStrings);
|
||||
setSection(mTitle->run(mSection.subsection));
|
||||
delete mTitle;
|
||||
}
|
||||
|
||||
void Director::runGame()
|
||||
{
|
||||
mGame = new Game(mRenderer, mFileList, mInput, false);
|
||||
mGame = new Game(mRenderer, mFileList, mTextStrings, mInput, false);
|
||||
setSection(mGame->run());
|
||||
delete mGame;
|
||||
}
|
||||
|
||||
void Director::run()
|
||||
{
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// Game *test = new Game(mRenderer, mFileList, mInput, true);
|
||||
// delete test;
|
||||
// printf("%i\n", i);
|
||||
//}
|
||||
//mSection.name = PROG_SECTION_QUIT;
|
||||
|
||||
// Bucle principal
|
||||
while (!(getSection() == PROG_SECTION_QUIT))
|
||||
{
|
||||
|
||||
@@ -34,13 +34,14 @@ private:
|
||||
|
||||
Input *mInput;
|
||||
|
||||
Logo *mLogo; // Objeto para la sección del logo
|
||||
Intro *mIntro; // Objeto para la sección de la intro
|
||||
Title *mTitle; // Objeto para la sección del titulo y el menu de opciones
|
||||
Game *mGame; // Objeto para la sección del juego
|
||||
Logo *mLogo; // Objeto para la sección del logo
|
||||
Intro *mIntro; // Objeto para la sección de la intro
|
||||
Title *mTitle; // Objeto para la sección del titulo y el menu de opciones
|
||||
Game *mGame; // Objeto para la sección del juego
|
||||
|
||||
std::string mFileList[100]; // Vector con las rutas a los ficheros de recursos
|
||||
struct options_t *mOptions; // Variable con todas las opciones del programa
|
||||
std::string mFileList[100]; // Vector con las rutas a los ficheros de recursos
|
||||
struct options_t *mOptions; // Variable con todas las opciones del programa
|
||||
std::string mTextStrings[MAX_TEXT_STRINGS]; // Vector con los textos del juego
|
||||
|
||||
std::string mExecutablePath; // Path del ejecutable
|
||||
section_t mSection; // Sección y subsección actual del programa;
|
||||
@@ -48,6 +49,9 @@ private:
|
||||
// Inicializa jail_audio
|
||||
void initJailAudio();
|
||||
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
//void initTextStrings(Uint8 lang);
|
||||
|
||||
// Arranca SDL y crea la ventana
|
||||
bool initSDL();
|
||||
|
||||
@@ -83,7 +87,6 @@ private:
|
||||
|
||||
void runGame();
|
||||
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Director(std::string path);
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Game::Game(SDL_Renderer *renderer, std::string *filelist, Input *input, bool demo)
|
||||
Game::Game(SDL_Renderer *renderer, std::string *filelist, std::string *textStrings, Input *input, bool demo)
|
||||
{
|
||||
// Referencia objetos
|
||||
// Copia los punteros
|
||||
mRenderer = renderer;
|
||||
mFileList = filelist;
|
||||
mTextStrings = textStrings;
|
||||
mInput = input;
|
||||
mDemo.enabled = demo;
|
||||
|
||||
@@ -300,8 +301,8 @@ void Game::init()
|
||||
|
||||
// Inicializa el objeto con el menu de pausa
|
||||
mMenuPause->init("PAUSE", 0, 12 * BLOCK, MENU_BACKGROUND_SOLID);
|
||||
mMenuPause->addItem("CONTINUE");
|
||||
mMenuPause->addItem("EXIT TO TITLE");
|
||||
mMenuPause->addItem(mTextStrings[46]);
|
||||
mMenuPause->addItem(mTextStrings[47]);
|
||||
mMenuPause->setDefaultActionWhenCancel(0);
|
||||
mMenuPause->setBackgroundColor(0x29, 0x39, 0x41, 240);
|
||||
mMenuPause->setSelectorColor(0xFF, 0x7A, 0x00, 255);
|
||||
@@ -311,8 +312,8 @@ void Game::init()
|
||||
|
||||
// Inicializa el objeto con el menu de la pantalla de game over
|
||||
mMenuGameOver->init("GAME OVER", 0, PLAY_AREA_CENTER_Y + BLOCK * 4, MENU_BACKGROUND_TRANSPARENT);
|
||||
mMenuGameOver->addItem("YES");
|
||||
mMenuGameOver->addItem("NO");
|
||||
mMenuGameOver->addItem(mTextStrings[48]);
|
||||
mMenuGameOver->addItem(mTextStrings[49]);
|
||||
mMenuGameOver->setDefaultActionWhenCancel(1);
|
||||
mMenuGameOver->setBackgroundColor(0, 0, 0, 255);
|
||||
mMenuGameOver->setSelectorColor(0x54, 0x6e, 0x7a, 255);
|
||||
@@ -1362,6 +1363,7 @@ void Game::deployEnemyFormation()
|
||||
// Crea una powerball
|
||||
createPowerBall();
|
||||
|
||||
// Da un poco de margen para que se creen mas enemigos
|
||||
mEnemyDeployCounter = 50;
|
||||
}
|
||||
else
|
||||
@@ -1491,16 +1493,16 @@ void Game::renderScoreBoard()
|
||||
//if (!mDemo.enabled)
|
||||
{
|
||||
// SCORE
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_WORD_Y - 6, "SCORE", 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_WORD_Y - 6, mTextStrings[39], 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y - 6, updateScoreText(mScore), 0);
|
||||
|
||||
// HI-SCORE
|
||||
mText->writeCentered(PLAY_AREA_CENTER_THIRD_QUARTER_X, HISCORE_WORD_Y - 6, "HI-SCORE", 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_THIRD_QUARTER_X, HISCORE_WORD_Y - 6, mTextStrings[40], 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_THIRD_QUARTER_X, HISCORE_NUMBER_Y - 6, updateScoreText(mHiScore), 0);
|
||||
|
||||
// MULT
|
||||
color.g = 255;
|
||||
mText->writeColored(MULTIPLIER_WORD_X, MULTIPLIER_WORD_Y - 6, "MULT", color);
|
||||
mText->writeColored(MULTIPLIER_WORD_X, MULTIPLIER_WORD_Y - 6, mTextStrings[41], color);
|
||||
|
||||
color.g = 192;
|
||||
mTextX2->writeShadowed(PLAY_AREA_CENTER_X - 16, SCORE_WORD_Y + 5, std::to_string(mPlayer->getScoreMultiplier()).substr(0, 1), color, 1);
|
||||
@@ -1508,7 +1510,7 @@ void Game::renderScoreBoard()
|
||||
mText->writeShadowed(PLAY_AREA_CENTER_X + 4, SCORE_WORD_Y + 12, std::to_string(mPlayer->getScoreMultiplier()).substr(2, 1), color);
|
||||
|
||||
// STAGE
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y + 4, "STAGE " + std::to_string(mStage[mCurrentStage].number), 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_FIRST_QUARTER_X, SCORE_NUMBER_Y + 4, mTextStrings[42] + std::to_string(mStage[mCurrentStage].number), 0);
|
||||
|
||||
// POWER
|
||||
mSpritePowerMeter->setSpriteClip(256, 184, 40, 8);
|
||||
@@ -1517,13 +1519,6 @@ void Game::renderScoreBoard()
|
||||
mSpritePowerMeter->setSpriteClip(296, 184, (int)percent, 8);
|
||||
mSpritePowerMeter->render();
|
||||
}
|
||||
/*else
|
||||
{
|
||||
mText->writeCentered(SCREEN_FIRST_QUARTER_X, SCORE_WORD_Y - 3, "A game by", -1);
|
||||
mText->writeCentered(SCREEN_FIRST_QUARTER_X, SCORE_NUMBER_Y, "JailDesigner", -1);
|
||||
mText->writeCentered(SCREEN_THIRD_QUARTER_X, HISCORE_WORD_Y - 3, "Intro music by", -1);
|
||||
mText->writeCentered(SCREEN_THIRD_QUARTER_X, HISCORE_NUMBER_Y, "JailDoctor", -1);
|
||||
}*/
|
||||
}
|
||||
|
||||
// Actualiza las variables del jugador
|
||||
@@ -1689,10 +1684,12 @@ Uint8 Game::createNewBalloon(float x, int y, Uint8 kind, float velx, float speed
|
||||
// Crea una PowerBall
|
||||
void Game::createPowerBall()
|
||||
{
|
||||
const int posY = (PLAY_AREA_TOP);
|
||||
const int posY = PLAY_AREA_TOP;
|
||||
|
||||
const int left = PLAY_AREA_LEFT;
|
||||
const int center = PLAY_AREA_CENTER_X - (BALLOON_WIDTH_4 / 2);
|
||||
const int right = (PLAY_AREA_RIGHT)-BALLOON_WIDTH_4;
|
||||
const int right = PLAY_AREA_RIGHT - BALLOON_WIDTH_4;
|
||||
|
||||
const int x[3] = {left, center, right};
|
||||
const int posX = x[rand() % 3];
|
||||
|
||||
@@ -2687,7 +2684,7 @@ void Game::renderMessages()
|
||||
{
|
||||
if ((mTimeStoppedCounter > 100) || (mTimeStoppedCounter % 10 > 4))
|
||||
//mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, "Time Stopped: " + std::to_string(mTimeStoppedCounter / 10));
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, "Time Stopped: " + std::to_string(mTimeStoppedCounter / 10), 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[36] + std::to_string(mTimeStoppedCounter / 10), 0, noColor, 1, shdwTxtColor);
|
||||
|
||||
if (mTimeStoppedCounter > 100)
|
||||
{
|
||||
@@ -2704,11 +2701,11 @@ void Game::renderMessages()
|
||||
// D E M O
|
||||
if (mDemo.enabled)
|
||||
if (mDemo.counter % 30 > 14)
|
||||
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, "D E M O", 0, noColor, 2, shdwTxtColor);
|
||||
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mTextStrings[37], 0, noColor, 2, shdwTxtColor);
|
||||
|
||||
// STAGE NUMBER
|
||||
if (mStageBitmapCounter < STAGE_COUNTER)
|
||||
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], "STAGE " + std::to_string(mStage[mCurrentStage].number), 0, noColor, 2, shdwTxtColor);
|
||||
mTextX2->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], mTextStrings[38] + std::to_string(mStage[mCurrentStage].number), 0, noColor, 2, shdwTxtColor);
|
||||
}
|
||||
|
||||
// Habilita el efecto del item de detener el tiempo
|
||||
@@ -3026,9 +3023,9 @@ void Game::runGameOverScreen()
|
||||
SDL_RenderClear(mRenderer);
|
||||
|
||||
// Dibuja los objetos
|
||||
mTextX2->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), "GAME OVER", 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), "YOUR SCORE: " + std::to_string(mPlayer->getScore()), 0);
|
||||
mText->write(PLAY_AREA_CENTER_X - (mText->lenght("RETRY?", 0) / 2), PLAY_AREA_CENTER_Y + BLOCK * 2, "RETRY?", 0);
|
||||
mTextX2->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mTextStrings[43], 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mTextStrings[44] + std::to_string(mPlayer->getScore()), 0);
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y + BLOCK * 2, mTextStrings[45], 0);
|
||||
mMenuGameOver->render();
|
||||
mFade->render();
|
||||
|
||||
@@ -3082,7 +3079,7 @@ void Game::renderDebugInfo()
|
||||
// Indica si se puede crear una powerball
|
||||
bool Game::canPowerBallBeCreated()
|
||||
{
|
||||
if ((!mPowerBallEnabled) && (calculateScreenPower() > 0))
|
||||
if ((!mPowerBallEnabled) && (calculateScreenPower() > POWERBALL_SCREENPOWER_MINIMUM))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
|
||||
struct enemyFormation_t // Contiene la información de una formación enemiga
|
||||
{
|
||||
Uint8 numberOfEnemies; // Cantidad de enemigos que forman la formación
|
||||
Uint8 numberOfEnemies; // Cantidad de enemigos que forman la formación
|
||||
enemyInits_t init[MAX_NUMBER_OF_ENEMIES_IN_A_FORMATION]; // Vector con todas las inicializaciones de los enemigos de la formación
|
||||
};
|
||||
enemyFormation_t mEnemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas
|
||||
@@ -65,9 +65,10 @@ private:
|
||||
Uint8 shakeCounter; // Contador para medir el tiempo que dura el efecto
|
||||
};
|
||||
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
std::string *mFileList; // Lista de ficheros con los recursos
|
||||
Input *mInput; // Manejador de entrada
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
std::string *mFileList; // Lista de ficheros con los recursos
|
||||
std::string *mTextStrings; // Vector con los textos del juego
|
||||
Input *mInput; // Manejador de entrada
|
||||
|
||||
Player *mPlayer; // El jugador
|
||||
|
||||
@@ -127,13 +128,13 @@ private:
|
||||
|
||||
JA_Music mMusicPlaying; // Musica de fondo
|
||||
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
|
||||
Uint32 mScore; // Puntuación actual
|
||||
Uint32 mHiScore; // Puntuación máxima
|
||||
bool mHiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
||||
section_t mSection; // Seccion actual dentro del juego
|
||||
section_t mSection; // Seccion actual dentro del juego
|
||||
stage_t mStage[10]; // Variable con los datos de cada pantalla
|
||||
Uint8 mCurrentStage; // Indica la fase actual
|
||||
Uint8 mStageBitmapCounter; // Contador para el tiempo visible del texto de Stage
|
||||
@@ -182,7 +183,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Game(SDL_Renderer *renderer, std::string *filelist, Input *input, bool demo);
|
||||
Game(SDL_Renderer *renderer, std::string *filelist, std::string *textStrings, Input *input, bool demo);
|
||||
|
||||
// Destructor
|
||||
~Game();
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
const Uint8 SELF = 0;
|
||||
|
||||
// Constructor
|
||||
Instructions::Instructions(SDL_Renderer *renderer, std::string *fileList)
|
||||
Instructions::Instructions(SDL_Renderer *renderer, std::string *fileList, std::string *textStrings)
|
||||
{
|
||||
// Copia la dirección del renderizador
|
||||
// Copia los punteros
|
||||
mRenderer = renderer;
|
||||
|
||||
// Copia la dirección del la lista de ficheros
|
||||
mFileList = fileList;
|
||||
mTextStrings = textStrings;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
mEventHandler = new SDL_Event();
|
||||
@@ -157,21 +156,21 @@ void Instructions::run(Uint8 mode)
|
||||
SDL_RenderClear(mRenderer);
|
||||
|
||||
// Escribe el texto
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, "OBJECTIVE", 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, "YOU HAVE TO POP AS MANY", 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, "BALLOONS AS YOU CAN", 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, "DIFFICULTY WILL BE INCREASED", 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, "AS YOU SCORE POINTS", 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, "ITEMS", 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, mTextStrings[11], 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, mTextStrings[12], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, mTextStrings[13], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, mTextStrings[14], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, mTextStrings[15], 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, mTextStrings[16], 0, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
mText->writeShadowed(84, 92, "1.000 POINTS", shdwTxtColor);
|
||||
mText->writeShadowed(84, 108, "2.500 POINTS", shdwTxtColor);
|
||||
mText->writeShadowed(84, 124, "5.000 POINTS", shdwTxtColor);
|
||||
mText->writeShadowed(84, 140, "TIME STOPPER", shdwTxtColor);
|
||||
mText->writeShadowed(84, 156, "EXTRA HIT", shdwTxtColor);
|
||||
mText->writeShadowed(84, 92, mTextStrings[17], shdwTxtColor);
|
||||
mText->writeShadowed(84, 108, mTextStrings[18], shdwTxtColor);
|
||||
mText->writeShadowed(84, 124, mTextStrings[19], shdwTxtColor);
|
||||
mText->writeShadowed(84, 140, mTextStrings[20], shdwTxtColor);
|
||||
mText->writeShadowed(84, 156, mTextStrings[21], shdwTxtColor);
|
||||
|
||||
if ((mode == INSTRUCTIONS_MODE_MANUAL) && (mCounter % 50 > 14))
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - 12, "PRESS ANY KEY TO RETURN", 0, orangeColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - 12, mTextStrings[22], 0, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
// Disquito
|
||||
mSprite->init(destRect1, mItemTexture, mRenderer);
|
||||
|
||||
@@ -14,19 +14,20 @@
|
||||
class Instructions
|
||||
{
|
||||
private:
|
||||
LTexture *mItemTexture; // Textura con los graficos
|
||||
LTexture *mTextTexture; // Textura con los graficos
|
||||
SDL_Event *mEventHandler; // Manejador de eventos
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
|
||||
Sprite *mSprite; // Sprite con la textura de las instrucciones
|
||||
std::string *mFileList; // Lista de ficheros
|
||||
Text *mText; // Objeto para escribir texto
|
||||
Uint16 mCounter; // Contador
|
||||
section_t mSection; // Estado del bucle principal para saber si continua o se sale
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
bool mManualQuit; // Indica si se quiere salir del modo manual
|
||||
LTexture *mItemTexture; // Textura con los graficos
|
||||
LTexture *mTextTexture; // Textura con los graficos
|
||||
SDL_Event *mEventHandler; // Manejador de eventos
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
|
||||
Sprite *mSprite; // Sprite con la textura de las instrucciones
|
||||
std::string *mFileList; // Lista de ficheros
|
||||
std::string *mTextStrings; // Vector con los textos del juego
|
||||
Text *mText; // Objeto para escribir texto
|
||||
Uint16 mCounter; // Contador
|
||||
section_t mSection; // Estado del bucle principal para saber si continua o se sale
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
bool mManualQuit; // Indica si se quiere salir del modo manual
|
||||
|
||||
// Carga los recursos
|
||||
bool loadMedia();
|
||||
@@ -42,7 +43,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Instructions(SDL_Renderer *renderer, std::string *fileList);
|
||||
Instructions(SDL_Renderer *renderer, std::string *fileList, std::string *textStrings);
|
||||
|
||||
// Destructor
|
||||
~Instructions();
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Intro::Intro(SDL_Renderer *renderer, std::string *fileList)
|
||||
Intro::Intro(SDL_Renderer *renderer, std::string *fileList, std::string *textStrings)
|
||||
{
|
||||
// Copia la dirección del renderizador
|
||||
// Copia los punteros
|
||||
mRenderer = renderer;
|
||||
|
||||
// Copia la dirección del la lista de ficheros
|
||||
mFileList = fileList;
|
||||
mTextStrings = textStrings;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
mEventHandler = new SDL_Event();
|
||||
@@ -144,31 +143,40 @@ void Intro::init()
|
||||
mText[i]->setEnabledTimer(180);
|
||||
}
|
||||
|
||||
mText[0]->setCaption("Un dia qualsevol de l'any 2000");
|
||||
// Un dia qualsevol de l'any 2000
|
||||
mText[0]->setCaption(mTextStrings[27]);
|
||||
mText[0]->setWrittingSpeed(10);
|
||||
|
||||
mText[1]->setCaption("Tot esta tranquil a la UPV");
|
||||
// Tot esta tranquil a la UPV
|
||||
mText[1]->setCaption(mTextStrings[28]);
|
||||
mText[1]->setWrittingSpeed(10);
|
||||
|
||||
mText[2]->setCaption("Fins que un desaprensiu...");
|
||||
// Fins que un desaprensiu...
|
||||
mText[2]->setCaption(mTextStrings[29]);
|
||||
mText[2]->setWrittingSpeed(15);
|
||||
|
||||
mText[3]->setCaption("HEY! ME ANE A FERME UN CORTAET...");
|
||||
// HEY! ME ANE A FERME UN CORTAET...
|
||||
mText[3]->setCaption(mTextStrings[30]);
|
||||
mText[3]->setWrittingSpeed(10);
|
||||
|
||||
mText[4]->setCaption("UAAAAAAAAAAAAA!!!");
|
||||
// UAAAAAAAAAAAAA!!!
|
||||
mText[4]->setCaption(mTextStrings[31]);
|
||||
mText[4]->setWrittingSpeed(1);
|
||||
|
||||
mText[5]->setCaption("Espera un moment...");
|
||||
// Espera un moment...
|
||||
mText[5]->setCaption(mTextStrings[32]);
|
||||
mText[5]->setWrittingSpeed(20);
|
||||
|
||||
mText[6]->setCaption("Si resulta que no tinc solt!");
|
||||
// Si resulta que no tinc solt!
|
||||
mText[6]->setCaption(mTextStrings[33]);
|
||||
mText[6]->setWrittingSpeed(2);
|
||||
|
||||
mText[7]->setCaption("MERDA DE MAQUINA!");
|
||||
// MERDA DE MAQUINA!
|
||||
mText[7]->setCaption(mTextStrings[34]);
|
||||
mText[7]->setWrittingSpeed(3);
|
||||
|
||||
mText[8]->setCaption("Blop... blop... blop...");
|
||||
// Blop... blop... blop...
|
||||
mText[8]->setCaption(mTextStrings[35]);
|
||||
mText[8]->setWrittingSpeed(20);
|
||||
|
||||
for (int i = 0; i < INTRO_TOTAL_TEXTS; i++)
|
||||
|
||||
@@ -19,6 +19,7 @@ private:
|
||||
SDL_Event *mEventHandler; // Manejador de eventos
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
std::string *mFileList; // Lista de ficheros
|
||||
std::string *mTextStrings; // Vector con los textos del juego
|
||||
section_t mSection; // Estado del bucle principal para saber si continua o se sale
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 mTicksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
@@ -29,7 +30,7 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Intro(SDL_Renderer *renderer, std::string *fileList);
|
||||
Intro(SDL_Renderer *renderer, std::string *fileList, std::string *textStrings);
|
||||
|
||||
// Destructor
|
||||
~Intro();
|
||||
|
||||
10
source/lang.cpp
Normal file
10
source/lang.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "lang.h"
|
||||
|
||||
// Inicializa los textos del juego en el idioma seleccionado
|
||||
void initTextStrings(std::string *textStrings, Uint8 lang)
|
||||
{
|
||||
if ((lang < 0) || (lang > MAX_LANGUAGES))
|
||||
lang = en_UK;
|
||||
for (int i = 0; i < MAX_TEXT_STRINGS; i++)
|
||||
textStrings[i] = gTextStrings[i][lang].c_str();
|
||||
}
|
||||
272
source/lang.h
Normal file
272
source/lang.h
Normal file
@@ -0,0 +1,272 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include <string>
|
||||
|
||||
#ifndef LANG_H
|
||||
#define LANG_H
|
||||
|
||||
// iso codes
|
||||
#define es_ES 0
|
||||
#define ba_BA 1
|
||||
#define en_UK 2
|
||||
#define MAX_LANGUAGES 3
|
||||
|
||||
// Textos
|
||||
#define MAX_TEXT_STRINGS 100
|
||||
const std::string gTextStrings[MAX_TEXT_STRINGS][3] =
|
||||
{
|
||||
// 0 - TITULO E INSTRUCCIONES
|
||||
{"JUGAR",
|
||||
"JUGAR",
|
||||
"PLAY"},
|
||||
|
||||
// 1
|
||||
{"OPCIONES",
|
||||
"OPCIONS",
|
||||
"OPTIONS"},
|
||||
|
||||
// 2
|
||||
{"INSTRUCCIONES",
|
||||
"INSTRUCCIONS",
|
||||
"HOW TO PLAY"},
|
||||
|
||||
// 3
|
||||
{"SALIR",
|
||||
"EIXIR",
|
||||
"QUIT"},
|
||||
|
||||
// 4
|
||||
{"VENTANA",
|
||||
"FINESTRA",
|
||||
"WINDOW"},
|
||||
|
||||
// 5
|
||||
{"PANTALLA COMPLETA",
|
||||
"PANTALLA COMPLETA",
|
||||
"FULLSCREEN"},
|
||||
|
||||
// 6
|
||||
{"PANTALLA COMPLETA FALSA",
|
||||
"PANTALLA COMPLETA FALSA",
|
||||
"FAKE FULLSCREEN"},
|
||||
|
||||
// 7
|
||||
{"TAMAÑO DE VENTANA",
|
||||
"TAMANY DE FINESTRA",
|
||||
"WINDOW SIZE"},
|
||||
|
||||
// 8
|
||||
{"IDIOMA",
|
||||
"IDIOMA",
|
||||
"LANGUAGE"},
|
||||
|
||||
// 9
|
||||
{"[ACEPTAR]",
|
||||
"[ACEPTAR]",
|
||||
"[ACCEPT]"},
|
||||
|
||||
// 10
|
||||
{"[CANCELAR]",
|
||||
"[CANCELAR]",
|
||||
"[CANCEL]"},
|
||||
|
||||
// 11
|
||||
{"OBJETIVO",
|
||||
"OBJECTIU",
|
||||
"OBJECTIVE"},
|
||||
|
||||
// 12
|
||||
{"TIENES QUE EXPLOTAR",
|
||||
"HAS D'EXPLOTAR",
|
||||
"YOU HAVE TO POP AS MANY"},
|
||||
|
||||
// 13
|
||||
{"TANTOS GLOBOS COMO PUEDAS",
|
||||
"TANTS GLOBUS COM PUGUES",
|
||||
"BALLOONS AS YOU CAN"},
|
||||
|
||||
// 14
|
||||
{"LA DIFICULTAD SE INCREMENTA",
|
||||
"LA DIFICULTAT AUGMENTA",
|
||||
"DIFFICULTY WILL BE INCREASED"},
|
||||
|
||||
// 15
|
||||
{"A MEDIDA QUE VAS PUNTUANDO",
|
||||
"A MESURA QUE VAS PUNTUANT",
|
||||
"AS YOU SCORE POINTS"},
|
||||
|
||||
// 16
|
||||
{"OBJETOS",
|
||||
"OBJECTES",
|
||||
"ITEMS"},
|
||||
|
||||
// 17
|
||||
{"1.000 PUNTOS",
|
||||
"1.000 PUNTS",
|
||||
"1.000 POINTS"},
|
||||
|
||||
// 18
|
||||
{"2.500 PUNTOS",
|
||||
"2.500 PUNTS",
|
||||
"2.500 POINTS"},
|
||||
|
||||
// 19
|
||||
{"5.000 PUNTOS",
|
||||
"5.000 PUNTS",
|
||||
"5.000 POINTS"},
|
||||
|
||||
// 20
|
||||
{"DETIENE EL TIEMPO",
|
||||
"PARA EL TEMPS",
|
||||
"TIME STOPPER"},
|
||||
|
||||
// 21
|
||||
{"VIDA EXTRA",
|
||||
"VIDA EXTRA",
|
||||
"EXTRA HIT"},
|
||||
|
||||
// 22
|
||||
{"PULSA UNA TECLA PARA VOLVER",
|
||||
"PREM UNA TECLA PER A TORNAR",
|
||||
"PRESS ANY KEY TO RETURN"},
|
||||
|
||||
// 23
|
||||
{"PULSA CUALQUIER TECLA",
|
||||
"PREM QUALSEVOL TECLA",
|
||||
"PRESS ANY KEY"},
|
||||
|
||||
// 24
|
||||
{"ESPAÑOL",
|
||||
"ESPAÑOL (ESPANYOL)",
|
||||
"ESPAÑOL (SPANISH)"},
|
||||
|
||||
// 25
|
||||
{"BALOONCIA (VALENCIANO)",
|
||||
"BALOONCIA",
|
||||
"BALOONCIA (VALENCIAN)"},
|
||||
|
||||
// 26
|
||||
{"ENGLISH (INGLES)",
|
||||
"ENGLISH (ANGLES)",
|
||||
"ENGLISH"},
|
||||
|
||||
// 27 - INTRO
|
||||
{"Un dia cualquiera del año 2000",
|
||||
"Un dia qualsevol de l'any 2000",
|
||||
"Any day of the year 2000"},
|
||||
|
||||
// 28
|
||||
{"Todo esta tranquilo en la UPV",
|
||||
"Tot esta tranquil a la UPV",
|
||||
"Everything is quiet at the UPV"},
|
||||
|
||||
// 29
|
||||
{"Hasta que un desaprensivo...",
|
||||
"Fins que un desaprensiu...",
|
||||
"Until a bastard arrives..."},
|
||||
|
||||
// 30
|
||||
{"HEY! ME VOY A HACER UN TALLADET...",
|
||||
"HEY! ME ANE A FERME UN CORTAET...",
|
||||
" YO! GONNA TAKE A CAFELITO... "},
|
||||
|
||||
// 31
|
||||
{"UAAAAAAAAAAAAA!!!",
|
||||
"UAAAAAAAAAAAAA!!!",
|
||||
"AAAAAAAARGHHHH!!!"},
|
||||
|
||||
// 32
|
||||
{"Espera un momento...",
|
||||
"Espera un moment...",
|
||||
"Wait a moment..."},
|
||||
|
||||
// 33
|
||||
{"Si resulta que no llevo suelto!",
|
||||
"Si resulta que no tinc solt!",
|
||||
" I don't have any loose! "},
|
||||
|
||||
// 34
|
||||
{"MIERDA DE MAQUINA!",
|
||||
"MERDA DE MAQUINA!",
|
||||
"FUCKING MACHINE!"},
|
||||
|
||||
// 35
|
||||
{"Blop... blop... blop...",
|
||||
"Blop... blop... blop...",
|
||||
"Blop... blop... blop..."},
|
||||
|
||||
// 36 - TEXTOS DEL JUEGO
|
||||
{"Tiempo: ",
|
||||
"Temps detes: ",
|
||||
"Time Stopped: "},
|
||||
|
||||
// 37
|
||||
{"D E M O",
|
||||
"D E M O",
|
||||
"D E M O"},
|
||||
|
||||
// 38
|
||||
{"FASE ",
|
||||
"PANTALLA ",
|
||||
"STAGE "},
|
||||
|
||||
// 39 - MARCADOR
|
||||
{"PUNTOS",
|
||||
"PUNTS",
|
||||
"SCORE"},
|
||||
|
||||
// 40
|
||||
{"MAX.PUNT.",
|
||||
"MAX.PUNT.",
|
||||
"HI-SCORE"},
|
||||
|
||||
// 41
|
||||
{"MULT",
|
||||
"MULT",
|
||||
"MULT"},
|
||||
|
||||
// 42
|
||||
{"FASE ",
|
||||
"PANTALLA ",
|
||||
"STAGE "},
|
||||
|
||||
// 43 - PANTALLA DE GAME OVER
|
||||
{"FIN DE JUEGO",
|
||||
"FI DEL JOC",
|
||||
"GAME OVER"},
|
||||
|
||||
// 44
|
||||
{"TU PUNTUACION: ",
|
||||
"ELS TEUS PUNTS: ",
|
||||
"YOUR SCORE: "},
|
||||
|
||||
// 45
|
||||
{"REINTENTAR?",
|
||||
"REINTENTAR?",
|
||||
"RETRY?"},
|
||||
|
||||
// 46 - MENU DE PAUSA
|
||||
{"CONTINUAR",
|
||||
"CONTINUAR",
|
||||
"CONTINUE"},
|
||||
|
||||
// 47
|
||||
{"SALIR DEL JUEGO ",
|
||||
"EIXIR DEL JOC",
|
||||
"LEAVE GAME"},
|
||||
|
||||
// 48 - MENU GAME OVER
|
||||
{"SI",
|
||||
"SI",
|
||||
"YES"},
|
||||
|
||||
// 49
|
||||
{"NO",
|
||||
"NO",
|
||||
"NO"},
|
||||
|
||||
};
|
||||
|
||||
void initTextStrings(std::string *textStrings, Uint8 lang);
|
||||
|
||||
#endif
|
||||
133
source/title.cpp
133
source/title.cpp
@@ -5,7 +5,7 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options)
|
||||
Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options, std::string *textStrings)
|
||||
{
|
||||
// Copia las direcciones de los punteros
|
||||
mWindow = window;
|
||||
@@ -13,6 +13,7 @@ Title::Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::stri
|
||||
mInput = input;
|
||||
mFileList = fileList;
|
||||
mOptions = options;
|
||||
mTextStrings = textStrings;
|
||||
|
||||
// Reserva memoria para los punteros propios
|
||||
mEventHandler = new SDL_Event();
|
||||
@@ -95,7 +96,7 @@ Title::~Title()
|
||||
}
|
||||
|
||||
// Inicializa las variables necesarias para la sección 'Title'
|
||||
void Title::init(Uint8 subsection)
|
||||
void Title::init(bool demo, Uint8 subsection)
|
||||
{
|
||||
// Carga los recursos
|
||||
loadMedia();
|
||||
@@ -114,6 +115,7 @@ void Title::init(Uint8 subsection)
|
||||
mTicksSpeed = 15;
|
||||
mText->init(TEXT_FIXED, BLOCK);
|
||||
mFade->init();
|
||||
mDemo = demo;
|
||||
|
||||
// Inicializa el bitmap de Coffee
|
||||
mCoffeeBitmap->init(mTitleTexture, mRenderer);
|
||||
@@ -223,10 +225,10 @@ void Title::init(Uint8 subsection)
|
||||
|
||||
// Inicializa los objetos de menu
|
||||
mMenu.title->init("TITLE", 0, 15 * BLOCK, MENU_BACKGROUND_SOLID);
|
||||
mMenu.title->addItem("PLAY");
|
||||
mMenu.title->addItem("OPTIONS");
|
||||
mMenu.title->addItem("HOW TO PLAY", 0, 5);
|
||||
mMenu.title->addItem("QUIT");
|
||||
mMenu.title->addItem(mTextStrings[0]); // PLAY
|
||||
mMenu.title->addItem(mTextStrings[1]); // OPTIONS
|
||||
mMenu.title->addItem(mTextStrings[2], 0, 5); // HOW TO PLAY
|
||||
mMenu.title->addItem(mTextStrings[3]); // QUIT
|
||||
mMenu.title->setDefaultActionWhenCancel(3);
|
||||
mMenu.title->setBackgroundColor(0x30, 0x30, 0x40, 192);
|
||||
mMenu.title->setSelectorColor(0xe5, 0x1c, 0x23, 255);
|
||||
@@ -234,20 +236,21 @@ void Title::init(Uint8 subsection)
|
||||
mMenu.title->centerMenu(SCREEN_CENTER_X);
|
||||
mMenu.title->centerMenuElements();
|
||||
|
||||
mMenu.options->init("OPTIONS", 0, 15 * BLOCK, MENU_BACKGROUND_SOLID);
|
||||
mMenu.options->addItem("FULLSCREEN");
|
||||
mMenu.options->addItem("WINDOWS SIZE", 0, 5);
|
||||
mMenu.options->addItem("[OK]");
|
||||
mMenu.options->addItem("[CANCEL]");
|
||||
mMenu.options->setDefaultActionWhenCancel(3);
|
||||
mMenu.options->init("OPTIONS", 0, 14 * BLOCK, MENU_BACKGROUND_SOLID);
|
||||
mMenu.options->addItem(mTextStrings[4]);
|
||||
mMenu.options->addItem(mTextStrings[7]);
|
||||
mMenu.options->addItem(mTextStrings[8], 0, 5);
|
||||
mMenu.options->addItem(mTextStrings[9]);
|
||||
mMenu.options->addItem(mTextStrings[10]);
|
||||
mMenu.options->setDefaultActionWhenCancel(4);
|
||||
mMenu.options->setBackgroundColor(0x30, 0x30, 0x40, 192);
|
||||
mMenu.options->setSelectorColor(0xe5, 0x1c, 0x23, 255);
|
||||
mMenu.options->setSelectorTextColor(0xFF, 0xF1, 0x76);
|
||||
mMenu.options->centerMenu(SCREEN_CENTER_X);
|
||||
mMenu.options->centerMenuElements();
|
||||
|
||||
// Actualiza los elementos del menu de opciones con los valores correspondientes
|
||||
updateOptionsMenuLabels();
|
||||
// Actualiza los textos de los menus
|
||||
updateMenuLabels();
|
||||
}
|
||||
|
||||
// Carga los recursos necesarios para la sección 'Title'
|
||||
@@ -291,28 +294,54 @@ void Title::switchFullScreenModeVar()
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los elementos del menu de opciones
|
||||
void Title::updateOptionsMenuLabels()
|
||||
// Actualiza los elementos de los menus
|
||||
void Title::updateMenuLabels()
|
||||
{
|
||||
switch (mOptions->fullScreenMode)
|
||||
{
|
||||
case 0:
|
||||
mMenu.options->setItemCaption(0, "WINDOWED");
|
||||
mMenu.options->setItemCaption(0, mTextStrings[4]); // WINDOW
|
||||
break;
|
||||
case SDL_WINDOW_FULLSCREEN:
|
||||
mMenu.options->setItemCaption(0, "FULLSCREEN");
|
||||
mMenu.options->setItemCaption(0, mTextStrings[5]); // FULLSCREEN
|
||||
break;
|
||||
case SDL_WINDOW_FULLSCREEN_DESKTOP:
|
||||
mMenu.options->setItemCaption(0, "FAKE FULLSCREEN");
|
||||
mMenu.options->setItemCaption(0, mTextStrings[6]); // FAKE FULLSCREEN
|
||||
break;
|
||||
|
||||
default:
|
||||
mMenu.options->setItemCaption(0, "WINDOWED");
|
||||
mMenu.options->setItemCaption(0, mTextStrings[4]); // WINDOW
|
||||
break;
|
||||
}
|
||||
mMenu.options->setItemCaption(1, "WINDOWS SIZE " + std::to_string(mOptions->windowSize));
|
||||
|
||||
mMenu.options->setItemCaption(1, mTextStrings[7] + " x" + std::to_string(mOptions->windowSize)); // WINDOW SIZE
|
||||
|
||||
switch (mOptions->language)
|
||||
{
|
||||
case es_ES:
|
||||
mMenu.options->setItemCaption(2, mTextStrings[8] + " " + mTextStrings[24]);
|
||||
break;
|
||||
case ba_BA:
|
||||
mMenu.options->setItemCaption(2, mTextStrings[8] + " " + mTextStrings[25]);
|
||||
break;
|
||||
case en_UK:
|
||||
mMenu.options->setItemCaption(2, mTextStrings[8] + " " + mTextStrings[26]);
|
||||
break;
|
||||
}
|
||||
|
||||
mMenu.options->setItemCaption(3, mTextStrings[9]);
|
||||
mMenu.options->setItemCaption(4, mTextStrings[10]);
|
||||
|
||||
mMenu.options->centerMenu(SCREEN_CENTER_X);
|
||||
mMenu.options->centerMenuElements();
|
||||
|
||||
mMenu.title->setItemCaption(0, mTextStrings[0]);
|
||||
mMenu.title->setItemCaption(1, mTextStrings[1]);
|
||||
mMenu.title->setItemCaption(2, mTextStrings[2]);
|
||||
mMenu.title->setItemCaption(3, mTextStrings[3]);
|
||||
|
||||
mMenu.title->centerMenu(SCREEN_CENTER_X);
|
||||
mMenu.title->centerMenuElements();
|
||||
}
|
||||
|
||||
// Aplica las opciones de menu seleccionadas
|
||||
@@ -320,6 +349,8 @@ void Title::applyOptions()
|
||||
{
|
||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||
initTextStrings(mTextStrings, mOptions->language);
|
||||
updateMenuLabels();
|
||||
}
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
@@ -466,7 +497,6 @@ section_t Title::run(Uint8 subsection)
|
||||
case 0: // PLAY
|
||||
mSection.name = PROG_SECTION_GAME;
|
||||
JA_StopMusic();
|
||||
mDemo = false;
|
||||
break;
|
||||
|
||||
case 1: // QUIT
|
||||
@@ -476,15 +506,15 @@ section_t Title::run(Uint8 subsection)
|
||||
|
||||
case 2: // TIME OUT
|
||||
mCounter = TITLE_COUNTER;
|
||||
//mSection = mNextSection;
|
||||
//mSection.name = PROG_SECTION_TITLE;
|
||||
//mSection.subsection = TITLE_SECTION_INSTRUCTIONS;
|
||||
mMenu.active->reset();
|
||||
//toogleTitleNextGS();
|
||||
runDemoGame();
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init();
|
||||
mDemo = true;
|
||||
if (mDemo)
|
||||
{
|
||||
runDemoGame();
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init(false);
|
||||
}
|
||||
else
|
||||
mSection.name = PROG_SECTION_LOGO;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -509,6 +539,7 @@ section_t Title::run(Uint8 subsection)
|
||||
mMenu.active = mMenu.options;
|
||||
mOptions->fullScreenModePrevious = mOptions->fullScreenMode;
|
||||
mOptions->windowSizePrevious = mOptions->windowSize;
|
||||
mOptions->languagePrevious = mOptions->language;
|
||||
break;
|
||||
case 2: // HOW TO PLAY
|
||||
runInstructions(INSTRUCTIONS_MODE_MANUAL);
|
||||
@@ -530,25 +561,30 @@ section_t Title::run(Uint8 subsection)
|
||||
{
|
||||
case 0: // Fullscreen mode
|
||||
switchFullScreenModeVar();
|
||||
updateOptionsMenuLabels();
|
||||
mMenu.active->deselectItem();
|
||||
updateMenuLabels();
|
||||
break;
|
||||
case 1: // Windows size
|
||||
mOptions->windowSize++;
|
||||
if (mOptions->windowSize == 5)
|
||||
mOptions->windowSize = 1;
|
||||
updateOptionsMenuLabels();
|
||||
mMenu.active->deselectItem();
|
||||
updateMenuLabels();
|
||||
break;
|
||||
case 2: // OK
|
||||
case 2: // Language
|
||||
mOptions->language++;
|
||||
if (mOptions->language == 3)
|
||||
mOptions->language = 0;
|
||||
updateMenuLabels();
|
||||
break;
|
||||
case 3: // OK
|
||||
applyOptions();
|
||||
mMenu.active->reset();
|
||||
mMenu.active = mMenu.title;
|
||||
break;
|
||||
case 3: // CANCEL
|
||||
case 4: // CANCEL
|
||||
mOptions->fullScreenMode = mOptions->fullScreenModePrevious;
|
||||
mOptions->windowSize = mOptions->windowSizePrevious;
|
||||
updateOptionsMenuLabels();
|
||||
mOptions->language = mOptions->languagePrevious;
|
||||
updateMenuLabels();
|
||||
mMenu.active->reset();
|
||||
mMenu.active = mMenu.title;
|
||||
break;
|
||||
@@ -602,7 +638,7 @@ section_t Title::run(Uint8 subsection)
|
||||
|
||||
// PRESS ANY KEY!
|
||||
if ((mCounter % 50 > 14) && (mMenuVisible == false))
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, "PRESS ANY KEY!", 0, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, mTextStrings[23], 0, noColor, 1, shdwTxtColor);
|
||||
|
||||
// Texto con el copyright y versión
|
||||
mText->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, SCREEN_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 0, noColor, 1, shdwTxtColor);
|
||||
@@ -615,11 +651,14 @@ section_t Title::run(Uint8 subsection)
|
||||
}
|
||||
else if (mCounter == 0)
|
||||
{
|
||||
//mPostFade = 2;
|
||||
//mFade->activateFade();
|
||||
runDemoGame();
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init();
|
||||
if (mDemo)
|
||||
{
|
||||
runDemoGame();
|
||||
runInstructions(INSTRUCTIONS_MODE_AUTO);
|
||||
init(false);
|
||||
}
|
||||
else
|
||||
mSection.name = PROG_SECTION_LOGO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,19 +676,15 @@ section_t Title::run(Uint8 subsection)
|
||||
// Ejecuta la parte donde se muestran las instrucciones
|
||||
void Title::runInstructions(Uint8 mode)
|
||||
{
|
||||
printf("carrega instructions\n");
|
||||
mInstructions = new Instructions(mRenderer, mFileList);
|
||||
mInstructions = new Instructions(mRenderer, mFileList, mTextStrings);
|
||||
mInstructions->run(mode);
|
||||
delete mInstructions;
|
||||
printf("borra instructions\n");
|
||||
}
|
||||
|
||||
// Ejecuta el juego en modo demo
|
||||
void Title::runDemoGame()
|
||||
{
|
||||
printf("carrega joc\n");
|
||||
mDemoGame = new Game(mRenderer, mFileList, mInput, true);
|
||||
mDemoGame = new Game(mRenderer, mFileList, mTextStrings, mInput, true);
|
||||
mDemoGame->run();
|
||||
delete mDemoGame;
|
||||
printf("borra joc\n");
|
||||
}
|
||||
@@ -36,12 +36,13 @@ private:
|
||||
SDL_Event *mEventHandler; // Manejador de eventos
|
||||
SDL_Rect mBackgroundWindow; // Ventana visible para la textura de fondo del titulo
|
||||
SDL_Renderer *mRenderer; // El renderizador de la ventana
|
||||
SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
|
||||
//SDL_Texture *mBackbuffer; // Textura para usar como backbuffer
|
||||
SDL_Texture *mBackground; // Textura dibujar el fondo del titulo
|
||||
SmartSprite *mCoffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo
|
||||
SmartSprite *mCrisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo
|
||||
Sprite *mTile; // Sprite para dibujar el fondo de pantalla del título
|
||||
std::string *mFileList; // Lista de ficheros
|
||||
std::string *mTextStrings; // Vector con los textos del juego
|
||||
Uint16 mBackgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
|
||||
Uint16 mCounter; // Temporizador para la pantalla de titulo
|
||||
Uint32 mTicks; // Contador de ticks para ajustar la velocidad del programa
|
||||
@@ -75,8 +76,8 @@ private:
|
||||
// Cambia el valor de la variable de modo de pantalla completa
|
||||
void switchFullScreenModeVar();
|
||||
|
||||
// Actualiza los elementos del menu de opciones
|
||||
void updateOptionsMenuLabels();
|
||||
// Actualiza los elementos de los menus
|
||||
void updateMenuLabels();
|
||||
|
||||
// Aplica las opciones de menu seleccionadas
|
||||
void applyOptions();
|
||||
@@ -89,16 +90,13 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options);
|
||||
Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options, std::string *textStrings);
|
||||
|
||||
// Destructor
|
||||
~Title();
|
||||
|
||||
// Inicializa las variables necesarias para la sección 'Title'
|
||||
void init(Uint8 subsection = TITLE_SECTION_1);
|
||||
|
||||
// Resetea las variables necesarias para la sección 'Title'
|
||||
void reset(Uint8 subsection = TITLE_SECTION_1);
|
||||
void init(bool demo = true, Uint8 subsection = TITLE_SECTION_1);
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
section_t run(Uint8 subsection = TITLE_SECTION_1);
|
||||
|
||||
@@ -46,6 +46,8 @@ struct options_t
|
||||
Uint32 fullScreenModePrevious; // Usado por si se cancelan los cambios en el menu de opciones
|
||||
Uint8 windowSize; // Contiene el valor del tamaño de la ventana
|
||||
Uint8 windowSizePrevious; // Usado por si se cancelan los cambios en el menu de opciones
|
||||
Uint8 language; // Idioma usado en el juego
|
||||
Uint8 languagePrevious; // Usado por si se cancelan los cambios en el menu de opciones
|
||||
};
|
||||
|
||||
// Calcula el cuadrado de la distancia entre dos puntos
|
||||
|
||||
Reference in New Issue
Block a user