arreglos estetics en ServiceMenu
afegides noves fonts de text
This commit is contained in:
BIN
data/font/04b_25_flat.png
Normal file
BIN
data/font/04b_25_flat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
data/font/04b_25_flat_2x.png
Normal file
BIN
data/font/04b_25_flat_2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
BIN
data/font/04b_25_reversed.png
Normal file
BIN
data/font/04b_25_reversed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
data/font/04b_25_reversed_2x.png
Normal file
BIN
data/font/04b_25_reversed_2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -451,6 +451,10 @@ void Director::setFileList()
|
|||||||
Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT);
|
Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP);
|
Asset::get()->add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
||||||
|
Asset::get()->add(prefix + "/data/font/04b_25_flat.png", AssetType::BITMAP);
|
||||||
|
Asset::get()->add(prefix + "/data/font/04b_25_reversed.png", AssetType::BITMAP);
|
||||||
|
Asset::get()->add(prefix + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP);
|
||||||
|
Asset::get()->add(prefix + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
Asset::get()->add(prefix + "/data/lang/es_ES.txt", AssetType::LANG);
|
Asset::get()->add(prefix + "/data/lang/es_ES.txt", AssetType::LANG);
|
||||||
|
|||||||
@@ -329,6 +329,10 @@ void Resource::createText()
|
|||||||
{"04b_25_2x", "04b_25_2x.png", "04b_25_2x.txt"},
|
{"04b_25_2x", "04b_25_2x.png", "04b_25_2x.txt"},
|
||||||
{"04b_25_metal", "04b_25_metal.png", "04b_25.txt"},
|
{"04b_25_metal", "04b_25_metal.png", "04b_25.txt"},
|
||||||
{"04b_25_grey", "04b_25_grey.png", "04b_25.txt"},
|
{"04b_25_grey", "04b_25_grey.png", "04b_25.txt"},
|
||||||
|
{"04b_25_flat", "04b_25_flat.png", "04b_25.txt"},
|
||||||
|
{"04b_25_reversed", "04b_25_reversed.png", "04b_25.txt"},
|
||||||
|
{"04b_25_flat_2x", "04b_25_flat_2x.png", "04b_25_2x.txt"},
|
||||||
|
{"04b_25_reversed_2x", "04b_25_reversed_2x.png", "04b_25_2x.txt"},
|
||||||
{"8bithud", "8bithud.png", "8bithud.txt"},
|
{"8bithud", "8bithud.png", "8bithud.txt"},
|
||||||
{"smb2", "smb2.gif", "smb2.txt"}};
|
{"smb2", "smb2.gif", "smb2.txt"}};
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ void Screen::update()
|
|||||||
fps_.calculate(SDL_GetTicks());
|
fps_.calculate(SDL_GetTicks());
|
||||||
shake_effect_.update(src_rect_, dst_rect_);
|
shake_effect_.update(src_rect_, dst_rect_);
|
||||||
flash_effect_.update();
|
flash_effect_.update();
|
||||||
|
serviceMenu_->update();
|
||||||
notifier_->update();
|
notifier_->update();
|
||||||
Mouse::updateCursorVisibility();
|
Mouse::updateCursorVisibility();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ServiceMenu::ServiceMenu()
|
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;
|
setAnchors();
|
||||||
rect_ = {GAP, GAP, param.game.width - GAP * 2, param.game.height - GAP * 2};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceMenu::toggle()
|
void ServiceMenu::toggle()
|
||||||
@@ -35,14 +35,15 @@ void ServiceMenu::render()
|
|||||||
{
|
{
|
||||||
if (enabled_)
|
if (enabled_)
|
||||||
{
|
{
|
||||||
constexpr int SEPARATION = 14;
|
int y = rect_.y;
|
||||||
|
constexpr int H_PADDING = 20;
|
||||||
constexpr std::array<const char *, 4> MAIN_LIST = {
|
constexpr std::array<const char *, 4> MAIN_LIST = {
|
||||||
"VIDEO",
|
"VIDEO",
|
||||||
"AUDIO",
|
"AUDIO",
|
||||||
"GAME",
|
"GAME",
|
||||||
"SYSTEM"};
|
"SYSTEM"};
|
||||||
|
|
||||||
constexpr std::array<const char *, 54> VIDEO_LIST = {
|
constexpr std::array<const char *, 5> VIDEO_LIST = {
|
||||||
"VIDEO MODE",
|
"VIDEO MODE",
|
||||||
"WINDOW SIZE",
|
"WINDOW SIZE",
|
||||||
"SHADERS",
|
"SHADERS",
|
||||||
@@ -64,29 +65,95 @@ void ServiceMenu::render()
|
|||||||
"EXIT",
|
"EXIT",
|
||||||
"SHUTDOWN"};
|
"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
|
// 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_);
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||||
|
|
||||||
// BORDE
|
// 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_);
|
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
|
||||||
|
|
||||||
// SERVICE MENU
|
// 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
|
// LINEA
|
||||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BLUE_SKY_COLOR.lighten().r, BLUE_SKY_COLOR.lighten().g, BLUE_SKY_COLOR.lighten().b, 255);
|
y += lineHeight_ * 2;
|
||||||
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + 20, rect_.y + SEPARATION * 3, rect_.x + rect_.w - 20, rect_.y + SEPARATION * 3);
|
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
|
// 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()
|
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);
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
class Text;
|
class Text;
|
||||||
|
|
||||||
@@ -22,9 +23,26 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// -- Variables internas ---
|
// -- Variables internas ---
|
||||||
bool enabled_ = false; // Indica si el menú de servicio está activo
|
bool enabled_ = false; // Indica si el menú de servicio está activo
|
||||||
SDL_FRect rect_; // Rectangulo para definir el area del menú de servicio
|
SDL_FRect rect_; // Rectangulo para definir el area del menú de servicio
|
||||||
std::shared_ptr<Text> text_; // Objeto para escribir texto;
|
std::shared_ptr<Text> elementText_; // Objeto para escribir texto;
|
||||||
|
std::shared_ptr<Text> titleText_; // Objeto para escribir texto;
|
||||||
|
size_t selected_ = 2; // Elemento del menú seleccionado
|
||||||
|
Uint32 counter_ = 0; // Contador interno
|
||||||
|
|
||||||
|
// -- Aspecto --
|
||||||
|
Color bgColor_ = SERV_MENU_BG_COLOR; // Color de fondo
|
||||||
|
Color titleColor_ = SERV_MENU_TITLE_COLOR; // Color del título del menu
|
||||||
|
Color textColor_ = SERV_MENU_TEXT_COLOR; // Color para el texto de los elementos
|
||||||
|
Color selectedColor_ = SERV_MENU_SELECTED_COLOR; // Color para el elemento seleccionado
|
||||||
|
int width_; // Ancho del menú
|
||||||
|
int height_; // Alto del menu
|
||||||
|
int lineHeight_; // Espacio entre elementos del menu
|
||||||
|
|
||||||
|
// -- Métodos internos ---
|
||||||
|
void setAnchors(); // Establece el valor de las variables de anclaje
|
||||||
|
void updateCounter(); // Actualiza el contador interno
|
||||||
|
Color getSelectedColor(); // Devuelve el color del elemento seleccionado
|
||||||
|
|
||||||
// --- Patrón Singleton ---
|
// --- Patrón Singleton ---
|
||||||
ServiceMenu(); // Constructor privado
|
ServiceMenu(); // Constructor privado
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ const Color GREEN_COLOR = Color(0X5B, 0XEC, 0X95);
|
|||||||
const Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1);
|
const Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1);
|
||||||
const Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97);
|
const Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97);
|
||||||
const Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B);
|
const Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B);
|
||||||
|
const Color SERV_MENU_TITLE_COLOR = Color(0XFF, 0XFF, 0XFF);
|
||||||
|
const Color SERV_MENU_TEXT_COLOR = Color(0XFF, 0XFF, 0XFF);
|
||||||
|
const Color SERV_MENU_SELECTED_COLOR = Color(0XFF, 0XFF, 0X00);;
|
||||||
|
const Color SERV_MENU_BG_COLOR = Color(0x1E, 0x1E, 0x1E);
|
||||||
|
|
||||||
// Obtiene un color del vector de colores imitando al Coche Fantástico
|
// Obtiene un color del vector de colores imitando al Coche Fantástico
|
||||||
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_)
|
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_)
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ extern const Color GREEN_COLOR;
|
|||||||
extern const Color BLUE_SKY_COLOR;
|
extern const Color BLUE_SKY_COLOR;
|
||||||
extern const Color PINK_SKY_COLOR;
|
extern const Color PINK_SKY_COLOR;
|
||||||
extern const Color GREEN_SKY_COLOR;
|
extern const Color GREEN_SKY_COLOR;
|
||||||
|
extern const Color SERV_MENU_TITLE_COLOR;
|
||||||
|
extern const Color SERV_MENU_TEXT_COLOR;
|
||||||
|
extern const Color SERV_MENU_SELECTED_COLOR;
|
||||||
|
extern const Color SERV_MENU_BG_COLOR;
|
||||||
|
|
||||||
// Colores y gráficos
|
// Colores y gráficos
|
||||||
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_);
|
Color getColorLikeKnightRider(const std::vector<Color> &colors, int counter_);
|
||||||
|
|||||||
Reference in New Issue
Block a user