|
@@ -1115,12 +1115,46 @@ void VideoDriver_Win32::CheckPaletteAnim
|
|
|
if (_cur_palette.count_dirty == 0) return;
|
|
|
|
|
|
_local_palette = _cur_palette;
|
|
|
this->MakeDirty(0, 0, _screen.width, _screen.height);
|
|
|
}
|
|
|
|
|
|
void VideoDriver_Win32::InputLoop()
|
|
|
{
|
|
|
bool old_ctrl_pressed = _ctrl_pressed;
|
|
|
|
|
|
_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL) < 0;
|
|
|
_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT) < 0;
|
|
|
|
|
|
#if defined(_DEBUG)
|
|
|
if (_shift_pressed)
|
|
|
#else
|
|
|
/* Speedup when pressing tab, except when using ALT+TAB
|
|
|
* to switch to another application. */
|
|
|
if (_wnd.has_focus && GetAsyncKeyState(VK_TAB) < 0 && GetAsyncKeyState(VK_MENU) >= 0)
|
|
|
#endif
|
|
|
{
|
|
|
if (!_networking && _game_mode != GM_MENU) _fast_forward |= 2;
|
|
|
} else if (_fast_forward & 2) {
|
|
|
_fast_forward = 0;
|
|
|
}
|
|
|
|
|
|
/* Determine which directional keys are down. */
|
|
|
if (_wnd.has_focus) {
|
|
|
_dirkeys =
|
|
|
(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
|
|
|
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
|
|
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
|
|
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
|
|
} else {
|
|
|
_dirkeys = 0;
|
|
|
}
|
|
|
|
|
|
if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
|
|
|
}
|
|
|
|
|
|
void VideoDriver_Win32::MainLoop()
|
|
|
{
|
|
|
MSG mesg;
|
|
|
auto cur_ticks = std::chrono::steady_clock::now();
|
|
|
auto last_realtime_tick = cur_ticks;
|
|
|
auto next_game_tick = cur_ticks;
|
|
@@ -1171,24 +1205,12 @@ void VideoDriver_Win32::MainLoop()
|
|
|
/* Convert key messages to char messages if we want text input. */
|
|
|
if (EditBoxInGlobalFocus()) TranslateMessage(&mesg);
|
|
|
DispatchMessage(&mesg);
|
|
|
}
|
|
|
if (_exit_game) break;
|
|
|
|
|
|
#if defined(_DEBUG)
|
|
|
if (_wnd.has_focus && GetAsyncKeyState(VK_SHIFT) < 0)
|
|
|
#else
|
|
|
/* Speed up using TAB, but disable for ALT+TAB of course */
|
|
|
if (_wnd.has_focus && GetAsyncKeyState(VK_TAB) < 0 && GetAsyncKeyState(VK_MENU) >= 0)
|
|
|
#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();
|
|
@@ -1217,36 +1239,19 @@ void VideoDriver_Win32::MainLoop()
|
|
|
/* Prevent drawing when switching mode, as windows can be removed when they should still appear. */
|
|
|
if (cur_ticks >= next_draw_tick && (_switch_mode == SM_NONE || HasModalProgress())) {
|
|
|
next_draw_tick += this->GetDrawInterval();
|
|
|
/* Avoid next_draw_tick getting behind more and more if it cannot keep up. */
|
|
|
if (next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) next_draw_tick = cur_ticks;
|
|
|
|
|
|
bool old_ctrl_pressed = _ctrl_pressed;
|
|
|
|
|
|
_ctrl_pressed = _wnd.has_focus && GetAsyncKeyState(VK_CONTROL)<0;
|
|
|
_shift_pressed = _wnd.has_focus && GetAsyncKeyState(VK_SHIFT)<0;
|
|
|
|
|
|
/* determine which directional keys are down */
|
|
|
if (_wnd.has_focus) {
|
|
|
_dirkeys =
|
|
|
(GetAsyncKeyState(VK_LEFT) < 0 ? 1 : 0) +
|
|
|
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
|
|
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
|
|
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
|
|
} else {
|
|
|
_dirkeys = 0;
|
|
|
}
|
|
|
|
|
|
if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
|
|
|
|
|
|
if (_force_full_redraw) MarkWholeScreenDirty();
|
|
|
|
|
|
/* Flush GDI buffer to ensure we don't conflict with the drawing thread. */
|
|
|
GdiFlush();
|
|
|
|
|
|
InputLoop();
|
|
|
this->InputLoop();
|
|
|
::InputLoop();
|
|
|
UpdateWindows();
|
|
|
CheckPaletteAnim();
|
|
|
|
|
|
if (_draw_mutex != nullptr && !HasModalProgress()) {
|
|
|
_draw_signal->notify_one();
|
|
|
} else {
|