Initial implementation of the [select_unit] tag per bug #16819

Optional attributes: fire_event (def. no), hilight (def. yes)

Part of this is broken since I haven't figured out yet how to make it
possible to draw the movement ranges etc. when hilight=yes; apparently
some pathfinder stuff is required per mouse_events.cpp:280 and 284...
This commit is contained in:
Ignacio R. Morelle 2010-10-18 03:17:15 +00:00
parent 31c3fc7ddc
commit 3fc1fc16e1
3 changed files with 43 additions and 0 deletions

View file

@ -69,6 +69,8 @@ Version 1.9.1+svn:
* added new parameters directional_x and directional_y to animations * added new parameters directional_x and directional_y to animations
* added new parameters auto_vflip and auto_hflip to animations * added new parameters auto_vflip and auto_hflip to animations
* Made it so that units affected by [hide_unit] don't appear on the minimap (FR #16796) * Made it so that units affected by [hide_unit] don't appear on the minimap (FR #16796)
* New [select_unit] tag, with optional fire_event (def. no) and hilight_hex (def. yes)
attributes (FR #16819)
* Miscellaneous and bugfixes: * Miscellaneous and bugfixes:
* Changed: Lowered severity of some gui2 timer log messages. * Changed: Lowered severity of some gui2 timer log messages.
* Units created in debug mode now play their recruit animation (FR #16766). * Units created in debug mode now play their recruit animation (FR #16766).

View file

@ -279,6 +279,20 @@ function wml_actions.scroll_to_unit(cfg)
wesnoth.scroll_to_tile(u.x, u.y, cfg.check_fogged) wesnoth.scroll_to_tile(u.x, u.y, cfg.check_fogged)
end end
function wml_actions.select_unit(cfg)
local u = wesnoth.get_units(cfg)[1]
if not u then return end
local fire_event = cfg.fire_event
local hilight = (cfg.hilight or true)
wesnoth.select_hex(u.x, u.y)
if hilight then wesnoth.hilight_hex(u.x, u.y) end
if fire_event then
wesnoth.fire_event("select", u.x, u.y)
end
end
function wml_actions.unit_overlay(cfg) function wml_actions.unit_overlay(cfg)
local img = cfg.image local img = cfg.image
for i,u in ipairs(wesnoth.get_units(cfg)) do for i,u in ipairs(wesnoth.get_units(cfg)) do

View file

@ -631,6 +631,33 @@ My best advancement costs $next_cost gold and I'm $experience|% there."
[/lua] [/lua]
[/event] [/event]
[event]
name=test1
first_time_only=no
[select_unit]
type=Elvish Avenger
fire_event=yes
[/select_unit]
[/event]
[event]
name=select
first_time_only=no
[filter]
type=Elvish Avenger
[filter_wml]
[status]
petrified=yes
[/status]
[/filter_wml]
[/filter]
[message]
speaker=unit
message="Oh hi"
[/message]
[/event]
[event] [event]
name=prestart name=prestart
[time_area] [time_area]