mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Merge pull request #2892 from Laserlicht/highscore_menu
Highscore Menu & end video
This commit is contained in:
@ -37,6 +37,7 @@
|
||||
#include "gui/WindowHandler.h"
|
||||
|
||||
#include "mainmenu/CMainMenu.h"
|
||||
#include "mainmenu/CHighScoreScreen.h"
|
||||
|
||||
#include "mapView/mapHandler.h"
|
||||
|
||||
@ -1697,16 +1698,43 @@ void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
|
||||
|
||||
void CPlayerInterface::requestReturningToMainMenu(bool won)
|
||||
{
|
||||
HighScoreParameter param;
|
||||
param.difficulty = cb->getStartInfo()->difficulty;
|
||||
param.day = cb->getDate();
|
||||
param.townAmount = cb->howManyTowns();
|
||||
param.usedCheat = cb->getPlayerState(*cb->getPlayerID())->cheated;
|
||||
param.hasGrail = false;
|
||||
for(const CGHeroInstance * h : cb->getHeroesInfo())
|
||||
if(h->hasArt(ArtifactID::GRAIL))
|
||||
param.hasGrail = true;
|
||||
for(const CGTownInstance * t : cb->getTownsInfo())
|
||||
if(t->builtBuildings.count(BuildingID::GRAIL))
|
||||
param.hasGrail = true;
|
||||
param.allDefeated = true;
|
||||
for (PlayerColor player(0); player < PlayerColor::PLAYER_LIMIT; ++player)
|
||||
{
|
||||
auto ps = cb->getPlayerState(player, false);
|
||||
if(ps && player != *cb->getPlayerID())
|
||||
if(!ps->checkVanquished())
|
||||
param.allDefeated = false;
|
||||
}
|
||||
param.scenarioName = cb->getMapHeader()->name;
|
||||
param.playerName = cb->getStartInfo()->playerInfos.find(*cb->getPlayerID())->second.name;
|
||||
HighScoreCalculation highScoreCalc;
|
||||
highScoreCalc.parameters.push_back(param);
|
||||
highScoreCalc.isCampaign = false;
|
||||
|
||||
if(won && cb->getStartInfo()->campState)
|
||||
CSH->startCampaignScenario(cb->getStartInfo()->campState);
|
||||
CSH->startCampaignScenario(param, cb->getStartInfo()->campState);
|
||||
else
|
||||
{
|
||||
GH.dispatchMainThread(
|
||||
[]()
|
||||
[won, highScoreCalc]()
|
||||
{
|
||||
CSH->endGameplay();
|
||||
GH.defActionsDef = 63;
|
||||
CMM->menu->switchToTab("main");
|
||||
GH.windows().createAndPushWindow<CHighScoreInputScreen>(won, highScoreCalc);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user