Window object

The Window object allows you to access the properties of your game's windows. Window objects are created by loading a window definition file using the Game.LoadWindow metod. A special case is the window used for the inventory. It can be queried using the Game.GetInventoryWindow method.


Methods

SetFont Sets a normal font.
SetImage Sets a background image (sprite).
GetImage Returns the filename of the background sprite (or null if no sprite is set)
GetImageObject Returns a reference to the background sprite (or null if no sprite is set)
Focus Focuses the control.
MoveAfter Moves the control in z-order after a given control.
MoveBefore Moves the control in z-order before a given control.
MoveToTop Moves the control to the top of the z-order.
MoveToBottom Moves the control to the bottom of the z-order.
SkipTo Moves an object to a specified location.
Actions
GetControl Get a reference to a given object contained in this window
SetInactiveFont Sets a font to be used when the window is inactive.
SetInactiveImage Sets a background image (sprite) to be used when this window is inactive.
GetInactiveImage Returns the filename of the inactive background sprite (or null if no sprite is set)
GetInactiveImageObject Returns a reference to the inactive background sprite (or null if no sprite is set)
Close Closes the window.
GoExclusive Makes the window an exclusive object on screen.
GoSystemExclusive Pauses the game and makes the window an exclusive object on screen.
Center Centers the window on screen.
LoadFromFile Loads the window definition from a specified file.
CreateButton Dynamically creates a new button control
CreateStatic Dynamically creates a new static control
CreateEditor Dynamically creates a new editor control
CreateWindow Dynamically creates a new sub-window control
CreateEntityContainer Dynamically creates a new entity container control
DeleteButton Deletes a button object
DeleteStatic Deletes a static control object
DeleteEditor Deletes an editor object
DeleteWindow Deletes a window object
DeleteControl Deletes a child control object (button, static, etc.)
Cursor functions
SetCursor Sets the standard cursor.
GetCursor Returns the filename of the cursor sprite (or null if no cursor is set)
GetCursorObject Returns a reference to the cursor sprite (or null if no cursor is set)
RemoveCursor Removes the standard cursor.
HasCursor Queries whether the standard cursor is set.
Script functions
AttachScript Executes a script file and attaches it to the object.
DetachScript Terminates a specified script file and detaches it from an object.
IsScriptRunning Queries whether a specified script file is running and attached to an object.
CanHandleMethod Queries whether the object supports a method of a specified name.
Sound functions
PlaySound Plays a sound. If the filename is omitted, the currently assigned sound is played (if any).
PlaySoundEvent Plays a sound and triggers an event when the sound is over. If the filename is omitted, the currently assigned sound is played (if any).
StopSound Stops the currently playing sound (if any).
PauseSound Pauses the currently playing sound.
ResumeSound Resumes a paused sound playback.
IsSoundPlaying Queries whether a sound playback is in progress.
SetSoundPosition Sets the sound's current playing position.
GetSoundPosition Queries the sound's current playing position
SetSoundVolume Sets a volume of the currently playing sound.
GetSoundVolume Gets a volume of the currently playing sound.
LoadSound Initializes a sound from file and makes it ready to be played.
Sound effects functions
SoundFXNone Removes any sound effect currently assigned to this object.
SoundFXEcho Assigns an echo effect to the sounds played by this object.
SoundFXReverb Assigns a reverb effect to the sounds played by this object.
Event functions
ApplyEvent Applies a named event to the object.
CanHandleEvent Queries whether the object has an event handler for a specified event.

Attributes

