#include "service_menu.h" #include "screen.h" #include #include #include #include "text.h" #include "resource.h" // Singleton ServiceMenu *ServiceMenu::instance_ = nullptr; // Inicializa la instancia Ășnica del singleton void ServiceMenu::init() { ServiceMenu::instance_ = new ServiceMenu(); } // Libera la instancia 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_; } void ServiceMenu::render() { if (enabled_) { constexpr int SEPARATION = 14; constexpr std::array MAIN_LIST = { "VIDEO", "AUDIO", "GAME", "SYSTEM"}; constexpr std::array VIDEO_LIST = { "VIDEO MODE", "WINDOW SIZE", "SHADERS", "VSYNC", "INTEGER SCALE"}; constexpr std::array AUDIO_LIST = { "AUDIO", "MAIN VOLUME", "MUSIC VOLUME", "SFX VOLUME"}; constexpr std::array GAME_LIST = { "AUTOFIRE", "LANG"}; constexpr std::array 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); } } } void ServiceMenu::update() { }