Merge branch 'main' of https://gitea.sustancia.synology.me/JailDesigner/coffee_crisis_arcade_edition
This commit is contained in:
@@ -61,6 +61,8 @@
|
|||||||
"[NOTIFICATIONS] 14": "Sincronisme vertical",
|
"[NOTIFICATIONS] 14": "Sincronisme vertical",
|
||||||
"[NOTIFICATIONS] 15": "Reiniciar",
|
"[NOTIFICATIONS] 15": "Reiniciar",
|
||||||
|
|
||||||
|
"[RESOURCE] LOADING": "Carregant",
|
||||||
|
|
||||||
"[SERVICE_MENU] TITLE": "Menu de servei",
|
"[SERVICE_MENU] TITLE": "Menu de servei",
|
||||||
"[SERVICE_MENU] RESET": "Reiniciar",
|
"[SERVICE_MENU] RESET": "Reiniciar",
|
||||||
"[SERVICE_MENU] QUIT": "Eixir del joc",
|
"[SERVICE_MENU] QUIT": "Eixir del joc",
|
||||||
|
|||||||
@@ -61,6 +61,8 @@
|
|||||||
"[NOTIFICATIONS] 14": "Vertical Sync",
|
"[NOTIFICATIONS] 14": "Vertical Sync",
|
||||||
"[NOTIFICATIONS] 15": "Reset",
|
"[NOTIFICATIONS] 15": "Reset",
|
||||||
|
|
||||||
|
"[RESOURCE] LOADING": "Loading",
|
||||||
|
|
||||||
"[SERVICE_MENU] TITLE": "Service Menu",
|
"[SERVICE_MENU] TITLE": "Service Menu",
|
||||||
"[SERVICE_MENU] RESET": "Reset",
|
"[SERVICE_MENU] RESET": "Reset",
|
||||||
"[SERVICE_MENU] QUIT": "Quit Game",
|
"[SERVICE_MENU] QUIT": "Quit Game",
|
||||||
|
|||||||
@@ -61,6 +61,8 @@
|
|||||||
"[NOTIFICATIONS] 14": "Sincronismo vertical",
|
"[NOTIFICATIONS] 14": "Sincronismo vertical",
|
||||||
"[NOTIFICATIONS] 15": "Reiniciar",
|
"[NOTIFICATIONS] 15": "Reiniciar",
|
||||||
|
|
||||||
|
"[RESOURCE] LOADING": "Cargando",
|
||||||
|
|
||||||
"[SERVICE_MENU] TITLE": "Menu de servicio",
|
"[SERVICE_MENU] TITLE": "Menu de servicio",
|
||||||
"[SERVICE_MENU] RESET": "Reiniciar",
|
"[SERVICE_MENU] RESET": "Reiniciar",
|
||||||
"[SERVICE_MENU] QUIT": "Salir del juego",
|
"[SERVICE_MENU] QUIT": "Salir del juego",
|
||||||
|
|||||||
@@ -122,10 +122,8 @@ void Director::close()
|
|||||||
// Libera todos los recursos de SDL
|
// Libera todos los recursos de SDL
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
#ifdef ARCADE
|
// Apaga el sistema
|
||||||
// Si está en modo arcade, apaga el sistema si corresponde
|
shutdownSystem(section::options == section::Options::SHUTDOWN);
|
||||||
shutdownSystem(section::options == section::Options::QUIT_WITH_CONTROLLER);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga los parametros
|
// Carga los parametros
|
||||||
@@ -671,26 +669,9 @@ int Director::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string return_code;
|
return 0;
|
||||||
switch (section::options)
|
|
||||||
{
|
|
||||||
case section::Options::QUIT_WITH_KEYBOARD:
|
|
||||||
return_code = "with keyboard";
|
|
||||||
break;
|
|
||||||
case section::Options::QUIT_WITH_CONTROLLER:
|
|
||||||
return_code = "with controller";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return_code = "from event";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nGame end %s", return_code.c_str());
|
|
||||||
|
|
||||||
return (section::options == section::Options::QUIT_WITH_CONTROLLER) ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCADE
|
|
||||||
// Apaga el sistema
|
// Apaga el sistema
|
||||||
void Director::shutdownSystem(bool should_shutdown)
|
void Director::shutdownSystem(bool should_shutdown)
|
||||||
{
|
{
|
||||||
@@ -710,5 +691,4 @@ void Director::shutdownSystem(bool should_shutdown)
|
|||||||
#error "Sistema operativo no soportado"
|
#error "Sistema operativo no soportado"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ARCADE
|
|
||||||
@@ -9,35 +9,33 @@ namespace lang
|
|||||||
class Director
|
class Director
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// --- Constructor y destructor ---
|
||||||
Director(int argc, const char *argv[]);
|
Director(int argc, const char *argv[]);
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Director();
|
~Director();
|
||||||
|
|
||||||
// Bucle principal de la aplicación
|
// --- Bucle principal ---
|
||||||
int run();
|
int run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Variables internas
|
// --- Variables internas ---
|
||||||
std::string executable_path_; // Ruta del ejecutable
|
std::string executable_path_; // Ruta del ejecutable
|
||||||
std::string system_folder_; // Carpeta del sistema para almacenar datos
|
std::string system_folder_; // Carpeta del sistema para almacenar datos
|
||||||
|
|
||||||
// Inicialización y cierre del sistema
|
// --- Inicialización y cierre del sistema ---
|
||||||
void init(); // Inicializa la aplicación
|
void init(); // Inicializa la aplicación
|
||||||
void close(); // Cierra y libera recursos
|
void close(); // Cierra y libera recursos
|
||||||
|
|
||||||
// Configuración inicial
|
// --- Configuración inicial ---
|
||||||
void loadParams(); // Carga los parámetros del programa
|
void loadParams(); // Carga los parámetros del programa
|
||||||
void loadScoreFile(); // Carga el fichero de puntuaciones
|
void loadScoreFile(); // Carga el fichero de puntuaciones
|
||||||
void createSystemFolder(const std::string &folder); // Crea la carpeta del sistema
|
void createSystemFolder(const std::string &folder); // Crea la carpeta del sistema
|
||||||
|
|
||||||
// Gestión de entrada y archivos
|
// --- Gestión de entrada y archivos ---
|
||||||
void bindInputs(); // Asigna botones y teclas al sistema de entrada
|
void bindInputs(); // Asigna botones y teclas al sistema de entrada
|
||||||
void setFileList(); // Crea el índice de archivos disponibles
|
void setFileList(); // Crea el índice de archivos disponibles
|
||||||
void checkProgramArguments(int argc, const char *argv[]); // Verifica los parámetros del programa
|
void checkProgramArguments(int argc, const char *argv[]); // Verifica los parámetros del programa
|
||||||
|
|
||||||
// Diferentes secciones del programa
|
// --- Secciones del programa ---
|
||||||
void runLogo(); // Ejecuta la pantalla con el logo
|
void runLogo(); // Ejecuta la pantalla con el logo
|
||||||
void runIntro(); // Ejecuta la introducción del juego
|
void runIntro(); // Ejecuta la introducción del juego
|
||||||
void runTitle(); // Ejecuta la pantalla de título
|
void runTitle(); // Ejecuta la pantalla de título
|
||||||
@@ -48,10 +46,9 @@ private:
|
|||||||
void runDemoGame(); // Ejecuta el modo demo
|
void runDemoGame(); // Ejecuta el modo demo
|
||||||
void reset(); // Reinicia objetos y vuelve a la sección inicial
|
void reset(); // Reinicia objetos y vuelve a la sección inicial
|
||||||
|
|
||||||
// Gestión de archivos de idioma
|
// --- Gestión de archivos de idioma ---
|
||||||
std::string getLangFile(lang::Code code); // Obtiene un fichero de idioma según el código
|
std::string getLangFile(lang::Code code); // Obtiene un fichero de idioma según el código
|
||||||
|
|
||||||
#ifdef ARCADE
|
// --- Apagado del sistema ---
|
||||||
void shutdownSystem(bool should_shutdown); // Apaga el sistema (modo arcade)
|
void shutdownSystem(bool should_shutdown); // Apaga el sistema
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace globalEvents
|
|||||||
{
|
{
|
||||||
case SDL_EVENT_QUIT: // Evento de salida de la aplicación
|
case SDL_EVENT_QUIT: // Evento de salida de la aplicación
|
||||||
section::name = section::Name::QUIT;
|
section::name = section::Name::QUIT;
|
||||||
section::options = section::Options::QUIT_FROM_EVENT;
|
section::options = section::Options::NONE;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case SDL_EVENT_RENDER_DEVICE_RESET:
|
case SDL_EVENT_RENDER_DEVICE_RESET:
|
||||||
|
|||||||
@@ -17,24 +17,19 @@
|
|||||||
namespace globalInputs
|
namespace globalInputs
|
||||||
{
|
{
|
||||||
// Termina
|
// Termina
|
||||||
void quit(section::Options code)
|
void quit()
|
||||||
{
|
{
|
||||||
const std::string CODE = "QUIT";
|
const std::string CODE = "QUIT";
|
||||||
if (Notifier::get()->checkCode(CODE))
|
if (Notifier::get()->checkCode(CODE))
|
||||||
{
|
{
|
||||||
// Si la notificación de salir está activa, cambia de sección
|
// Si la notificación de salir está activa, cambia de sección
|
||||||
section::name = section::Name::QUIT;
|
section::name = section::Name::QUIT;
|
||||||
section::options = code;
|
section::options = section::Options::NONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si la notificación de salir no está activa, muestra la notificación
|
// Si la notificación de salir no está activa, muestra la notificación
|
||||||
#ifdef ARCADE
|
|
||||||
const std::string TEXT = code == section::Options::QUIT_WITH_CONTROLLER ? lang::getText("[NOTIFICATIONS] 02") : lang::getText("[NOTIFICATIONS] 01");
|
|
||||||
Notifier::get()->show({TEXT, std::string()}, -1, CODE);
|
|
||||||
#else
|
|
||||||
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
|
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +351,7 @@ namespace globalInputs
|
|||||||
// Salir
|
// Salir
|
||||||
if (Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
if (Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
quit(section::Options::QUIT_WITH_KEYBOARD);
|
quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ HiScoreTable::HiScoreTable()
|
|||||||
HiScoreTable::~HiScoreTable()
|
HiScoreTable::~HiScoreTable()
|
||||||
{
|
{
|
||||||
SDL_DestroyTexture(backbuffer_);
|
SDL_DestroyTexture(backbuffer_);
|
||||||
options.game.clear_last_hi_score_entries();
|
options.game.clearLastHiScoreEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ void initOptions()
|
|||||||
options.game.difficulty = GameDifficulty::NORMAL;
|
options.game.difficulty = GameDifficulty::NORMAL;
|
||||||
options.game.language = lang::Code::VALENCIAN;
|
options.game.language = lang::Code::VALENCIAN;
|
||||||
options.game.autofire = true;
|
options.game.autofire = true;
|
||||||
options.game.clear_last_hi_score_entries();
|
options.game.shutdown_enabled = false;
|
||||||
|
options.game.clearLastHiScoreEntries();
|
||||||
|
|
||||||
// Opciones de control
|
// Opciones de control
|
||||||
options.controllers.clear();
|
options.controllers.clear();
|
||||||
@@ -155,6 +156,7 @@ bool saveOptionsFile(std::string file_path)
|
|||||||
file << "game.language=" << static_cast<int>(options.game.language) << "\n";
|
file << "game.language=" << static_cast<int>(options.game.language) << "\n";
|
||||||
file << "game.difficulty=" << static_cast<int>(options.game.difficulty) << "\n";
|
file << "game.difficulty=" << static_cast<int>(options.game.difficulty) << "\n";
|
||||||
file << "game.autofire=" << boolToString(options.game.autofire) << "\n";
|
file << "game.autofire=" << boolToString(options.game.autofire) << "\n";
|
||||||
|
file << "game.shutdown_enabled=" << boolToString(options.game.shutdown_enabled) << "\n";
|
||||||
|
|
||||||
// Opciones de mandos
|
// Opciones de mandos
|
||||||
file << "\n\n## CONTROLLERS\n";
|
file << "\n\n## CONTROLLERS\n";
|
||||||
@@ -255,6 +257,10 @@ bool setOptions(const std::string &var, const std::string &value)
|
|||||||
{
|
{
|
||||||
options.game.autofire = stringToBool(value);
|
options.game.autofire = stringToBool(value);
|
||||||
}
|
}
|
||||||
|
else if (var == "game.shutdown_enabled")
|
||||||
|
{
|
||||||
|
options.game.shutdown_enabled = stringToBool(value);
|
||||||
|
}
|
||||||
|
|
||||||
// Opciones de mandos
|
// Opciones de mandos
|
||||||
else if (var == "controller.0.name")
|
else if (var == "controller.0.name")
|
||||||
@@ -379,10 +385,10 @@ int getPlayerWhoUsesKeyboard()
|
|||||||
// Aplica los cambios pendientes copiando los valores a sus variables
|
// Aplica los cambios pendientes copiando los valores a sus variables
|
||||||
void applyPendingChanges()
|
void applyPendingChanges()
|
||||||
{
|
{
|
||||||
if (options.pending_changes.has_pending_changes)
|
if (options.pending_changes.has_pending_changes)
|
||||||
{
|
{
|
||||||
options.game.language = options.pending_changes.new_language;
|
options.game.language = options.pending_changes.new_language;
|
||||||
options.game.difficulty = options.pending_changes.new_difficulty;
|
options.game.difficulty = options.pending_changes.new_difficulty;
|
||||||
options.pending_changes.has_pending_changes = false;
|
options.pending_changes.has_pending_changes = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,11 +68,12 @@ struct GameOptions
|
|||||||
GameDifficulty difficulty; // Dificultad del juego
|
GameDifficulty difficulty; // Dificultad del juego
|
||||||
lang::Code language; // Idioma usado en el juego
|
lang::Code language; // Idioma usado en el juego
|
||||||
bool autofire; // Indicador de autofire
|
bool autofire; // Indicador de autofire
|
||||||
|
bool shutdown_enabled; // Especifica si se puede apagar el sistema
|
||||||
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
|
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
|
||||||
std::vector<int> last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla
|
std::vector<int> last_hi_score_entry = {-1, -1}; // Últimas posiciones de entrada en la tabla
|
||||||
|
|
||||||
// Reinicia las últimas entradas de puntuación
|
// Reinicia las últimas entradas de puntuación
|
||||||
void clear_last_hi_score_entries()
|
void clearLastHiScoreEntries()
|
||||||
{
|
{
|
||||||
last_hi_score_entry[0] = -1;
|
last_hi_score_entry[0] = -1;
|
||||||
last_hi_score_entry[1] = -1;
|
last_hi_score_entry[1] = -1;
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ void Resource::renderProgress()
|
|||||||
loading_text_->write(
|
loading_text_->write(
|
||||||
loading_wired_rect_.x,
|
loading_wired_rect_.x,
|
||||||
loading_wired_rect_.y - 9,
|
loading_wired_rect_.y - 9,
|
||||||
"Loading : " + loading_resource_name_
|
lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Renderiza el frame en pantalla
|
// Renderiza el frame en pantalla
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace section
|
|||||||
// --- Enumeraciones de secciones del programa ---
|
// --- Enumeraciones de secciones del programa ---
|
||||||
enum class Name
|
enum class Name
|
||||||
{
|
{
|
||||||
RESET, // Inicialización
|
RESET, // Inicialización
|
||||||
LOGO, // Pantalla de logo
|
LOGO, // Pantalla de logo
|
||||||
INTRO, // Introducción
|
INTRO, // Introducción
|
||||||
TITLE, // Pantalla de título/menú principal
|
TITLE, // Pantalla de título/menú principal
|
||||||
@@ -31,11 +31,9 @@ namespace section
|
|||||||
TITLE_TIME_OUT, // Timeout en el título
|
TITLE_TIME_OUT, // Timeout en el título
|
||||||
TITLE_1, // Opción 1 en el título
|
TITLE_1, // Opción 1 en el título
|
||||||
TITLE_2, // Opción 2 en el título
|
TITLE_2, // Opción 2 en el título
|
||||||
QUIT_WITH_KEYBOARD, // Salir con teclado
|
|
||||||
QUIT_WITH_CONTROLLER, // Salir con mando
|
|
||||||
QUIT_FROM_EVENT, // Salir por evento
|
|
||||||
RELOAD, // Recargar sección
|
RELOAD, // Recargar sección
|
||||||
HI_SCORE_AFTER_PLAYING, // Mostrar récord tras jugar
|
HI_SCORE_AFTER_PLAYING, // Mostrar récord tras jugar
|
||||||
|
SHUTDOWN, // Apagar el sistema
|
||||||
NONE, // Sin opción
|
NONE, // Sin opción
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -263,13 +263,13 @@ void ServiceMenu::selectOption()
|
|||||||
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] QUIT"))
|
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] QUIT"))
|
||||||
{
|
{
|
||||||
section::name = section::Name::QUIT;
|
section::name = section::Name::QUIT;
|
||||||
section::options = section::Options::QUIT_WITH_KEYBOARD;
|
section::options = section::Options::NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] SHUTDOWN"))
|
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] SHUTDOWN"))
|
||||||
{
|
{
|
||||||
section::name = section::Name::QUIT;
|
section::name = section::Name::QUIT;
|
||||||
section::options = section::Options::QUIT_WITH_CONTROLLER;
|
section::options = section::Options::SHUTDOWN;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -327,7 +327,8 @@ void ServiceMenu::initializeOptions()
|
|||||||
// System
|
// System
|
||||||
options_.emplace_back(lang::getText("[SERVICE_MENU] RESET"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
options_.emplace_back(lang::getText("[SERVICE_MENU] RESET"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
||||||
options_.emplace_back(lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
options_.emplace_back(lang::getText("[SERVICE_MENU] QUIT"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
||||||
options_.emplace_back(lang::getText("[SERVICE_MENU] SHUTDOWN"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
if (options.game.shutdown_enabled)
|
||||||
|
options_.emplace_back(lang::getText("[SERVICE_MENU] SHUTDOWN"), SettingsGroup::SYSTEM, OptionBehavior::SELECT, nullptr, ValueType::NONE);
|
||||||
|
|
||||||
// Menu principal
|
// Menu principal
|
||||||
options_.emplace_back(lang::getText("[SERVICE_MENU] VIDEO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::VIDEO);
|
options_.emplace_back(lang::getText("[SERVICE_MENU] VIDEO"), SettingsGroup::MAIN, OptionBehavior::SELECT, SettingsGroup::VIDEO);
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ bool checkCollision(const SDL_FPoint &p, const SDL_FRect &r)
|
|||||||
// Convierte una cadena en un valor booleano
|
// Convierte una cadena en un valor booleano
|
||||||
bool stringToBool(const std::string &str)
|
bool stringToBool(const std::string &str)
|
||||||
{
|
{
|
||||||
return str == "true";
|
std::string s = trim(toLower(str));
|
||||||
|
return (s == "true" || s == "1" || s == "yes" || s == "on");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convierte un valor booleano en una cadena
|
// Convierte un valor booleano en una cadena
|
||||||
|
|||||||
Reference in New Issue
Block a user