RandomMapTab.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * RandomMapTab.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 "CSelectionBase.h"
  12. #include "../../lib/FunctionList.h"
  13. #include "../../lib/GameConstants.h"
  14. #include "../../lib/rmg/CRmgTemplate.h"
  15. #include "../gui/InterfaceObjectConfigurable.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class CMapGenOptions;
  18. VCMI_LIB_NAMESPACE_END
  19. class CToggleButton;
  20. class CLabel;
  21. class CLabelGroup;
  22. class CSlider;
  23. class CPicture;
  24. class CTextInput;
  25. class TransparentFilledRectangle;
  26. class RandomMapTab : public InterfaceObjectConfigurable
  27. {
  28. public:
  29. RandomMapTab();
  30. void updateMapInfoByHost();
  31. void setMapGenOptions(std::shared_ptr<CMapGenOptions> opts);
  32. void setTemplate(const CRmgTemplate *);
  33. void saveOptions(const CMapGenOptions & options);
  34. void loadOptions();
  35. CMapGenOptions & obtainMapGenOptions() {return *mapGenOptions;}
  36. CFunctionList<void(std::shared_ptr<CMapInfo>, std::shared_ptr<CMapGenOptions>)> mapInfoChanged;
  37. private:
  38. void deactivateButtonsFrom(CToggleGroup & group, const std::set<int> & allowed);
  39. std::vector<int> getStandardMapSizes();
  40. void onToggleMapSize(int btnId);
  41. std::shared_ptr<CMapInfo> mapInfo;
  42. std::shared_ptr<CMapGenOptions> mapGenOptions;
  43. //options allowed - need to store as impact each other
  44. std::set<int> playerCountAllowed;
  45. std::set<int> playerTeamsAllowed;
  46. std::set<int> compCountAllowed;
  47. std::set<int> compTeamsAllowed;
  48. int templateIndex;
  49. };
  50. class TeamAlignmentsWidget: public InterfaceObjectConfigurable
  51. {
  52. public:
  53. TeamAlignmentsWidget(RandomMapTab & randomMapTab);
  54. private:
  55. void checkTeamCount();
  56. std::shared_ptr<CFilledTexture> background;
  57. std::shared_ptr<CLabelGroup> labels;
  58. std::shared_ptr<CButton> buttonOk;
  59. std::shared_ptr<CButton> buttonCancel;
  60. std::vector<std::shared_ptr<CToggleGroup>> players;
  61. std::vector<std::shared_ptr<CIntObject>> placeholders;
  62. };
  63. class TeamAlignments: public CWindowObject
  64. {
  65. std::shared_ptr<TeamAlignmentsWidget> widget;
  66. public:
  67. TeamAlignments(RandomMapTab & randomMapTab);
  68. };
  69. class SetSizeWindow: public CWindowObject
  70. {
  71. std::shared_ptr<FilledTexturePlayerColored> background;
  72. std::vector<std::shared_ptr<CLabel>> titles;
  73. std::shared_ptr<CButton> buttonOk;
  74. std::vector<std::shared_ptr<CTextInput>> numInputs;
  75. std::vector<std::shared_ptr<TransparentFilledRectangle>> rectangles;
  76. public:
  77. SetSizeWindow(int3 initSize, std::function<void(int3)> cb);
  78. };