feature/imgui-sdl
Last change
on this file since 699e83a was e1f88a9, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 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:
1001 bytes
|
Rev | Line | |
---|
[e1f88a9] | 1 | #ifndef _SCREEN_H
|
---|
| 2 | #define _SCREEN_H
|
---|
| 3 |
|
---|
| 4 | #include <vector>
|
---|
| 5 |
|
---|
| 6 | #include <vulkan/vulkan.h>
|
---|
| 7 |
|
---|
| 8 | #include <SDL2/SDL.h>
|
---|
| 9 |
|
---|
| 10 | #include "../consts.hpp"
|
---|
| 11 | //#include "../game-gui.hpp"
|
---|
| 12 |
|
---|
| 13 | #include "ui-element.hpp"
|
---|
| 14 |
|
---|
| 15 | using namespace std;
|
---|
| 16 |
|
---|
| 17 | class VulkanGame;
|
---|
| 18 |
|
---|
| 19 | template<class Type>
|
---|
| 20 | struct ValueReference {
|
---|
| 21 |
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | // TODO: Add a function to create an SDL_Color from a uint32_t
|
---|
| 25 |
|
---|
| 26 | // TODO: Maybe make this a subclass of UIElement
|
---|
| 27 | class Screen {
|
---|
| 28 | public:
|
---|
| 29 | Screen(SDL_Renderer& renderer, VulkanGame& gameInfo);
|
---|
| 30 | virtual ~Screen();
|
---|
| 31 |
|
---|
| 32 | virtual void createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage) = 0;
|
---|
| 33 | virtual void init();
|
---|
| 34 |
|
---|
| 35 | virtual void renderUI();
|
---|
| 36 | virtual void handleEvent(UIEvent& e);
|
---|
| 37 | void addUIElement(UIElement* element);
|
---|
| 38 |
|
---|
| 39 | protected:
|
---|
| 40 | SDL_Renderer& renderer;
|
---|
| 41 | VulkanGame& gameInfo;
|
---|
| 42 |
|
---|
| 43 | private:
|
---|
| 44 | vector<UIElement*> uiElements;
|
---|
| 45 | };
|
---|
| 46 |
|
---|
| 47 | // TODO: Maybe move these somewhere else
|
---|
| 48 | void button_onMouseEnter(UIElement& element);
|
---|
| 49 | void button_onMouseLeave(UIElement& element);
|
---|
| 50 |
|
---|
| 51 | #endif // _SCREEN_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.