| 228 | } |
| 229 | |
| 230 | void Player::MainLoop() { |
| 231 | Instrumentation::FrameScope iframe; |
| 232 | |
| 233 | const auto frame_time = Game_Clock::now(); |
| 234 | Game_Clock::OnNextFrame(frame_time); |
| 235 | |
| 236 | Player::UpdateInput(); |
| 237 | |
| 238 | if (!DisplayUi->ProcessEvents()) { |
| 239 | Scene::PopUntil(Scene::Null); |
| 240 | Player::Exit(); |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | int num_updates = 0; |
| 245 | while (Game_Clock::NextGameTimeStep()) { |
| 246 | if (num_updates > 0) { |
| 247 | Player::UpdateInput(); |
| 248 | |
| 249 | if (!DisplayUi->ProcessEvents()) { |
| 250 | Scene::PopUntil(Scene::Null); |
| 251 | Player::Exit(); |
| 252 | return; |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | Scene::old_instances.clear(); |
| 257 | Scene::instance->MainFunction(); |
| 258 | |
| 259 | Graphics::GetMessageOverlay().Update(); |
| 260 | |
| 261 | ++num_updates; |
| 262 | } |
| 263 | if (num_updates == 0) { |
| 264 | // If no logical frames ran, we need to update the system keys only. |
| 265 | Input::UpdateSystem(); |
| 266 | } |
| 267 | |
| 268 | Player::Draw(); |
| 269 | |
| 270 | Scene::old_instances.clear(); |
| 271 | |
| 272 | if (!Transition::instance().IsActive() && Scene::instance->type == Scene::Null) { |
| 273 | Exit(); |
| 274 | return; |
| 275 | } |
| 276 | |
| 277 | if (Player::player_config.automatic_screenshots.Get() && FileFinder::Game()) { |
| 278 | auto diff = std::chrono::duration_cast<std::chrono::seconds>(Game_Clock::now() - last_auto_screenshot); |
| 279 | if (diff.count() >= Player::player_config.automatic_screenshots_interval.Get()) { |
| 280 | last_auto_screenshot = Game_Clock::now(); |
| 281 | Output::TakeScreenshot(true); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | auto frame_limit = DisplayUi->GetFrameLimit(); |
| 286 | if (frame_limit == Game_Clock::duration()) { |
| 287 | return; |
nothing calls this directly
no test coverage detected