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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user