Ja duplica la ultima lletra al posar el nom
This commit is contained in:
@@ -15,7 +15,7 @@ void EnterName::init()
|
||||
|
||||
// Inicia la lista de caracteres permitidos
|
||||
character_list_ = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-+-*/=?¿<>!\"#$%&/()";
|
||||
pos_ = 0;
|
||||
position_ = 0;
|
||||
num_characters_ = (int)character_list_.size();
|
||||
|
||||
// Pone la lista de indices para que refleje el nombre
|
||||
@@ -26,26 +26,27 @@ void EnterName::init()
|
||||
}
|
||||
|
||||
// Incrementa la posición
|
||||
void EnterName::incPos()
|
||||
void EnterName::incPosition()
|
||||
{
|
||||
pos_++;
|
||||
pos_ = std::min(pos_, NAME_LENGHT - 1);
|
||||
position_++;
|
||||
position_ = std::min(position_, NAME_LENGHT - 1);
|
||||
checkIfPositionHasBeenUsed();
|
||||
}
|
||||
|
||||
// Decrementa la posición
|
||||
void EnterName::decPos()
|
||||
void EnterName::decPosition()
|
||||
{
|
||||
pos_--;
|
||||
pos_ = std::max(pos_, 0);
|
||||
position_--;
|
||||
position_ = std::max(position_, 0);
|
||||
}
|
||||
|
||||
// Incrementa el índice
|
||||
void EnterName::incIndex()
|
||||
{
|
||||
++character_index_[pos_];
|
||||
if (character_index_[pos_] >= num_characters_)
|
||||
++character_index_[position_];
|
||||
if (character_index_[position_] >= num_characters_)
|
||||
{
|
||||
character_index_[pos_] = 0;
|
||||
character_index_[position_] = 0;
|
||||
}
|
||||
updateName();
|
||||
}
|
||||
@@ -53,15 +54,15 @@ void EnterName::incIndex()
|
||||
// Decrementa el índice
|
||||
void EnterName::decIndex()
|
||||
{
|
||||
--character_index_[pos_];
|
||||
if (character_index_[pos_] < 0)
|
||||
--character_index_[position_];
|
||||
if (character_index_[position_] < 0)
|
||||
{
|
||||
character_index_[pos_] = num_characters_ - 1;
|
||||
character_index_[position_] = num_characters_ - 1;
|
||||
}
|
||||
updateName();
|
||||
}
|
||||
|
||||
// Actualiza la variable
|
||||
// Actualiza el nombre a partir de la lista de índices
|
||||
void EnterName::updateName()
|
||||
{
|
||||
name_.clear();
|
||||
@@ -74,16 +75,18 @@ void EnterName::updateName()
|
||||
// Actualiza la variable
|
||||
void EnterName::updateCharacterIndex()
|
||||
{
|
||||
// Rellena de espacios
|
||||
// Rellena de espacios y marca como no usados
|
||||
for (int i = 0; i < NAME_LENGHT; ++i)
|
||||
{
|
||||
character_index_[i] = 0;
|
||||
position_has_been_used_[i] = false;
|
||||
}
|
||||
|
||||
// Coloca los índices en funcion de los caracteres que forman el nombre
|
||||
for (int i = 0; i < (int)name_.size(); ++i)
|
||||
{
|
||||
character_index_[i] = findIndex(name_.at(i));
|
||||
position_has_been_used_[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +110,21 @@ std::string EnterName::getName() const
|
||||
}
|
||||
|
||||
// Obtiene la posición que se está editando
|
||||
int EnterName::getPos() const
|
||||
int EnterName::getPosition() const
|
||||
{
|
||||
return pos_;
|
||||
return position_;
|
||||
}
|
||||
|
||||
// Comprueba la posición y copia el caracter si es necesario
|
||||
void EnterName::checkIfPositionHasBeenUsed()
|
||||
{
|
||||
auto used = position_has_been_used_[position_];
|
||||
|
||||
if (!used && position_ > 0)
|
||||
{
|
||||
character_index_[position_] = character_index_[position_ - 1];
|
||||
}
|
||||
|
||||
position_has_been_used_[position_] = true;
|
||||
updateName();
|
||||
}
|
||||
Reference in New Issue
Block a user