modificada la estructura de fitxers en source
This commit is contained in:
89
source/ui/service_menu.h
Normal file
89
source/ui/service_menu.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "utils.h"
|
||||
#include "ui_message.h"
|
||||
|
||||
// Forward Declarations
|
||||
class Text;
|
||||
class MenuOption;
|
||||
class MenuRenderer; // <-- Nuevo
|
||||
|
||||
class ServiceMenu {
|
||||
public:
|
||||
enum class Aspect { ASPECT1, ASPECT2 };
|
||||
enum class SettingsGroup { VIDEO, AUDIO, SETTINGS, SYSTEM, MAIN };
|
||||
enum class GroupAlignment { CENTERED, LEFT };
|
||||
|
||||
// --- Constantes públicas que el Renderer podría necesitar ---
|
||||
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 void init();
|
||||
static void destroy();
|
||||
static ServiceMenu* get();
|
||||
|
||||
void toggle();
|
||||
void render(); // Ahora solo delega
|
||||
void update(); // Ahora delega la parte visual
|
||||
void reset();
|
||||
|
||||
// --- Lógica de navegación ---
|
||||
void setSelectorUp();
|
||||
void setSelectorDown();
|
||||
void adjustOption(bool adjust_up);
|
||||
void selectOption();
|
||||
void moveBack();
|
||||
|
||||
// --- Getters para que el Renderer pueda leer el estado ---
|
||||
bool isEnabled() const { return enabled_; }
|
||||
const std::string& getTitle() const { return title_; }
|
||||
SettingsGroup getCurrentGroup() const { return current_settings_group_; }
|
||||
GroupAlignment getCurrentGroupAlignment() const;
|
||||
const std::vector<MenuOption*>& getDisplayOptions() const { return display_options_; }
|
||||
const std::vector<std::unique_ptr<MenuOption>>& getAllOptions() const { return options_; }
|
||||
size_t getSelectedIndex() const { return selected_; }
|
||||
const std::vector<std::pair<std::string, std::string>>& getOptionPairs() const { return option_pairs_; }
|
||||
size_t countOptionsInGroup(SettingsGroup group) const;
|
||||
Aspect getAspect() const { return aspect_; }
|
||||
|
||||
private:
|
||||
// --- Lógica de estado del menú (Modelo) ---
|
||||
bool enabled_ = false;
|
||||
std::vector<std::unique_ptr<MenuOption>> options_;
|
||||
std::vector<MenuOption*> display_options_;
|
||||
std::vector<std::pair<std::string, std::string>> option_pairs_;
|
||||
|
||||
SettingsGroup current_settings_group_;
|
||||
SettingsGroup previous_settings_group_;
|
||||
Aspect aspect_ = Aspect::ASPECT1;
|
||||
std::string title_;
|
||||
size_t selected_ = 0;
|
||||
size_t main_menu_selected_ = 0;
|
||||
|
||||
// --- Mensaje de reinicio ---
|
||||
std::unique_ptr<UIMessage> restart_message_ui_;
|
||||
bool last_pending_changes_ = false;
|
||||
|
||||
// --- La Vista ---
|
||||
std::unique_ptr<MenuRenderer> renderer_;
|
||||
|
||||
// --- Métodos de lógica interna ---
|
||||
void initializeOptions();
|
||||
void updateMenu();
|
||||
void applySettings();
|
||||
void AdjustListValues();
|
||||
void playMenuSound();
|
||||
std::string settingsGroupToString(SettingsGroup group) const;
|
||||
|
||||
// --- Singleton ---
|
||||
ServiceMenu();
|
||||
~ServiceMenu() = default;
|
||||
ServiceMenu(const ServiceMenu&) = delete;
|
||||
ServiceMenu& operator=(const ServiceMenu&) = delete;
|
||||
static ServiceMenu* instance_;
|
||||
};
|
||||
Reference in New Issue
Block a user