瀏覽代碼

fix playername

Laserlicht 2 年之前
父節點
當前提交
242e0ffa4a
共有 3 個文件被更改,包括 6 次插入4 次删除
  1. 1 0
      client/CPlayerInterface.cpp
  2. 3 3
      client/mainmenu/CHighScoreScreen.cpp
  3. 2 1
      client/mainmenu/CHighScoreScreen.h

+ 1 - 0
client/CPlayerInterface.cpp

@@ -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;

+ 3 - 3
client/mainmenu/CHighScoreScreen.cpp

@@ -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()

+ 2 - 1
client/mainmenu/CHighScoreScreen.h

@@ -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