singletons
This commit is contained in:
@@ -30,13 +30,9 @@
|
||||
struct JA_Sound_t;
|
||||
|
||||
// Constructor
|
||||
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, section_t *section) {
|
||||
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, section_t *section) {
|
||||
// Copia los punteros
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->asset = asset;
|
||||
this->lang = lang;
|
||||
this->input = input;
|
||||
this->section = section;
|
||||
|
||||
// Pasa variables
|
||||
@@ -404,15 +400,15 @@ void Game::loadMedia() {
|
||||
|
||||
// Menus
|
||||
gameOverMenu = R->getMenu("gameover");
|
||||
gameOverMenu->setItemCaption(0, lang->getText(48));
|
||||
gameOverMenu->setItemCaption(1, lang->getText(49));
|
||||
const int w = text->getCharacterSize() * lang->getText(45).length();
|
||||
gameOverMenu->setItemCaption(0, Lang::get()->getText(48));
|
||||
gameOverMenu->setItemCaption(1, Lang::get()->getText(49));
|
||||
const int w = text->getCharacterSize() * Lang::get()->getText(45).length();
|
||||
gameOverMenu->setRectSize(w, 0);
|
||||
gameOverMenu->centerMenuOnX(199);
|
||||
pauseMenu = R->getMenu("pause");
|
||||
pauseMenu->setItemCaption(0, lang->getText(41));
|
||||
pauseMenu->setItemCaption(1, lang->getText(46));
|
||||
pauseMenu->setItemCaption(2, lang->getText(47));
|
||||
pauseMenu->setItemCaption(0, Lang::get()->getText(41));
|
||||
pauseMenu->setItemCaption(1, Lang::get()->getText(46));
|
||||
pauseMenu->setItemCaption(2, Lang::get()->getText(47));
|
||||
|
||||
// Sonidos
|
||||
balloonSound = R->getSound("balloon.wav");
|
||||
@@ -444,7 +440,7 @@ void Game::loadMedia() {
|
||||
bool Game::loadScoreFile() {
|
||||
// Indicador de éxito en la carga
|
||||
bool success = true;
|
||||
const std::string p = asset->get("score.bin");
|
||||
const std::string p = Asset::get()->get("score.bin");
|
||||
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "r+b");
|
||||
|
||||
@@ -536,7 +532,7 @@ bool Game::loadDemoFile() {
|
||||
// Guarda el fichero de puntos
|
||||
bool Game::saveScoreFile() {
|
||||
bool success = true;
|
||||
const std::string p = asset->get("score.bin");
|
||||
const std::string p = Asset::get()->get("score.bin");
|
||||
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "w+b");
|
||||
if (file != nullptr) {
|
||||
@@ -562,7 +558,7 @@ bool Game::saveScoreFile() {
|
||||
// Guarda el fichero de datos para la demo
|
||||
bool Game::saveDemoFile() {
|
||||
bool success = true;
|
||||
const std::string p = asset->get("demo.bin");
|
||||
const std::string p = Asset::get()->get("demo.bin");
|
||||
const std::string filename = p.substr(p.find_last_of("\\/") + 1);
|
||||
if (demo.recording) {
|
||||
SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "w+b");
|
||||
@@ -1375,33 +1371,33 @@ void Game::renderScoreBoard() {
|
||||
const int offsetRight = PLAY_AREA_RIGHT - 45;
|
||||
|
||||
// PLAYER1 - SCORE
|
||||
textScoreBoard->writeCentered(offsetLeft, offset1, lang->getText(53));
|
||||
textScoreBoard->writeCentered(offsetLeft, offset1, Lang::get()->getText(53));
|
||||
textScoreBoard->writeCentered(offsetLeft, offset2, updateScoreText(players[0]->getScore()));
|
||||
|
||||
// PLAYER1 - MULT
|
||||
textScoreBoard->writeCentered(offsetLeft, offset3, lang->getText(55));
|
||||
textScoreBoard->writeCentered(offsetLeft, offset3, Lang::get()->getText(55));
|
||||
textScoreBoard->writeCentered(offsetLeft, offset4, std::to_string(players[0]->getScoreMultiplier()).substr(0, 3));
|
||||
|
||||
if (numPlayers == 2) {
|
||||
// PLAYER2 - SCORE
|
||||
textScoreBoard->writeCentered(offsetRight, offset1, lang->getText(54));
|
||||
textScoreBoard->writeCentered(offsetRight, offset1, Lang::get()->getText(54));
|
||||
textScoreBoard->writeCentered(offsetRight, offset2, updateScoreText(players[1]->getScore()));
|
||||
|
||||
// PLAYER2 - MULT
|
||||
textScoreBoard->writeCentered(offsetRight, offset3, lang->getText(55));
|
||||
textScoreBoard->writeCentered(offsetRight, offset3, Lang::get()->getText(55));
|
||||
textScoreBoard->writeCentered(offsetRight, offset4, std::to_string(players[1]->getScoreMultiplier()).substr(0, 3));
|
||||
} else {
|
||||
// PLAYER2 - SCORE
|
||||
textScoreBoard->writeCentered(offsetRight, offset1, lang->getText(54));
|
||||
textScoreBoard->writeCentered(offsetRight, offset1, Lang::get()->getText(54));
|
||||
textScoreBoard->writeCentered(offsetRight, offset2, "0000000");
|
||||
|
||||
// PLAYER2 - MULT
|
||||
textScoreBoard->writeCentered(offsetRight, offset3, lang->getText(55));
|
||||
textScoreBoard->writeCentered(offsetRight, offset3, Lang::get()->getText(55));
|
||||
textScoreBoard->writeCentered(offsetRight, offset4, "1.0");
|
||||
}
|
||||
|
||||
// STAGE
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1, lang->getText(57) + std::to_string(stage[currentStage].number));
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1, Lang::get()->getText(57) + std::to_string(stage[currentStage].number));
|
||||
|
||||
// POWERMETER
|
||||
powerMeterSprite->setPosY(offset2);
|
||||
@@ -1412,7 +1408,7 @@ void Game::renderScoreBoard() {
|
||||
powerMeterSprite->render();
|
||||
|
||||
// HI-SCORE
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3, lang->getText(56));
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3, Lang::get()->getText(56));
|
||||
textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, hiScoreName + updateScoreText(hiScore));
|
||||
}
|
||||
|
||||
@@ -2458,10 +2454,10 @@ void Game::renderBackground() {
|
||||
// Dibuja el juego
|
||||
void Game::render() {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Dibuja los objetos
|
||||
renderBackground();
|
||||
@@ -2484,7 +2480,7 @@ void Game::render() {
|
||||
renderFlashEffect();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Gestiona el nivel de amenaza
|
||||
@@ -2519,7 +2515,7 @@ void Game::checkGameInput() {
|
||||
demo.keys.fireRight = 0;
|
||||
|
||||
// Atalls globals (zoom finestra, fullscreen, shaders, presets, ...)
|
||||
GlobalInputs::handle(screen, input);
|
||||
GlobalInputs::handle();
|
||||
|
||||
// Modo Demo activo
|
||||
if (demo.enabled) {
|
||||
@@ -2561,7 +2557,7 @@ void Game::checkGameInput() {
|
||||
}
|
||||
|
||||
// Si se pulsa cualquier tecla, se sale del modo demo
|
||||
if (input->checkAnyInput()) {
|
||||
if (Input::get()->checkAnyInput()) {
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
}
|
||||
|
||||
@@ -2579,12 +2575,12 @@ void Game::checkGameInput() {
|
||||
for (auto player : players) {
|
||||
if (player->isAlive()) {
|
||||
// Input a la izquierda
|
||||
if (input->checkInput(input_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (Input::get()->checkInput(input_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
player->setInput(input_left);
|
||||
demo.keys.left = 1;
|
||||
} else {
|
||||
// Input a la derecha
|
||||
if (input->checkInput(input_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (Input::get()->checkInput(input_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
player->setInput(input_right);
|
||||
demo.keys.right = 1;
|
||||
} else {
|
||||
@@ -2594,7 +2590,7 @@ void Game::checkGameInput() {
|
||||
}
|
||||
}
|
||||
// Comprueba el input de disparar al centro
|
||||
if (input->checkInput(input_fire_center, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (Input::get()->checkInput(input_fire_center, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (player->canFire()) {
|
||||
player->setInput(input_fire_center);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_UP, player->isPowerUp(), i);
|
||||
@@ -2608,7 +2604,7 @@ void Game::checkGameInput() {
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la izquierda
|
||||
if (input->checkInput(input_fire_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (Input::get()->checkInput(input_fire_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (player->canFire()) {
|
||||
player->setInput(input_fire_left);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_LEFT, player->isPowerUp(), i);
|
||||
@@ -2622,7 +2618,7 @@ void Game::checkGameInput() {
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la derecha
|
||||
if (input->checkInput(input_fire_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (Input::get()->checkInput(input_fire_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (player->canFire()) {
|
||||
player->setInput(input_fire_right);
|
||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 4, player->getPosY() + (player->getHeight() / 2), BULLET_RIGHT, player->isPowerUp(), i);
|
||||
@@ -2636,7 +2632,7 @@ void Game::checkGameInput() {
|
||||
}
|
||||
|
||||
// Comprueba el input de pausa
|
||||
if (input->checkInput(input_pause, REPEAT_FALSE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
if (Input::get()->checkInput(input_pause, REPEAT_FALSE, Options::inputs[i].deviceType, Options::inputs[i].id)) {
|
||||
section->subsection = SUBSECTION_GAME_PAUSE;
|
||||
}
|
||||
|
||||
@@ -2659,13 +2655,13 @@ void Game::checkGameInput() {
|
||||
void Game::renderMessages() {
|
||||
// GetReady
|
||||
if ((counter < STAGE_COUNTER) && (!demo.enabled)) {
|
||||
textNokiaBig2->write((int)getReadyBitmapPath[counter], PLAY_AREA_CENTER_Y - 8, lang->getText(75), -2);
|
||||
textNokiaBig2->write((int)getReadyBitmapPath[counter], PLAY_AREA_CENTER_Y - 8, Lang::get()->getText(75), -2);
|
||||
}
|
||||
|
||||
// Time Stopped
|
||||
if (timeStopped) {
|
||||
if ((timeStoppedCounter > 100) || (timeStoppedCounter % 10 > 4)) {
|
||||
textNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, lang->getText(36) + std::to_string(timeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
||||
textNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, Lang::get()->getText(36) + std::to_string(timeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
||||
}
|
||||
|
||||
if (timeStoppedCounter > 100) {
|
||||
@@ -2682,7 +2678,7 @@ void Game::renderMessages() {
|
||||
// D E M O
|
||||
if (demo.enabled) {
|
||||
if (demo.counter % 30 > 14) {
|
||||
textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, lang->getText(37), 0, noColor, 2, shdwTxtColor);
|
||||
textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, Lang::get()->getText(37), 0, noColor, 2, shdwTxtColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2692,17 +2688,17 @@ void Game::renderMessages() {
|
||||
std::string text;
|
||||
|
||||
if (stageNum == 10) { // Ultima fase
|
||||
text = lang->getText(79);
|
||||
text = Lang::get()->getText(79);
|
||||
} else { // X fases restantes
|
||||
text = std::to_string(11 - stage[currentStage].number) + lang->getText(38);
|
||||
text = std::to_string(11 - stage[currentStage].number) + Lang::get()->getText(38);
|
||||
}
|
||||
|
||||
if (!gameCompleted) { // Escribe el numero de fases restantes
|
||||
textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 2, shdwTxtColor);
|
||||
} else { // Escribe el texto de juego completado
|
||||
text = lang->getText(50);
|
||||
text = Lang::get()->getText(50);
|
||||
textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter], text, -2, noColor, 1, shdwTxtColor);
|
||||
textNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, lang->getText(76), -1, noColor, 1, shdwTxtColor);
|
||||
textNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, Lang::get()->getText(76), -1, noColor, 1, shdwTxtColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2861,6 +2857,9 @@ void Game::updatePausedGame() {
|
||||
// Actualiza el contador de ticks
|
||||
ticks = SDL_GetTicks();
|
||||
|
||||
// Atalls globals (zoom finestra, fullscreen, shaders, presets, ...)
|
||||
GlobalInputs::handle();
|
||||
|
||||
if (leavingPauseMenu) {
|
||||
if (pauseCounter > 0) { // El contador está descendiendo
|
||||
const bool a = pauseCounter == 90;
|
||||
@@ -2913,10 +2912,10 @@ void Game::updatePausedGame() {
|
||||
// Dibuja el menu de pausa del juego
|
||||
void Game::renderPausedGame() {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Pinta el escenario
|
||||
{
|
||||
@@ -2948,7 +2947,7 @@ void Game::renderPausedGame() {
|
||||
fade->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Inicializa el estado de pausa del juego
|
||||
@@ -2974,6 +2973,9 @@ void Game::updateGameOverScreen() {
|
||||
// Actualiza el contador de ticks
|
||||
ticks = SDL_GetTicks();
|
||||
|
||||
// Atalls globals (zoom finestra, fullscreen, shaders, presets, ...)
|
||||
GlobalInputs::handle();
|
||||
|
||||
// Actualiza la lógica del menu
|
||||
gameOverMenu->update();
|
||||
|
||||
@@ -3043,10 +3045,10 @@ void Game::checkGameOverEvents() {
|
||||
// Dibuja los elementos de la pantalla de game over
|
||||
void Game::renderGameOverScreen() {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Dibujo
|
||||
if (!gameCompleted) { // Dibujo de haber perdido la partida
|
||||
@@ -3059,33 +3061,33 @@ void Game::renderGameOverScreen() {
|
||||
if (numPlayers == 1) {
|
||||
// Congratulations!!
|
||||
if (gameCompleted) {
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), lang->getText(50));
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), Lang::get()->getText(50));
|
||||
}
|
||||
|
||||
// Game Over
|
||||
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), lang->getText(43));
|
||||
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), Lang::get()->getText(43));
|
||||
|
||||
// Your Score
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), lang->getText(44) + std::to_string(players[0]->getScore()));
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), Lang::get()->getText(44) + std::to_string(players[0]->getScore()));
|
||||
} else {
|
||||
// Congratulations!!
|
||||
if (gameCompleted) {
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), lang->getText(50));
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), Lang::get()->getText(50));
|
||||
}
|
||||
|
||||
// Game Over
|
||||
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), lang->getText(43));
|
||||
textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), Lang::get()->getText(43));
|
||||
|
||||
// Player1 Score
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), lang->getText(77) + std::to_string(players[0]->getScore()));
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), Lang::get()->getText(77) + std::to_string(players[0]->getScore()));
|
||||
|
||||
// Player2 Score
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 2), lang->getText(78) + std::to_string(players[1]->getScore()));
|
||||
text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 2), Lang::get()->getText(78) + std::to_string(players[1]->getScore()));
|
||||
}
|
||||
|
||||
// Continue?
|
||||
if (!gameCompleted) { // Solo dibuja el menu de continuar en el caso de no haber completado la partida
|
||||
text->writeCentered(199, PLAY_AREA_CENTER_Y + BLOCK * 3, lang->getText(45));
|
||||
text->writeCentered(199, PLAY_AREA_CENTER_Y + BLOCK * 3, Lang::get()->getText(45));
|
||||
gameOverMenu->render();
|
||||
}
|
||||
|
||||
@@ -3093,7 +3095,7 @@ void Game::renderGameOverScreen() {
|
||||
fade->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Inicializa el estado de game over
|
||||
@@ -3158,7 +3160,7 @@ void Game::initPaths() {
|
||||
}
|
||||
|
||||
// Letrero de GetReady
|
||||
const int size = textNokiaBig2->lenght(lang->getText(75), -2);
|
||||
const int size = textNokiaBig2->lenght(Lang::get()->getText(75), -2);
|
||||
|
||||
const float start1 = PLAY_AREA_LEFT - size;
|
||||
const float finish1 = PLAY_AREA_CENTER_X - (size / 2);
|
||||
|
||||
@@ -6,17 +6,13 @@
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "utils/utils.h" // for demoKeys_t, color_t
|
||||
class Asset;
|
||||
class Balloon;
|
||||
class Bullet;
|
||||
class Fade;
|
||||
class Input;
|
||||
class Item;
|
||||
class Lang;
|
||||
class Menu;
|
||||
class MovingSprite;
|
||||
class Player;
|
||||
class Screen;
|
||||
class SmartSprite;
|
||||
class Sprite;
|
||||
class Text;
|
||||
@@ -131,10 +127,6 @@ class Game {
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||
Input *input; // Manejador de entrada
|
||||
section_t *section; // Seccion actual dentro del juego
|
||||
|
||||
std::vector<Player *> players; // Vector con los jugadores
|
||||
@@ -545,7 +537,7 @@ class Game {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, section_t *section);
|
||||
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, section_t *section);
|
||||
|
||||
// Destructor
|
||||
~Game();
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "core/input/input.h" // for INPUT_USE_KEYBOARD, INPUT_USE_GAMECONTROLLER
|
||||
#include "core/locale/lang.h" // for MAX_LANGUAGES, en_UK
|
||||
#include "core/input/input.h" // for INPUT_USE_KEYBOARD, INPUT_USE_GAMECONTROLLER
|
||||
#include "core/locale/lang.h" // for MAX_LANGUAGES, en_UK
|
||||
#include "external/fkyaml_node.hpp" // for fkyaml::node
|
||||
#include "utils/utils.h" // for boolToString
|
||||
|
||||
@@ -456,7 +456,9 @@ namespace Options {
|
||||
for (const auto &p : yaml["presets"]) {
|
||||
PostFXPreset preset;
|
||||
if (p.contains("name")) {
|
||||
try { preset.name = p["name"].get_value<std::string>(); } catch (...) {}
|
||||
try {
|
||||
preset.name = p["name"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
parseFloatField(p, "vignette", preset.vignette);
|
||||
parseFloatField(p, "scanlines", preset.scanlines);
|
||||
@@ -511,7 +513,9 @@ namespace Options {
|
||||
for (const auto &p : yaml["presets"]) {
|
||||
CrtPiPreset preset;
|
||||
if (p.contains("name")) {
|
||||
try { preset.name = p["name"].get_value<std::string>(); } catch (...) {}
|
||||
try {
|
||||
preset.name = p["name"].get_value<std::string>();
|
||||
} catch (...) {}
|
||||
}
|
||||
parseFloatField(p, "scanline_weight", preset.scanline_weight);
|
||||
parseFloatField(p, "scanline_gap_brightness", preset.scanline_gap_brightness);
|
||||
@@ -522,22 +526,34 @@ namespace Options {
|
||||
parseFloatField(p, "curvature_x", preset.curvature_x);
|
||||
parseFloatField(p, "curvature_y", preset.curvature_y);
|
||||
if (p.contains("mask_type")) {
|
||||
try { preset.mask_type = p["mask_type"].get_value<int>(); } catch (...) {}
|
||||
try {
|
||||
preset.mask_type = p["mask_type"].get_value<int>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (p.contains("enable_scanlines")) {
|
||||
try { preset.enable_scanlines = p["enable_scanlines"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
preset.enable_scanlines = p["enable_scanlines"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (p.contains("enable_multisample")) {
|
||||
try { preset.enable_multisample = p["enable_multisample"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
preset.enable_multisample = p["enable_multisample"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (p.contains("enable_gamma")) {
|
||||
try { preset.enable_gamma = p["enable_gamma"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
preset.enable_gamma = p["enable_gamma"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (p.contains("enable_curvature")) {
|
||||
try { preset.enable_curvature = p["enable_curvature"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
preset.enable_curvature = p["enable_curvature"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
if (p.contains("enable_sharper")) {
|
||||
try { preset.enable_sharper = p["enable_sharper"].get_value<bool>(); } catch (...) {}
|
||||
try {
|
||||
preset.enable_sharper = p["enable_sharper"].get_value<bool>();
|
||||
} catch (...) {}
|
||||
}
|
||||
crtpi_presets.push_back(preset);
|
||||
}
|
||||
|
||||
@@ -6,27 +6,22 @@
|
||||
#include <iostream> // for char_traits, basic_ostream, operator<<
|
||||
#include <string> // for basic_string
|
||||
|
||||
#include "core/audio/jail_audio.hpp" // for JA_StopMusic
|
||||
#include "core/audio/jail_audio.hpp" // for JA_StopMusic
|
||||
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
|
||||
#include "core/locale/lang.h" // for Lang
|
||||
#include "core/rendering/screen.h" // for Screen
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
|
||||
#include "core/locale/lang.h" // for Lang
|
||||
#include "core/rendering/screen.h" // for Screen
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/resource.h"
|
||||
#include "game/defaults.hpp" // for shdwTxtColor, GAMECANVAS_CENTER_X, GAME...
|
||||
#include "utils/utils.h" // for color_t, section_t
|
||||
|
||||
// Constructor
|
||||
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {
|
||||
Instructions::Instructions(SDL_Renderer *renderer, section_t *section) {
|
||||
// Copia los punteros
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->asset = asset;
|
||||
this->input = input;
|
||||
this->lang = lang;
|
||||
this->section = section;
|
||||
|
||||
// Texturas (handles compartidos de Resource)
|
||||
@@ -122,21 +117,21 @@ void Instructions::render() {
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Escribe el texto
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, lang->getText(11), 1, orangeColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 24, lang->getText(12), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 34, lang->getText(13), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 48, lang->getText(14), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 58, lang->getText(15), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 75, lang->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, Lang::get()->getText(11), 1, orangeColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 24, Lang::get()->getText(12), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 34, Lang::get()->getText(13), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 48, Lang::get()->getText(14), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 58, Lang::get()->getText(15), 1, noColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 75, Lang::get()->getText(16), 1, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
text->writeShadowed(84, 92, lang->getText(17), shdwTxtColor);
|
||||
text->writeShadowed(84, 108, lang->getText(18), shdwTxtColor);
|
||||
text->writeShadowed(84, 124, lang->getText(19), shdwTxtColor);
|
||||
text->writeShadowed(84, 140, lang->getText(20), shdwTxtColor);
|
||||
text->writeShadowed(84, 156, lang->getText(21), shdwTxtColor);
|
||||
text->writeShadowed(84, 92, Lang::get()->getText(17), shdwTxtColor);
|
||||
text->writeShadowed(84, 108, Lang::get()->getText(18), shdwTxtColor);
|
||||
text->writeShadowed(84, 124, Lang::get()->getText(19), shdwTxtColor);
|
||||
text->writeShadowed(84, 140, Lang::get()->getText(20), shdwTxtColor);
|
||||
text->writeShadowed(84, 156, Lang::get()->getText(21), shdwTxtColor);
|
||||
|
||||
if ((mode == m_manual) && (counter % 50 > 14)) {
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, Lang::get()->getText(22), 1, orangeColor, 1, shdwTxtColor);
|
||||
}
|
||||
|
||||
// Disquito
|
||||
@@ -178,10 +173,10 @@ void Instructions::render() {
|
||||
SDL_SetRenderTarget(renderer, nullptr);
|
||||
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Establece la ventana del backbuffer
|
||||
if (mode == m_auto) {
|
||||
@@ -195,7 +190,7 @@ void Instructions::render() {
|
||||
SDL_RenderTexture(renderer, backbuffer, nullptr, &fWindow);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Comprueba los eventos
|
||||
@@ -216,15 +211,15 @@ void Instructions::checkEvents() {
|
||||
// Comprueba las entradas
|
||||
void Instructions::checkInput() {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
quitRequested = true;
|
||||
finished = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (GlobalInputs::handle(screen, input)) { return; }
|
||||
if (GlobalInputs::handle()) { return; }
|
||||
|
||||
if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
if (mode == m_auto) {
|
||||
finished = true;
|
||||
} else {
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <vector> // for vector
|
||||
class Asset;
|
||||
class Input;
|
||||
class Lang;
|
||||
class Screen;
|
||||
class Sprite;
|
||||
class Text;
|
||||
class Texture;
|
||||
@@ -22,14 +18,10 @@ class Instructions {
|
||||
private:
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
std::vector<Texture *> itemTextures; // Vector con las texturas de los items
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
SDL_Texture *backbuffer; // Textura para usar como backbuffer
|
||||
Sprite *sprite; // Sprite con la textura de las instrucciones
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
Input *input; // Objeto pata gestionar la entrada
|
||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||
Text *text; // Objeto para escribir texto
|
||||
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
||||
|
||||
@@ -48,7 +40,7 @@ class Instructions {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section);
|
||||
Instructions(SDL_Renderer *renderer, section_t *section);
|
||||
|
||||
// Destructor
|
||||
~Instructions();
|
||||
|
||||
@@ -4,28 +4,23 @@
|
||||
|
||||
#include <string> // for basic_string
|
||||
|
||||
#include "core/audio/jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic
|
||||
#include "core/audio/jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic
|
||||
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
|
||||
#include "core/locale/lang.h" // for Lang
|
||||
#include "core/rendering/screen.h" // for Screen
|
||||
#include "core/rendering/smartsprite.h" // for SmartSprite
|
||||
#include "core/rendering/text.h" // for Text
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/rendering/writer.h" // for Writer
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
#include "core/resources/resource.h"
|
||||
#include "game/defaults.hpp" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU...
|
||||
#include "utils/utils.h" // for section_t, color_t
|
||||
|
||||
// Constructor
|
||||
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {
|
||||
Intro::Intro(SDL_Renderer *renderer, section_t *section) {
|
||||
// Copia los punteros
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->lang = lang;
|
||||
this->asset = asset;
|
||||
this->input = input;
|
||||
this->section = section;
|
||||
|
||||
// Reserva memoria para los objetos
|
||||
@@ -115,39 +110,39 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input,
|
||||
}
|
||||
|
||||
// Un dia qualsevol de l'any 2000
|
||||
texts[0]->setCaption(lang->getText(27));
|
||||
texts[0]->setCaption(Lang::get()->getText(27));
|
||||
texts[0]->setSpeed(8);
|
||||
|
||||
// Tot esta tranquil a la UPV
|
||||
texts[1]->setCaption(lang->getText(28));
|
||||
texts[1]->setCaption(Lang::get()->getText(28));
|
||||
texts[1]->setSpeed(8);
|
||||
|
||||
// Fins que un desaprensiu...
|
||||
texts[2]->setCaption(lang->getText(29));
|
||||
texts[2]->setCaption(Lang::get()->getText(29));
|
||||
texts[2]->setSpeed(12);
|
||||
|
||||
// HEY! ME ANE A FERME UN CORTAET...
|
||||
texts[3]->setCaption(lang->getText(30));
|
||||
texts[3]->setCaption(Lang::get()->getText(30));
|
||||
texts[3]->setSpeed(8);
|
||||
|
||||
// UAAAAAAAAAAAAA!!!
|
||||
texts[4]->setCaption(lang->getText(31));
|
||||
texts[4]->setCaption(Lang::get()->getText(31));
|
||||
texts[4]->setSpeed(1);
|
||||
|
||||
// Espera un moment...
|
||||
texts[5]->setCaption(lang->getText(32));
|
||||
texts[5]->setCaption(Lang::get()->getText(32));
|
||||
texts[5]->setSpeed(16);
|
||||
|
||||
// Si resulta que no tinc solt!
|
||||
texts[6]->setCaption(lang->getText(33));
|
||||
texts[6]->setCaption(Lang::get()->getText(33));
|
||||
texts[6]->setSpeed(2);
|
||||
|
||||
// MERDA DE MAQUINA!
|
||||
texts[7]->setCaption(lang->getText(34));
|
||||
texts[7]->setCaption(Lang::get()->getText(34));
|
||||
texts[7]->setSpeed(3);
|
||||
|
||||
// Blop... blop... blop...
|
||||
texts[8]->setCaption(lang->getText(35));
|
||||
texts[8]->setCaption(Lang::get()->getText(35));
|
||||
texts[8]->setSpeed(16);
|
||||
|
||||
for (auto text : texts) {
|
||||
@@ -193,14 +188,14 @@ void Intro::checkEvents() {
|
||||
// Comprueba las entradas
|
||||
void Intro::checkInput() {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (GlobalInputs::handle(screen, input)) { return; }
|
||||
if (GlobalInputs::handle()) { return; }
|
||||
|
||||
if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
JA_StopMusic();
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
@@ -369,10 +364,10 @@ void Intro::update() {
|
||||
// Dibuja el objeto en pantalla
|
||||
void Intro::render() {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Dibuja los objetos
|
||||
for (auto bitmap : bitmaps) {
|
||||
@@ -384,7 +379,7 @@ void Intro::render() {
|
||||
}
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Bucle principal
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <vector> // for vector
|
||||
class Asset;
|
||||
class Input;
|
||||
class Lang;
|
||||
class Screen;
|
||||
class SmartSprite;
|
||||
class Text;
|
||||
class Texture;
|
||||
@@ -19,12 +15,8 @@ class Intro {
|
||||
private:
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Texture *texture; // Textura con los graficos
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||
Input *input; // Objeto pata gestionar la entrada
|
||||
std::vector<SmartSprite *> bitmaps; // Vector con los sprites inteligentes para los dibujos de la intro
|
||||
std::vector<Writer *> texts; // Textos de la intro
|
||||
Text *text; // Textos de la intro
|
||||
@@ -56,7 +48,7 @@ class Intro {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section);
|
||||
Intro(SDL_Renderer *renderer, section_t *section);
|
||||
|
||||
// Destructor
|
||||
~Intro();
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
#include <algorithm> // for min
|
||||
#include <string> // for basic_string
|
||||
|
||||
#include "core/audio/jail_audio.hpp" // for JA_StopMusic
|
||||
#include "core/audio/jail_audio.hpp" // for JA_StopMusic
|
||||
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
|
||||
#include "core/rendering/screen.h" // for Screen
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
|
||||
#include "core/rendering/screen.h" // for Screen
|
||||
#include "core/rendering/sprite.h" // for Sprite
|
||||
#include "core/rendering/texture.h" // for Texture
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
#include "core/resources/resource.h"
|
||||
#include "game/defaults.hpp" // for bgColor, SECTION_PROG_LOGO, SECTION_PROG...
|
||||
#include "utils/utils.h" // for section_t, color_t
|
||||
@@ -21,12 +21,9 @@ constexpr int INIT_FADE = 100;
|
||||
constexpr int END_LOGO = 200;
|
||||
|
||||
// Constructor
|
||||
Logo::Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, section_t *section) {
|
||||
Logo::Logo(SDL_Renderer *renderer, section_t *section) {
|
||||
// Copia la dirección de los objetos
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->asset = asset;
|
||||
this->input = input;
|
||||
this->section = section;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
@@ -76,14 +73,14 @@ void Logo::checkEvents() {
|
||||
// Comprueba las entradas
|
||||
void Logo::checkInput() {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (GlobalInputs::handle(screen, input)) { return; }
|
||||
if (GlobalInputs::handle()) { return; }
|
||||
|
||||
if (input->checkInput(input_pause, REPEAT_FALSE) || input->checkInput(input_accept, REPEAT_FALSE) || input->checkInput(input_fire_left, REPEAT_FALSE) || input->checkInput(input_fire_center, REPEAT_FALSE) || input->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_pause, REPEAT_FALSE) || Input::get()->checkInput(input_accept, REPEAT_FALSE) || Input::get()->checkInput(input_fire_left, REPEAT_FALSE) || Input::get()->checkInput(input_fire_center, REPEAT_FALSE) || Input::get()->checkInput(input_fire_right, REPEAT_FALSE)) {
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
section->subsection = SUBSECTION_TITLE_1;
|
||||
}
|
||||
@@ -120,10 +117,10 @@ void Logo::update() {
|
||||
// Dibuja el objeto en pantalla
|
||||
void Logo::render() {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean({238, 238, 238});
|
||||
Screen::get()->clean({238, 238, 238});
|
||||
|
||||
// Dibuja los objetos
|
||||
sprite->render();
|
||||
@@ -132,7 +129,7 @@ void Logo::render() {
|
||||
renderFade();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
}
|
||||
|
||||
// Bucle para el logo del juego
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
class Asset;
|
||||
class Input;
|
||||
class Screen;
|
||||
class Sprite;
|
||||
class Texture;
|
||||
struct section_t;
|
||||
@@ -13,9 +10,6 @@ class Logo {
|
||||
private:
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
Input *input; // Objeto pata gestionar la entrada
|
||||
Texture *texture; // Textura con los graficos
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
Sprite *sprite; // Sprite con la textura del logo
|
||||
@@ -46,7 +40,7 @@ class Logo {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Logo(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, section_t *section);
|
||||
Logo(SDL_Renderer *renderer, section_t *section);
|
||||
|
||||
// Destructor
|
||||
~Logo();
|
||||
|
||||
@@ -25,13 +25,9 @@
|
||||
#include "game/ui/menu.h" // for Menu
|
||||
|
||||
// Constructor
|
||||
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, Lang *lang, section_t *section) {
|
||||
Title::Title(SDL_Renderer *renderer, section_t *section) {
|
||||
// Copia las direcciones de los punteros
|
||||
this->renderer = renderer;
|
||||
this->screen = screen;
|
||||
this->input = input;
|
||||
this->asset = asset;
|
||||
this->lang = lang;
|
||||
this->section = section;
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
@@ -136,7 +132,7 @@ void Title::init() {
|
||||
deviceIndex.push_back(0); // El primer mando encontrado. Si no ha encontrado ninguno es el teclado
|
||||
|
||||
// Si ha encontrado un mando se lo asigna al segundo jugador
|
||||
if (input->gameControllerFound()) {
|
||||
if (Input::get()->gameControllerFound()) {
|
||||
Options::inputs[1].id = availableInputDevices[deviceIndex[1]].id;
|
||||
Options::inputs[1].name = availableInputDevices[deviceIndex[1]].name;
|
||||
Options::inputs[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType;
|
||||
@@ -241,10 +237,10 @@ void Title::update() {
|
||||
// que Screen::blit() presente por la ruta activa (GPU o
|
||||
// SDL_Renderer). Un `SDL_RenderPresent(renderer)` directe
|
||||
// crasheja quan el SDL3 GPU ha reclamat la ventana.
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
|
||||
// Reproduce el efecto sonoro
|
||||
JA_PlaySound(crashSound);
|
||||
@@ -513,10 +509,10 @@ void Title::render() {
|
||||
// Sección 1 - Titulo desplazandose
|
||||
case SUBSECTION_TITLE_1: {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Dibuja el tileado de fondo
|
||||
{
|
||||
@@ -532,16 +528,16 @@ void Title::render() {
|
||||
crisisBitmap->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
} break;
|
||||
|
||||
// Sección 2 - Titulo vibrando
|
||||
case SUBSECTION_TITLE_2: {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Dibuja el tileado de fondo
|
||||
{
|
||||
@@ -560,15 +556,15 @@ void Title::render() {
|
||||
dustBitmapL->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
} break;
|
||||
|
||||
// Sección 3 - La pantalla de titulo con el menú y la música
|
||||
case SUBSECTION_TITLE_3: { // Prepara para empezar a dibujar en la textura de juego
|
||||
screen->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Limpia la pantalla
|
||||
screen->clean(bgColor);
|
||||
Screen::get()->clean(bgColor);
|
||||
|
||||
// Dibuja el tileado de fondo
|
||||
{
|
||||
@@ -598,14 +594,14 @@ void Title::render() {
|
||||
|
||||
// PRESS ANY KEY!
|
||||
if ((counter % 50 > 14) && (menuVisible == false)) {
|
||||
text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor);
|
||||
text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, Lang::get()->getText(23), 1, noColor, 1, shdwTxtColor);
|
||||
}
|
||||
|
||||
// Fade
|
||||
fade->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
Screen::get()->blit();
|
||||
} break;
|
||||
|
||||
default:
|
||||
@@ -642,12 +638,12 @@ void Title::checkEvents() {
|
||||
// Comprueba las entradas
|
||||
void Title::checkInput() {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (input->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) {
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
GlobalInputs::handle(screen, input);
|
||||
GlobalInputs::handle();
|
||||
}
|
||||
|
||||
// Actualiza el tileado de fondo
|
||||
@@ -673,37 +669,37 @@ void Title::updateMenuLabels() {
|
||||
// DIFFICULTY
|
||||
switch (Options::settings.difficulty) {
|
||||
case DIFFICULTY_EASY:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(66)); // EASY
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(66)); // EASY
|
||||
break;
|
||||
|
||||
case DIFFICULTY_NORMAL:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(67)); // NORMAL
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(67)); // NORMAL
|
||||
break;
|
||||
|
||||
case DIFFICULTY_HARD:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(68)); // HARD
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(68)); // HARD
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(59) + ": " + lang->getText(67)); // NORMAL
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(67)); // NORMAL
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// PLAYER 1 CONTROLS
|
||||
menu.options->setItemCaption(i, lang->getText(62));
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(62));
|
||||
|
||||
i++;
|
||||
// PLAYER 1 CONTROLS - OPTIONS
|
||||
switch (Options::inputs[0].deviceType) {
|
||||
case INPUT_USE_KEYBOARD:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
menu.options->setItemCaption(i, Lang::get()->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->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER
|
||||
if (!Input::get()->gameControllerFound())
|
||||
menu.options->setGreyed(i, true);
|
||||
else {
|
||||
menu.options->setGreyed(i, false);
|
||||
@@ -712,25 +708,25 @@ void Title::updateMenuLabels() {
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// PLAYER 2 CONTROLS
|
||||
menu.options->setItemCaption(i, lang->getText(63));
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(63));
|
||||
|
||||
i++;
|
||||
// PLAYER 2 CONTROLS - OPTIONS
|
||||
switch (Options::inputs[1].deviceType) {
|
||||
case INPUT_USE_KEYBOARD:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
menu.options->setItemCaption(i, Lang::get()->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->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER
|
||||
if (!Input::get()->gameControllerFound())
|
||||
menu.options->setGreyed(i, true);
|
||||
else {
|
||||
menu.options->setGreyed(i, false);
|
||||
@@ -739,7 +735,7 @@ void Title::updateMenuLabels() {
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(69)); // KEYBOARD
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -747,59 +743,59 @@ void Title::updateMenuLabels() {
|
||||
// LANGUAGE
|
||||
switch (Options::settings.language) {
|
||||
case es_ES:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(24)); // SPANISH
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(24)); // SPANISH
|
||||
break;
|
||||
|
||||
case ba_BA:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(25)); // VALENCIAN
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(25)); // VALENCIAN
|
||||
break;
|
||||
|
||||
case en_UK:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(26)); // ENGLISH
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(26)); // ENGLISH
|
||||
break;
|
||||
|
||||
default:
|
||||
menu.options->setItemCaption(i, lang->getText(8) + ": " + lang->getText(26)); // ENGLISH
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(26)); // ENGLISH
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
// DISPLAY MODE
|
||||
menu.options->setItemCaption(i, lang->getText(58));
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(58));
|
||||
|
||||
i++;
|
||||
// DISPLAY MODE - OPTIONS
|
||||
menu.options->setItemCaption(i, Options::video.fullscreen ? lang->getText(5) : lang->getText(4));
|
||||
menu.options->setItemCaption(i, Options::video.fullscreen ? Lang::get()->getText(5) : Lang::get()->getText(4));
|
||||
|
||||
i++;
|
||||
// WINDOW SIZE
|
||||
menu.options->setItemCaption(i, lang->getText(7) + " x" + std::to_string(Options::window.zoom)); // WINDOW SIZE
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(7) + " x" + std::to_string(Options::window.zoom)); // WINDOW SIZE
|
||||
|
||||
i++;
|
||||
// SCALE MODE
|
||||
if (Options::video.scale_mode == SDL_SCALEMODE_LINEAR)
|
||||
menu.options->setItemCaption(i, lang->getText(60) + ": " + lang->getText(71)); // BILINEAL
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(60) + ": " + Lang::get()->getText(71)); // BILINEAL
|
||||
else
|
||||
menu.options->setItemCaption(i, lang->getText(60) + ": " + lang->getText(72)); // LINEAL
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(60) + ": " + Lang::get()->getText(72)); // LINEAL
|
||||
|
||||
i++;
|
||||
// VSYNC
|
||||
if (Options::video.vsync)
|
||||
menu.options->setItemCaption(i, lang->getText(61) + ": " + lang->getText(73)); // ON
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(61) + ": " + Lang::get()->getText(73)); // ON
|
||||
else
|
||||
menu.options->setItemCaption(i, lang->getText(61) + ": " + lang->getText(74)); // OFF
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(61) + ": " + Lang::get()->getText(74)); // OFF
|
||||
|
||||
i++;
|
||||
// HOW TO PLAY
|
||||
menu.options->setItemCaption(i, lang->getText(2));
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(2));
|
||||
|
||||
i++;
|
||||
// ACCEPT
|
||||
menu.options->setItemCaption(i, lang->getText(9)); // ACCEPT
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(9)); // ACCEPT
|
||||
|
||||
i++;
|
||||
// CANCEL
|
||||
menu.options->setItemCaption(i, lang->getText(10)); // CANCEL
|
||||
menu.options->setItemCaption(i, Lang::get()->getText(10)); // CANCEL
|
||||
|
||||
// Recoloca el menu de opciones
|
||||
menu.options->centerMenuOnX(GAMECANVAS_CENTER_X);
|
||||
@@ -808,13 +804,13 @@ void Title::updateMenuLabels() {
|
||||
|
||||
// Establece las etiquetas del menu de titulo
|
||||
#ifdef GAME_CONSOLE
|
||||
menu.title->setItemCaption(0, lang->getText(0)); // PLAY
|
||||
menu.title->setItemCaption(0, Lang::get()->getText(0)); // PLAY
|
||||
#else
|
||||
menu.title->setItemCaption(0, lang->getText(51)); // 1 PLAYER
|
||||
menu.title->setItemCaption(0, Lang::get()->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
|
||||
menu.title->setItemCaption(1, Lang::get()->getText(52)); // 2 PLAYERS
|
||||
menu.title->setItemCaption(2, Lang::get()->getText(1)); // OPTIONS
|
||||
menu.title->setItemCaption(3, Lang::get()->getText(3)); // QUIT
|
||||
#ifdef __EMSCRIPTEN__
|
||||
menu.title->setVisible(3, false);
|
||||
menu.title->setSelectable(3, false);
|
||||
@@ -825,8 +821,8 @@ void Title::updateMenuLabels() {
|
||||
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
|
||||
menu.playerSelect->setItemCaption(0, Lang::get()->getText(39)); // SELECT PLAYER
|
||||
menu.playerSelect->setItemCaption(3, Lang::get()->getText(40)); // BACK
|
||||
|
||||
// Recoloca el menu de selección de jugador
|
||||
menu.playerSelect->centerMenuOnX(GAMECANVAS_CENTER_X);
|
||||
@@ -846,11 +842,11 @@ void Title::updateMenuLabels() {
|
||||
|
||||
// Aplica las opciones de menu seleccionadas
|
||||
void Title::applyOptions() {
|
||||
screen->setVideoMode(Options::video.fullscreen);
|
||||
screen->setWindowZoom(Options::window.zoom);
|
||||
screen->setVSync(Options::video.vsync);
|
||||
Screen::get()->setVideoMode(Options::video.fullscreen);
|
||||
Screen::get()->setWindowZoom(Options::window.zoom);
|
||||
Screen::get()->setVSync(Options::video.vsync);
|
||||
|
||||
lang->setLang(Options::settings.language);
|
||||
Lang::get()->setLang(Options::settings.language);
|
||||
|
||||
updateMenuLabels();
|
||||
createTiledBackground();
|
||||
@@ -954,7 +950,7 @@ void Title::run() {
|
||||
|
||||
// Inicia la parte donde se muestran las instrucciones
|
||||
void Title::runInstructions(mode_e mode) {
|
||||
instructions = new Instructions(renderer, screen, asset, input, lang, section);
|
||||
instructions = new Instructions(renderer, section);
|
||||
instructions->start(mode);
|
||||
instructionsActive = true;
|
||||
instructionsMode = mode;
|
||||
@@ -965,7 +961,7 @@ void Title::runDemoGame() {
|
||||
// Temporalmente ponemos section para que el constructor de Game funcione
|
||||
section->name = SECTION_PROG_GAME;
|
||||
section->subsection = SUBSECTION_GAME_PLAY_1P;
|
||||
demoGame = new Game(1, 0, renderer, screen, asset, lang, input, true, section);
|
||||
demoGame = new Game(1, 0, renderer, true, section);
|
||||
demoGameActive = true;
|
||||
// Restauramos section para que Director no transicione fuera de Title
|
||||
section->name = SECTION_PROG_TITLE;
|
||||
@@ -975,7 +971,7 @@ void Title::runDemoGame() {
|
||||
bool Title::updatePlayerInputs(int numPlayer) {
|
||||
const int numDevices = availableInputDevices.size();
|
||||
|
||||
if (!input->gameControllerFound()) { // Si no hay mandos se deja todo de manera prefijada
|
||||
if (!Input::get()->gameControllerFound()) { // Si no hay mandos se deja todo de manera prefijada
|
||||
deviceIndex[0] = 0;
|
||||
deviceIndex[1] = 0;
|
||||
|
||||
@@ -1035,7 +1031,7 @@ void Title::createTiledBackground() {
|
||||
}
|
||||
|
||||
// Crea los objetos para pintar en la textura de fondo
|
||||
Texture *bgTileTexture = new Texture(renderer, asset->get("title_bg_tile.png"));
|
||||
Texture *bgTileTexture = new Texture(renderer, Asset::get()->get("title_bg_tile.png"));
|
||||
Sprite *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, renderer);
|
||||
|
||||
// Prepara para dibujar sobre la textura
|
||||
@@ -1069,7 +1065,7 @@ void Title::checkInputDevices() {
|
||||
if (Options::settings.console) {
|
||||
std::cout << "Filling devices for options menu..." << std::endl;
|
||||
}
|
||||
const int numControllers = input->getNumControllers();
|
||||
const int numControllers = Input::get()->getNumControllers();
|
||||
availableInputDevices.clear();
|
||||
input_t temp;
|
||||
|
||||
@@ -1077,7 +1073,7 @@ void Title::checkInputDevices() {
|
||||
if (numControllers > 0)
|
||||
for (int i = 0; i < numControllers; ++i) {
|
||||
temp.id = i;
|
||||
temp.name = input->getControllerName(i);
|
||||
temp.name = Input::get()->getControllerName(i);
|
||||
temp.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
availableInputDevices.push_back(temp);
|
||||
if (Options::settings.console) {
|
||||
|
||||
@@ -8,13 +8,9 @@
|
||||
#include "game/scenes/instructions.h" // for mode_e
|
||||
#include "utils/utils.h" // for input_t, section_t
|
||||
class AnimatedSprite;
|
||||
class Asset;
|
||||
class Fade;
|
||||
class Game;
|
||||
class Input;
|
||||
class Lang;
|
||||
class Menu;
|
||||
class Screen;
|
||||
class SmartSprite;
|
||||
class Sprite;
|
||||
class Text;
|
||||
@@ -43,10 +39,6 @@ class Title {
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
Input *input; // Objeto para leer las entradas de teclado o mando
|
||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||
Instructions *instructions; // Objeto para la sección de las instrucciones
|
||||
Game *demoGame; // Objeto para lanzar la demo del juego
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
@@ -73,19 +65,19 @@ class Title {
|
||||
Fade *fade; // Objeto para realizar fundidos en pantalla
|
||||
|
||||
// Variable
|
||||
JA_Music_t *titleMusic; // Musica para el titulo
|
||||
JA_Sound_t *crashSound; // Sonido con el impacto del título
|
||||
int backgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
|
||||
int counter; // Temporizador para la pantalla de titulo
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 backgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo
|
||||
float sin[360]; // Vector con los valores del seno precalculados
|
||||
bool menuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
|
||||
bool demo; // Indica si el modo demo estará activo
|
||||
section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
Uint8 postFade; // Opción a realizar cuando termina el fundido
|
||||
menu_t menu; // Variable con todos los objetos menus y sus variables
|
||||
JA_Music_t *titleMusic; // Musica para el titulo
|
||||
JA_Sound_t *crashSound; // Sonido con el impacto del título
|
||||
int backgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo
|
||||
int counter; // Temporizador para la pantalla de titulo
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 backgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo
|
||||
float sin[360]; // Vector con los valores del seno precalculados
|
||||
bool menuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
|
||||
bool demo; // Indica si el modo demo estará activo
|
||||
section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
|
||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
Uint8 postFade; // Opción a realizar cuando termina el fundido
|
||||
menu_t menu; // Variable con todos los objetos menus y sus variables
|
||||
// Snapshot per a permetre CANCEL al menú d'opcions.
|
||||
Options::Video prevVideo;
|
||||
Options::Window prevWindow;
|
||||
@@ -153,7 +145,7 @@ class Title {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, Lang *lang, section_t *section);
|
||||
Title(SDL_Renderer *renderer, section_t *section);
|
||||
|
||||
// Destructor
|
||||
~Title();
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
#include "core/resources/resource_helper.h"
|
||||
|
||||
// Constructor
|
||||
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) {
|
||||
Menu::Menu(SDL_Renderer *renderer, std::string file) {
|
||||
// Copia punteros
|
||||
this->renderer = renderer;
|
||||
this->asset = asset;
|
||||
this->input = input;
|
||||
|
||||
// Inicializa punteros
|
||||
soundMove = nullptr;
|
||||
@@ -74,8 +72,6 @@ Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
|
||||
|
||||
Menu::~Menu() {
|
||||
renderer = nullptr;
|
||||
asset = nullptr;
|
||||
input = nullptr;
|
||||
|
||||
if (soundMove) {
|
||||
JA_DeleteSound(soundMove);
|
||||
@@ -130,8 +126,8 @@ bool Menu::parseFromStream(std::istream &file, const std::string &filename) {
|
||||
// Crea el objeto text tan pronto como se pueda. Necesario para añadir items.
|
||||
// Carga via ResourceHelper para que funcione tanto con pack como con filesystem.
|
||||
if (font_png != "" && font_txt != "" && !textAllocated) {
|
||||
auto pngBytes = ResourceHelper::loadFile(asset->get(font_png));
|
||||
auto txtBytes = ResourceHelper::loadFile(asset->get(font_txt));
|
||||
auto pngBytes = ResourceHelper::loadFile(Asset::get()->get(font_png));
|
||||
auto txtBytes = ResourceHelper::loadFile(Asset::get()->get(font_txt));
|
||||
text = new Text(pngBytes, txtBytes, renderer);
|
||||
textAllocated = true;
|
||||
}
|
||||
@@ -218,17 +214,17 @@ bool Menu::setVars(std::string var, std::string value) {
|
||||
}
|
||||
|
||||
else if (var == "sound_cancel") {
|
||||
auto bytes = ResourceHelper::loadFile(asset->get(value));
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) soundCancel = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
|
||||
else if (var == "sound_accept") {
|
||||
auto bytes = ResourceHelper::loadFile(asset->get(value));
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) soundAccept = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
|
||||
else if (var == "sound_move") {
|
||||
auto bytes = ResourceHelper::loadFile(asset->get(value));
|
||||
auto bytes = ResourceHelper::loadFile(Asset::get()->get(value));
|
||||
if (!bytes.empty()) soundMove = JA_LoadSound(bytes.data(), (uint32_t)bytes.size());
|
||||
}
|
||||
|
||||
@@ -770,7 +766,7 @@ void Menu::setDefaultActionWhenCancel(int item) {
|
||||
|
||||
// Gestiona la entrada de teclado y mando durante el menu
|
||||
void Menu::checkInput() {
|
||||
if (input->checkInput(input_up, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_up, REPEAT_FALSE)) {
|
||||
if (decreaseSelectorIndex()) {
|
||||
if (soundMove) {
|
||||
JA_PlaySound(soundMove);
|
||||
@@ -778,7 +774,7 @@ void Menu::checkInput() {
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_down, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_down, REPEAT_FALSE)) {
|
||||
if (increaseSelectorIndex()) {
|
||||
if (soundMove) {
|
||||
JA_PlaySound(soundMove);
|
||||
@@ -786,14 +782,14 @@ void Menu::checkInput() {
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_accept, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_accept, REPEAT_FALSE)) {
|
||||
itemSelected = selector.index;
|
||||
if (soundAccept) {
|
||||
JA_PlaySound(soundAccept);
|
||||
}
|
||||
}
|
||||
|
||||
if (input->checkInput(input_cancel, REPEAT_FALSE)) {
|
||||
if (Input::get()->checkInput(input_cancel, REPEAT_FALSE)) {
|
||||
itemSelected = defaultActionWhenCancel;
|
||||
if (soundCancel) {
|
||||
JA_PlaySound(soundCancel);
|
||||
@@ -875,7 +871,7 @@ void Menu::setBackgroundType(int value) {
|
||||
// Establece la fuente de texto que se utilizará
|
||||
void Menu::setText(std::string font_png, std::string font_txt) {
|
||||
if (!text) {
|
||||
text = new Text(asset->get(font_png), asset->get(font_txt), renderer);
|
||||
text = new Text(Asset::get()->get(font_png), Asset::get()->get(font_txt), renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "utils/utils.h" // for color_t
|
||||
class Asset;
|
||||
class Input;
|
||||
class Text;
|
||||
struct JA_Sound_t;
|
||||
|
||||
@@ -70,9 +68,7 @@ class Menu {
|
||||
|
||||
// Objetos y punteros
|
||||
SDL_Renderer *renderer; // Puntero al renderizador de la ventana
|
||||
Asset *asset; // Objeto para gestionar los ficheros de recursos
|
||||
Text *text; // Texto para poder escribir los items del menu
|
||||
Input *input; // Gestor de eventos de entrada de teclado o gamepad
|
||||
|
||||
// Variables
|
||||
std::string name; // Nombre del menu
|
||||
@@ -146,7 +142,7 @@ class Menu {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file = "");
|
||||
Menu(SDL_Renderer *renderer, std::string file = "");
|
||||
|
||||
// Destructor
|
||||
~Menu();
|
||||
|
||||
Reference in New Issue
Block a user