Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

UI.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*!
  2. * \file include/UI.h
  3. * \brief Abstract UI interface
  4. *
  5. * \author xythobuz
  6. */
  7. #ifndef _UI_H_
  8. #define _UI_H_
  9. #include <functional>
  10. #include <list>
  11. #include <memory>
  12. #include <tuple>
  13. #include <vector>
  14. #include "imgui/imgui.h"
  15. class UI {
  16. public:
  17. virtual ~UI();
  18. virtual void display();
  19. virtual void handleKeyboard(KeyboardButton key, bool pressed);
  20. virtual void handleText(char *text, bool notFinished);
  21. virtual void handleAction(ActionEvents action, bool isFinished);
  22. virtual void handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released);
  23. virtual void handleMouseMotion(int xrel, int yrel);
  24. virtual void handleMouseScroll(int xrel, int yrel);
  25. virtual bool isOnTop();
  26. virtual void moveToTop();
  27. virtual void makeInvisible();
  28. static int initialize();
  29. static void eventsFinished();
  30. static void displayInOrder();
  31. static void passKeyboard(KeyboardButton key, bool pressed);
  32. static void passText(char *text, bool notFinished);
  33. static void passMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released);
  34. static void passMouseMotion(int xrel, int yrel);
  35. static void passMouseScroll(int xrel, int yrel);
  36. protected:
  37. static void addWindow(UI* window);
  38. static void removeWindow(UI *window);
  39. long zPos;
  40. private:
  41. static void sendKeyboard(KeyboardButton key, bool pressed);
  42. static void sendText(char *text, bool notFinished);
  43. static void sendMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released);
  44. static void sendMouseMotion(int xrel, int yrel);
  45. static void sendMouseScroll(int xrel, int yrel);
  46. static void renderImGui(ImDrawList** const draw_lists, int count);
  47. static void findInList(UI *w, std::function<void (unsigned long i)> func);
  48. static bool isOnTop(unsigned long windowID);
  49. static void moveToTop(unsigned long windowID);
  50. static void makeInvisible(unsigned long windowID);
  51. static bool compareUIs(UI* a, UI* b);
  52. static std::vector<UI*> windows;
  53. static std::list<std::tuple<KeyboardButton, bool>> keyboardEvents;
  54. static std::list<std::tuple<char *, bool>> textEvents;
  55. static std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> clickEvents;
  56. static std::list<std::tuple<int, int>> motionEvents;
  57. static std::list<std::tuple<int, int>> scrollEvents;
  58. };
  59. #endif