afegit callback a service menu per a posar pausa en el joc

This commit is contained in:
2025-08-10 13:36:28 +02:00
parent d90f247bdd
commit 0204a8896a
4 changed files with 56 additions and 33 deletions

View File

@@ -1,27 +1,40 @@
#pragma once
#include <cstddef>
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "ui_message.h"
#include "define_buttons.h"
#include "ui_message.h"
class MenuOption;
class MenuRenderer;
class ServiceMenu {
public:
// ... (enums y constantes sin cambios)
enum class SettingsGroup { CONTROLS, VIDEO, AUDIO, SETTINGS, SYSTEM, MAIN };
enum class GroupAlignment { CENTERED, LEFT };
// --- Enums y constantes ---
enum class SettingsGroup {
CONTROLS,
VIDEO,
AUDIO,
SETTINGS,
SYSTEM,
MAIN
};
enum class GroupAlignment {
CENTERED,
LEFT
};
static constexpr size_t OPTIONS_HORIZONTAL_PADDING = 20;
static constexpr size_t MIN_WIDTH = 240;
static constexpr size_t MIN_GAP_OPTION_VALUE = 30;
static constexpr size_t SETTINGS_GROUP_SIZE = 6;
using StateChangeCallback = std::function<void(bool isActive)>;
// --- Métodos de singleton ---
static void init();
static void destroy();
@@ -47,15 +60,17 @@ class ServiceMenu {
bool checkInput();
// --- Método principal para refresco externo ---
void refresh(); // Refresca los valores y el layout del menú bajo demanda
void refresh(); // Refresca los valores y el layout del menú bajo demanda
// --- Método para registrar el callback ---
void setStateChangeCallback(StateChangeCallback callback);
// --- Getters para el estado ---
[[nodiscard]] auto isDefiningButtons() const -> bool;
[[nodiscard]] auto isAnimating() const -> bool; // Nuevo getter
[[nodiscard]] auto isAnimating() const -> bool; // Nuevo getter
// --- Getters para que el Renderer pueda leer el estado ---
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; }
// ... (resto de getters sin cambios)
[[nodiscard]] auto getTitle() const -> const std::string & { return title_; }
[[nodiscard]] auto getCurrentGroup() const -> SettingsGroup { return current_settings_group_; }
[[nodiscard]] auto getCurrentGroupAlignment() const -> GroupAlignment;
@@ -66,7 +81,6 @@ class ServiceMenu {
[[nodiscard]] auto countOptionsInGroup(SettingsGroup group) const -> size_t;
private:
// ... (resto de miembros privados sin cambios)
bool enabled_ = false;
std::vector<std::unique_ptr<MenuOption>> options_;
std::vector<MenuOption *> display_options_;
@@ -80,6 +94,7 @@ class ServiceMenu {
bool last_pending_changes_ = false;
std::unique_ptr<DefineButtons> define_buttons_;
std::unique_ptr<MenuRenderer> renderer_;
StateChangeCallback state_change_callback_;
// --- Métodos de lógica interna ---
void updateDisplayOptions();
@@ -99,6 +114,7 @@ class ServiceMenu {
static void playBackSound();
[[nodiscard]] static auto settingsGroupToString(SettingsGroup group) -> std::string;
void setHiddenOptions();
void setEnabledInternal(bool enabled); // Método privado para cambiar estado y notificar
// --- Constructores y destructor privados (singleton) ---
ServiceMenu();