diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-12-05 22:55:40 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-12-05 22:55:40 +0100 |
commit | 30f488cdcb88dad5dd1df425588cb6a7fd206bb5 (patch) | |
tree | ccd606c44bb2a6ab028548e21463b08c8c92577b /src/states | |
parent | bf34d835e4ea49bd4ef2e5de2b1fea2fd3c95adc (diff) |
Sketch ImGUI:
- Still needs font rendering
Diffstat (limited to 'src/states')
-rw-r--r-- | src/states/titleState.cpp | 35 | ||||
-rw-r--r-- | src/states/titleState.h | 2 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/states/titleState.cpp b/src/states/titleState.cpp index a0d17c8..d96c840 100644 --- a/src/states/titleState.cpp +++ b/src/states/titleState.cpp @@ -1,8 +1,12 @@ #include "titleState.h" #include <SFML/Graphics.hpp> +#include <string> + TitleState::TitleState(StateStack &stack, State::Context context) : State(stack, context) + // TODO: Initialize UI properly to zeros + //, ui(0,0,false,false,0,0) { } @@ -12,14 +16,31 @@ void TitleState::update(sf::Time dt){ } void TitleState::render(){ - sf::RectangleShape rectangle; - rectangle.setSize(sf::Vector2f(100, 50)); - rectangle.setOutlineColor(sf::Color::Red); - rectangle.setOutlineThickness(5); - rectangle.setPosition(10, 20); - context_.window->draw(rectangle); + static bool radioState = false; + + ui.initImUI(); + + if (ui.button(context_.window, 17, "Button 1", sf::Vector2i(0,0), sf::Vector2i(200,100)) ){ + printf("Button 1 pressed!!\n"); + } + if (ui.button(context_.window, 18, "Button 2", sf::Vector2i(0,200), sf::Vector2i(200,100)) ){ + printf("Button 2 pressed!!\n"); + } + if (ui.button(context_.window, 19, "Button 3", sf::Vector2i(0,400), sf::Vector2i(200,100)) ){ + printf("Button 3 pressed!!\n"); + } + + + radioState = ui.radioButton(context_.window, 21, "Radio", radioState, + sf::Vector2i(0,800), sf::Vector2i(200,100)); + + if (radioState){ + ui.button(context_.window, 20, "Hidden button", sf::Vector2i(0,600), sf::Vector2i(200,100)); + } + + ui.finishImUI(); } void TitleState::handleEvent(const sf::Event &event){ - + ui.handleEvent(event); } diff --git a/src/states/titleState.h b/src/states/titleState.h index 8b914d8..83339f8 100644 --- a/src/states/titleState.h +++ b/src/states/titleState.h @@ -2,8 +2,10 @@ #define STATES_TITLESTATE_H #include "../states.h" +#include "../ui.h" class TitleState : public State{ + UI ui; public: TitleState(StateStack &stack, State::Context context); virtual void update(sf::Time dt) override; |