1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

changed layout

This commit is contained in:
Laserlicht
2024-04-30 21:52:04 +02:00
parent 0565c062e5
commit 78b8c2c71c
4 changed files with 53 additions and 69 deletions

View File

@@ -15,7 +15,6 @@
#include "PlayerLocalState.h"
#include "globalLobby/GlobalLobbyClient.h"
#include "lobby/CLobbyScreen.h"
#include "lobby/CSelectionBase.h"
#include "adventureMap/CInGameConsole.h"
@@ -74,11 +73,8 @@ void GameChatHandler::onNewLobbyMessageReceived(const std::string & senderName,
formatted.replaceRawString(messageText);
lobby->card->chat->addNewMessage(formatted.toString());
if (lobby->card->chatMode != InfoCard::ChatMode::Enabled)
{
lobby->card->setChat(InfoCard::ChatMode::Disabled);
lobby->toggleChat();
}
if (!lobby->card->showChat)
lobby->toggleChat();
}
chatHistory.push_back({senderName, messageText, TextOperations::getCurrentFormattedTimeLocal()});

View File

@@ -221,21 +221,11 @@ void CLobbyScreen::toggleMode(bool host)
void CLobbyScreen::toggleChat()
{
switch(card->chatMode)
{
case InfoCard::ChatMode::Enabled:
card->setChat(InfoCard::ChatMode::PvP);
card->toggleChat();
if(card->showChat)
buttonChat->setTextOverlay(CGI->generaltexth->allTexts[531], FONT_SMALL, Colors::WHITE);
break;
case InfoCard::ChatMode::Disabled:
card->setChat(InfoCard::ChatMode::Enabled);
buttonChat->setTextOverlay("PvP actions", FONT_SMALL, Colors::WHITE);
break;
case InfoCard::ChatMode::PvP:
card->setChat(InfoCard::ChatMode::Disabled);
else
buttonChat->setTextOverlay(CGI->generaltexth->allTexts[532], FONT_SMALL, Colors::WHITE);
break;
}
}
void CLobbyScreen::updateAfterStateChange()

View File

