gameMode.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #pragma once
  2. #ifndef GAME_MODE_H
  3. #define GAME_MODE_H
  4. #ifdef TORQUE_TOOLS
  5. #ifndef _GUI_INSPECTOR_TYPES_H_
  6. #include "gui/editor/guiInspectorTypes.h"
  7. #endif
  8. #endif
  9. #ifndef SUB_SCENE_H
  10. #include "SubScene.h"
  11. #endif
  12. #include "T3D/assets/ImageAsset.h"
  13. class GameMode : public SimObject
  14. {
  15. typedef SimObject Parent;
  16. private:
  17. StringTableEntry mGameModeName;
  18. StringTableEntry mGameModeDesc;
  19. DECLARE_IMAGEASSET(GameMode, PreviewImage, previewChange, GFXStaticTextureSRGBProfile);
  20. DECLARE_ASSET_SETGET(GameMode, PreviewImage);
  21. bool mIsActive;
  22. bool mIsAlwaysActive;
  23. public:
  24. GameMode();
  25. ~GameMode() = default;
  26. static void initPersistFields();
  27. bool onAdd() override;
  28. void onRemove() override;
  29. bool isActive() { return mIsActive; }
  30. void setActive(const bool& active);
  31. bool isAlwaysActive() { return mIsAlwaysActive; }
  32. void setAlwaysActive(const bool& alwaysActive);
  33. DECLARE_CONOBJECT(GameMode);
  34. static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes);
  35. void previewChange() {}
  36. DECLARE_CALLBACK(void, onActivated, ());
  37. DECLARE_CALLBACK(void, onDeactivated, ());
  38. DECLARE_CALLBACK(void, onSceneLoaded, ());
  39. DECLARE_CALLBACK(void, onSceneUnloaded, ());
  40. DECLARE_CALLBACK(void, onSubsceneLoaded, (SubScene*));
  41. DECLARE_CALLBACK(void, onSubsceneUnloaded, (SubScene*));
  42. };
  43. DefineConsoleType(TypeGameModeList, String)
  44. #ifdef TORQUE_TOOLS
  45. class GuiInspectorTypeGameModeListHelper;
  46. class GuiInspectorTypeGameModeList : public GuiInspectorField
  47. {
  48. typedef GuiInspectorField Parent;
  49. public:
  50. GuiInspectorTypeGameModeListHelper* mHelper;
  51. GuiRolloutCtrl* mRollout;
  52. GuiDynamicCtrlArrayControl* mArrayCtrl;
  53. Vector<GuiInspectorField*> mChildren;
  54. GuiBitmapButtonCtrl* mButton;
  55. RectI mButtonRect;
  56. DECLARE_CONOBJECT(GuiInspectorTypeGameModeList);
  57. GuiInspectorTypeGameModeList();
  58. // ConsoleObject
  59. bool onAdd() override;
  60. static void consoleInit();
  61. // GuiInspectorField
  62. bool resize(const Point2I& newPosition, const Point2I& newExtent) override;
  63. void childResized(GuiControl* child) override;
  64. bool updateRects() override;
  65. void updateData() override;
  66. StringTableEntry getValue() override;
  67. void setValue(StringTableEntry value) override;
  68. };
  69. class GuiInspectorTypeGameModeListHelper : public GuiInspectorField
  70. {
  71. typedef GuiInspectorField Parent;
  72. public:
  73. GuiInspectorTypeGameModeListHelper();
  74. DECLARE_CONOBJECT(GuiInspectorTypeGameModeListHelper);
  75. GuiBitmapButtonCtrl* mButton;
  76. GuiRolloutCtrl* mParentRollout;
  77. GuiInspectorTypeGameModeList* mParentField;
  78. RectI mButtonRect;
  79. //-----------------------------------------------------------------------------
  80. // Override able methods for custom edit fields
  81. //-----------------------------------------------------------------------------
  82. GuiControl* constructEditControl() override;
  83. bool resize(const Point2I& newPosition, const Point2I& newExtent) override;
  84. bool updateRects() override;
  85. void setValue(StringTableEntry value) override;
  86. };
  87. #endif
  88. #endif