eliminades referencies antigues
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#include "core/resources/resource_list.hpp" // Para Asset
|
||||
#include "core/system/event_buffer.hpp" // Para EventBuffer
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement
|
||||
#include "game/options.hpp" // Para Options, options, SectionState, Section
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "game/ui/console.hpp" // Para Console
|
||||
@@ -42,7 +41,6 @@ Title::Title()
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
// Acciones iniciales
|
||||
createCheevosTexture(); // Crea y rellena la textura para mostrar los logros
|
||||
Screen::get()->setBorderColor(0); // Cambia el color del borde
|
||||
Audio::get()->playMusic("574071_EA_DTV.ogg"); // Inicia la musica
|
||||
}
|
||||
@@ -111,11 +109,6 @@ void Title::handleMainMenuKeyPress(SDL_Keycode key) {
|
||||
// Si no hay gamepad, simplemente no hacer nada
|
||||
break;
|
||||
|
||||
case SDLK_4:
|
||||
// PROJECTS
|
||||
transitionToState(State::CHEEVOS_MENU);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -139,19 +132,6 @@ void Title::handleInput(float delta_time) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state_) {
|
||||
case State::CHEEVOS_MENU:
|
||||
if (Input::get()->checkAction(InputAction::ACCEPT, Input::DO_NOT_ALLOW_REPEAT) ||
|
||||
Input::get()->checkAction(InputAction::CANCEL, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
resetCheevosScroll();
|
||||
transitionToState(State::MAIN_MENU);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GlobalInputs::handle();
|
||||
}
|
||||
|
||||
@@ -175,10 +155,6 @@ void Title::updateState(float delta_time) {
|
||||
updateMainMenu(delta_time);
|
||||
break;
|
||||
|
||||
case State::CHEEVOS_MENU:
|
||||
updateCheevosMenu(delta_time);
|
||||
break;
|
||||
|
||||
case State::FADE_MENU:
|
||||
updateFadeMenu(delta_time);
|
||||
break;
|
||||
@@ -231,49 +207,6 @@ void Title::updateMainMenu(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el estado CHEEVOS_MENU
|
||||
void Title::updateCheevosMenu(float delta_time) {
|
||||
// Determina la velocidad objetivo basada en el input
|
||||
float target_velocity = 0.0F;
|
||||
if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) {
|
||||
target_velocity = CHEEVOS_SCROLL_MAX_SPEED; // Scroll hacia abajo
|
||||
} else if (Input::get()->checkAction(InputAction::LEFT, Input::ALLOW_REPEAT)) {
|
||||
target_velocity = -CHEEVOS_SCROLL_MAX_SPEED; // Scroll hacia arriba
|
||||
}
|
||||
|
||||
// Interpola suavemente la velocidad actual hacia la velocidad objetivo
|
||||
if (target_velocity != 0.0F) {
|
||||
// Acelerando hacia la velocidad objetivo
|
||||
const float ACCELERATION_STEP = CHEEVOS_SCROLL_ACCELERATION * delta_time;
|
||||
if (cheevos_scroll_velocity_ < target_velocity) {
|
||||
cheevos_scroll_velocity_ = std::min(cheevos_scroll_velocity_ + ACCELERATION_STEP, target_velocity);
|
||||
} else if (cheevos_scroll_velocity_ > target_velocity) {
|
||||
cheevos_scroll_velocity_ = std::max(cheevos_scroll_velocity_ - ACCELERATION_STEP, target_velocity);
|
||||
}
|
||||
} else {
|
||||
// Desacelerando hacia 0
|
||||
const float DECELERATION_STEP = CHEEVOS_SCROLL_DECELERATION * delta_time;
|
||||
if (cheevos_scroll_velocity_ > 0.0F) {
|
||||
cheevos_scroll_velocity_ = std::max(cheevos_scroll_velocity_ - DECELERATION_STEP, 0.0F);
|
||||
} else if (cheevos_scroll_velocity_ < 0.0F) {
|
||||
cheevos_scroll_velocity_ = std::min(cheevos_scroll_velocity_ + DECELERATION_STEP, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
// Aplica la velocidad actual al scroll position
|
||||
if (cheevos_scroll_velocity_ != 0.0F) {
|
||||
cheevos_surface_view_.y += cheevos_scroll_velocity_ * delta_time;
|
||||
|
||||
// Ajusta los límites
|
||||
const float BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
|
||||
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0.0F, BOTTOM);
|
||||
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
// No incrementar state_time_ (no timeout en este estado)
|
||||
}
|
||||
|
||||
// Actualiza el estado FADE_MENU
|
||||
void Title::updateFadeMenu(float delta_time) {
|
||||
fade_accumulator_ += delta_time;
|
||||
@@ -310,68 +243,6 @@ void Title::render() {
|
||||
Screen::get()->render();
|
||||
}
|
||||
|
||||
// Crea y rellena la textura para mostrar los logros
|
||||
void Title::createCheevosTexture() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
// Define la zona central del menu (entre el logo y la marquesina)
|
||||
constexpr int MENU_ZONE_Y = 73; // Top of menu zone
|
||||
constexpr int MENU_ZONE_HEIGHT = 102; // Height of menu zone
|
||||
|
||||
// Crea la textura con el listado de logros
|
||||
const auto CHEEVOS_LIST = Cheevos::get()->list();
|
||||
const auto TEXT = Resource::Cache::get()->getText("subatomic");
|
||||
constexpr int CHEEVOS_TEXTURE_WIDTH = 200;
|
||||
constexpr int CHEEVOS_TEXTURE_VIEW_HEIGHT = MENU_ZONE_HEIGHT;
|
||||
constexpr int CHEEVOS_PADDING = 10;
|
||||
const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (TEXT->getCharacterSize() * 2) + 1;
|
||||
const int CHEEVOS_TEXTURE_HEIGHT = (CHEEVO_HEIGHT * CHEEVOS_LIST.size()) + 2 + TEXT->getCharacterSize() + 8;
|
||||
cheevos_surface_ = std::make_shared<Surface>(CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT);
|
||||
|
||||
// Prepara para dibujar sobre la textura
|
||||
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||
Screen::get()->setRendererSurface(cheevos_surface_);
|
||||
|
||||
// Rellena la textura con color sólido
|
||||
const auto CHEEVOS_BG_COLOR = 0;
|
||||
cheevos_surface_->clear(CHEEVOS_BG_COLOR);
|
||||
|
||||
// Escribe la lista de logros en la textura
|
||||
const std::string CHEEVOS_OWNER = Locale::get()->get("title.projects"); // NOLINT(readability-static-accessed-through-instance)
|
||||
const std::string CHEEVOS_LIST_CAPTION = CHEEVOS_OWNER + " (" + std::to_string(Cheevos::get()->getTotalUnlockedAchievements()) + " / " + std::to_string(Cheevos::get()->size()) + ")";
|
||||
int pos = 2;
|
||||
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, cheevos_surface_->getWidth() / 2, pos, CHEEVOS_LIST_CAPTION, 1, 9);
|
||||
pos += TEXT->getCharacterSize();
|
||||
const Uint8 CHEEVO_LOCKED_COLOR = 14;
|
||||
const Uint8 CHEEVO_UNLOCKED_COLOR = 9;
|
||||
constexpr int LINE_X1 = (CHEEVOS_TEXTURE_WIDTH / 7) * 3;
|
||||
constexpr int LINE_X2 = LINE_X1 + ((CHEEVOS_TEXTURE_WIDTH / 7) * 1);
|
||||
|
||||
for (const auto& cheevo : CHEEVOS_LIST) {
|
||||
const Uint8 CHEEVO_COLOR = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR;
|
||||
pos += CHEEVOS_PADDING;
|
||||
constexpr int HALF = CHEEVOS_PADDING / 2;
|
||||
cheevos_surface_->drawLine(LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1, CHEEVO_COLOR);
|
||||
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, CHEEVO_COLOR);
|
||||
pos += TEXT->getCharacterSize() + 1;
|
||||
TEXT->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.description, 1, CHEEVO_COLOR);
|
||||
pos += TEXT->getCharacterSize();
|
||||
}
|
||||
|
||||
// Restablece el RenderSurface
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
|
||||
// Crea el sprite para el listado de logros (usa la zona del menu)
|
||||
cheevos_sprite_ = std::make_unique<Sprite>(cheevos_surface_, (GameCanvas::WIDTH - cheevos_surface_->getWidth()) / 2, MENU_ZONE_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
|
||||
cheevos_surface_view_ = {.x = 0, .y = 0, .w = cheevos_surface_->getWidth(), .h = CHEEVOS_TEXTURE_VIEW_HEIGHT};
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
// Resetea el scroll de la lista de logros
|
||||
void Title::resetCheevosScroll() {
|
||||
cheevos_surface_view_.y = 0;
|
||||
cheevos_scroll_velocity_ = 0.0F;
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
// Dibuja el logo con el titulo del juego
|
||||
void Title::renderGameLogo() {
|
||||
game_logo_sprite_->render();
|
||||
@@ -389,30 +260,24 @@ void Title::renderMainMenu() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Zona central del menu (debe coincidir con la textura de cheevos)
|
||||
// Zona central del menu
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
|
||||
// Menú principal normal con 4 opciones centradas verticalmente en la zona
|
||||
// Menú principal normal con 3 opciones centradas verticalmente en la zona
|
||||
const Uint8 COLOR = 8;
|
||||
const int TEXT_SIZE = menu_text_->getCharacterSize();
|
||||
const int MENU_CENTER_Y = MENU_ZONE_Y + (MENU_ZONE_HEIGHT / 2);
|
||||
const int SPACING = 2 * TEXT_SIZE; // Espaciado entre opciones
|
||||
|
||||
// Calcula posiciones centradas verticalmente (4 items con espaciado)
|
||||
const int TOTAL_HEIGHT = 3 * SPACING; // 3 espacios entre 4 items
|
||||
// Calcula posiciones centradas verticalmente (3 items con espaciado)
|
||||
const int TOTAL_HEIGHT = 2 * SPACING; // 2 espacios entre 3 items
|
||||
const int START_Y = MENU_CENTER_Y - (TOTAL_HEIGHT / 2);
|
||||
|
||||
auto* loc = Locale::get();
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y, loc->get("title.menu.play"), 1, COLOR);
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + SPACING, loc->get("title.menu.keyboard"), 1, COLOR);
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + (2 * SPACING), loc->get("title.menu.joystick"), 1, COLOR);
|
||||
menu_text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG, PlayArea::CENTER_X, START_Y + (3 * SPACING), loc->get("title.menu.projects"), 1, COLOR);
|
||||
}
|
||||
|
||||
// Dibuja el menu de logros
|
||||
void Title::renderCheevosMenu() {
|
||||
cheevos_sprite_->render();
|
||||
}
|
||||
|
||||
// Dibuja los elementos en la surface
|
||||
@@ -432,12 +297,6 @@ void Title::fillTitleSurface() {
|
||||
|
||||
break;
|
||||
|
||||
case State::CHEEVOS_MENU:
|
||||
renderGameLogo();
|
||||
renderCheevosMenu();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -534,7 +393,7 @@ void Title::applyKeyboardRemap() { // NOLINT(readability-convert-member-functio
|
||||
|
||||
// Dibuja la pantalla de redefinir teclado
|
||||
void Title::renderKeyboardRemap() const {
|
||||
// Zona central del menu (debe coincidir con la textura de cheevos)
|
||||
// Zona central del menu
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
|
||||
@@ -582,7 +441,7 @@ void Title::renderKeyboardRemap() const {
|
||||
|
||||
// Dibuja la pantalla de redefinir joystick
|
||||
void Title::renderJoystickRemap() const {
|
||||
// Zona central del menu (debe coincidir con la textura de cheevos)
|
||||
// Zona central del menu
|
||||
constexpr int MENU_ZONE_Y = 73;
|
||||
constexpr int MENU_ZONE_HEIGHT = 102;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user