Retocat un poc el disseny de Title

Retocades les notificacions
This commit is contained in:
2025-03-06 23:12:53 +01:00
parent ff309168ef
commit 9eaf3bc134
4 changed files with 17 additions and 14 deletions

View File

@@ -183,12 +183,14 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
}
// Inicializa variables
const auto PADDING_IN_H = text_->getCharacterSize();
const auto PADDING_IN_V = text_->getCharacterSize() / 2;
//const int text_size = text_->getCharacterSize();
const int text_size = 6;
const auto PADDING_IN_H = text_size;
const auto PADDING_IN_V = text_size / 2;
const int ICON_SPACE = icon >= 0 ? ICON_SIZE_ + PADDING_IN_H : 0;
text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is;
const int WIDTH = options.game.width - (PADDING_OUT_ * 2);
const int HEIGHT = (text_->getCharacterSize() * texts.size()) + (PADDING_IN_V * 2);
const int HEIGHT = (text_size * texts.size()) + (PADDING_IN_V * 2);
const auto SHAPE = NotificationShape::SQUARED;
// Posición horizontal
@@ -237,7 +239,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
n.surface = std::make_shared<Surface>(WIDTH, HEIGHT);
// Prepara para dibujar en la textura
auto previuos_renderer = Screen::get()->getRendererSurface();
auto previuos_renderer = Screen::get()->getRendererSurface();
Screen::get()->setRendererSurface(n.surface);
// Dibuja el fondo de la notificación
@@ -260,6 +262,8 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
else if (SHAPE == NotificationShape::SQUARED)
{
n.surface->clear(bg_color_);
SDL_Rect rect = {0, 0, n.surface->getWidth(), n.surface->getHeight()};
n.surface->drawRectBorder(&rect, static_cast<Uint8>(PaletteColor::RED));
}
// Dibuja el icono de la notificación
@@ -272,17 +276,17 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
}
// Escribe el texto de la notificación
const Uint8 COLOR = stringToColor("white");
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::WHITE);
int iterator = 0;
for (const auto &text : texts)
{
switch (text_is)
{
case NotificationText::LEFT:
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, COLOR);
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_size + 1), text, COLOR);
break;
case NotificationText::CENTER:
text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, 1, COLOR);
text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + iterator * (text_size + 1), text, 1, COLOR);
break;
default:
break;

View File

@@ -140,7 +140,7 @@ void Title::checkInput()
// Actualiza la marquesina
void Title::updateMarquee()
{
const auto TEXT = Resource::get()->getText("smb2");
const auto TEXT = Resource::get()->getText("gauntlet");
for (int i = 0; i < (int)letters_.size(); ++i)
{
@@ -172,12 +172,12 @@ void Title::updateMarquee()
// Dibuja la marquesina
void Title::renderMarquee()
{
const auto TEXT = Resource::get()->getText("smb2");
const auto TEXT = Resource::get()->getText("gauntlet");
for (const auto &l : letters_)
{
if (l.enabled)
{
TEXT->writeColored(l.x, 184, l.letter, stringToColor("white"));
TEXT->writeColored(l.x, 184, l.letter, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
}
}
}
@@ -327,8 +327,7 @@ void Title::fillSurface()
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 11 * TEXT_SIZE, "1.PLAY", 1, COLOR);
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 13 * TEXT_SIZE, "2.ACHIEVEMENTS", 1, COLOR);
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 15 * TEXT_SIZE, "3.REDEFINE KEYS", 1, COLOR);
text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * TEXT_SIZE, "ESC.EXIT GAME", 1, COLOR);
text->writeColored(PLAY_AREA_CENTER_X, 30 * TEXT_SIZE, "ESC.EXIT GAME", COLOR);
//text->writeDX(TEXT_CENTER | TEXT_COLOR, PLAY_AREA_CENTER_X, 20 * TEXT_SIZE, "ESC.EXIT GAME", 1, COLOR);
// Devuelve el puntero del renderizador a su sitio
Screen::get()->setRendererSurface(previuos_renderer);
@@ -341,7 +340,7 @@ void Title::createCheevosTexture()
const auto CHEEVOS_LIST = Cheevos::get()->list();
const auto TEXT = Resource::get()->getText("subatomic");
constexpr int CHEEVOS_TEXTURE_WIDTH = 200;
constexpr int CHEEVOS_TEXTURE_VIEW_HEIGHT = 110;
constexpr int CHEEVOS_TEXTURE_VIEW_HEIGHT = 110 - 8;
constexpr int CHEEVOS_TEXTURE_POS_Y = 73;
constexpr int CHEEVOS_PADDING = 10;
const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (TEXT->getCharacterSize() * 2) + 1;

View File

@@ -39,7 +39,7 @@ private:
std::string long_text_; // Texto que aparece en la parte inferior del titulo
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
std::vector<TitleLetter> letters_; // Vector con las letras de la marquesina
int marquee_speed_ = 3; // Velocidad de desplazamiento de la marquesina
int marquee_speed_ = 2; // Velocidad de desplazamiento de la marquesina
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
SDL_Rect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
TitleState state_; // Estado en el que se encuentra el bucle principal