소스 검색

- Show confirmation dialog when pressing Alt + F4 to quit the game

beegee1 12 년 전
부모
커밋
f2cc630e2c
1개의 변경된 파일30개의 추가작업 그리고 17개의 파일을 삭제
  1. 30 17
      client/CMT.cpp

+ 30 - 17
client/CMT.cpp

@@ -846,7 +846,7 @@ static void listenForEvents()
 			(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4 && (ev.key.keysym.mod & KMOD_ALT)))
 		{
 			handleQuit();
-			break;
+			continue;
 		}
 		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()
 {
-	if (client)
-		client->endGame();
-	if (mainGUIThread) 
-	{
-		GH.terminate = true;
-		mainGUIThread->join();
-		delete mainGUIThread;
-		mainGUIThread = nullptr;
-	}
-	delete console;
-	console = nullptr;
-	boost::this_thread::sleep(boost::posix_time::milliseconds(750));
-	if(!gNoGUI)
-		SDL_Quit();
+	auto quitApplication = []()
+	{
+		if(client) client->endGame();
+
+		if(mainGUIThread)
+		{
+			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);
+		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();
+	}
 }