|
|
|
|
@@ -11,27 +11,27 @@
|
|
|
|
|
#include <memory> // Para make_unique, unique_ptr
|
|
|
|
|
#include <string> // Para operator+, allocator, char_traits
|
|
|
|
|
|
|
|
|
|
#include "core/audio/audio.hpp" // Para Audio
|
|
|
|
|
#include "core/input/input.hpp" // Para Input, InputAction
|
|
|
|
|
#include "core/rendering/screen.hpp" // Para Screen
|
|
|
|
|
#include "core/resources/asset.hpp" // Para Asset, AssetType
|
|
|
|
|
#include "core/resources/resource.hpp" // Para Resource
|
|
|
|
|
#include "core/audio/audio.hpp" // Para Audio
|
|
|
|
|
#include "core/input/input.hpp" // Para Input, InputAction
|
|
|
|
|
#include "core/rendering/screen.hpp" // Para Screen
|
|
|
|
|
#include "core/resources/asset.hpp" // Para Asset, AssetType
|
|
|
|
|
#include "core/resources/resource.hpp" // Para Resource
|
|
|
|
|
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
|
|
|
|
#include "core/resources/resource_loader.hpp" // Para ResourceLoader
|
|
|
|
|
#include "core/system/debug.hpp" // Para Debug
|
|
|
|
|
#include "game/gameplay/cheevos.hpp" // Para Cheevos
|
|
|
|
|
#include "game/options.hpp" // Para Options, options, OptionsVideo
|
|
|
|
|
#include "game/scene_manager.hpp" // Para SceneManager
|
|
|
|
|
#include "game/scenes/credits.hpp" // Para Credits
|
|
|
|
|
#include "game/scenes/ending.hpp" // Para Ending
|
|
|
|
|
#include "game/scenes/ending2.hpp" // Para Ending2
|
|
|
|
|
#include "game/scenes/game.hpp" // Para Game, GameMode
|
|
|
|
|
#include "game/scenes/game_over.hpp" // Para GameOver
|
|
|
|
|
#include "game/scenes/loading_screen.hpp" // Para LoadingScreen
|
|
|
|
|
#include "game/scenes/logo.hpp" // Para Logo
|
|
|
|
|
#include "game/scenes/title.hpp" // Para Title
|
|
|
|
|
#include "game/ui/notifier.hpp" // Para Notifier
|
|
|
|
|
#include "utils/defines.hpp" // Para WINDOW_CAPTION
|
|
|
|
|
#include "core/system/debug.hpp" // Para Debug
|
|
|
|
|
#include "game/gameplay/cheevos.hpp" // Para Cheevos
|
|
|
|
|
#include "game/options.hpp" // Para Options, options, OptionsVideo
|
|
|
|
|
#include "game/scene_manager.hpp" // Para SceneManager
|
|
|
|
|
#include "game/scenes/credits.hpp" // Para Credits
|
|
|
|
|
#include "game/scenes/ending.hpp" // Para Ending
|
|
|
|
|
#include "game/scenes/ending2.hpp" // Para Ending2
|
|
|
|
|
#include "game/scenes/game.hpp" // Para Game, GameMode
|
|
|
|
|
#include "game/scenes/game_over.hpp" // Para GameOver
|
|
|
|
|
#include "game/scenes/loading_screen.hpp" // Para LoadingScreen
|
|
|
|
|
#include "game/scenes/logo.hpp" // Para Logo
|
|
|
|
|
#include "game/scenes/title.hpp" // Para Title
|
|
|
|
|
#include "game/ui/notifier.hpp" // Para Notifier
|
|
|
|
|
#include "utils/defines.hpp" // Para WINDOW_CAPTION
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
#include <pwd.h>
|
|
|
|
|
@@ -92,7 +92,7 @@ Director::Director(std::vector<std::string> const& args) {
|
|
|
|
|
// 4. Initialize Asset system with config from pack
|
|
|
|
|
// NOTE: In release, don't use executable_path or PREFIX - paths in pack are relative
|
|
|
|
|
// Pass empty string to avoid issues when running from different directories
|
|
|
|
|
Asset::init(""); // Empty executable_path in release
|
|
|
|
|
Asset::init(""); // Empty executable_path in release
|
|
|
|
|
Asset::get()->loadFromString(assets_config, "", system_folder_); // Empty PREFIX for pack
|
|
|
|
|
std::cout << "Asset system initialized from pack\n";
|
|
|
|
|
|
|
|
|
|
@@ -134,13 +134,12 @@ Director::Director(std::vector<std::string> const& args) {
|
|
|
|
|
#ifdef RELEASE_BUILD
|
|
|
|
|
// In release, construct the path manually (not from Asset which has empty executable_path)
|
|
|
|
|
std::string gamecontroller_db = executable_path_ + PREFIX + "/gamecontrollerdb.txt";
|
|
|
|
|
Input::init(gamecontroller_db);
|
|
|
|
|
Input::init(gamecontroller_db, Asset::get()->get("controllers.json"));
|
|
|
|
|
#else
|
|
|
|
|
// In development, use Asset as normal
|
|
|
|
|
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
|
|
|
|
Input::init(Asset::get()->get("gamecontrollerdb.txt"), Asset::get()->get("controllers.json")); // Carga configuración de controles
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
initInput();
|
|
|
|
|
Debug::init();
|
|
|
|
|
|
|
|
|
|
// Special handling for cheevos.bin - also needs filesystem path
|
|
|
|
|
@@ -249,72 +248,6 @@ void Director::createSystemFolder(const std::string& folder) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Inicia las variables necesarias para arrancar el programa
|
|
|
|
|
void Director::initInput() {
|
|
|
|
|
// Busca si hay un mando conectado
|
|
|
|
|
Input::get()->discoverGameControllers();
|
|
|
|
|
|
|
|
|
|
// Teclado - Movimiento
|
|
|
|
|
if (Options::keys == Options::ControlScheme::CURSOR) {
|
|
|
|
|
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_UP);
|
|
|
|
|
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_LEFT);
|
|
|
|
|
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_RIGHT);
|
|
|
|
|
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_UP);
|
|
|
|
|
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_DOWN);
|
|
|
|
|
} else if (Options::keys == Options::ControlScheme::OPQA) {
|
|
|
|
|
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_Q);
|
|
|
|
|
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_O);
|
|
|
|
|
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_P);
|
|
|
|
|
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_Q);
|
|
|
|
|
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_A);
|
|
|
|
|
} else if (Options::keys == Options::ControlScheme::WASD) {
|
|
|
|
|
Input::get()->bindKey(InputAction::JUMP, SDL_SCANCODE_W);
|
|
|
|
|
Input::get()->bindKey(InputAction::LEFT, SDL_SCANCODE_A);
|
|
|
|
|
Input::get()->bindKey(InputAction::RIGHT, SDL_SCANCODE_D);
|
|
|
|
|
Input::get()->bindKey(InputAction::UP, SDL_SCANCODE_W);
|
|
|
|
|
Input::get()->bindKey(InputAction::DOWN, SDL_SCANCODE_S);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Teclado - Otros
|
|
|
|
|
Input::get()->bindKey(InputAction::ACCEPT, SDL_SCANCODE_RETURN);
|
|
|
|
|
Input::get()->bindKey(InputAction::CANCEL, SDL_SCANCODE_ESCAPE);
|
|
|
|
|
Input::get()->bindKey(InputAction::PAUSE, SDL_SCANCODE_H);
|
|
|
|
|
Input::get()->bindKey(InputAction::EXIT, SDL_SCANCODE_ESCAPE);
|
|
|
|
|
Input::get()->bindKey(InputAction::WINDOW_DEC_ZOOM, SDL_SCANCODE_F1);
|
|
|
|
|
Input::get()->bindKey(InputAction::WINDOW_INC_ZOOM, SDL_SCANCODE_F2);
|
|
|
|
|
Input::get()->bindKey(InputAction::TOGGLE_VIDEOMODE, SDL_SCANCODE_F3);
|
|
|
|
|
Input::get()->bindKey(InputAction::TOGGLE_SHADERS, SDL_SCANCODE_F4);
|
|
|
|
|
Input::get()->bindKey(InputAction::NEXT_PALETTE, SDL_SCANCODE_F5);
|
|
|
|
|
Input::get()->bindKey(InputAction::PREVIOUS_PALETTE, SDL_SCANCODE_F6);
|
|
|
|
|
Input::get()->bindKey(InputAction::TOGGLE_INTEGER_SCALE, SDL_SCANCODE_F7);
|
|
|
|
|
Input::get()->bindKey(InputAction::SHOW_DEBUG_INFO, SDL_SCANCODE_F12);
|
|
|
|
|
Input::get()->bindKey(InputAction::TOGGLE_MUSIC, SDL_SCANCODE_M);
|
|
|
|
|
Input::get()->bindKey(InputAction::TOGGLE_BORDER, SDL_SCANCODE_B);
|
|
|
|
|
|
|
|
|
|
// MANDO
|
|
|
|
|
const int NUM_GAMEPADS = Input::get()->getNumControllers();
|
|
|
|
|
for (int i = 0; i < NUM_GAMEPADS; ++i) {
|
|
|
|
|
// Movimiento
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::JUMP, SDL_GAMEPAD_BUTTON_SOUTH);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
|
|
|
|
|
|
|
|
|
|
// Otros
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::ACCEPT, SDL_GAMEPAD_BUTTON_SOUTH);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::CANCEL, SDL_GAMEPAD_BUTTON_EAST);
|
|
|
|
|
#ifdef GAME_CONSOLE
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::input_pause, SDL_GAMEPAD_BUTTON_BACK);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::input_exit, SDL_GAMEPAD_BUTTON_START);
|
|
|
|
|
#else
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::PAUSE, SDL_GAMEPAD_BUTTON_START);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::EXIT, SDL_GAMEPAD_BUTTON_BACK);
|
|
|
|
|
#endif
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::NEXT_PALETTE, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::TOGGLE_MUSIC, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
|
|
|
|
|
Input::get()->bindGameControllerButton(i, InputAction::TOGGLE_BORDER, SDL_GAMEPAD_BUTTON_NORTH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Crea el indice de ficheros
|
|
|
|
|
auto Director::setFileList() -> bool {
|
|
|
|
|
// Determinar el prefijo de ruta según la plataforma
|
|
|
|
|
|