1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

SDL event handling is now done exclusively in input handler

This commit is contained in:
Ivan Savenko
2023-05-18 23:31:05 +03:00
parent 5e86b00dda
commit 0e70f2998f
14 changed files with 52 additions and 78 deletions

View File

@@ -12,15 +12,13 @@
#include "CMT.h"
#include "gui/CGuiHandler.h"
#include "eventsSDL/InputHandler.h"
#include "gui/FramerateManager.h"
#include "renderSDL/SDL_Extensions.h"
#include "CPlayerInterface.h"
#include "../lib/filesystem/Filesystem.h"
#include <SDL_render.h>
#include <SDL_events.h>
extern CGuiHandler GH; //global gui handler
#ifndef DISABLE_VIDEO
@@ -31,18 +29,6 @@ extern "C" {
#include <libswscale/swscale.h>
}
//reads events and returns true on key down
static bool keyDown()
{
SDL_Event ev;
while(SDL_PollEvent(&ev))
{
if(ev.type == SDL_KEYDOWN || ev.type == SDL_MOUSEBUTTONDOWN)
return true;
}
return false;
}
#ifdef _MSC_VER
#pragma comment(lib, "avcodec.lib")
#pragma comment(lib, "avutil.lib")
@@ -455,7 +441,9 @@ bool CVideoPlayer::playVideo(int x, int y, bool stopOnKey)
while(nextFrame())
{
if(stopOnKey && keyDown())
GH.input().fetchEvents();
if(stopOnKey && GH.input().ignoreEventsUntilInput())
return false;
SDL_Rect rect = CSDL_Ext::toSDL(pos);