#textdomain wesnoth
# 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_ID IMAGE CAPTION_TEXT MESSAGE_TEXT
    # Displays a text message spoken by SPEAKER_ID.
    # 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_ID}
        message={MESSAGE_TEXT}
        image={IMAGE}
        caption={CAPTION_TEXT}
    [/message]
#enddef

#define HIGHLIGHT_IMAGE X Y IMAGE BACKGROUND_VALUE
    # Scrolls to the given location, blinks the given image in and out a few
    # times, and then leaves the image in place. Use this to pinpoint an
    # important location to the player. If there's an existing [item] on the
    # location, specify it as the BACKGROUND_VALUE or else it'll get lost
    # during the blinking.
    [scroll_to]
        x,y={X},{Y}
        check_fogged=false
    [/scroll_to]
    [item]
        x,y={X},{Y}
        halo={IMAGE}
    [/item]
    [redraw][/redraw]
    [delay]
        time=300
    [/delay]
    [remove_item]
        x,y={X},{Y}
    [/remove_item]
    [item]
        x,y={X},{Y}
        image={BACKGROUND_VALUE}
    [/item]
    [redraw][/redraw]
    [delay]
        time=300
    [/delay]
    [item]
        x,y={X},{Y}
        halo={IMAGE}
    [/item]
    [redraw][/redraw]
    [delay]
        time=300
    [/delay]
    [remove_item]
        x,y={X},{Y}
    [/remove_item]
    [item]
        x,y={X},{Y}
        image={BACKGROUND_VALUE}
    [/item]
    [redraw][/redraw]
    [delay]
        time=300
    [/delay]
    [item]
        x,y={X},{Y}
        halo={IMAGE}
    [/item]
    [redraw][/redraw]
    [delay]
        time=300
    [/delay]
    [remove_item]
        x,y={X},{Y}
    [/remove_item]
    [item]
        x,y={X},{Y}
        image={BACKGROUND_VALUE}
    [/item]
    [redraw][/redraw]
    [delay]
        time=300
    [/delay]
    [item]
        x,y={X},{Y}
        image={IMAGE}
    [/item]
    [redraw][/redraw]
#enddef

#define CLEAR_FOG SIDE X Y RADIUS
    # Clears fog in a specific area for the given side.
    # This will persist until {UNCLEAR_FOG} (below) is used.
    [lift_fog]
        [filter_side]
            side={SIDE}
        [/filter_side]
        x,y={X},{Y}
        radius={RADIUS}
        multiturn=yes
    [/lift_fog]
#enddef

#define UNCLEAR_FOG
    # Restores fog that was temporarily cleared (check CLEAR_FOG above). Only
    # one UNCLEAR_FOG is required no matter how many times CLEAR_FOG was used.
    [reset_fog]
    [/reset_fog]
#enddef

