CSelectionBase.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. class CButton;
  13. class CTextBox;
  14. class CTextInput;
  15. class CAnimImage;
  16. class CToggleGroup;
  17. class RandomMapTab;
  18. class OptionsTab;
  19. class SelectionTab;
  20. class InfoCard;
  21. class CChatBox;
  22. class CMapInfo;
  23. struct StartInfo;
  24. struct PlayerInfo;
  25. class CLabel;
  26. class CFlagBox;
  27. class CLabelGroup;
  28. class ISelectionScreenInfo
  29. {
  30. public:
  31. ESelectionScreen screenType;
  32. ISelectionScreenInfo(ESelectionScreen ScreenType = ESelectionScreen::unknown);
  33. virtual ~ISelectionScreenInfo();
  34. virtual const CMapInfo * getMapInfo() = 0;
  35. virtual const StartInfo * getStartInfo() = 0;
  36. virtual int getCurrentDifficulty();
  37. virtual PlayerInfo getPlayerInfo(int color);
  38. };
  39. /// The actual map selection screen which consists of the options and selection tab
  40. class CSelectionBase : public CWindowObject, public ISelectionScreenInfo
  41. {
  42. public:
  43. std::shared_ptr<InfoCard> card;
  44. std::shared_ptr<CButton> buttonSelect;
  45. std::shared_ptr<CButton> buttonRMG;
  46. std::shared_ptr<CButton> buttonOptions;
  47. std::shared_ptr<CButton> buttonStart;
  48. std::shared_ptr<CButton> buttonBack;
  49. std::shared_ptr<SelectionTab> tabSel;
  50. std::shared_ptr<OptionsTab> tabOpt;
  51. std::shared_ptr<RandomMapTab> tabRand;
  52. std::shared_ptr<CIntObject> curTab;
  53. CSelectionBase(ESelectionScreen type);
  54. virtual void toggleTab(std::shared_ptr<CIntObject> tab);
  55. };
  56. class InfoCard : public CIntObject
  57. {
  58. std::shared_ptr<CPicture> playerListBg;
  59. std::shared_ptr<CPicture> background;
  60. std::shared_ptr<CAnimImage> iconsVictoryCondition;
  61. std::shared_ptr<CAnimImage> iconsLossCondition;
  62. std::shared_ptr<CAnimImage> iconsMapSizes;
  63. std::shared_ptr<CLabel> labelSaveDate;
  64. std::shared_ptr<CLabel> labelScenarioName;
  65. std::shared_ptr<CLabel> labelScenarioDescription;
  66. std::shared_ptr<CLabel> labelVictoryCondition;
  67. std::shared_ptr<CLabel> labelLossCondition;
  68. std::shared_ptr<CLabel> labelMapDiff;
  69. std::shared_ptr<CLabel> labelPlayerDifficulty;
  70. std::shared_ptr<CLabel> labelRating;
  71. std::shared_ptr<CLabel> labelCampaignDescription;
  72. std::shared_ptr<CLabel> mapName;
  73. std::shared_ptr<CTextBox> mapDescription;
  74. std::shared_ptr<CLabel> labelDifficulty;
  75. std::shared_ptr<CLabel> labelDifficultyPercent;
  76. std::shared_ptr<CLabel> labelVictoryConditionText;
  77. std::shared_ptr<CLabel> labelLossConditionText;
  78. std::shared_ptr<CLabelGroup> labelGroupPlayersAssigned;
  79. std::shared_ptr<CLabelGroup> labelGroupPlayersUnassigned;
  80. public:
  81. bool showChat;
  82. std::shared_ptr<CChatBox> chat;
  83. std::shared_ptr<CFlagBox> flagbox;
  84. std::shared_ptr<CToggleGroup> iconDifficulty;
  85. InfoCard();
  86. void disableLabelRedraws();
  87. void changeSelection();
  88. void toggleChat();
  89. void setChat(bool activateChat);
  90. };
  91. class CChatBox : public CIntObject
  92. {
  93. public:
  94. std::shared_ptr<CTextBox> chatHistory;
  95. std::shared_ptr<CTextInput> inputBox;
  96. CChatBox(const Rect & rect);
  97. void keyPressed(const SDL_KeyboardEvent & key) override;
  98. void addNewMessage(const std::string & text);
  99. };
  100. class CFlagBox : public CIntObject
  101. {
  102. std::shared_ptr<CAnimation> iconsTeamFlags;
  103. std::shared_ptr<CLabel> labelAllies;
  104. std::shared_ptr<CLabel> labelEnemies;
  105. std::vector<std::shared_ptr<CAnimImage>> flagsAllies;
  106. std::vector<std::shared_ptr<CAnimImage>> flagsEnemies;
  107. public:
  108. CFlagBox(const Rect & rect);
  109. void recreate();
  110. void clickRight(tribool down, bool previousState) override;
  111. void showTeamsPopup();
  112. class CFlagBoxTooltipBox : public CWindowObject
  113. {
  114. std::shared_ptr<CLabel> labelTeamAlignment;
  115. std::shared_ptr<CLabelGroup> labelGroupTeams;
  116. std::vector<std::shared_ptr<CAnimImage>> iconsFlags;
  117. public:
  118. CFlagBoxTooltipBox(std::shared_ptr<CAnimation> icons);
  119. };
  120. };
  121. extern ISelectionScreenInfo * SEL;