wesnoth/data/campaigns/tutorial/lua/character_selection.lua
Subhraman Sarkar 0302dd8601 tutorial: UI improvements
uses portraits in the character selection and single click selection on pictures instead of buttons
also adds a dark background to hint messages to make them easier to read
adds arrow markers in the beginning on the units
2024-11-02 12:56:29 +05:30

49 lines
1.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- #textdomain wesnoth-tutorial
-- Allows the player to choose whether they want to play Konrad or Lisar
-- for the tutorial
local T = wml.tag
local wml_actions = wesnoth.wml_actions
local _ = wesnoth.textdomain "wesnoth-tutorial"
selected = 1
function pre_show(dialog)
local list = dialog:find("characters")
list.on_modified = function()
selected = list.selected_index
dialog:close()
end
end
function wml_actions.select_character()
local character_selection_dialog = wml.load "campaigns/tutorial/gui/character_selection.cfg"
local dialog_wml = wml.get_child(character_selection_dialog, 'resolution')
local result = wesnoth.sync.evaluate_single(function()
return { value = gui.show_dialog(dialog_wml, pre_show, function() end) }
end)
local unit = wml.variables.student_store
if selected == 2 then
wesnoth.units.to_map({
type = "Fighteress",
side = 1,
id = unit.id,
name = _"Lisar",
unrenamable = true,
profile = "portraits/lisar.webp",
canrecruit = true,
facing = unit.facing,
}, unit.x, unit.y )
wesnoth.sides[1].side_name = _"Lisar"
-- enable the help to display this unit's page
wesnoth.add_known_unit("Fighteress")
else
wesnoth.units.to_map(unit)
end
wesnoth.redraw {}
end