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.


Методы

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 Перемещает объект в указанную точку.
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
DeleteButton Deletes a button object
DeleteStatic Deletes a static control object
DeleteEditor Deletes an editor object
DeleteWindow Deletes a window object
Функции управления курсором
SetCursor Устанавливает стандартный курсор.
GetCursor Возвращает имя файла спрайта курсора или null, если курсор не задан
GetCursorObject Возвращает ссылку на спрайт курсора (объект) или null, если курсор не задан
RemoveCursor Удаляет стандартный курсор.
HasCursor Выясняет, задан ли стандартный курсор для объекта.
Функции для работы со сценариями
AttachScript Выполняет файл сценария и прикрепляет его к объекту.
DetachScript Выгружает из памяти файл сценария и удаляет его связку с объектом.
IsScriptRunning Выясняет, прикреплён ли указанный файл сценария к объекту.
CanHandleMethod Выясняет, поддерживает ли объект метод с указанным именем.
PlaySound Воспроизводит звук. Если имя файла не указано, воспроизводится прикреплённый на настоящий момент звук (если есть).
PlaySoundEvent Воспроизводит звук и генерирует событие, когда воспроизведение закончится. Если имя файла не указано, воспроизводится прикреплённый на настоящий момент звук (если есть).
StopSound Останавливает воспроизведение звука (если есть).
PauseSound Ставит на паузу воспроизведение звука.
ResumeSound Продолжает воспроизведение после паузы.
IsSoundPlaying Выясняет, воспроизводится ли в настоящий момент звуковой файл.
SetSoundPosition Задаёт текущую позицию для воспроизведения в звуковом файле.
GetSoundPosition Возвращает текущую позицию для воспроизведения в звуковом файле
SetSoundVolume Устанавливает громкость звука.
GetSoundVolume Возвращает значение уровня громкости звука.
LoadSound Инициализирует звук из файла, подготавливая его к воспроизведению.
Звуковые эффекты
SoundFXNone Удаляет любой звуковой эффект, прикреплённый к объекту.
SoundFXEcho Задаёт эффект эха для любого звука, привязанного к объекту.
SoundFXReverb Задаёт эффект реверберации для любого звука, привязанного к объекту.
Обработка событий
ApplyEvent Вызывает указанное событие для объекта.
CanHandleEvent Выясняет, имеет ли объект обработчик для указанного события.

Атрибуты

Parent (только для чтения) 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 (только для чтения) Returns a reference to the next control in z-order
PrevSibling (только для чтения) Returns a reference to the previous control in z-order
Type (только для чтения) Returns always "window"
NumControls (только для чтения) 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 Внутреннее имя объекта.
Caption Заголовок объекта.
AccCaption Специальный заголовок объекта, используемый специальными фукциями движка для людей с ослабленным зрением.
X Координата X объекта.
Y Координата Y объекта.
Height (только для чтения) Возвращает текущую высоту объекта (учитывает масштаб персонажей).
Filename (только для чтения) Возвращает имя файла объекта.
Ready (только для чтения) Возвращает true, если объект в настоящий момент не совершает никакого действия.
Interactive Указывает, должен ли объект реагировать на действия пользователя (быть интерактивным).
SoundPanning Указывает, должен ли звук, воспроизводимый данным объектом, панорамироваться в зависимости от его позиции на экране.
NonIntMouseEvents Указывает, должен ли объект реагировать на события MouseEntry и MouseLeave, даже в том случае, если игра работает в неинтерактивном режиме.
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.

Низкоуровневые события

LeftClick Была нажата левая кнопка мыши.
RightClick Была нажата правая кнопка мыши.
MiddleClick Была нажата средняя кнопка мыши.
LeftDoubleClick Был сделан двойной щелчок левой кнопкой мыши.
RightDoubleClick Был сделан двойной щелчок правой кнопкой мыши.
LeftRelease Была отпущена левая кнопка мыши.
RightRelease Была отпущена правая кнопка мыши.
MiddleRelease Была отпущена средняя кнопка мыши.
MouseWheelUp Колёсико мыши было прокручено вверх.
MouseWheelDown Колёсико мыши было прокручено вниз.
Keypress Была нажата клавиша. Для выяснения деталей (какая клавиша была нажата и др.), используйте переменную Keyboard.

