SotA: Convert zombie recruit dialog to WML

This commit is contained in:
Celtic Minstrel 2021-03-31 14:02:29 -04:00
parent 690e8f0193
commit 726b5458f9
2 changed files with 357 additions and 63 deletions

View file

@ -0,0 +1,355 @@
#textdomain wesnoth-sota
# Since this file is loaded standalone, we need to manually include these
{gui/macros}
#define UNIT_ROW
[row]
[column]
grow_factor=0
border="right"
border_size=5
horizontal_alignment = "left"
[image]
id = "unit_sprite"
[/image]
[/column]
[column]
grow_factor=0
border="right"
border_size=10
[grid]
[row]
[column]
[grid]
[row]
[column]
[label]
definition = "default"
use_markup = "true"
id = "unit_type"
[/label]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
border="top"
border_size=7
horizontal_alignment = "left"
[grid]
[row]
[column]
border="right"
border_size=6
[image]
label = "themes/gold.png"
[/image]
[/column]
[column]
[label]
definition = "default"
use_markup = "true"
id = "unit_cost"
[/label]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/column]
[column]
grow_factor=1
[spacer]
[/spacer]
[/column]
[/row]
#enddef
# There is a panel definition that does this, but it's more complicated than
# this grid; several of these fields can have constant values.
#define INFO_GRID
[grid]
[row]
[column]
border = "top,bottom"
border_size = 10
horizontal_alignment="left"
horizontal_grow=true
[image]
id = "large_unit_sprite"
[/image]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 5
horizontal_alignment="left"
horizontal_grow=true
[label]
use_markup = "true"
id = "large_unit_type"
[/label]
[/column]
[/row]
[row]
[column]
[grid]
[row]
[column]
border = "right"
border_size = 10
[label]
definition = "default_bold"
label= _ "Lvl 0"
[/label]
[/column]
[column]
border = "right"
border_size = 5
[image]
label = "../../images/icons/alignments/alignment_chaotic_30.png"
[/image]
[/column]
[column]
border = "right"
border_size = 5
[image]
label = "../../images/icons/unit-groups/race_undead_30.png"
[/image]
[/column]
[column]
border = "right"
border_size = 35
[label]
definition="default_small"
label= _ "Undead"
[/label]
[/column]
[column]
border = "right"
border_size = 17
[button]
definition="action_about"
id="unit_help_button"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 6
[spacer]
[/spacer]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 12
horizontal_grow = true
[label]
definition = "default_tiny"
use_markup = "true"
id="unit_points"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 2
horizontal_alignment = "left"
[label]
definition ="default_small"
use_markup = "true"
label = "<b>" .. _ "Traits" .. "</b>"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 2
horizontal_alignment = "left"
[label]
definition = "default_small"
label = " undead"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 12
horizontal_alignment = "left"
[label]
definition = "default_small"
label = " fearless"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 2
horizontal_alignment = "left"
[label]
definition = "default_small"
use_markup = "true"
label = "<b>" .. _ "Attacks" .. "</b>"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 2
horizontal_alignment = "left"
horizontal_grow = true
[label]
definition = "default_small"
use_markup = "true"
id = "unit_attack"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 2
horizontal_alignment = "left"
horizontal_grow = true
[label]
definition = "default_small"
use_markup = "true"
id = "damage_type"
[/label]
[/column]
[/row]
[row]
[column]
horizontal_alignment = "left"
[label]
definition="default_small"
use_markup = "true"
label = "<span color='#a69275'> plague</span>"
[/label]
[/column]
[/row]
[row]
[column]
border = "bottom"
border_size = 100
[spacer]
[/spacer]
[/column]
[/row]
[/grid]
#enddef
[resolution]
maximum_height=676
minimum_height=608
[tooltip]
id = "tooltip_large"
[/tooltip]
[helptip]
id = "tooltip_large"
[/helptip]
[grid]
[row]
[column]
border = "left,top"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "title"
label = _ "Choose a Corpse"
[/label]
[/column]
[column]
[spacer]
[/spacer]
[/column]
[/row]
[row]
[column]
border = "left"
border_size = 5
vertical_alignment="top"
{INFO_GRID}
[/column]
[column]
border = "right,top"
border_size = 5
vertical_alignment = "top"
[grid]
[row]
[column]
horizontal_grow = true
[listbox]
scrollbar="manditory"
vertical_scrollbar_mode="initial_auto"
id = "unit_list"
[list_definition]
[row]
[column]
horizontal_grow=true
[toggle_panel]
return_value = -1
[grid]
{UNIT_ROW}
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
[column]
border = "left, top, bottom"
border_size = 7
horizontal_alignment="left"
[button]
id="help_button"
definition="help"
[/button]
[/column]
[column]
border = "left, top, bottom"
border_size = 7
[grid]
[row]
[column]
border_size=10
border="right"
[button]
return_value = 1
label = _"Recruit"
[/button]
[/column]
[column]
[button]
id = "cancel"
label = _"Cancel"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/resolution]

View file

