Jump to content

Space between lines is too short after UI update


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

Just testing with tiles now...

#include "Leadwerks.h"

using namespace UltraEngine;

shared_ptr<Window> window;
shared_ptr<Framebuffer> framebuffer;
shared_ptr<World> menuWold;
shared_ptr<Interface> ui;
shared_ptr<Camera> uiCamera;

int main(int argc, const char* argv[]) {
    auto displays = GetDisplays();
    window = CreateWindow("Ultra Engine", 0, 0, 800, 250, displays[0], WINDOW_DEFAULT);
    menuWold = CreateWorld();
    framebuffer = CreateFramebuffer(window);

    uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC);
    
    auto font = LoadFont("Fonts\\arial.ttf");
    auto tile1 = CreateTile(uiCamera, 100, 12);
    tile1->SetColor(0, 0, 1);

    auto tile2 = CreateTile(uiCamera, font, "ESCpppp123", 12, TEXT_MIDDLE);
    tile2->SetPosition(0, 6);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        menuWold->Update();
        menuWold->Render(framebuffer);
    }
    return 0;
}

 

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

Since FreeType does not provide the font height, I just started using the height of the letter E for the font height, and it works fine. Problems may arise in the future for fonts that do not have this character.

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

Testing a multi-line label...

image.thumb.png.306fdfc19c8d9b4845f7957f31138d87.png

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char* argv[]) {
    auto displays = GetDisplays();
    auto window = CreateWindow("Leawerks 5", 0, 0, 800, 250, displays[0], WINDOW_DEFAULT);
    auto menuWold = CreateWorld();
    auto framebuffer = CreateFramebuffer(window);

    auto uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC);
    uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
    uiCamera->SetClearMode(CLEAR_DEPTH);
    auto default_font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(uiCamera, default_font, framebuffer->GetSize());

    auto panel = CreatePanel(10, 10, ui->background->size.x - 20, ui->background->size.y - 20, ui->background);
    panel->SetColor(0, 0, 1);

    auto customWidget = CreateLabel("", 0, 0, panel->size.x, panel->size.y, panel, LABEL_CENTER | LABEL_MIDDLE);
    customWidget->SetText("Enemy in full armored biosuit which can be penetrate only with nails.\nBalloon at the back can be destroyed and it will cause an explosion.\nHis laser rifle shoots at long range and charged shot can hit few units in the shot line.");
    customWidget->SetFontScale(2.0f);
    
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        menuWold->Update();
        menuWold->Render(framebuffer);
    }
    return 0;
}

 

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

  • Solution

Pretty darn good now

image.thumb.png.50181bf99e92fe0756f063f4459df882.png

image.thumb.png.c2368875fc6573bb97cc89ee7c08e02c.png

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char* argv[]) {
    auto displays = GetDisplays();
    auto window = CreateWindow("Leawerks 5", 0, 0, 800, 100, displays[0], WINDOW_DEFAULT | WINDOW_CLIENTCOORDS);
    auto menuWold = CreateWorld();
    auto framebuffer = CreateFramebuffer(window);

    auto uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC);
    uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0);
    uiCamera->SetClearMode(CLEAR_DEPTH);
    auto default_font = LoadFont("Fonts\\arial.ttf");
    auto ui = CreateInterface(uiCamera, default_font, framebuffer->GetSize());

    auto panel = CreatePanel(10, 10, ui->background->size.x - 20, ui->background->size.y - 20, ui->background);
    panel->SetColor(0, 0, 1);

    String s = "Enemy in full armored biosuit which can be penetrate only with nails.\nBalloon at the back can be destroyed and it will cause an explosion.\nHis laser rifle shoots at long range and charged shot can hit few units in the shot line.";

    auto customWidget = CreateLabel("", 0, 0, panel->size.x, panel->size.y, panel, LABEL_CENTER | LABEL_MIDDLE);
    customWidget->SetText(s);
    customWidget->SetFontScale(2.0f);
    
    //auto tile = CreateTile(uiCamera, default_font, s, 12.0f * 2.0f, TEXT_MIDDLE);
    //tile->SetOrder(100000);
    //tile->SetPosition(10, 50);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) {
        menuWold->Update();
        menuWold->Render(framebuffer);
    }
    return 0;
}

 

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

7 hours ago, Josh said:

E for the font height, and it works fine. Problems may arise in the future for fonts that do not have this character.

Would not be some digit more reliable then? But i'm not if digits always have same height as upper letters tho.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...