ServiceMenu ja pinta un recuadro de prova
el ServiceMenu el pinta Screen
This commit is contained in:
@@ -100,9 +100,9 @@ void Director::init()
|
|||||||
Input::init(Asset::get()->get("gamecontrollerdb.txt")); // Carga configuración de controles
|
Input::init(Asset::get()->get("gamecontrollerdb.txt")); // Carga configuración de controles
|
||||||
bindInputs(); // Asigna los controles a la entrada del sistema
|
bindInputs(); // Asigna los controles a la entrada del sistema
|
||||||
ServiceMenu::init(); // Inicializa el menú de servicio
|
ServiceMenu::init(); // Inicializa el menú de servicio
|
||||||
|
Notifier::init(std::string(), Resource::get()->getText("8bithud")); // Inicialización del sistema de notificaciones
|
||||||
|
|
||||||
// Inicialización del sistema de notificaciones
|
Screen::get()->getSingletons(); // Obtiene los punteros al resto de singletones
|
||||||
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Configuración adicional en modo depuración
|
// Configuración adicional en modo depuración
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
|
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
|
||||||
#include "screen.h" // Para Screen
|
#include "screen.h" // Para Screen
|
||||||
#include "section.h" // Para Name, name, AttractMode, Options
|
#include "section.h" // Para Name, name, AttractMode, Options
|
||||||
#include "service_menu.h" // Para ServiceMenu
|
|
||||||
#include "smart_sprite.h" // Para SmartSprite
|
#include "smart_sprite.h" // Para SmartSprite
|
||||||
#include "stage.h" // Para number, get, Stage, total_power
|
#include "stage.h" // Para number, get, Stage, total_power
|
||||||
#include "tabe.h" // Para Tabe, TabeState
|
#include "tabe.h" // Para Tabe, TabeState
|
||||||
@@ -40,7 +39,6 @@
|
|||||||
Game::Game(int player_id, int current_stage, bool demo)
|
Game::Game(int player_id, int current_stage, bool demo)
|
||||||
: renderer_(Screen::get()->getRenderer()),
|
: renderer_(Screen::get()->getRenderer()),
|
||||||
screen_(Screen::get()),
|
screen_(Screen::get()),
|
||||||
serviceMenu_(ServiceMenu::get()),
|
|
||||||
input_(Input::get()),
|
input_(Input::get()),
|
||||||
background_(std::make_unique<Background>()),
|
background_(std::make_unique<Background>()),
|
||||||
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
|
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
|
||||||
@@ -1068,9 +1066,6 @@ void Game::render()
|
|||||||
fade_in_->render();
|
fade_in_->render();
|
||||||
fade_out_->render();
|
fade_out_->render();
|
||||||
|
|
||||||
// Service Menu
|
|
||||||
serviceMenu_->render();
|
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen_->render();
|
screen_->render();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class Item;
|
|||||||
class PathSprite;
|
class PathSprite;
|
||||||
class Scoreboard;
|
class Scoreboard;
|
||||||
class Screen;
|
class Screen;
|
||||||
class ServiceMenu;
|
|
||||||
class SmartSprite;
|
class SmartSprite;
|
||||||
class Texture;
|
class Texture;
|
||||||
enum class BulletType : Uint8;
|
enum class BulletType : Uint8;
|
||||||
@@ -106,7 +105,6 @@ private:
|
|||||||
// --- Objetos y punteros ---
|
// --- Objetos y punteros ---
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
||||||
ServiceMenu *serviceMenu_; // Objeto para mostrar el menu de servicio
|
|
||||||
Input *input_; // Manejador de entrada
|
Input *input_; // Manejador de entrada
|
||||||
Scoreboard *scoreboard_; // Objeto para dibujar el marcador
|
Scoreboard *scoreboard_; // Objeto para dibujar el marcador
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "notifier.h" // Para Notifier
|
#include "notifier.h" // Para Notifier
|
||||||
#include "options.h" // Para Options, options, WindowOptions, Vid...
|
#include "options.h" // Para Options, options, WindowOptions, Vid...
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
|
#include "service_menu.h" // Para ServiceMenu
|
||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
@@ -172,7 +173,7 @@ void Screen::update()
|
|||||||
fps_.calculate(SDL_GetTicks());
|
fps_.calculate(SDL_GetTicks());
|
||||||
shake_effect_.update(src_rect_, dst_rect_);
|
shake_effect_.update(src_rect_, dst_rect_);
|
||||||
flash_effect_.update();
|
flash_effect_.update();
|
||||||
Notifier::get()->update();
|
notifier_->update();
|
||||||
Mouse::updateCursorVisibility();
|
Mouse::updateCursorVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,7 +278,8 @@ void Screen::renderOverlays()
|
|||||||
renderShake();
|
renderShake();
|
||||||
renderFlash();
|
renderFlash();
|
||||||
renderAttenuate();
|
renderAttenuate();
|
||||||
Notifier::get()->render();
|
serviceMenu_->render();
|
||||||
|
notifier_->render();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
renderInfo();
|
renderInfo();
|
||||||
#endif
|
#endif
|
||||||
@@ -402,3 +404,10 @@ void Screen::toggleVSync()
|
|||||||
options.video.v_sync = !options.video.v_sync;
|
options.video.v_sync = !options.video.v_sync;
|
||||||
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
SDL_SetRenderVSync(renderer_, options.video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene los punteros a los singletones
|
||||||
|
void Screen::getSingletons()
|
||||||
|
{
|
||||||
|
serviceMenu_ = ServiceMenu::get();
|
||||||
|
notifier_ = Notifier::get();
|
||||||
|
}
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class Notifier;
|
||||||
|
class ServiceMenu;
|
||||||
|
|
||||||
// Clase Screen: gestiona la ventana, el renderizador y los efectos visuales globales
|
// Clase Screen: gestiona la ventana, el renderizador y los efectos visuales globales
|
||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
@@ -50,6 +53,7 @@ public:
|
|||||||
SDL_Renderer *getRenderer() { return renderer_; } // Obtiene el renderizador
|
SDL_Renderer *getRenderer() { return renderer_; } // Obtiene el renderizador
|
||||||
void show() { SDL_ShowWindow(window_); } // Muestra la ventana
|
void show() { SDL_ShowWindow(window_); } // Muestra la ventana
|
||||||
void hide() { SDL_HideWindow(window_); } // Oculta la ventana
|
void hide() { SDL_HideWindow(window_); } // Oculta la ventana
|
||||||
|
void getSingletons(); // Obtiene los punteros a los singletones
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// --- Debug ---
|
// --- Debug ---
|
||||||
@@ -184,6 +188,8 @@ private:
|
|||||||
SDL_Window *window_; // Ventana de la aplicación
|
SDL_Window *window_; // Ventana de la aplicación
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
SDL_Texture *game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador
|
SDL_Texture *game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador
|
||||||
|
ServiceMenu *serviceMenu_; // Objeto para mostrar el menú de servicio
|
||||||
|
Notifier *notifier_; // Objeto para mostrar las notificaciones por pantalla
|
||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
SDL_FRect src_rect_; // Coordenadas de origen para dibujar la textura del juego
|
SDL_FRect src_rect_; // Coordenadas de origen para dibujar la textura del juego
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ void ServiceMenu::destroy() { delete ServiceMenu::instance_; }
|
|||||||
// Obtiene la instancia
|
// Obtiene la instancia
|
||||||
ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
ServiceMenu::ServiceMenu()
|
||||||
|
{
|
||||||
|
constexpr float GAP = 15.0f;
|
||||||
|
rect_ = {GAP, GAP, param.game.width - GAP * 2, param.game.height - GAP * 2};
|
||||||
|
}
|
||||||
|
|
||||||
void ServiceMenu::toggle()
|
void ServiceMenu::toggle()
|
||||||
{
|
{
|
||||||
enabled_ = !enabled_;
|
enabled_ = !enabled_;
|
||||||
@@ -23,8 +30,11 @@ void ServiceMenu::render()
|
|||||||
{
|
{
|
||||||
if (enabled_)
|
if (enabled_)
|
||||||
{
|
{
|
||||||
SDL_FRect rect = {10.0f, 10.0f, 100.0f, 100.0f};
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 224);
|
||||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect);
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 224, 224, 224, 255);
|
||||||
|
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
class ServiceMenu
|
class ServiceMenu
|
||||||
{
|
{
|
||||||
@@ -19,9 +20,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
// -- Variables internas ---
|
// -- Variables internas ---
|
||||||
bool enabled_ = false;
|
bool enabled_ = false;
|
||||||
|
SDL_FRect rect_; // Rectangulo para definir el area del menú de servicio
|
||||||
|
|
||||||
// --- Patrón Singleton ---
|
// --- Patrón Singleton ---
|
||||||
ServiceMenu() = default; // Constructor privado
|
ServiceMenu(); // Constructor privado
|
||||||
~ServiceMenu() = default; // Destructor privado
|
~ServiceMenu() = default; // Destructor privado
|
||||||
ServiceMenu(const ServiceMenu &) = delete; // Evitar copia
|
ServiceMenu(const ServiceMenu &) = delete; // Evitar copia
|
||||||
ServiceMenu &operator=(const ServiceMenu &) = delete; // Evitar asignación
|
ServiceMenu &operator=(const ServiceMenu &) = delete; // Evitar asignación
|
||||||
|
|||||||
Reference in New Issue
Block a user