AGS: Script API: Mouse.AutoLock

From upstream f49501a18b48767184e5f3d5da355405e29ad9e
This commit is contained in:
Walter Agazzi 2023-01-17 00:05:43 +01:00 committed by Thierry Crozat
parent c00d43685c
commit 43bdb0d5c5

View File

@ -316,6 +316,20 @@ void Mouse_EnableControl(bool on) {
_GP(usetup).mouse_ctrl_enabled = on; // remember setting in config
}
bool Mouse_IsAutoLocking() {
return _GP(usetup).mouse_auto_lock;
}
void Mouse_SetAutoLock(bool on) {
_GP(usetup).mouse_auto_lock = on;
if (_GP(scsystem).windowed) {
if (_GP(usetup).mouse_auto_lock)
_GP(mouse).TryLockToWindow();
else
_GP(mouse).UnlockFromWindow();
}
}
//=============================================================================
int GetMouseCursor() {
@ -546,6 +560,13 @@ RuntimeScriptValue Sc_Mouse_SetControlEnabled(const RuntimeScriptValue *params,
API_SCALL_VOID_PBOOL(Mouse_EnableControl);
}
RuntimeScriptValue Sc_Mouse_GetAutoLock(const RuntimeScriptValue *params, int32_t param_count) {
API_SCALL_BOOL(Mouse_IsAutoLocking);
}
RuntimeScriptValue Sc_Mouse_SetAutoLock(const RuntimeScriptValue *params, int32_t param_count) {
API_SCALL_VOID_PBOOL(Mouse_SetAutoLock);
}
RuntimeScriptValue Sc_Mouse_GetSpeed(const RuntimeScriptValue *params, int32_t param_count) {
API_SCALL_FLOAT(_GP(mouse).GetSpeed);
@ -576,6 +597,8 @@ void RegisterMouseAPI() {
ccAddExternalStaticFunction("Mouse::Update^0", Sc_RefreshMouse);
ccAddExternalStaticFunction("Mouse::UseDefaultGraphic^0", Sc_set_default_cursor);
ccAddExternalStaticFunction("Mouse::UseModeGraphic^1", Sc_set_mouse_cursor);
ccAddExternalStaticFunction("Mouse::get_AutoLock", Sc_Mouse_GetAutoLock);
ccAddExternalStaticFunction("Mouse::set_AutoLock", Sc_Mouse_SetAutoLock);
ccAddExternalStaticFunction("Mouse::get_ControlEnabled", Sc_Mouse_GetControlEnabled);
ccAddExternalStaticFunction("Mouse::set_ControlEnabled", Sc_Mouse_SetControlEnabled);
ccAddExternalStaticFunction("Mouse::get_Mode", Sc_GetCursorMode);