|
@@ -626,25 +626,25 @@ bool VideoDriver_Cocoa::PollEvent()
|
|
|
|
|
|
if (event == nil) return false;
|
|
|
|
|
|
[ NSApp sendEvent:event ];
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/** Main game loop. */
|
|
|
void VideoDriver_Cocoa::GameLoop()
|
|
|
{
|
|
|
auto cur_ticks = std::chrono::steady_clock::now();
|
|
|
auto last_cur_ticks = cur_ticks;
|
|
|
auto last_realtime_tick = cur_ticks;
|
|
|
auto next_tick = cur_ticks;
|
|
|
|
|
|
for (;;) {
|
|
|
@autoreleasepool {
|
|
|
|
|
|
InteractiveRandom(); // randomness
|
|
|
|
|
|
while (this->PollEvent()) {}
|
|
|
|
|
|
if (_exit_game) {
|
|
|
/* Restore saved resolution if in fullscreen mode. */
|
|
|
if (this->IsFullscreen()) _cur_resolution = this->orig_res;
|
|
@@ -655,27 +655,33 @@ void VideoDriver_Cocoa::GameLoop()
|
|
|
|
|
|
#if defined(_DEBUG)
|
|
|
if (cur_mods & NSShiftKeyMask) {
|
|
|
#else
|
|
|
if (_tab_is_down) {
|
|
|
#endif
|
|
|
if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
|
|
|
} else if (_fast_forward & 2) {
|
|
|
_fast_forward = 0;
|
|
|
}
|
|
|
|
|
|
cur_ticks = std::chrono::steady_clock::now();
|
|
|
|
|
|
/* If more than a millisecond has passed, increase the _realtime_tick. */
|
|
|
if (cur_ticks - last_realtime_tick > std::chrono::milliseconds(1)) {
|
|
|
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(cur_ticks - last_realtime_tick);
|
|
|
_realtime_tick += delta.count();
|
|
|
last_realtime_tick += delta;
|
|
|
}
|
|
|
|
|
|
if (cur_ticks >= next_tick || (_fast_forward && !_pause_mode)) {
|
|
|
_realtime_tick += std::chrono::duration_cast<std::chrono::milliseconds>(cur_ticks - last_cur_ticks).count();
|
|
|
last_cur_ticks = cur_ticks;
|
|
|
next_tick = cur_ticks + std::chrono::milliseconds(MILLISECONDS_PER_TICK);
|
|
|
|
|
|
bool old_ctrl_pressed = _ctrl_pressed;
|
|
|
|
|
|
_ctrl_pressed = (cur_mods & ( _settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask)) != 0;
|
|
|
_shift_pressed = (cur_mods & NSShiftKeyMask) != 0;
|
|
|
|
|
|
if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
|
|
|
|
|
|
::GameLoop();
|
|
|
|
|
|
UpdateWindows();
|