canvi de pc

treballant en enter name
This commit is contained in:
2025-02-06 14:59:25 +01:00
parent 3cebee2ae4
commit 44e4ca490d
7 changed files with 33 additions and 18 deletions

View File

@@ -22,7 +22,7 @@ void EnterName::init()
// Pone la lista de indices para que refleje el nombre
updateCharacterIndex();
// Actualiza el nombre para que ocupe 8 espacios
// Actualiza el nombre para que ocupe todos los espacios
updateName();
}
@@ -30,7 +30,7 @@ void EnterName::init()
void EnterName::incPosition()
{
position_++;
position_ = std::min(position_, NAME_LENGHT - 1);
position_ = std::min(position_, NAME_LENGHT);
checkIfPositionHasBeenUsed();
}
@@ -118,7 +118,9 @@ 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();

View File

@@ -1635,7 +1635,7 @@ void Game::handlePlayerContinue(const std::shared_ptr<Player> &player)
input_->checkInput(InputType::FIRE_CENTER, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index) ||
input_->checkInput(InputType::FIRE_RIGHT, INPUT_DO_NOT_ALLOW_REPEAT, options.controllers[controllerIndex].type, options.controllers[controllerIndex].index))
{
if (player->getContinueCounter() < 8)
if (player->getContinueCounter() < 7)
{
player->decContinueCounter();
}

View File

@@ -12,7 +12,7 @@ void ManageHiScoreTable::clear()
table_.clear();
// Añade 10 entradas predefinidas
table_.push_back(HiScoreEntry("BRY", 1000000));
table_.push_back(HiScoreEntry("BRIBON", 1000000));
table_.push_back(HiScoreEntry("USUFON", 500000));
table_.push_back(HiScoreEntry("GLUCAS", 100000));
table_.push_back(HiScoreEntry("PDLGAT", 50000));

View File

@@ -20,7 +20,7 @@ struct HiScoreEntry
// Constructor
explicit HiScoreEntry(const std::string &n = "", int s = 0, bool occ = false)
: name(n.substr(0, 5)), score(s), one_credit_complete(occ) {}
: name(n.substr(0, 6)), score(s), one_credit_complete(occ) {}
};
// Clase ManageHiScoreTable

View File

@@ -226,7 +226,7 @@ public:
int getPosX() const { return static_cast<int>(pos_x_); }
int getPosY() const { return pos_y_; }
int getPowerUpCounter() const { return power_up_counter_; }
std::string getRecordName() const { return enter_name_->getName(); }
std::string getRecordName() const { return enter_name_->getName().substr(0, getRecordNamePos()); }
int getScore() const { return score_; }
int getScoreBoardPanel() const { return scoreboard_panel_; }
int getWidth() const { return WIDTH_; }

View File

@@ -86,11 +86,11 @@ Scoreboard::~Scoreboard()
}
}
// Transforma un valor numérico en una cadena de 6 cifras
// Transforma un valor numérico en una cadena de 7 cifras
std::string Scoreboard::updateScoreText(int num)
{
std::ostringstream oss;
oss << std::setw(8) << std::setfill('0') << num;
oss << std::setw(7) << std::setfill('0') << num;
return oss.str();
}
@@ -150,7 +150,7 @@ void Scoreboard::fillPanelTextures()
// Guarda a donde apunta actualmente el renderizador
auto temp = SDL_GetRenderTarget(renderer_);
// Genera el contenidoi de cada panel_
// Genera el contenido de cada panel_
for (size_t i = 0; i < SCOREBOARD_MAX_PANELS; ++i)
{
// Cambia el destino del renderizador
@@ -253,17 +253,30 @@ void Scoreboard::fillPanelTextures()
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
// ENTER NAME
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
SDL_Rect rect = {enter_name_pos_.x, enter_name_pos_.y, 5, 7};
SDL_SetRenderDrawColor(renderer_, 0xFF, 0xFF, 0xEB, 255);
for (size_t j = 0; j < record_name_[i].size(); ++j)
{
if (j != selector_pos_[i] || counter_ % 3 == 0)
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
SDL_Rect rect = {enter_name_pos_.x, enter_name_pos_.y, 5, 7};
// Recorre el nombre
for (size_t j = 0; j < record_name_[i].size(); ++j)
{
SDL_RenderDrawLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
text_scoreboard_->write(rect.x, rect.y, record_name_[i].substr(j, 1));
// Selecciona el color
const Color color = j < selector_pos_[i] ? orange_soft_color.lighten() : Color(0xFF, 0xFF, 0xEB);
if (j != selector_pos_[i] || counter_ % 3 == 0)
{
// Dibuja la linea
if (j >= selector_pos_[i])
{
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 255);
SDL_RenderDrawLine(renderer_, rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
}
// Dibuja la letra
text_scoreboard_->writeColored(rect.x, rect.y, record_name_[i].substr(j, 1), color);
}
rect.x += 7;
}
rect.x += 7;
}
break;
}

View File

@@ -81,7 +81,7 @@ private:
// Recalcula las anclas de los elementos
void recalculateAnchors();
// Transforma un valor numérico en una cadena de 6 cifras
// Transforma un valor numérico en una cadena de 7 cifras
std::string updateScoreText(int num);
// Crea la textura de fondo