diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index f4e574eb3..6a5d32ac6 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -653,6 +653,7 @@ namespace GUIEngine #include "guiengine/screen.hpp" #include "guiengine/skin.hpp" #include "guiengine/widget.hpp" +#include "modes/demo_world.hpp" #include "modes/world.hpp" #include "states_screens/race_gui_base.hpp" @@ -1168,6 +1169,20 @@ namespace GUIEngine g_driver->enableMaterial2D(false); + + if (gamestate == MENU) + { + if (DemoWorld::updateIdleTimeAndStartDemo(elapsed_time)) + { + return; + } + } + else + { + DemoWorld::resetIdleTime(); + } + + } // render // ----------------------------------------------------------------------- diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index 1bcc151b0..50aff798b 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -30,6 +30,7 @@ #include "guiengine/widgets/list_widget.hpp" #include "guiengine/widgets/ribbon_widget.hpp" #include "input/input_manager.hpp" +#include "modes/demo_world.hpp" #include "modes/world.hpp" #include "states_screens/state_manager.hpp" #include "utils/profiler.hpp" @@ -657,6 +658,8 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event) if (event.GUIEvent.Caller == NULL) return EVENT_LET; const s32 id = event.GUIEvent.Caller->getID(); + DemoWorld::resetIdleTime(); + switch (event.GUIEvent.EventType) { case EGET_BUTTON_CLICKED: diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 04b1b9657..6be789aa3 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -136,13 +136,6 @@ void MainMenuScreen::init() // ---------------------------------------------------------------------------- void MainMenuScreen::onUpdate(float delta, irr::video::IVideoDriver* driver) { - // If a demo mode is started, do nothing more - if(DemoWorld::updateIdleTimeAndStartDemo(delta)) - { - //StateManager::get()->popMenu(); - return; - } - IconButtonWidget* addons_icon = getWidget("addons"); if (addons_icon != NULL) { @@ -186,7 +179,6 @@ void MainMenuScreen::onUpdate(float delta, irr::video::IVideoDriver* driver) void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { - DemoWorld::resetIdleTime(); // most interesting stuff is in the ribbons, so start there RibbonWidget* ribbon = dynamic_cast(widget);