83 lines
2.2 KiB
C++
83 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <SDL2/SDL.h>
|
|
#include "common/asset.h"
|
|
#include "common/screen.h"
|
|
#include "common/utils.h"
|
|
#include "common/text.h"
|
|
#include "common/texture.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#ifndef ENTER_ID_H
|
|
#define ENTER_ID_H
|
|
|
|
class EnterID
|
|
{
|
|
private:
|
|
struct captions_t
|
|
{
|
|
std::string label; // Texto a escribir
|
|
color_t color; // Color del texto
|
|
};
|
|
|
|
// Punteros y objetos
|
|
Asset *asset; // Objeto con los ficheros de recursos
|
|
options_t *options; // Puntero a las opciones del juego
|
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
|
SDL_Event *eventHandler; // Manejador de eventos
|
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
|
SDL_Texture *textTexture; // Textura para dibujar el texto
|
|
Text *text; // Objeto para escribir texto en pantalla
|
|
Texture *texture; // Textura para la fuente para el texto
|
|
section_t *section; // Estado del bucle principal para saber si continua o se sale
|
|
|
|
// Variables
|
|
bool loopRunning; // Indica si ha de terminar el bucle principal
|
|
int counter; // Contador
|
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
|
std::vector<captions_t> texts; // Vector con los textos
|
|
std::string cursor; // Contiene el caracter que se muestra como cursor
|
|
|
|
char name[15]; // Aqui se guardan los caracteres de las teclas que se van pulsando
|
|
int pos; // Posición actual en el vector name
|
|
int maxLenght; // Tamaño máximo del jailerID
|
|
|
|
// Actualiza las variables
|
|
void update();
|
|
|
|
// Dibuja en pantalla
|
|
void render();
|
|
|
|
// Comprueba el manejador de eventos
|
|
void checkEvents();
|
|
|
|
// Inicializa los textos
|
|
void iniTexts();
|
|
|
|
// Escribe el texto en la textura
|
|
void fillTexture();
|
|
|
|
// Inicializa los servicios online
|
|
void initOnline();
|
|
|
|
// Termina la sección
|
|
void endSection();
|
|
|
|
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
|
|
void initName();
|
|
|
|
public:
|
|
// Constructor
|
|
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
|
|
|
|
// Destructor
|
|
~EnterID();
|
|
|
|
// Bucle principal
|
|
void run();
|
|
};
|
|
|
|
#endif
|