CSelectionBase.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * CSelectionBase.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../mainmenu/CMainMenu.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class CMapInfo;
  14. struct StartInfo;
  15. struct PlayerInfo;
  16. VCMI_LIB_NAMESPACE_END
  17. class CButton;
  18. class CTextBox;
  19. class CTextInput;
  20. class CAnimImage;
  21. class CToggleGroup;
  22. class RandomMapTab;
  23. class OptionsTab;
  24. class TurnOptionsTab;
  25. class ExtraOptionsTab;
  26. class SelectionTab;
  27. class BattleOnlyModeTab;
  28. class InfoCard;
  29. class CChatBox;
  30. class PvPBox;
  31. class TownSelector;
  32. class CLabel;
  33. class CSlider;
  34. class CFlagBox;
  35. class CLabelGroup;
  36. class TransparentFilledRectangle;
  37. class FilledTexturePlayerColored;
  38. class LRClickableArea;
  39. class ISelectionScreenInfo
  40. {
  41. public:
  42. ESelectionScreen screenType;
  43. ISelectionScreenInfo(ESelectionScreen ScreenType = ESelectionScreen::unknown);
  44. virtual ~ISelectionScreenInfo();
  45. virtual const CMapInfo * getMapInfo() = 0;
  46. virtual const StartInfo * getStartInfo() = 0;
  47. virtual int getCurrentDifficulty();
  48. virtual PlayerInfo getPlayerInfo(PlayerColor color);
  49. };
  50. /// The actual map selection screen which consists of the options and selection tab
  51. class CSelectionBase : public CWindowObject, public ISelectionScreenInfo
  52. {
  53. public:
  54. std::shared_ptr<InfoCard> card;
  55. std::shared_ptr<CButton> buttonSelect;
  56. std::shared_ptr<CButton> buttonRMG;
  57. std::shared_ptr<CButton> buttonOptions;
  58. std::shared_ptr<CButton> buttonTurnOptions;
  59. std::shared_ptr<CButton> buttonExtraOptions;
  60. std::shared_ptr<CButton> buttonStart;
  61. std::shared_ptr<CButton> buttonBack;
  62. std::shared_ptr<CButton> buttonSimturns;
  63. std::vector<std::shared_ptr<CPicture>> images;
  64. std::shared_ptr<SelectionTab> tabSel;
  65. std::shared_ptr<OptionsTab> tabOpt;
  66. std::shared_ptr<TurnOptionsTab> tabTurnOptions;
  67. std::shared_ptr<ExtraOptionsTab> tabExtraOptions;
  68. std::shared_ptr<RandomMapTab> tabRand;
  69. std::shared_ptr<BattleOnlyModeTab> tabBattleOnlyMode;
  70. std::shared_ptr<CIntObject> curTab;
  71. CSelectionBase(ESelectionScreen type);
  72. virtual void toggleTab(std::shared_ptr<CIntObject> tab);
  73. };
  74. class InfoCard : public CIntObject
  75. {
  76. std::shared_ptr<CPicture> playerListBg;
  77. std::shared_ptr<CPicture> background;
  78. std::shared_ptr<CAnimImage> iconsVictoryCondition;
  79. std::shared_ptr<CAnimImage> iconsLossCondition;
  80. std::shared_ptr<CAnimImage> iconsMapSizes;
  81. std::shared_ptr<CLabel> labelSaveDate;
  82. std::shared_ptr<CLabel> labelMapSize;
  83. std::shared_ptr<CLabel> labelScenarioName;
  84. std::shared_ptr<CLabel> labelScenarioDescription;
  85. std::shared_ptr<CLabel> labelVictoryCondition;
  86. std::shared_ptr<CLabel> labelLossCondition;
  87. std::shared_ptr<CLabel> labelMapDiff;
  88. std::shared_ptr<CLabel> labelPlayerDifficulty;
  89. std::shared_ptr<CLabel> labelRating;
  90. std::shared_ptr<CLabel> labelCampaignDescription;
  91. std::shared_ptr<CLabel> mapName;
  92. std::shared_ptr<CTextBox> mapDescription;
  93. std::shared_ptr<CLabel> labelDifficulty;
  94. std::shared_ptr<CLabel> labelDifficultyPercent;
  95. std::shared_ptr<CLabel> labelVictoryConditionText;
  96. std::shared_ptr<CLabel> labelLossConditionText;
  97. std::shared_ptr<CLabelGroup> labelGroupPlayers;
  98. std::shared_ptr<CButton> buttonInvitePlayers;
  99. std::shared_ptr<CButton> buttonOpenGlobalLobby;
  100. std::shared_ptr<PvPBox> pvpBox;
  101. public:
  102. bool showChat;
  103. std::shared_ptr<CChatBox> chat;
  104. std::shared_ptr<CFlagBox> flagbox;
  105. std::shared_ptr<CToggleGroup> iconDifficulty;
  106. InfoCard();
  107. void disableLabelRedraws();
  108. void changeSelection();
  109. void clearSelection();
  110. void toggleChat();
  111. void setChat(bool activateChat);
  112. };
  113. class CChatBox : public CIntObject
  114. {
  115. public:
  116. std::shared_ptr<CTextBox> chatHistory;
  117. std::shared_ptr<CTextInput> inputBox;
  118. std::shared_ptr<TransparentFilledRectangle> inputBackground;
  119. CChatBox(const Rect & rect);
  120. void keyPressed(EShortcut key) override;
  121. bool captureThisKey(EShortcut key) override;
  122. void addNewMessage(const std::string & text);
  123. };
  124. class PvPBox : public CIntObject
  125. {
  126. std::shared_ptr<FilledTexturePlayerColored> backgroundTexture;
  127. std::shared_ptr<TransparentFilledRectangle> backgroundBorder;
  128. std::shared_ptr<TownSelector> townSelector;
  129. std::shared_ptr<CButton> buttonFlipCoin;
  130. std::shared_ptr<CButton> buttonRandomTown;
  131. std::shared_ptr<CButton> buttonRandomTownVs;
  132. std::shared_ptr<CButton> buttonHandicap;
  133. public:
  134. PvPBox(const Rect & rect);
  135. };
  136. class TownSelector : public CIntObject
  137. {
  138. std::map<FactionID, std::shared_ptr<CAnimImage>> towns;
  139. std::map<FactionID, std::shared_ptr<LRClickableArea>> townsArea;
  140. std::shared_ptr<CSlider> slider;
  141. void sliderMove(int slidPos);
  142. void updateListItems();
  143. public:
  144. std::map<FactionID, bool> townsEnabled;
  145. TownSelector(const Point & loc);
  146. };
  147. class CFlagBox : public CIntObject
  148. {
  149. std::shared_ptr<CLabel> labelAllies;
  150. std::shared_ptr<CLabel> labelEnemies;
  151. std::vector<std::shared_ptr<CAnimImage>> flagsAllies;
  152. std::vector<std::shared_ptr<CAnimImage>> flagsEnemies;
  153. public:
  154. CFlagBox(const Rect & rect);
  155. void recreate();
  156. void showPopupWindow(const Point & cursorPosition) override;
  157. void showTeamsPopup();
  158. class CFlagBoxTooltipBox : public CWindowObject
  159. {
  160. std::shared_ptr<CLabel> labelTeamAlignment;
  161. std::shared_ptr<CLabelGroup> labelGroupTeams;
  162. std::vector<std::shared_ptr<CAnimImage>> iconsFlags;
  163. public:
  164. CFlagBoxTooltipBox();
  165. };
  166. };
  167. extern ISelectionScreenInfo * SEL;