StOneDOes Posted January 15, 2023 Share Posted January 15, 2023 The UI label widget appears to ignore the \n newline character, whereas the Text Area widget utilizes it correctly. Is this the expected behaviour? Because for something like on-screen debug info I personally would prefer to have a single widget with all the text assigned to the one label, rather than having eg. 10 label widgets and having to set their positions. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted January 15, 2023 Share Posted January 15, 2023 I've noticed the same thing and I think it's intended but not positive. You can probably use the textarea widget and set its background to be transparent. Quote Link to comment Share on other sites More sharing options...
Josh Posted January 15, 2023 Share Posted January 15, 2023 This is the intended behavior. The TextArea widget is intended for displaying multi-line text. It might be possible in the future for labels to support multiple lines, but it needs to be done carefully because labels have a lot of alignment options in their style flags. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 15, 2023 Share Posted January 15, 2023 Actually, I take that back. I already programmed it with multi-line support: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); //Create User Interface auto ui = CreateInterface(window); //Create widget auto label1 = CreateLabel("First line\nSecond line\nThird line", 20, 20, 120, 60, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE ); while (window->Closed() == false) { WaitEvent(); } return 0; } However, when a 3D GUI is in use the line return is ignored: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0); auto font = LoadFont("Fonts/arial.ttf"); auto ui = CreateInterface(world, font, framebuffer->size); auto label = CreateLabel("First line\nSecond line\nThird line", 20, 20, 120, 60, ui->root, LABEL_BORDER | LABEL_CENTER | LABEL_MIDDLE ); while (window->Closed() == false) { world->Update(); world->Render(framebuffer); } return 0; } So I need to adjust the sprite creation code to handle multi-line text and then everything should work the same in Vulkan. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 23, 2023 Share Posted January 23, 2023 Working on this now... 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
reepblue Posted January 23, 2023 Share Posted January 23, 2023 Can text sprites also properly support this if they don't already? Would be nice to have for close captioning. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Josh Posted January 23, 2023 Share Posted January 23, 2023 Yeah, that is the part I have done so far. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted January 23, 2023 Solution Share Posted January 23, 2023 Here's an example of it working. I will have an update up shortly: #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; #define UI3D int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); world->SetAmbientLight(0); //Create a framebuffer #ifdef UI3D auto framebuffer = CreateFramebuffer(window); #endif //Create a camera auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); #ifdef UI3D camera->SetPosition(float(framebuffer->size.x) * 0.5f,float(framebuffer->size.y) * 0.5f); #endif auto font = LoadFont("Fonts/arial.ttf"); auto sprite = CreateSprite(world, font, "AAAAAAAAAAAAA", 26, TEXT_CENTER | TEXT_MIDDLE, 400000.0f); auto ss = CreateSprite(world, 100, 100); ss->SetColor(1, 0, 0); #ifdef UI3D auto ui = CreateInterface(world, font, framebuffer->size); #else auto ui = CreateInterface(window); #endif auto label = CreateLabel("test 1\ntest line 2\ntest 3", 20, 20, 200, 200, ui->background, LABEL_BORDER | LABEL_MIDDLE | LABEL_RIGHT ); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { Sleep(10); #ifdef UI3D world->Update(); world->Render(framebuffer); #endif } return 0; } 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.