Define the sample dialog in the test scenario in WML instead of in Lua

I thought it would be nice to have at least one piece of example code that does this.

It also serves as a test to ensure that this technique actually works.
This commit is contained in:
Celtic Minstrel 2020-09-26 23:47:16 -04:00 committed by Celtic Minstrel
parent b3033ee0bd
commit bb5929dc69

View file

@ -1229,38 +1229,93 @@ Adjacent own units of lower level will do more damage in battle. When a unit adj
x,y=14,7
[/filter]
[lua]
[args]
[helptip]
id=helptip_large
[/helptip]
[tooltip]
id=tooltip_large
[/tooltip]
[grid]
[row]
[column]
[grid]
[row]
[column]
horizontal_grow=true
[listbox]
id=the_list
[list_definition]
[row]
[column]
horizontal_grow=true
[toggle_panel]
[grid]
[row]
[column]
horizontal_alignment=left
[label]
id=the_label
[/label]
[/column]
[column]
[image]
id=the_icon
[/image]
[/column]
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[row]
[column]
[grid]
[row]
[column]
[button]
id=ok
label=OK
[/button]
[/column]
[column]
[button]
id=cancel
label=Cancel
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
[toggle_button]
id=flip
label=Flip
[/toggle_button]
[/column]
[/row]
[/grid]
[/column]
[column]
[image]
id=the_image
[/image]
[/column]
[/row]
[/grid]
[/args]
code=<<
local types = { "Ancient Lich", "Ancient Wose", "Elvish Avenger" }
local dialog = ...
local result = wesnoth.synchronize_choice(function()
-- Human choice
local T = wml.tag
local _ = wesnoth.textdomain "wesnoth"
local dialog = {
T.helptip { id = "helptip_large" },
T.tooltip { id = "tooltip_large" },
T.grid { T.row {
T.column { T.grid {
T.row { T.column { horizontal_grow = true, T.listbox { id = "the_list",
T.list_definition { T.row { T.column { horizontal_grow = true,
T.toggle_panel { T.grid { T.row {
T.column { horizontal_alignment = "left", T.label { id = "the_label" } },
T.column { T.image { id = "the_icon" } }
} } }
} } }
} } },
T.row { T.column { T.grid { T.row {
T.column { T.button { id = "ok", label = _"OK" } },
T.column { T.button { id = "cancel", label = _"Cancel" } }
} } } },
T.row { T.column {
T.toggle_button { id = "flip", label = "Flip" }
} }
} },
T.column { T.image { id = "the_image" } }
} }
}
local function preshow(dialog)
local function select()
local i = dialog.the_list.selected_index
@ -1279,8 +1334,8 @@ local result = wesnoth.synchronize_choice(function()
dialog.the_list.selected_index = 2
select()
dialog:set_canvas(2, {
T.rectangle { x = 20, y = 20, w = 20, h = 20, fill_color= "0,0,255,255" },
T.rectangle { x = 30, y = 30, w = 20, h = 20, fill_color = "255,0,0,255" }
wml.tag.rectangle { x = 20, y = 20, w = 20, h = 20, fill_color= "0,0,255,255" },
wml.tag.rectangle { x = 30, y = 30, w = 20, h = 20, fill_color = "255,0,0,255" }
})
end