Files
thepool/source/m_menu_tecles.cpp

63 lines
2.4 KiB
C++

#include "m_menu_tecles.h"
#include "jdraw.h"
#include "jinput.h"
#include "config.h"
#include <SDL2/SDL.h>
namespace modules
{
namespace menu_tecles
{
int selected_option = MENU_TECLES_AMUNT;
void init()
{
selected_option = MENU_TECLES_AMUNT;
}
int loop()
{
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
return MENU_TECLES_TORNAR;
}
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
{ selected_option++; if (selected_option>6) selected_option=0; }
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
{ selected_option--; if (selected_option<0) selected_option=6; }
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
//if (selected_option==MENU_AUDIO_MUSICA) config::toggleMusic();
//if (selected_option==MENU_AUDIO_SO) config::toggleSound();
if (selected_option==MENU_TECLES_TORNAR) return MENU_TECLES_TORNAR;
}
draw::cls(2);
draw::color(1);
draw::print2("REDEFINIR TECLES", 13, 3, YELLOW, FONT_ZOOM_VERTICAL);
int pos = 10;
static const char *textos[6] = { "AMUNT:", "AVALL:", "ESQUERRA:", "DRETA:", "BOTAR: ", "AGAFAR: " };
for (int i=0; i<6; ++i)
{
const bool selected = (i==selected_option);
draw::print2(selected?"fg":"de", 13, pos, selected?YELLOW:TEAL, selected?FONT_ZOOM_VERTICAL:FONT_ZOOM_NONE);
draw::print2(textos[i], 18, pos, selected?YELLOW:TEAL, selected?FONT_ZOOM_VERTICAL:FONT_ZOOM_NONE);
pos += selected?3:2;
}
const bool selected = (selected_option==MENU_TECLES_TORNAR);
draw::print2(selected?"fg":"de", 13, pos, selected?YELLOW:TEAL, selected?FONT_ZOOM_VERTICAL:FONT_ZOOM_NONE);
draw::print2("TORNAR", 18, pos, selected?YELLOW:TEAL, selected?FONT_ZOOM_VERTICAL:FONT_ZOOM_NONE);
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);
draw::render();
return MENU_TECLES_NONE;
}
}
}