Repository recovery 3: former r14320

Ignore all events received during the loading screen. Namely, this means that clicking on the STK window to focus it while it's loading will no longer open story mode.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14315 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2013-10-28 09:47:03 +00:00
parent 02e93b1e52
commit 46b19e2e8b
3 changed files with 21 additions and 0 deletions

View File

@@ -837,6 +837,17 @@ namespace GUIEngine
}
}
// Hack : on the first frame, irrlicht processes all events that have been queued
// during the loading screen. So way until the second frame to start processing events.
// (Events queues during the loading screens are likely the user clicking on the
// frame to focus it, or similar, and should not be used as a game event)
static int frame = 0;
if (frame < 2)
{
frame++;
if (frame == 2)
GUIEngine::EventHandler::get()->startAcceptingEvents();
}
}
// ------------------------------------------------------------------------

View File

@@ -44,6 +44,7 @@ using namespace irr::gui;
EventHandler::EventHandler()
{
m_accept_events = false;
}
// -----------------------------------------------------------------------------
@@ -56,6 +57,8 @@ EventHandler::~EventHandler()
bool EventHandler::OnEvent (const SEvent &event)
{
if (!m_accept_events && event.EventType != EET_LOG_TEXT_EVENT) return true;
// TO DEBUG HATS (when you don't actually have a hat)
/*
if (event.EventType == EET_KEY_INPUT_EVENT)

View File

@@ -55,6 +55,11 @@ namespace GUIEngine
*/
class EventHandler : public irr::IEventReceiver
{
/** This variable is used to ignore events during the initial load screen, so that
a player cannot trigger an action by clicking on the window during loading screen
for example */
bool m_accept_events;
EventPropagation onGUIEvent(const irr::SEvent& event);
EventPropagation onWidgetActivated(Widget* w, const int playerID);
void navigateUp(const int playerID, Input::InputType type, const bool pressedDown);
@@ -97,6 +102,8 @@ namespace GUIEngine
/** singleton access */
static EventHandler* get();
static void deallocate();
void startAcceptingEvents() { m_accept_events = true; }
};
}