Compare commits
3 Commits
653bb7dc76
...
093b775360
| Author | SHA1 | Date | |
|---|---|---|---|
| 093b775360 | |||
| 3e9716901b | |||
| 16d9774519 |
@@ -100,9 +100,9 @@ void Director::init()
|
||||
Input::init(Asset::get()->get("gamecontrollerdb.txt")); // Carga configuración de controles
|
||||
bindInputs(); // Asigna los controles a la entrada del sistema
|
||||
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
|
||||
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
||||
Screen::get()->getSingletons(); // Obtiene los punteros al resto de singletones
|
||||
|
||||
#ifdef DEBUG
|
||||
// Configuración adicional en modo depuración
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
|
||||
#include "screen.h" // Para Screen
|
||||
#include "section.h" // Para Name, name, AttractMode, Options
|
||||
#include "service_menu.h" // Para ServiceMenu
|
||||
#include "smart_sprite.h" // Para SmartSprite
|
||||
#include "stage.h" // Para number, get, Stage, total_power
|
||||
#include "tabe.h" // Para Tabe, TabeState
|
||||
@@ -40,7 +39,6 @@
|
||||
Game::Game(int player_id, int current_stage, bool demo)
|
||||
: renderer_(Screen::get()->getRenderer()),
|
||||
screen_(Screen::get()),
|
||||
serviceMenu_(ServiceMenu::get()),
|
||||
input_(Input::get()),
|
||||
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)),
|
||||
@@ -1068,9 +1066,6 @@ void Game::render()
|
||||
fade_in_->render();
|
||||
fade_out_->render();
|
||||
|
||||
// Service Menu
|
||||
serviceMenu_->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen_->render();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ class Item;
|
||||
class PathSprite;
|
||||
class Scoreboard;
|
||||
class Screen;
|
||||
class ServiceMenu;
|
||||
class SmartSprite;
|
||||
class Texture;
|
||||
enum class BulletType : Uint8;
|
||||
@@ -106,7 +105,6 @@ private:
|
||||
// --- Objetos y punteros ---
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
||||
ServiceMenu *serviceMenu_; // Objeto para mostrar el menu de servicio
|
||||
Input *input_; // Manejador de entrada
|
||||
Scoreboard *scoreboard_; // Objeto para dibujar el marcador
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "notifier.h" // Para Notifier
|
||||
#include "options.h" // Para Options, options, WindowOptions, Vid...
|
||||
#include "resource.h" // Para Resource
|
||||
#include "service_menu.h" // Para ServiceMenu
|
||||
#include "text.h" // Para Text
|
||||
|
||||
// Singleton
|
||||
@@ -172,7 +173,7 @@ void Screen::update()
|
||||
fps_.calculate(SDL_GetTicks());
|
||||
shake_effect_.update(src_rect_, dst_rect_);
|
||||
flash_effect_.update();
|
||||
Notifier::get()->update();
|
||||
notifier_->update();
|
||||
Mouse::updateCursorVisibility();
|
||||
}
|
||||
|
||||
@@ -220,10 +221,10 @@ void Screen::renderInfo()
|
||||
{
|
||||
// FPS
|
||||
const std::string FPS_TEXT = std::to_string(fps_.lastValue) + " FPS";
|
||||
debug_info_.text->writeColored(param.game.width - debug_info_.text->lenght(FPS_TEXT), 0, FPS_TEXT, ORANGE_SOFT_COLOR);
|
||||
debug_info_.text->writeDX(TEXT_COLOR | TEXT_SHADOW, param.game.width - debug_info_.text->lenght(FPS_TEXT), 0, FPS_TEXT, 1, ORANGE_SOFT_COLOR, 1, ORANGE_SHADOW_COLOR);
|
||||
|
||||
// Resolution
|
||||
debug_info_.text->writeColored(0, 0, options.video.info, ORANGE_SOFT_COLOR);
|
||||
debug_info_.text->writeDX(TEXT_COLOR | TEXT_SHADOW, 0, 0, options.video.info, 1, ORANGE_SOFT_COLOR, 1, ORANGE_SHADOW_COLOR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -277,7 +278,8 @@ void Screen::renderOverlays()
|
||||
renderShake();
|
||||
renderFlash();
|
||||
renderAttenuate();
|
||||
Notifier::get()->render();
|
||||
serviceMenu_->render();
|
||||
notifier_->render();
|
||||
#ifdef DEBUG
|
||||
renderInfo();
|
||||
#endif
|
||||
@@ -401,4 +403,11 @@ void Screen::toggleVSync()
|
||||
{
|
||||
options.video.v_sync = !options.video.v_sync;
|
||||
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"
|
||||
#endif
|
||||
|
||||
class Notifier;
|
||||
class ServiceMenu;
|
||||
|
||||
// Clase Screen: gestiona la ventana, el renderizador y los efectos visuales globales
|
||||
class Screen
|
||||
{
|
||||
@@ -50,6 +53,7 @@ public:
|
||||
SDL_Renderer *getRenderer() { return renderer_; } // Obtiene el renderizador
|
||||
void show() { SDL_ShowWindow(window_); } // Muestra la ventana
|
||||
void hide() { SDL_HideWindow(window_); } // Oculta la ventana
|
||||
void getSingletons(); // Obtiene los punteros a los singletones
|
||||
|
||||
#ifdef DEBUG
|
||||
// --- Debug ---
|
||||
@@ -184,6 +188,8 @@ private:
|
||||
SDL_Window *window_; // Ventana de la aplicación
|
||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||
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 ---
|
||||
SDL_FRect src_rect_; // Coordenadas de origen para dibujar la textura del juego
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "service_menu.h"
|
||||
#include "screen.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include "text.h"
|
||||
#include "resource.h"
|
||||
|
||||
// Singleton
|
||||
ServiceMenu *ServiceMenu::instance_ = nullptr;
|
||||
@@ -14,6 +18,14 @@ void ServiceMenu::destroy() { delete ServiceMenu::instance_; }
|
||||
// Obtiene la instancia
|
||||
ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
||||
|
||||
// Constructor
|
||||
ServiceMenu::ServiceMenu()
|
||||
: text_(Resource::get()->getText("04b_25_metal"))
|
||||
{
|
||||
constexpr float GAP = 30.0f;
|
||||
rect_ = {GAP, GAP, param.game.width - GAP * 2, param.game.height - GAP * 2};
|
||||
}
|
||||
|
||||
void ServiceMenu::toggle()
|
||||
{
|
||||
enabled_ = !enabled_;
|
||||
@@ -23,8 +35,55 @@ void ServiceMenu::render()
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
SDL_FRect rect = {10.0f, 10.0f, 100.0f, 100.0f};
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect);
|
||||
constexpr int SEPARATION = 14;
|
||||
constexpr std::array<const char *, 4> MAIN_LIST = {
|
||||
"VIDEO",
|
||||
"AUDIO",
|
||||
"GAME",
|
||||
"SYSTEM"};
|
||||
|
||||
constexpr std::array<const char *, 54> VIDEO_LIST = {
|
||||
"VIDEO MODE",
|
||||
"WINDOW SIZE",
|
||||
"SHADERS",
|
||||
"VSYNC",
|
||||
"INTEGER SCALE"};
|
||||
|
||||
constexpr std::array<const char *, 4> AUDIO_LIST = {
|
||||
"AUDIO",
|
||||
"MAIN VOLUME",
|
||||
"MUSIC VOLUME",
|
||||
"SFX VOLUME"};
|
||||
|
||||
constexpr std::array<const char *, 2> GAME_LIST = {
|
||||
"AUTOFIRE",
|
||||
"LANG"};
|
||||
|
||||
constexpr std::array<const char *, 3> SYSTEM_LIST = {
|
||||
"RESET",
|
||||
"EXIT",
|
||||
"SHUTDOWN"};
|
||||
|
||||
// FONDO
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 224);
|
||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||
|
||||
// BORDE
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 224, 224, 224, 255);
|
||||
SDL_RenderRect(Screen::get()->getRenderer(), &rect_);
|
||||
|
||||
// SERVICE MENU
|
||||
text_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, rect_.y + SEPARATION, "SERVICE MENU", -2, BLUE_SKY_COLOR.lighten());
|
||||
|
||||
// LINEA
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), BLUE_SKY_COLOR.lighten().r, BLUE_SKY_COLOR.lighten().g, BLUE_SKY_COLOR.lighten().b, 255);
|
||||
SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + 20, rect_.y + SEPARATION * 3, rect_.x + rect_.w - 20, rect_.y + SEPARATION * 3);
|
||||
|
||||
// LIST
|
||||
for (size_t i = 0; i < MAIN_LIST.size(); ++i)
|
||||
{
|
||||
text_->writeColored(rect_.x + 20, rect_.y + (SEPARATION * 4) + (i * (SEPARATION + SEPARATION * 0.5f)), MAIN_LIST.at(i), BLUE_SKY_COLOR.lighten(100), -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
class Text;
|
||||
|
||||
class ServiceMenu
|
||||
{
|
||||
@@ -18,10 +22,12 @@ public:
|
||||
|
||||
private:
|
||||
// -- Variables internas ---
|
||||
bool enabled_ = false;
|
||||
bool enabled_ = false; // Indica si el menú de servicio está activo
|
||||
SDL_FRect rect_; // Rectangulo para definir el area del menú de servicio
|
||||
std::shared_ptr<Text> text_; // Objeto para escribir texto;
|
||||
|
||||
// --- Patrón Singleton ---
|
||||
ServiceMenu() = default; // Constructor privado
|
||||
ServiceMenu(); // Constructor privado
|
||||
~ServiceMenu() = default; // Destructor privado
|
||||
ServiceMenu(const ServiceMenu &) = delete; // Evitar copia
|
||||
ServiceMenu &operator=(const ServiceMenu &) = delete; // Evitar asignación
|
||||
|
||||
@@ -27,6 +27,7 @@ const Color FLASH_COLOR = Color(0XFF, 0XFF, 0XFF);
|
||||
const Color FADE_COLOR = Color(0X27, 0X27, 0X36);
|
||||
const Color ORANGE_COLOR = Color(0XFF, 0X7A, 0X00);
|
||||
const Color ORANGE_SOFT_COLOR = Color(0XFF, 0XA0, 0X33);
|
||||
const Color ORANGE_SHADOW_COLOR = ORANGE_SOFT_COLOR.darken(100);
|
||||
const Color GREEN_COLOR = Color(0X5B, 0XEC, 0X95);
|
||||
const Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1);
|
||||
const Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97);
|
||||
|
||||
@@ -122,6 +122,7 @@ extern const Color FLASH_COLOR;
|
||||
extern const Color FADE_COLOR;
|
||||
extern const Color ORANGE_COLOR;
|
||||
extern const Color ORANGE_SOFT_COLOR;
|
||||
extern const Color ORANGE_SHADOW_COLOR;
|
||||
extern const Color GREEN_COLOR;
|
||||
extern const Color BLUE_SKY_COLOR;
|
||||
extern const Color PINK_SKY_COLOR;
|
||||
|
||||
Reference in New Issue
Block a user