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

Author Topic: wraped text in a renderwindow  (Read 2903 times)

0 Members and 1 Guest are viewing this topic.

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
wraped text in a renderwindow
« on: December 23, 2017, 07:11:28 pm »
i have a renderwindow ( see the pic in grey ) i need to define an AREA ( in the pic the rectangle with red edges )
in this AREA i want to load some text from a simple file.txt .
any suggestions? how to do it?
with this code i read the file , I really dont know how to define this AREA ?
void textLoader(Text *TmplineMenu) {

        string menuLine, tmpStr;
        ifstream infile;

        infile.open("Tools/datiMenu.txt");
        while (getline(infile, menuLine)) {

                size_t position = menuLine.find("||") + 1;
                menuLine.insert(position, "\n");
                tmpStr += menuLine;
                tmpStr += '\n';
        }
        TmplineMenu->setString(tmpStr);
        infile.close();
}

 
any suggestions ?
« Last Edit: December 23, 2017, 08:33:30 pm by danersound »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: wraped text in a renderwindow
« Reply #1 on: December 24, 2017, 04:58:37 pm »
You calculate the space the text takes up and insert a line break when it reaches a certain width.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

danersound

  • Newbie
  • *
  • Posts: 12
  • sound of the silent
    • View Profile
    • Email
Re: wraped text in a renderwindow
« Reply #2 on: December 25, 2017, 02:13:27 pm »
You calculate the space the text takes up and insert a line break when it reaches a certain width.

yeah i've been thinking about it but i break to much lines! in my application will be 3 diferents text Areas! i dont know if the space ill be enough... can you make me a example how to define this area effectively without breaking to many lines? thx you

 

anything