#define SET_LABEL X Y STRING
    # Puts STRING 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={STRING}
    [/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="" # wmllint: ignore
    [/label]
#enddef

#define FAKE_UNIT_MOVE FROM_X TO_X FROM_Y TO_Y SIDE TYPE MODIFIER_WML
    # Moves a fake unit using TYPE's animations, from (FROM_X, FROM_Y)
    # to (TO_X, TO_Y).  You can also specify modifiers that change the
    # baseframe displayed by unit's gender or variation, or none at
    # all.
    #
    # Example:
    #! {FAKE_UNIT_MOVE 1 2 1 2 1 (Dark Adept) (
    #!     gender=female
    #!     variation=fancy
    #! )}
    [move_unit_fake]
        type={TYPE}
        side={SIDE}
        x={FROM_X},{TO_X}
        y={FROM_Y},{TO_Y}
        {MODIFIER_WML}
    [/move_unit_fake]
#enddef

#define SCROLL X Y
    # Scrolls the screen by the specified offsets
    #
    # For example, let's scroll 5 right and 3 down:
    #! {SCROLL 5 3}
    [scroll]
        x={X}
        y={Y}
    [/scroll]
#enddef

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

#define QUAKE SOUND
    # Visuals and sound for an earth tremor.
    [sound]
        name={SOUND}
    [/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_WML
    # Creates an earthquake-effect while performing ACTION_WML
    # For example we could kill all non-leader units in the earthquake:
    #! {EARTHQUAKE (
    #!   [kill]
    #!       canrecruit=no
    #!       animate=yes
    #!   [/kill]
    #! )}
    [sound]
        name=lightning.ogg
    [/sound]
    {SCROLL 2 1}
    {SCROLL -1 -3}
    {SCROLL -3 1}
    {ACTION_WML}
    {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}
    [color_adjust]
        red={RED}
        green={GREEN}
        blue={BLUE}
    [/color_adjust]
#enddef

# Flashes the screen with a given color performing ACTION_WML
# 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_WML
    # Flash the screen momentarily white.
    {COLOR_ADJUST 67 67 67}
    {COLOR_ADJUST 100 100 100}
    {ACTION_WML}
    {COLOR_ADJUST 33 33 33}
    {COLOR_ADJUST 0 0 0}
#enddef

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

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

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

#define THUNDER ACTION_WML
    # Creates a thunder-and-lightning effect while performing ACTION_WML.
    # 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_WML}) }
#enddef

#The macro that all the following macros work off
#define FADE_STEP_RGB RED GREEN BLUE DELAY_TIME
    [color_adjust]
        red,green,blue={RED},{GREEN},{BLUE}
    [/color_adjust]
    [delay]
        time={DELAY_TIME}
    [/delay]
    [redraw][/redraw]
#enddef

#The macro that the following fade to black macros rely on
#define FADE_STEP NUMBER DELAY_TIME
    {FADE_STEP_RGB {NUMBER} {NUMBER} {NUMBER} {DELAY_TIME}}
#enddef

#define FADE_TO_BLACK
    # Fades the screen to black. Use {FADE_IN} to return to normal
    {FADE_STEP -32 5}
    {FADE_STEP -64 5}
    {FADE_STEP -96 5}
    {FADE_STEP -128 5}
    {FADE_STEP -160 5}
    {FADE_STEP -192 5}
    {FADE_STEP -224 5}
    {FADE_STEP -256 5}
    {FADE_STEP -512 5}
#enddef

#define FADE_TO_BLACK_HOLD TIME
    # Fades the screen to black and then pauses for TIME milliseconds.
    # Use {FADE_IN} to return to normal
    {FADE_STEP -32 5}
    {FADE_STEP -64 5}
    {FADE_STEP -96 5}
    {FADE_STEP -128 5}
    {FADE_STEP -160 5}
    {FADE_STEP -192 5}
    {FADE_STEP -224 5}
    {FADE_STEP -256 5}
    {FADE_STEP -512 {TIME}}
#enddef

#define FADE_IN
    # Brings the screen back from a {FADE_TO_BLACK}
    {FADE_STEP -256 5}
    {FADE_STEP -224 5}
    {FADE_STEP -192 5}
    {FADE_STEP -160 5}
    {FADE_STEP -128 5}
    {FADE_STEP -96 5}
    {FADE_STEP -64 5}
    {FADE_STEP -32 5}
    {FADE_STEP 0 5}
#enddef

# Encapsulate text in conventional markup for characters whispering.
# We do this so whispers can be restyled by tweaking this markup
#define WHISPER TEXT
"<small>(" + {TEXT} + ")</small>"#enddef

# Encapsulate text in conventional markup for characters speaking aside.
# We do this so asides can be restyled by tweaking this markup
#define ASIDE TEXT
"<i>(" + {TEXT} + ")</i>"#enddef

# Encapsulate text in conventional markup similar to how standard
# character message dialogs are rendered. Intended for story screens
# mainly.
#define CAPTION TEXT
    "<span color='#bcb088'><b>" + {TEXT} + "</b></span>

"#enddef
