#include "..\script_component.hpp"

/*
 * File: fnc_handleUIEvents.sqf
 * Author: IDSolutions
 * Date: 2026-01-28
 * Last Update: 2026-01-31
 * 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(ActorClass) call ["getNearbyActions", [_control]]; };
    case "actor::open::atm": { [true] spawn EFUNC(bank,openUI); };
    case "actor::open::bank": { [] spawn EFUNC(bank,openUI); };
    case "actor::open::device": { hint "Device interaction is not yet implemented."; };
    case "actor::open::garage": { hint "Garage interaction is not yet implemented."; };
    case "actor::open::vgarage": { [] spawn EFUNC(garage,openVG); };
    case "actor::open::org": { [] spawn EFUNC(org,openUI); };
    case "actor::open::vlocker": { ["Open", [false, FORGE_Locker_Box, player]] spawn BFUNC(arsenal) };
    case "actor::open::phone": { hint "Phone interaction is not yet implemented."; };
    case "actor::open::iplayer": { hint "Player interaction is not yet implemented." };
    case "actor::open::store": { hint "Store interaction is not yet implemented."; };
    default { hint format ["Unhandled UI event: %1", _event]; };
};

if (_event isNotEqualTo "actor::get::actions") then { closeDialog 1; };

true;
