feature/imgui-sdl
|
Last change
on this file since 9c0a614 was d8cf709, checked in by Dmitry Portnoy <dportnoy@…>, 5 years ago |
|
Change UIEvent to also include the original event from the UI library the game gui is currently using, such as SDL or GLFW.
|
-
Property mode
set to
100644
|
|
File size:
831 bytes
|
| Line | |
|---|
| 1 | #include "screen.hpp"
|
|---|
| 2 |
|
|---|
| 3 | #include "../vulkan-game.hpp"
|
|---|
| 4 |
|
|---|
| 5 | Screen::Screen(SDL_Renderer& renderer, VulkanGame& gameInfo) :
|
|---|
| 6 | renderer(renderer),
|
|---|
| 7 | gameInfo(gameInfo) {
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | Screen::~Screen() {
|
|---|
| 11 | for (UIElement*& uiElement : this->uiElements) {
|
|---|
| 12 | delete uiElement;
|
|---|
| 13 | }
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | void Screen::init() {
|
|---|
| 17 | for (UIElement*& uiElement : this->uiElements) {
|
|---|
| 18 | uiElement->init();
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | void Screen::renderUI() {
|
|---|
| 23 | SDL_SetRenderDrawColor(&this->renderer, 0x00, 0x00, 0x00, 0x00);
|
|---|
| 24 | SDL_RenderClear(&this->renderer);
|
|---|
| 25 |
|
|---|
| 26 | for (UIElement*& uiElement : this->uiElements) {
|
|---|
| 27 | uiElement->render(0, 0);
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | void Screen::handleEvent(GameEvent& e) {
|
|---|
| 32 | for (UIElement*& uiElement : this->uiElements) {
|
|---|
| 33 | uiElement->handleEvent(e);
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | void Screen::addUIElement(UIElement* element) {
|
|---|
| 38 | this->uiElements.push_back(element);
|
|---|
| 39 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.