@@ -31,6 +31,7 @@
#include "../widgets/Buttons.h"
#include "../widgets/CComponent.h"
#include "../widgets/GraphicalPrimitiveCanvas.h"
#include "../widgets/Images.h"
#include "../widgets/ObjectLists.h"
#include "../widgets/Slider.h"
#include "../widgets/TextControls.h"
@@ -124,7 +125,7 @@ void CSelectionBase::toggleTab(std::shared_ptr<CIntObject> tab)
}
InfoCard::InfoCard()
: chatMode(ChatMode::Enabled)
: showChat(true)
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
setRedrawParent(true);
@@ -138,7 +139,7 @@ InfoCard::InfoCard()
mapDescription = std::make_shared<CTextBox>("", descriptionRect, 1);
playerListBg = std::make_shared<CPicture>(ImagePath::builtin("CHATPLUG.bmp"), 16, 276);
chat = std::make_shared<CChatBox>(Rect(18, 126, 335, 143));
pvpBox = std::make_shared<PvPBox>(Rect(18, 126, 335, 262));
pvpBox = std::make_shared<PvPBox>(Rect(17, 396, 338, 105));
buttonInvitePlayers = std::make_shared<CButton>(Point(20, 365), AnimationPath::builtin("pregameInvitePlayers"), CGI->generaltexth->zelp[105], [](){ CSH->getGlobalLobby().activateRoomInviteInterface(); } );
buttonOpenGlobalLobby = std::make_shared<CButton>(Point(188, 365), AnimationPath::builtin("pregameReturnToLobby"), CGI->generaltexth->zelp[105], [](){ CSH->getGlobalLobby().activateInterface(); });
@@ -195,9 +196,9 @@ InfoCard::InfoCard()
labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
disableLabelRedraws();
}
setChat(ChatMode::Disabled);
setChat(false);
if (CSH->inLobbyRoom())
setChat(ChatMode::Enabled); // FIXME: less ugly version?
setChat(true); // FIXME: less ugly version?
}
void InfoCard::disableLabelRedraws()
@@ -251,7 +252,7 @@ void InfoCard::changeSelection()
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
// FIXME: We recreate them each time because CLabelGroup don't use smart pointers
labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
if(chatMode != ChatMode::Enabled)
if(!showChat)
labelGroupPlayers->disable();
for(const auto & p : CSH->playerNames)
@@ -268,14 +269,18 @@ void InfoCard::changeSelection()
}
}
void InfoCard::setChat(ChatMode setMode)
void InfoCard::toggleChat()
{
if(chatMode == setMode)
setChat(!showChat);
}
void InfoCard::setChat(bool activateChat)
{
if(showChat == activateChat)
return;
switch(setMode)
if(activateChat)
{
case InfoCard::ChatMode::Enabled:
if(SEL->screenType == ESelectionScreen::campaignList)
{
labelCampaignDescription->disable();
@@ -296,12 +301,20 @@ void InfoCard::setChat(ChatMode setMode)
buttonInvitePlayers->enable();
buttonOpenGlobalLobby->enable();
}
labelMapDiff->disable();
labelPlayerDifficulty->disable();
labelRating->disable();
labelDifficulty->disable();
labelDifficultyPercent->disable();
flagbox->disable();
iconDifficulty->disable();
mapDescription->disable();
chat->enable();
pvpBox->disable();
pvpBox->enable();
playerListBg->enable();
break;
case InfoCard::ChatMode::Disabled:
}
else
{
buttonInvitePlayers->disable();
buttonOpenGlobalLobby->disable();
mapDescription->enable();
@@ -324,34 +337,16 @@ void InfoCard::setChat(ChatMode setMode)
labelLossConditionText->enable();
labelGroupPlayers->disable();
}
break;
case InfoCard::ChatMode::PvP:
buttonInvitePlayers->disable();
buttonOpenGlobalLobby->disable();
mapDescription->disable();
chat->disable();
pvpBox->enable();
playerListBg->enable();
if(SEL->screenType == ESelectionScreen::campaignList)
{
labelCampaignDescription->disable();
}
else
{
labelScenarioDescription->disable();
labelVictoryCondition->disable();
labelLossCondition->disable();
iconsVictoryCondition->disable();
iconsLossCondition->disable();
labelVictoryConditionText->disable();
labelLossConditionText->disable();
labelGroupPlayers->disable();
}
break;
labelMapDiff->enable();
labelPlayerDifficulty->enable();
labelRating->enable();
labelDifficulty->enable();
labelDifficultyPercent->enable();
flagbox->enable();
iconDifficulty->enable();
}
chatMode = setMode;
showChat = activateChat;
GH.windows().totalRedraw();
}
@@ -403,21 +398,25 @@ PvPBox::PvPBox(const Rect & rect)
pos += rect.topLeft();
setRedrawParent(true);
buttonFlipCoin = std::make_shared<CButton>(Point(17, 160), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){
backgroundTexture = std::make_shared<FilledTexturePlayerColored>(ImagePath::builtin("DiBoxBck"), Rect(0, 0, rect.w, rect.h));
backgroundTexture->playerColored(PlayerColor(1));
backgroundBorder = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, rect.w, rect.h), ColorRGBA(0, 0, 0, 64), ColorRGBA(96, 96, 96, 255), 1);
buttonFlipCoin = std::make_shared<CButton>(Point(17, 10), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){
LobbyPvPAction lpa;
lpa.action = LobbyPvPAction::COIN;
CSH->sendLobbyPack(lpa);
}, EShortcut::NONE);
buttonFlipCoin->setTextOverlay("Flip coin2", EFonts::FONT_SMALL, Colors::WHITE);
buttonRandomTown = std::make_shared<CButton>(Point(17, 184), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town"), [](){
buttonRandomTown = std::make_shared<CButton>(Point(17, 30), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town"), [](){
LobbyPvPAction lpa;
lpa.action = LobbyPvPAction::RANDOM_TOWN;
CSH->sendLobbyPack(lpa);
}, EShortcut::NONE);
buttonRandomTown->setTextOverlay("random town", EFonts::FONT_SMALL, Colors::WHITE);
buttonRandomTownVs = std::make_shared<CButton>(Point(17, 208), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town vs"), [](){
buttonRandomTownVs = std::make_shared<CButton>(Point(17, 50), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town vs"), [](){
LobbyPvPAction lpa;
lpa.action = LobbyPvPAction::RANDOM_TOWN_VS;
CSH->sendLobbyPack(lpa);

View File

@@ -36,6 +36,7 @@ class CLabel;
class CFlagBox;
class CLabelGroup;
class TransparentFilledRectangle;
class FilledTexturePlayerColored;
class ISelectionScreenInfo
{
@@ -111,13 +112,8 @@ class InfoCard : public CIntObject
std::shared_ptr<PvPBox> pvpBox;
public:
enum ChatMode {
Disabled,
Enabled,
PvP
};
ChatMode chatMode;
bool showChat;
std::shared_ptr<CChatBox> chat;
std::shared_ptr<CFlagBox> flagbox;
@@ -126,7 +122,8 @@ public:
InfoCard();
void disableLabelRedraws();
void changeSelection();
void setChat(ChatMode setMode);
void toggleChat();
void setChat(bool activateChat);
};
class CChatBox : public CIntObject
@@ -145,11 +142,13 @@ public:
class PvPBox : public CIntObject
{
public:
std::shared_ptr<FilledTexturePlayerColored> backgroundTexture;
std::shared_ptr<TransparentFilledRectangle> backgroundBorder;
std::shared_ptr<CButton> buttonFlipCoin;
std::shared_ptr<CButton> buttonRandomTown;
std::shared_ptr<CButton> buttonRandomTownVs;
public:
PvPBox(const Rect & rect);
};