SetFont(Filename)

Sets a normal font.

Параметры

Filename
A filename of a font file to be used.

Возвращаемое значение

If the method succeeds, the return value is true.


SetImage(Filename)

Sets a background image (sprite).

Параметры

Filename
A filename of a sprite file to be used.

Возвращаемое значение

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.

Параметры

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

Возвращаемое значение

If the method succeeds, the return value is true.


MoveBefore(Control)
MoveBefore(ControlName)

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

Параметры

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

Возвращаемое значение

If the method succeeds, the return value is true.


MoveToTop()

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

Возвращаемое значение

If the method succeeds, the return value is true.


MoveToBottom()

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

Возвращаемое значение

If the method succeeds, the return value is true.


SkipTo(X, Y)

Перемещает объект в указанную точку.

Параметры

X
Координата X.
Y
Координата Y.

GetControl(ControlIndex)
GetControl(ControlName)

Get a reference to a given object contained in this window

Параметры

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

Возвращаемое значение

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

Примечания

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.

Параметры

Filename
A filename of a font file to be used.

Возвращаемое значение

If the method succeeds, the return value is true.


SetInactiveImage(Filename)

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

Параметры

Filename
A filename of a sprite file to be used.

Возвращаемое значение

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.

Возвращаемое значение

If the method succeeds, the return value is true.

Примечания

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.

Примечания

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.

Примечания

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.

Параметры

Filename
A filename of a window file to be loaded.

Возвращаемое значение

If the method succeeds, the return value is true.


CreateButton(Name)

Dynamically creates a new button control

Параметры

Name
The name of the button (optional)

Возвращаемое значение

Returns the newly created button object

Примечания

Use the DeleteButton method to remove the button.


CreateStatic(Name)

Dynamically creates a new static control

Параметры

Name
The name of the control (optional)

Возвращаемое значение

Returns the newly created static control object

Примечания

Use the DeleteStatic method to remove the control.


CreateEditor(Name)

Dynamically creates a new editor control

Параметры

Name
The name of the editor (optional)

Возвращаемое значение

Returns the newly created editor object

Примечания

Use the DeleteEditor method to remove the editor.


CreateWindow(Name)

Dynamically creates a new sub-window control

Параметры

Name
The name of the window (optional)

Возвращаемое значение

Returns the newly created window object

Примечания

Use the DeleteWindow method to remove the window.


DeleteButton(Button)

Deletes a button object

Параметры

Button
The button to be deleted

DeleteStatic(Static)

Deletes a static control object

Параметры

Static
The static control to be deleted

DeleteEditor(Editor)

Deletes an editor object

Параметры

Editor
The editor control to be deleted

DeleteWindow(Window)

Deletes a window object

Параметры

Window
The window control to be deleted

SetCursor(Filename)

Устанавливает стандартный курсор.

Параметры

Filename
Имя файла спрайта, который будет использоваться в качестве указателя.

Возвращаемое значение

Возвращает true в случае успеха.


GetCursor()

Возвращает имя файла спрайта курсора или null, если курсор не задан


GetCursorObject()

Возвращает ссылку на спрайт курсора (объект) или null, если курсор не задан


RemoveCursor()

Удаляет стандартный курсор.


HasCursor()

Выясняет, задан ли стандартный курсор для объекта.

Возвращаемое значение

Возвращает true, если для объекта задан свой собственный стандартный курсор.


AttachScript(Filename)

Выполняет файл сценария и прикрепляет его к объекту.

Параметры

Filename
Имя файла сценария.

Возвращаемое значение

Возвращает true, если сценарий был успешно выполнен.

Примечания

К каждому объекту WME можно прикреплять несколько сценариев.


DetachScript(Filename, KillThreads)

Выгружает из памяти файл сценария и удаляет его связку с объектом.

Параметры

Filename
Имя файла сценария.
KillThreads
Указывает, нужно ли выгружать из памяти всё запущенные экземляры (threads) этого сценария (необязательный параметр, по умолчанию = false)

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.

Примечания

Экземпляры сценария (threads) - это исполняемые в настоящий момент обработчики событий и методы, которые тем или иным образом включают в себя выполнение данного сценария.


IsScriptRunning(Filename)

Выясняет, прикреплён ли указанный файл сценария к объекту.

Параметры

