pick_advance: Load dialog from separate file so it can be validated
This commit is contained in:
parent
69ba3e0273
commit
db0ee9f02c
2 changed files with 155 additions and 142 deletions
|
@ -20,147 +20,9 @@ function pickadvance.show_dialog_unsynchronized(advance_info, unit)
|
|||
local game_override_one = (advance_info.game_override or {})[2] == nil
|
||||
and (advance_info.game_override or {})[1] or nil
|
||||
|
||||
local description_row = T.row {
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
horizontal_alignment = "left",
|
||||
T.label {
|
||||
definition = "title",
|
||||
label = _ "Plan Advancement"
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
local list_row_definition = T.grid {
|
||||
T.row {
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
grow_factor = 0,
|
||||
horizontal_alignment = "left",
|
||||
T.image {
|
||||
id = "the_icon",
|
||||
linked_group = "image"
|
||||
}
|
||||
},
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
grow_factor = 1,
|
||||
horizontal_alignment = "left",
|
||||
T.label {
|
||||
use_markup = true,
|
||||
id = "the_label",
|
||||
linked_group = "type"
|
||||
}
|
||||
},
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
horizontal_alignment = "center",
|
||||
vertical_alignment = "center",
|
||||
T.image {
|
||||
id = "global_icon",
|
||||
linked_group = "global_icon",
|
||||
label = "icons/action/editor-tool-unit_30-pressed.png",
|
||||
tooltip = _ "This advancement is currently the default for all units of the same type"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local listbox = T.listbox {
|
||||
id = "the_list",
|
||||
has_minimum = true,
|
||||
T.list_definition {
|
||||
T.row {
|
||||
T.column {
|
||||
horizontal_grow = true,
|
||||
vertical_grow = true,
|
||||
T.toggle_panel {
|
||||
return_value = single_unit_code,
|
||||
list_row_definition
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- main dialog definition
|
||||
local dialog = {
|
||||
T.tooltip {
|
||||
id = "tooltip"
|
||||
},
|
||||
T.helptip {
|
||||
id = "tooltip"
|
||||
},
|
||||
T.linked_group {
|
||||
id = "image",
|
||||
fixed_width = true
|
||||
},
|
||||
T.linked_group {
|
||||
id = "type",
|
||||
fixed_width = true
|
||||
},
|
||||
T.linked_group {
|
||||
id = "global_icon",
|
||||
fixed_width = true
|
||||
},
|
||||
T.grid {
|
||||
description_row,
|
||||
T.row {
|
||||
grow_factor = 1,
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
horizontal_grow = true,
|
||||
listbox
|
||||
}
|
||||
},
|
||||
T.row {
|
||||
grow_factor = 0,
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
horizontal_alignment = "left",
|
||||
T.toggle_button {
|
||||
id = "apply_to_all",
|
||||
label = _ "Apply to all units of this type"
|
||||
}
|
||||
}
|
||||
},
|
||||
T.row {
|
||||
T.column {
|
||||
horizontal_alignment = "right",
|
||||
T.grid {
|
||||
T.row {
|
||||
grow_factor = 0,
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
horizontal_alignment = "right",
|
||||
T.button {
|
||||
return_value = single_unit_code,
|
||||
label = _ "Save"
|
||||
}
|
||||
},
|
||||
T.column {
|
||||
border = "all",
|
||||
border_size = 5,
|
||||
horizontal_alignment = "right",
|
||||
T.button {
|
||||
id = "cancel",
|
||||
label = _ "Cancel"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local pick_advance_dialog = wml.load "modifications/pick_advance/gui/pick_advance.cfg"
|
||||
local dialog_wml = wml.get_child(pick_advance_dialog, 'resolution')
|
||||
|
||||
-- dialog preshow function
|
||||
local function preshow(window)
|
||||
window.apply_to_all.visible = not unit.canrecruit
|
||||
|
@ -206,7 +68,7 @@ function pickadvance.show_dialog_unsynchronized(advance_info, unit)
|
|||
apply_to_all = window.apply_to_all.selected
|
||||
end
|
||||
|
||||
local dialog_exit_code = gui.show_dialog(dialog, preshow, postshow)
|
||||
local dialog_exit_code = gui.show_dialog(dialog_wml, preshow, postshow)
|
||||
|
||||
if dialog_exit_code == cancel_code then
|
||||
return { ignore = true }
|
||||
|
|
151
data/modifications/pick_advance/gui/pick_advance.cfg
Normal file
151
data/modifications/pick_advance/gui/pick_advance.cfg
Normal file
|
@ -0,0 +1,151 @@
|
|||
#textdomain "wesnoth"
|
||||
|
||||
#define SINGLE_UNIT_CODE
|
||||
-1#enddef
|
||||
|
||||
#define DESCRIPTION_ROW
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
definition = "title"
|
||||
label = _ "Plan Advancement"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
#enddef
|
||||
|
||||
#define LIST_ROW_DEFINITION
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
[image]
|
||||
id = "the_icon"
|
||||
linked_group = "image"
|
||||
[/image]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
grow_factor = 1
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
use_markup = true
|
||||
id = "the_label"
|
||||
linked_group = "type"
|
||||
[/label]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
vertical_alignment = "center"
|
||||
[image]
|
||||
id = "global_icon"
|
||||
linked_group = "global_icon"
|
||||
label = "icons/action/editor-tool-unit_30-pressed.png"
|
||||
tooltip = _ "This advancement is currently the default for all units of the same type"
|
||||
[/image]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
#enddef
|
||||
|
||||
#define LISTBOX
|
||||
[listbox]
|
||||
id = "the_list"
|
||||
has_minimum = true
|
||||
[list_definition]
|
||||
[row]
|
||||
[column]
|
||||
horizontal_grow = true
|
||||
vertical_grow = true
|
||||
[toggle_panel]
|
||||
return_value = {SINGLE_UNIT_CODE}
|
||||
{LIST_ROW_DEFINITION}
|
||||
[/toggle_panel]
|
||||
[/column]
|
||||
[/row]
|
||||
[/list_definition]
|
||||
[/listbox]
|
||||
#enddef
|
||||
|
||||
# main dialog definition
|
||||
[resolution]
|
||||
[tooltip]
|
||||
id = "tooltip"
|
||||
[/tooltip]
|
||||
[helptip]
|
||||
id = "tooltip"
|
||||
[/helptip]
|
||||
[linked_group]
|
||||
id = "image"
|
||||
fixed_width = true
|
||||
[/linked_group]
|
||||
[linked_group]
|
||||
id = "type"
|
||||
fixed_width = true
|
||||
[/linked_group]
|
||||
[linked_group]
|
||||
id = "global_icon"
|
||||
fixed_width = true
|
||||
[/linked_group]
|
||||
[grid]
|
||||
{DESCRIPTION_ROW}
|
||||
[row]
|
||||
grow_factor = 1
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = true
|
||||
{LISTBOX}
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
grow_factor = 0
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[toggle_button]
|
||||
id = "apply_to_all"
|
||||
label = _ "Apply to all units of this type"
|
||||
[/toggle_button]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
horizontal_alignment = "right"
|
||||
[grid]
|
||||
[row]
|
||||
grow_factor = 0
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
[button]
|
||||
return_value = {SINGLE_UNIT_CODE}
|
||||
label = _ "Save"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
[button]
|
||||
id = "cancel"
|
||||
label = _ "Cancel"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/resolution]
|
Loading…
Add table
Reference in a new issue