Allow setting CGUISize properties directly
Previously, modifying individual CGUISize properties (left, top, right,
bottom) via JavaScript had no effect unless the entire size object was
copied, modified, and reassigned—resulting in verbose and error-prone
code.
This update introduces proper JavaScript property accessors, enabling
direct reading and writing of CGUISize members. The result is a more
intuitive and scriptable API.
Key Changes:
- Implemented JavaScript get/set accessors for each CGUISize property,
directly interacting with the native object.
- Retained support for string assignments to CGUISize
- Maintained the GUISize JS object for backward compatibility, also
marked as deprecated.
- Improved CGUISimpleSetting<CGUISize> to allow partial updates via
direct property access.
- allow assigning size from object with pixel and percent values
You can now assign size using an object with properties like:
size = {
left: number, right: number, top: number, bottom: number,
rleft: number, rright: number, rtop: number, rbottom: number
}
- One or more properties can be specified, the missing properties with
fill as zero.
- Assignment triggers an immediate update event.
Delayed Setting Notifications:
- Introduced a mechanism for delayed setting notifications, currently
only used in CGUISimpleSetting<CGUISize>, to avoid redundant
recalculations.
- Ensured that getComputedSize triggers any pending delayed
notifications before returning the size.
This change significantly enhances the developer experience and brings
the behavior in line with typical expectations for direct property
manipulation in JavaScript.
2025-06-04 14:22:34 -07:00
|
|
|
/* Copyright (C) 2025 Wildfire Games.
|
2023-12-02 16:30:12 -08:00
|
|
|
* This file is part of 0 A.D.
|
2010-01-09 11:20:14 -08:00
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2010-01-09 11:20:14 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2010-01-09 11:20:14 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-02 16:30:12 -08:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-09 11:20:14 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
2019-09-22 16:28:25 -07:00
|
|
|
#include "ScriptFunctions.h"
|
2010-01-09 11:20:14 -08:00
|
|
|
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "graphics/scripting/JSInterface_GameView.h"
|
Allow setting CGUISize properties directly
Previously, modifying individual CGUISize properties (left, top, right,
bottom) via JavaScript had no effect unless the entire size object was
copied, modified, and reassigned—resulting in verbose and error-prone
code.
This update introduces proper JavaScript property accessors, enabling
direct reading and writing of CGUISize members. The result is a more
intuitive and scriptable API.
Key Changes:
- Implemented JavaScript get/set accessors for each CGUISize property,
directly interacting with the native object.
- Retained support for string assignments to CGUISize
- Maintained the GUISize JS object for backward compatibility, also
marked as deprecated.
- Improved CGUISimpleSetting<CGUISize> to allow partial updates via
direct property access.
- allow assigning size from object with pixel and percent values
You can now assign size using an object with properties like:
size = {
left: number, right: number, top: number, bottom: number,
rleft: number, rright: number, rtop: number, rbottom: number
}
- One or more properties can be specified, the missing properties with
fill as zero.
- Assignment triggers an immediate update event.
Delayed Setting Notifications:
- Introduced a mechanism for delayed setting notifications, currently
only used in CGUISimpleSetting<CGUISize>, to avoid redundant
recalculations.
- Ensured that getComputedSize triggers any pending delayed
notifications before returning the size.
This change significantly enhances the developer experience and brings
the behavior in line with typical expectations for direct property
manipulation in JavaScript.
2025-06-04 14:22:34 -07:00
|
|
|
#include "gui/Scripting/JSInterface_CGUISize.h"
|
2019-10-02 02:44:00 -07:00
|
|
|
#include "gui/Scripting/JSInterface_GUIManager.h"
|
|
|
|
|
#include "gui/Scripting/JSInterface_GUISize.h"
|
2014-04-20 13:03:57 -07:00
|
|
|
#include "i18n/scripting/JSInterface_L10n.h"
|
2013-11-16 10:38:40 -08:00
|
|
|
#include "lobby/scripting/JSInterface_Lobby.h"
|
2017-09-11 17:29:10 -07:00
|
|
|
#include "network/scripting/JSInterface_Network.h"
|
2013-09-29 11:56:50 -07:00
|
|
|
#include "ps/scripting/JSInterface_ConfigDB.h"
|
2013-09-21 07:48:19 -07:00
|
|
|
#include "ps/scripting/JSInterface_Console.h"
|
2017-09-11 19:25:28 -07:00
|
|
|
#include "ps/scripting/JSInterface_Debug.h"
|
2017-09-11 18:38:46 -07:00
|
|
|
#include "ps/scripting/JSInterface_Game.h"
|
Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.
Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.
Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.
Follows work in 3d7784d2af.
Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 01:27:26 -08:00
|
|
|
#include "ps/scripting/JSInterface_Hotkey.h"
|
2017-09-11 20:11:33 -07:00
|
|
|
#include "ps/scripting/JSInterface_Main.h"
|
2014-08-25 09:02:54 -07:00
|
|
|
#include "ps/scripting/JSInterface_Mod.h"
|
2018-04-24 06:12:08 -07:00
|
|
|
#include "ps/scripting/JSInterface_ModIo.h"
|
2017-09-11 16:22:28 -07:00
|
|
|
#include "ps/scripting/JSInterface_SavedGame.h"
|
2018-08-22 05:48:27 -07:00
|
|
|
#include "ps/scripting/JSInterface_UserReport.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "ps/scripting/JSInterface_VFS.h"
|
2015-09-21 10:00:21 -07:00
|
|
|
#include "ps/scripting/JSInterface_VisualReplay.h"
|
2013-09-21 01:24:45 -07:00
|
|
|
#include "renderer/scripting/JSInterface_Renderer.h"
|
2025-06-19 15:06:41 -07:00
|
|
|
#include "scriptinterface/ScriptRequest.h"
|
2017-09-11 18:53:46 -07:00
|
|
|
#include "simulation2/scripting/JSInterface_Simulation.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "soundmanager/scripting/JSInterface_Sound.h"
|
2010-01-09 11:20:14 -08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file defines a set of functions that are available to GUI scripts, to allow
|
|
|
|
|
* interaction with the rest of the engine.
|
|
|
|
|
* Functions are exposed to scripts within the global object 'Engine', so
|
|
|
|
|
* scripts should call "Engine.FunctionName(...)" etc.
|
|
|
|
|
*/
|
|
|
|
|
void GuiScriptingInit(ScriptInterface& scriptInterface)
|
|
|
|
|
{
|
2021-03-01 12:52:24 -08:00
|
|
|
ScriptRequest rq(scriptInterface);
|
|
|
|
|
|
2019-09-30 01:19:56 -07:00
|
|
|
JSI_GUISize::RegisterScriptClass(scriptInterface);
|
Allow setting CGUISize properties directly
Previously, modifying individual CGUISize properties (left, top, right,
bottom) via JavaScript had no effect unless the entire size object was
copied, modified, and reassigned—resulting in verbose and error-prone
code.
This update introduces proper JavaScript property accessors, enabling
direct reading and writing of CGUISize members. The result is a more
intuitive and scriptable API.
Key Changes:
- Implemented JavaScript get/set accessors for each CGUISize property,
directly interacting with the native object.
- Retained support for string assignments to CGUISize
- Maintained the GUISize JS object for backward compatibility, also
marked as deprecated.
- Improved CGUISimpleSetting<CGUISize> to allow partial updates via
direct property access.
- allow assigning size from object with pixel and percent values
You can now assign size using an object with properties like:
size = {
left: number, right: number, top: number, bottom: number,
rleft: number, rright: number, rtop: number, rbottom: number
}
- One or more properties can be specified, the missing properties with
fill as zero.
- Assignment triggers an immediate update event.
Delayed Setting Notifications:
- Introduced a mechanism for delayed setting notifications, currently
only used in CGUISimpleSetting<CGUISize>, to avoid redundant
recalculations.
- Ensured that getComputedSize triggers any pending delayed
notifications before returning the size.
This change significantly enhances the developer experience and brings
the behavior in line with typical expectations for direct property
manipulation in JavaScript.
2025-06-04 14:22:34 -07:00
|
|
|
JSI_CGUISize::RegisterScriptClass(scriptInterface);
|
2021-03-02 12:01:14 -08:00
|
|
|
JSI_ConfigDB::RegisterScriptFunctions(rq);
|
2021-03-01 12:52:24 -08:00
|
|
|
JSI_Console::RegisterScriptFunctions(rq);
|
2021-03-02 12:01:14 -08:00
|
|
|
JSI_Debug::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_GUIManager::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Game::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_GameView::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Hotkey::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_L10n::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Lobby::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Main::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Mod::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_ModIo::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Network::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Renderer::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_SavedGame::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Simulation::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_Sound::RegisterScriptFunctions(rq);
|
|
|
|
|
JSI_UserReport::RegisterScriptFunctions(rq);
|
2022-05-14 23:34:17 -07:00
|
|
|
JSI_VFS::RegisterScriptFunctions_ReadWriteAnywhere(rq);
|
2021-03-02 12:01:14 -08:00
|
|
|
JSI_VisualReplay::RegisterScriptFunctions(rq);
|
2010-01-09 11:20:14 -08:00
|
|
|
}
|