102 lines
4.1 KiB
Plaintext
102 lines
4.1 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
* File: fnc_handleUIEvents.sqf
|
|
* Author: IDSolutions
|
|
* Date: 2026-01-28
|
|
* Last Update: 2026-04-06
|
|
* Public: No
|
|
*
|
|
* Description:
|
|
* Handles the UI events.
|
|
*
|
|
* Arguments:
|
|
* 0: [CONTROL] - The control that triggered the event
|
|
* 1: [BOOL] - Whether the event is from a confirm dialog
|
|
* 2: [STRING] - The message containing the event data
|
|
*
|
|
* Return Value:
|
|
* UI events handled [BOOL]
|
|
*
|
|
* Example:
|
|
* call forge_client_actor_fnc_handleUIEvents;
|
|
*/
|
|
|
|
params ["_control", "_isConfirmDialog", "_message"];
|
|
|
|
private _alert = fromJSON _message;
|
|
private _event = _alert get "event";
|
|
private _data = _alert get "data";
|
|
|
|
diag_log format ["[FORGE:Client:Actor] Handling UI event: %1 with data: %2", _event, _data];
|
|
|
|
switch (_event) do {
|
|
case "actor::get::actions": { GVAR(ActorRepository) call ["getNearbyActions", [_control]]; };
|
|
case "actor::close::menu": { closeDialog 1; };
|
|
case "actor::open::atm": { [true] spawn EFUNC(bank,openUI); };
|
|
case "actor::open::bank": { [] spawn EFUNC(bank,openUI); };
|
|
case "actor::open::cad": { [] spawn EFUNC(cad,openUI); };
|
|
case "actor::open::device": { hint "Device interaction is not yet implemented."; };
|
|
case "actor::open::missionSetup": {
|
|
diag_log "[FORGE:Client:Actor] Requesting framework mission setup UI.";
|
|
[SRPC(task,requestOpenMissionSetup), [player]] call CFUNC(serverEvent);
|
|
};
|
|
case "actor::open::garage": {
|
|
private _garageObject = objNull;
|
|
if (_data isEqualType createHashMap) then {
|
|
private _netId = _data getOrDefault ["netId", ""];
|
|
if (_netId isNotEqualTo "") then { _garageObject = objectFromNetId _netId; };
|
|
};
|
|
[_garageObject] spawn EFUNC(garage,openUI);
|
|
};
|
|
case "actor::open::vgarage": {
|
|
private _garageObject = objNull;
|
|
if (_data isEqualType createHashMap) then {
|
|
private _netId = _data getOrDefault ["netId", ""];
|
|
if (_netId isNotEqualTo "") then { _garageObject = objectFromNetId _netId; };
|
|
};
|
|
[_garageObject] spawn EFUNC(garage,openVG);
|
|
};
|
|
case "actor::open::org": { [] spawn EFUNC(org,openUI); };
|
|
case "actor::open::vlocker": { [FORGE_Locker_Box, player, false] spawn AFUNC(arsenal,openBox) };
|
|
case "actor::open::phone": { [] spawn EFUNC(phone,openUI); };
|
|
case "actor::open::iplayer": { hint "Player interaction is not yet implemented." };
|
|
case "actor::open::store": { [] spawn EFUNC(store,openUI); };
|
|
case "actor::request::transport": {
|
|
if !(_data isEqualType createHashMap) exitWith {
|
|
hint "Invalid transport request.";
|
|
};
|
|
|
|
private _destination = _data getOrDefault ["destination", createHashMap];
|
|
if !(_destination isEqualType createHashMap) exitWith {
|
|
hint "Invalid transport destination.";
|
|
};
|
|
|
|
private _fromNode = objectFromNetId (_data getOrDefault ["netId", ""]);
|
|
private _toNode = objectFromNetId (_destination getOrDefault ["netId", ""]);
|
|
|
|
if (isNull _fromNode || { isNull _toNode }) exitWith {
|
|
hint "Transport destination is no longer available.";
|
|
};
|
|
|
|
private _options = createHashMapFromArray [
|
|
["label", _data getOrDefault ["label", "Transport"]],
|
|
["nodePrefix", _data getOrDefault ["nodePrefix", "transport"]],
|
|
["vehiclePrefix", _data getOrDefault ["vehiclePrefix", "transport_vehicle"]],
|
|
["arrivalPrefix", _data getOrDefault ["arrivalPrefix", "transport_arrival"]],
|
|
["maxIndexedNodes", _data getOrDefault ["maxIndexedNodes", 10]],
|
|
["baseFare", _data getOrDefault ["baseFare", 100]],
|
|
["pricePerKm", _data getOrDefault ["pricePerKm", 50]],
|
|
["cargoRadius", _data getOrDefault ["cargoRadius", 25]],
|
|
["includeCargo", _data getOrDefault ["includeCargo", true]]
|
|
];
|
|
|
|
[SRPC(transport,requestTransport), [player, _fromNode, _toNode, _options]] call CFUNC(serverEvent);
|
|
};
|
|
default { hint format ["Unhandled UI event: %1", _event]; };
|
|
};
|
|
|
|
if (_event isNotEqualTo "actor::get::actions") then { closeDialog 1; };
|
|
|
|
true;
|