75 lines
2.2 KiB
Plaintext
75 lines
2.2 KiB
Plaintext
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
* Author: IDSolutions
|
|
* Handles the UI events.
|
|
*
|
|
* Arguments:
|
|
* None
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* call forge_client_org_fnc_handleUIEvents;
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_control", "_isConfirmDialog", "_message"];
|
|
|
|
private _alert = fromJSON _message;
|
|
private _event = _alert get "event";
|
|
private _data = _alert get "data";
|
|
// private _display = displayChild findDisplay 46;
|
|
|
|
private _fnc_execBridge = {
|
|
params ["_control", "_fnName", "_payload"];
|
|
|
|
private _json = toJSON _payload;
|
|
_control ctrlWebBrowserAction ["ExecJS", format ["OrgUIBridge.%1(%2)", _fnName, _json]];
|
|
};
|
|
|
|
diag_log format ["[FORGE:Client:Org] Handling UI event: %1 with data: %2", _event, _data];
|
|
|
|
switch (_event) do {
|
|
case "org::close": { closeDialog 1; };
|
|
case "org::login::request": {
|
|
private _orgData = GVAR(OrgClass) get "org";
|
|
private _orgId = _orgData getOrDefault ["id", ""];
|
|
private _orgName = _orgData getOrDefault ["name", ""];
|
|
|
|
if (_orgId isEqualTo "" && {_orgName isEqualTo ""}) exitWith {
|
|
[_control, "receiveLoginFailure", createHashMapFromArray [
|
|
["message", "No organization data is available for this player."]
|
|
]] call _fnc_execBridge;
|
|
};
|
|
|
|
private _payload = call FUNC(buildPortalPayload);
|
|
[_control, "receiveLoginSuccess", _payload] call _fnc_execBridge;
|
|
};
|
|
case "org::create::request": {
|
|
private _orgName = _data getOrDefault ["orgName", ""];
|
|
|
|
if (_orgName isEqualTo "") exitWith {
|
|
[_control, "receiveCreateFailure", createHashMapFromArray [
|
|
["message", "Enter an organization name."]
|
|
]] call _fnc_execBridge;
|
|
};
|
|
|
|
uiNamespace setVariable [QGVAR(PendingBrowserControl), _control];
|
|
[SRPC(org,requestCreateOrg), [getPlayerUID player, _orgName]] call CFUNC(serverEvent);
|
|
};
|
|
case "org::ready": {
|
|
[_control, "receive", createHashMapFromArray [
|
|
["event", "org::ready"],
|
|
["data", createHashMapFromArray [
|
|
["loaded", true]
|
|
]]
|
|
]] call _fnc_execBridge;
|
|
};
|
|
default { hint format ["Unhandled UI event: %1", _event]; };
|
|
};
|
|
|
|
true;
|