Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Heinrich

#1
General Discussion / Re: libconfig & JSON
28 November 2014, 10:57:35
Quote from: texus on 27 November 2014, 08:33:35
I have though about XML, but I kindof see JSON as its successor.
XML requires you to open and close tags which means you have to write things twice.

I would choose the second or third opposed to the first one. The third one looks best here, but these key-value pairs like now are too limited.
<TextSize>5</TextSize>
"TextSize" : 5
TextSize = 5


While 2nd and 3rd are more human-readable, the question is if you would write them manually in the first place. If I wouldn't use the GUI builder, I'd do it programmatically in my .cpp files.
Hm. And file size shouldn't be a concern. If I were not to use xml I'd probably go for JSON  instead of the 3rd option, simply because libconfig uses ascii for strings which is undesirable if you do ButtonText = "MinButtøn".
#2
General Discussion / libconfig & JSON
26 November 2014, 22:24:22
Hello Bruno,

Have you given thought to using XML format?
I am extensively using custom XML config files myself and read and write them with tinyxml https://www.grinninglizard.com/tinyxml2/. It's fast and header-only.
However, tinyxml does not understand DTDs for validation. If you go for XML, check this helpful image:
https://i.stack.imgur.com/hUjpw.png

[spoiler]I still owe you that 0.7 tutorial, I'm a huge slacker
#3
General Discussion / Re: changing theme files
17 October 2014, 01:31:51
Quote from: texus on 16 October 2014, 17:58:39
Just in case you didn't know this yet: in v0.7 you don't need a separate file for every button. You can have multiple sections for buttons (or other widgets), just give them a name other than the default "Button" and pass the name as second parameter of the Button::create function.

I didn't. That's pretty handy.
#4
General Discussion / changing theme files
16 October 2014, 14:06:47
I read this on your blog
QuoteThinking about a new design...

// Load one theme that is shared between widgets
tgui::Theme theme{"Black.conf"};

// Create widgets based on that theme
auto button = tgui::Button::create(theme);

// Change the theme for all connected widgets on the fly
theme->changeProperty("Button", "TextColorNormal", "(200, 200, 200)");

Wow, this sounds good. What would happen if I create an element with a theme object and later I want to change a property on this element only? Reminds me a little of the setGlobalTextSize() issues.

A short user story how I use tgui:
I have several game states (startup, main menu, game lobby, game room, ..). No two states can be active at the same time. I share a global tgui::gui between all states. When a new state is transitioned into, all widgets get removed from the global tgui::gui and the specific state widgets get reloaded.
Each state has it's own gui elements and it's own theme.conf. On state creation I load everything with element::create("myState.conf") and hide() and show() and connect() accordingly. Then on some elements, I change properties via getRenderer() because I didn't want an extra theme.conf for a single Button. Sometimes gui elements need to be created dynamically. That is, when game objects offer to be configured. These objects have a tgui::Widget::Ptr getConfigWidget() interface and the state loops over the objects to get the widgets and add them to the tgui::gui.

#5
Help requests / Re: List of all signals
15 October 2014, 18:01:45
Quote from: texus on 15 October 2014, 17:48:43
It would be great if there were tutorials written by the tgui users :).

Sounds like something I could do.
The bug is really minor, I just thought I report it before I forget about it.
#6
Help requests / Re: List of all signals
15 October 2014, 17:46:55
BTW, I found a little bug. When a listbox is populated with items and you "drag an entry downward" over the last entry in the list. Like, you click on an entry and do not release the mouse button and then move the mouse cursor downward until you pass the last entry in the list. The Listbox must have set it's size large enough that there is some space displayed below the last entry. Then tgui crashes with some subscript out of range error.
If you have some spare time you may try to reproduce it. No signal needs to be connected for this.
#7
Help requests / Re: List of all signals
15 October 2014, 17:37:02
Quote from: texus on 15 October 2014, 15:34:14
There is no single list containing all signals.

