1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Implemented #715 (load game from sys options). Fixed #224. Minor improvements.

This commit is contained in:
Michał W. Urbańczyk
2012-04-09 02:53:50 +00:00
parent f9f0fe9d97
commit 8baec8b093
14 changed files with 85 additions and 42 deletions

View File

@ -697,6 +697,16 @@ static void listenForEvents()
}
else if(ev->type == SDL_USEREVENT)
{
auto endGame = []
{
client->endGame();
vstd::clear_pointer(client);
delete CGI->dobjinfo.get();
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
};
switch(ev->user.code)
{
case CHANGE_SCREEN_RESOLUTION:
@ -708,13 +718,7 @@ static void listenForEvents()
break;
}
case RETURN_TO_MAIN_MENU:
client->endGame();
vstd::clear_pointer(client);
delete CGI->dobjinfo.get();
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
endGame();
CGPreGame::createIfNotPresent();
GH.curInt = CGP;
GH.defActionsDef = 63;
@ -725,16 +729,18 @@ static void listenForEvents()
case RESTART_GAME:
{
StartInfo si = *client->getStartInfo();
client->endGame();
vstd::clear_pointer(client);
delete CGI->dobjinfo.get();
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
endGame();
startGame(&si);
}
break;
case RETURN_TO_MENU_LOAD:
endGame();
CGPreGame::createIfNotPresent();
GH.defActionsDef = 63;
CGP->update();
CGP->menu->switchToTab(vstd::find_pos(CGP->menu->menuNameToEntry, "load"));
GH.curInt = CGP;
break;
default:
tlog1 << "Error: unknown user event. Code " << ev->user.code << std::endl;
assert(0);