CSelectionBase.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 CLabel;
  31. class CFlagBox;
  32. class CLabelGroup;
  33. class TransparentFilledRectangle;
  34. class ISelectionScreenInfo
  35. {
  36. public:
  37. ESelectionScreen screenType;
  38. ISelectionScreenInfo(ESelectionScreen ScreenType = ESelectionScreen::unknown);
  39. virtual ~ISelectionScreenInfo();
  40. virtual const CMapInfo * getMapInfo() = 0;
  41. virtual const StartInfo * getStartInfo() = 0;
  42. virtual int getCurrentDifficulty();
  43. virtual PlayerInfo getPlayerInfo(PlayerColor color);
  44. };
  45. /// The actual map selection screen which consists of the options and selection tab
  46. class CSelectionBase : public CWindowObject, public ISelectionScreenInfo
  47. {
  48. public:
  49. std::shared_ptr<InfoCard> card;
  50. std::shared_ptr<CButton> buttonSelect;
  51. std::shared_ptr<CButton> buttonRMG;
  52. std::shared_ptr<CButton> buttonOptions;
  53. std::shared_ptr<CButton> buttonTurnOptions;
  54. std::shared_ptr<CButton> buttonExtraOptions;
  55. std::shared_ptr<CButton> buttonStart;
  56. std::shared_ptr<CButton> buttonBack;
  57. std::shared_ptr<CButton> buttonSimturns;
  58. std::shared_ptr<SelectionTab> tabSel;
  59. std::shared_ptr<OptionsTab> tabOpt;
  60. std::shared_ptr<TurnOptionsTab> tabTurnOptions;
  61. std::shared_ptr<ExtraOptionsTab> tabExtraOptions;
  62. std::shared_ptr<RandomMapTab> tabRand;
  63. std::shared_ptr<CIntObject> curTab;
  64. CSelectionBase(ESelectionScreen type);
  65. virtual void toggleTab(std::shared_ptr<CIntObject> tab);
  66. };
  67. class InfoCard : public CIntObject
  68. {
  69. std::shared_ptr<CPicture> playerListBg;
  70. std::shared_ptr<CPicture> background;
  71. std::shared_ptr<CAnimImage> iconsVictoryCondition;
  72. std::shared_ptr<CAnimImage> iconsLossCondition;
  73. std::shared_ptr<CAnimImage> iconsMapSizes;
  74. std::shared_ptr<CLabel> labelSaveDate;
  75. std::shared_ptr<CLabel> labelMapSize;
  76. std::shared_ptr<CLabel> labelScenarioName;
  77. std::shared_ptr<CLabel> labelScenarioDescription;
  78. std::shared_ptr<CLabel> labelVictoryCondition;
  79. std::shared_ptr<CLabel> labelLossCondition;
  80. std::shared_ptr<CLabel> labelMapDiff;
  81. std::shared_ptr<CLabel> labelPlayerDifficulty;
  82. std::shared_ptr<CLabel> labelRating;
  83. std::shared_ptr<CLabel> labelCampaignDescription;
  84. std::shared_ptr<CLabel> mapName;
  85. std::shared_ptr<CTextBox> mapDescription;
  86. std::shared_ptr<CLabel> labelDifficulty;
  87. std::shared_ptr<CLabel> labelDifficultyPercent;
  88. std::shared_ptr<CLabel> labelVictoryConditionText;
  89. std::shared_ptr<CLabel> labelLossConditionText;
  90. std::shared_ptr<CLabelGroup> labelGroupPlayers;
  91. std::shared_ptr<CButton> buttonInvitePlayers;
  92. std::shared_ptr<CButton> buttonOpenGlobalLobby;
  93. std::shared_ptr<PvPBox> pvpBox;
  94. public:
  95. enum ChatMode {
  96. Disabled,
  97. Enabled,
  98. PvP
  99. };
  100. ChatMode chatMode;
  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 setChat(ChatMode setMode);
  108. };
  109. class CChatBox : public CIntObject
  110. {
  111. public:
  112. std::shared_ptr<CTextBox> chatHistory;
  113. std::shared_ptr<CTextInput> inputBox;
  114. std::shared_ptr<TransparentFilledRectangle> inputBackground;
  115. CChatBox(const Rect & rect);
  116. void keyPressed(EShortcut key) override;
  117. bool captureThisKey(EShortcut key) override;
  118. void addNewMessage(const std::string & text);
  119. };
  120. class PvPBox : public CIntObject
  121. {
  122. public:
  123. std::shared_ptr<CButton> buttonFlipCoin;
  124. PvPBox(const Rect & rect);
  125. };
  126. class CFlagBox : public CIntObject
  127. {
  128. std::shared_ptr<CAnimation> iconsTeamFlags;
  129. std::shared_ptr<CLabel> labelAllies;
  130. std::shared_ptr<CLabel> labelEnemies;
  131. std::vector<std::shared_ptr<CAnimImage>> flagsAllies;
  132. std::vector<std::shared_ptr<CAnimImage>> flagsEnemies;
  133. public:
  134. CFlagBox(const Rect & rect);
  135. void recreate();
  136. void showPopupWindow(const Point & cursorPosition) override;
  137. void showTeamsPopup();
  138. class CFlagBoxTooltipBox : public CWindowObject
  139. {
  140. std::shared_ptr<CLabel> labelTeamAlignment;
  141. std::shared_ptr<CLabelGroup> labelGroupTeams;
  142. std::vector<std::shared_ptr<CAnimImage>> iconsFlags;
  143. public:
  144. CFlagBoxTooltipBox(std::shared_ptr<CAnimation> icons);
  145. };
  146. };
  147. extern ISelectionScreenInfo * SEL;