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
This commit is contained in:
Subhraman Sarkar 2024-10-25 09:18:02 +05:30
parent 7fb0b8cdb3
commit 0302dd8601
5 changed files with 111 additions and 37 deletions

View File

@ -13,9 +13,9 @@
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
horizontal_alignment = "center"
[label]
definition = "title"
definition = "title_script"
label = _"Select Character"
[/label]
[/column]
@ -25,7 +25,7 @@
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
horizontal_alignment = "center"
[label]
label = _"Who do you want to play as?"
[/label]
@ -39,37 +39,88 @@
grow_factor = 1
border = "all"
border_size = 5
[image]
label = "units/konrad-fighter.png"
[/image]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
[image]
label = "units/human-princess.png~TC(1,magenta)"
[/image]
[/column]
[/row]
[row]
[column]
grow_factor = 1
border = "all"
border_size = 5
[button]
label = _"Konrad"
return_value = 1
[/button]
[/column]
[column]
grow_factor = 1
border = "all"
border_size = 5
[button]
label = _"Lisar"
return_value = 2
[/button]
[horizontal_listbox]
id = "characters"
has_minimum = false
[list_definition]
[row]
[column]
horizontal_grow = true
vertical_grow = true
[toggle_panel]
definition = "default"
return_value_id = "ok"
linked_group = "panel"
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_alignment = "center"
border = "all"
border_size = 5
[image]
id = "image"
definition = "default"
[/image]
[/column]
[/row]
[row]
grow_factor = 1
[column]
grow_factor = 0
border = "all"
border_size = 10
horizontal_grow = true
vertical_alignment = "top"
[label]
id = "name"
use_markup = true
text_alignment = "center"
[/label]
[/column]
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[list_data]
[row]
[column]
[widget]
id = "image"
label = "portraits/konrad.webp~SCALE(200,200)"
[/widget]
[widget]
id = "name"
label = "<span size='x-large' face='OldaniaAdfStd'>" + _"Konrad" + "</span>"
[/widget]
[/column]
[/row]
[row]
[column]
[widget]
id = "image"
label = "portraits/lisar.webp~SCALE(200,200)~FL()"
[/widget]
[widget]
id = "name"
label = "<span size='x-large' face='OldaniaAdfStd'>" + _"Lisar" + "</span>"
[/widget]
[/column]
[/row]
[/list_data]
[/horizontal_listbox]
[/column]
[/row]
[/grid]

View File

@ -7,17 +7,26 @@ 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) }
return { value = gui.show_dialog(dialog_wml, pre_show, function() end) }
end)
local character = result.value
local unit = wml.variables.student_store
if character == 2 then
if selected == 2 then
wesnoth.units.to_map({
type = "Fighteress",
side = 1,

View File

@ -14,6 +14,8 @@ function wesnoth.wml_actions.hint_message(cfg)
size = 18,
location = {5,5},
color = {255, 255, 255},
bgcolor = {0, 0, 0},
bgalpha = 85,
duration = "unlimited",
max_width = "40%",
valign = "top",

View File

@ -151,6 +151,7 @@
[select_character][/select_character]
{HIGHLIGHT_IMAGE $student_store.x $student_store.y "misc/unit-marker.png" ()}
{CLEAR_VARIABLE student_store}
{GENDER (
@ -376,6 +377,17 @@
) (
{PRINT ( _ "Move Lisar next to Delfador")}
)}
[store_unit]
[filter]
id=Delfador
[/filter]
variable=mentor
kill=no
[/store_unit]
{HIGHLIGHT_IMAGE $mentor.x $mentor.y "misc/unit-marker.png" ()}
{CLEAR_VARIABLE mentor}
[/event]
[event]

BIN
images/misc/unit-marker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB