Files
jaildoctors_dilemma/source/global_inputs.cpp
Sergio Valor d339fb13b0 Canviades les paletes dels .gif
Ara es poden carregar paletes desde fitxers .pal
Reajustada la pleta general
fix: la pantalla de càrrega deixava un pixel per pintar, desde sempre
Ajustat el color del borde en el Logo i el Title per a ser igual al fondo amb les paletes de 16 colors (la del Spectrum es de 15)
2025-03-06 20:04:53 +01:00

108 lines
3.8 KiB
C++

#include "global_inputs.h"
#include <string> // for basic_string
#include <vector> // for vector
#include "input.h" // for Input, REPEAT_FALSE, inputs_e
#include "notifier.h" // for Notifier
#include "options.h" // for Section, Options, options, SectionState, Optio...
#include "screen.h" // for Screen
#include "utils.h" // for Palette
namespace globalInputs
{
void quit()
{
const std::string code = options.section.section == Section::GAME ? "PRESS AGAIN TO RETURN TO MENU" : "PRESS AGAIN TO EXIT";
auto code_found = stringInVector(Notifier::get()->getCodes(), code);
if (code_found)
{
// Si la notificación de salir está activa, cambia de sección
options.section.section = options.section.section == Section::GAME ? Section::TITLE : Section::QUIT;
}
else
{
// Si la notificación de salir no está activa, muestra la notificación
Notifier::get()->show({code}, NotificationText::CENTER, -1, true, code);
}
}
// Cambia de seccion
void skip_section()
{
switch (options.section.section)
{
case Section::LOGO:
case Section::LOADING_SCREEN:
case Section::CREDITS:
case Section::DEMO:
case Section::GAME_OVER:
case Section::ENDING:
case Section::ENDING2:
options.section.section = Section::TITLE;
options.section.subsection = Subsection::NONE;
break;
default:
break;
}
}
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
void check()
{
if (Input::get()->checkInput(InputAction::EXIT, REPEAT_FALSE))
{
quit();
}
else if (Input::get()->checkInput(InputAction::ACCEPT, REPEAT_FALSE))
{
skip_section();
}
else if (Input::get()->checkInput(InputAction::TOGGLE_BORDER, REPEAT_FALSE))
{
Screen::get()->toggleBorder();
Notifier::get()->show({"BORDER " + std::string(options.video.border.enabled ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
}
else if (Input::get()->checkInput(InputAction::TOGGLE_VIDEOMODE, REPEAT_FALSE))
{
Screen::get()->toggleVideoMode();
Notifier::get()->show({"FULLSCREEN " + std::string(options.video.mode == 0 ? "DISABLED" : "ENABLED")}, NotificationText::CENTER);
}
else if (Input::get()->checkInput(InputAction::WINDOW_DEC_ZOOM, REPEAT_FALSE))
{
if (Screen::get()->decWindowZoom())
{
Notifier::get()->show({"WINDOW ZOOM x" + std::to_string(options.window.zoom)}, NotificationText::CENTER);
}
}
else if (Input::get()->checkInput(InputAction::WINDOW_INC_ZOOM, REPEAT_FALSE))
{
if (Screen::get()->incWindowZoom())
{
Notifier::get()->show({"WINDOW ZOOM x" + std::to_string(options.window.zoom)}, NotificationText::CENTER);
}
}
else if (Input::get()->checkInput(InputAction::TOGGLE_SHADERS, REPEAT_FALSE))
{
Screen::get()->toggleShaders();
Notifier::get()->show({"SHADERS " + std::string(options.video.shaders ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
}
else if (Input::get()->checkInput(InputAction::NEXT_PALETTE, REPEAT_FALSE))
{
Screen::get()->nextPalette();
Notifier::get()->show({"PALETTE " + options.video.palette}, NotificationText::CENTER);
}
else if (Input::get()->checkInput(InputAction::PREVIOUS_PALETTE, REPEAT_FALSE))
{
Screen::get()->previousPalette();
Notifier::get()->show({"PALETTE " + options.video.palette}, NotificationText::CENTER);
}
}
}