Parametritzant colorets de varios llocs
This commit is contained in:
@@ -131,8 +131,15 @@ void Scoreboard::render()
|
||||
// Establece el valor de la variable
|
||||
void Scoreboard::setColor(Color color)
|
||||
{
|
||||
// Actualiza las variables de colores
|
||||
color_ = color;
|
||||
text_color1_ = param.scoreboard.text_autocolor ? color_.lighten(100) : param.scoreboard.text_color1;
|
||||
text_color2_ = param.scoreboard.text_autocolor ? color_.lighten(150) : param.scoreboard.text_color2;
|
||||
|
||||
// Aplica los colores
|
||||
power_meter_sprite_->getTexture()->setColor(text_color2_);
|
||||
fillBackgroundTexture();
|
||||
iniNameColors();
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
@@ -167,25 +174,25 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::SCORE:
|
||||
{
|
||||
// SCORE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, name_[i]);
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
text_scoreboard_->writeDX(TEXT_COLOR | TEXT_CENTER, slot4_1_.x, slot4_1_.y, name_[i], 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_COLOR | TEXT_CENTER, slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]), 1, text_color2_);
|
||||
|
||||
// MULT
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 3"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, "x" + std::to_string(mult_[i]).substr(0, 3));
|
||||
text_scoreboard_->writeDX(TEXT_COLOR | TEXT_CENTER, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 3"), 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_COLOR | TEXT_CENTER, slot4_4_.x, slot4_4_.y, "x" + std::to_string(mult_[i]).substr(0, 3), 1, text_color2_);
|
||||
break;
|
||||
}
|
||||
|
||||
case ScoreboardMode::DEMO:
|
||||
{
|
||||
// DEMO MODE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 6"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 6"), 1, text_color1_);
|
||||
|
||||
// PRESS START TO PLAY
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 8"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 9"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 8"), 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 9"), 1, text_color1_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -193,13 +200,13 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::WAITING:
|
||||
{
|
||||
// GAME OVER
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"), 1, text_color1_);
|
||||
|
||||
// PRESS START TO PLAY
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 8"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 9"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 8"), 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 9"), 1, text_color1_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -207,13 +214,13 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::GAME_OVER:
|
||||
{
|
||||
// GAME OVER
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"), 1, text_color1_);
|
||||
|
||||
// PLEASE WAIT
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 12"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 13"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 12"), 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y - 2, Lang::getText("[SCOREBOARD] 13"), 1, text_color1_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -221,7 +228,7 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::STAGE_INFO:
|
||||
{
|
||||
// STAGE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, Lang::getText("[SCOREBOARD] 5") + std::to_string(stage_));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y, Lang::getText("[SCOREBOARD] 5") + std::to_string(stage_), 1, text_color1_);
|
||||
|
||||
// POWERMETER
|
||||
power_meter_sprite_->setSpriteClip(0, 0, 40, 7);
|
||||
@@ -230,40 +237,40 @@ void Scoreboard::fillPanelTextures()
|
||||
power_meter_sprite_->render();
|
||||
|
||||
// HI-SCORE
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 4"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 4"), 1, text_color1_);
|
||||
const std::string name = hi_score_name_ == "" ? "" : hi_score_name_ + " - ";
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, name + updateScoreText(hi_score_), 1, text_color2_);
|
||||
break;
|
||||
}
|
||||
|
||||
case ScoreboardMode::CONTINUE:
|
||||
{
|
||||
// SCORE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, name_[i]);
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y, name_[i], 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]), 1, text_color2_);
|
||||
|
||||
// CONTINUE
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 10"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y, std::to_string(continue_counter_[i]));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 10"), 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, std::to_string(continue_counter_[i]), 1, text_color2_);
|
||||
break;
|
||||
}
|
||||
|
||||
case ScoreboardMode::ENTER_NAME:
|
||||
{
|
||||
// SCORE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, name_[i]);
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y, name_[i], 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]), 1, text_color2_);
|
||||
|
||||
// ENTER NAME
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 11"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 11"), 1, text_color1_);
|
||||
SDL_FRect rect = {enter_name_pos_.x, enter_name_pos_.y, 5.0f, 7.0f};
|
||||
|
||||
// Recorre todos los slots de letras del nombre
|
||||
for (size_t j = 0; j < NAME_SIZE; ++j)
|
||||
{
|
||||
// Selecciona el color
|
||||
const Color color = j < selector_pos_[i] ? ORANGE_SOFT_COLOR.lighten() : Color(0xFF, 0xFF, 0xEB);
|
||||
const Color color = j < selector_pos_[i] ? text_color2_ : text_color1_;
|
||||
|
||||
if (j != selector_pos_[i] || time_counter_ % 3 == 0)
|
||||
{
|
||||
@@ -288,11 +295,11 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::SHOW_NAME:
|
||||
{
|
||||
// SCORE
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y, name_[i]);
|
||||
text_scoreboard_->writeCentered(slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y, name_[i], 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_2_.x, slot4_2_.y, updateScoreText(score_[i]), 1, text_color2_);
|
||||
|
||||
// NAME
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 11"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y, Lang::getText("[SCOREBOARD] 11"), 1, text_color1_);
|
||||
/* TEXTO CENTRADO */
|
||||
// text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
|
||||
|
||||
@@ -303,13 +310,13 @@ void Scoreboard::fillPanelTextures()
|
||||
case ScoreboardMode::GAME_COMPLETED:
|
||||
{
|
||||
// GAME OVER
|
||||
text_scoreboard_->writeCentered(slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_1_.x, slot4_1_.y + 4, Lang::getText("[SCOREBOARD] 7"), 1, text_color1_);
|
||||
|
||||
// SCORE
|
||||
if (time_counter_ % 10 < 8)
|
||||
{
|
||||
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 14"));
|
||||
text_scoreboard_->writeCentered(slot4_4_.x, slot4_4_.y - 2, updateScoreText(score_[i]));
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_3_.x, slot4_3_.y - 2, Lang::getText("[SCOREBOARD] 14"), 1, text_color1_);
|
||||
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y - 2, updateScoreText(score_[i]), 1, text_color2_);
|
||||
}
|
||||
}
|
||||
default:
|
||||
@@ -366,10 +373,10 @@ void Scoreboard::recalculateAnchors()
|
||||
const int TEXT_HEIGHT = 7;
|
||||
|
||||
// Filas
|
||||
const float ROW1 = (ROW_SIZE * 0) + (TEXT_HEIGHT / 2);
|
||||
const float ROW2 = (ROW_SIZE * 1) + (TEXT_HEIGHT / 2) - 1;
|
||||
const float ROW3 = (ROW_SIZE * 2) + (TEXT_HEIGHT / 2) - 2;
|
||||
const float ROW4 = (ROW_SIZE * 3) + (TEXT_HEIGHT / 2) - 3;
|
||||
const float ROW1 = 1 + (ROW_SIZE * 0) + (TEXT_HEIGHT / 2);
|
||||
const float ROW2 = 1 + (ROW_SIZE * 1) + (TEXT_HEIGHT / 2) - 1;
|
||||
const float ROW3 = 1 + (ROW_SIZE * 2) + (TEXT_HEIGHT / 2) - 2;
|
||||
const float ROW4 = 1 + (ROW_SIZE * 3) + (TEXT_HEIGHT / 2) - 3;
|
||||
|
||||
// Columna
|
||||
const float COL = panel_width / 2;
|
||||
@@ -433,14 +440,15 @@ void Scoreboard::createPanelTextures()
|
||||
void Scoreboard::renderSeparator()
|
||||
{
|
||||
// Dibuja la linea que separa el marcador de la zona de juego
|
||||
SDL_SetRenderDrawColor(renderer_, param.scoreboard.separator_color.r, param.scoreboard.separator_color.g, param.scoreboard.separator_color.b, 255);
|
||||
auto color = param.scoreboard.separator_autocolor ? color_.darken() : param.scoreboard.separator_color;
|
||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 255);
|
||||
SDL_RenderLine(renderer_, 0, 0, rect_.w, 0);
|
||||
}
|
||||
|
||||
// Inicializa el vector de colores para el nombre
|
||||
void Scoreboard::iniNameColors()
|
||||
{
|
||||
Color color = GREEN_COLOR;
|
||||
Color color = color_.inverse();
|
||||
|
||||
name_colors_.clear();
|
||||
name_colors_.emplace_back(color.lighten(50));
|
||||
|
||||
Reference in New Issue
Block a user