GUI2 custom dialog questions

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

GUI2 custom dialog questions

Post by Exasperation »

I'm working on using wesnoth.show_dialog to create a custom dialog in 1.9.0, and I've run into a stumbling block. I need to color the text in a label widget. Using the old dialog, I just applied Pango to the string, but the label doesn't process the markup by default. As far as I can tell, it should be possible to override the behavior of the widget to do one of a) processing the markup or b) just using a manually defined color by using wesnoth.set_dialog_canvas.

The documentation in the wiki is, however, somewhat sparse, and I haven't been able to figure out the right set of arguments to pass to the function. I know what the path to the widget is, and I've figured out that the only valid values for the canvas index are 1 and 2, but I can't figure out what to put in the WML table to make it work. So far, everything I've tried results in no visible change if the canvas index is 2, and making the text invisible (I guess it disables the widget?) if the canvas index is 1.
Last edited by Exasperation on April 30th, 2011, 10:16 pm, edited 1 time in total.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: colored label widgets in custom dialogs

Post by Anonymissimus »

(no answers in this post)
1. Whenever I pass an apparently wrong table describing the dialog, wesnoth 1.9.0+svn freezes.
2. Could we get a or some much more simpler examples than the one in the wiki (which is almost the same like the one from the testscenario), to show the relation between graphical appearance and the table ?
3. simple definition of "widget" ? I've already looked it up at wikipedia.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: colored label widgets in custom dialogs

Post by Sapient »

http://en.wikipedia.org/wiki/GUI_widget

For the other questions, you might want to check with Mordante a.k.a. SkeletonCrew.

I'm not really an expert on the new features.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: colored label widgets in custom dialogs

Post by Exasperation »

I got b) working, so no need to answer my question.
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: colored label widgets in custom dialogs

Post by silene »

Anonymissimus wrote:1. Whenever I pass an apparently wrong table describing the dialog, wesnoth 1.9.0+svn freezes.
Yes, that's an unfortunate feature of the GUI engine. Assertions were used, not to check the internal consistency of data, but to validate external values. So, expect the engine to constantly crash while trying to write the correct WML containers. I have already replaced the assertions I experienced, but I'm sure there are still lots of them. So please report them and I will fix them.

Note that it isn't specially difficult to fix them. So you may also try to do it on your side too, as it will considerably ease your WML development. See the following patches for instances of how to convert failed assertions into proper errors.
http://svn.gna.org/viewcvs/wesnoth/trun ... uilder.cpp
http://svn.gna.org/viewcvs/wesnoth/trun ... erator.cpp
Anonymissimus wrote:2. Could we get a or some much more simpler examples than the one in the wiki (which is almost the same like the one from the testscenario), to show the relation between graphical appearance and the table ?
Do you have some examples in mind?
As far as I'm concerned, I learned the syntax by reading the .cfg files in data/gui/default.
Anonymissimus wrote:3. simple definition of "widget" ? I've already looked it up at wikipedia.
I don't understand your question. If you looked it up in Wikipedia, you already know that it means "window gadget". (I didn't check, I hope that's the definition Wikipedia gives.) Is there something missing? Or do you mean that the Wesnoth documentation should remind this definition too?
Exasperation wrote:I got b) working, so no need to answer my question.
Ouch, I didn't expect one to have to go as far as overwriting the canvas to simply get Pango markup inside a label. I somehow hope there exists a simpler way.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: colored label widgets in custom dialogs

Post by Anonymissimus »

@Exasperation
Could you please post whatever you got working ? ;)

For anyone checking this out, expect crashes and such since the engine gui code is (not yet) very stable. And when the engine seems to freeze when it should show the dialog, press enter or esc on the keyboard so you don't need to shut down wesnoth.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: colored label widgets in custom dialogs

Post by Exasperation »

Sure. It's in ATBX, so you can get the most recent version off the 1.9.0 add-on server, but the specific function that calls show_dialog is as follows (spoilered for length):
Spoiler:
Not sure how much help it's going to be - it's pretty messy (a lot of trial and error involved in getting it working, and I didn't want to risk breaking it by trying to clean it up too much).
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

GUI2 custom dialog questions

Post by Exasperation »

So, I got back to work on this, and decided to start by downloading 1.9.5 and updating the era to work with it. My custom dialog now throws the following error (although it still works for the moment): "<Invalid WML found> Window builder: parsing resolution tip with empty 'id' field. Will become mandatory in 1.9.7."

Unfortunately, I can't find (or at least have been unable to recognize) any related parts of the GUI2 documentation. Any ideas?
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: GUI2 custom dialog questions

Post by Anonymissimus »

Dude -
1. Our lua expert (silene) decided to go away so we're on our own.
2. Thus you may be currently the one who knows most about lua dialog coding (I did shy away from it ever. ;))
3. mordante can possibly tell you about that error, but you need to ask him in IRC.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
Elvish_Hunter
Posts: 1576
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: GUI2 custom dialog questions

Post by Elvish_Hunter »

Anonymissimus wrote:2. Thus you may be currently the one who knows most about lua dialog coding (I did shy away from it ever. ;))
The very same thing applies for me. :mrgreen: Perhaps we need a tutorial page that explains in a simple way how to make dialogs with Lua. For example, on Python I'm currently using Tkinter with ttk; and I was able to get started because I found this tutorial that teached me how to think in Tkinter (although I used the Italian translation).
Following this example, a wiki page explaining dialogs with Lua should start with some simple dialogs (like placing a button, a text entry, and how to position them), and end with something more complex. Anyone up for the challenge?
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: GUI2 custom dialog questions

Post by Exasperation »

Victory is mine! In addition to a [grid] child, the dialog box table now also requires a [tooltip] child and a [helptip] child. I'm off to edit the relevant WML reference entry.
Post Reply