mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Merge pull request #1969 from Nordsoft91/spectator
Single player spectator
This commit is contained in:
@ -401,16 +401,22 @@ void CClient::initPlayerEnvironments()
|
|||||||
playerEnvironments.clear();
|
playerEnvironments.clear();
|
||||||
|
|
||||||
auto allPlayers = CSH->getAllClientPlayers(CSH->c->connectionID);
|
auto allPlayers = CSH->getAllClientPlayers(CSH->c->connectionID);
|
||||||
if(allPlayers.empty())
|
bool hasHumanPlayer = false;
|
||||||
{
|
|
||||||
Settings session = settings.write["session"];
|
|
||||||
session["spectate"].Bool() = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto & color : allPlayers)
|
for(auto & color : allPlayers)
|
||||||
{
|
{
|
||||||
logNetwork->info("Preparing environment for player %s", color.getStr());
|
logNetwork->info("Preparing environment for player %s", color.getStr());
|
||||||
playerEnvironments[color] = std::make_shared<CPlayerEnvironment>(color, this, std::make_shared<CCallback>(gs, color, this));
|
playerEnvironments[color] = std::make_shared<CPlayerEnvironment>(color, this, std::make_shared<CCallback>(gs, color, this));
|
||||||
|
|
||||||
|
if(!hasHumanPlayer && gs->players[color].isHuman())
|
||||||
|
hasHumanPlayer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!hasHumanPlayer)
|
||||||
|
{
|
||||||
|
Settings session = settings.write["session"];
|
||||||
|
session["spectate"].Bool() = true;
|
||||||
|
session["spectate-skip-battle-result"].Bool() = true;
|
||||||
|
session["spectate-ignore-hero"].Bool() = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(settings["session"]["spectate"].Bool())
|
if(settings["session"]["spectate"].Bool())
|
||||||
|
@ -69,14 +69,14 @@ CLobbyScreen::CLobbyScreen(ESelectionScreen screenType)
|
|||||||
|
|
||||||
card->iconDifficulty->addCallback(std::bind(&IServerAPI::setDifficulty, CSH, _1));
|
card->iconDifficulty->addCallback(std::bind(&IServerAPI::setDifficulty, CSH, _1));
|
||||||
|
|
||||||
buttonStart = std::make_shared<CButton>(Point(411, 535), "SCNRBEG.DEF", CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, false), SDLK_b);
|
buttonStart = std::make_shared<CButton>(Point(411, 535), "SCNRBEG.DEF", CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, true), SDLK_b);
|
||||||
initLobby();
|
initLobby();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESelectionScreen::loadGame:
|
case ESelectionScreen::loadGame:
|
||||||
{
|
{
|
||||||
tabOpt = std::make_shared<OptionsTab>();
|
tabOpt = std::make_shared<OptionsTab>();
|
||||||
buttonStart = std::make_shared<CButton>(Point(411, 535), "SCNRLOD.DEF", CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, false), SDLK_l);
|
buttonStart = std::make_shared<CButton>(Point(411, 535), "SCNRLOD.DEF", CGI->generaltexth->zelp[103], std::bind(&CLobbyScreen::startScenario, this, true), SDLK_l);
|
||||||
initLobby();
|
initLobby();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry(const PlayerSettings & S, con
|
|||||||
|
|
||||||
void OptionsTab::onSetPlayerClicked(const PlayerSettings & ps) const
|
void OptionsTab::onSetPlayerClicked(const PlayerSettings & ps) const
|
||||||
{
|
{
|
||||||
if(ps.isControlledByAI() || humanPlayers > 1)
|
if(ps.isControlledByAI() || humanPlayers > 0)
|
||||||
CSH->setPlayer(ps.color);
|
CSH->setPlayer(ps.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user