Treballant en globalInputs::update()
This commit is contained in:
@@ -91,6 +91,7 @@ void Credits::update()
|
|||||||
}
|
}
|
||||||
updateAllFades();
|
updateAllFades();
|
||||||
Screen::get()->update();
|
Screen::get()->update();
|
||||||
|
globalInputs::update();
|
||||||
++counter_;
|
++counter_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ void Director::init()
|
|||||||
bindInputs();
|
bindInputs();
|
||||||
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
||||||
OnScreenHelp::init();
|
OnScreenHelp::init();
|
||||||
globalInputs::init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cierra todo
|
// Cierra todo
|
||||||
|
|||||||
@@ -14,18 +14,8 @@
|
|||||||
namespace globalInputs
|
namespace globalInputs
|
||||||
{
|
{
|
||||||
// Variables
|
// Variables
|
||||||
std::vector<int> service_pressed_counter;
|
int service_pressed_counter = 0;
|
||||||
|
bool service_pressed = false;
|
||||||
// Inicializa variables
|
|
||||||
void init()
|
|
||||||
{
|
|
||||||
const auto num_inputs = Input::get()->getNumControllers() + 1;
|
|
||||||
service_pressed_counter.reserve(num_inputs);
|
|
||||||
for (int i = 0; i < num_inputs; ++i)
|
|
||||||
{
|
|
||||||
service_pressed_counter.push_back(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Termina
|
// Termina
|
||||||
void quit(section::Options code)
|
void quit(section::Options code)
|
||||||
@@ -34,11 +24,13 @@ namespace globalInputs
|
|||||||
auto code_found = stringInVector(Notifier::get()->getCodes(), exit_code);
|
auto code_found = stringInVector(Notifier::get()->getCodes(), exit_code);
|
||||||
if (code_found)
|
if (code_found)
|
||||||
{
|
{
|
||||||
|
// 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 = code;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Si la notificación de salir no está activa, muestra la notificación
|
||||||
#ifdef ARCADE
|
#ifdef ARCADE
|
||||||
const int index = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
|
const int index = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
|
||||||
Notifier::get()->showText({lang::getText(index), std::string()}, -1, exit_code);
|
Notifier::get()->showText({lang::getText(index), std::string()}, -1, exit_code);
|
||||||
@@ -87,7 +79,6 @@ namespace globalInputs
|
|||||||
return Asset::get()->get("en_UK.txt");
|
return Asset::get()->get("en_UK.txt");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene una cadena a partir de un lang::Code
|
// Obtiene una cadena a partir de un lang::Code
|
||||||
@@ -195,17 +186,9 @@ namespace globalInputs
|
|||||||
// OnScreenHelp
|
// OnScreenHelp
|
||||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||||
{
|
{
|
||||||
service_pressed_counter[0]++;
|
service_pressed = true;
|
||||||
|
|
||||||
if (service_pressed_counter[0] >= 3000)
|
|
||||||
{
|
|
||||||
OnScreenHelp::get()->toggleState();
|
|
||||||
service_pressed_counter[0] = 0;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
service_pressed_counter[0] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mandos
|
// Mandos
|
||||||
@@ -255,18 +238,30 @@ namespace globalInputs
|
|||||||
// OnScreenHelp
|
// OnScreenHelp
|
||||||
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
if (Input::get()->checkInput(InputType::SERVICE, INPUT_ALLOW_REPEAT, InputDeviceToUse::CONTROLLER, i))
|
||||||
{
|
{
|
||||||
service_pressed_counter[i + 1]++;
|
service_pressed = true;
|
||||||
|
|
||||||
if (service_pressed_counter[i + 1] >= 3000)
|
|
||||||
{
|
|
||||||
OnScreenHelp::get()->toggleState();
|
|
||||||
service_pressed_counter[i + 1] = 0;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
service_pressed_counter[i + 1] = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actualiza variables
|
||||||
|
void update()
|
||||||
|
{
|
||||||
|
if (service_pressed)
|
||||||
|
{
|
||||||
|
++service_pressed_counter;
|
||||||
|
if (service_pressed_counter >= 3000)
|
||||||
|
{
|
||||||
|
OnScreenHelp::get()->toggleState();
|
||||||
|
service_pressed_counter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
service_pressed_counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
service_pressed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
namespace globalInputs
|
namespace globalInputs
|
||||||
{
|
{
|
||||||
extern std::vector<int> service_pressed_counter;
|
extern int service_pressed_counter;
|
||||||
|
extern bool service_pressed;
|
||||||
// Inicializa variables
|
|
||||||
void init();
|
|
||||||
|
|
||||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||||
void check();
|
void check();
|
||||||
|
|
||||||
|
// Actualiza variables
|
||||||
|
void update();
|
||||||
}
|
}
|
||||||
@@ -392,7 +392,7 @@ void Screen::renderInfo()
|
|||||||
dbg_print(0, 0, info_resolution_.c_str(), 255, 255, 0);
|
dbg_print(0, 0, info_resolution_.c_str(), 255, 255, 0);
|
||||||
|
|
||||||
// Contador de service_pressed_counter
|
// Contador de service_pressed_counter
|
||||||
if (const int counter = globalInputs::service_pressed_counter[0]; counter > 0)
|
if (const int counter = globalInputs::service_pressed_counter; counter > 0)
|
||||||
dbg_print(0, 8, std::to_string(counter).c_str(), 255, 0, 255);
|
dbg_print(0, 8, std::to_string(counter).c_str(), 255, 0, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
int fps_ = 0; // Frames calculados en el último segundo
|
int fps_ = 0; // Frames calculados en el último segundo
|
||||||
std::string info_resolution_; // Texto con la informacion de la pantalla
|
std::string info_resolution_; // Texto con la informacion de la pantalla
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool show_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
bool show_info_ = true; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||||
#else
|
#else
|
||||||
bool show_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
bool show_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user