1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +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
3 changed files with 6 additions and 4 deletions

View File

@@ -1707,6 +1707,7 @@ void CPlayerInterface::requestReturningToMainMenu(bool won)
param.allDefeated = false; param.allDefeated = false;
} }
param.scenarioName = cb->getMapHeader()->name; param.scenarioName = cb->getMapHeader()->name;
param.playerName = cb->getStartInfo()->playerInfos.find(*cb->getPlayerID())->second.name;
HighScoreCalculation highScoreCalc; HighScoreCalculation highScoreCalc;
highScoreCalc.parameters.push_back(param); highScoreCalc.parameters.push_back(param);
highScoreCalc.isCampaign = false; highScoreCalc.isCampaign = false;

View File

@@ -335,7 +335,7 @@ void CHighScoreInputScreen::clickPressed(const Point & cursorPosition)
if(!input) if(!input)
{ {
input = std::make_shared<CHighScoreInput>( input = std::make_shared<CHighScoreInput>(calc.parameters[0].playerName,
[&] (std::string text) [&] (std::string text)
{ {
if(!text.empty()) if(!text.empty())
@@ -355,7 +355,7 @@ void CHighScoreInputScreen::keyPressed(EShortcut key)
clickPressed(Point()); 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) : CWindowObject(0, ImagePath::builtin("HIGHNAME")), ready(readyCB)
{ {
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; 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); 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)); 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 = std::make_shared<CTextInput>(Rect(18, 104, 200, 25), FONT_SMALL, 0);
textInput->setText(settings["general"]["playerName"].String()); textInput->setText(playerName);
} }
void CHighScoreInput::okay() void CHighScoreInput::okay()

View File

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