mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
- Show confirmation dialog when pressing Alt + F4 to quit the game
This commit is contained in:
parent
30b3081ac4
commit
f2cc630e2c
@ -846,7 +846,7 @@ static void listenForEvents()
|
|||||||
(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4 && (ev.key.keysym.mod & KMOD_ALT)))
|
(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4 && (ev.key.keysym.mod & KMOD_ALT)))
|
||||||
{
|
{
|
||||||
handleQuit();
|
handleQuit();
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
else if(LOCPLINT && ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4)
|
else if(LOCPLINT && ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4)
|
||||||
{
|
{
|
||||||
@ -949,21 +949,34 @@ void startGame(StartInfo * options, CConnection *serv/* = nullptr*/)
|
|||||||
|
|
||||||
void handleQuit()
|
void handleQuit()
|
||||||
{
|
{
|
||||||
if (client)
|
auto quitApplication = []()
|
||||||
client->endGame();
|
|
||||||
if (mainGUIThread)
|
|
||||||
{
|
{
|
||||||
GH.terminate = true;
|
if(client) client->endGame();
|
||||||
mainGUIThread->join();
|
|
||||||
delete mainGUIThread;
|
|
||||||
mainGUIThread = nullptr;
|
|
||||||
}
|
|
||||||
delete console;
|
|
||||||
console = nullptr;
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(750));
|
|
||||||
if(!gNoGUI)
|
|
||||||
SDL_Quit();
|
|
||||||
|
|
||||||
std::cout << "Ending...\n";
|
if(mainGUIThread)
|
||||||
exit(0);
|
{
|
||||||
|
GH.terminate = true;
|
||||||
|
if(mainGUIThread->get_id() != boost::this_thread::get_id()) mainGUIThread->join();
|
||||||
|
delete mainGUIThread;
|
||||||
|
mainGUIThread = nullptr;
|
||||||
|
}
|
||||||
|
delete console;
|
||||||
|
console = nullptr;
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(750));
|
||||||
|
if(!gNoGUI)
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
std::cout << "Ending...\n";
|
||||||
|
exit(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
if(client && LOCPLINT)
|
||||||
|
{
|
||||||
|
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
|
||||||
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[69], quitApplication, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
quitApplication();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user