Howdy, Can you print multiple lines of text with one call to the IGUIFont->draw() function? For instance:
[code]
core::stringw str;
str = L"Line #1 \n Line #2 \n Line #3";
gameFont->draw(
str.c_str(),
core::rect<s32>(
core::position2d<s32>( 0, 500 ),
core::dimension2d<s32>( 450,15 )),
video::SColor(255,255,255,255));
[/code]
This code basically ignores the newline characters. I would like to make an on screen text console. If this isn't the way to go, does anyone have any better ideas how to implement such a thing?
Thanks, chaps,
S.[code][/code]
Newline from IGUIFont->draw()?
i did it this way
Code: Select all
irr::core::stringc buffer = "sum text\nline2\n";
irr::core::array<irr::core::stringc> screen_buffer;
irr::u32 start = 0;
irr::u32 i = 0;
for(;i<buffer.size();i++) {
//add next line
if( buffer[i] == '\n' ) {
screen_buffer.push_back(buffer.subString(start,i-start));
start = i+1;
continue;
}
}
//add the rest if the string
if(start<buffer.size()) {
screen_buffer.push_back(buffer.subString(start,i-start));
}
//now draw the screen_buffer array, line by line
for(i=0;i<screen_buffer.size();i++) {
y = fontScale*i;
drawStr(0,y,screen_buffer[i].c_str(),color,Font);
}