Chatbox only displaying one line?

Started by AlexAUT, 22 January 2014, 03:01:33

AlexAUT

First thanks for this great Gui  :).

To the problem:

I have created a simple form with the form_builder with a chatbox on it. Then I load the form into a panel and because the Form_builder doesn't support it, I add lines to the checkbox manually in the c++ code.



   tgui::ChatBox::Ptr chatbox = panel->get<tgui::ChatBox>("ChatBox1");

   chatbox->addLine("Developed by Alexander Weinrauch (AlexAUT).", sf::Color::White);
   chatbox->addLine("Laurent Gomila for SFML!", sf::Color::White);
   chatbox->addLine("fallahn for sfChat (Chat system)", sf::Color::White);
   chatbox->addLine("MafiaFLairBeatz for the music!", sf::Color::White);
   chatbox->addLine("Machinimasound for the music!", sf::Color::White);
   chatbox->addLine("Alexandre Bodelot", sf::Color::White);
   chatbox->addLine("Lukas Dürrenberger", sf::Color::White);



But only the first line gets rendered  :o? So isn't it implemented yet or did I a misstake?

(I have to add you to the list too  ;) )
AlexAUT

texus

I can't immediately reproduce this.
Could you send me the widgets file (the file created by the form builder) and a minimal code example?

The form builder is still far from being complete and some things just don't work like they should. It is possible to add the lines in the form builder, but it requires a specific syntax. You can always write a small c++ code and call gui.saveWidgetsToFile to see what the values of some properties should be.
If you would want to specify the lines directly in the form builder then you would have to set the Lines property to "(Line1\, (255\, 0\, 0)), (Line2\, (0\, 255\, 0)" (without the quotes). But I'm aware that is a pain to write it that way.

AlexAUT

Ok, here is a minimal example: https://pastebin.com/HARi0diB

The output from saveWidgetsToFile looks right. The line variable's content:
Lines = "(Test\,(0\,0\,0)),(Test2\,(0\,0\,0)),(ASFASF\,(0\,0\,0))"


But I can still only see the first line.



AlexAUT

texus

Strange. If I run your code on my pc, then everything looks fine. The only change I made was use the DejaVuSans.ttf which is provided in tgui.

I can't really do much now. I got an exam tomorrow and the day after tomorrow and two more next week.
But afterwards I'll definately look into this in more detail (check on windows with the libraries that I uploaded instead of just testing on linux with some unknown tgui version installed).

AlexAUT

Quote from: texus on 22 January 2014, 12:47:33
Strange. If I run your code on my pc, then everything looks fine. The only change I made was use the DejaVuSans.ttf which is provided in tgui.

With DejaVuSans it works  :o . Hmm I will test some more font files and report the results later :)


Thanks.

AlexAUT

AlexAUT

Ok ~15% of the fonts i tested (around 20) didn't work, would be interessting to know why  :) .

But anyways thanks for the great gui and good luck with you exam tomorrow!

Little spoiler ;)




AlexAUT

texus

Quote~15% of the fonts i tested (around 20) didn't work, would be interessting to know why  :)
Ok, I'll try to figure out if it has anything to do with tgui next week.

QuoteBut anyways thanks for the great gui and good luck with you exam tomorrow!
Thanks

QuoteLittle spoiler ;)
Looks good.
I played Kroniax some time ago when it was still new, I guess I should look at it again because a lot seems to have changed since then.

AlexAUT

Quote from: texus on 22 January 2014, 15:57:35
Looks good.
I played Kroniax some time ago when it was still new, I guess I should look at it again because a lot seems to have changed since then.

Yeah definitly, currently I'm refactoring the whole multiplayer mode and of course the gui  :) (tgui is working great)



AlexAUT

texus

#8
Quote~15% of the fonts i tested (around 20) didn't work, would be interessting to know why
The problem of these fonts are that their line spacing is too small. The sf::Font::getLineSpacing function returns a value smaller than the character size. Due to badly placed brackets and the use of unsigned ints, subtracting the character size from the line spacing ended up being a really huge number :).

The fix is easy, but another problem remains: the line spacing is too small. So with the current implementation the lines will overlap instead of being displayed below each other. I'll just put the lines below each other with an offset of e.g. 1/10th of its size, instead of using the line spacing returned by sfml.

Edit: Fixed in latest version on github.

AlexAUT

Makes sense to me  :) Thanks for your work to solve this "issue".

Currently I'm coding for the SFML game jam, but next week I will update tgui on my computer and test it.

Feature request: It would be nice if we could set the spacing between each line manually too.


AlexAUT

texus

QuoteFeature request: It would be nice if we could set the spacing between each line manually too.
I've been thinking about it and I don't think I will do this, it would hardly ever get used and I would have to add several functions to support setting a different line spacing for every line and for reusing the default spacing. Setting one line spacing for the whole chatbox is something that I would do, but it doesn't fit with the fact that you can set a different font and text size for every line.

There are other things that are hardcoded (e.g. the distance between the text and the side of the chatbox), so maybe if I ever allow customizing these small details then I will also allow the line spacing to be changed.

AlexAUT

Quote from: texus on 01 February 2014, 20:41:02
but it doesn't fit with the fact that you can set a different font and text size for every line.

Didn't know that this is possible. Nice

Quote from: texus on 01 February 2014, 20:41:02
Setting one line spacing for the whole chatbox is something that I would do

That is what i meant. Because currently it looks kinda ugly when different lines with the same font/charactersize have different space between.




AlexAUT

texus

I've added a setLineSpacing function which allows you to set the line spacings of all lines, no matter what font or text size it uses.

In the meantime I've also updated the addLine function so that you don't have to pass the color every time. You can now choose to make it use the default values (changeable with setTextSize, setTextColor and setTextFont) or to pass the values directly to the addLine function.

AlexAUT

Nice to hear, and thanks for the quick addition of this feature  :D


AlexAUT