ServiceMenu ja pinta alguns textos d'exemple
This commit is contained in:
@@ -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;
|
||||
@@ -16,8 +20,9 @@ ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; }
|
||||
|
||||
// Constructor
|
||||
ServiceMenu::ServiceMenu()
|
||||
: text_(Resource::get()->getText("04b_25_metal"))
|
||||
{
|
||||
constexpr float GAP = 15.0f;
|
||||
constexpr float GAP = 30.0f;
|
||||
rect_ = {GAP, GAP, param.game.width - GAP * 2, param.game.height - GAP * 2};
|
||||
}
|
||||
|
||||
@@ -30,11 +35,55 @@ void ServiceMenu::render()
|
||||
{
|
||||
if (enabled_)
|
||||
{
|
||||
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,8 +2,11 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
class Text;
|
||||
|
||||
class ServiceMenu
|
||||
{
|
||||
public:
|
||||
@@ -19,8 +22,9 @@ public:
|
||||
|
||||
private:
|
||||
// -- Variables internas ---
|
||||
bool enabled_ = false;
|
||||
SDL_FRect rect_; // Rectangulo para definir el area del menú de servicio
|
||||
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(); // Constructor privado
|
||||
|
||||
Reference in New Issue
Block a user