arreglos estetics en ServiceMenu

afegides noves fonts de text
This commit is contained in:
2025-06-03 09:56:41 +02:00
parent 093b775360
commit 7ac0ce9354
11 changed files with 117 additions and 15 deletions

View File

@@ -20,10 +20,10 @@ ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
// Constructor
ServiceMenu::ServiceMenu()
: text_(Resource::get()->getText("04b_25_metal"))
: elementText_(Resource::get()->getText("04b_25_flat")),
titleText_(Resource::get()->getText("04b_25_flat_2x"))
{
constexpr float GAP = 30.0f;
rect_ = {GAP, GAP, param.game.width - GAP * 2, param.game.height - GAP * 2};
setAnchors();
}
void ServiceMenu::toggle()
@@ -35,14 +35,15 @@ void ServiceMenu::render()
{
if (enabled_)
{
constexpr int SEPARATION = 14;
int y = rect_.y;
constexpr int H_PADDING = 20;
constexpr std::array<const char *, 4> MAIN_LIST = {
"VIDEO",
"AUDIO",
"GAME",
"SYSTEM"};
constexpr std::array<const char *, 54> VIDEO_LIST = {
constexpr std::array<const char *, 5> VIDEO_LIST = {
"VIDEO MODE",
"WINDOW SIZE",
"SHADERS",
@@ -64,29 +65,95 @@ void ServiceMenu::render()
"EXIT",
"SHUTDOWN"};
constexpr std::array<const char *, 5> OPTIONS_LIST = {
"FULLSCREEN",
"3",
"OFF",
"ON",
"ON"};
// SOMBRA
SDL_FRect shadowRect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h};
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64);
SDL_RenderFillRect(Screen::get()->getRenderer(), &shadowRect);
// FONDO
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 224);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), bgColor_.r, bgColor_.g, bgColor_.b, 255);
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
// BORDE
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 224, 224, 224, 255);
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), titleColor_.r, titleColor_.g, titleColor_.b, 255);
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
// SERVICE MENU
text_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, rect_.y + SEPARATION, "SERVICE MENU", -2, BLUE_SKY_COLOR.lighten());
y += lineHeight_;
titleText_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, y, "SERVICE MENU", -4, titleColor_);
// LINEA
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BLUE_SKY_COLOR.lighten().r, BLUE_SKY_COLOR.lighten().g, BLUE_SKY_COLOR.lighten().b, 255);
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + 20, rect_.y + SEPARATION * 3, rect_.x + rect_.w - 20, rect_.y + SEPARATION * 3);
y += lineHeight_ * 2;
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), titleColor_.r, titleColor_.g, titleColor_.b, 255);
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + H_PADDING, y, rect_.x + rect_.w - H_PADDING, y);
// LIST
for (size_t i = 0; i < MAIN_LIST.size(); ++i)
for (size_t i = 0; i < VIDEO_LIST.size(); ++i)
{
text_->writeColored(rect_.x + 20, rect_.y + (SEPARATION * 4) + (i * (SEPARATION + SEPARATION * 0.5f)), MAIN_LIST.at(i), BLUE_SKY_COLOR.lighten(100), -2);
y += lineHeight_;
elementText_->writeColored(rect_.x + H_PADDING, y, VIDEO_LIST.at(i), i == selected_ ? selectedColor_ : textColor_, -2);
elementText_->writeColored(rect_.x + H_PADDING + 100, y, ": " + std::string(OPTIONS_LIST.at(i)), i == selected_ ? selectedColor_ : textColor_, -2);
}
}
}
void ServiceMenu::update()
{
if (enabled_)
{
updateCounter();
selectedColor_ = getSelectedColor();
}
}
void ServiceMenu::setAnchors()
{
width_ = 220;
height_ = 200;
lineHeight_ = elementText_->getCharacterSize() + 5;
rect_ = {
(param.game.width - width_) / 2,
(param.game.height - height_) / 2,
static_cast<float>(width_),
static_cast<float>(height_)};
}
void ServiceMenu::updateCounter()
{
static Uint64 lastUpdate = SDL_GetTicks();
Uint64 currentTicks = SDL_GetTicks();
if (currentTicks - lastUpdate >= 50)
{
counter_++;
lastUpdate = currentTicks;
}
}
Color ServiceMenu::getSelectedColor()
{
static std::array<Color, 12> colors = {
Color(0xFF, 0xFF, 0x00), // Amarillo brillante
Color(0xFF, 0xD7, 0x00), // Dorado claro
Color(0xFF, 0xEF, 0x7C), // Amarillo pastel
Color(0xFF, 0xCC, 0x00), // Amarillo anaranjado
Color(0xFF, 0xF7, 0x00), // Amarillo limón
Color(0xCC, 0x99, 0x00), // Mostaza
Color(0xFF, 0xF7, 0x00), // Amarillo limón (regreso)
Color(0xFF, 0xCC, 0x00), // Amarillo anaranjado (regreso)
Color(0xFF, 0xEF, 0x7C), // Amarillo pastel (regreso)
Color(0xFF, 0xD7, 0x00), // Dorado claro (regreso)
Color(0xFF, 0xFF, 0x00), // Amarillo brillante (regreso)
Color(0xCC, 0x99, 0x00) // Mostaza (regreso, cierre)
};
const size_t index = counter_ % colors.size();
return colors.at(index);
}