[interface] Allow [option] to specify the [message]'s image

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
Post Reply
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

[interface] Allow [option] to specify the [message]'s image

Post by WhiteWolf »

Hello,

I've had this idea for a while, and I can't find a way to do it in wml yet. If it can be done somehow in Lua, please tell me how :D
The point would be to allow an object tag within a message to change the main image displayed with [message]. I'm not thinking of the little image inside the option, which is set with MENU_IMG_TXT or with the new DescriptionWML, but the large main image, usually for portraits.
Example:
Since the image key is taken, it could have a syntax like message_image=...
The key would not be mandatory, if omitted, the image specified in [message] is shown.

Code: Select all


[message]
speaker = someone
image = default.png
message = _ "something"
[option]
message = "Option 1"
message_image = image_for_option_1.png
[command]
[/command]
[/option]

[option]
message = "Option 2"
message_image = image_for_option_2.png
[command]
[/command]
[/option]

[option]
message = "Option 3"
# Option 3 has no image, so default.png is shown when this is option highlighted
[command]
[/command]
[/option]


The main advantage would be embellishments, and it could prove useful for mainline campaigns, where characters already have several portraits for their moods and expressions. When a choice is offered, the portrait could be fine-tuned to the option, like angry choice - mad profile, reasonable choice - some moderate profile.

Any ways to do this in Lua, or is not too much work to implement it to WML?
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Heindal
Posts: 1355
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: [interface] Allow [option] to specify the [message]'s im

Post by Heindal »

You can do this with a macro, so you can do it in "wml" without using lua.

Code: Select all

#define MACRONAME messagetext1 picture1 messagetext2 picture2 messagetext3 picture3

#place an if clause of something else here

                            [message]
                                image={picture1}
                                speaker=narrator
                                message= _ "{messagetext1}"
                            [/message]

#end the if clause


#place an if clause of something else here

                            [message]
                                image={picture2}
                                speaker=narrator
                                message= _ "{messagetext2}"
                            [/message]
#end the if clause

#place an if clause of something else here
                            [message]
                                image={picture3}
                                speaker=narrator
                                message= _ "{messagetext3}"
                            [/message]
#end the if clause

#enddef

Edit: you do it even more charming by just giving specific variables a value, without a macro

Code: Select all

#if clause when selected an option
                    [set_variable]
                        name=textvariable
                        value="The text for the option!"
                    [/set_variable]

                    [set_variable]
                        name=picturevariable
                        value=picturepath
                    [/set_variable]

#end if clause when selected an option

                            [message]
                                image=$picturepath
                                speaker=narrator
                                message= _ "$textvariable"
                            [/message]
Last edited by Heindal on March 30th, 2017, 9:01 pm, edited 1 time in total.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: [interface] Allow [option] to specify the [message]'s im

Post by zookeeper »

Heindal wrote:You can do this with a macro, so you can do it in "wml" without using lua.
No, that's not what he wants. He wants the image to change depending on which option is currently selected, but not yet chosen.
User avatar
Heindal
Posts: 1355
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: [interface] Allow [option] to specify the [message]'s im

Post by Heindal »

Ah ok got it. That's lua indeed.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: [interface] Allow [option] to specify the [message]'s im

Post by gfgtdf »

yes it can be done with lua, not with [message] but with creating your own custom dialogs with callbacks with the wesnoth.show_dialog function.

I personally think that wesnoth.show_dialog is one of the most advanced lua features wesnoth has. It might have changed quite a bit since i started creating wesnoth addons but when i started writing my first addons (i think it was wesnoth 1.11.2), in particular 'scenario with robots', i found it quite hard to use, secially since it was rather undocumented and had a high chance to crash wensoth when invalid parameters were given.

Also in order to not get OOS you have to know how to use wensoth.sync_choice().
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [interface] Allow [option] to specify the [message]'s im

Post by WhiteWolf »

Unfortunately, I do not know anything about Lua, only that it exists. But I'm willing to learn, so I might try to do this as my first lua code...
It'd still be nice to have it accessible in WML :)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: [interface] Allow [option] to specify the [message]'s im

Post by zookeeper »

gfgtdf wrote:yes it can be done with lua, not with [message] but with creating your own custom dialogs with callbacks with the wesnoth.show_dialog function.
Wouldn't that be ridiculously complicated (in relation to the functionality it accomplishes)?
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: [interface] Allow [option] to specify the [message]'s im

Post by gfgtdf »

zookeeper wrote:
gfgtdf wrote:yes it can be done with lua, not with [message] but with creating your own custom dialogs with callbacks with the wesnoth.show_dialog function.
Wouldn't that be ridiculously complicated (in relation to the functionality it accomplishes)?
well for someone who has no expeirince with wesnoth lua dialogs, sure.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Celtic_Minstrel
Developer
Posts: 2207
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: [interface] Allow [option] to specify the [message]'s im

Post by Celtic_Minstrel »

This sounds like an interesting idea, and would not be too difficult to implement into the engine...
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: [interface] Allow [option] to specify the [message]'s im

Post by WhiteWolf »

Well, I for one would like to see it become a feature some day :)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Post Reply