forked from Mirrorlandia_minetest/minetest
Allow SIGINT to kill mainmenu again
This commit is contained in:
parent
4242782dc2
commit
ade70fe4b9
@ -79,7 +79,8 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
|
|||||||
gui::IGUIElement* parent,
|
gui::IGUIElement* parent,
|
||||||
IMenuManager *menumgr,
|
IMenuManager *menumgr,
|
||||||
scene::ISceneManager* smgr,
|
scene::ISceneManager* smgr,
|
||||||
MainMenuData* data) :
|
MainMenuData* data,
|
||||||
|
bool& kill) :
|
||||||
m_device(dev),
|
m_device(dev),
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_menumanager(menumgr),
|
m_menumanager(menumgr),
|
||||||
@ -89,6 +90,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev,
|
|||||||
m_formspecgui(0),
|
m_formspecgui(0),
|
||||||
m_buttonhandler(0),
|
m_buttonhandler(0),
|
||||||
m_menu(0),
|
m_menu(0),
|
||||||
|
m_kill(kill),
|
||||||
m_startgame(false),
|
m_startgame(false),
|
||||||
m_script(0),
|
m_script(0),
|
||||||
m_scriptdir(""),
|
m_scriptdir(""),
|
||||||
@ -219,7 +221,7 @@ void GUIEngine::run()
|
|||||||
|
|
||||||
cloudInit();
|
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));
|
driver->beginScene(true, true, video::SColor(255,140,186,250));
|
||||||
|
|
||||||
if (m_clouds_enabled)
|
if (m_clouds_enabled)
|
||||||
|
@ -109,7 +109,8 @@ public:
|
|||||||
gui::IGUIElement* parent,
|
gui::IGUIElement* parent,
|
||||||
IMenuManager *menumgr,
|
IMenuManager *menumgr,
|
||||||
scene::ISceneManager* smgr,
|
scene::ISceneManager* smgr,
|
||||||
MainMenuData* data);
|
MainMenuData* data,
|
||||||
|
bool& kill);
|
||||||
|
|
||||||
/** default destructor */
|
/** default destructor */
|
||||||
virtual ~GUIEngine();
|
virtual ~GUIEngine();
|
||||||
@ -159,6 +160,9 @@ private:
|
|||||||
/** the formspec menu */
|
/** the formspec menu */
|
||||||
GUIFormSpecMenu* m_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 */
|
/** variable used to abort menu and return back to main game handling */
|
||||||
bool m_startgame;
|
bool m_startgame;
|
||||||
|
|
||||||
|
@ -49,9 +49,6 @@ struct MainMenuData
|
|||||||
int selected_world;
|
int selected_world;
|
||||||
bool simple_singleplayer_mode;
|
bool simple_singleplayer_mode;
|
||||||
|
|
||||||
// Actions
|
|
||||||
bool kill;
|
|
||||||
|
|
||||||
//error handling
|
//error handling
|
||||||
std::string errormessage;
|
std::string errormessage;
|
||||||
MainMenuData():
|
MainMenuData():
|
||||||
|
@ -1519,7 +1519,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Initialize menu data
|
// Initialize menu data
|
||||||
MainMenuData menudata;
|
MainMenuData menudata;
|
||||||
menudata.kill = kill;
|
|
||||||
menudata.address = address;
|
menudata.address = address;
|
||||||
menudata.name = playername;
|
menudata.name = playername;
|
||||||
menudata.port = itos(port);
|
menudata.port = itos(port);
|
||||||
@ -1565,13 +1564,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
infostream<<"Waited for other menus"<<std::endl;
|
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;
|
delete temp;
|
||||||
//once finished you'll never end up here
|
//once finished you'll never end up here
|
||||||
smgr->clear();
|
smgr->clear();
|
||||||
kill = menudata.kill;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(menudata.errormessage != ""){
|
if(menudata.errormessage != ""){
|
||||||
|
@ -131,11 +131,7 @@ int ModApiMainMenu::l_close(lua_State *L)
|
|||||||
GUIEngine* engine = getGuiEngine(L);
|
GUIEngine* engine = getGuiEngine(L);
|
||||||
assert(engine != 0);
|
assert(engine != 0);
|
||||||
|
|
||||||
engine->m_data->kill = true;
|
engine->m_kill = true;
|
||||||
|
|
||||||
//close menu next time
|
|
||||||
engine->m_startgame = true;
|
|
||||||
engine->m_menu->quitMenu();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user