Filename
Имя файла сценария.

Возвращаемое значение

Возвращает true, если указанный сценарий прикреплён к объекту.


CanHandleMethod(MethodName)

Выясняет, поддерживает ли объект метод с указанным именем.

Параметры

MethodName
Название метода.

Возвращаемое значение

Возвращает true, если объект поддерживает метод с указанным именем.


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

Воспроизводит звук. Если имя файла не указано, воспроизводится прикреплённый на настоящий момент звук (если есть).

Параметры

Filename
Имя звукового файла
Looping
Указывает, нужно ли зациклить воспроизведение звука (необязательный параметр, по умолчанию = false).
LoopStart
Позиция в мс, с которой будет начинаться воспроизведение при включённом зацикливании (необязательный параметр, по умолчанию = 0).

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


PlaySoundEvent(Filename, EventName)
PlaySoundEvent(EventName)

Воспроизводит звук и генерирует событие, когда воспроизведение закончится. Если имя файла не указано, воспроизводится прикреплённый на настоящий момент звук (если есть).

Параметры

Filename
Имя звукового файла
EventName
Имя события, которое будет сгенерировано после окончания воспроизведения звука.

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


StopSound()

Останавливает воспроизведение звука (если есть).

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


PauseSound()

Ставит на паузу воспроизведение звука.

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


ResumeSound()

Продолжает воспроизведение после паузы.

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


IsSoundPlaying()

Выясняет, воспроизводится ли в настоящий момент звуковой файл.

Возвращаемое значение

Если звук воспроизводится, метод вернёт true.


SetSoundPosition(Time)

Задаёт текущую позицию для воспроизведения в звуковом файле.

Параметры

Time
Новая позиция в мс

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


GetSoundPosition()

Возвращает текущую позицию для воспроизведения в звуковом файле

Возвращаемое значение

Позиция в мс.


SetSoundVolume(Volume)

Устанавливает громкость звука.

Параметры

Volume
Уровень громкости в процентах.

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.


GetSoundVolume()

Возвращает значение уровня громкости звука.

Возвращаемое значение

Текущий уровень громкости в процентах.


LoadSound(Filename)

Инициализирует звук из файла, подготавливая его к воспроизведению.

Параметры

Filename
Имя звукового файла.

Возвращаемое значение

В случае удачного выполнения, метод вернёт значение true.

Примечания

Этот метод используется для кэширования звуковых файлов. Инициализация звука занимает некоторое время, поэтому желательно разместить её в стартовом сценарии сцены, чтобы метод PlaySound не замедлял игру. Для этой цели и служит метод LoadSound. Чтобы воспроизвести кэшированный звук, нужно просто вызвать метод PlaySound без указания имени файла, например, SomeObject.PlaySound(false);


SoundFXNone()

Удаляет любой звуковой эффект, прикреплённый к объекту.


SoundFXEcho(WetDryMix, Feedback, LeftDelay, RightDelay)

Задаёт эффект эха для любого звука, привязанного к объекту.

Параметры

WetDryMix
Микс влажность/сухость, в процентах (0 - 100)
Feedback
Обратная отдача, в процентах (0 - 100)
LeftDelay
Задержка слева, в мс (1 - 2000)
RightDelay
Задержка справа, в мс (1 - 2000)

Примечания

Пример: actor.SoundFXEcho(50, 50);


SoundFXReverb(InGain, ReverbMix, ReverbTime, HighFreqRTRatio)

Задаёт эффект реверберации для любого звука, привязанного к объекту.

Параметры

InGain
Прирост, в дБ (-96 - 0)
ReverbMix
Реверберация, в дБ (-96 - 0)
ReverbTime
Время реверберации, в мс (0.001 - 3000)
HighFreqRTRatio
Коэффициент высоких частот (0.001 - 0.999)

Примечания

Пример: actor.SoundFXReverb(0, 0, 2000);


ApplyEvent(EventName)

Вызывает указанное событие для объекта.

Параметры

EventName
Имя события.

Возвращаемое значение

Возвращает true, если событие было вызвано успешно.


CanHandleEvent(EventName)

Выясняет, имеет ли объект обработчик для указанного события.

Параметры

EventName
Имя события.

Возвращаемое значение

Возвращает true, если объект может обрабатывать запрашиваемое событие.