menu: enum class Menu::Background/Sound + constant Menu::NO_OPTION
This commit is contained in:
+16
-15
@@ -12,26 +12,25 @@ namespace Ja {
|
||||
struct Sound;
|
||||
} // namespace Ja
|
||||
|
||||
// Tipos de fondos para el menú
|
||||
constexpr int MENU_BACKGROUND_TRANSPARENT = 0;
|
||||
constexpr int MENU_BACKGROUND_SOLID = 1;
|
||||
|
||||
// Tipos de archivos de audio
|
||||
constexpr int SOUND_ACCEPT = 0;
|
||||
constexpr int SOUND_MOVE = 1;
|
||||
constexpr int SOUND_CANCEL = 2;
|
||||
|
||||
// Opciones de menú
|
||||
constexpr int MENU_NO_OPTION = -1;
|
||||
|
||||
// Clase Menu
|
||||
class Menu {
|
||||
public:
|
||||
enum class Background : std::uint8_t {
|
||||
TRANSPARENT,
|
||||
SOLID
|
||||
};
|
||||
|
||||
enum class Sound : std::uint8_t {
|
||||
ACCEPT,
|
||||
MOVE,
|
||||
CANCEL
|
||||
};
|
||||
|
||||
explicit Menu(SDL_Renderer *renderer, const std::string &file = ""); // Constructor
|
||||
~Menu(); // Destructor
|
||||
|
||||
auto loadFromBytes(const std::vector<uint8_t> &bytes, const std::string &name_for_logs = "") -> bool; // Carga el menu desde bytes en memoria
|
||||
void loadAudioFile(const std::string &file, int sound); // Carga los ficheros de audio
|
||||
void loadAudioFile(const std::string &file, Sound sound); // Carga los ficheros de audio
|
||||
|
||||
[[nodiscard]] auto getName() const -> const std::string &; // Obtiene el nombre del menu
|
||||
auto getItemSelected() -> int; // Obtiene el valor de la variable
|
||||
@@ -72,11 +71,13 @@ class Menu {
|
||||
|
||||
void setName(const std::string &name); // Establece el nombre del menu
|
||||
void setPos(int x, int y); // Establece la posición del menu
|
||||
void setBackgroundType(int value); // Establece el tipo de fondo del menu
|
||||
void setBackgroundType(Background value); // Establece el tipo de fondo del menu
|
||||
void setText(const std::string &font_png, const std::string &font_txt); // Establece la fuente de texto que se utilizará
|
||||
void setRectSize(int w = 0, int h = 0); // Establece el rectangulo de fondo del menu
|
||||
|
||||
private:
|
||||
static constexpr int NO_OPTION = -1; // Centinela: ningún item seleccionado
|
||||
|
||||
struct Rectangle {
|
||||
SDL_Rect rect; // Rectangulo
|
||||
Color color; // Color
|
||||
@@ -137,7 +138,7 @@ class Menu {
|
||||
int w_; // Anchura del menu
|
||||
int item_selected_; // Índice del item del menu que ha sido seleccionado
|
||||
int default_action_when_cancel_; // Indice del item del menu que se selecciona cuando se cancela el menu
|
||||
int background_type_; // Tipo de fondo para el menu
|
||||
Background background_type_; // Tipo de fondo para el menu
|
||||
int center_x_; // Centro del menu en el eje X
|
||||
int center_y_; // Centro del menu en el eje Y
|
||||
bool is_centered_on_x_; // Variable para saber si el menu debe estar centrado respecto a un punto en el eje X
|
||||
|
||||
Reference in New Issue
Block a user