2
0

CSelectionBase.h 3.8 KB

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