Updateable.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright © 2011-2020 Frictional Games
  3. *
  4. * This file is part of Amnesia: A Machine For Pigs.
  5. *
  6. * Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. * Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #ifndef HPL_UPDATEABLE_H
  19. #define HPL_UPDATEABLE_H
  20. #include "engine/EngineTypes.h"
  21. #include "system/SystemTypes.h"
  22. namespace hpl {
  23. class iUpdateable
  24. {
  25. public:
  26. iUpdateable(const tString& asName) : msName(asName){}
  27. virtual ~iUpdateable() {}
  28. virtual void OnPostBufferSwap(){}
  29. virtual void OnStart(){}
  30. virtual void OnDraw(float afFrameTime){}
  31. virtual void OnPostRender(float afFrameTime){}
  32. virtual void PreUpdate(float afTimeStep){}
  33. virtual void Update(float afTimeStep){}
  34. virtual void PostUpdate(float afTimeStep){}
  35. virtual void OnPauseUpdate(float afTimeStep){}
  36. virtual void OnQuit(){}
  37. virtual void OnExit(){}
  38. virtual void Reset(){}
  39. virtual void OnEnterContainer(const tString& asOldContainer){}
  40. virtual void OnLeaveContainer(const tString& asNewContainer){}
  41. virtual void AppGotInputFocus(){}
  42. virtual void AppGotMouseFocus(){}
  43. virtual void AppGotVisibility(){}
  44. virtual void AppLostInputFocus(){}
  45. virtual void AppLostMouseFocus(){}
  46. virtual void AppLostVisibility(){}
  47. virtual void AppDeviceWasPlugged(){}
  48. virtual void AppDeviceWasRemoved(){}
  49. void RunMessage(eUpdateableMessage aMessage, float afX)
  50. {
  51. switch(aMessage)
  52. {
  53. case eUpdateableMessage_OnPostBufferSwap:
  54. OnPostBufferSwap(); break;
  55. case eUpdateableMessage_OnStart:
  56. OnStart(); break;
  57. case eUpdateableMessage_OnDraw:
  58. OnDraw(afX); break;
  59. case eUpdateableMessage_OnPostRender:
  60. OnPostRender(afX); break;
  61. case eUpdateableMessage_PreUpdate:
  62. PreUpdate(afX); break;
  63. case eUpdateableMessage_Update:
  64. Update(afX); break;
  65. case eUpdateableMessage_PostUpdate:
  66. PostUpdate(afX); break;
  67. case eUpdateableMessage_OnQuit:
  68. OnQuit(); break;
  69. case eUpdateableMessage_OnExit:
  70. OnExit(); break;
  71. case eUpdateableMessage_Reset:
  72. Reset(); break;
  73. case eUpdateableMessage_OnPauseUpdate:
  74. OnPauseUpdate(afX);break;
  75. case eUpdateableMessage_AppGotInputFocus:
  76. AppGotInputFocus();break;
  77. case eUpdateableMessage_AppGotMouseFocus:
  78. AppGotMouseFocus();break;
  79. case eUpdateableMessage_AppGotVisibility:
  80. AppGotVisibility();break;
  81. case eUpdateableMessage_AppLostInputFocus:
  82. AppLostInputFocus();break;
  83. case eUpdateableMessage_AppLostMouseFocus:
  84. AppLostMouseFocus();break;
  85. case eUpdateableMessage_AppLostVisibility:
  86. AppLostVisibility();break;
  87. case eUpdateableMessage_AppDeviceWasPlugged:
  88. AppDeviceWasPlugged();break;
  89. case eUpdateableMessage_AppDeviceWasRemoved:
  90. AppDeviceWasRemoved();break;
  91. };
  92. }
  93. const tString& GetName(){ return msName;}
  94. private:
  95. tString msName;
  96. };
  97. };
  98. #endif // HPL_UPDATEABLE_H