Convert uses of deprecated GUI2 API
This covers everything: - SotA zombie dialog (was mostly converted already, just needed module name update) - The remaining minor World Conquest dialogs that had yet to be converted - Tutorial character select - Test scenario sample dialog This also replaces any uses of "callback" in favour of "on_xxx".
This commit is contained in:
parent
251e6c3f7a
commit
f57217f6c4
8 changed files with 31 additions and 31 deletions
|
@ -87,13 +87,13 @@ local function preshow(dialog)
|
|||
dialog.damage_type.label = "<span color='#a69275'> melee–" .. unit_type.attacks[1].type .. "</span>"
|
||||
end
|
||||
|
||||
dialog.unit_list.callback = select
|
||||
dialog.unit_list.on_modified = select
|
||||
|
||||
function dialog.help_button.callback()
|
||||
function dialog.help_button.on_button_click()
|
||||
W.open_help { topic="recruit_and_recall" }
|
||||
end
|
||||
|
||||
function dialog.unit_help_button.callback()
|
||||
function dialog.unit_help_button.on_button_click()
|
||||
W.open_help { topic="unit_" .. listedZombies[dialog.unit_list.selected_index] }
|
||||
end
|
||||
|
||||
|
@ -120,8 +120,8 @@ local function preshow(dialog)
|
|||
select()
|
||||
end
|
||||
|
||||
local function postshow()
|
||||
recruitedType = listedZombies[wesnoth.get_dialog_value "unit_list"]
|
||||
local function postshow(dialog)
|
||||
recruitedType = listedZombies[dialog.unit_list.selected_index]
|
||||
recruitCost = wesnoth.unit_types[ recruitedType ].cost
|
||||
end
|
||||
|
||||
|
@ -145,7 +145,7 @@ if zExists==false then
|
|||
gui.show_prompt("", _ "There are no corpses available.", "")
|
||||
else
|
||||
--TODO: this seems not to be synced.
|
||||
local returned = wesnoth.show_dialog(zombie_recruit_dialog, preshow, postshow)
|
||||
local returned = gui.show_dialog(zombie_recruit_dialog, preshow, postshow)
|
||||
if returned ~= -2 and sides[1].gold < recruitCost then
|
||||
gui.show_prompt("", _ "You do not have enough gold to recruit that unit", "")
|
||||
elseif returned ~= -2 and (sides[1].gold ) >= recruitCost then
|
||||
|
|
|
@ -165,7 +165,7 @@ function wc2_show_invest_dialog_impl(args)
|
|||
res = selected_data.res
|
||||
end
|
||||
end
|
||||
local d_res = wesnoth.show_dialog(dialog_wml, preshow)
|
||||
local d_res = gui.show_dialog(dialog_wml, preshow)
|
||||
return d_res, res
|
||||
end
|
||||
|
||||
|
|
|
@ -61,12 +61,12 @@ function invest_tellunit.execute(unit_type)
|
|||
if not wesnoth.sides[wesnoth.current.side].is_local then
|
||||
return
|
||||
end
|
||||
local function preshow()
|
||||
wesnoth.set_dialog_value(wc2_color.tc_image(unit_type.image), "icon")
|
||||
wesnoth.set_dialog_value(unit_type.name, "name")
|
||||
local function preshow(dialog)
|
||||
dialog.icon.label = wc2_color.tc_image(unit_type.image)
|
||||
dialog.name.label = unit_type.name
|
||||
end
|
||||
|
||||
wesnoth.show_dialog(invest_tellunit.dialog_wml, preshow)
|
||||
gui.show_dialog(invest_tellunit.dialog_wml, preshow)
|
||||
end
|
||||
|
||||
return invest_tellunit
|
||||
|
|
|
@ -83,7 +83,7 @@ local function show_dialog(unit, item_image)
|
|||
dialog.item_icon.label = item_image
|
||||
dialog.res_yes:focus()
|
||||
end
|
||||
local res = wesnoth.show_dialog(dialog_wml, preshow)
|
||||
local res = gui.show_dialog(dialog_wml, preshow)
|
||||
return res == 1 or res == -1
|
||||
end
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ function wesnoth.wml_actions.wc2_show_wocopedia(cfg)
|
|||
page.label_version.marked_up_text = wml.variables["wc2_host_version"] or "unknown"
|
||||
page.label_difficulty.marked_up_text = wml.variables["wc2_difficulty.name"] or "unknown"
|
||||
|
||||
function page.checkbox_show_pickup_confirmation.callback()
|
||||
function page.checkbox_show_pickup_confirmation.on_modified()
|
||||
wc2_utils.global_vars.skip_pickup_dialog = not page.checkbox_show_pickup_confirmation.selected
|
||||
end
|
||||
end
|
||||
|
@ -234,7 +234,7 @@ function wesnoth.wml_actions.wc2_show_wocopedia(cfg)
|
|||
|
||||
root_node:focus()
|
||||
|
||||
function root_node.callback()
|
||||
function root_node.on_modified()
|
||||
local selected_index = index_map[table.concat(root_node.selected_item_path, '_')]
|
||||
if selected_index ~= nil then
|
||||
details.selected_index = selected_index
|
||||
|
@ -242,7 +242,7 @@ function wesnoth.wml_actions.wc2_show_wocopedia(cfg)
|
|||
end
|
||||
end
|
||||
|
||||
wesnoth.show_dialog(dialog, preshow)
|
||||
gui.show_dialog(dialog, preshow)
|
||||
end
|
||||
|
||||
wc2_utils.menu_item {
|
||||
|
|
|
@ -280,8 +280,8 @@ function wc2_debug_settings(nplayers)
|
|||
|
||||
sl_scenario.value = globals.settings.scenario_num or 1
|
||||
sl_map.value = globals.settings.map_num or 1
|
||||
sl_scenario.callback = on_set_scenario
|
||||
sl_map.callback = on_set_map
|
||||
sl_scenario.on_modified = on_set_scenario
|
||||
sl_map.on_modified = on_set_map
|
||||
|
||||
on_set_map()
|
||||
end
|
||||
|
@ -299,5 +299,5 @@ function wc2_debug_settings(nplayers)
|
|||
globals.settings.ncastles = window.sl_ncastles.value
|
||||
|
||||
end
|
||||
wesnoth.show_dialog(dialog_wml, preshow, postshow)
|
||||
gui.show_dialog(dialog_wml, preshow, postshow)
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ function wml_actions.select_character()
|
|||
}
|
||||
}
|
||||
|
||||
local character = wesnoth.show_dialog(character_selection_dialog)
|
||||
local character = gui.show_dialog(character_selection_dialog)
|
||||
local unit = wml.variables.student_store
|
||||
|
||||
if character == 2 then
|
||||
|
|
|
@ -1261,32 +1261,32 @@ local result = wesnoth.synchronize_choice(function()
|
|||
} }
|
||||
}
|
||||
|
||||
local function preshow()
|
||||
local function preshow(dialog)
|
||||
local function select()
|
||||
local i = wesnoth.get_dialog_value "the_list"
|
||||
local i = dialog.the_list.selected_index
|
||||
local ut = wesnoth.unit_types[types[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")
|
||||
if dialog.flip.selected_index == 1 then profile = profile .. "~FL()" end
|
||||
dialog.the_image.label = profile
|
||||
end
|
||||
wesnoth.set_dialog_callback(select, "the_list")
|
||||
wesnoth.set_dialog_callback(select, "flip")
|
||||
dialog.the_list.on_modified = select
|
||||
dialog.flip.on_modified = select
|
||||
for i,v in ipairs(types) 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")
|
||||
dialog:find("the_list", i, "the_label").label = ut.name
|
||||
dialog:find("the_list", i, "the_icon").label = ut.image
|
||||
end
|
||||
wesnoth.set_dialog_value(2, "the_list")
|
||||
dialog.the_list.selected_index = 2
|
||||
select()
|
||||
wesnoth.set_dialog_canvas(2, {
|
||||
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" }
|
||||
})
|
||||
end
|
||||
|
||||
local li = 0
|
||||
local r = wesnoth.show_dialog(dialog, preshow, function ()
|
||||
li = wesnoth.get_dialog_value "the_list"
|
||||
local r = gui.show_dialog(dialog, preshow, function(dialog)
|
||||
li = dialog.the_list.selected_index
|
||||
end)
|
||||
return { button = r, list_item = li }
|
||||
end, function()
|
||||
|
|
Loading…
Add table
Reference in a new issue