source: opengl-game/gui/screen.cpp

feature/imgui-sdl
Last change on this file was d8cf709, checked in by Dmitry Portnoy <dportnoy@…>, 4 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
5Screen::Screen(SDL_Renderer& renderer, VulkanGame& gameInfo) :
6 renderer(renderer),
7 gameInfo(gameInfo) {
8}
9
10Screen::~Screen() {
11 for (UIElement*& uiElement : this->uiElements) {
12 delete uiElement;
13 }
14}
15
16void Screen::init() {
17 for (UIElement*& uiElement : this->uiElements) {
18 uiElement->init();
19 }
20}
21
22void 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
31void Screen::handleEvent(GameEvent& e) {
32 for (UIElement*& uiElement : this->uiElements) {
33 uiElement->handleEvent(e);
34 }
35}
36
37void Screen::addUIElement(UIElement* element) {
38 this->uiElements.push_back(element);
39}
Note: See TracBrowser for help on using the repository browser.