Stored dialog result into replay.
This commit is contained in:
parent
0c559fa49d
commit
b003c7e60e
1 changed files with 55 additions and 50 deletions
|
@ -284,61 +284,66 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
|
|||
[/filter]
|
||||
[lua]
|
||||
code=<<
|
||||
local helper = wesnoth.require "lua/helper.lua"
|
||||
local T = helper.set_wml_tag_metatable {}
|
||||
local _ = wesnoth.textdomain "wesnoth"
|
||||
local t = {
|
||||
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" }
|
||||
local result = wesnoth.synchronize_choice(function()
|
||||
local helper = wesnoth.require "lua/helper.lua"
|
||||
local T = helper.set_wml_tag_metatable {}
|
||||
local _ = wesnoth.textdomain "wesnoth"
|
||||
local dialog = {
|
||||
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" } }
|
||||
} }
|
||||
} },
|
||||
T.column { T.image { id = "the_image" } }
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
||||
local li = 0
|
||||
local function preshow()
|
||||
local t = { "Ancient Lich", "Ancient Wose", "Elvish Avenger" }
|
||||
local function select()
|
||||
local i = wesnoth.get_dialog_value "the_list"
|
||||
local ut = wesnoth.unit_types[t[i]].__cfg
|
||||
local profile = string.gsub(ut.profile, "([^/]+)$", "transparent/%1")
|
||||
if wesnoth.get_dialog_value "flip" then profile = profile .. "~FL()" end
|
||||
wesnoth.set_dialog_value(profile, "the_image")
|
||||
end
|
||||
wesnoth.set_dialog_callback(select, "the_list")
|
||||
wesnoth.set_dialog_callback(select, "flip")
|
||||
for i,v in ipairs(t) do
|
||||
local ut = wesnoth.unit_types[v].__cfg
|
||||
wesnoth.set_dialog_value(ut.name, "the_list", i, "the_label")
|
||||
wesnoth.set_dialog_value(ut.image, "the_list", i, "the_icon")
|
||||
end
|
||||
wesnoth.set_dialog_value(2, "the_list")
|
||||
select()
|
||||
wesnoth.set_dialog_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" }
|
||||
})
|
||||
end
|
||||
|
||||
local r = wesnoth.show_dialog(t, function()
|
||||
local t = { "Ancient Lich", "Ancient Wose", "Elvish Avenger" }
|
||||
local function select()
|
||||
local i = wesnoth.get_dialog_value "the_list"
|
||||
local ut = wesnoth.unit_types[t[i]].__cfg
|
||||
local profile = string.gsub(ut.profile, "([^/]+)$", "transparent/%1")
|
||||
if wesnoth.get_dialog_value "flip" then profile = profile .. "~FL()" end
|
||||
wesnoth.set_dialog_value(profile, "the_image")
|
||||
end
|
||||
wesnoth.set_dialog_callback(select, "the_list")
|
||||
wesnoth.set_dialog_callback(select, "flip")
|
||||
for i,v in ipairs(t) do
|
||||
local ut = wesnoth.unit_types[v].__cfg
|
||||
wesnoth.set_dialog_value(ut.name, "the_list", i, "the_label")
|
||||
wesnoth.set_dialog_value(ut.image, "the_list", i, "the_icon")
|
||||
end
|
||||
wesnoth.set_dialog_value(2, "the_list")
|
||||
select()
|
||||
wesnoth.set_dialog_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" }
|
||||
})
|
||||
end, function ()
|
||||
li = wesnoth.get_dialog_value "the_list"
|
||||
local li = 0
|
||||
local r = wesnoth.show_dialog(dialog, preshow, function ()
|
||||
li = wesnoth.get_dialog_value "the_list"
|
||||
end)
|
||||
return { button = r, list_item = li }
|
||||
end)
|
||||
|
||||
wesnoth.message(string.format("Button %d pressed. Item %d selected.", r, li))
|
||||
wesnoth.message(string.format("Button %d pressed. Item %d selected.",
|
||||
result.button, result.list_item))
|
||||
>>
|
||||
[/lua]
|
||||
[/event]
|
||||
|
|
Loading…
Add table
Reference in a new issue