# Interface shortcut macros.

# These don't depend on any other macros.  Please don't change this.
# ! in comments is used to generate HTML documentation; ignore it otherwise.

#define MESSAGE SPEAKER IMAGE CAPTION TEXT
# Displays a text message spoken by SPEAKER.
# Speaker can be any of: narrator, unit and second_unit
# For example, let's have the narrator, which looks like a faery
# express some feelings on the undead:
#! {MESSAGE narrator "units/elves-wood/shyde.png" _ "Faery" _ "Aarr! Them be undeadies! Loooks at them.."}
    [message]
        speaker={SPEAKER}
        message={TEXT}
        image={IMAGE}
        caption={CAPTION}
    [/message]
#enddef

#define FLOATING_TEXT FILTER COLOUR TEXT
# Floats the given text above the given unit in the same manner as damage
# numbers are displayed in combat.
# For example when a unit steps on a hidden trap and is dealt 8 damage, let's
# show this to the player like all other damage is:
#! {FLOATING_TEXT x,y=$x1,$y1 255,0,0 "8"}
    [store_unit]
        [filter]
            {FILTER}
        [/filter]

        kill=no
        variable=FLOATING_TEXT_temp
    [/store_unit]

    [unstore_unit]
        variable=FLOATING_TEXT_temp
        find_vacant=no
        red,green,blue={COLOUR}
        text={TEXT}
    [/unstore_unit]

    {CLEAR_VARIABLE FLOATING_TEXT_temp}
#enddef

#define SET_LABEL X Y TEXT
# Puts TEXT on the map at X,Y.  Strictly a syntactic shortcut.
#
# For example:
#! {SET_LABEL 4 7 _ "There be dragons here!"}
    [label]
        x={X}
        y={Y}
        text={TEXT}
    [/label]
#enddef

#define REMOVE_LABEL X Y
# Removes a label from a given tile.
#
# For example, remove it from 4,7
#! {REMOVE_LABEL 4 7}
    [label]
        x={X}
        y={Y}
        text=""
    [/label]
#enddef

#define SET_LABEL_PERSISTANT X Y TEXT
# Sets a label on tile x,y that gets reset every sideturn in case
# someone clears it.
#
# Example:
#! {SET_LABEL_PERSISTANT 4 7 _ "There really will be dragons here!!"}
    {SET_LABEL {X} {Y} ({TEXT}) }
    {ON_SIDETURN (
        {SET_LABEL {X} {Y} ({TEXT}) }
    )}
#enddef

#define SET_IMAGE X Y IMAGE
# Places an image at a given tile, shrinking it to fit the tile
#
# For example, let's put a tent on tile 14,5
#! {SET_IMAGE 14 5 "terrain/tent.png"}
    [item]
        x,y={X},{Y}
        image={IMAGE}
    [/item]
#enddef

#define REMOVE_IMAGE X Y
# Removes a previously set image from a tile.
#
# Example:
#! {REMOVE_IMAGE 14 5}
    [removeitem]
        x,y={X},{Y}
    [/removeitem]
#enddef


#define SET_IMAGE_AND_LABEL X Y IMAGE TEXT
# Shorthand for setting both an image and a label at once.
    {SET_LABEL {X} {Y} ({TEXT}) }
    {SET_IMAGE {X} {Y} ({IMAGE}) }
#enddef

#define SET_IMAGE_AND_LABEL_PERSISTANT X Y IMAGE TEXT
# Shorthand for setting both a persistant label and image at once.
    {SET_LABEL_PERSISTANT {X} {Y} ({TEXT}) }
    {SET_IMAGE {X} {Y} ({IMAGE}) }
#enddef

#define REMOVE_IMAGE_AND_LABEL X Y
# Shorthand for removing both image and label at once
    {REMOVE_IMAGE {X} {Y}}
    {REMOVE_LABEL {X} {Y}}
#enddef

#define SCROLL X Y
# Scrolls the screen to the given coordinates.
#
# For example, let's focus on 26,35:
#! {SCROLL 26 35}
    [scroll]
        x={X}
        y={Y}
    [/scroll]
#enddef

#define TREMOR
# Visuals and sound for an earth tremor.
    [sound]
    name="rumble.ogg"
    [/sound]
    [scroll]
        x=5
        y=0
    [/scroll]
    [scroll]
        x=-10
        y=0
    [/scroll]
    [scroll]
        x=5
        y=5
    [/scroll]
    [scroll]
        x=0
        y=-10
    [/scroll]
    [scroll]
        x=0
        y=5
    [/scroll]
#enddef

#define EARTHQUAKE ACTION
# Creates an earthquake-effect while performing ACTION
# For example we could kill all non-leader units in the earthquake:
#! {EARTHQUAKE (
#!   [kill]
#!       canrecruit=0
#!       animate=yes
#!   [/kill]
#! )}
    [sound]
        name=lightning.ogg
    [/sound]
    {SCROLL 2 1}
    {SCROLL -1 -3}
    {SCROLL -3 1}
    {ACTION}
    {SCROLL 1 3}
    {SCROLL 1 -2}
#enddef

#define COLOR_ADJUST RED GREEN BLUE
# Adjusts the color of the screen by a tint or red, green and blue
# for example, let's make it very blueish:
#! {COLOR_ADJUST 0 0 100}
    [colour_adjust]
        red={RED}
        green={GREEN}
        blue={BLUE}
    [/colour_adjust]
#enddef

# Flashes the screen with a given color performing ACTION
# These macros come in WHITE, RED, GREEN and BLUE and can
# easily be expanded for ORANGE, PURPLE etc.
#
# Example: flash the screen to scare the player:
#! {FLASH_GREEN ()}
#! {FLASH_RED ()}
#! {FLASH_BLUE ()}
#! {FLASH_WHITE ()}

#define FLASH_WHITE ACTION
# Flash the screen momentarily white.
    {COLOR_ADJUST 67 67 67}
    {COLOR_ADJUST 100 100 100}
    {ACTION}
    {COLOR_ADJUST 33 33 33}
    {COLOR_ADJUST 0 0 0}
#enddef

#define FLASH_RED ACTION
# Flash the screen momentarily red.
    {COLOR_ADJUST 67 0 0}
    {COLOR_ADJUST 100 0 0}
    {ACTION}
    {COLOR_ADJUST 33 0 0}
    {COLOR_ADJUST 0 0 0}
#enddef

#define FLASH_GREEN ACTION
# Flash the screen momentarily green.
    {COLOR_ADJUST 0 67 0}
    {COLOR_ADJUST 0 100 0}
    {ACTION}
    {COLOR_ADJUST 0 33 0}
    {COLOR_ADJUST 0 0 0}
#enddef

#define FLASH_BLUE ACTION
# Flash the screen momentarily blue.
    {COLOR_ADJUST 0 0 67}
    {COLOR_ADJUST 0 0 100}
    {ACTION}
    {COLOR_ADJUST 0 0 33}
    {COLOR_ADJUST 0 0 0}
#enddef

#define THUNDER ACTION
# Creates a thunder-and-lightning effect while performing ACTION.
# For example, player 3 might disappear in the flash of lightning:
#! {THUNDER (
#!   [store_unit]
#!       [filter]
#!           side=3
#!       [/filter]
#!       variable=player3
#!       kill=yes
#!   [/store_unit]
#! )}
    [sound]
        name=lightning.ogg
    [/sound]
    {FLASH_WHITE ({ACTION}) }
#enddef
