1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00

fix playername

This commit is contained in:
Laserlicht 2023-09-26 22:06:04 +02:00 committed by GitHub
parent 02c82cb35b
commit 242e0ffa4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -1707,6 +1707,7 @@ void CPlayerInterface::requestReturningToMainMenu(bool won)
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;

View File

@ -335,7 +335,7 @@ void CHighScoreInputScreen::clickPressed(const Point & cursorPosition)
if(!input)
{
input = std::make_shared<CHighScoreInput>(
input = std::make_shared<CHighScoreInput>(calc.parameters[0].playerName,
[&] (std::string text)
{
if(!text.empty())
@ -355,7 +355,7 @@ void CHighScoreInputScreen::keyPressed(EShortcut key)
clickPressed(Point());
}
CHighScoreInput::CHighScoreInput(std::function<void(std::string text)> readyCB)
CHighScoreInput::CHighScoreInput(std::string playerName, std::function<void(std::string text)> readyCB)
: CWindowObject(0, ImagePath::builtin("HIGHNAME")), ready(readyCB)
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
@ -369,7 +369,7 @@ CHighScoreInput::CHighScoreInput(std::function<void(std::string text)> readyCB)
buttonCancel = std::make_shared<CButton>(Point(142, 142), AnimationPath::builtin("MUBCANC.DEF"), CGI->generaltexth->zelp[561], std::bind(&CHighScoreInput::abort, this), EShortcut::GLOBAL_CANCEL);
statusBar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(7, 186, 218, 18), 7, 186));
textInput = std::make_shared<CTextInput>(Rect(18, 104, 200, 25), FONT_SMALL, 0);
textInput->setText(settings["general"]["playerName"].String());
textInput->setText(playerName);
}
void CHighScoreInput::okay()

View File

@ -29,6 +29,7 @@ public:
bool allDefeated;
std::string campaignName;
std::string scenarioName;
std::string playerName;
};
class HighScoreCalculation
@ -84,7 +85,7 @@ class CHighScoreInput : public CWindowObject
void okay();
void abort();
public:
CHighScoreInput(std::function<void(std::string text)> readyCB);
CHighScoreInput(std::string playerName, std::function<void(std::string text)> readyCB);
};
class CHighScoreInputScreen : public CWindowObject