diff options
author | Kahrl <kahrl@gmx.net> | 2013-08-19 14:55:38 +0200 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2013-08-19 15:49:36 +0200 |
commit | ade70fe4b92202065c17d04f21415848b2c6d419 (patch) | |
tree | 14fa79b64c8eb744082d13443a01c55ce673b53c /src | |
parent | 4242782dc27e7932e050677b92ec8b1a994a4f0d (diff) | |
download | minetest-ade70fe4b92202065c17d04f21415848b2c6d419.tar.gz minetest-ade70fe4b92202065c17d04f21415848b2c6d419.tar.bz2 minetest-ade70fe4b92202065c17d04f21415848b2c6d419.zip |
Allow SIGINT to kill mainmenu again
Diffstat (limited to 'src')
-rw-r--r-- | src/guiEngine.cpp | 6 | ||||
-rw-r--r-- | src/guiEngine.h | 6 | ||||
-rw-r--r-- | src/guiMainMenu.h | 3 | ||||
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 6 |
5 files changed, 11 insertions, 15 deletions
diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index f89ad8731..f00cd039c 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -79,7 +79,8 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev, gui::IGUIElement* parent, IMenuManager *menumgr, scene::ISceneManager* smgr, - MainMenuData* data) : + MainMenuData* data, + bool& kill) : m_device(dev), m_parent(parent), m_menumanager(menumgr), @@ -89,6 +90,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev, m_formspecgui(0), m_buttonhandler(0), m_menu(0), + m_kill(kill), m_startgame(false), m_script(0), m_scriptdir(""), @@ -219,7 +221,7 @@ void GUIEngine::run() cloudInit(); - while(m_device->run() && (!m_startgame)) { + while(m_device->run() && (!m_startgame) && (!m_kill)) { driver->beginScene(true, true, video::SColor(255,140,186,250)); if (m_clouds_enabled) diff --git a/src/guiEngine.h b/src/guiEngine.h index 3987b52c7..6b7d3b6ed 100644 --- a/src/guiEngine.h +++ b/src/guiEngine.h @@ -109,7 +109,8 @@ public: gui::IGUIElement* parent, IMenuManager *menumgr, scene::ISceneManager* smgr, - MainMenuData* data); + MainMenuData* data, + bool& kill); /** default destructor */ virtual ~GUIEngine(); @@ -159,6 +160,9 @@ private: /** the formspec menu */ GUIFormSpecMenu* m_menu; + /** reference to kill variable managed by SIGINT handler */ + bool& m_kill; + /** variable used to abort menu and return back to main game handling */ bool m_startgame; diff --git a/src/guiMainMenu.h b/src/guiMainMenu.h index 5eaca23fa..34362dba6 100644 --- a/src/guiMainMenu.h +++ b/src/guiMainMenu.h @@ -49,9 +49,6 @@ struct MainMenuData int selected_world; bool simple_singleplayer_mode; - // Actions - bool kill; - //error handling std::string errormessage; MainMenuData(): diff --git a/src/main.cpp b/src/main.cpp index 05a7dd163..41acfe7b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1519,7 +1519,6 @@ int main(int argc, char *argv[]) // Initialize menu data MainMenuData menudata; - menudata.kill = kill; menudata.address = address; menudata.name = playername; menudata.port = itos(port); @@ -1565,13 +1564,11 @@ int main(int argc, char *argv[]) } infostream<<"Waited for other menus"<<std::endl; - GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata); + GUIEngine* temp = new GUIEngine(device, guiroot, &g_menumgr,smgr,&menudata,kill); delete temp; //once finished you'll never end up here smgr->clear(); - kill = menudata.kill; - } if(menudata.errormessage != ""){ diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 65676eacd..6417d1e18 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -131,11 +131,7 @@ int ModApiMainMenu::l_close(lua_State *L) GUIEngine* engine = getGuiEngine(L); assert(engine != 0); - engine->m_data->kill = true; - - //close menu next time - engine->m_startgame = true; - engine->m_menu->quitMenu(); + engine->m_kill = true; return 0; } |