@ -12,68 +12,7 @@ local recruitCost
local zombies = wml.array_access.get("zombies")
local sides = wesnoth.sides.find()
local unit_row = T.row {
T.column { grow_factor=0, border="right", border_size=5, horizontal_alignment = "left", T.image { id = "unit_sprite" } },
T.column { grow_factor=0, border="right", border_size=10, T.grid {
T.row { T.column { T.grid { T.row { T.column { T.label { definition = "default", use_markup = "true", id = "unit_type" } } } } } },
T.row { T.column { border="top", border_size=7, horizontal_alignment = "left", T.grid { T.row {
T.column {border="right", border_size=6, T.image { label = "themes/gold.png" } },
T.column { T.label { definition = "default", use_markup = "true", id = "unit_cost"} }
} } } }
} },
T.column { grow_factor=1, T.spacer {} }
}
-- There is a panel definition that does this, but it's more complicated than
-- this grid; several of these fields can have constant values.
local info_grid = T.grid {
T.row { T.column { border = "top,bottom", border_size = 10, horizontal_alignment="left", horizontal_grow=true, T.image { id = "large_unit_sprite" } } },
T.row { T.column { border = "bottom", border_size = 5, horizontal_alignment="left", horizontal_grow=true, T.label { use_markup = "true", id = "large_unit_type" } } },
T.row { T.column { T.grid { T.row {
T.column { border = "right", border_size = 10, T.label { definition = "default_bold", label= _ "Lvl 0" } },
T.column { border = "right", border_size = 5, T.image { label = "../../images/icons/alignments/alignment_chaotic_30.png" } },
T.column { border = "right", border_size = 5, T.image { label = "../../images/icons/unit-groups/race_undead_30.png" } },
T.column { border = "right", border_size = 35, T.label { definition="default_small", label= _ "Undead" } },
T.column { border = "right", border_size = 17, T.button { definition="action_about", id="unit_help_button" } }
} } } },
T.row { T.column { border = "bottom", border_size = 6, T.spacer { } } },
T.row { T.column { border = "bottom", border_size = 12, horizontal_grow = true, T.label { definition = "default_tiny", use_markup = "true", id="unit_points" } } },
T.row { T.column { border = "bottom", border_size = 2, horizontal_alignment = "left", T.label { definition ="default_small", use_markup = "true", label = "<b>" .. _ "Traits" .. "</b>" } } },
T.row { T.column { border = "bottom", border_size = 2, horizontal_alignment = "left", T.label { definition = "default_small", label = " undead" } } },
T.row { T.column { border = "bottom", border_size = 12, horizontal_alignment = "left", T.label { definition = "default_small", label = " fearless" } } },
T.row { T.column { border = "bottom", border_size = 2, horizontal_alignment = "left", T.label { definition = "default_small", use_markup = "true", label = "<b>" .. _ "Attacks" .. "</b>" } } },
T.row { T.column { border = "bottom", border_size = 2, horizontal_alignment = "left", horizontal_grow = true, T.label { definition = "default_small", use_markup = "true", id = "unit_attack" } } },
T.row { T.column { border = "bottom", border_size = 2, horizontal_alignment = "left", horizontal_grow = true, T.label { definition = "default_small", use_markup = "true", id = "damage_type" } } },
T.row { T.column { horizontal_alignment = "left", T.label { definition="default_small", use_markup = "true", label = "<span color='#a69275'> plague</span>" } } },
T.row { T.column { border = "bottom", border_size = 100, T.spacer { } } }
}
local zombie_recruit_dialog = { maximum_height=676, minimum_height=608,
T.tooltip { id = "tooltip_large" },
T.helptip { id = "tooltip_large" },
T.grid {
T.row {
T.column { border = "left,top", border_size = 5, horizontal_alignment = "left", T.label { definition = "title", label = _ "Choose a Corpse" } },
T.column { T.spacer {} },
},
T.row {
T.column { border = "left", border_size = 5, vertical_alignment="top", info_grid },
T.column { border = "right,top", border_size = 5, vertical_alignment = "top", T.grid {
T.row { T.column { horizontal_grow = true, T.listbox { scrollbar="manditory", vertical_scrollbar_mode="initial_auto", id = "unit_list",
T.list_definition { T.row { T.column { horizontal_grow=true, T.toggle_panel { return_value = -1, T.grid { unit_row } }
} } }
} } }
} }
},
T.row {
T.column { border = "left, top, bottom", border_size = 7, horizontal_alignment="left", T.button { id="help_button", definition="help" } },
T.column { border = "left, top, bottom", border_size = 7, T.grid { T.row {
T.column { border_size=10, border="right", T.button { return_value = 1, label = _"Recruit" } },
T.column { T.button { id = "cancel", label = _"Cancel" } }
} } }
}
}
}
local zombie_recruit_dialog = wml.load "campaigns/Secrets_of_the_Ancients/gui/zombie_recruit_dialog.cfg"
local function preshow(dialog)
@ -150,7 +89,7 @@ if zExists==false then
gui.show_prompt("", _ "There are no corpses available.", "")
else
--TODO: this seems not to be synced.
local returned = gui.show_dialog(zombie_recruit_dialog, preshow, postshow)
local returned = gui.show_dialog(wml.get_child(zombie_recruit_dialog, 'resolution'), 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