feature/imgui-sdl
Last change
on this file since 8b823e7 was e1f88a9, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago |
Create a system to draw and switch between different screens, a Screen class, a MainScreen class that extends it, and some classes for UI elements that can be added to screens.
|
-
Property mode
set to
100644
|
File size:
1.8 KB
|
Line | |
---|
1 | #ifndef _GAME_GUI_H
|
---|
2 | #define _GAME_GUI_H
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 | #include <vector>
|
---|
6 |
|
---|
7 | #ifdef GAMEGUI_INCLUDE_VULKAN
|
---|
8 | #include <vulkan/vulkan.h>
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | using namespace std;
|
---|
12 |
|
---|
13 | // TODO: See if it makes sense to combine this with the files in the gui folder
|
---|
14 |
|
---|
15 | enum EventType {
|
---|
16 | UI_EVENT_QUIT,
|
---|
17 | UI_EVENT_WINDOW,
|
---|
18 | UI_EVENT_WINDOWRESIZE,
|
---|
19 | UI_EVENT_KEYDOWN,
|
---|
20 | UI_EVENT_KEYUP,
|
---|
21 | UI_EVENT_MOUSEBUTTONDOWN,
|
---|
22 | UI_EVENT_MOUSEBUTTONUP,
|
---|
23 | UI_EVENT_MOUSEMOTION,
|
---|
24 | UI_EVENT_UNKNOWN
|
---|
25 | };
|
---|
26 |
|
---|
27 | struct WindowEvent {
|
---|
28 | EventType type;
|
---|
29 | };
|
---|
30 |
|
---|
31 | struct KeyEvent {
|
---|
32 | EventType type;
|
---|
33 | unsigned int keycode;
|
---|
34 | bool repeat;
|
---|
35 | };
|
---|
36 |
|
---|
37 | struct MouseEvent {
|
---|
38 | EventType type;
|
---|
39 | int x;
|
---|
40 | int y;
|
---|
41 | /*
|
---|
42 | int button;
|
---|
43 | int action;
|
---|
44 | */
|
---|
45 | };
|
---|
46 |
|
---|
47 | struct WindowResizeEvent {
|
---|
48 | EventType type;
|
---|
49 | int width;
|
---|
50 | int height;
|
---|
51 | };
|
---|
52 |
|
---|
53 | struct UnknownEvent {
|
---|
54 | EventType type;
|
---|
55 | unsigned int eventType;
|
---|
56 | };
|
---|
57 |
|
---|
58 | // TODO: Switch from union to std::variant
|
---|
59 |
|
---|
60 | union UIEvent {
|
---|
61 | EventType type;
|
---|
62 | WindowEvent window;
|
---|
63 | KeyEvent key;
|
---|
64 | MouseEvent mouse;
|
---|
65 | WindowResizeEvent windowResize;
|
---|
66 | UnknownEvent unknown;
|
---|
67 | };
|
---|
68 |
|
---|
69 | class GameGui {
|
---|
70 | public:
|
---|
71 | virtual ~GameGui() {};
|
---|
72 |
|
---|
73 | virtual string& getError() = 0;
|
---|
74 |
|
---|
75 | virtual bool init() = 0;
|
---|
76 | virtual void shutdown() = 0;
|
---|
77 |
|
---|
78 | virtual void* createWindow(const string& title, int width, int height, bool fullscreen) = 0;
|
---|
79 | virtual void destroyWindow() = 0;
|
---|
80 |
|
---|
81 | virtual void processEvents() = 0;
|
---|
82 | virtual int pollEvent(UIEvent* event) = 0;
|
---|
83 | virtual bool keyPressed(unsigned int key) = 0;
|
---|
84 |
|
---|
85 | virtual void refreshWindowSize() = 0;
|
---|
86 | virtual int getWindowWidth() = 0;
|
---|
87 | virtual int getWindowHeight() = 0;
|
---|
88 |
|
---|
89 | #ifdef GAMEGUI_INCLUDE_VULKAN
|
---|
90 | virtual bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
|
---|
91 | virtual vector<const char*> getRequiredExtensions() = 0;
|
---|
92 | #endif
|
---|
93 | };
|
---|
94 |
|
---|
95 | #endif // _GAME_GUI_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.