CSelectionBase.h 5.2 KB

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