summaryrefslogtreecommitdiff
path: root/src/states/titleState.cpp
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2022-12-13 19:35:48 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2022-12-13 19:35:48 +0100
commite45e92e0ff294e6a1899b01b8cfdd8ab25d8dcdc (patch)
tree6021345d94502db896ca0174abf270b51e89e306 /src/states/titleState.cpp
parent70c0be5b2cfb3b9cfe86d5a6e6624e28fb845453 (diff)
Make a better text rendering system and a simple example in titlestate
Diffstat (limited to 'src/states/titleState.cpp')
-rw-r--r--src/states/titleState.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/states/titleState.cpp b/src/states/titleState.cpp
index d96c840..fe78d45 100644
--- a/src/states/titleState.cpp
+++ b/src/states/titleState.cpp
@@ -8,7 +8,11 @@ TitleState::TitleState(StateStack &stack, State::Context context)
// TODO: Initialize UI properly to zeros
//, ui(0,0,false,false,0,0)
{
-
+ context.textures->load(Textures::Id::Base_Font, "assets/img/Font/Font.png");
+ auto &fontTexture = context.textures->get(Textures::Id::Base_Font);
+ Graphics::TextureFont::Descr fontDescr {"abcdefghijklmnopqrstuvwxyz1234567890!?.,$ ", 6,7};
+ auto font = new Graphics::TextureFont(fontTexture, fontDescr);
+ context.textureFonts->manage(Fonts::Id::Base_Font, font);
}
void TitleState::update(sf::Time dt){
@@ -20,22 +24,16 @@ void TitleState::render(){
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");
- }
-
+ Graphics::TextureFont &font = context_.textureFonts->get(Fonts::Id::Base_Font);
- radioState = ui.radioButton(context_.window, 21, "Radio", radioState,
- sf::Vector2i(0,800), sf::Vector2i(200,100));
+ radioState = ui.radioButton(context_.window,
+ font, 21,
+ "this is\nthe whole thing or maybe is just another bullshit code it doesn't work",
+ radioState,
+ sf::Vector2i(0,100), sf::Vector2i(200,50));
if (radioState){
- ui.button(context_.window, 20, "Hidden button", sf::Vector2i(0,600), sf::Vector2i(200,100));
+ ui.button(context_.window, 20, "Hidden button", sf::Vector2i(0,200), sf::Vector2i(200,100));
}
ui.finishImUI();