Tooltip text or extra buttons in WML UI for [message]

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Tooltip text or extra buttons in WML UI for [message]

Post by LordAwsomeness »

Hi! Just curious if there is/are any ways to customize the [message] UI in WML. I know you can do it in Lua but I'm still not quite able to understanding Lua's ins and outs on how to make it work.
I'm imagining something along the lines of Legends of the Invicibles UI that they made using Lua but maybe in WML form.
See below for example:
20201012_140749.jpg
I would like to know if you can add tooltips as well. Such as hovering over a button would give you a description (that the author could customize the Tooltip text). If anybody has any knowledge of this please let me know cause I'm scratching my head on the Lua version and I can't find anything like this in WML on the WML reference links.
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Tooltip text or extra buttons in WML UI for [message]

Post by Celtic_Minstrel »

I'm pretty sure the [message] dialog has no provision for custom tooltips, even if you use the Lua interface to it. A more complicated UI like you see in Legends of the Invincibles can only be done in Lua; though you can define the dialog's layout in WML, the functionality can only be implemented in Lua.

It would be possible to create a WML tag that does let you do some not-too-complicated things with custom dialogs in pure WML, mind you, but I don't know of anyone who did such a thing.

Tooltips are part of a dialog's definition, so if you're using a custom dialog, you can set them to whatever you want. The WML for defining a custom dialog is documented on the wiki. You can get a very basic custom dialog with any imaginable layout using the following WML:

Code: Select all

[lua]
	[args]
		[tooltip]
			id=tooltip # or id=tooltip_large
		[/tooltip]
		[helptip]
			id=tooltip
		[/helptip]
		# You can add [linked_group] tags here if you need them
		[grid]
			# Put the WML of your dialog definition here.
		[/grid]
	[/args]
	code=<<
		local dialog  = ...
		local result = wesnoth.show_dialog(dialog)
		wesnoth.set_variable("dialog_result", result)
	>>
[/lua]
If all you need is a fancy choice dialog, where you click a button and the dialog closes, then that code will be enough - it'll store the return value of the clicked button in the $dialog_result variable. If you need any more complicated functionality, however, you'll need to write some Lua code (in which case this should be moved to the Lua Labs forum).
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: Tooltip text or extra buttons in WML UI for [message]

Post by LordAwsomeness »

Celtic_Minstrel wrote: October 14th, 2020, 1:23 am If all you need is a fancy choice dialog, where you click a button and the dialog closes, then that code will be enough - it'll store the return value of the clicked button in the $dialog_result variable. If you need any more complicated functionality, however, you'll need to write some Lua code (in which case this should be moved to the Lua Labs forum).
Id basically wanna create the equivalent to a [while] [do] dialogue with choices. I want to create an inventory system that has equippable items and such. Ive already done a very in depth version of this in wml using the [message] tag, however i want to create something a bit more clean. Lua it is i guess :/

regarding the tooltips though, there wouldn't happen to be a way to use tooltips for the [option] tag is there?

Also where should i place the snippet you provided to get started? (the lua tag) Ive been working on placing lua in my code a little bit but i honestly dont know what the example circumstance of where i would insert that exact snippet and modify it should be.

EDIT: I just discovered the test_scenario.cfg actually has some interesting lua and how to implement it!
custom_dialogue.PNG
I am a little curious though regarding themes: Could I potentially change parts of the displayed theme such as villages captured to display something different such as variables inside of a unit like the unit's mana?
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Tooltip text or extra buttons in WML UI for [message]

Post by Celtic_Minstrel »

LordAwsomeness wrote: October 14th, 2020, 4:08 pm I just discovered the test_scenario.cfg actually has some interesting lua and how to implement it!
With a small change to the test_scenario example, you can also implement the dialog's layout in WML like I mentioned in my previous post. Basically you just need to replace the giant Lua definition of the dialog with the three lines in my example that grab the WMl-defined dialog from [args].
LordAwsomeness wrote: October 14th, 2020, 4:08 pm I am a little curious though regarding themes: Could I potentially change parts of the displayed theme such as villages captured to display something different such as variables inside of a unit like the unit's mana?
Are you talking about customizing the HUD that displays above and to the right of the map? That can be done, but uses an entirely separate system from custom dialogs.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: Tooltip text or extra buttons in WML UI for [message]

Post by LordAwsomeness »

EDIT: Idk how it posted copies several times in a row of the same message! Sorry!
Also the delete button isnt appearing for some reason
EDIT2: it allowed me to delete some but not the first message
Last edited by LordAwsomeness on October 15th, 2020, 4:25 am, edited 2 times in total.
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
User avatar
LordAwsomeness
Posts: 203
Joined: August 12th, 2013, 2:20 pm
Location: U.S.A.

Re: Tooltip text or extra buttons in WML UI for [message]

Post by LordAwsomeness »

Celtic_Minstrel wrote: October 15th, 2020, 12:48 am With a small change to the test_scenario example, you can also implement the dialog's layout in WML like I mentioned in my previous post. Basically you just need to replace the giant Lua definition of the dialog with the three lines in my example that grab the WMl-defined dialog from [args].
Sweet! Thanks!

Celtic_Minstrel wrote: October 15th, 2020, 12:48 am I am a little curious though regarding themes: Could I potentially change parts of the displayed theme such as villages captured to display something different such as variables inside of a unit like the unit's mana?
Are you talking about customizing the HUD that displays above and to the right of the map? That can be done, but uses an entirely separate system from custom dialogs.
I got a little side tracked :doh: :lol:
But yes!
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
white_haired_uncle
Posts: 1187
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Tooltip text or extra buttons in WML UI for [message]

Post by white_haired_uncle »

The Unit Information tab in LotI actually calls an event that uses a WML [message] to display various info about a given unit. I'd like to modify that to allow you to hover over things like a weapon's special and get a tooltip. My assumption is that I'd need to use a gui instead of message. This thread seems to indicate that this was so in 2020.

Before I get into such an effort, I just wanted to confirm this would still be necessary?

TIA
Speak softly, and carry Doombringer.
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Tooltip text or extra buttons in WML UI for [message]

Post by Celtic_Minstrel »

While adding a tooltip to [option] isn't a bad idea for a feature request, it's not supported right now.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply