SFML community forums

Help => Window => Topic started by: danersound on December 23, 2017, 07:11:28 pm

Title: wraped text in a renderwindow
Post by: danersound 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 ?
Title: Re: wraped text in a renderwindow
Post by: eXpl0it3r 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.
Title: Re: wraped text in a renderwindow
Post by: danersound 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