- treballant en el menu de redefinició de tecles

This commit is contained in:
2024-07-09 06:52:05 +02:00
parent 1e216bfd24
commit 4d91e86178
3 changed files with 38 additions and 5 deletions

View File

@@ -1,5 +1,8 @@
#include "m_menu_tecles.h"
#include "jdraw.h"
#include "jinput.h"
#include "config.h"
#include <SDL2/SDL.h>
namespace modules
{
@@ -14,21 +17,42 @@ namespace modules
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 char *textos[6] = { "AMUNT:", "AVALL:", "ESQUERRA:", "DRETA:", "BOTAR: ", "AGAFAR: " };
static const char *textos[6] = { "AMUNT:", "AVALL:", "ESQUERRA:", "DRETA:", "BOTAR: ", "AGAFAR: " };
for (int i=0; i<6; ++i)
{
draw::print2(i==selected_option?"fg":"de", 13, pos, i==selected_option?YELLOW:TEAL, i==selected_option?FONT_ZOOM_VERTICAL:FONT_ZOOM_NONE);
draw::print2(textos[i], 18, pos, i==selected_option?YELLOW:TEAL, i==selected_option?FONT_ZOOM_VERTICAL:FONT_ZOOM_NONE);
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();