Precàrrega de tots els recursos al inici del joc
8.000.000 de cherrypickings que he anat fent pel codi
This commit is contained in:
@@ -74,11 +74,8 @@ Director::Director(int argc, const char *argv[])
|
||||
// Crea el objeto que controla los ficheros de recursos
|
||||
Asset::init(executable_path_);
|
||||
|
||||
// Si falta algún fichero no inicia el programa
|
||||
if (!setFileList())
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Crea el indice de ficheros
|
||||
setFileList();
|
||||
|
||||
// Carga el fichero de configuración
|
||||
loadOptionsFile(Asset::get()->get("config.txt"));
|
||||
@@ -107,14 +104,15 @@ Director::Director(int argc, const char *argv[])
|
||||
// Crea los objetos
|
||||
lang::loadFromFile(getLangFile((lang::Code)options.game.language));
|
||||
|
||||
Screen::init(window_, renderer_);
|
||||
|
||||
Resource::init();
|
||||
|
||||
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
||||
initInput();
|
||||
bindInputs();
|
||||
|
||||
Screen::init(window_, renderer_);
|
||||
|
||||
Notifier::init(renderer_, std::string(), Asset::get()->get("8bithud.png"), Asset::get()->get("8bithud.txt"), Asset::get()->get("notify.wav"));
|
||||
auto notifier_text = std::make_shared<Text>(Resource::get()->getTexture("8bithud.png"), Resource::get()->getTextFile("8bithud.txt"));
|
||||
Notifier::init(std::string(), notifier_text, Asset::get()->get("notify.wav"));
|
||||
|
||||
OnScreenHelp::init();
|
||||
|
||||
@@ -132,19 +130,15 @@ Director::~Director()
|
||||
Notifier::destroy();
|
||||
OnScreenHelp::destroy();
|
||||
|
||||
|
||||
SDL_DestroyRenderer(renderer_);
|
||||
SDL_DestroyWindow(window_);
|
||||
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
/// Inicializa el objeto input
|
||||
void Director::initInput()
|
||||
// Asigna los botones y teclas al objeto Input
|
||||
void Director::bindInputs()
|
||||
{
|
||||
// Busca si hay mandos conectados
|
||||
Input::get()->discoverGameControllers();
|
||||
|
||||
// Teclado - Movimiento del jugador
|
||||
Input::get()->bindKey(InputType::UP, SDL_SCANCODE_UP);
|
||||
Input::get()->bindKey(InputType::DOWN, SDL_SCANCODE_DOWN);
|
||||
@@ -331,7 +325,7 @@ bool Director::initSDL()
|
||||
}
|
||||
|
||||
// Crea el indice de ficheros
|
||||
bool Director::setFileList()
|
||||
void Director::setFileList()
|
||||
{
|
||||
#ifdef MACOS_BUNDLE
|
||||
const std::string prefix = "/../Resources";
|
||||
@@ -456,17 +450,17 @@ bool Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
|
||||
|
||||
// Fuentes de texto
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.png", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.png", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.png", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/nokia.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.png", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/nokia2.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/nokia_big2.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.png", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.png", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_big.txt", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::FONT);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::BITMAP);
|
||||
Asset::get()->add(prefix + "/data/font/smb2_pal1.gif", AssetType::PALETTE);
|
||||
Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT);
|
||||
|
||||
@@ -475,7 +469,9 @@ bool Director::setFileList()
|
||||
Asset::get()->add(prefix + "/data/lang/en_UK.txt", AssetType::LANG);
|
||||
Asset::get()->add(prefix + "/data/lang/ba_BA.txt", AssetType::LANG);
|
||||
|
||||
return Asset::get()->check();
|
||||
// Si falta algun fichero, sale del programa
|
||||
if (!Asset::get()->check())
|
||||
throw std::runtime_error("Falta algun fichero");
|
||||
}
|
||||
|
||||
// Carga los parametros para configurar el juego
|
||||
|
||||
Reference in New Issue
Block a user