claude: treballant en el nou define_buttons
This commit is contained in:
@@ -43,7 +43,6 @@ Title::Title()
|
||||
tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::RANDOM)),
|
||||
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
||||
mini_logo_sprite_(std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"))),
|
||||
define_buttons_(std::make_unique<DefineButtons>()),
|
||||
num_controllers_(Input::get()->getNumGamepads()),
|
||||
state_(TitleState::LOGO_ANIMATING) {
|
||||
// Configura objetos
|
||||
@@ -102,7 +101,6 @@ void Title::render() {
|
||||
renderPlayers();
|
||||
renderStartPrompt();
|
||||
renderCopyright();
|
||||
define_buttons_->render();
|
||||
fade_->render();
|
||||
|
||||
SCREEN->render();
|
||||
@@ -117,15 +115,10 @@ void Title::checkEvents() {
|
||||
}
|
||||
|
||||
GlobalEvents::check(event);
|
||||
define_buttons_->checkEvents(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Title::handleKeyDownEvent(const SDL_Event& event) {
|
||||
bool is_first_press = static_cast<int>(event.key.repeat) == 0;
|
||||
if (is_first_press) {
|
||||
handleControlKeys(event.key.key);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
bool is_repeat = static_cast<int>(event.key.repeat) == 1;
|
||||
if (is_repeat) {
|
||||
@@ -209,44 +202,8 @@ void Title::printColorValue(const Color& color) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void Title::handleControlKeys(SDL_Keycode key) {
|
||||
switch (key) {
|
||||
case SDLK_1:
|
||||
define_buttons_->enable(&Options::gamepad_manager.getGamepad(Player::Id::PLAYER1));
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
case SDLK_2:
|
||||
define_buttons_->enable(&Options::gamepad_manager.getGamepad(Player::Id::PLAYER2));
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
case SDLK_3:
|
||||
swapControllers();
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
case SDLK_4:
|
||||
swapKeyboard();
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
case SDLK_5:
|
||||
showControllers();
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba las entradas
|
||||
void Title::checkInput() {
|
||||
if (shouldSkipInputCheck()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Input::get()->update();
|
||||
|
||||
if (!ServiceMenu::get()->isEnabled()) {
|
||||
@@ -256,10 +213,6 @@ void Title::checkInput() {
|
||||
GlobalInputs::check();
|
||||
}
|
||||
|
||||
auto Title::shouldSkipInputCheck() const -> bool {
|
||||
return define_buttons_->isEnabled();
|
||||
}
|
||||
|
||||
void Title::processControllerInputs() {
|
||||
for (const auto& controller : Options::gamepad_manager) {
|
||||
if (isStartButtonPressed(&controller)) {
|
||||
@@ -396,14 +349,9 @@ void Title::updateState() {
|
||||
break;
|
||||
}
|
||||
case TitleState::LOGO_FINISHED: {
|
||||
// El contador solo sube si no estamos definiendo botones
|
||||
counter_ = define_buttons_->isEnabled() ? 0 : counter_ + 1;
|
||||
|
||||
// Actualiza el logo con el título del juego
|
||||
game_logo_->update();
|
||||
|
||||
// Actualiza el mosaico de fondo
|
||||
tiled_bg_->update();
|
||||
++counter_; // Incrementa el contador
|
||||
game_logo_->update(); // Actualiza el logo con el título del juego
|
||||
tiled_bg_->update(); // Actualiza el mosaico de fondo
|
||||
|
||||
if (counter_ == param.title.title_duration) {
|
||||
// El menu ha hecho time out
|
||||
@@ -411,20 +359,16 @@ void Title::updateState() {
|
||||
fade_->activate();
|
||||
selection_ = Section::Options::TITLE_TIME_OUT;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TitleState::START_HAS_BEEN_PRESSED: {
|
||||
// Actualiza el logo con el título del juego
|
||||
game_logo_->update();
|
||||
|
||||
// Actualiza el mosaico de fondo
|
||||
tiled_bg_->update();
|
||||
++counter_; // Incrementa el contador
|
||||
game_logo_->update(); // Actualiza el logo con el título del juego
|
||||
tiled_bg_->update(); // Actualiza el mosaico de fondo
|
||||
|
||||
if (counter_ == 100) {
|
||||
fade_->activate();
|
||||
}
|
||||
++counter_;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -443,19 +387,17 @@ void Title::updateStartPrompt() {
|
||||
Uint32 time_ms = SDL_GetTicks();
|
||||
bool condition_met = false;
|
||||
|
||||
if (!define_buttons_->isEnabled()) {
|
||||
switch (state_) {
|
||||
case TitleState::LOGO_FINISHED:
|
||||
condition_met = (time_ms % LOGO_BLINK_PERIOD) >= (LOGO_BLINK_PERIOD - LOGO_BLINK_ON_TIME);
|
||||
break;
|
||||
switch (state_) {
|
||||
case TitleState::LOGO_FINISHED:
|
||||
condition_met = (time_ms % LOGO_BLINK_PERIOD) >= (LOGO_BLINK_PERIOD - LOGO_BLINK_ON_TIME);
|
||||
break;
|
||||
|
||||
case TitleState::START_HAS_BEEN_PRESSED:
|
||||
condition_met = (time_ms % START_BLINK_PERIOD) >= (START_BLINK_PERIOD - START_BLINK_ON_TIME);
|
||||
break;
|
||||
case TitleState::START_HAS_BEEN_PRESSED:
|
||||
condition_met = (time_ms % START_BLINK_PERIOD) >= (START_BLINK_PERIOD - START_BLINK_ON_TIME);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
should_render_start_prompt_ = condition_met;
|
||||
|
||||
Reference in New Issue
Block a user