Parent (read only) Returns a reference to a parent window of this control (or null)
ParentNotify Specifies whether this control should notify its parent about events
Width A width of the control
Height A height of the control
Visible Specifies whether the control is visible
Disabled Specifies whether the control is disabled
Text A text the control displays
NextSibling (read only) Returns a reference to the next control in z-order
PrevSibling (read only) Returns a reference to the previous control in z-order
Type (read only) Returns always "window"
NumControls (read only) Returns a number of controls contained in this window.
Exclusive Specifies if the window is in exclusive mode.
SystemExclusive Specifies if the window is in system exclusive mode.
Menu Specifies whether this is a "menu" type window (it's closed when the user clicks anywhere outside the window).
InGame Specifies whether this is an "in-game" type window (it's always displayed before the inventory window).
ClipContents Specifies whether the contained controls are clipped when they lie partially outside the window.
Transparent Specifies whether the window receives click events. All the mouse clicks go through for transparent windows.
Name The internal name of the object.
Caption The caption of the object.
AccCaption A special caption of the object used for accessibility purposes.
X The X position of the object.
Y The Y position of the object.
Height (read only) Returns the current height of the object. In case of actors and entities the scaling is taken into account.
Filename (read only) Returns the filename.
Ready (read only) Returns whether the object isn't currently performing any action.
Interactive Specifies whether the object recieves user input.
SoundPanning Specifies whether the sounds played by this object are automatically panned depending on object's position on screen.
NonIntMouseEvents Specifies if the object can receive the MouseEntry and MouseLeave events even if the game is in non-interactive mode.
Movable Specifies whether the object can be moved by its sprites (in case the sprite frames have a "move" property set).
Scalable Specifies whether the object is affected by scene's scaling levels.
Rotatable Specifies whether the object is affected by scene's rotation levels.
Colorable Specifies whether the object is affected by scene's color regions.
AlphaColor Specifies an RGBA color of this object (overrides scene coloring); set to 0 to reset default behavior.
BlendMode Specifies how the object's image is blended with the background colors; 0...normal mode, 1...additive blending, 2...subtractive blending
Scale Specifies a scale of this object (overrides scene scaling); set to null to reset default behavior.
ScaleX Specifies horizontal scale of this object; set to null to reset default behavior.
ScaleY Specifies vertical scale of this object; set to null to reset default behavior.
RelativeScale Specifies a scale amount to be added to the default scene scale.
Rotate Specifies rotation of this object (in degrees); overrides scene rotation; set to null to reset default behavior; not available in compatibility mode
RelativeRotate Specifies a rotation amount to be added to the default scene rotation.
FadeColor Specifies an alpha color which the background is faded to when this window is being displayed.
AlphaColor Specifies an alpha color which is applied to the entire window.
PauseMusic Specifies whether the music is paused when this window is running in system-exclusive mode.

Low level events

LeftClick The left mouse button has been pressed.
RightClick The right mouse button has been pressed.
MiddleClick The middle mouse button has been pressed.
LeftDoubleClick The left mouse button has been double-clicked.
RightDoubleClick The right mouse button has been double-clicked.
LeftRelease The left mouse button has been released.
RightRelease The right mouse button has been released.
MiddleRelease The middle mouse button has been released.
MouseWheelUp The mouse wheel has been rolled up.
MouseWheelDown The mouse wheel has been rolled down.
Keypress Some key has been pressed. Use the Keyboard variable to find out the details.

SetFont(Filename)

Sets a normal font.

Parameters

Filename
A filename of a font file to be used.

Return value

If the method succeeds, the return value is true.


SetImage(Filename)

Sets a background image (sprite).

Parameters

Filename
A filename of a sprite file to be used.

Return value

If the method succeeds, the return value is true.


GetImage()

Returns the filename of the background sprite (or null if no sprite is set)


GetImageObject()

Returns a reference to the background sprite (or null if no sprite is set)


Focus()

Focuses the control.


MoveAfter(Control)
MoveAfter(ControlName)

Moves the control in z-order after a given control.

Parameters

Control
A control object we will move our control after
ControlName
A name of a control object we will move our control after

Return value

If the method succeeds, the return value is true.


MoveBefore(Control)
MoveBefore(ControlName)

Moves the control in z-order before a given control.

Parameters

Control
A control object we will move our control before
ControlName
A name of a control object we will move our control before

Return value

If the method succeeds, the return value is true.


MoveToTop()

Moves the control to the top of the z-order.

Return value

If the method succeeds, the return value is true.


MoveToBottom()

Moves the control to the bottom of the z-order.

Return value

If the method succeeds, the return value is true.


SkipTo(X, Y)

Moves an object to a specified location.

Parameters

X
Destination X coordinate.
Y
Destination Y coordinate.

GetControl(ControlIndex)
GetControl(ControlName)

Get a reference to a given object contained in this window

Parameters

ControlIndex
A nuber specifying an index of a control to be returned
ControlName
Name of a control to be returned

Return value

Returns a reference to a requested control or null if such a control doesn't exist

Remarks

This method has been previously called "GetWidget" and this name is still valid for backwards compatibility.


SetInactiveFont(Filename)

Sets a font to be used when the window is inactive.

Parameters

Filename
A filename of a font file to be used.

Return value

If the method succeeds, the return value is true.


SetInactiveImage(Filename)

Sets a background image (sprite) to be used when this window is inactive.

Parameters

Filename
A filename of a sprite file to be used.

Return value

If the method succeeds, the return value is true.


GetInactiveImage()

Returns the filename of the inactive background sprite (or null if no sprite is set)


GetInactiveImageObject()

Returns a reference to the inactive background sprite (or null if no sprite is set)


Close()

Closes the window.

Return value

If the method succeeds, the return value is true.

Remarks

Note that this method only removes window from screen but it stays loaded in memory. If you no longer need the window, you should unload it using the Game.UnloadObject method.


GoExclusive()

Makes the window an exclusive object on screen.

Remarks

The user cannot interact with any other object while the window is in exclusive state. Use the Window.Close() method to cancel the exclusive state.


GoSystemExclusive()

Pauses the game and makes the window an exclusive object on screen.

Remarks

This method is intended for system windows, such as save/load dialogs, because the entire game is frozen while the window is in system exclusive state. Use the Window.Close() method to cancel the exclusive state.


Center()

Centers the window on screen.


LoadFromFile(Filename)

Loads the window definition from a specified file.

Parameters

Filename
A filename of a window file to be loaded.

Return value

If the method succeeds, the return value is true.


CreateButton(Name)

Dynamically creates a new button control

Parameters

Name
The name of the button (optional)

Return value

Returns the newly created button object

Remarks

Use the DeleteButton method to remove the button.


CreateStatic(Name)

Dynamically creates a new static control

Parameters

Name
The name of the control (optional)

Return value

Returns the newly created static control object

Remarks

Use the DeleteStatic method to remove the control.


CreateEditor(Name)

Dynamically creates a new editor control

Parameters

Name
The name of the editor (optional)

Return value

Returns the newly created editor object

Remarks

Use the DeleteEditor method to remove the editor.


CreateWindow(Name)

Dynamically creates a new sub-window control

Parameters

Name
The name of the window (optional)

Return value

Returns the newly created window object

Remarks

Use the DeleteWindow method to remove the window.


CreateEntityContainer(Name)

Dynamically creates a new entity container control

Parameters

Name
The name of the container (optional)

Return value

Returns the newly created entity container object

Remarks

Use the DeleteControl method to remove the entity container.


DeleteButton(Button)

Deletes a button object

Parameters

Button
The button to be deleted

DeleteStatic(Static)

Deletes a static control object

Parameters

Static
The static control to be deleted

DeleteEditor(Editor)

Deletes an editor object

Parameters

Editor
The editor control to be deleted

DeleteWindow(Window)

Deletes a window object

Parameters

Window
The window control to be deleted

DeleteControl(Control)

Deletes a child control object (button, static, etc.)

Parameters

Control
The control to be deleted

SetCursor(Filename)

Sets the standard cursor.

Parameters

Filename
Filename of a sprite file to be used as a cursor pointer.

Return value

Returns true if the cursor has been set succesfuly.


GetCursor()

Returns the filename of the cursor sprite (or null if no cursor is set)


GetCursorObject()

Returns a reference to the cursor sprite (or null if no cursor is set)


RemoveCursor()

Removes the standard cursor.


HasCursor()

Queries whether the standard cursor is set.

Return value

Returns true if the object has a custom mouse pointer assigned.


AttachScript(Filename)

Executes a script file and attaches it to the object.

Parameters

Filename
The filename of the script file to be executed.

Return value

Returns true if the script has been executed succesfuly.

Remarks

Each WME object can have multiple scripts attached.


DetachScript(Filename, KillThreads)

Terminates a specified script file and detaches it from an object.

Parameters

Filename
The filename of the (running) script to be terminated and detached.
KillThreads
Specifies whether to terminate all running threads of this script (optional, default=false)

Return value

Returns true if the script has been detached succesfully.

Remarks

Script threads are currently executed event handlers and methods.


IsScriptRunning(Filename)

Queries whether a specified script file is running and attached to an object.

Parameters

Filename
The filename of the script to be queried.

Return value

Returns true if a specified script file is attached to an object.


CanHandleMethod(MethodName)

Queries whether the object supports a method of a specified name.

Parameters

MethodName
The name of the method to be checked.

Return value

Returns true if the object is able to handle the specified method.


PlaySound(Filename, Looping, LoopStart)
PlaySound(Looping, LoopStart)

Plays a sound. If the filename is omitted, the currently assigned sound is played (if any).

Parameters

Filename
The filename of the sound file to be played
Looping
Whether the sound should be looped (optional, default = false).
LoopStart
The point from which the sound restarts when looping, in milliseconds (optional, default=0).

Return value

If the method succeeds, the return value is true.


PlaySoundEvent(Filename, EventName)
PlaySoundEvent(EventName)

Plays a sound and triggers an event when the sound is over. If the filename is omitted, the currently assigned sound is played (if any).

Parameters

Filename
The filename of the sound file to be played
EventName
The name of the event to be triggered after the sound finishes.

Return value

If the method succeeds, the return value is true.


StopSound()

Stops the currently playing sound (if any).

Return value

If the method succeeds, the return value is true.


PauseSound()

Pauses the currently playing sound.

Return value

If the method succeeds, the return value is true.


ResumeSound()

Resumes a paused sound playback.

Return value

If the method succeeds, the return value is true.


IsSoundPlaying()

Queries whether a sound playback is in progress.

Return value

If the sound is playing, the return value is true.


SetSoundPosition(Time)

Sets the sound's current playing position.

Parameters

Time
A new playing position (in milliseconds)

Return value

If the method succeeds, the return value is true.


GetSoundPosition()

Queries the sound's current playing position

Return value

Returns the current playing position (in milliseconds).


SetSoundVolume(Volume)

Sets a volume of the currently playing sound.

Parameters

Volume
A new sound volume (in percent).

Return value

If the method succeeds, the return value is true.


GetSoundVolume()

Gets a volume of the currently playing sound.

Return value

Returns the volume of the currently playing sound (in percent).


LoadSound(Filename)

Initializes a sound from file and makes it ready to be played.

Parameters

Filename
The sound file to be loaded

Return value

If the method succeeds, the return value is true.

Remarks

Use this method to pre-cache a sound file. Initializing the sound takes some time and sometimes it's desirable to move all sound initialization to e.g. scene start so that the subsequent PlaySound calls don't slow the game down. That's what LoadSound is for. To play the pre-cached sound simply call PlaySound without specifying a filename, for example SomeObject.PlaySound(false);


SoundFXNone()

Removes any sound effect currently assigned to this object.


SoundFXEcho(WetDryMix, Feedback, LeftDelay, RightDelay)

Assigns an echo effect to the sounds played by this object.

Parameters

WetDryMix
Wet/Dry Mix, in percent (0 to 100)
Feedback
Feedback, in percent (0 to 100)
LeftDelay
Left delay, in milliseconds (1 to 2000)
RightDelay
Right delay, in milliseconds (1 to 2000)

Remarks

Example: actor.SoundFXEcho(50, 50);


SoundFXReverb(InGain, ReverbMix, ReverbTime, HighFreqRTRatio)

Assigns a reverb effect to the sounds played by this object.

Parameters

InGain
In gain, in dB (-96 to 0)
ReverbMix
Reverb mix, in dB (-96 to 0)
ReverbTime
Reverb time, in milliseconds (0.001 to 3000)
HighFreqRTRatio
HighFreq RT Ratio (0.001 to 0.999)

Remarks

Example: actor.SoundFXReverb(0, 0, 2000);


ApplyEvent(EventName)

Applies a named event to the object.

Parameters

EventName
A name of the event to be applied to the object.

Return value

Returns true it the event has been applied succesfuly.


CanHandleEvent(EventName)

Queries whether the object has an event handler for a specified event.

Parameters

EventName
The name of the event to be checked.

Return value

Returns true if the object is able to handle the specified event.