ServiceMenu: el aspecte es defineix en param.h
This commit is contained in:
@@ -3,34 +3,15 @@
|
||||
#include "menu_option.h" // Necesario para acceder a las opciones
|
||||
#include "screen.h" // Para param
|
||||
#include <array>
|
||||
#include "param.h"
|
||||
|
||||
MenuRenderer::MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr<Text> element_text, std::shared_ptr<Text> title_text)
|
||||
: element_text_(std::move(element_text)), title_text_(std::move(title_text)) { init(menu_state); }
|
||||
|
||||
void MenuRenderer::init(const ServiceMenu *menu_state)
|
||||
{
|
||||
aspect_ = menu_state->getAspect();
|
||||
switch (aspect_)
|
||||
{
|
||||
case ServiceMenu::Aspect::SHADOW:
|
||||
bg_color_ = SERV_MENU_BG_COLOR_SHADOW;
|
||||
bg_alpha_ = 255;
|
||||
break;
|
||||
|
||||
case ServiceMenu::Aspect::ALPHA:
|
||||
bg_color_ = SERV_MENU_BG_COLOR_ALPHA;
|
||||
bg_alpha_ = 240;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
: element_text_(std::move(element_text)), title_text_(std::move(title_text)) {}
|
||||
|
||||
void MenuRenderer::render(const ServiceMenu *menu_state)
|
||||
{
|
||||
// Dibuja la sombra
|
||||
if (aspect_ == ServiceMenu::Aspect::SHADOW)
|
||||
if (param.service_menu.drop_shadow)
|
||||
{
|
||||
SDL_FRect shadowRect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h};
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64);
|
||||
@@ -38,18 +19,18 @@ void MenuRenderer::render(const ServiceMenu *menu_state)
|
||||
}
|
||||
|
||||
// Dibuja el fondo
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), bg_color_.r, bg_color_.g, bg_color_.b, bg_alpha_);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), param.service_menu.bg_color.r, param.service_menu.bg_color.g, param.service_menu.bg_color.b, param.service_menu.bg_color.a);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||
|
||||
// Dibuja el borde
|
||||
const Color BORDER_COLOR = title_color_.darken();
|
||||
const Color BORDER_COLOR = param.service_menu.title_color.darken();
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BORDER_COLOR.r, BORDER_COLOR.g, BORDER_COLOR.b, 255);
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &border_rect_);
|
||||
|
||||
// Dibuja el título
|
||||
float y = rect_.y + title_padding_;
|
||||
title_text_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, y, menu_state->getTitle(), -4, title_color_);
|
||||
title_text_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, y, menu_state->getTitle(), -4, param.service_menu.title_color);
|
||||
|
||||
// Dibuja la línea separadora
|
||||
y = rect_.y + upper_height_;
|
||||
@@ -62,7 +43,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state)
|
||||
for (size_t i = 0; i < option_pairs.size(); ++i)
|
||||
{
|
||||
const bool is_selected = (i == menu_state->getSelectedIndex());
|
||||
const Color ¤t_color = is_selected ? selected_color_ : text_color_;
|
||||
const Color ¤t_color = is_selected ? param.service_menu.selected_color : param.service_menu.text_color;
|
||||
|
||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT)
|
||||
{
|
||||
@@ -85,7 +66,7 @@ void MenuRenderer::update(const ServiceMenu *menu_state)
|
||||
updateResizeAnimation();
|
||||
}
|
||||
updateColorCounter();
|
||||
selected_color_ = getAnimatedSelectedColor();
|
||||
param.service_menu.selected_color = getAnimatedSelectedColor();
|
||||
}
|
||||
|
||||
void MenuRenderer::onLayoutChanged(const ServiceMenu *menu_state)
|
||||
@@ -231,7 +212,7 @@ void MenuRenderer::updateColorCounter()
|
||||
|
||||
Color MenuRenderer::getAnimatedSelectedColor()
|
||||
{
|
||||
static auto colorCycle = generateMirroredCycle(SERV_MENU_SELECTED_COLOR, ColorCycleStyle::HueWave);
|
||||
static auto colorCycle = generateMirroredCycle(param.service_menu.selected_color, ColorCycleStyle::HueWave);
|
||||
return colorCycle.at(color_counter_ % colorCycle.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "ui/service_menu.h" // Necesario para las enums y para acceder al estado del menú
|
||||
#include "utils.h" // Para Color
|
||||
|
||||
|
||||
// Forward declarations
|
||||
class Text;
|
||||
class MenuOption;
|
||||
@@ -33,14 +34,8 @@ private:
|
||||
std::shared_ptr<Text> title_text_;
|
||||
|
||||
// --- Variables de estado de la vista (layout y animación) ---
|
||||
ServiceMenu::Aspect aspect_ = ServiceMenu::Aspect::ALPHA;
|
||||
SDL_FRect rect_{};
|
||||
SDL_FRect border_rect_{};
|
||||
Color bg_color_ = SERV_MENU_BG_COLOR_ALPHA;
|
||||
Uint8 bg_alpha_ = 240;
|
||||
Color title_color_ = SERV_MENU_TITLE_COLOR;
|
||||
Color text_color_ = SERV_MENU_TEXT_COLOR;
|
||||
Color selected_color_ = SERV_MENU_SELECTED_COLOR;
|
||||
size_t width_ = 0;
|
||||
size_t height_ = 0;
|
||||
size_t options_height_ = 0;
|
||||
@@ -64,7 +59,6 @@ private:
|
||||
int group_menu_widths_[5]{};
|
||||
|
||||
// --- Métodos privados de la vista ---
|
||||
void init(const ServiceMenu *menu_state);
|
||||
void setAnchors(const ServiceMenu *menu_state);
|
||||
SDL_FRect calculateNewRect(const ServiceMenu *menu_state);
|
||||
void resize(const ServiceMenu *menu_state);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "section.h"
|
||||
#include "screen.h"
|
||||
#include "asset.h"
|
||||
#include "param.h"
|
||||
|
||||
// Singleton
|
||||
ServiceMenu *ServiceMenu::instance_ = nullptr;
|
||||
@@ -22,7 +23,7 @@ ServiceMenu::ServiceMenu()
|
||||
auto title_text = Resource::get()->getText("04b_25_flat_2x");
|
||||
|
||||
renderer_ = std::make_unique<MenuRenderer>(this, element_text, title_text);
|
||||
restart_message_ui_ = std::make_unique<UIMessage>(element_text, Lang::getText("[SERVICE_MENU] NEED_RESTART_MESSAGE"), SERV_MENU_TITLE_COLOR);
|
||||
restart_message_ui_ = std::make_unique<UIMessage>(element_text, Lang::getText("[SERVICE_MENU] NEED_RESTART_MESSAGE"), param.service_menu.title_color);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -15,11 +15,6 @@ class MenuRenderer; // <-- Nuevo
|
||||
class ServiceMenu
|
||||
{
|
||||
public:
|
||||
enum class Aspect
|
||||
{
|
||||
SHADOW,
|
||||
ALPHA
|
||||
};
|
||||
enum class SettingsGroup
|
||||
{
|
||||
VIDEO,
|
||||
@@ -28,6 +23,7 @@ public:
|
||||
SYSTEM,
|
||||
MAIN
|
||||
};
|
||||
|
||||
enum class GroupAlignment
|
||||
{
|
||||
CENTERED,
|
||||
@@ -65,7 +61,6 @@ public:
|
||||
size_t getSelectedIndex() const { return selected_; }
|
||||
const std::vector<std::pair<std::string, std::string>> &getOptionPairs() const { return option_pairs_; }
|
||||
size_t countOptionsInGroup(SettingsGroup group) const;
|
||||
Aspect getAspect() const { return aspect_; }
|
||||
|
||||
private:
|
||||
// --- Lógica de estado del menú (Modelo) ---
|
||||
@@ -76,7 +71,6 @@ private:
|
||||
|
||||
SettingsGroup current_settings_group_;
|
||||
SettingsGroup previous_settings_group_;
|
||||
Aspect aspect_ = Aspect::ALPHA;
|
||||
std::string title_;
|
||||
size_t selected_ = 0;
|
||||
size_t main_menu_selected_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user