renombrades extensions .h a .hpp
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#include "menu_renderer.h"
|
||||
#include "menu_renderer.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "color.h"
|
||||
#include "menu_option.h"
|
||||
#include "param.h"
|
||||
#include "screen.h"
|
||||
#include "text.h"
|
||||
#include "utils.h"
|
||||
#include "color.hpp"
|
||||
#include "menu_option.hpp"
|
||||
#include "param.hpp"
|
||||
#include "screen.hpp"
|
||||
#include "text.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
// --- Implementación de las estructuras de animación ---
|
||||
|
||||
@@ -43,14 +43,14 @@ void MenuRenderer::ShowHideAnimation::stop() {
|
||||
elapsed = 0.0F;
|
||||
}
|
||||
|
||||
MenuRenderer::MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr<Text> element_text, std::shared_ptr<Text> title_text)
|
||||
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)) {
|
||||
initializeMaxSizes();
|
||||
setPosition(param.game.game_area.center_x, param.game.game_area.center_y, PositionMode::CENTERED);
|
||||
}
|
||||
|
||||
void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::render(const ServiceMenu* menu_state) {
|
||||
if (!visible_) {
|
||||
return;
|
||||
}
|
||||
@@ -85,11 +85,11 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
|
||||
// Dibuja las opciones
|
||||
y = options_y_;
|
||||
const auto &option_pairs = menu_state->getOptionPairs();
|
||||
const auto& option_pairs = menu_state->getOptionPairs();
|
||||
|
||||
for (size_t i = 0; i < option_pairs.size(); ++i) {
|
||||
const bool IS_SELECTED = (i == menu_state->getSelectedIndex());
|
||||
const Color ¤t_color = IS_SELECTED ? param.service_menu.selected_color : param.service_menu.text_color;
|
||||
const Color& current_color = IS_SELECTED ? param.service_menu.selected_color : param.service_menu.text_color;
|
||||
|
||||
if (menu_state->getCurrentGroupAlignment() == ServiceMenu::GroupAlignment::LEFT) {
|
||||
const int AVAILABLE_WIDTH = rect_.w - (ServiceMenu::OPTIONS_HORIZONTAL_PADDING * 2) - element_text_->length(option_pairs.at(i).first, -2) - ServiceMenu::MIN_GAP_OPTION_VALUE;
|
||||
@@ -107,7 +107,7 @@ void MenuRenderer::render(const ServiceMenu *menu_state) {
|
||||
}
|
||||
}
|
||||
|
||||
void MenuRenderer::update(const ServiceMenu *menu_state, float delta_time) {
|
||||
void MenuRenderer::update(const ServiceMenu* menu_state, float delta_time) {
|
||||
updateAnimations(delta_time);
|
||||
|
||||
if (visible_) {
|
||||
@@ -118,7 +118,7 @@ void MenuRenderer::update(const ServiceMenu *menu_state, float delta_time) {
|
||||
|
||||
// --- Nuevos métodos de control ---
|
||||
|
||||
void MenuRenderer::show(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::show(const ServiceMenu* menu_state) {
|
||||
if (visible_) {
|
||||
return;
|
||||
}
|
||||
@@ -162,13 +162,13 @@ void MenuRenderer::setPosition(float x, float y, PositionMode mode) {
|
||||
|
||||
// --- Métodos de layout ---
|
||||
|
||||
void MenuRenderer::onLayoutChanged(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::onLayoutChanged(const ServiceMenu* menu_state) {
|
||||
precalculateMenuWidths(menu_state->getAllOptions(), menu_state);
|
||||
setAnchors(menu_state);
|
||||
resize(menu_state);
|
||||
}
|
||||
|
||||
void MenuRenderer::setLayout(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::setLayout(const ServiceMenu* menu_state) {
|
||||
precalculateMenuWidths(menu_state->getAllOptions(), menu_state);
|
||||
setAnchors(menu_state);
|
||||
setSize(menu_state);
|
||||
@@ -179,7 +179,7 @@ void MenuRenderer::initializeMaxSizes() {
|
||||
max_menu_height_ = static_cast<size_t>(param.game.game_area.rect.h * 0.9F);
|
||||
}
|
||||
|
||||
void MenuRenderer::setAnchors(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::setAnchors(const ServiceMenu* menu_state) {
|
||||
size_t max_entries = 0;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
max_entries = std::max(max_entries, menu_state->countOptionsInGroup(static_cast<ServiceMenu::SettingsGroup>(i)));
|
||||
@@ -197,9 +197,9 @@ void MenuRenderer::setAnchors(const ServiceMenu *menu_state) {
|
||||
height_ = upper_height_ + lower_height_;
|
||||
}
|
||||
|
||||
auto MenuRenderer::calculateNewRect(const ServiceMenu *menu_state) -> SDL_FRect {
|
||||
auto MenuRenderer::calculateNewRect(const ServiceMenu* menu_state) -> SDL_FRect {
|
||||
width_ = std::min(static_cast<size_t>(getMenuWidthForGroup(menu_state->getCurrentGroup())), max_menu_width_);
|
||||
const auto &display_options = menu_state->getDisplayOptions();
|
||||
const auto& display_options = menu_state->getDisplayOptions();
|
||||
lower_height_ = ((!display_options.empty() ? display_options.size() - 1 : 0) * (options_height_ + options_padding_)) + options_height_ + (lower_padding_ * 2);
|
||||
height_ = std::min(upper_height_ + lower_height_, max_menu_height_);
|
||||
|
||||
@@ -209,7 +209,7 @@ auto MenuRenderer::calculateNewRect(const ServiceMenu *menu_state) -> SDL_FRect
|
||||
return new_rect;
|
||||
}
|
||||
|
||||
void MenuRenderer::resize(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::resize(const ServiceMenu* menu_state) {
|
||||
SDL_FRect new_rect = calculateNewRect(menu_state);
|
||||
|
||||
if (rect_.w != new_rect.w || rect_.h != new_rect.h) {
|
||||
@@ -222,7 +222,7 @@ void MenuRenderer::resize(const ServiceMenu *menu_state) {
|
||||
options_y_ = rect_.y + upper_height_ + lower_padding_;
|
||||
}
|
||||
|
||||
void MenuRenderer::setSize(const ServiceMenu *menu_state) {
|
||||
void MenuRenderer::setSize(const ServiceMenu* menu_state) {
|
||||
SDL_FRect new_rect = calculateNewRect(menu_state);
|
||||
rect_.w = new_rect.w;
|
||||
rect_.h = new_rect.h;
|
||||
@@ -310,15 +310,15 @@ void MenuRenderer::updatePosition() {
|
||||
|
||||
// Resto de métodos (sin cambios significativos)
|
||||
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>> &all_options, const ServiceMenu *menu_state) {
|
||||
for (int &w : group_menu_widths_) {
|
||||
void MenuRenderer::precalculateMenuWidths(const std::vector<std::unique_ptr<MenuOption>>& all_options, const ServiceMenu* menu_state) {
|
||||
for (int& w : group_menu_widths_) {
|
||||
w = ServiceMenu::MIN_WIDTH;
|
||||
}
|
||||
for (int group = 0; group < 5; ++group) {
|
||||
auto sg = static_cast<ServiceMenu::SettingsGroup>(group);
|
||||
int max_option_width = 0;
|
||||
int max_value_width = 0;
|
||||
for (const auto &option : all_options) {
|
||||
for (const auto& option : all_options) {
|
||||
if (option->getGroup() != sg) {
|
||||
continue;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ auto MenuRenderer::setRect(SDL_FRect rect) -> SDL_FRect {
|
||||
border_rect_ = {.x = rect.x - 1, .y = rect.y + 1, .w = rect.w + 2, .h = rect.h - 2};
|
||||
return rect;
|
||||
}
|
||||
auto MenuRenderer::getTruncatedValueWidth(const std::string &value, int available_width) const -> int {
|
||||
auto MenuRenderer::getTruncatedValueWidth(const std::string& value, int available_width) const -> int {
|
||||
int value_width = element_text_->length(value, -2);
|
||||
if (value_width <= available_width) {
|
||||
return value_width;
|
||||
@@ -385,7 +385,7 @@ auto MenuRenderer::getTruncatedValueWidth(const std::string &value, int availabl
|
||||
return element_text_->length(truncated, -2);
|
||||
}
|
||||
|
||||
auto MenuRenderer::getTruncatedValue(const std::string &value, int available_width) const -> std::string {
|
||||
auto MenuRenderer::getTruncatedValue(const std::string& value, int available_width) const -> std::string {
|
||||
int value_width = element_text_->length(value, -2);
|
||||
if (value_width <= available_width) {
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user