singletons
This commit is contained in:
@@ -5,35 +5,35 @@
|
||||
|
||||
namespace GlobalInputs {
|
||||
|
||||
auto handle(Screen *screen, Input *input) -> bool {
|
||||
if (screen == nullptr || input == nullptr) { return false; }
|
||||
auto handle() -> bool {
|
||||
if (Screen::get() == nullptr || Input::get() == nullptr) { return false; }
|
||||
|
||||
if (input->checkInput(input_window_fullscreen, REPEAT_FALSE)) {
|
||||
screen->toggleVideoMode();
|
||||
if (Input::get()->checkInput(input_window_fullscreen, REPEAT_FALSE)) {
|
||||
Screen::get()->toggleVideoMode();
|
||||
return true;
|
||||
}
|
||||
if (input->checkInput(input_window_dec_size, REPEAT_FALSE)) {
|
||||
screen->decWindowZoom();
|
||||
if (Input::get()->checkInput(input_window_dec_size, REPEAT_FALSE)) {
|
||||
Screen::get()->decWindowZoom();
|
||||
return true;
|
||||
}
|
||||
if (input->checkInput(input_window_inc_size, REPEAT_FALSE)) {
|
||||
screen->incWindowZoom();
|
||||
if (Input::get()->checkInput(input_window_inc_size, REPEAT_FALSE)) {
|
||||
Screen::get()->incWindowZoom();
|
||||
return true;
|
||||
}
|
||||
if (input->checkInput(input_prev_preset, REPEAT_FALSE)) {
|
||||
screen->prevPreset();
|
||||
if (Input::get()->checkInput(input_prev_preset, REPEAT_FALSE)) {
|
||||
Screen::get()->prevPreset();
|
||||
return true;
|
||||
}
|
||||
if (input->checkInput(input_next_preset, REPEAT_FALSE)) {
|
||||
screen->nextPreset();
|
||||
if (Input::get()->checkInput(input_next_preset, REPEAT_FALSE)) {
|
||||
Screen::get()->nextPreset();
|
||||
return true;
|
||||
}
|
||||
if (input->checkInput(input_toggle_shader, REPEAT_FALSE)) {
|
||||
screen->toggleShaderEnabled();
|
||||
if (Input::get()->checkInput(input_toggle_shader, REPEAT_FALSE)) {
|
||||
Screen::get()->toggleShaderEnabled();
|
||||
return true;
|
||||
}
|
||||
if (input->checkInput(input_toggle_shader_type, REPEAT_FALSE)) {
|
||||
screen->toggleActiveShader();
|
||||
if (Input::get()->checkInput(input_toggle_shader_type, REPEAT_FALSE)) {
|
||||
Screen::get()->toggleActiveShader();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
class Input;
|
||||
class Screen;
|
||||
|
||||
namespace GlobalInputs {
|
||||
// Gestiona els atalls globals disponibles en qualsevol escena: zoom de
|
||||
// finestra (F1/F2), fullscreen (F3), presets de shader (F8/F9), toggle
|
||||
// shader (F10) i tipus de shader POSTFX↔CRTPI (F11). Retorna true si ha
|
||||
// consumit alguna tecla (per si la capa cridant vol suprimir-la del
|
||||
// processament específic de l'escena).
|
||||
auto handle(Screen *screen, Input *input) -> bool;
|
||||
auto handle() -> bool;
|
||||
} // namespace GlobalInputs
|
||||
|
||||
@@ -39,6 +39,23 @@ static void installWebStandardMapping(SDL_JoystickID jid) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Instancia única
|
||||
Input *Input::instance = nullptr;
|
||||
|
||||
// Singleton API
|
||||
void Input::init(const std::string &gameControllerDbPath) {
|
||||
Input::instance = new Input(gameControllerDbPath);
|
||||
}
|
||||
|
||||
void Input::destroy() {
|
||||
delete Input::instance;
|
||||
Input::instance = nullptr;
|
||||
}
|
||||
|
||||
auto Input::get() -> Input * {
|
||||
return Input::instance;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Input::Input(std::string file) {
|
||||
// Fichero gamecontrollerdb.txt
|
||||
|
||||
@@ -79,10 +79,18 @@ class Input {
|
||||
// Construye el nombre visible de un mando (name truncado + sufijo #N)
|
||||
std::string buildControllerName(SDL_Gamepad *pad, int padIndex);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
// Constructor privado (usar Input::init)
|
||||
Input(std::string file);
|
||||
|
||||
// Instancia única
|
||||
static Input *instance;
|
||||
|
||||
public:
|
||||
// Singleton API
|
||||
static void init(const std::string &gameControllerDbPath); // Crea la instancia
|
||||
static void destroy(); // Libera la instancia
|
||||
static auto get() -> Input *; // Obtiene el puntero a la instancia
|
||||
|
||||
// Destructor
|
||||
~Input();
|
||||
|
||||
|
||||
@@ -6,9 +6,25 @@
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
#include "core/resources/resource_helper.h"
|
||||
|
||||
// Instancia única
|
||||
Lang *Lang::instance = nullptr;
|
||||
|
||||
// Singleton API
|
||||
void Lang::init() {
|
||||
Lang::instance = new Lang();
|
||||
}
|
||||
|
||||
void Lang::destroy() {
|
||||
delete Lang::instance;
|
||||
Lang::instance = nullptr;
|
||||
}
|
||||
|
||||
auto Lang::get() -> Lang * {
|
||||
return Lang::instance;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Lang::Lang(Asset *mAsset) {
|
||||
this->mAsset = mAsset;
|
||||
Lang::Lang() {
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -21,19 +37,19 @@ bool Lang::setLang(Uint8 lang) {
|
||||
|
||||
switch (lang) {
|
||||
case es_ES:
|
||||
file = mAsset->get("es_ES.txt");
|
||||
file = Asset::get()->get("es_ES.txt");
|
||||
break;
|
||||
|
||||
case en_UK:
|
||||
file = mAsset->get("en_UK.txt");
|
||||
file = Asset::get()->get("en_UK.txt");
|
||||
break;
|
||||
|
||||
case ba_BA:
|
||||
file = mAsset->get("ba_BA.txt");
|
||||
file = Asset::get()->get("ba_BA.txt");
|
||||
break;
|
||||
|
||||
default:
|
||||
file = mAsset->get("en_UK.txt");
|
||||
file = Asset::get()->get("en_UK.txt");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <string> // for string, basic_string
|
||||
class Asset;
|
||||
|
||||
// Códigos de idioma
|
||||
constexpr int es_ES = 0;
|
||||
@@ -17,12 +16,19 @@ constexpr int MAX_TEXT_STRINGS = 100;
|
||||
// Clase Lang
|
||||
class Lang {
|
||||
private:
|
||||
Asset *mAsset; // Objeto que gestiona todos los ficheros de recursos
|
||||
std::string mTextStrings[MAX_TEXT_STRINGS]; // Vector con los textos
|
||||
|
||||
// Constructor privado (usar Lang::init)
|
||||
Lang();
|
||||
|
||||
// Instancia única
|
||||
static Lang *instance;
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Lang(Asset *mAsset);
|
||||
// Singleton API
|
||||
static void init(); // Crea la instancia
|
||||
static void destroy(); // Libera la instancia
|
||||
static auto get() -> Lang *; // Obtiene el puntero a la instancia
|
||||
|
||||
// Destructor
|
||||
~Lang();
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include <string> // for basic_string, char_traits, string
|
||||
|
||||
#include "core/input/mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime
|
||||
#include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_STROKE
|
||||
#include "core/resources/asset.h" // for Asset
|
||||
#include "core/input/mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime
|
||||
#include "core/rendering/text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_STROKE
|
||||
#include "core/resources/resource.h"
|
||||
#include "game/defaults.hpp" // for GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT
|
||||
#include "game/options.hpp" // for Options::video, Options::settings
|
||||
@@ -60,12 +59,28 @@ namespace {
|
||||
} // namespace
|
||||
#endif // __EMSCRIPTEN__
|
||||
|
||||
// Instancia única
|
||||
Screen *Screen::instance = nullptr;
|
||||
|
||||
// Singleton API
|
||||
void Screen::init(SDL_Window *window, SDL_Renderer *renderer) {
|
||||
Screen::instance = new Screen(window, renderer);
|
||||
}
|
||||
|
||||
void Screen::destroy() {
|
||||
delete Screen::instance;
|
||||
Screen::instance = nullptr;
|
||||
}
|
||||
|
||||
auto Screen::get() -> Screen * {
|
||||
return Screen::instance;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset) {
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) {
|
||||
// Inicializa variables
|
||||
this->window = window;
|
||||
this->renderer = renderer;
|
||||
this->asset = asset;
|
||||
|
||||
gameCanvasWidth = GAMECANVAS_WIDTH;
|
||||
gameCanvasHeight = GAMECANVAS_HEIGHT;
|
||||
@@ -586,8 +601,7 @@ void Screen::applyCurrentPostFXPreset() {
|
||||
#ifndef NO_SHADERS
|
||||
if (!shader_backend_ || !shader_backend_->isHardwareAccelerated()) { return; }
|
||||
if (Options::postfx_presets.empty()) { return; }
|
||||
if (Options::current_postfx_preset < 0
|
||||
|| Options::current_postfx_preset >= static_cast<int>(Options::postfx_presets.size())) {
|
||||
if (Options::current_postfx_preset < 0 || Options::current_postfx_preset >= static_cast<int>(Options::postfx_presets.size())) {
|
||||
Options::current_postfx_preset = 0;
|
||||
}
|
||||
const auto &PRESET = Options::postfx_presets[Options::current_postfx_preset];
|
||||
@@ -608,8 +622,7 @@ void Screen::applyCurrentCrtPiPreset() {
|
||||
#ifndef NO_SHADERS
|
||||
if (!shader_backend_ || !shader_backend_->isHardwareAccelerated()) { return; }
|
||||
if (Options::crtpi_presets.empty()) { return; }
|
||||
if (Options::current_crtpi_preset < 0
|
||||
|| Options::current_crtpi_preset >= static_cast<int>(Options::crtpi_presets.size())) {
|
||||
if (Options::current_crtpi_preset < 0 || Options::current_crtpi_preset >= static_cast<int>(Options::crtpi_presets.size())) {
|
||||
Options::current_crtpi_preset = 0;
|
||||
}
|
||||
const auto &PRESET = Options::crtpi_presets[Options::current_crtpi_preset];
|
||||
@@ -632,17 +645,15 @@ void Screen::applyCurrentCrtPiPreset() {
|
||||
#endif
|
||||
}
|
||||
|
||||
auto Screen::getCurrentPresetName() const -> const char* {
|
||||
auto Screen::getCurrentPresetName() const -> const char * {
|
||||
#ifndef NO_SHADERS
|
||||
if (!shader_backend_ || !shader_backend_->isHardwareAccelerated()) { return "---"; }
|
||||
if (Options::video.shader.current_shader == Rendering::ShaderType::POSTFX) {
|
||||
if (Options::current_postfx_preset >= 0
|
||||
&& Options::current_postfx_preset < static_cast<int>(Options::postfx_presets.size())) {
|
||||
if (Options::current_postfx_preset >= 0 && Options::current_postfx_preset < static_cast<int>(Options::postfx_presets.size())) {
|
||||
return Options::postfx_presets[Options::current_postfx_preset].name.c_str();
|
||||
}
|
||||
} else {
|
||||
if (Options::current_crtpi_preset >= 0
|
||||
&& Options::current_crtpi_preset < static_cast<int>(Options::crtpi_presets.size())) {
|
||||
if (Options::current_crtpi_preset >= 0 && Options::current_crtpi_preset < static_cast<int>(Options::crtpi_presets.size())) {
|
||||
return Options::crtpi_presets[Options::current_crtpi_preset].name.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Rendering {
|
||||
}
|
||||
#endif
|
||||
|
||||
class Asset;
|
||||
class Text;
|
||||
|
||||
class Screen {
|
||||
@@ -30,8 +29,12 @@ class Screen {
|
||||
static constexpr int WASM_RENDER_SCALE = 3;
|
||||
#endif
|
||||
|
||||
// Constructor y destructor
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset);
|
||||
// Singleton API
|
||||
static void init(SDL_Window *window, SDL_Renderer *renderer); // Crea la instancia
|
||||
static void destroy(); // Libera la instancia
|
||||
static auto get() -> Screen *; // Obtiene el puntero a la instancia
|
||||
|
||||
// Destructor (público por requisitos de `delete` desde destroy())
|
||||
~Screen();
|
||||
|
||||
// Render loop
|
||||
@@ -77,11 +80,17 @@ class Screen {
|
||||
// Retornen false si GPU off / shaders off / llista buida (igual que a aee_plus).
|
||||
auto nextPreset() -> bool;
|
||||
auto prevPreset() -> bool;
|
||||
auto getCurrentPresetName() const -> const char*;
|
||||
auto getCurrentPresetName() const -> const char *;
|
||||
void applyCurrentPostFXPreset(); // Escriu el preset PostFX actiu al backend
|
||||
void applyCurrentCrtPiPreset(); // Escriu el preset CrtPi actiu al backend
|
||||
|
||||
private:
|
||||
// Constructor privado (usar Screen::init)
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
||||
|
||||
// Instancia única
|
||||
static Screen *instance;
|
||||
|
||||
// Helpers internos de setVideoMode
|
||||
void applyFullscreen(bool fullscreen); // SDL_SetWindowFullscreen + visibilidad del cursor
|
||||
void applyWindowedLayout(); // Calcula windowWidth/Height/dest + SDL_SetWindowSize + SDL_SetWindowPosition
|
||||
@@ -104,7 +113,6 @@ class Screen {
|
||||
// Objetos y punteros
|
||||
SDL_Window *window; // Ventana de la aplicación
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Asset *asset; // Objeto con el listado de recursos
|
||||
SDL_Texture *gameCanvas; // Textura para completar la ventana de juego hasta la pantalla completa
|
||||
|
||||
// Variables
|
||||
|
||||
@@ -7,6 +7,23 @@
|
||||
|
||||
#include "core/resources/resource_helper.h"
|
||||
|
||||
// Instancia única
|
||||
Asset *Asset::instance = nullptr;
|
||||
|
||||
// Singleton API
|
||||
void Asset::init(const std::string &executablePath) {
|
||||
Asset::instance = new Asset(executablePath);
|
||||
}
|
||||
|
||||
void Asset::destroy() {
|
||||
delete Asset::instance;
|
||||
Asset::instance = nullptr;
|
||||
}
|
||||
|
||||
auto Asset::get() -> Asset * {
|
||||
return Asset::instance;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
Asset::Asset(std::string executablePath) {
|
||||
this->executablePath = executablePath.substr(0, executablePath.find_last_of("\\/"));
|
||||
|
||||
@@ -39,10 +39,18 @@ class Asset {
|
||||
// Devuelve el nombre del tipo de recurso
|
||||
std::string getTypeName(int type);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
// Constructor privado (usar Asset::init)
|
||||
Asset(std::string path);
|
||||
|
||||
// Instancia única
|
||||
static Asset *instance;
|
||||
|
||||
public:
|
||||
// Singleton API
|
||||
static void init(const std::string &executablePath); // Crea la instancia
|
||||
static void destroy(); // Libera la instancia
|
||||
static auto get() -> Asset *; // Obtiene el puntero a la instancia
|
||||
|
||||
// Añade un elemento a la lista
|
||||
void add(std::string file, enum assetType type, bool required = true, bool absolute = false);
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include "core/resources/resource_helper.h"
|
||||
#include "game/ui/menu.h"
|
||||
|
||||
// Nota: Asset::get() e Input::get() se consultan en preloadAll y al construir
|
||||
// los menús; no se guardan punteros en el objeto Resource.
|
||||
|
||||
Resource *Resource::instance_ = nullptr;
|
||||
|
||||
static std::string basename(const std::string &path) {
|
||||
@@ -25,9 +28,9 @@ static std::string stem(const std::string &path) {
|
||||
return b.substr(0, dot);
|
||||
}
|
||||
|
||||
void Resource::init(SDL_Renderer *renderer, Asset *asset, Input *input) {
|
||||
void Resource::init(SDL_Renderer *renderer) {
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = new Resource(renderer, asset, input);
|
||||
instance_ = new Resource(renderer);
|
||||
instance_->preloadAll();
|
||||
}
|
||||
}
|
||||
@@ -41,10 +44,8 @@ Resource *Resource::get() {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
Resource::Resource(SDL_Renderer *renderer, Asset *asset, Input *input)
|
||||
: renderer_(renderer),
|
||||
asset_(asset),
|
||||
input_(input) {}
|
||||
Resource::Resource(SDL_Renderer *renderer)
|
||||
: renderer_(renderer) {}
|
||||
|
||||
Resource::~Resource() {
|
||||
for (auto &[name, m] : menus_) delete m;
|
||||
@@ -64,7 +65,7 @@ Resource::~Resource() {
|
||||
}
|
||||
|
||||
void Resource::preloadAll() {
|
||||
const auto &items = asset_->getAll();
|
||||
const auto &items = Asset::get()->getAll();
|
||||
|
||||
// Pass 1: texturas, sonidos, músicas, animaciones (raw lines), demo, lenguajes
|
||||
for (const auto &it : items) {
|
||||
@@ -155,7 +156,7 @@ void Resource::preloadAll() {
|
||||
if (bname.size() < 4 || bname.substr(bname.size() - 4) != ".men") continue;
|
||||
auto bytes = ResourceHelper::loadFile(it.file);
|
||||
if (bytes.empty()) continue;
|
||||
Menu *m = new Menu(renderer_, asset_, input_, "");
|
||||
Menu *m = new Menu(renderer_, "");
|
||||
m->loadFromBytes(bytes, bname);
|
||||
const std::string s = stem(it.file);
|
||||
menus_[s] = m;
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class Asset;
|
||||
class Input;
|
||||
class Menu;
|
||||
class Text;
|
||||
class Texture;
|
||||
@@ -19,7 +17,7 @@ struct JA_Sound_t;
|
||||
// Singleton inicializado desde Director; las escenas consultan handles via get*().
|
||||
class Resource {
|
||||
public:
|
||||
static void init(SDL_Renderer *renderer, Asset *asset, Input *input);
|
||||
static void init(SDL_Renderer *renderer);
|
||||
static void destroy();
|
||||
static Resource *get();
|
||||
|
||||
@@ -32,14 +30,12 @@ class Resource {
|
||||
const std::vector<uint8_t> &getDemoBytes() const { return demoBytes_; }
|
||||
|
||||
private:
|
||||
Resource(SDL_Renderer *renderer, Asset *asset, Input *input);
|
||||
Resource(SDL_Renderer *renderer);
|
||||
~Resource();
|
||||
|
||||
void preloadAll();
|
||||
|
||||
SDL_Renderer *renderer_;
|
||||
Asset *asset_;
|
||||
Input *input_;
|
||||
|
||||
std::unordered_map<std::string, Texture *> textures_;
|
||||
std::unordered_map<std::string, JA_Sound_t *> sounds_;
|
||||
|
||||
@@ -88,8 +88,8 @@ Director::Director(int argc, const char *argv[]) {
|
||||
}
|
||||
|
||||
// Crea el objeto que controla los ficheros de recursos
|
||||
asset = new Asset(executablePath);
|
||||
asset->setVerbose(Options::settings.console);
|
||||
Asset::init(executablePath);
|
||||
Asset::get()->setVerbose(Options::settings.console);
|
||||
|
||||
// Si falta algún fichero no inicia el programa
|
||||
if (!setFileList()) {
|
||||
@@ -106,18 +106,18 @@ Director::Director(int argc, const char *argv[]) {
|
||||
Texture::setGlobalScaleMode(Options::video.scale_mode);
|
||||
|
||||
// Crea los objetos
|
||||
lang = new Lang(asset);
|
||||
lang->setLang(Options::settings.language);
|
||||
Lang::init();
|
||||
Lang::get()->setLang(Options::settings.language);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
input = new Input("/gamecontrollerdb.txt");
|
||||
Input::init("/gamecontrollerdb.txt");
|
||||
#else
|
||||
{
|
||||
const std::string binDir = std::filesystem::path(executablePath).parent_path().string();
|
||||
#ifdef MACOS_BUNDLE
|
||||
input = new Input(binDir + "/../Resources/gamecontrollerdb.txt");
|
||||
Input::init(binDir + "/../Resources/gamecontrollerdb.txt");
|
||||
#else
|
||||
input = new Input(binDir + "/gamecontrollerdb.txt");
|
||||
Input::init(binDir + "/gamecontrollerdb.txt");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -130,22 +130,22 @@ Director::Director(int argc, const char *argv[]) {
|
||||
// intenta reclamar la ventana para el dispositivo SDL3 GPU.
|
||||
//
|
||||
// Por eso el constructor de Screen NO carga notificationText desde
|
||||
// Resource; se enlaza después vía `screen->initNotifications()`.
|
||||
screen = new Screen(window, renderer, asset);
|
||||
// Resource; se enlaza después vía `Screen::get()->initNotifications()`.
|
||||
Screen::init(window, renderer);
|
||||
|
||||
#ifndef NO_SHADERS
|
||||
if (Options::video.gpu.acceleration) {
|
||||
screen->initShaders();
|
||||
Screen::get()->initShaders();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Ahora sí, precarga todos los recursos en memoria (texturas, sonidos,
|
||||
// música, ...). Vivirán durante toda la vida de la app.
|
||||
Resource::init(renderer, asset, input);
|
||||
Resource::init(renderer);
|
||||
|
||||
// Completa el enlazado de Screen con recursos que necesitan Resource
|
||||
// inicializado (actualmente sólo el Text de las notificaciones).
|
||||
screen->initNotifications();
|
||||
Screen::get()->initNotifications();
|
||||
|
||||
activeSection = ActiveSection::None;
|
||||
}
|
||||
@@ -163,14 +163,14 @@ Director::~Director() {
|
||||
|
||||
// Screen puede tener referencias a Text propiedad de Resource: destruir
|
||||
// Screen antes que Resource.
|
||||
delete screen;
|
||||
Screen::destroy();
|
||||
|
||||
// Libera todos los recursos precargados antes de cerrar SDL.
|
||||
Resource::destroy();
|
||||
|
||||
delete asset;
|
||||
delete input;
|
||||
delete lang;
|
||||
Asset::destroy();
|
||||
Input::destroy();
|
||||
Lang::destroy();
|
||||
delete section;
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
@@ -186,51 +186,51 @@ Director::~Director() {
|
||||
// Inicializa el objeto input
|
||||
void Director::initInput() {
|
||||
// Establece si ha de mostrar mensajes
|
||||
input->setVerbose(Options::settings.console);
|
||||
Input::get()->setVerbose(Options::settings.console);
|
||||
|
||||
// Busca si hay un mando conectado
|
||||
input->discoverGameController();
|
||||
Input::get()->discoverGameController();
|
||||
|
||||
// Teclado - Movimiento del jugador
|
||||
input->bindKey(input_up, SDL_SCANCODE_UP);
|
||||
input->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||||
input->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||
input->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||||
input->bindKey(input_fire_left, SDL_SCANCODE_Q);
|
||||
input->bindKey(input_fire_center, SDL_SCANCODE_W);
|
||||
input->bindKey(input_fire_right, SDL_SCANCODE_E);
|
||||
Input::get()->bindKey(input_up, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(input_down, SDL_SCANCODE_DOWN);
|
||||
Input::get()->bindKey(input_left, SDL_SCANCODE_LEFT);
|
||||
Input::get()->bindKey(input_right, SDL_SCANCODE_RIGHT);
|
||||
Input::get()->bindKey(input_fire_left, SDL_SCANCODE_Q);
|
||||
Input::get()->bindKey(input_fire_center, SDL_SCANCODE_W);
|
||||
Input::get()->bindKey(input_fire_right, SDL_SCANCODE_E);
|
||||
|
||||
// Teclado - Otros
|
||||
input->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
||||
input->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
||||
input->bindKey(input_pause, SDL_SCANCODE_ESCAPE);
|
||||
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||||
input->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
||||
input->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
||||
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
|
||||
input->bindKey(input_prev_preset, SDL_SCANCODE_F8);
|
||||
input->bindKey(input_next_preset, SDL_SCANCODE_F9);
|
||||
input->bindKey(input_toggle_shader, SDL_SCANCODE_F10);
|
||||
input->bindKey(input_toggle_shader_type, SDL_SCANCODE_F11);
|
||||
Input::get()->bindKey(input_accept, SDL_SCANCODE_RETURN);
|
||||
Input::get()->bindKey(input_cancel, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(input_pause, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
|
||||
Input::get()->bindKey(input_window_dec_size, SDL_SCANCODE_F1);
|
||||
Input::get()->bindKey(input_window_inc_size, SDL_SCANCODE_F2);
|
||||
Input::get()->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
|
||||
Input::get()->bindKey(input_prev_preset, SDL_SCANCODE_F8);
|
||||
Input::get()->bindKey(input_next_preset, SDL_SCANCODE_F9);
|
||||
Input::get()->bindKey(input_toggle_shader, SDL_SCANCODE_F10);
|
||||
Input::get()->bindKey(input_toggle_shader_type, SDL_SCANCODE_F11);
|
||||
|
||||
// Mando - Movimiento del jugador
|
||||
input->bindGameControllerButton(input_up, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||
input->bindGameControllerButton(input_down, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||
input->bindGameControllerButton(input_left, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||
input->bindGameControllerButton(input_right, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||
input->bindGameControllerButton(input_fire_left, SDL_GAMEPAD_BUTTON_WEST);
|
||||
input->bindGameControllerButton(input_fire_center, SDL_GAMEPAD_BUTTON_NORTH);
|
||||
input->bindGameControllerButton(input_fire_right, SDL_GAMEPAD_BUTTON_EAST);
|
||||
Input::get()->bindGameControllerButton(input_up, SDL_GAMEPAD_BUTTON_DPAD_UP);
|
||||
Input::get()->bindGameControllerButton(input_down, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
|
||||
Input::get()->bindGameControllerButton(input_left, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
||||
Input::get()->bindGameControllerButton(input_right, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
||||
Input::get()->bindGameControllerButton(input_fire_left, SDL_GAMEPAD_BUTTON_WEST);
|
||||
Input::get()->bindGameControllerButton(input_fire_center, SDL_GAMEPAD_BUTTON_NORTH);
|
||||
Input::get()->bindGameControllerButton(input_fire_right, SDL_GAMEPAD_BUTTON_EAST);
|
||||
|
||||
// Mando - Otros
|
||||
// SOUTH queda sin asignar para evitar salidas accidentales: pausa/cancel se hace con START/BACK.
|
||||
input->bindGameControllerButton(input_accept, SDL_GAMEPAD_BUTTON_EAST);
|
||||
Input::get()->bindGameControllerButton(input_accept, SDL_GAMEPAD_BUTTON_EAST);
|
||||
#ifdef GAME_CONSOLE
|
||||
input->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_BACK);
|
||||
input->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_START);
|
||||
Input::get()->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_BACK);
|
||||
Input::get()->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_START);
|
||||
#else
|
||||
input->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_START);
|
||||
input->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_BACK);
|
||||
Input::get()->bindGameControllerButton(input_pause, SDL_GAMEPAD_BUTTON_START);
|
||||
Input::get()->bindGameControllerButton(input_exit, SDL_GAMEPAD_BUTTON_BACK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -313,123 +313,123 @@ bool Director::setFileList() {
|
||||
#endif
|
||||
|
||||
// Ficheros de configuración
|
||||
asset->add(systemFolder + "/score.bin", t_data, false, true);
|
||||
asset->add(prefix + "/data/demo/demo.bin", t_data);
|
||||
Asset::get()->add(systemFolder + "/score.bin", t_data, false, true);
|
||||
Asset::get()->add(prefix + "/data/demo/demo.bin", t_data);
|
||||
|
||||
// Musicas
|
||||
asset->add(prefix + "/data/music/intro.ogg", t_music);
|
||||
asset->add(prefix + "/data/music/playing.ogg", t_music);
|
||||
asset->add(prefix + "/data/music/title.ogg", t_music);
|
||||
Asset::get()->add(prefix + "/data/music/intro.ogg", t_music);
|
||||
Asset::get()->add(prefix + "/data/music/playing.ogg", t_music);
|
||||
Asset::get()->add(prefix + "/data/music/title.ogg", t_music);
|
||||
|
||||
// Sonidos
|
||||
asset->add(prefix + "/data/sound/balloon.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/bubble1.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/bubble2.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/bubble3.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/bubble4.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/bullet.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/coffeeout.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/hiscore.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/itemdrop.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/itempickup.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/menu_move.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/menu_select.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/player_collision.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/stage_change.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/title.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/clock.wav", t_sound);
|
||||
asset->add(prefix + "/data/sound/powerball.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/balloon.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/bubble1.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/bubble2.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/bubble3.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/bubble4.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/bullet.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/coffeeout.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/hiscore.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/itemdrop.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/itempickup.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/menu_move.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/menu_select.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/player_collision.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/stage_change.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/title.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/clock.wav", t_sound);
|
||||
Asset::get()->add(prefix + "/data/sound/powerball.wav", t_sound);
|
||||
|
||||
// Texturas
|
||||
asset->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/balloon1.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/balloon2.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/balloon2.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/balloon3.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/balloon3.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/balloon4.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/balloon4.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/bullet.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon1.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon2.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon2.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon3.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon3.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon4.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/balloon4.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/bullet.png", t_bitmap);
|
||||
|
||||
asset->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/game_clouds.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/game_grass.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/game_power_meter.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/game_sky_colors.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/game_text.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_buildings.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_clouds.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_grass.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_power_meter.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_sky_colors.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/game_text.png", t_bitmap);
|
||||
|
||||
asset->add(prefix + "/data/gfx/intro.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/logo.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/intro.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/logo.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
|
||||
|
||||
asset->add(prefix + "/data/gfx/item_points1_disk.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/item_points1_disk.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/item_points2_gavina.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/item_points2_gavina.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/item_points3_pacmar.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/item_points3_pacmar.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/item_clock.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/item_clock.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/item_coffee.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/item_coffee.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/item_coffee_machine.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/item_coffee_machine.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_points1_disk.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_points1_disk.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_points2_gavina.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_points2_gavina.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_points3_pacmar.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_points3_pacmar.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_clock.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_clock.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_coffee.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_coffee.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_coffee_machine.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/item_coffee_machine.ani", t_data);
|
||||
|
||||
asset->add(prefix + "/data/gfx/title_bg_tile.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/title_coffee.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/title_crisis.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/title_dust.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/title_dust.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/title_gradient.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/title_bg_tile.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/title_coffee.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/title_crisis.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/title_dust.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/title_dust.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/title_gradient.png", t_bitmap);
|
||||
|
||||
asset->add(prefix + "/data/gfx/player_head.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/player_body.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/player_legs.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/player_death.ani", t_data);
|
||||
asset->add(prefix + "/data/gfx/player_fire.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_head.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_body.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_legs.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_death.ani", t_data);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_fire.ani", t_data);
|
||||
|
||||
asset->add(prefix + "/data/gfx/player_bal1_head.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_bal1_body.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_bal1_legs.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_bal1_death.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_bal1_fire.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_bal1_head.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_bal1_body.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_bal1_legs.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_bal1_death.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_bal1_fire.png", t_bitmap);
|
||||
|
||||
asset->add(prefix + "/data/gfx/player_arounder_head.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_arounder_body.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_arounder_legs.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_arounder_death.png", t_bitmap);
|
||||
asset->add(prefix + "/data/gfx/player_arounder_fire.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_arounder_head.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_arounder_body.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_arounder_legs.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_arounder_death.png", t_bitmap);
|
||||
Asset::get()->add(prefix + "/data/gfx/player_arounder_fire.png", t_bitmap);
|
||||
|
||||
// Fuentes
|
||||
asset->add(prefix + "/data/font/8bithud.png", t_font);
|
||||
asset->add(prefix + "/data/font/8bithud.txt", t_font);
|
||||
asset->add(prefix + "/data/font/nokia.png", t_font);
|
||||
asset->add(prefix + "/data/font/nokia_big2.png", t_font);
|
||||
asset->add(prefix + "/data/font/nokia.txt", t_font);
|
||||
asset->add(prefix + "/data/font/nokia2.png", t_font);
|
||||
asset->add(prefix + "/data/font/nokia2.txt", t_font);
|
||||
asset->add(prefix + "/data/font/nokia_big2.txt", t_font);
|
||||
asset->add(prefix + "/data/font/smb2_big.png", t_font);
|
||||
asset->add(prefix + "/data/font/smb2_big.txt", t_font);
|
||||
asset->add(prefix + "/data/font/smb2.png", t_font);
|
||||
asset->add(prefix + "/data/font/smb2.txt", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.png", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.txt", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.png", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.png", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.txt", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.png", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.txt", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.txt", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.png", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.txt", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.png", t_font);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.txt", t_font);
|
||||
|
||||
// Textos
|
||||
asset->add(prefix + "/data/lang/es_ES.txt", t_lang);
|
||||
asset->add(prefix + "/data/lang/en_UK.txt", t_lang);
|
||||
asset->add(prefix + "/data/lang/ba_BA.txt", t_lang);
|
||||
Asset::get()->add(prefix + "/data/lang/es_ES.txt", t_lang);
|
||||
Asset::get()->add(prefix + "/data/lang/en_UK.txt", t_lang);
|
||||
Asset::get()->add(prefix + "/data/lang/ba_BA.txt", t_lang);
|
||||
|
||||
// Menus
|
||||
asset->add(prefix + "/data/menu/title.men", t_data);
|
||||
asset->add(prefix + "/data/menu/title_gc.men", t_data);
|
||||
asset->add(prefix + "/data/menu/options.men", t_data);
|
||||
asset->add(prefix + "/data/menu/options_gc.men", t_data);
|
||||
asset->add(prefix + "/data/menu/pause.men", t_data);
|
||||
asset->add(prefix + "/data/menu/gameover.men", t_data);
|
||||
asset->add(prefix + "/data/menu/player_select.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/title.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/title_gc.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/options.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/options_gc.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/pause.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/gameover.men", t_data);
|
||||
Asset::get()->add(prefix + "/data/menu/player_select.men", t_data);
|
||||
|
||||
return asset->check();
|
||||
return Asset::get()->check();
|
||||
}
|
||||
|
||||
// Comprueba los parametros del programa
|
||||
@@ -540,17 +540,17 @@ void Director::handleSectionTransition() {
|
||||
activeSection = targetSection;
|
||||
switch (activeSection) {
|
||||
case ActiveSection::Logo:
|
||||
logo = std::make_unique<Logo>(renderer, screen, asset, input, section);
|
||||
logo = std::make_unique<Logo>(renderer, section);
|
||||
break;
|
||||
case ActiveSection::Intro:
|
||||
intro = std::make_unique<Intro>(renderer, screen, asset, input, lang, section);
|
||||
intro = std::make_unique<Intro>(renderer, section);
|
||||
break;
|
||||
case ActiveSection::Title:
|
||||
title = std::make_unique<Title>(renderer, screen, input, asset, lang, section);
|
||||
title = std::make_unique<Title>(renderer, section);
|
||||
break;
|
||||
case ActiveSection::Game: {
|
||||
const int numPlayers = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||
game = std::make_unique<Game>(numPlayers, 0, renderer, screen, asset, lang, input, false, section);
|
||||
game = std::make_unique<Game>(numPlayers, 0, renderer, false, section);
|
||||
break;
|
||||
}
|
||||
case ActiveSection::None:
|
||||
@@ -611,16 +611,16 @@ SDL_AppResult Director::handleEvent(SDL_Event *event) {
|
||||
// Hot-plug de mandos
|
||||
if (event->type == SDL_EVENT_GAMEPAD_ADDED) {
|
||||
std::string name;
|
||||
if (input->handleGamepadAdded(event->gdevice.which, name)) {
|
||||
screen->notify(name + " " + lang->getText(94),
|
||||
if (Input::get()->handleGamepadAdded(event->gdevice.which, name)) {
|
||||
Screen::get()->notify(name + " " + Lang::get()->getText(94),
|
||||
color_t{0x40, 0xFF, 0x40},
|
||||
color_t{0, 0, 0},
|
||||
2500);
|
||||
}
|
||||
} else if (event->type == SDL_EVENT_GAMEPAD_REMOVED) {
|
||||
std::string name;
|
||||
if (input->handleGamepadRemoved(event->gdevice.which, name)) {
|
||||
screen->notify(name + " " + lang->getText(95),
|
||||
if (Input::get()->handleGamepadRemoved(event->gdevice.which, name)) {
|
||||
Screen::get()->notify(name + " " + Lang::get()->getText(95),
|
||||
color_t{0xFF, 0x50, 0x50},
|
||||
color_t{0, 0, 0},
|
||||
2500);
|
||||
@@ -650,4 +650,3 @@ SDL_AppResult Director::handleEvent(SDL_Event *event) {
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,9 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string> // for string, basic_string
|
||||
class Asset;
|
||||
class Game;
|
||||
class Input;
|
||||
class Intro;
|
||||
class Lang;
|
||||
class Logo;
|
||||
class Screen;
|
||||
class Title;
|
||||
struct section_t;
|
||||
|
||||
@@ -26,10 +22,6 @@ class Director {
|
||||
// Objetos y punteros
|
||||
SDL_Window *window; // La ventana donde dibujamos
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Input *input; // Objeto Input para gestionar las entradas
|
||||
Lang *lang; // Objeto para gestionar los textos en diferentes idiomas
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
section_t *section; // Sección y subsección actual del programa;
|
||||
|
||||
// Secciones del juego
|
||||
|
||||
@@ -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