#include "..\script_component.hpp" /* * File: fnc_initUI.sqf * Author: IDSolutions * Date: 2026-03-28 * Public: No * * Description: * Initializes the CAD map dialog controls and local map event handling. * * Arguments: * 0: Display [DISPLAY] * * Return Value: * UI initialized [BOOL] * * Example: * [_display] call forge_client_cad_fnc_initUI */ params [["_display", displayNull, [displayNull]]]; if (isNull _display) exitWith { false }; private _mapCtrl = _display displayCtrl 1001; private _topBarCtrl = _display displayCtrl 1002; private _bottomBarCtrl = _display displayCtrl 1003; private _sidePanelCtrl = _display displayCtrl 1005; uiNamespace setVariable [QGVAR(Display), _display]; uiNamespace setVariable [QGVAR(MapCtrl), _mapCtrl]; uiNamespace setVariable [QGVAR(TopBarCtrl), _topBarCtrl]; uiNamespace setVariable [QGVAR(BottomBarCtrl), _bottomBarCtrl]; uiNamespace setVariable [QGVAR(SidePanelCtrl), _sidePanelCtrl]; private _center = if (isNull player) then { [worldSize / 2, worldSize / 2, 0] } else { getPosATL player }; _mapCtrl ctrlMapAnimAdd [0, 0.2, _center]; ctrlMapAnimCommit _mapCtrl; _mapCtrl ctrlAddEventHandler ["MouseButtonClick", { params ["_ctrl", "_button", "_xPos", "_yPos"]; private _worldPos = _ctrl ctrlMapScreenToWorld [_xPos, _yPos]; private _bottomBar = uiNamespace getVariable [QGVAR(BottomBarCtrl), controlNull]; if (isNull _bottomBar) exitWith {}; private _jsCode = format [ "updateStatus('Clicked at: %1, %2');", round (_worldPos # 0), round (_worldPos # 1) ]; _bottomBar ctrlWebBrowserAction ["ExecJS", _jsCode]; }]; _mapCtrl ctrlAddEventHandler ["MouseMoving", { params ["_ctrl", "_xPos", "_yPos"]; private _worldPos = _ctrl ctrlMapScreenToWorld [_xPos, _yPos]; private _topBar = uiNamespace getVariable [QGVAR(TopBarCtrl), controlNull]; if (isNull _topBar) exitWith {}; private _jsCode = format [ "updateCoordinates(%1, %2);", _worldPos # 0, _worldPos # 1 ]; _topBar ctrlWebBrowserAction ["ExecJS", _jsCode]; }]; [] spawn { while { !isNull (uiNamespace getVariable [QGVAR(Display), displayNull]) } do { private _mapCtrl = uiNamespace getVariable [QGVAR(MapCtrl), controlNull]; private _topBar = uiNamespace getVariable [QGVAR(TopBarCtrl), controlNull]; if (!isNull _mapCtrl && { !isNull _topBar }) then { _topBar ctrlWebBrowserAction ["ExecJS", format ["updateScale(%1);", round (ctrlMapScale _mapCtrl)]]; }; sleep 0.5; }; }; diag_log "[FORGE:Client:CAD] CAD UI initialized."; true