Textbox.h 694 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef INCLUDE_TEXTBOX_H
  2. #define INCLUDE_TEXTBOX_H
  3. #include "Graphics.h"
  4. #include "render/Font.h"
  5. #include "TINYSTL/vector.h"
  6. namespace WalrusRPG
  7. {
  8. constexpr char MAGIC_TOKEN = '\xFF';
  9. constexpr unsigned COMMAND_LEGNTH = 4;
  10. struct TextboxChar
  11. {
  12. char c;
  13. uint8_t routine;
  14. uint8_t arg1;
  15. uint8_t arg2;
  16. uint8_t arg3;
  17. };
  18. class Textbox
  19. {
  20. private:
  21. Graphics::Font fnt;
  22. tinystl::vector<TextboxChar> buffer;
  23. unsigned buffer_index;
  24. Graphics::Pixel current_color;
  25. signed letter_wait;
  26. signed letter_wait_cooldown;
  27. public:
  28. Textbox(Graphics::Font fnt);
  29. ~Textbox();
  30. void set_text(char *new_msg);
  31. void update(unsigned dt);
  32. void render(unsigned dt);
  33. };
  34. }
  35. #endif