2018-01-05 19:21:07 +02:00
|
|
|
/*
|
|
|
|
* CSelectionBase.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "CSelectionBase.h"
|
|
|
|
#include "CBonusSelection.h"
|
|
|
|
#include "CLobbyScreen.h"
|
|
|
|
#include "OptionsTab.h"
|
|
|
|
#include "RandomMapTab.h"
|
|
|
|
#include "SelectionTab.h"
|
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
|
|
|
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CPlayerInterface.h"
|
|
|
|
#include "../CMusicHandler.h"
|
|
|
|
#include "../CVideoHandler.h"
|
|
|
|
#include "../CPlayerInterface.h"
|
|
|
|
#include "../CServerHandler.h"
|
|
|
|
#include "../gui/CGuiHandler.h"
|
|
|
|
#include "../mainmenu/CMainMenu.h"
|
|
|
|
#include "../widgets/CComponent.h"
|
|
|
|
#include "../widgets/Buttons.h"
|
|
|
|
#include "../widgets/MiscWidgets.h"
|
|
|
|
#include "../widgets/ObjectLists.h"
|
|
|
|
#include "../widgets/TextControls.h"
|
|
|
|
#include "../windows/GUIClasses.h"
|
|
|
|
#include "../windows/InfoWindows.h"
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../render/CAnimation.h"
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
#include "../../lib/NetPacksLobby.h"
|
|
|
|
#include "../../lib/CGeneralTextHandler.h"
|
|
|
|
#include "../../lib/CHeroHandler.h"
|
|
|
|
#include "../../lib/CThreadHelper.h"
|
|
|
|
#include "../../lib/filesystem/Filesystem.h"
|
|
|
|
#include "../../lib/mapping/CMapInfo.h"
|
|
|
|
#include "../../lib/serializer/Connection.h"
|
|
|
|
|
|
|
|
ISelectionScreenInfo::ISelectionScreenInfo(ESelectionScreen ScreenType)
|
|
|
|
: screenType(ScreenType)
|
|
|
|
{
|
|
|
|
assert(!SEL);
|
|
|
|
SEL = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISelectionScreenInfo::~ISelectionScreenInfo()
|
|
|
|
{
|
|
|
|
assert(SEL == this);
|
|
|
|
SEL = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ISelectionScreenInfo::getCurrentDifficulty()
|
|
|
|
{
|
|
|
|
return getStartInfo()->difficulty;
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayerInfo ISelectionScreenInfo::getPlayerInfo(int color)
|
|
|
|
{
|
|
|
|
return getMapInfo()->mapHeader->players[color];
|
|
|
|
}
|
|
|
|
|
|
|
|
CSelectionBase::CSelectionBase(ESelectionScreen type)
|
|
|
|
: CWindowObject(BORDERED | SHADOW_DISABLED), ISelectionScreenInfo(type)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
IShowActivatable::type = BLOCK_ADV_HOTKEYS;
|
|
|
|
pos.w = 762;
|
|
|
|
pos.h = 584;
|
|
|
|
if(screenType == ESelectionScreen::campaignList)
|
|
|
|
{
|
|
|
|
setBackground("CamCust.bmp");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const JsonVector & bgNames = CMainMenuConfig::get().getConfig()["game-select"].Vector();
|
|
|
|
setBackground(RandomGeneratorUtil::nextItem(bgNames, CRandomGenerator::getDefault())->String());
|
|
|
|
}
|
|
|
|
pos = background->center();
|
|
|
|
card = std::make_shared<InfoCard>();
|
2018-07-25 00:36:48 +02:00
|
|
|
buttonBack = std::make_shared<CButton>(Point(581, 535), "SCNRBACK.DEF", CGI->generaltexth->zelp[105], [=](){ close();}, SDLK_ESCAPE);
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSelectionBase::toggleTab(std::shared_ptr<CIntObject> tab)
|
|
|
|
{
|
|
|
|
if(curTab && curTab->active)
|
|
|
|
{
|
|
|
|
curTab->deactivate();
|
|
|
|
curTab->recActions = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(curTab != tab)
|
|
|
|
{
|
|
|
|
tab->recActions = 255 - DISPOSE;
|
|
|
|
tab->activate();
|
|
|
|
curTab = tab;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
curTab.reset();
|
|
|
|
}
|
|
|
|
GH.totalRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
InfoCard::InfoCard()
|
|
|
|
: showChat(true)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
CIntObject::type |= REDRAW_PARENT;
|
|
|
|
pos.x += 393;
|
|
|
|
pos.y += 6;
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
labelSaveDate = std::make_shared<CLabel>(158, 19, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
|
|
|
mapName = std::make_shared<CLabel>(26, 39, FONT_BIG, ETextAlignment::TOPLEFT, Colors::YELLOW);
|
2018-01-05 19:21:07 +02:00
|
|
|
Rect descriptionRect(26, 149, 320, 115);
|
|
|
|
mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1);
|
|
|
|
playerListBg = std::make_shared<CPicture>("CHATPLUG.bmp", 16, 276);
|
|
|
|
chat = std::make_shared<CChatBox>(Rect(26, 132, 340, 132));
|
|
|
|
|
|
|
|
if(SEL->screenType == ESelectionScreen::campaignList)
|
|
|
|
{
|
2022-11-26 23:12:20 +02:00
|
|
|
labelCampaignDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
background = std::make_shared<CPicture>("GSELPOP1.bmp", 0, 0);
|
|
|
|
parent->addChild(background.get());
|
|
|
|
auto it = vstd::find(parent->children, this); //our position among parent children
|
|
|
|
parent->children.insert(it, background.get()); //put BG before us
|
|
|
|
parent->children.pop_back();
|
|
|
|
pos.w = background->pos.w;
|
|
|
|
pos.h = background->pos.h;
|
|
|
|
iconsMapSizes = std::make_shared<CAnimImage>("SCNRMPSZ", 4, 0, 318, 22); //let it be custom size (frame 4) by default
|
|
|
|
|
|
|
|
iconDifficulty = std::make_shared<CToggleGroup>(0);
|
|
|
|
{
|
|
|
|
static const char * difButns[] = {"GSPBUT3.DEF", "GSPBUT4.DEF", "GSPBUT5.DEF", "GSPBUT6.DEF", "GSPBUT7.DEF"};
|
|
|
|
|
|
|
|
for(int i = 0; i < 5; i++)
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
auto button = std::make_shared<CToggleButton>(Point(110 + i * 32, 450), difButns[i], CGI->generaltexth->zelp[24 + i]);
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
iconDifficulty->addToggle(i, button);
|
|
|
|
if(SEL->screenType != ESelectionScreen::newGame)
|
|
|
|
button->block(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
flagbox = std::make_shared<CFlagBox>(Rect(24, 400, 335, 23));
|
2022-11-26 23:12:20 +02:00
|
|
|
labelMapDiff = std::make_shared<CLabel>(33, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[494]);
|
|
|
|
labelPlayerDifficulty = std::make_shared<CLabel>(133, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[492] + ":");
|
|
|
|
labelRating = std::make_shared<CLabel>(290, 430, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[218] + ":");
|
|
|
|
labelScenarioName = std::make_shared<CLabel>(26, 22, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[495]);
|
|
|
|
labelScenarioDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[496]);
|
|
|
|
labelVictoryCondition = std::make_shared<CLabel>(26, 283, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[497]);
|
|
|
|
labelLossCondition = std::make_shared<CLabel>(26, 339, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[498]);
|
2018-01-05 19:21:07 +02:00
|
|
|
iconsVictoryCondition = std::make_shared<CAnimImage>("SCNRVICT", 0, 0, 24, 302);
|
|
|
|
iconsLossCondition = std::make_shared<CAnimImage>("SCNRLOSS", 0, 0, 24, 359);
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
labelVictoryConditionText = std::make_shared<CLabel>(60, 307, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
|
|
|
labelLossConditionText = std::make_shared<CLabel>(60, 366, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
labelDifficulty = std::make_shared<CLabel>(62, 472, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
|
|
|
|
labelDifficultyPercent = std::make_shared<CLabel>(311, 472, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
|
|
|
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
2019-04-20 18:26:54 +02:00
|
|
|
disableLabelRedraws();
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
setChat(false);
|
|
|
|
}
|
|
|
|
|
2019-04-20 18:26:54 +02:00
|
|
|
void InfoCard::disableLabelRedraws()
|
|
|
|
{
|
|
|
|
labelSaveDate->setAutoRedraw(false);
|
|
|
|
mapName->setAutoRedraw(false);
|
|
|
|
mapDescription->label->setAutoRedraw(false);
|
|
|
|
labelVictoryConditionText->setAutoRedraw(false);
|
|
|
|
labelLossConditionText->setAutoRedraw(false);
|
|
|
|
labelDifficulty->setAutoRedraw(false);
|
|
|
|
labelDifficultyPercent->setAutoRedraw(false);
|
|
|
|
}
|
|
|
|
|
2018-01-05 19:21:07 +02:00
|
|
|
void InfoCard::changeSelection()
|
|
|
|
{
|
2019-04-20 18:26:54 +02:00
|
|
|
auto mapInfo = SEL->getMapInfo();
|
|
|
|
if(!mapInfo)
|
2018-01-05 19:21:07 +02:00
|
|
|
return;
|
|
|
|
|
2019-04-20 18:26:54 +02:00
|
|
|
labelSaveDate->setText(mapInfo->date);
|
|
|
|
mapName->setText(mapInfo->getName());
|
|
|
|
mapDescription->setText(mapInfo->getDescription());
|
2018-01-05 19:21:07 +02:00
|
|
|
|
2019-04-20 18:26:54 +02:00
|
|
|
mapDescription->label->scrollTextTo(0, false);
|
2018-01-05 19:21:07 +02:00
|
|
|
if(mapDescription->slider)
|
|
|
|
mapDescription->slider->moveToMin();
|
|
|
|
|
|
|
|
if(SEL->screenType == ESelectionScreen::campaignList)
|
|
|
|
return;
|
|
|
|
|
2019-04-20 18:26:54 +02:00
|
|
|
iconsMapSizes->setFrame(mapInfo->getMapSizeIconId());
|
|
|
|
const CMapHeader * header = mapInfo->mapHeader.get();
|
2018-01-05 19:21:07 +02:00
|
|
|
iconsVictoryCondition->setFrame(header->victoryIconIndex);
|
|
|
|
labelVictoryConditionText->setText(header->victoryMessage);
|
|
|
|
iconsLossCondition->setFrame(header->defeatIconIndex);
|
|
|
|
labelLossConditionText->setText(header->defeatMessage);
|
|
|
|
flagbox->recreate();
|
2019-04-20 18:26:54 +02:00
|
|
|
labelDifficulty->setText(CGI->generaltexth->arraytxt[142 + mapInfo->mapHeader->difficulty]);
|
2018-01-05 19:21:07 +02:00
|
|
|
iconDifficulty->setSelected(SEL->getCurrentDifficulty());
|
|
|
|
const std::array<std::string, 5> difficultyPercent = {"80%", "100%", "130%", "160%", "200%"};
|
|
|
|
labelDifficultyPercent->setText(difficultyPercent[SEL->getCurrentDifficulty()]);
|
|
|
|
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
// FIXME: We recreate them each time because CLabelGroup don't use smart pointers
|
2022-11-26 23:12:20 +02:00
|
|
|
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
|
|
|
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
|
2018-01-05 19:21:07 +02:00
|
|
|
if(!showChat)
|
|
|
|
{
|
|
|
|
labelGroupPlayersAssigned->disable();
|
|
|
|
labelGroupPlayersUnassigned->disable();
|
|
|
|
}
|
|
|
|
for(auto & p : CSH->playerNames)
|
|
|
|
{
|
|
|
|
const auto pset = CSH->si->getPlayersSettings(p.first);
|
|
|
|
int pid = p.first;
|
|
|
|
if(pset)
|
|
|
|
{
|
|
|
|
auto name = boost::str(boost::format("%s (%d-%d %s)") % p.second.name % p.second.connection % pid % pset->color.getStr());
|
2020-10-01 10:38:06 +02:00
|
|
|
labelGroupPlayersAssigned->add(24, 285 + (int)labelGroupPlayersAssigned->currentSize()*(int)graphics->fonts[FONT_SMALL]->getLineHeight(), name);
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto name = boost::str(boost::format("%s (%d-%d)") % p.second.name % p.second.connection % pid);
|
2020-10-01 10:38:06 +02:00
|
|
|
labelGroupPlayersUnassigned->add(193, 285 + (int)labelGroupPlayersUnassigned->currentSize()*(int)graphics->fonts[FONT_SMALL]->getLineHeight(), name);
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InfoCard::toggleChat()
|
|
|
|
{
|
|
|
|
setChat(!showChat);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InfoCard::setChat(bool activateChat)
|
|
|
|
{
|
|
|
|
if(showChat == activateChat)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(activateChat)
|
|
|
|
{
|
|
|
|
if(SEL->screenType == ESelectionScreen::campaignList)
|
|
|
|
{
|
|
|
|
labelCampaignDescription->disable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelScenarioDescription->disable();
|
|
|
|
labelVictoryCondition->disable();
|
|
|
|
labelLossCondition->disable();
|
|
|
|
iconsVictoryCondition->disable();
|
|
|
|
labelVictoryConditionText->disable();
|
|
|
|
iconsLossCondition->disable();
|
|
|
|
labelLossConditionText->disable();
|
|
|
|
labelGroupPlayersAssigned->enable();
|
|
|
|
labelGroupPlayersUnassigned->enable();
|
|
|
|
}
|
|
|
|
mapDescription->disable();
|
|
|
|
chat->enable();
|
|
|
|
playerListBg->enable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mapDescription->enable();
|
|
|
|
chat->disable();
|
|
|
|
playerListBg->disable();
|
|
|
|
|
|
|
|
if(SEL->screenType == ESelectionScreen::campaignList)
|
|
|
|
{
|
|
|
|
labelCampaignDescription->enable();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
labelScenarioDescription->enable();
|
|
|
|
labelVictoryCondition->enable();
|
|
|
|
labelLossCondition->enable();
|
|
|
|
iconsVictoryCondition->enable();
|
|
|
|
iconsLossCondition->enable();
|
|
|
|
labelVictoryConditionText->enable();
|
|
|
|
labelLossConditionText->enable();
|
|
|
|
labelGroupPlayersAssigned->disable();
|
|
|
|
labelGroupPlayersUnassigned->disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
showChat = activateChat;
|
|
|
|
GH.totalRedraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
CChatBox::CChatBox(const Rect & rect)
|
|
|
|
: CIntObject(KEYBOARD | TEXTINPUT)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION;
|
2022-12-15 23:24:03 +02:00
|
|
|
pos += rect.topLeft();
|
2018-01-05 19:21:07 +02:00
|
|
|
captureAllKeys = true;
|
|
|
|
type |= REDRAW_PARENT;
|
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
const int height = static_cast<int>(graphics->fonts[FONT_SMALL]->getLineHeight());
|
2023-01-30 13:58:13 +02:00
|
|
|
inputBox = std::make_shared<CTextInput>(Rect(0, rect.h - height, rect.w, height), EFonts::FONT_SMALL, 0);
|
2018-01-05 19:21:07 +02:00
|
|
|
inputBox->removeUsedEvents(KEYBOARD);
|
|
|
|
chatHistory = std::make_shared<CTextBox>("", Rect(0, 0, rect.w, rect.h - height), 1);
|
|
|
|
|
|
|
|
chatHistory->label->color = Colors::GREEN;
|
|
|
|
}
|
|
|
|
|
2023-02-02 18:42:44 +02:00
|
|
|
void CChatBox::keyPressed(const SDL_Keycode & key)
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-02-02 18:02:25 +02:00
|
|
|
if(key == SDLK_RETURN && inputBox->getText().size())
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2022-12-19 22:04:50 +02:00
|
|
|
CSH->sendMessage(inputBox->getText());
|
2018-01-05 19:21:07 +02:00
|
|
|
inputBox->setText("");
|
|
|
|
}
|
|
|
|
else
|
2023-02-02 18:42:44 +02:00
|
|
|
inputBox->keyPressed(key);
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CChatBox::addNewMessage(const std::string & text)
|
|
|
|
{
|
|
|
|
CCS->soundh->playSound("CHAT");
|
2022-12-19 22:04:50 +02:00
|
|
|
chatHistory->setText(chatHistory->label->getText() + text + "\n");
|
2018-01-05 19:21:07 +02:00
|
|
|
if(chatHistory->slider)
|
|
|
|
chatHistory->slider->moveToMax();
|
|
|
|
}
|
|
|
|
|
|
|
|
CFlagBox::CFlagBox(const Rect & rect)
|
|
|
|
: CIntObject(RCLICK)
|
|
|
|
{
|
2022-12-15 23:24:03 +02:00
|
|
|
pos += rect.topLeft();
|
2018-01-05 19:21:07 +02:00
|
|
|
pos.w = rect.w;
|
|
|
|
pos.h = rect.h;
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
labelAllies = std::make_shared<CLabel>(0, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[390] + ":");
|
|
|
|
labelEnemies = std::make_shared<CLabel>(133, 0, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":");
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
iconsTeamFlags = std::make_shared<CAnimation>("ITGFLAGS.DEF");
|
|
|
|
iconsTeamFlags->preload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFlagBox::recreate()
|
|
|
|
{
|
|
|
|
flagsAllies.clear();
|
|
|
|
flagsEnemies.clear();
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
2020-10-01 10:38:06 +02:00
|
|
|
const int alliesX = 5 + (int)labelAllies->getWidth();
|
|
|
|
const int enemiesX = 5 + 133 + (int)labelEnemies->getWidth();
|
2018-01-05 19:21:07 +02:00
|
|
|
for(auto i = CSH->si->playerInfos.cbegin(); i != CSH->si->playerInfos.cend(); i++)
|
|
|
|
{
|
|
|
|
auto flag = std::make_shared<CAnimImage>(iconsTeamFlags, i->first.getNum(), 0);
|
|
|
|
if(i->first == CSH->myFirstColor() || CSH->getPlayerTeamId(i->first) == CSH->getPlayerTeamId(CSH->myFirstColor()))
|
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
flag->moveTo(Point(pos.x + alliesX + (int)flagsAllies.size()*flag->pos.w, pos.y));
|
2018-01-05 19:21:07 +02:00
|
|
|
flagsAllies.push_back(flag);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-01 10:38:06 +02:00
|
|
|
flag->moveTo(Point(pos.x + enemiesX + (int)flagsEnemies.size()*flag->pos.w, pos.y));
|
2018-01-05 19:21:07 +02:00
|
|
|
flagsEnemies.push_back(flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFlagBox::clickRight(tribool down, bool previousState)
|
|
|
|
{
|
|
|
|
if(down && SEL->getMapInfo())
|
2018-07-25 00:36:48 +02:00
|
|
|
GH.pushIntT<CFlagBoxTooltipBox>(iconsTeamFlags);
|
2018-01-05 19:21:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CFlagBox::CFlagBoxTooltipBox::CFlagBoxTooltipBox(std::shared_ptr<CAnimation> icons)
|
|
|
|
: CWindowObject(BORDERED | RCLICK_POPUP | SHADOW_DISABLED, "DIBOXBCK")
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
pos.w = 256;
|
|
|
|
pos.h = 90 + 50 * SEL->getMapInfo()->mapHeader->howManyTeams;
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
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);
|
2018-01-05 19:21:07 +02:00
|
|
|
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++)
|
|
|
|
{
|
|
|
|
if((SEL->getPlayerInfo(j).canHumanPlay || SEL->getPlayerInfo(j).canComputerPlay)
|
|
|
|
&& SEL->getPlayerInfo(j).team == TeamID(i))
|
|
|
|
{
|
|
|
|
flags.push_back(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
int curx = 128 - 9 * (int)flags.size();
|
2018-01-05 19:21:07 +02:00
|
|
|
for(auto & flag : flags)
|
|
|
|
{
|
|
|
|
iconsFlags.push_back(std::make_shared<CAnimImage>(icons, flag, 0, curx, 75 + 50 * i));
|
|
|
|
curx += 18;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
background->scaleTo(Point(pos.w, pos.h));
|
|
|
|
center();
|
|
|
|
}
|