1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Added UI for inviting players into a match

This commit is contained in:
Ivan Savenko
2024-03-23 21:12:10 +02:00
parent 4dce0479ba
commit ace43e97b9
11 changed files with 179 additions and 36 deletions

View File

@@ -26,6 +26,7 @@
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h"
#include "../globalLobby/GlobalLobbyClient.h"
#include "../mainmenu/CMainMenu.h"
#include "../widgets/Buttons.h"
#include "../widgets/CComponent.h"
@@ -137,6 +138,9 @@ InfoCard::InfoCard()
playerListBg = std::make_shared<CPicture>(ImagePath::builtin("CHATPLUG.bmp"), 16, 276);
chat = std::make_shared<CChatBox>(Rect(18, 126, 335, 143));
buttonInvitePlayers = std::make_shared<CButton>(Point(30, 360), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[105], [=](){ CSH->getGlobalLobby().activateRoomInviteInterface(); } );
buttonOpenGlobalLobby = std::make_shared<CButton>(Point(200, 360), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[105], [=](){ CSH->getGlobalLobby().activateInterface(); });
if(SEL->screenType == ESelectionScreen::campaignList)
{
labelCampaignDescription = std::make_shared<CLabel>(26, 132, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::YELLOW, CGI->generaltexth->allTexts[38]);
@@ -183,8 +187,7 @@ InfoCard::InfoCard()
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);
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
disableLabelRedraws();
}
setChat(false);
@@ -240,27 +243,21 @@ void InfoCard::changeSelection()
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
// FIXME: We recreate them each time because CLabelGroup don't use smart pointers
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
if(!showChat)
{
labelGroupPlayersAssigned->disable();
labelGroupPlayersUnassigned->disable();
}
labelGroupPlayers->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.toString());
labelGroupPlayersAssigned->add(24, 285 + (int)labelGroupPlayersAssigned->currentSize()*(int)graphics->fonts[FONT_SMALL]->getLineHeight(), name);
}
int slotsUsed = labelGroupPlayers->currentSize();
Point labelPosition;
if (slotsUsed < 4)
labelPosition = Point(24, 285 + slotsUsed * graphics->fonts[FONT_SMALL]->getLineHeight()); // left column
else
{
auto name = boost::str(boost::format("%s (%d-%d)") % p.second.name % p.second.connection % pid);
labelGroupPlayersUnassigned->add(193, 285 + (int)labelGroupPlayersUnassigned->currentSize()*(int)graphics->fonts[FONT_SMALL]->getLineHeight(), name);
}
labelPosition = Point(193, 285 + (slotsUsed - 4) * graphics->fonts[FONT_SMALL]->getLineHeight()); // right column
labelGroupPlayers->add(labelPosition.x, labelPosition.y, p.second.name);
}
}
@@ -289,8 +286,12 @@ void InfoCard::setChat(bool activateChat)
labelVictoryConditionText->disable();
iconsLossCondition->disable();
labelLossConditionText->disable();
labelGroupPlayersAssigned->enable();
labelGroupPlayersUnassigned->enable();
labelGroupPlayers->enable();
}
if (CSH->inLobbyRoom())
{
buttonInvitePlayers->enable();
buttonOpenGlobalLobby->enable();
}
mapDescription->disable();
chat->enable();
@@ -298,6 +299,8 @@ void InfoCard::setChat(bool activateChat)
}
else
{
buttonInvitePlayers->disable();
buttonOpenGlobalLobby->disable();
mapDescription->enable();
chat->disable();
playerListBg->disable();
@@ -315,8 +318,7 @@ void InfoCard::setChat(bool activateChat)
iconsLossCondition->enable();
labelVictoryConditionText->enable();
labelLossConditionText->enable();
labelGroupPlayersAssigned->disable();
labelGroupPlayersUnassigned->disable();
labelGroupPlayers->disable();
}
}