Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:WindowStartPositionAnimation

From RoR Wiki

UI Lua API · Window functions
Version: WAR 1.4.8

Starts an animation that moves a window between two positions relative to its parent.

WindowStartPositionAnimation(windowName, animationType, startX, startY, endX, endY, duration, setStartBeforeDelay, delay, loopCount)

Arguments

windowName
string – Name of the window.
animationType
number – How the position changes over time. Use a Window.AnimationType constant; see WindowStartAlphaAnimation for the list.
startX, startY
number – Start offset of the window's top-left corner from its parent's top-left corner, in screen pixels.
endX, endY
number – End offset, in screen pixels.
duration
number – Length of one pass from start to end, in seconds.
setStartBeforeDelay
boolean – true to move the window to the start position straight away, during the delay. See Details for what false does.
delay
number – Seconds to wait before the animation starts.
loopCount
number – For LOOP and REPEAT: how many passes to run. 0 runs until stopped.

Returns

Nothing.

Details

  • The animation types, the delay, the loop count and the reset at the end work as described on WindowStartAlphaAnimation. X and Y are animated separately with the same settings.
  • The positions are in screen pixels. They are not multiplied by the window's scale, unlike the values of WindowSetOffsetFromParent. The stock alert text window multiplies the result of WindowGetOffsetFromParent by the interface scale before using it here (see the example).
  • "Original position" for the resetting types is the window's offset from its parent when the animation was started.
  • Unlike the alpha and scale animations, the value used before the animation starts is not the window's current position but (0, 0). With a delay and setStartBeforeDelay = false, the window therefore sits at its parent's top-left corner until the delay is over. Pass true to avoid this.
  • Each frame the new offset is applied the same way as a moved window, so the client may keep the window on screen (see WindowIsSticky).
  • The window's anchors are not removed. The stock UI clears and re-adds anchors around position animations; its comment says "animation ignores the anchors".
  • A window has at most one position animation. Starting a new one stops the old one first.
  • animationType and loopCount are truncated to whole numbers.

Errors

  • Error in function call 'WindowStartPositionAnimation': Window %s does not exist
  • Error in function call 'WindowStartPositionAnimation': Window %s is currently locked and may not be modified from lua. ...
    This check never triggers in the current client. See WindowSetShowing.

Example

Sliding an alert upwards, from ea_alerttextwindow/source/alerttextwindow.lua:

-- Get where we are
local x, y = WindowGetOffsetFromParent( oldestWindowName )
WindowStopPositionAnimation( oldestWindowName )

-- reset the anchor for the oldest window
-- because animation ignores the anchors
WindowClearAnchors( oldestWindowName )
WindowAddAnchor( oldestWindowName, "top", "Root", "top", 0, y )

local uiScale = InterfaceCore.GetScale()
x = uiScale * x
y = uiScale * y

local targetY = y - AlertTextWindow.NewestHeight
WindowStartPositionAnimation(   oldestWindowName,
                                Window.AnimationType.SINGLE_NO_RESET,
                                x,
                                y,
                                x,
                                targetY,
                                AlertTextWindow.ANIMATION_DATA.duration,
                                true, 0, 0 )

See also