source: opengl-game/gui/main-screen.cpp@ 670c09a

feature/imgui-sdl
Last change on this file since 670c09a 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: 997 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(UIEvent& 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.