diff --git a/data/font/04b_25_flat.png b/data/font/04b_25_flat.png new file mode 100644 index 0000000..3f5f42b Binary files /dev/null and b/data/font/04b_25_flat.png differ diff --git a/data/font/04b_25_flat_2x.png b/data/font/04b_25_flat_2x.png new file mode 100644 index 0000000..01834a3 Binary files /dev/null and b/data/font/04b_25_flat_2x.png differ diff --git a/data/font/04b_25_reversed.png b/data/font/04b_25_reversed.png new file mode 100644 index 0000000..ff5cf4c Binary files /dev/null and b/data/font/04b_25_reversed.png differ diff --git a/data/font/04b_25_reversed_2x.png b/data/font/04b_25_reversed_2x.png new file mode 100644 index 0000000..398946e Binary files /dev/null and b/data/font/04b_25_reversed_2x.png differ diff --git a/source/director.cpp b/source/director.cpp index 0ba7ec2..647119e 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -451,6 +451,10 @@ void Director::setFileList() Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT); Asset::get()->add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP); Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/font/04b_25_flat.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/font/04b_25_reversed.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/font/04b_25_flat_2x.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/font/04b_25_reversed_2x.png", AssetType::BITMAP); // Textos Asset::get()->add(prefix + "/data/lang/es_ES.txt", AssetType::LANG); diff --git a/source/resource.cpp b/source/resource.cpp index 1c4ddba..e46d157 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -329,6 +329,10 @@ void Resource::createText() {"04b_25_2x", "04b_25_2x.png", "04b_25_2x.txt"}, {"04b_25_metal", "04b_25_metal.png", "04b_25.txt"}, {"04b_25_grey", "04b_25_grey.png", "04b_25.txt"}, + {"04b_25_flat", "04b_25_flat.png", "04b_25.txt"}, + {"04b_25_reversed", "04b_25_reversed.png", "04b_25.txt"}, + {"04b_25_flat_2x", "04b_25_flat_2x.png", "04b_25_2x.txt"}, + {"04b_25_reversed_2x", "04b_25_reversed_2x.png", "04b_25_2x.txt"}, {"8bithud", "8bithud.png", "8bithud.txt"}, {"smb2", "smb2.gif", "smb2.txt"}}; diff --git a/source/screen.cpp b/source/screen.cpp index 2bbf967..fc384a2 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -173,6 +173,7 @@ void Screen::update() fps_.calculate(SDL_GetTicks()); shake_effect_.update(src_rect_, dst_rect_); flash_effect_.update(); + serviceMenu_->update(); notifier_->update(); Mouse::updateCursorVisibility(); } diff --git a/source/service_menu.cpp b/source/service_menu.cpp index e7e232b..7880308 100644 --- a/source/service_menu.cpp +++ b/source/service_menu.cpp @@ -20,10 +20,10 @@ ServiceMenu *ServiceMenu::get() { return ServiceMenu::instance_; } // Constructor ServiceMenu::ServiceMenu() - : text_(Resource::get()->getText("04b_25_metal")) + : elementText_(Resource::get()->getText("04b_25_flat")), + titleText_(Resource::get()->getText("04b_25_flat_2x")) { - constexpr float GAP = 30.0f; - rect_ = {GAP, GAP, param.game.width - GAP * 2, param.game.height - GAP * 2}; + setAnchors(); } void ServiceMenu::toggle() @@ -35,14 +35,15 @@ void ServiceMenu::render() { if (enabled_) { - constexpr int SEPARATION = 14; + int y = rect_.y; + constexpr int H_PADDING = 20; constexpr std::array MAIN_LIST = { "VIDEO", "AUDIO", "GAME", "SYSTEM"}; - constexpr std::array VIDEO_LIST = { + constexpr std::array VIDEO_LIST = { "VIDEO MODE", "WINDOW SIZE", "SHADERS", @@ -64,29 +65,95 @@ void ServiceMenu::render() "EXIT", "SHUTDOWN"}; + constexpr std::array OPTIONS_LIST = { + "FULLSCREEN", + "3", + "OFF", + "ON", + "ON"}; + + // SOMBRA + SDL_FRect shadowRect = {rect_.x + 5, rect_.y + 5, rect_.w, rect_.h}; + SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 64); + SDL_RenderFillRect(Screen::get()->getRenderer(), &shadowRect); + // FONDO - SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 224); + SDL_SetRenderDrawColor(Screen::get()->getRenderer(), bgColor_.r, bgColor_.g, bgColor_.b, 255); SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_); // BORDE - SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 224, 224, 224, 255); + SDL_SetRenderDrawColor(Screen::get()->getRenderer(), titleColor_.r, titleColor_.g, titleColor_.b, 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()); + y += lineHeight_; + titleText_->writeDX(TEXT_COLOR | TEXT_CENTER, param.game.game_area.center_x, y, "SERVICE MENU", -4, titleColor_); // 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); + y += lineHeight_ * 2; + SDL_SetRenderDrawColor(Screen::get()->getRenderer(), titleColor_.r, titleColor_.g, titleColor_.b, 255); + SDL_RenderLine(Screen::get()->getRenderer(), rect_.x + H_PADDING, y, rect_.x + rect_.w - H_PADDING, y); // LIST - for (size_t i = 0; i < MAIN_LIST.size(); ++i) + for (size_t i = 0; i < VIDEO_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); + y += lineHeight_; + elementText_->writeColored(rect_.x + H_PADDING, y, VIDEO_LIST.at(i), i == selected_ ? selectedColor_ : textColor_, -2); + elementText_->writeColored(rect_.x + H_PADDING + 100, y, ": " + std::string(OPTIONS_LIST.at(i)), i == selected_ ? selectedColor_ : textColor_, -2); } } } void ServiceMenu::update() { + if (enabled_) + { + updateCounter(); + selectedColor_ = getSelectedColor(); + } +} + +void ServiceMenu::setAnchors() +{ + width_ = 220; + height_ = 200; + lineHeight_ = elementText_->getCharacterSize() + 5; + rect_ = { + (param.game.width - width_) / 2, + (param.game.height - height_) / 2, + static_cast(width_), + static_cast(height_)}; +} + +void ServiceMenu::updateCounter() +{ + static Uint64 lastUpdate = SDL_GetTicks(); + Uint64 currentTicks = SDL_GetTicks(); + if (currentTicks - lastUpdate >= 50) + { + counter_++; + lastUpdate = currentTicks; + } +} + +Color ServiceMenu::getSelectedColor() +{ + static std::array colors = { + Color(0xFF, 0xFF, 0x00), // Amarillo brillante + Color(0xFF, 0xD7, 0x00), // Dorado claro + Color(0xFF, 0xEF, 0x7C), // Amarillo pastel + Color(0xFF, 0xCC, 0x00), // Amarillo anaranjado + Color(0xFF, 0xF7, 0x00), // Amarillo limón + Color(0xCC, 0x99, 0x00), // Mostaza + Color(0xFF, 0xF7, 0x00), // Amarillo limón (regreso) + Color(0xFF, 0xCC, 0x00), // Amarillo anaranjado (regreso) + Color(0xFF, 0xEF, 0x7C), // Amarillo pastel (regreso) + Color(0xFF, 0xD7, 0x00), // Dorado claro (regreso) + Color(0xFF, 0xFF, 0x00), // Amarillo brillante (regreso) + Color(0xCC, 0x99, 0x00) // Mostaza (regreso, cierre) + }; + + const size_t index = counter_ % colors.size(); + + return colors.at(index); } \ No newline at end of file diff --git a/source/service_menu.h b/source/service_menu.h index 38d2075..076e2a4 100644 --- a/source/service_menu.h +++ b/source/service_menu.h @@ -4,6 +4,7 @@ #include #include #include +#include "utils.h" class Text; @@ -22,9 +23,26 @@ public: private: // -- Variables internas --- - 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_; // Objeto para escribir texto; + 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 elementText_; // Objeto para escribir texto; + std::shared_ptr titleText_; // Objeto para escribir texto; + size_t selected_ = 2; // Elemento del menú seleccionado + Uint32 counter_ = 0; // Contador interno + + // -- Aspecto -- + Color bgColor_ = SERV_MENU_BG_COLOR; // Color de fondo + Color titleColor_ = SERV_MENU_TITLE_COLOR; // Color del título del menu + Color textColor_ = SERV_MENU_TEXT_COLOR; // Color para el texto de los elementos + Color selectedColor_ = SERV_MENU_SELECTED_COLOR; // Color para el elemento seleccionado + int width_; // Ancho del menú + int height_; // Alto del menu + int lineHeight_; // Espacio entre elementos del menu + + // -- Métodos internos --- + void setAnchors(); // Establece el valor de las variables de anclaje + void updateCounter(); // Actualiza el contador interno + Color getSelectedColor(); // Devuelve el color del elemento seleccionado // --- Patrón Singleton --- ServiceMenu(); // Constructor privado diff --git a/source/utils.cpp b/source/utils.cpp index a3170b9..58aa68f 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -32,6 +32,10 @@ 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); const Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B); +const Color SERV_MENU_TITLE_COLOR = Color(0XFF, 0XFF, 0XFF); +const Color SERV_MENU_TEXT_COLOR = Color(0XFF, 0XFF, 0XFF); +const Color SERV_MENU_SELECTED_COLOR = Color(0XFF, 0XFF, 0X00);; +const Color SERV_MENU_BG_COLOR = Color(0x1E, 0x1E, 0x1E); // Obtiene un color del vector de colores imitando al Coche Fantástico Color getColorLikeKnightRider(const std::vector &colors, int counter_) diff --git a/source/utils.h b/source/utils.h index 63e81e1..844ce7c 100644 --- a/source/utils.h +++ b/source/utils.h @@ -127,6 +127,10 @@ extern const Color GREEN_COLOR; extern const Color BLUE_SKY_COLOR; extern const Color PINK_SKY_COLOR; extern const Color GREEN_SKY_COLOR; +extern const Color SERV_MENU_TITLE_COLOR; +extern const Color SERV_MENU_TEXT_COLOR; +extern const Color SERV_MENU_SELECTED_COLOR; +extern const Color SERV_MENU_BG_COLOR; // Colores y gráficos Color getColorLikeKnightRider(const std::vector &colors, int counter_);