| 335 | } |
| 336 | |
| 337 | void Player::Update(bool update_scene) { |
| 338 | std::shared_ptr<Scene> old_instance = Scene::instance; |
| 339 | |
| 340 | if (exit_flag) { |
| 341 | Scene::PopUntil(Scene::Null); |
| 342 | } else if (reset_flag && !Scene::IsAsyncPending()) { |
| 343 | reset_flag = false; |
| 344 | if (Scene::ReturnToTitleScene()) { |
| 345 | // Fade out music and stop sound effects before returning |
| 346 | Main_Data::game_system->BgmFade(800); |
| 347 | Audio().SE_Stop(); |
| 348 | // Do not update this scene until it's properly set up in the next main loop |
| 349 | update_scene = false; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | if (update_scene) { |
| 354 | IncFrame(); |
| 355 | } |
| 356 | |
| 357 | Audio().Update(); |
| 358 | Input::Update(); |
| 359 | |
| 360 | // Game events can query full screen status and change their behavior, so this needs to |
| 361 | // be a game key and not a system key. |
| 362 | if (Input::IsTriggered(Input::TOGGLE_FULLSCREEN)) { |
| 363 | DisplayUi->ToggleFullscreen(); |
| 364 | } |
| 365 | |
| 366 | if (Main_Data::game_quit) { |
| 367 | Main_Data::game_quit->Update(); |
| 368 | } |
| 369 | |
| 370 | auto& transition = Transition::instance(); |
| 371 | |
| 372 | if (transition.IsActive()) { |
| 373 | transition.Update(); |
| 374 | } else { |
| 375 | // If we aren't waiting on a transition, but we are waiting for scene delay. |
| 376 | Scene::instance->UpdateDelayFrames(); |
| 377 | } |
| 378 | |
| 379 | if (update_scene) { |
| 380 | if (Main_Data::game_ineluki) { |
| 381 | Main_Data::game_ineluki->Update(); |
| 382 | } |
| 383 | |
| 384 | Scene::instance->Update(); |
| 385 | } |
| 386 | |
| 387 | #if defined(__ANDROID__) && !defined(USE_LIBRETRO) |
| 388 | EpAndroid::invoke(); |
| 389 | #endif |
| 390 | } |
| 391 | |
| 392 | void Player::Draw() { |
| 393 | Graphics::Update(); |
no test coverage detected