mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Merge pull request #2746 from wb180/teamsPopup
Show only non-empty teams in teams popup
This commit is contained in:
		| @@ -393,32 +393,37 @@ CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox(std::shared_ptr<CAnimation> ico | |||||||
| 	: CWindowObject(BORDERED | RCLICK_POPUP | SHADOW_DISABLED, "DIBOXBCK") | 	: CWindowObject(BORDERED | RCLICK_POPUP | SHADOW_DISABLED, "DIBOXBCK") | ||||||
| { | { | ||||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; | 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; | ||||||
| 	pos.w = 256; |  | ||||||
| 	pos.h = 90 + 50 * SEL->getMapInfo()->mapHeader->howManyTeams; |  | ||||||
|  |  | ||||||
| 	labelTeamAlignment = std::make_shared<CLabel>(128, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[657]); | 	labelTeamAlignment = std::make_shared<CLabel>(128, 30, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[657]); | ||||||
| 	labelGroupTeams = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE); | 	labelGroupTeams = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE); | ||||||
| 	for(int i = 0; i < SEL->getMapInfo()->mapHeader->howManyTeams; i++) |  | ||||||
| 	{ |  | ||||||
| 		std::vector<ui8> flags; |  | ||||||
| 		labelGroupTeams->add(128, 65 + 50 * i, boost::str(boost::format(CGI->generaltexth->allTexts[656]) % (i+1))); |  | ||||||
|  |  | ||||||
| 		for(int j = 0; j < PlayerColor::PLAYER_LIMIT_I; j++) | 	std::vector<std::set<ui8>> teams(PlayerColor::PLAYER_LIMIT_I); | ||||||
|  | 	for(ui8 j = 0; j < PlayerColor::PLAYER_LIMIT_I; j++) | ||||||
| 	{ | 	{ | ||||||
| 			if((SEL->getPlayerInfo(j).canHumanPlay || SEL->getPlayerInfo(j).canComputerPlay) | 		if(SEL->getPlayerInfo(j).canHumanPlay || SEL->getPlayerInfo(j).canComputerPlay) | ||||||
| 				&& SEL->getPlayerInfo(j).team == TeamID(i)) |  | ||||||
| 		{ | 		{ | ||||||
| 				flags.push_back(j); | 			teams[SEL->getPlayerInfo(j).team].insert(j); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 		int curx = 128 - 9 * (int)flags.size(); | 	auto curIdx = 0; | ||||||
| 		for(auto & flag : flags) | 	for(const auto & team : teams) | ||||||
| 	{ | 	{ | ||||||
| 			iconsFlags.push_back(std::make_shared<CAnimImage>(icons, flag, 0, curx, 75 + 50 * i)); | 		if(team.empty()) | ||||||
|  | 			continue; | ||||||
|  |  | ||||||
|  | 		labelGroupTeams->add(128, 65 + 50 * curIdx, boost::str(boost::format(CGI->generaltexth->allTexts[656]) % (curIdx + 1))); | ||||||
|  | 		int curx = 128 - 9 * team.size(); | ||||||
|  | 		for(const auto & player : team) | ||||||
|  | 		{ | ||||||
|  | 			iconsFlags.push_back(std::make_shared<CAnimImage>(icons, player, 0, curx, 75 + 50 * curIdx)); | ||||||
| 			curx += 18; | 			curx += 18; | ||||||
| 		} | 		} | ||||||
|  | 		++curIdx; | ||||||
| 	} | 	} | ||||||
|  | 	pos.w = 256; | ||||||
|  | 	pos.h = 90 + 50 * curIdx; | ||||||
|  |  | ||||||
| 	background->scaleTo(Point(pos.w, pos.h)); | 	background->scaleTo(Point(pos.w, pos.h)); | ||||||
| 	center(); | 	center(); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user