vaig a fer un commit per si de cas petara algo ...

This commit is contained in:
2025-06-04 14:05:56 +02:00
parent 64b86c7ac1
commit 1a84f1b1b0
6 changed files with 97 additions and 23 deletions

View File

@@ -31,6 +31,51 @@ public:
bool isEnabled() const { return enabled_; }
private:
enum class SettingsGroup
{
VIDEO, // Configuraciones relacionadas con la calidad y resolución de imagen
AUDIO, // Opciones de sonido y volumen
GAME, // Ajustes de jugabilidad y mecánicas
SYSTEM // Preferencias generales y configuraciones del sistema
};
enum class OptionBehavior
{
ADJUST, // Modificable con izquierda/derecha
SELECT // Activable con ENTER
};
enum class ValueType
{
BOOL,
INT,
NONE
};
struct OptionEntry
{
std::string caption; // Texto visible en el menú
SettingsGroup group; // Categoría de la opción
OptionBehavior behavior; // Cómo se interactúa con la opción
void *linkedVariable; // Puntero a la variable que controla la opción
ValueType type; // Tipo de la variable (bool o int)
// Constructor para inicializar los valores fácilmente
OptionEntry(std::string cap, SettingsGroup grp, OptionBehavior beh, void *var, ValueType t)
: caption(cap), group(grp), behavior(beh), linkedVariable(var), type(t) {}
// Método para obtener el valor como string
std::string getValueAsString() const
{
if (type == ValueType::BOOL)
return (*(static_cast<bool *>(linkedVariable))) ? "ON" : "OFF";
else if (type == ValueType::INT)
return std::to_string(*(static_cast<int *>(linkedVariable)));
return "Unknown";
}
};
// -- 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
@@ -38,6 +83,7 @@ private:
std::shared_ptr<Text> titleText_; // Objeto para escribir texto;
size_t selected_ = 2; // Elemento del menú seleccionado
Uint32 counter_ = 0; // Contador interno
std::vector<OptionEntry> options_; // Listado con todas las opciones del menú de servicio
// -- Aspecto --
Color bgColor_ = SERV_MENU_BG_COLOR; // Color de fondo
@@ -52,6 +98,7 @@ private:
void setAnchors(); // Establece el valor de las variables de anclaje
void updateCounter(); // Actualiza el contador interno
Color getSelectedColor(); // Devuelve el color del elemento seleccionado
void initializeOptions(); // Crea todas las opciones del menú de servicio
// --- Patrón Singleton ---
ServiceMenu(); // Constructor privado