screen.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SuperTux
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #ifndef HEADER_SUPERTUX_SUPERTUX_SCREEN_HPP
  17. #define HEADER_SUPERTUX_SUPERTUX_SCREEN_HPP
  18. #include "sdk/integration.hpp"
  19. class Compositor;
  20. class Controller;
  21. /**
  22. * Abstract base class for code the MainLoop runs exclusively and full-screen.
  23. *
  24. * Examples of Screens are: The TitleScreen, a WorldMap, a level's
  25. * GameSession, a TextScroller, ...
  26. */
  27. class Screen
  28. {
  29. public:
  30. virtual ~Screen()
  31. {}
  32. /**
  33. * gets called before this screen gets activated (which is at least once
  34. * before the first draw or update call
  35. */
  36. virtual void setup()
  37. {}
  38. /** gets called when the current screen is temporarily suspended */
  39. virtual void leave()
  40. {}
  41. /**
  42. * gets called once per frame. The screen should draw itself in this function.
  43. * State changes should not be done in this function, but rather in update
  44. */
  45. virtual void draw(Compositor& compositor) = 0;
  46. /**
  47. * gets called for once (per logical) frame. Screens should do their state
  48. * updates and logic here
  49. */
  50. virtual void update(float dt_sec, const Controller& controller) = 0;
  51. /**
  52. * Gives details about what the user is doing right now.
  53. *
  54. * @returns activity details for presence integrations
  55. */
  56. virtual IntegrationStatus get_status() const = 0;
  57. };
  58. #endif
  59. /* EOF */