EnterID ya recibe bien el JailerID en caso de tenerlo ya definido previamente
This commit is contained in:
@@ -35,9 +35,7 @@ EnterID::EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t
|
|||||||
counter = 0;
|
counter = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
pos = 0;
|
initName();
|
||||||
name[pos] = 0;
|
|
||||||
maxLenght = 15;
|
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
fillTexture();
|
fillTexture();
|
||||||
@@ -287,3 +285,36 @@ void EnterID::endSection()
|
|||||||
loopRunning = false;
|
loopRunning = false;
|
||||||
initOnline();
|
initOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
|
||||||
|
void EnterID::initName()
|
||||||
|
{
|
||||||
|
std::cout << options->online.jailerID << std::endl;
|
||||||
|
|
||||||
|
// Calcula el tamaño del vector
|
||||||
|
name[0] = 0;
|
||||||
|
maxLenght = sizeof(name) / sizeof(name[pos]);
|
||||||
|
|
||||||
|
// Inicializa el vector con ceros
|
||||||
|
for (int i = 0; i < maxLenght; ++i)
|
||||||
|
{
|
||||||
|
name[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si no hay definido ningun JailerID, coloca el cursor en primera posición
|
||||||
|
if (options->online.jailerID == "")
|
||||||
|
{
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// En caso contrario, copia el texto al vector y coloca el cursor en posición
|
||||||
|
const int len = std::min((int)options->online.jailerID.size(), maxLenght);
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
name[i] = (char)options->online.jailerID[i];
|
||||||
|
}
|
||||||
|
pos = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << (std::string)name << std::endl;
|
||||||
|
}
|
||||||
@@ -40,8 +40,8 @@ private:
|
|||||||
std::vector<captions_t> texts; // Vector con los textos
|
std::vector<captions_t> texts; // Vector con los textos
|
||||||
std::string cursor; // Contiene el caracter que se muestra como cursor
|
std::string cursor; // Contiene el caracter que se muestra como cursor
|
||||||
|
|
||||||
char name[15];
|
char name[15]; // Aqui se guardan los caracteres de las teclas que se van pulsando
|
||||||
int pos;
|
int pos; // Posición actual en el vector name
|
||||||
int maxLenght; // Tamaño máximo del jailerID
|
int maxLenght; // Tamaño máximo del jailerID
|
||||||
|
|
||||||
// Actualiza las variables
|
// Actualiza las variables
|
||||||
@@ -65,6 +65,9 @@ private:
|
|||||||
// Termina la sección
|
// Termina la sección
|
||||||
void endSection();
|
void endSection();
|
||||||
|
|
||||||
|
// Inicializa el vector utilizado para almacenar el texto que se escribe en pantalla
|
||||||
|
void initName();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
|
EnterID(SDL_Renderer *renderer, Screen *screen, Asset *asset, options_t *options, section_t *section);
|
||||||
|
|||||||
@@ -699,7 +699,6 @@ void Title::checkEvents()
|
|||||||
switch (eventHandler->key.keysym.scancode)
|
switch (eventHandler->key.keysym.scancode)
|
||||||
{
|
{
|
||||||
case SDL_SCANCODE_A:
|
case SDL_SCANCODE_A:
|
||||||
std::cout << "PULSA A" << std::endl;
|
|
||||||
runEnterID();
|
runEnterID();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user