Michael 2 tahun lalu
induk
melakukan
e61dc2ec23
3 mengubah file dengan 29 tambahan dan 22 penghapusan
  1. 1 1
      client/CServerHandler.h
  2. 21 21
      client/lobby/OptionsTab.cpp
  3. 7 0
      client/lobby/OptionsTab.h

+ 1 - 1
client/CServerHandler.h

@@ -62,7 +62,7 @@ public:
 	virtual void setCampaignBonus(int bonusId) const = 0;
 	virtual void setMapInfo(std::shared_ptr<CMapInfo> to, std::shared_ptr<CMapGenOptions> mapGenOpts = {}) const = 0;
 	virtual void setPlayer(PlayerColor color) const = 0;
-	virtual void setPlayerOption(ui8 what, si16 value, PlayerColor player) const = 0;
+	virtual void setPlayerOption(ui8 what, int32_t value, PlayerColor player) const = 0;
 	virtual void setDifficulty(int to) const = 0;
 	virtual void setTurnLength(int npos) const = 0;
 	virtual void sendMessage(const std::string & txt) const = 0;

+ 21 - 21
client/lobby/OptionsTab.cpp

@@ -518,8 +518,8 @@ void OptionsTab::SelectionWindow::recreate()
 		amountLines = calcLines((type > SelType::TOWN) ? selectedFaction : static_cast<FactionID>(PlayerSettings::RANDOM));
 	}
 
-	int x = (elementsPerLine) * 57;
-	int y = (amountLines) * 63;
+	int x = (elementsPerLine) * (ICON_BIG_WIDTH-1);
+	int y = (amountLines) * (ICON_BIG_HEIGHT-1);
 
 	pos = Rect(0, 0, x, y);
 
@@ -553,7 +553,7 @@ void OptionsTab::SelectionWindow::genContentGrid(int lines)
 	{
 		for(int x = 0; x < elementsPerLine; x++)
 		{
-			components.push_back(std::make_shared<CPicture>("lobby/townBorderBig", x * 57, y * 63));
+			components.push_back(std::make_shared<CPicture>("lobby/townBorderBig", x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
 		}
 	}
 }
@@ -566,10 +566,10 @@ void OptionsTab::SelectionWindow::genContentFactions()
 	PlayerSettings set = PlayerSettings();
 	set.castle = PlayerSettings::RANDOM;
 	CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
-	components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, 6, 32 / 2));
-	drawOutlinedText(29, 56, (selectedFaction == PlayerSettings::RANDOM) ? Colors::YELLOW : Colors::WHITE, helper.getName());
+	components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, 6, (ICON_SMALL_HEIGHT/2)));
+	drawOutlinedText(TEXT_POS_X, TEXT_POS_Y, (selectedFaction == PlayerSettings::RANDOM) ? Colors::YELLOW : Colors::WHITE, helper.getName());
 	if(selectedFaction == PlayerSettings::RANDOM)
-		components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", 6, 32 / 2));
+		components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", 6, (ICON_SMALL_HEIGHT/2)));
 
 	for(auto & elem : allowedFactions)
 	{
@@ -581,9 +581,9 @@ void OptionsTab::SelectionWindow::genContentFactions()
 
 		CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::TOWN);
 
-		components.push_back(std::make_shared<CAnimImage>(helper.getImageName(true), helper.getImageIndex(true), 0, x * 57, y * 63));
-		components.push_back(std::make_shared<CPicture>(selectedFaction == elem ? "lobby/townBorderBigActivated" : "lobby/townBorderBig", x * 57, y * 63));
-		drawOutlinedText(x * 57 + 29, y * 63 + 56, (selectedFaction == elem) ? Colors::YELLOW : Colors::WHITE, helper.getName());
+		components.push_back(std::make_shared<CAnimImage>(helper.getImageName(true), helper.getImageIndex(true), 0, x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
+		components.push_back(std::make_shared<CPicture>(selectedFaction == elem ? "lobby/townBorderBigActivated" : "lobby/townBorderBig", x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
+		drawOutlinedText(x * (ICON_BIG_WIDTH-1) + TEXT_POS_X, y * (ICON_BIG_HEIGHT-1) + TEXT_POS_Y, (selectedFaction == elem) ? Colors::YELLOW : Colors::WHITE, helper.getName());
 		factions.push_back(elem);
 
 		i++;
@@ -598,10 +598,10 @@ void OptionsTab::SelectionWindow::genContentHeroes()
 	PlayerSettings set = PlayerSettings();
 	set.hero = PlayerSettings::RANDOM;
 	CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
-	components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, 6, 32 / 2));
-	drawOutlinedText(29, 56, (selectedHero == PlayerSettings::RANDOM) ? Colors::YELLOW : Colors::WHITE, helper.getName());
+	components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, 6, (ICON_SMALL_HEIGHT/2)));
+	drawOutlinedText(TEXT_POS_X, TEXT_POS_Y, (selectedHero == PlayerSettings::RANDOM) ? Colors::YELLOW : Colors::WHITE, helper.getName());
 	if(selectedHero == PlayerSettings::RANDOM)
