فهرست منبع

pvp option init

Laserlicht 1 سال پیش
والد
کامیت
f4d1442a86
4فایلهای تغییر یافته به همراه83 افزوده شده و 24 حذف شده
  1. 3 2
      client/GameChatHandler.cpp
  2. 13 3
      client/lobby/CLobbyScreen.cpp
  3. 49 16
      client/lobby/CSelectionBase.cpp
  4. 18 3
      client/lobby/CSelectionBase.h

+ 3 - 2
client/GameChatHandler.cpp

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

+ 13 - 3
client/lobby/CLobbyScreen.cpp

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

+ 49 - 16
client/lobby/CSelectionBase.cpp

@@ -123,7 +123,7 @@ void CSelectionBase::toggleTab(std::shared_ptr<CIntObject> tab)
 }
 
 InfoCard::InfoCard()
-	: showChat(true)
+	: chatMode(ChatMode::Enabled)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
 	setRedrawParent(true);
@@ -137,6 +137,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));
 
 	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(); });
@@ -193,9 +194,9 @@ InfoCard::InfoCard()
 		labelGroupPlayers = std::make_shared<CLabelGroup>(FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE);
 		disableLabelRedraws();
 	}
-	setChat(false);
+	setChat(ChatMode::Disabled);
 	if (CSH->inLobbyRoom())
-		setChat(true); // FIXME: less ugly version?
+		setChat(ChatMode::Enabled); // FIXME: less ugly version?
 }
 
 void InfoCard::disableLabelRedraws()
@@ -249,7 +250,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(!showChat)
+	if(chatMode != ChatMode::Enabled)
 		labelGroupPlayers->disable();
 
 	for(const auto & p : CSH->playerNames)
@@ -266,18 +267,14 @@ void InfoCard::changeSelection()
 	}
 }
 
-void InfoCard::toggleChat()
+void InfoCard::setChat(ChatMode setMode)
 {
-	setChat(!showChat);
-}
-
-void InfoCard::setChat(bool activateChat)
-{
-	if(showChat == activateChat)
+	if(chatMode == setMode)
 		return;
 
-	if(activateChat)
+	switch(setMode)
 	{
+	case InfoCard::ChatMode::Enabled:
 		if(SEL->screenType == ESelectionScreen::campaignList)
 		{
 			labelCampaignDescription->disable();
@@ -300,14 +297,15 @@ void InfoCard::setChat(bool activateChat)
 		}
 		mapDescription->disable();
 		chat->enable();
+		pvpBox->disable();
 		playerListBg->enable();
-	}
-	else
-	{
+		break;
+	case InfoCard::ChatMode::Disabled:
 		buttonInvitePlayers->disable();
 		buttonOpenGlobalLobby->disable();
 		mapDescription->enable();
 		chat->disable();
+		pvpBox->disable();
 		playerListBg->disable();
 
 		if(SEL->screenType == ESelectionScreen::campaignList)
@@ -325,9 +323,34 @@ void InfoCard::setChat(bool activateChat)
 			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;
 	}
 
-	showChat = activateChat;
+	chatMode = setMode;
 	GH.windows().totalRedraw();
 }
 
@@ -373,6 +396,16 @@ void CChatBox::addNewMessage(const std::string & text)
 		chatHistory->slider->scrollToMax();
 }
 
+PvPBox::PvPBox(const Rect & rect)
+{
+	OBJ_CONSTRUCTION;
+	pos += rect.topLeft();
+	setRedrawParent(true);
+
+	buttonFlipCoin = std::make_shared<CButton>(Point(17, 160), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){ std::cout << "coin flip"; }, EShortcut::NONE);
+	buttonFlipCoin->setTextOverlay("Flip coin2", EFonts::FONT_SMALL, Colors::WHITE);
+}
+
 CFlagBox::CFlagBox(const Rect & rect)
 	: CIntObject(SHOW_POPUP)
 {

+ 18 - 3
client/lobby/CSelectionBase.h

@@ -31,6 +31,7 @@ class ExtraOptionsTab;
 class SelectionTab;
 class InfoCard;
 class CChatBox;
+class PvPBox;
 class CLabel;
 class CFlagBox;
 class CLabelGroup;
@@ -107,9 +108,16 @@ class InfoCard : public CIntObject
 	std::shared_ptr<CLabelGroup> labelGroupPlayers;
 	std::shared_ptr<CButton> buttonInvitePlayers;
 	std::shared_ptr<CButton> buttonOpenGlobalLobby;
+
+	std::shared_ptr<PvPBox> pvpBox;
 public:
+	enum ChatMode {
+		Disabled,
+		Enabled,
+		PvP
+	};
 
-	bool showChat;
+	ChatMode chatMode;
 	std::shared_ptr<CChatBox> chat;
 	std::shared_ptr<CFlagBox> flagbox;
 
@@ -118,8 +126,7 @@ public:
 	InfoCard();
 	void disableLabelRedraws();
 	void changeSelection();
-	void toggleChat();
-	void setChat(bool activateChat);
+	void setChat(ChatMode setMode);
 };
 
 class CChatBox : public CIntObject
@@ -136,6 +143,14 @@ public:
 	void addNewMessage(const std::string & text);
 };
 
+class PvPBox : public CIntObject
+{
+public:
+	std::shared_ptr<CButton> buttonFlipCoin;
+
+	PvPBox(const Rect & rect);
+};
+
 class CFlagBox : public CIntObject
 {
 	std::shared_ptr<CAnimation> iconsTeamFlags;