afegida font aseprite canvis estetics en la info de debug moviment del cursor del ServiceMenu
64 lines
2.4 KiB
C++
64 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <SDL3/SDL.h>
|
|
#include "utils.h"
|
|
|
|
class Text;
|
|
|
|
class ServiceMenu
|
|
{
|
|
public:
|
|
// --- Métodos de singleton ---
|
|
static void init(); // Inicializa el objeto ServiceMenu
|
|
static void destroy(); // Libera el objeto ServiceMenu
|
|
static ServiceMenu *get(); // Obtiene el puntero al objeto ServiceMenu
|
|
|
|
// -- Métodos ---
|
|
void toggle();
|
|
void render();
|
|
void update();
|
|
|
|
// --- Métodos de control ---
|
|
void setSelectorUp();
|
|
void setSelectorDown();
|
|
void acceptSelection();
|
|
void cancelSelection();
|
|
|
|
// --- Getters ---
|
|
bool isEnabled() const { return enabled_; }
|
|
|
|
private:
|
|
// -- Variables internas ---
|
|
bool enabled_ = false; // Indica si el menú de servicio está activo
|
|
SDL_FRect rect_; // Rectangulo para definir el area del menú de servicio
|
|
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 ---
|
|
ServiceMenu(); // Constructor privado
|
|
~ServiceMenu() = default; // Destructor privado
|
|
ServiceMenu(const ServiceMenu &) = delete; // Evitar copia
|
|
ServiceMenu &operator=(const ServiceMenu &) = delete; // Evitar asignación
|
|
|
|
// --- Singleton ---
|
|
static ServiceMenu *instance_;
|
|
}; |