-		components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", 6, 32 / 2));
+		components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", 6, (ICON_SMALL_HEIGHT/2)));
 
 	for(auto & elem : allowedHeroes)
 	{
@@ -618,9 +618,9 @@ void OptionsTab::SelectionWindow::genContentHeroes()
 
 			CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::HERO);
 
-			components.push_back(std::make_shared<CAnimImage>(helper.getImageName(true), helper.getImageIndex(true), 0, x * 57, y * 63));
-			components.push_back(std::make_shared<CPicture>(selectedHero == elem ? "lobby/townBorderBigActivated" : "lobby/townBorderBig", x * 57, y * 63));
-			drawOutlinedText(x * 57 + 29, y * 63 + 56, (selectedHero == elem) ? Colors::YELLOW : Colors::WHITE, helper.getName());
+			components.push_back(std::make_shared<CAnimImage>(helper.getImageName(true), helper.getImageIndex(true), 0, x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
+			components.push_back(std::make_shared<CPicture>(selectedHero == elem ? "lobby/townBorderBigActivated" : "lobby/townBorderBig", x * (ICON_BIG_WIDTH-1), y * (ICON_BIG_HEIGHT-1)));
+			drawOutlinedText(x * (ICON_BIG_WIDTH-1) + TEXT_POS_X, y * (ICON_BIG_HEIGHT-1) + TEXT_POS_Y, (selectedHero == elem) ? Colors::YELLOW : Colors::WHITE, helper.getName());
 			heroes.push_back(elem);
 
 			i++;
@@ -640,12 +640,12 @@ void OptionsTab::SelectionWindow::genContentBonus()
 
 		set.bonus = static_cast<PlayerSettings::Ebonus>(elem);
 		CPlayerSettingsHelper helper = CPlayerSettingsHelper(set, SelType::BONUS);
-		components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, x * 57 + 6, y * 63 + 32 / 2));
-		drawOutlinedText(x * 57 + 29, y * 63 + 56, Colors::WHITE , helper.getName());
+		components.push_back(std::make_shared<CAnimImage>(helper.getImageName(), helper.getImageIndex(), 0, x * (ICON_BIG_WIDTH-1) + 6, y * (ICON_BIG_HEIGHT-1) + (ICON_SMALL_HEIGHT/2)));
+		drawOutlinedText(x * (ICON_BIG_WIDTH-1) + TEXT_POS_X, y * (ICON_BIG_HEIGHT-1) + TEXT_POS_Y, Colors::WHITE , helper.getName());
 		if(selectedBonus == elem)
 		{
-			components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", x * 57 + 6, y * 63 + 32 / 2));
-			drawOutlinedText(x * 57 + 29, y * 63 + 56, Colors::YELLOW , helper.getName());
+			components.push_back(std::make_shared<CPicture>("lobby/townBorderSmallActivated", x * (ICON_BIG_WIDTH-1) + 6, y * (ICON_BIG_HEIGHT-1) + (ICON_SMALL_HEIGHT/2)));
+			drawOutlinedText(x * (ICON_BIG_WIDTH-1) + TEXT_POS_X, y * (ICON_BIG_HEIGHT-1) + TEXT_POS_Y, Colors::YELLOW , helper.getName());
 		}
 
 		i++;
@@ -654,8 +654,8 @@ void OptionsTab::SelectionWindow::genContentBonus()
 
 int OptionsTab::SelectionWindow::getElement(const Point & cursorPosition)
 {
-	int x = (cursorPosition.x - pos.x) / 57;
-	int y = (cursorPosition.y - pos.y) / 63;
+	int x = (cursorPosition.x - pos.x) / (ICON_BIG_WIDTH-1);
+	int y = (cursorPosition.y - pos.y) / (ICON_BIG_HEIGHT-1);
 
 	return x + y * elementsPerLine;
 }

+ 7 - 0
client/lobby/OptionsTab.h

@@ -98,6 +98,13 @@ public:
 
 	class SelectionWindow : public CWindowObject
 	{
+		const int ICON_SMALL_WIDTH = 48;
+		const int ICON_SMALL_HEIGHT = 32;
+		const int ICON_BIG_WIDTH = 58;
+		const int ICON_BIG_HEIGHT = 64;
+		const int TEXT_POS_X = 29;
+		const int TEXT_POS_Y = 56;
+
 		int elementsPerLine;
 
 		PlayerColor color;