From e45e92e0ff294e6a1899b01b8cfdd8ab25d8dcdc Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Tue, 13 Dec 2022 19:35:48 +0100 Subject: Make a better text rendering system and a simple example in titlestate --- src/states/titleState.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/states/titleState.cpp') 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(); -- cgit v1.2.3