OptionsTab.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * OptionsTab.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 "../../lib/StartInfo.h"
  12. #include "../../lib/mapping/CMap.h"
  13. class CSlider;
  14. class CLabel;
  15. class CMultiLineLabel;
  16. class CFilledTexture;
  17. class CAnimImage;
  18. class CComponentBox;
  19. /// The options tab which is shown at the map selection phase.
  20. class OptionsTab : public CIntObject
  21. {
  22. std::shared_ptr<CPicture> background;
  23. std::shared_ptr<CLabel> labelTitle;
  24. std::shared_ptr<CMultiLineLabel> labelSubTitle;
  25. std::shared_ptr<CMultiLineLabel> labelPlayerNameAndHandicap;
  26. std::shared_ptr<CMultiLineLabel> labelStartingTown;
  27. std::shared_ptr<CMultiLineLabel> labelStartingHero;
  28. std::shared_ptr<CMultiLineLabel> labelStartingBonus;
  29. std::shared_ptr<CLabel> labelPlayerTurnDuration;
  30. std::shared_ptr<CLabel> labelTurnDurationValue;
  31. ui8 humanPlayers;
  32. public:
  33. enum SelType
  34. {
  35. TOWN,
  36. HERO,
  37. BONUS
  38. };
  39. struct CPlayerSettingsHelper
  40. {
  41. const PlayerSettings & settings;
  42. const SelType type;
  43. CPlayerSettingsHelper(const PlayerSettings & settings, SelType type)
  44. : settings(settings), type(type)
  45. {}
  46. /// visible image settings
  47. size_t getImageIndex();
  48. std::string getImageName();
  49. std::string getName(); /// name visible in options dialog
  50. std::string getTitle(); /// title in popup box
  51. std::string getSubtitle(); /// popup box subtitle
  52. std::string getDescription(); /// popup box description, not always present
  53. };
  54. class CPlayerOptionTooltipBox : public CWindowObject, public CPlayerSettingsHelper
  55. {
  56. std::shared_ptr<CFilledTexture> backgroundTexture;
  57. std::shared_ptr<CLabel> labelTitle;
  58. std::shared_ptr<CLabel> labelSubTitle;
  59. std::shared_ptr<CAnimImage> image;
  60. std::shared_ptr<CLabel> labelAssociatedCreatures;
  61. std::shared_ptr<CComponentBox> boxAssociatedCreatures;
  62. std::shared_ptr<CLabel> labelHeroSpeciality;
  63. std::shared_ptr<CAnimImage> imageSpeciality;
  64. std::shared_ptr<CLabel> labelSpecialityName;
  65. std::shared_ptr<CTextBox> textBonusDescription;
  66. void genHeader();
  67. void genTownWindow();
  68. void genHeroWindow();
  69. void genBonusWindow();
  70. public:
  71. CPlayerOptionTooltipBox(CPlayerSettingsHelper & helper);
  72. };
  73. /// Image with current town/hero/bonus
  74. struct SelectedBox : public CIntObject, public CPlayerSettingsHelper
  75. {
  76. std::shared_ptr<CAnimImage> image;
  77. std::shared_ptr<CLabel> subtitle;
  78. SelectedBox(Point position, PlayerSettings & settings, SelType type);
  79. void clickRight(tribool down, bool previousState) override;
  80. void update();
  81. };
  82. struct PlayerOptionsEntry : public CIntObject
  83. {
  84. PlayerInfo pi;
  85. PlayerSettings s;
  86. std::shared_ptr<CLabel> labelPlayerName;
  87. std::shared_ptr<CMultiLineLabel> labelWhoCanPlay;
  88. std::shared_ptr<CPicture> background;
  89. std::shared_ptr<CButton> buttonTownLeft;
  90. std::shared_ptr<CButton> buttonTownRight;
  91. std::shared_ptr<CButton> buttonHeroLeft;
  92. std::shared_ptr<CButton> buttonHeroRight;
  93. std::shared_ptr<CButton> buttonBonusLeft;
  94. std::shared_ptr<CButton> buttonBonusRight;
  95. std::shared_ptr<CButton> flag;
  96. std::shared_ptr<SelectedBox> town;
  97. std::shared_ptr<SelectedBox> hero;
  98. std::shared_ptr<SelectedBox> bonus;
  99. enum {HUMAN_OR_CPU, HUMAN, CPU} whoCanPlay;
  100. PlayerOptionsEntry(const PlayerSettings & S, const OptionsTab & parentTab);
  101. void hideUnavailableButtons();
  102. private:
  103. const OptionsTab & parentTab;
  104. };
  105. std::shared_ptr<CSlider> sliderTurnDuration;
  106. std::map<PlayerColor, std::shared_ptr<PlayerOptionsEntry>> entries;
  107. OptionsTab();
  108. void recreate();
  109. void onSetPlayerClicked(const PlayerSettings & ps) const;
  110. };