En proceso de eliminar el online y los menus
This commit is contained in:
457
source/title.cpp
457
source/title.cpp
@@ -1,5 +1,4 @@
|
||||
#include "title.h"
|
||||
#include "common/jscore.h"
|
||||
|
||||
// Constructor
|
||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section)
|
||||
@@ -31,15 +30,6 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
|
||||
text1 = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||
text2 = new Text(asset->get("8bithud.png"), asset->get("8bithud.txt"), renderer);
|
||||
|
||||
#ifdef GAME_CONSOLE
|
||||
menu.title = new Menu(renderer, asset, input, asset->get("title_gc.men"));
|
||||
menu.options = new Menu(renderer, asset, input, asset->get("options_gc.men"));
|
||||
#else
|
||||
menu.title = new Menu(renderer, asset, input, asset->get("title.men"));
|
||||
menu.options = new Menu(renderer, asset, input, asset->get("options.men"));
|
||||
#endif
|
||||
menu.playerSelect = new Menu(renderer, asset, input, asset->get("player_select.men"));
|
||||
|
||||
// Sonidos
|
||||
crashSound = JA_LoadSound(asset->get("title.wav").c_str());
|
||||
|
||||
@@ -77,10 +67,6 @@ Title::~Title()
|
||||
delete text1;
|
||||
delete text2;
|
||||
|
||||
delete menu.title;
|
||||
delete menu.options;
|
||||
delete menu.playerSelect;
|
||||
|
||||
JA_DeleteSound(crashSound);
|
||||
JA_DeleteMusic(titleMusic);
|
||||
|
||||
@@ -96,7 +82,6 @@ void Title::init()
|
||||
backgroundCounter = 0;
|
||||
backgroundMode = rand() % 2;
|
||||
menuVisible = false;
|
||||
menu.active = menu.title;
|
||||
nextSection.name = SECTION_PROG_GAME;
|
||||
postFade = 0;
|
||||
ticks = 0;
|
||||
@@ -133,11 +118,6 @@ void Title::init()
|
||||
options->input[1].name = availableInputDevices[deviceIndex[1]].name;
|
||||
options->input[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType;
|
||||
}
|
||||
else
|
||||
{ // Si no ha encontrado un mando, deshabilita la opción de jugar a 2 jugadores
|
||||
menu.title->setSelectable(1, false);
|
||||
menu.title->setGreyed(1, true);
|
||||
}
|
||||
|
||||
// Inicializa el bitmap de Coffee
|
||||
coffeeBitmap->init();
|
||||
@@ -203,12 +183,6 @@ void Title::init()
|
||||
{
|
||||
sin[i] = SDL_sinf((float)i * 3.14f / 180.0f);
|
||||
}
|
||||
|
||||
// Actualiza los textos de los menus
|
||||
updateMenuLabels();
|
||||
|
||||
// Comprueba si se puede acceder a la tabla de puntuaciones y habilita la opción de menu
|
||||
setHiScoreTableOptionMenu();
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -313,7 +287,6 @@ void Title::update()
|
||||
|
||||
case 3: // TIME OUT
|
||||
counter = TITLE_COUNTER;
|
||||
menu.active->reset();
|
||||
if (demo)
|
||||
{
|
||||
runDemoGame();
|
||||
@@ -337,179 +310,6 @@ void Title::update()
|
||||
|
||||
// Actualiza el tileado de fondo
|
||||
updateBG();
|
||||
|
||||
// Comprueba las entradas para el menu
|
||||
if (menuVisible == true)
|
||||
{
|
||||
menu.active->update();
|
||||
}
|
||||
|
||||
// Comprueba si se ha seleccionado algún item del menú de titulo
|
||||
if (menu.active->getName() == "TITLE")
|
||||
{
|
||||
switch (menu.active->getItemSelected())
|
||||
{
|
||||
case 0: // 1 PLAYER -> Cambia al manu de selección de jugador
|
||||
menu.active = menu.playerSelect;
|
||||
break;
|
||||
|
||||
case 1: // 2 PLAYERS
|
||||
postFade = 1;
|
||||
fade->activateFade();
|
||||
break;
|
||||
|
||||
case 2: // OPTIONS
|
||||
menu.active = menu.options;
|
||||
optionsPrevious = *options;
|
||||
break;
|
||||
|
||||
case 3: // QUIT
|
||||
postFade = 2;
|
||||
fade->activateFade();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si se ha seleccionado algún item del menú de selección de jugador
|
||||
if (menu.active->getName() == "PLAYER_SELECT")
|
||||
{
|
||||
switch (menu.active->getItemSelected())
|
||||
{
|
||||
case 0:
|
||||
// Este item no se puede seleccionar y actua de titulo
|
||||
break;
|
||||
|
||||
case 1: // BAL1
|
||||
postFade = 0;
|
||||
options->playerSelected = 0;
|
||||
fade->activateFade();
|
||||
break;
|
||||
|
||||
case 2: // AROUNDER
|
||||
postFade = 0;
|
||||
options->playerSelected = 1;
|
||||
fade->activateFade();
|
||||
break;
|
||||
|
||||
case 3: // BACK
|
||||
menu.active = menu.title;
|
||||
menu.playerSelect->reset();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si se ha seleccionado algún item de opciones
|
||||
if (menu.active->getName() == "OPTIONS")
|
||||
{
|
||||
switch (menu.active->getItemSelected())
|
||||
{
|
||||
case 0: // Difficulty
|
||||
if (options->difficulty == DIFFICULTY_EASY)
|
||||
options->difficulty = DIFFICULTY_NORMAL;
|
||||
else if (options->difficulty == DIFFICULTY_NORMAL)
|
||||
options->difficulty = DIFFICULTY_HARD;
|
||||
else
|
||||
options->difficulty = DIFFICULTY_EASY;
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 1: // PLAYER 1 CONTROLS
|
||||
updatePlayerInputs(0);
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 3: // PLAYER 2 CONTROLS
|
||||
updatePlayerInputs(1);
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 5: // Language
|
||||
options->language++;
|
||||
if (options->language == 3)
|
||||
options->language = 0;
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 6: // Display mode
|
||||
switchFullScreenModeVar();
|
||||
if (options->videoMode != 0)
|
||||
{
|
||||
menu.options->setSelectable(8, false);
|
||||
menu.options->setGreyed(8, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.options->setSelectable(8, true);
|
||||
menu.options->setGreyed(8, false);
|
||||
}
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 8: // Windows size
|
||||
options->windowSize++;
|
||||
if (options->windowSize == 5)
|
||||
options->windowSize = 1;
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 9: // FILTER
|
||||
if (options->filter == FILTER_LINEAL)
|
||||
options->filter = FILTER_NEAREST;
|
||||
else
|
||||
options->filter = FILTER_LINEAL;
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 10: // VSYNC
|
||||
if (options->vSync)
|
||||
options->vSync = false;
|
||||
else
|
||||
options->vSync = true;
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 11: // HOW TO PLAY
|
||||
runInstructions(m_manual);
|
||||
break;
|
||||
|
||||
case 12: // HISCORE TABLE
|
||||
runHiScoreTable(mhst_manual);
|
||||
break;
|
||||
|
||||
case 13: // JAILERID:
|
||||
runEnterID();
|
||||
setHiScoreTableOptionMenu();
|
||||
updateMenuLabels();
|
||||
break;
|
||||
|
||||
case 14: // ACCEPT
|
||||
applyOptions();
|
||||
menu.active->reset();
|
||||
menu.active = menu.title;
|
||||
break;
|
||||
|
||||
case 15: // CANCEL
|
||||
options = &optionsPrevious;
|
||||
updateMenuLabels();
|
||||
menu.active->reset();
|
||||
menu.active = menu.title;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (menu.active->getName() == "TITLE")
|
||||
{
|
||||
counter--;
|
||||
}
|
||||
}
|
||||
else if (counter == 0)
|
||||
{
|
||||
@@ -637,22 +437,7 @@ void Title::render()
|
||||
// Dibuja el degradado
|
||||
gradient->render();
|
||||
|
||||
// Dibuja los objetos
|
||||
if (menu.active->getName() != "OPTIONS")
|
||||
{
|
||||
// Bitmaps con el logo/titulo del juego
|
||||
coffeeBitmap->render();
|
||||
crisisBitmap->render();
|
||||
|
||||
// Texto con el copyright y versión
|
||||
text2->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor);
|
||||
}
|
||||
|
||||
if (menuVisible == true)
|
||||
{
|
||||
menu.active->render();
|
||||
}
|
||||
|
||||
// Dibuja el polvillo del título
|
||||
dustBitmapR->render();
|
||||
dustBitmapL->render();
|
||||
|
||||
@@ -768,223 +553,6 @@ void Title::switchFullScreenModeVar()
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza los elementos de los menus
|
||||
void Title::updateMenuLabels()
|
||||
{
|
||||
int i = 0;
|
||||
// DIFFICULTY
|
||||
switch (options->difficulty)
|
||||
{
|
||||
case DIFFICULTY_EASY:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(66)); // EASY
|
||||
break;
|
||||
|
||||
case DIFFICULTY_NORMAL:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(67)); // NORMAL
|
||||
break;
|
||||
|
||||
case DIFFICULTY_HARD:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(68)); // HARD
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(67)); // NORMAL
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// PLAYER 1 CONTROLS
|
||||
menu.options->setItemCaption(i, lang->getText(62));
|
||||
|
||||
i++;
|
||||
// PLAYER 1 CONTROLS - OPTIONS
|
||||
switch (options->input[0].deviceType)
|
||||
{
|
||||
case INPUT_USE_KEYBOARD:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
menu.options->setGreyed(i, false);
|
||||
break;
|
||||
|
||||
case INPUT_USE_GAMECONTROLLER:
|
||||
menu.options->setItemCaption(i, lang->getText(70)); // GAME CONTROLLER
|
||||
if (!input->gameControllerFound())
|
||||
menu.options->setGreyed(i, true);
|
||||
else
|
||||
{
|
||||
menu.options->setGreyed(i, false);
|
||||
menu.options->setItemCaption(i, options->input[0].name);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// PLAYER 2 CONTROLS
|
||||
menu.options->setItemCaption(i, lang->getText(63));
|
||||
|
||||
i++;
|
||||
// PLAYER 2 CONTROLS - OPTIONS
|
||||
switch (options->input[1].deviceType)
|
||||
{
|
||||
case INPUT_USE_KEYBOARD:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
menu.options->setGreyed(i, false);
|
||||
break;
|
||||
|
||||
case INPUT_USE_GAMECONTROLLER:
|
||||
menu.options->setItemCaption(i, lang->getText(70)); // GAME CONTROLLER
|
||||
if (!input->gameControllerFound())
|
||||
menu.options->setGreyed(i, true);
|
||||
else
|
||||
{
|
||||
menu.options->setGreyed(i, false);
|
||||
menu.options->setItemCaption(i, options->input[1].name);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// LANGUAGE
|
||||
switch (options->language)
|
||||
{
|
||||
case es_ES:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(24)); // SPANISH
|
||||
break;
|
||||
|
||||
case ba_BA:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(25)); // VALENCIAN
|
||||
break;
|
||||
|
||||
case en_UK:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(26)); // ENGLISH
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(26)); // ENGLISH
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// DISPLAY MODE
|
||||
menu.options->setItemCaption(i, lang->getText(58));
|
||||
|
||||
i++;
|
||||
// DISPLAY MODE - OPTIONS
|
||||
switch (options->videoMode)
|
||||
{
|
||||
case 0:
|
||||
menu.options->setItemCaption(i, lang->getText(4)); // WINDOW
|
||||
break;
|
||||
|
||||
case SDL_WINDOW_FULLSCREEN:
|
||||
menu.options->setItemCaption(i, lang->getText(5)); // FULLSCREEN
|
||||
break;
|
||||
|
||||
case SDL_WINDOW_FULLSCREEN_DESKTOP:
|
||||
menu.options->setItemCaption(i, lang->getText(6)); // FAKE FULLSCREEN
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(4)); // WINDOW
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// WINDOW SIZE
|
||||
menu.options->setItemCaption(i, lang->getText(7) + " x" + std::to_string(options->windowSize)); // WINDOW SIZE
|
||||
|
||||
i++;
|
||||
// FILTER
|
||||
if (options->filter == FILTER_LINEAL)
|
||||
menu.options->setItemCaption(i, lang->getText(60) + ": " + lang->getText(71)); // BILINEAL
|
||||
else
|
||||
menu.options->setItemCaption(i, lang->getText(60) + ": " + lang->getText(72)); // LINEAL
|
||||
|
||||
i++;
|
||||
// VSYNC
|
||||
if (options->vSync)
|
||||
menu.options->setItemCaption(i, lang->getText(61) + ": " + lang->getText(73)); // ON
|
||||
else
|
||||
menu.options->setItemCaption(i, lang->getText(61) + ": " + lang->getText(74)); // OFF
|
||||
|
||||
i++;
|
||||
// HOW TO PLAY
|
||||
menu.options->setItemCaption(i, lang->getText(2));
|
||||
|
||||
i++;
|
||||
// HISCORE TABLE
|
||||
menu.options->setItemCaption(i, lang->getText(93));
|
||||
|
||||
i++;
|
||||
// JAILERID;
|
||||
const std::string jailerID = options->online.jailerID == "" ? lang->getText(64) : options->online.jailerID;
|
||||
menu.options->setItemCaption(i, "JAILERID: " + jailerID);
|
||||
|
||||
i++;
|
||||
// ACCEPT
|
||||
menu.options->setItemCaption(i, lang->getText(9)); // ACCEPT
|
||||
|
||||
i++;
|
||||
// CANCEL
|
||||
menu.options->setItemCaption(i, lang->getText(10)); // CANCEL
|
||||
|
||||
// Recoloca el menu de opciones
|
||||
menu.options->centerMenuOnX(GAMECANVAS_CENTER_X);
|
||||
menu.options->centerMenuOnY(GAMECANVAS_CENTER_Y);
|
||||
menu.options->centerMenuElementsOnX();
|
||||
|
||||
// Establece las etiquetas del menu de titulo
|
||||
#ifdef GAME_CONSOLE
|
||||
menu.title->setItemCaption(0, lang->getText(0)); // PLAY
|
||||
#else
|
||||
menu.title->setItemCaption(0, lang->getText(51)); // 1 PLAYER
|
||||
#endif
|
||||
menu.title->setItemCaption(1, lang->getText(52)); // 2 PLAYERS
|
||||
menu.title->setItemCaption(2, lang->getText(1)); // OPTIONS
|
||||
menu.title->setItemCaption(3, lang->getText(3)); // QUIT
|
||||
|
||||
// Recoloca el menu de titulo
|
||||
menu.title->centerMenuOnX(GAMECANVAS_CENTER_X);
|
||||
menu.title->centerMenuElementsOnX();
|
||||
|
||||
// Establece las etiquetas del menu de seleccion de jugador
|
||||
menu.playerSelect->setItemCaption(0, lang->getText(39)); // SELECT PLAYER
|
||||
menu.playerSelect->setItemCaption(3, lang->getText(40)); // BACK
|
||||
|
||||
// Recoloca el menu de selección de jugador
|
||||
menu.playerSelect->centerMenuOnX(GAMECANVAS_CENTER_X);
|
||||
menu.playerSelect->centerMenuElementsOnX();
|
||||
|
||||
#ifdef GAME_CONSOLE
|
||||
menu.options->setGreyed(1, true);
|
||||
menu.options->setSelectable(1, false);
|
||||
menu.options->setGreyed(2, true);
|
||||
menu.options->setSelectable(2, false);
|
||||
menu.options->setGreyed(3, true);
|
||||
menu.options->setSelectable(3, false);
|
||||
menu.options->setGreyed(4, true);
|
||||
menu.options->setSelectable(4, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Aplica las opciones de menu seleccionadas
|
||||
void Title::applyOptions()
|
||||
{
|
||||
screen->setVideoMode(options->videoMode);
|
||||
|
||||
lang->setLang(options->language);
|
||||
|
||||
updateMenuLabels();
|
||||
createTiledBackground();
|
||||
}
|
||||
|
||||
// Bucle para el titulo del juego
|
||||
void Title::run()
|
||||
{
|
||||
@@ -1028,14 +596,6 @@ void Title::runDemoGame()
|
||||
delete demoGame;
|
||||
}
|
||||
|
||||
// Introduce el JailerID
|
||||
void Title::runEnterID()
|
||||
{
|
||||
enterID = new EnterID(renderer, screen, asset, lang, options, section);
|
||||
enterID->run();
|
||||
delete enterID;
|
||||
}
|
||||
|
||||
// Modifica las opciones para los controles de los jugadores
|
||||
bool Title::updatePlayerInputs(int numPlayer)
|
||||
{
|
||||
@@ -1186,19 +746,4 @@ void Title::reLoadTextures()
|
||||
crisisTexture->reLoad();
|
||||
gradientTexture->reLoad();
|
||||
createTiledBackground();
|
||||
}
|
||||
|
||||
// Comprueba si se puede acceder a la tabla de puntuaciones y habilita la opción de menu
|
||||
void Title::setHiScoreTableOptionMenu()
|
||||
{
|
||||
if (options->online.sessionEnabled)
|
||||
{
|
||||
menu.options->setSelectable(12, true);
|
||||
menu.options->setGreyed(12, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.options->setSelectable(12, false);
|
||||
menu.options->setGreyed(12, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user