Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Adding sf::Window::getTitle()  (Read 3023 times)

0 Members and 1 Guest are viewing this topic.

hamzse

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Adding sf::Window::getTitle()
« on: November 10, 2016, 04:18:07 pm »
Hello!

To say it in a short way, this is how i start my game:


int main(){
    MainProgram game(new sf::RenderWindow(sf::VideoMode(1280, 720), "Title"));

    game.insertNewState<StateMainMenu>();
    game.programLoop();
}
 

And it looks cool (to me) until i want to go fullscreen. The only way i can go fullscreen is by closing the  current window, then making a new one. The problem is i cannot get the title from the window, to pass it to the new one.


Originally i was about posting this here: http://en.sfml-dev.org/forums/index.php?topic=2276.0 , then the site warned me to make a new post instead of writing into a really old one.
« Last Edit: November 10, 2016, 05:39:05 pm by hamzse »

korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
Re: Adding sf::Window::getTitle()
« Reply #1 on: November 10, 2016, 05:12:55 pm »
int main() {
    std::string title = "SomeTitle?";
    MainProgram game(new sf::RenderWindow(sf::VideoMode(1280, 720), title.c_str()));

    game.insertNewState<StateMainMenu>();
    game.programLoop();
}
 
Or add „title” member to your MainProgram.

But IMHO getTitle() function would be nice feature.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Adding sf::Window::getTitle()
« Reply #2 on: November 10, 2016, 07:12:05 pm »
Just FYI: You don't have to actively close your window, just call sf::Window::create() once again.

Don't think a sf::Window::getTitle() would hurt, but at the same time just storing your title shouldn't be such a huge issue.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Adding sf::Window::getTitle()
« Reply #3 on: November 11, 2016, 12:15:58 am »
Storing the title in a string first has always been my work-around for this "problem". It can then be re-applied whenever the window is re-created (as when you change to fullscreen).

The added advantage to storing a string is that you can then add additional text that is more contextual. For example, the string would be the application name and then you could add information about the window after the title. Personally, I have used it to show feedback in the titlebar and still keeping the name ;)

One thing to note is that you don't actually have to convert it to a c string to pass it to the window as korczurekk's code did.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*