OptionsTab.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. public:
  32. enum SelType
  33. {
  34. TOWN,
  35. HERO,
  36. BONUS
  37. };
  38. struct CPlayerSettingsHelper
  39. {
  40. const PlayerSettings & settings;
  41. const SelType type;
  42. CPlayerSettingsHelper(const PlayerSettings & settings, SelType type)
  43. : settings(settings), type(type)
  44. {}
  45. /// visible image settings
  46. size_t getImageIndex();
  47. std::string getImageName();
  48. std::string getName(); /// name visible in options dialog
  49. std::string getTitle(); /// title in popup box
  50. std::string getSubtitle(); /// popup box subtitle
  51. std::string getDescription(); /// popup box description, not always present
  52. };
  53. class CPlayerOptionTooltipBox : public CWindowObject, public CPlayerSettingsHelper
  54. {
  55. std::shared_ptr<CFilledTexture> backgroundTexture;
  56. std::shared_ptr<CLabel> labelTitle;
  57. std::shared_ptr<CLabel> labelSubTitle;
  58. std::shared_ptr<CAnimImage> image;
  59. std::shared_ptr<CLabel> labelAssociatedCreatures;
  60. std::shared_ptr<CComponentBox> boxAssociatedCreatures;
  61. std::shared_ptr<CLabel> labelHeroSpeciality;
  62. std::shared_ptr<CAnimImage> imageSpeciality;
  63. std::shared_ptr<CLabel> labelSpecialityName;
  64. std::shared_ptr<CTextBox> textBonusDescription;
  65. void genHeader();
  66. void genTownWindow();
  67. void genHeroWindow();
  68. void genBonusWindow();
  69. public:
  70. CPlayerOptionTooltipBox(CPlayerSettingsHelper & helper);
  71. };
  72. /// Image with current town/hero/bonus
  73. struct SelectedBox : public CIntObject, public CPlayerSettingsHelper
  74. {
  75. std::shared_ptr<CAnimImage> image;
  76. std::shared_ptr<CLabel> subtitle;
  77. SelectedBox(Point position, PlayerSettings & settings, SelType type);
  78. void clickRight(tribool down, bool previousState) override;
  79. void update();
  80. };
  81. struct PlayerOptionsEntry : public CIntObject
  82. {
  83. PlayerInfo pi;
  84. PlayerSettings s;
  85. std::shared_ptr<CLabel> labelPlayerName;
  86. std::shared_ptr<CMultiLineLabel> labelWhoCanPlay;
  87. std::shared_ptr<CPicture> background;
  88. std::shared_ptr<CButton> buttonTownLeft;
  89. std::shared_ptr<CButton> buttonTownRight;
  90. std::shared_ptr<CButton> buttonHeroLeft;
  91. std::shared_ptr<CButton> buttonHeroRight;
  92. std::shared_ptr<CButton> buttonBonusLeft;
  93. std::shared_ptr<CButton> buttonBonusRight;
  94. std::shared_ptr<CButton> flag;
  95. std::shared_ptr<SelectedBox> town;
  96. std::shared_ptr<SelectedBox> hero;
  97. std::shared_ptr<SelectedBox> bonus;
  98. enum {HUMAN_OR_CPU, HUMAN, CPU} whoCanPlay;
  99. PlayerOptionsEntry(const PlayerSettings & S);
  100. void hideUnavailableButtons();
  101. };
  102. std::shared_ptr<CSlider> sliderTurnDuration;
  103. std::map<PlayerColor, std::shared_ptr<PlayerOptionsEntry>> entries;
  104. OptionsTab();
  105. void recreate();
  106. };