source: opengl-game/gui/main-screen.cpp@ 5081b9a

feature/imgui-sdl
Last change on this file since 5081b9a 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: 999 bytes
Line 
1#include "main-screen.hpp"
2
3#include "../vulkan-game.hpp"
4
5#include "button.hpp"
6
7MainScreen::MainScreen(SDL_Renderer& renderer, VulkanGame& gameInfo) :
8 Screen(renderer, gameInfo) {
9 addUIElement(new Button("New Game", 368, 131, 9, 0x222299FF, 0xFFFFFFFF, this->gameInfo,
10 this->renderer, newGame_onMouseClick, nullptr, nullptr));
11 addUIElement(new Button("Quit", 382, 186, 9, 0x222299FF, 0xFFFFFFFF, this->gameInfo,
12 this->renderer, quit_onMouseClick, nullptr, nullptr));
13}
14
15MainScreen::~MainScreen() {
16}
17
18void MainScreen::createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage) {
19 // Always render this pipeline last
20 gameInfo.overlayPipeline.createRenderCommands(commandBuffer, currentImage);
21}
22
23void MainScreen::handleEvent(GameEvent& e) {
24 Screen::handleEvent(e);
25}
26
27void newGame_onMouseClick(VulkanGame& gameInfo) {
28 gameInfo.goToScreen(gameInfo.screens[SCREEN_GAME]);
29}
30
31void quit_onMouseClick(VulkanGame& gameInfo) {
32 gameInfo.quitGame();
33}
Note: See TracBrowser for help on using the repository browser.