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
|
||||
|
||||
Reference in New Issue
Block a user