MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ProcessMessages

Function ProcessMessages

src/openrct2-ui/UiContext.cpp:344–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342 }
343
344 void ProcessMessages() override
345 {
346 _lastKeyPressed = 0;
347 _cursorState.left &= ~CURSOR_CHANGED;
348 _cursorState.middle &= ~CURSOR_CHANGED;
349 _cursorState.right &= ~CURSOR_CHANGED;
350 _cursorState.old = 0;
351
352 SDL_Event e;
353 while (SDL_PollEvent(&e))
354 {
355 switch (e.type)
356 {
357 case SDL_QUIT:
358 ContextQuit();
359 break;
360 case SDL_WINDOWEVENT:
361 if (e.window.event == SDL_WINDOWEVENT_RESIZED)
362 {
363 LOG_VERBOSE("New Window size: %ux%u\n", e.window.data1, e.window.data2);
364 OnResize(e.window.data1, e.window.data2);
365 }
366
367 switch (e.window.event)
368 {
369 case SDL_WINDOWEVENT_RESIZED:
370 case SDL_WINDOWEVENT_MOVED:
371 case SDL_WINDOWEVENT_MAXIMIZED:
372 case SDL_WINDOWEVENT_RESTORED:
373 {
374 // Update default display index
375 int32_t displayIndex = SDL_GetWindowDisplayIndex(_window);
376 if (displayIndex != Config::Get().general.defaultDisplay)
377 {
378 Config::Get().general.defaultDisplay = displayIndex;
379 Config::Save();
380 }
381 break;
382 }
383 }
384
385 if (Config::Get().sound.audioFocus)
386 {
387 if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
388 {
389 SetAudioVolume(1);
390 }
391 if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
392 {
393 SetAudioVolume(0);
394 }
395 }
396 break;
397 case SDL_MOUSEMOTION:
398 _cursorState.position = { static_cast<int32_t>(e.motion.x / Config::Get().general.windowScale),
399 static_cast<int32_t>(e.motion.y / Config::Get().general.windowScale) };
400 break;
401 case SDL_MOUSEWHEEL:

Callers

nothing calls this directly

Calls 10

ContextQuitFunction · 0.85
SaveFunction · 0.85
SetAudioVolumeFunction · 0.85
StoreMouseInputFunction · 0.85
MainWindowZoomFunction · 0.85
IsOpenMethod · 0.80
ScrollMethod · 0.80
queueInputEventMethod · 0.80
HandleMessageMethod · 0.80

Tested by

no test coverage detected