Chatbox only displaying one line?
« on: 22 January 2014, 03:01:33 »
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.




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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Chatbox only displaying one line?
« Reply #1 on: 22 January 2014, 12:08:33 »
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.

Re: Chatbox only displaying one line?
« Reply #2 on: 22 January 2014, 12:32:02 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Chatbox only displaying one line?
« Reply #3 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.

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).

Re: Chatbox only displaying one line?
« Reply #4 on: 22 January 2014, 12:51:56 »
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

Re: Chatbox only displaying one line?
« Reply #5 on: 22 January 2014, 15:45:10 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Chatbox only displaying one line?
« Reply #6 on: 22 January 2014, 15:57:35 »
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.

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

Quote
Little 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.

Re: Chatbox only displaying one line?
« Reply #7 on: 22 January 2014, 21:01:44 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Chatbox only displaying one line?
« Reply #8 on: 01 February 2014, 16:13:30 »
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.
« Last Edit: 01 February 2014, 16:30:20 by texus »

Re: Chatbox only displaying one line?
« Reply #9 on: 01 February 2014, 16:55:18 »
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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Chatbox only displaying one line?
« Reply #10 on: 01 February 2014, 20:41:02 »
Quote
Feature 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.

Re: Chatbox only displaying one line?
« Reply #11 on: 01 February 2014, 21:03:28 »
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

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

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Chatbox only displaying one line?
« Reply #12 on: 02 February 2014, 00:24:13 »
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.

Re: Chatbox only displaying one line?
« Reply #13 on: 02 February 2014, 14:04:54 »
Nice to hear, and thanks for the quick addition of this feature  :D


AlexAUT