Yes, I found it in ListBox.cpp, thats why I meant you should maybe compile a list for new users.
#8
Help requests / List of all signals
15 October 2014, 15:29:28
Where can I find one? I'm especially looking for something like "selected" in listbox.

Edit: I found where they are defined. Maybe you want to compile a list for your tutorial.
#9
Feature requests / Re: SetGlobalFontSize()
15 October 2014, 14:43:43
Quote from: texus on 15 October 2014, 14:14:44
But by the time you add a widget to its parent you could have already set a size manually and there is currently no way to detect that.

Well, you could do setGlobalDefaultTextSize(int size) which would simply set a default but not change anything and setGlobalTextSize(int size) which overwrites everything. But I do not want to mess your API up further.
#10
Feature requests / Re: SetGlobalFontSize()
15 October 2014, 14:21:38
Quote from: texus on 15 October 2014, 14:14:44
I can write such a getGuiTextSize function for you, but then you still have to apply it for every widget :).

:) Thanks, but I have such a function, the suggestion is for other users. You could put something like this internally into the widget creation code.

Myself, I will stick to mine anyway since I really do set this everytime in my code as I create a widget. Actually the function is static unsigned int Settings::getGuiTextSize(Globals::TXTSIZE size) // sizes are TXTSIZE::HEADING and so on. This is an artifact, it should rather be named LARGE, NORMAL SMALL. getGuiTextSize(Globals::TXTSIZE size = Globals::TXTSIZE::NORMAL), now that I think of it.
Be careful not to accidentally write an html renderer  ;D
#11
Feature requests / Re: SetGlobalFontSize()
15 October 2014, 14:07:57
Quote from: Heinrich on 15 October 2014, 13:11:34
Oftentimes my code looks like


widget = create();
widget->setTextSize(Globals::getGuiTextSize());



:P I understand why one would not to. Myself, I have a static class called settings where I store some global variables like fontSize, paths, videomode, audiovolume, etc
#12
Feature requests / Re: SetGlobalFontSize()
15 October 2014, 13:52:11
QuoteIt should be defined whether it adjusts widgets that are already created and/or widgets that are created later

A change should propagate to all widgets. Like so.

setGlobalFontSize(12);
widget a;  // (is size 12);
setGlobalFontSize(14);
widget b;  // (is size 14);

getSize(a) //14
getSize(b) //14

#13
Feature requests / Re: SetGlobalFontSize()
15 October 2014, 13:42:37
 :D While I'm at it; Currently text is centered inside a button by computing the center of it's axis-aligned bounding box.  Which is good. However, this bounding box depends on what glyphs you used, for example 'A's center is higher than 'j's center. The consequence is, that the base line of text does not align if you have words containing an Ascender(https://en.wikipedia.org/wiki/Ascender_%28typography%29)  and one that does not. Same for descenders. Image probably says more than words:

Note how "Hangar" has a glyph with a descender (the 'g') and "Join" has not. Vertically this looks correct most of the time (unless your word is long and contains a single Descender, then it looks as if it was too high in it's button)  because the text seems to be correctly centered. Horizontally it looks jumbled. Depending on the Font size this can be more or less noticeable. A solution would be to compute the center by using it's baseline glyphs only. I agree this is not an urgent issue.
#14
Feature requests / SetGlobalFontSize()
15 October 2014, 13:11:34
Oftentimes my code looks like


widget = create();
widget->setTextSize(Globals::getGuiTextSize());


Having it as a parameter in .conf files would also be an option. Well, this is for people who want the same font size in all their widgets anyway.

Also: Currently it is imho impossible to change the text size of entries in tgui::combobox. Even when I get the renderer for the widget. Also the sf::text is never exposed, so getting the text somehow and setting it there doesn't work either.

What do you think?
#15
Feature requests / Re: setTexture in Buttons
15 October 2014, 13:07:23
Alright, it compiles and works.
Some small bug I noticed in 0.6 already that still persists. Probably it's from sfml.