T: converted character selection dialog to a custom GUI2 one

This commit is contained in:
Charles Dang 2015-01-03 15:33:39 +11:00
parent 7aea1c732a
commit a50225922c
3 changed files with 112 additions and 41 deletions

View file

@ -15,6 +15,10 @@
{campaigns/tutorial/units}
[/units]
[lua]
code="wesnoth.require 'campaigns/tutorial/lua/character_selection.lua'"
[/lua]
{campaigns/tutorial/utils}
{campaigns/tutorial/scenarios}
#endif

View file

@ -0,0 +1,103 @@
-- #textdomain wesnoth-tutorial
-- Allows the player to choose whether they want to play Konrad or Lisar
-- for the tutorial
local helper = wesnoth.require "lua/helper.lua"
local T = helper.set_wml_tag_metatable {}
local wml_actions = wesnoth.wml_actions
local _ = wesnoth.textdomain "wesnoth-tutorial"
function wml_actions.select_character()
local character_selection_dialog = {
maximum_height = 250,
maximum_width = 400,
T.helptip { id="tooltip_large" }, -- mandatory field
T.tooltip { id="tooltip_large" }, -- mandatory field
T.grid {
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
horizontal_alignment = "left",
T.label {
definition = "title",
label = _"Select Character"
}
}
},
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
horizontal_alignment = "left",
T.label {
label = _"Who do you want to play?"
}
}
},
T.row {
T.column {
T.grid {
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.image {
label = "units/konrad-fighter.png"
}
},
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.image {
label = "units/human-princess.png"
}
}
},
T.row {
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.button {
label = _"Konrad",
return_value = 1
}
},
T.column {
grow_factor = 1,
border = "all",
border_size = 5,
T.button {
label = _"Lisar",
return_value = 2
}
}
}
}
}
}
}
}
local character = wesnoth.show_dialog(character_selection_dialog)
local unit = wesnoth.get_variable("student_store")
local gender = "male"
if character == 2 then
gender = "female"
unit.type = "Fighteress"
unit.name = "Lisar"
unit.profile = "portraits/lisar.png"
end
wesnoth.set_variable("gender", gender)
wesnoth.put_unit(unit)
wesnoth.redraw {}
end

View file

@ -126,52 +126,16 @@
condition=lose
[/objective]
[/objectives]
# We don't want players ending their turn before the requisite actions have been completed
# Therefor, we frequently disallow or allow end turn as needed
[disallow_end_turn][/disallow_end_turn]
[/event]
[event]
name=start
# We don't want players ending their turn before the requisite actions have been completed
# Therefor, we frequently disallow or allow end turn as needed
[disallow_end_turn][/disallow_end_turn]
# TODO: possibly convert to a custom gui2 dialog
[message]
speaker=narrator
message= _"Who would you like to play?"
[option]
message="&" + "units/konrad-fighter.png" + "=" + _"Konrad" # wmllint: no spellcheck
[command]
{VARIABLE gender male}
[unstore_unit]
variable=student_store
[/unstore_unit]
[/command]
[/option]
[option]
message="&" + "units/human-princess.png" + "=" + _"Lisar" # wmllint: no spellcheck
[command]
{VARIABLE gender female}
[unit]
type=Fighteress
side=1
x,y=9,6
profile=portraits/lisar.png
id=student
name= _"Lisar"
canrecruit=yes
facing=se
to_variable=student_store
[/unit]
[unstore_unit]
variable=student_store
[/unstore_unit]
[/command]
[/option]
[/message]
[select_character][/select_character]
{CLEAR_VARIABLE student_store}