You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 line
1.3 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #pragma once
  13. //
  14. // The Text class
  15. // --------------
  16. //
  17. #include "engine/entity.h"
  18. #include <string>
  19. namespace lol
  20. {
  21. class TextData;
  22. enum class TextAlign
  23. {
  24. Left,
  25. Right,
  26. Center,
  27. };
  28. class Text : public Entity
  29. {
  30. public:
  31. Text(std::string const &text, char const *font);
  32. virtual ~Text();
  33. /** Set the text that will be displayed */
  34. void SetText(std::string const &text);
  35. void SetInt(int val);
  36. /** Set the position of the text object, in the 3D world. */
  37. void SetPos(vec3 pos);
  38. /** Set the text scaling */
  39. void SetScale(vec2 scale);
  40. /** Set the spacing between characters, as a fraction of character width */
  41. void SetSpacing(float spacing);
  42. /** Set the alignment method */
  43. void SetAlign(TextAlign align);
  44. vec3 GetPos();
  45. ivec2 GetFontSize();
  46. protected:
  47. virtual void tick_draw(float seconds, Scene &scene);
  48. private:
  49. TextData *data;
  50. };
  51. } /* namespace lol */