Eliminades variables sobrants en director.cpp

This commit is contained in:
2024-10-03 17:02:40 +02:00
parent 5ebc58dd01
commit 71bd3bed52
2 changed files with 176 additions and 189 deletions

View File

@@ -59,7 +59,6 @@ Director::Director(int argc, char *argv[])
// Crea el objeto que controla los ficheros de recursos
Asset::init(executablePath);
asset = Asset::get();
// Si falta algún fichero no inicia el programa
if (!setFileList())
@@ -68,19 +67,19 @@ Director::Director(int argc, char *argv[])
}
// Carga el fichero de configuración
loadOptionsFile(asset->get("config.txt"));
loadOptionsFile(Asset::get()->get("config.txt"));
// Carga los parametros para configurar el juego
#ifdef ANBERNIC
const std::string paramFilePath = asset->get("param_320x240.txt");
#else
const std::string paramFilePath = paramFileArgument == "--320x240" ? asset->get("param_320x240.txt") : asset->get("param_320x256.txt");
const std::string paramFilePath = paramFileArgument == "--320x240" ? Asset::get()->get("param_320x240.txt") : Asset::get()->get("param_320x256.txt");
#endif
loadParams(paramFilePath);
// Carga el fichero de puntuaciones
ManageHiScoreTable *manager = new ManageHiScoreTable(&options.game.hiScoreTable);
manager->loadFromFile(asset->get("score.bin"));
manager->loadFromFile(Asset::get()->get("score.bin"));
delete manager;
// Inicializa SDL
@@ -95,12 +94,10 @@ Director::Director(int argc, char *argv[])
// Crea los objetos
lang::loadFromFile(getLangFile((lang::lang_e)options.game.language));
Input::init(asset->get("gamecontrollerdb.txt"));
input = Input::get();
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
initInput();
Screen::init(window, renderer);
screen = Screen::get();
OnScreenHelp::init();
@@ -113,7 +110,7 @@ Director::Director(int argc, char *argv[])
Director::~Director()
{
saveOptionsFile(asset->get("config.txt"));
saveOptionsFile(Asset::get()->get("config.txt"));
Asset::destroy();
Input::destroy();
@@ -134,94 +131,94 @@ void Director::initInput()
{
// Establece si ha de mostrar mensajes
#ifdef VERBOSE
input->setVerbose(true);
Input::get()->setVerbose(true);
#else
input->setVerbose(false);
Input::get()->setVerbose(false);
#endif
// Busca si hay mandos conectados
input->discoverGameControllers();
Input::get()->discoverGameControllers();
// 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::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->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_fire_left, SDL_SCANCODE_Q);
Input::get()->bindKey(input_fire_center, SDL_SCANCODE_W);
Input::get()->bindKey(input_fire_right, SDL_SCANCODE_E);
input->bindKey(input_start, SDL_SCANCODE_RETURN);
Input::get()->bindKey(input_start, SDL_SCANCODE_RETURN);
// Teclado - Control del programa
input->bindKey(input_service, SDL_SCANCODE_0);
input->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
input->bindKey(input_pause, SDL_SCANCODE_P);
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_video_shaders, SDL_SCANCODE_F4);
input->bindKey(input_mute, SDL_SCANCODE_F5);
input->bindKey(input_showinfo, SDL_SCANCODE_F6);
input->bindKey(input_reset, SDL_SCANCODE_F10);
Input::get()->bindKey(input_service, SDL_SCANCODE_0);
Input::get()->bindKey(input_exit, SDL_SCANCODE_ESCAPE);
Input::get()->bindKey(input_pause, SDL_SCANCODE_P);
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_video_shaders, SDL_SCANCODE_F4);
Input::get()->bindKey(input_mute, SDL_SCANCODE_F5);
Input::get()->bindKey(input_showinfo, SDL_SCANCODE_F6);
Input::get()->bindKey(input_reset, SDL_SCANCODE_F10);
// Asigna botones a inputs
const int numGamePads = input->getNumControllers();
const int numGamePads = Input::get()->getNumControllers();
for (int i = 0; i < numGamePads; ++i)
{
// Mando - Movimiento del jugador
input->bindGameControllerButton(i, input_up, SDL_CONTROLLER_BUTTON_DPAD_UP);
input->bindGameControllerButton(i, input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
input->bindGameControllerButton(i, input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
input->bindGameControllerButton(i, input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
Input::get()->bindGameControllerButton(i, input_up, SDL_CONTROLLER_BUTTON_DPAD_UP);
Input::get()->bindGameControllerButton(i, input_down, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
Input::get()->bindGameControllerButton(i, input_left, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
Input::get()->bindGameControllerButton(i, input_right, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
input->bindGameControllerButton(i, input_fire_left, SDL_CONTROLLER_BUTTON_X);
input->bindGameControllerButton(i, input_fire_center, SDL_CONTROLLER_BUTTON_Y);
input->bindGameControllerButton(i, input_fire_right, SDL_CONTROLLER_BUTTON_B);
Input::get()->bindGameControllerButton(i, input_fire_left, SDL_CONTROLLER_BUTTON_X);
Input::get()->bindGameControllerButton(i, input_fire_center, SDL_CONTROLLER_BUTTON_Y);
Input::get()->bindGameControllerButton(i, input_fire_right, SDL_CONTROLLER_BUTTON_B);
input->bindGameControllerButton(i, input_start, SDL_CONTROLLER_BUTTON_START);
Input::get()->bindGameControllerButton(i, input_start, SDL_CONTROLLER_BUTTON_START);
// Mando - Control del programa
input->bindGameControllerButton(i, input_service, SDL_CONTROLLER_BUTTON_BACK);
input->bindGameControllerButton(i, input_exit, input_start);
input->bindGameControllerButton(i, input_pause, input_fire_right);
input->bindGameControllerButton(i, input_video_shaders, input_fire_left);
input->bindGameControllerButton(i, input_mute, input_left);
input->bindGameControllerButton(i, input_showinfo, input_right);
input->bindGameControllerButton(i, input_reset, input_fire_center);
input->bindGameControllerButton(i, input_config, input_down);
input->bindGameControllerButton(i, input_swap_controllers, input_up);
Input::get()->bindGameControllerButton(i, input_service, SDL_CONTROLLER_BUTTON_BACK);
Input::get()->bindGameControllerButton(i, input_exit, input_start);
Input::get()->bindGameControllerButton(i, input_pause, input_fire_right);
Input::get()->bindGameControllerButton(i, input_video_shaders, input_fire_left);
Input::get()->bindGameControllerButton(i, input_mute, input_left);
Input::get()->bindGameControllerButton(i, input_showinfo, input_right);
Input::get()->bindGameControllerButton(i, input_reset, input_fire_center);
Input::get()->bindGameControllerButton(i, input_config, input_down);
Input::get()->bindGameControllerButton(i, input_swap_controllers, input_up);
}
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
for (int i = 0; i < numGamePads; ++i)
for (int index = 0; index < (int)options.controller.size(); ++index)
if (input->getControllerName(i) == options.controller[index].name)
if (Input::get()->getControllerName(i) == options.controller[index].name)
for (int j = 0; j < (int)options.controller[index].inputs.size(); ++j)
{
input->bindGameControllerButton(i, options.controller[index].inputs[j], options.controller[index].buttons[j]);
Input::get()->bindGameControllerButton(i, options.controller[index].inputs[j], options.controller[index].buttons[j]);
}
// Asigna botones a inputs desde otros inputs
for (int i = 0; i < numGamePads; ++i)
{
input->bindGameControllerButton(i, input_exit, input_start);
input->bindGameControllerButton(i, input_reset, input_fire_center);
input->bindGameControllerButton(i, input_pause, input_fire_right);
input->bindGameControllerButton(i, input_video_shaders, input_fire_left);
input->bindGameControllerButton(i, input_mute, input_left);
input->bindGameControllerButton(i, input_showinfo, input_right);
input->bindGameControllerButton(i, input_config, input_down);
input->bindGameControllerButton(i, input_swap_controllers, input_up);
Input::get()->bindGameControllerButton(i, input_exit, input_start);
Input::get()->bindGameControllerButton(i, input_reset, input_fire_center);
Input::get()->bindGameControllerButton(i, input_pause, input_fire_right);
Input::get()->bindGameControllerButton(i, input_video_shaders, input_fire_left);
Input::get()->bindGameControllerButton(i, input_mute, input_left);
Input::get()->bindGameControllerButton(i, input_showinfo, input_right);
Input::get()->bindGameControllerButton(i, input_config, input_down);
Input::get()->bindGameControllerButton(i, input_swap_controllers, input_up);
}
// Guarda las asignaciones de botones en las opciones
for (int i = 0; i < numGamePads; ++i)
{
options.controller[i].name = input->getControllerName(i);
options.controller[i].name = Input::get()->getControllerName(i);
for (int j = 0; j < (int)options.controller[i].inputs.size(); ++j)
{
options.controller[i].buttons[j] = input->getControllerBinding(i, options.controller[i].inputs[j]);
options.controller[i].buttons[j] = Input::get()->getControllerBinding(i, options.controller[i].inputs[j]);
}
}
}
@@ -346,137 +343,137 @@ bool Director::setFileList()
#endif
// Ficheros de configuración
asset->add(systemFolder + "/config.txt", t_data, false, true);
asset->add(systemFolder + "/score.bin", t_data, false, true);
asset->add(prefix + "/data/config/param_320x240.txt", t_data);
asset->add(prefix + "/data/config/param_320x256.txt", t_data);
asset->add(prefix + "/data/config/demo1.bin", t_data);
asset->add(prefix + "/data/config/demo2.bin", t_data);
asset->add(prefix + "/data/config/gamecontrollerdb.txt", t_data);
Asset::get()->add(systemFolder + "/config.txt", t_data, false, true);
Asset::get()->add(systemFolder + "/score.bin", t_data, false, true);
Asset::get()->add(prefix + "/data/config/param_320x240.txt", t_data);
Asset::get()->add(prefix + "/data/config/param_320x256.txt", t_data);
Asset::get()->add(prefix + "/data/config/demo1.bin", t_data);
Asset::get()->add(prefix + "/data/config/demo2.bin", t_data);
Asset::get()->add(prefix + "/data/config/gamecontrollerdb.txt", 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/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->add(prefix + "/data/sound/notify.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/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);
Asset::get()->add(prefix + "/data/sound/notify.wav", t_sound);
// Shaders
asset->add(prefix + "/data/shaders/crtpi.glsl", t_data);
Asset::get()->add(prefix + "/data/shaders/crtpi.glsl", t_data);
// Texturas
asset->add(prefix + "/data/gfx/controllers/controllers.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/controllers/controllers.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/balloon1.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/balloon1.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/balloon2.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/balloon2.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/balloon3.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/balloon3.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/balloon4.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/balloon4.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/explosion1.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/explosion1.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/explosion2.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/explosion2.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/explosion3.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/explosion3.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/explosion4.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/explosion4.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon/powerball.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon/powerball.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.ani", t_animation);
asset->add(prefix + "/data/gfx/bullet/bullet.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_buildings.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_clouds1.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_clouds2.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_grass.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_power_meter.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_sky_colors.png", t_bitmap);
asset->add(prefix + "/data/gfx/game/game_text.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_buildings.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_clouds1.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_clouds2.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_grass.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_power_meter.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_sky_colors.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/game/game_text.png", t_bitmap);
asset->add(prefix + "/data/gfx/intro/intro.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/intro/intro.png", t_bitmap);
asset->add(prefix + "/data/gfx/logo/logo_jailgames.png", t_bitmap);
asset->add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", t_bitmap);
asset->add(prefix + "/data/gfx/logo/logo_since_1998.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/logo/logo_since_1998.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_points1_disk.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_points1_disk.ani", t_animation);
asset->add(prefix + "/data/gfx/item/item_points2_gavina.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_points2_gavina.ani", t_animation);
asset->add(prefix + "/data/gfx/item/item_points3_pacmar.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_points3_pacmar.ani", t_animation);
asset->add(prefix + "/data/gfx/item/item_clock.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_clock.ani", t_animation);
asset->add(prefix + "/data/gfx/item/item_coffee.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_coffee.ani", t_animation);
asset->add(prefix + "/data/gfx/item/item_coffee_machine.png", t_bitmap);
asset->add(prefix + "/data/gfx/item/item_coffee_machine.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/item/item_clock.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", t_animation);
asset->add(prefix + "/data/gfx/title/title_bg_tile.png", t_bitmap);
asset->add(prefix + "/data/gfx/title/title_coffee.png", t_bitmap);
asset->add(prefix + "/data/gfx/title/title_crisis.png", t_bitmap);
asset->add(prefix + "/data/gfx/title/title_arcade_edition.png", t_bitmap);
asset->add(prefix + "/data/gfx/title/title_dust.png", t_bitmap);
asset->add(prefix + "/data/gfx/title/title_dust.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title/title_coffee.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title/title_crisis.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title/title_arcade_edition.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title/title_dust.png", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/title/title_dust.ani", t_animation);
asset->add(prefix + "/data/gfx/player/player1.gif", t_bitmap);
asset->add(prefix + "/data/gfx/player/player1_pal1.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player1_pal2.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player1_pal3.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player1.gif", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player/player1_pal1.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player1_pal2.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player1_pal3.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player2.gif", t_bitmap);
asset->add(prefix + "/data/gfx/player/player2_pal1.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player2_pal2.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player2_pal3.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player2.gif", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player/player2_pal1.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player2_pal2.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player2_pal3.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/player/player.ani", t_animation);
asset->add(prefix + "/data/gfx/player/player_power.gif", t_bitmap);
asset->add(prefix + "/data/gfx/player/player_power_pal.gif", t_palette);
asset->add(prefix + "/data/gfx/player/player_power.ani", t_animation);
Asset::get()->add(prefix + "/data/gfx/player/player_power.gif", t_bitmap);
Asset::get()->add(prefix + "/data/gfx/player/player_power_pal.gif", t_palette);
Asset::get()->add(prefix + "/data/gfx/player/player_power.ani", t_animation);
// Fuentes de texto
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.gif", t_font);
asset->add(prefix + "/data/font/smb2_pal1.gif", t_palette);
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.gif", t_font);
Asset::get()->add(prefix + "/data/font/smb2_pal1.gif", t_palette);
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);
return asset->check();
return Asset::get()->check();
}
// Carga los parametros para configurar el juego
@@ -563,7 +560,7 @@ void Director::createSystemFolder(std::string folder)
void Director::loadSounds()
{
// Obtiene la lista con las rutas a los ficheros de sonidos
std::vector<std::string> list = asset->getListByType(t_sound);
std::vector<std::string> list = Asset::get()->getListByType(t_sound);
sounds.clear();
for (auto l : list)
@@ -581,7 +578,7 @@ void Director::loadSounds()
void Director::loadMusics()
{
// Obtiene la lista con las rutas a los ficheros musicales
std::vector<std::string> list = asset->getListByType(t_music);
std::vector<std::string> list = Asset::get()->getListByType(t_music);
musics.clear();
for (auto l : list)
@@ -618,7 +615,7 @@ void Director::deleteMusics()
// Ejecuta la sección con el logo
void Director::runLogo()
{
logo = new Logo();
Logo *logo = new Logo();
logo->run();
delete logo;
}
@@ -626,7 +623,7 @@ void Director::runLogo()
// Ejecuta la sección con la secuencia de introducción
void Director::runIntro()
{
intro = new Intro(getMusic(musics, "intro.ogg"));
Intro *intro = new Intro(getMusic(musics, "intro.ogg"));
intro->run();
delete intro;
}
@@ -634,7 +631,7 @@ void Director::runIntro()
// Ejecuta la sección con el titulo del juego
void Director::runTitle()
{
title = new Title(getMusic(musics, "title.ogg"));
Title *title = new Title(getMusic(musics, "title.ogg"));
title->run();
delete title;
}
@@ -644,7 +641,7 @@ void Director::runGame()
{
const int playerID = section::options == section::OPTIONS_GAME_PLAY_1P ? 1 : 2;
const int currentStage = 0;
game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, getMusic(musics, "playing.ogg"));
Game *game = new Game(playerID, currentStage, GAME_MODE_DEMO_OFF, getMusic(musics, "playing.ogg"));
game->run();
delete game;
}
@@ -652,7 +649,7 @@ void Director::runGame()
// Ejecuta la sección donde se muestran las instrucciones
void Director::runInstructions()
{
instructions = new Instructions(getMusic(musics, "title.ogg"));
Instructions *instructions = new Instructions(getMusic(musics, "title.ogg"));
instructions->run();
delete instructions;
}
@@ -660,7 +657,7 @@ void Director::runInstructions()
// Ejecuta la sección donde se muestra la tabla de puntuaciones
void Director::runHiScoreTable()
{
hiScoreTable = new HiScoreTable(getMusic(musics, "title.ogg"));
HiScoreTable *hiScoreTable = new HiScoreTable(getMusic(musics, "title.ogg"));
hiScoreTable->run();
delete hiScoreTable;
}
@@ -670,9 +667,9 @@ void Director::runDemoGame()
{
const int playerID = (rand() % 2) + 1;
const int currentStage = 0;
demoGame = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, nullptr);
demoGame->run();
delete demoGame;
Game *game = new Game(playerID, currentStage, GAME_MODE_DEMO_ON, nullptr);
game->run();
delete game;
}
int Director::run()
@@ -729,20 +726,20 @@ std::string Director::getLangFile(lang::lang_e lang)
switch (lang)
{
case lang::ba_BA:
return asset->get("ba_BA.txt");
return Asset::get()->get("ba_BA.txt");
break;
case lang::es_ES:
return asset->get("es_ES.txt");
return Asset::get()->get("es_ES.txt");
break;
case lang::en_UK:
return asset->get("en_UK.txt");
return Asset::get()->get("en_UK.txt");
break;
default:
break;
}
return asset->get("en_UK.txt");
return Asset::get()->get("en_UK.txt");
}

View File

@@ -25,16 +25,6 @@ private:
// 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
Logo *logo; // Objeto para la sección del logo
Intro *intro; // Objeto para la sección de la intro
Title *title; // Objeto para la sección del titulo y el menu de opciones
Game *game; // Objeto para la sección del juego
Instructions *instructions; // Objeto para la sección de las instrucciones
HiScoreTable *hiScoreTable; // Objeto para mostrar las mejores puntuaciones online
Game *demoGame; // Objeto para lanzar la demo del juego
Input *input; // Objeto Input para gestionar las entradas
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
// Variables
std::string executablePath; // Path del ejecutable