2015-07-15 11:03:54 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike
|
|
|
|
* Handles spectator interface events
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Event name <STRING>
|
|
|
|
* 1: Event arguments <ANY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None <NIL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* ["onLoad",_this] call ace_spectator_fnc_handleInterface
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-07-18 17:46:46 +00:00
|
|
|
params ["_mode",["_args",[]]];
|
2015-07-15 11:03:54 +00:00
|
|
|
|
|
|
|
switch (toLower _mode) do {
|
|
|
|
case "onload": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_display"];
|
2016-01-13 18:28:36 +00:00
|
|
|
SETUVAR(GVAR(interface),_display);
|
2015-07-18 17:46:46 +00:00
|
|
|
|
2015-07-18 14:42:07 +00:00
|
|
|
// Always show interface and hide map upon opening
|
2015-07-20 21:45:11 +00:00
|
|
|
[_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(toggleInterface);
|
2015-07-15 11:03:54 +00:00
|
|
|
|
2016-05-11 15:01:07 +00:00
|
|
|
// Initalize the unit tree
|
|
|
|
["onUnitsUpdate",[(_display displayCtrl IDC_UNIT) controlsGroupCtrl IDC_UNIT_TREE]] call FUNC(handleInterface);
|
|
|
|
|
2015-07-24 18:02:27 +00:00
|
|
|
// Keep unit list and tree up to date
|
2016-05-11 15:01:07 +00:00
|
|
|
[FUNC(handleUnits), 9, _display] call CBA_fnc_addPerFrameHandler;
|
2015-07-19 01:25:52 +00:00
|
|
|
|
2015-08-07 17:59:48 +00:00
|
|
|
// Handle 3D unit icons
|
2017-02-14 16:54:37 +00:00
|
|
|
GVAR(iconHandler) = addMissionEventHandler ["Draw3D", {call FUNC(handleIcons)}];
|
2015-08-06 12:42:31 +00:00
|
|
|
|
2015-08-07 00:44:32 +00:00
|
|
|
// Populate the help window
|
2016-09-04 14:44:22 +00:00
|
|
|
private _help = (_display displayCtrl IDC_HELP) controlsGroupCtrl IDC_HELP_LIST;
|
2015-07-21 22:20:41 +00:00
|
|
|
{
|
2015-08-07 00:44:32 +00:00
|
|
|
_i = _help lbAdd (_x select 0);
|
|
|
|
if ((_x select 1) == "") then {
|
|
|
|
_help lbSetPicture [_i,"\A3\ui_f\data\map\markers\military\dot_CA.paa"];
|
|
|
|
_help lbSetPictureColor [_i,[COL_FORE]];
|
|
|
|
} else {
|
|
|
|
_help lbSetTooltip [_i,_x select 1];
|
2015-07-24 16:50:33 +00:00
|
|
|
};
|
2015-07-21 22:20:41 +00:00
|
|
|
} forEach [
|
2015-07-24 16:50:33 +00:00
|
|
|
[localize LSTRING(uiControls),""],
|
2015-11-18 15:18:21 +00:00
|
|
|
[localize LSTRING(uiToggleUnits),keyName 2],
|
|
|
|
[localize LSTRING(uiToggleHelp),keyName 3],
|
|
|
|
[localize LSTRING(uiToggleTools),keyName 4],
|
|
|
|
[localize LSTRING(uiToggleCompass),keyName 5],
|
|
|
|
[localize LSTRING(uiToggleIcons),keyName 6],
|
|
|
|
[localize LSTRING(uiToggleMap),keyName 50],
|
|
|
|
[localize LSTRING(uiToggleInterface),keyName 14],
|
2015-08-07 00:44:32 +00:00
|
|
|
[localize LSTRING(freeCamControls),""],
|
2015-11-18 15:18:21 +00:00
|
|
|
[localize LSTRING(freeCamForward),keyName 17],
|
|
|
|
[localize LSTRING(freeCamBackward),keyName 31],
|
|
|
|
[localize LSTRING(freeCamLeft),keyName 30],
|
|
|
|
[localize LSTRING(freeCamRight),keyName 32],
|
|
|
|
[localize LSTRING(freeCamUp),keyName 16],
|
|
|
|
[localize LSTRING(freeCamDown),keyName 44],
|
2015-07-24 10:23:14 +00:00
|
|
|
[localize LSTRING(freeCamPan),"RMB (Hold)"],
|
|
|
|
[localize LSTRING(freeCamDolly),"LMB (Hold)"],
|
2015-08-07 17:59:48 +00:00
|
|
|
[localize LSTRING(freeCamBoost),"Shift (Hold)"],
|
2015-08-08 17:31:37 +00:00
|
|
|
[localize LSTRING(attributeControls),""],
|
2015-11-18 15:18:21 +00:00
|
|
|
[localize LSTRING(nextCam),keyName 200],
|
|
|
|
[localize LSTRING(prevCam),keyName 208],
|
|
|
|
[localize LSTRING(nextUnit),keyName 205],
|
|
|
|
[localize LSTRING(prevUnit),keyName 203],
|
|
|
|
[localize LSTRING(nextVis),keyName 49],
|
|
|
|
[localize LSTRING(prevVis),format["%1 + %2",keyName 29,keyname 49]],
|
2015-08-08 17:31:37 +00:00
|
|
|
[localize LSTRING(adjZoom),"Scrollwheel"],
|
2015-11-18 15:18:21 +00:00
|
|
|
[localize LSTRING(adjSpeed),format["%1 + Scrollwheel",keyName 29]],
|
|
|
|
[localize LSTRING(incZoom),format["%1/%2",keyName 74,keyName 78]],
|
|
|
|
[localize LSTRING(incSpeed),format["%1 + %2/%3",keyName 29,keyName 74,keyName 78]],
|
|
|
|
[localize LSTRING(reZoom),format["%1 + %2",keyName 56,keyName 74]],
|
|
|
|
[localize LSTRING(reSpeed),format["%1 + %2",keyName 56,keyName 78]]
|
2015-07-21 22:20:41 +00:00
|
|
|
];
|
|
|
|
|
2015-08-05 18:25:38 +00:00
|
|
|
// Handle support for BI's respawn counter
|
|
|
|
[{
|
|
|
|
if !(isNull (GETUVAR(RscRespawnCounter,displayNull))) then {
|
|
|
|
disableSerialization;
|
|
|
|
private ["_counter","_title","_back","_timer","_frame","_x","_y"];
|
|
|
|
_counter = GETUVAR(RscRespawnCounter,displayNull);
|
|
|
|
_title = _counter displayCtrl 1001;
|
|
|
|
_back = _counter displayCtrl 1002;
|
|
|
|
_timer = _counter displayCtrl 1003;
|
|
|
|
_frame = _counter ctrlCreate ["RscFrame",1008];
|
|
|
|
|
|
|
|
_x = safeZoneX + safeZoneW - TOOL_W * 4 - MARGIN * 3;
|
|
|
|
_y = safeZoneY + safeZoneH - TOOL_H;
|
|
|
|
|
|
|
|
// Timer
|
|
|
|
_title ctrlSetPosition [_x,_y,TOOL_W,TOOL_H];
|
|
|
|
_back ctrlSetPosition [_x,_y,TOOL_W,TOOL_H];
|
|
|
|
_timer ctrlSetPosition [_x,_y,TOOL_W,TOOL_H];
|
|
|
|
_frame ctrlSetPosition [_x,_y,TOOL_W,TOOL_H];
|
2015-08-07 11:30:50 +00:00
|
|
|
|
|
|
|
_title ctrlSetBackgroundColor [0,0,0,0];
|
|
|
|
_back ctrlSetBackgroundColor [COL_BACK];
|
2015-08-05 18:25:38 +00:00
|
|
|
_timer ctrlSetFontHeight TOOL_H;
|
2015-08-07 11:30:50 +00:00
|
|
|
_frame ctrlSetTextColor [COL_FORE];
|
2015-08-05 18:25:38 +00:00
|
|
|
|
|
|
|
_title ctrlCommit 0;
|
|
|
|
_back ctrlCommit 0;
|
|
|
|
_timer ctrlCommit 0;
|
|
|
|
_frame ctrlCommit 0;
|
|
|
|
};
|
2016-05-22 13:27:24 +00:00
|
|
|
},[],0.5] call CBA_fnc_waitAndExecute;
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
|
|
|
case "onunload": {
|
2015-08-02 23:22:50 +00:00
|
|
|
// Kill GUI PFHs
|
2015-08-21 23:26:01 +00:00
|
|
|
removeMissionEventHandler ["Draw3D",GVAR(iconHandler)];
|
2015-07-18 16:06:13 +00:00
|
|
|
GVAR(camHandler) = nil;
|
2015-07-24 18:02:27 +00:00
|
|
|
GVAR(compHandler) = nil;
|
2015-07-25 11:28:03 +00:00
|
|
|
GVAR(iconHandler) = nil;
|
2015-07-24 18:02:27 +00:00
|
|
|
GVAR(toolHandler) = nil;
|
2015-08-21 23:26:01 +00:00
|
|
|
|
|
|
|
// Reset variables
|
|
|
|
GVAR(camBoom) = 0;
|
|
|
|
GVAR(camDolly) = [0,0];
|
|
|
|
GVAR(ctrlKey) = false;
|
|
|
|
GVAR(heldKeys) = [];
|
|
|
|
GVAR(heldKeys) resize 255;
|
|
|
|
GVAR(mouse) = [false,false];
|
|
|
|
GVAR(mousePos) = [0.5,0.5];
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
2015-07-15 11:11:19 +00:00
|
|
|
// Mouse events
|
|
|
|
case "onmousebuttondown": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_ctrl","_button"];
|
2015-07-15 11:11:19 +00:00
|
|
|
GVAR(mouse) set [_button,true];
|
2015-07-15 11:33:32 +00:00
|
|
|
|
|
|
|
// Detect right click
|
|
|
|
if ((_button == 1) && (GVAR(camMode) == 1)) then {
|
2015-07-15 13:33:11 +00:00
|
|
|
// In first person toggle sights mode
|
2015-07-21 17:05:29 +00:00
|
|
|
GVAR(camGun) = !GVAR(camGun);
|
2015-07-20 21:45:11 +00:00
|
|
|
[] call FUNC(transitionCamera);
|
2015-07-15 11:33:32 +00:00
|
|
|
};
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case "onmousebuttonup": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_ctrl","_button"];
|
|
|
|
|
2015-07-15 11:11:19 +00:00
|
|
|
GVAR(mouse) set [_button,false];
|
2015-07-21 17:44:24 +00:00
|
|
|
if (_button == 0) then { GVAR(camDolly) = [0,0]; };
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case "onmousezchanged": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_ctrl","_zChange"];
|
2015-07-15 11:33:32 +00:00
|
|
|
|
2015-09-09 22:21:49 +00:00
|
|
|
// Scroll to modify distance value in third person
|
|
|
|
if (GVAR(camMode) == 0) then {
|
|
|
|
// Scroll to change speed, modifier for zoom
|
|
|
|
if (GVAR(ctrlKey)) then {
|
|
|
|
[nil,nil,nil,nil,nil,nil,nil, GVAR(camSpeed) + _zChange * 0.2] call FUNC(setCameraAttributes);
|
|
|
|
} else {
|
|
|
|
[nil,nil,nil,nil,nil,nil, GVAR(camZoom) + _zChange * 0.1] call FUNC(setCameraAttributes);
|
|
|
|
};
|
2015-08-07 17:59:48 +00:00
|
|
|
} else {
|
2015-09-09 22:21:49 +00:00
|
|
|
GVAR(camDistance) = ((GVAR(camDistance) - _zChange * 2) max 5) min 50;
|
2015-07-15 11:33:32 +00:00
|
|
|
};
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case "onmousemoving": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_ctrl","_x","_y"];
|
2015-07-15 11:11:19 +00:00
|
|
|
|
2015-07-18 15:59:05 +00:00
|
|
|
[_x,_y] call FUNC(handleMouse);
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
2015-07-15 11:03:54 +00:00
|
|
|
// Keyboard events
|
|
|
|
case "onkeydown": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_display","_dik","_shift","_ctrl","_alt"];
|
2015-07-15 11:03:54 +00:00
|
|
|
|
2015-08-05 23:52:39 +00:00
|
|
|
if ((alive player) && {_dik in (actionKeys "curatorInterface")} && {!isNull (getAssignedCuratorLogic player)}) exitWith {
|
2015-08-21 23:26:01 +00:00
|
|
|
[QGVAR(zeus)] call FUNC(interrupt);
|
|
|
|
["zeus"] call FUNC(handleInterface);
|
2015-08-05 23:52:39 +00:00
|
|
|
};
|
2015-11-22 20:03:10 +00:00
|
|
|
if (_dik in (actionKeys "Chat")) exitWith {
|
2015-08-08 12:19:07 +00:00
|
|
|
false
|
|
|
|
};
|
2015-11-22 20:03:10 +00:00
|
|
|
if (_dik in (actionKeys "PrevChannel" + actionKeys "NextChannel")) exitWith {
|
|
|
|
!(isServer || serverCommandAvailable "#kick")
|
|
|
|
};
|
2015-08-05 23:52:39 +00:00
|
|
|
|
2015-07-24 10:12:26 +00:00
|
|
|
// Handle held keys (prevent repeat calling)
|
2015-11-30 16:14:05 +00:00
|
|
|
if (GVAR(heldKeys) param [_dik,false]) exitWith {};
|
2015-08-08 17:31:37 +00:00
|
|
|
// Exclude movement/adjustment keys so that speed can be adjusted on fly
|
|
|
|
if !(_dik in [16,17,30,31,32,44,74,78]) then {
|
2015-08-09 19:59:57 +00:00
|
|
|
GVAR(heldKeys) set [_dik,true];
|
2015-07-26 11:23:01 +00:00
|
|
|
};
|
2015-07-24 10:12:26 +00:00
|
|
|
|
2015-07-15 11:03:54 +00:00
|
|
|
switch (_dik) do {
|
|
|
|
case 1: { // Esc
|
2015-08-21 23:26:01 +00:00
|
|
|
[QGVAR(escape)] call FUNC(interrupt);
|
|
|
|
["escape"] call FUNC(handleInterface);
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
2015-07-19 21:50:13 +00:00
|
|
|
case 2: { // 1
|
2015-07-20 21:45:11 +00:00
|
|
|
[_display,nil,nil,nil,nil,nil,true] call FUNC(toggleInterface);
|
2015-07-19 21:50:13 +00:00
|
|
|
};
|
|
|
|
case 3: { // 2
|
2015-08-07 00:44:32 +00:00
|
|
|
[_display,nil,true] call FUNC(toggleInterface);
|
2015-07-19 21:50:13 +00:00
|
|
|
};
|
|
|
|
case 4: { // 3
|
2015-08-07 00:44:32 +00:00
|
|
|
[_display,nil,nil,nil,nil,true] call FUNC(toggleInterface);
|
2015-07-19 21:50:13 +00:00
|
|
|
};
|
2015-07-24 16:23:25 +00:00
|
|
|
case 5: { // 4
|
2015-08-07 00:44:32 +00:00
|
|
|
[_display,true] call FUNC(toggleInterface);
|
|
|
|
};
|
|
|
|
case 6: { // 5
|
2015-07-24 16:23:25 +00:00
|
|
|
GVAR(showIcons) = !GVAR(showIcons);
|
|
|
|
};
|
2015-07-15 11:03:54 +00:00
|
|
|
case 14: { // Backspace
|
2015-07-20 21:45:11 +00:00
|
|
|
[_display,nil,nil,true] call FUNC(toggleInterface);
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
2015-07-15 11:11:19 +00:00
|
|
|
case 16: { // Q
|
2015-08-07 17:59:48 +00:00
|
|
|
GVAR(camBoom) = 0.5 * GVAR(camSpeed) * ([1, 2] select _shift);
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 17: { // W
|
2015-08-07 17:59:48 +00:00
|
|
|
GVAR(camDolly) set [1, GVAR(camSpeed) * ([1, 2] select _shift)];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 29: { // Ctrl
|
|
|
|
GVAR(ctrlKey) = true;
|
|
|
|
};
|
|
|
|
case 30: { // A
|
2015-08-07 17:59:48 +00:00
|
|
|
GVAR(camDolly) set [0, -GVAR(camSpeed) * ([1, 2] select _shift)];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 31: { // S
|
2015-08-07 17:59:48 +00:00
|
|
|
GVAR(camDolly) set [1, -GVAR(camSpeed) * ([1, 2] select _shift)];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 32: { // D
|
2015-08-07 17:59:48 +00:00
|
|
|
GVAR(camDolly) set [0, GVAR(camSpeed) * ([1, 2] select _shift)];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 44: { // Z
|
2015-08-07 17:59:48 +00:00
|
|
|
GVAR(camBoom) = -0.5 * GVAR(camSpeed) * ([1, 2] select _shift);
|
2015-07-21 10:59:20 +00:00
|
|
|
};
|
|
|
|
case 49: { // N
|
2015-10-04 18:26:53 +00:00
|
|
|
if (GVAR(camMode) != 1) then {
|
2015-08-07 17:59:48 +00:00
|
|
|
if (_ctrl) then {
|
|
|
|
[nil,nil,-1] call FUNC(cycleCamera);
|
|
|
|
} else {
|
|
|
|
[nil,nil,1] call FUNC(cycleCamera);
|
|
|
|
};
|
2015-07-24 10:12:26 +00:00
|
|
|
};
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
2015-07-15 11:03:54 +00:00
|
|
|
case 50: { // M
|
2015-07-20 21:45:11 +00:00
|
|
|
[_display,nil,nil,nil,true] call FUNC(toggleInterface);
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
2015-07-15 11:33:32 +00:00
|
|
|
case 57: { // Spacebar
|
2015-11-18 15:18:21 +00:00
|
|
|
// Switch between unit and freecam here
|
2015-07-18 16:13:27 +00:00
|
|
|
};
|
2015-08-08 17:31:37 +00:00
|
|
|
case 74: { // Num -
|
|
|
|
if (_alt) exitWith { [nil,nil,nil,nil,nil,nil, 1.25] call FUNC(setCameraAttributes); };
|
|
|
|
if (_ctrl) then {
|
|
|
|
[nil,nil,nil,nil,nil,nil,nil, GVAR(camSpeed) - 0.05] call FUNC(setCameraAttributes);
|
|
|
|
} else {
|
|
|
|
[nil,nil,nil,nil,nil,nil, GVAR(camZoom) - 0.01] call FUNC(setCameraAttributes);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
case 78: { // Num +
|
2015-11-18 15:18:21 +00:00
|
|
|
if (_alt) exitWith { [nil,nil,nil,nil,nil,nil,nil, 1.5] call FUNC(setCameraAttributes); };
|
2015-08-08 17:31:37 +00:00
|
|
|
if (_ctrl) then {
|
|
|
|
[nil,nil,nil,nil,nil,nil,nil, GVAR(camSpeed) + 0.05] call FUNC(setCameraAttributes);
|
|
|
|
} else {
|
|
|
|
[nil,nil,nil,nil,nil,nil, GVAR(camZoom) + 0.01] call FUNC(setCameraAttributes);
|
|
|
|
};
|
|
|
|
};
|
2015-07-18 16:13:27 +00:00
|
|
|
case 200: { // Up arrow
|
2015-07-21 12:31:13 +00:00
|
|
|
[-1] call FUNC(cycleCamera);
|
2015-07-15 11:33:32 +00:00
|
|
|
};
|
2015-07-18 15:20:19 +00:00
|
|
|
case 203: { // Left arrow
|
2015-07-21 15:06:07 +00:00
|
|
|
[nil,1] call FUNC(cycleCamera);
|
2015-07-18 15:20:19 +00:00
|
|
|
};
|
|
|
|
case 205: { // Right arrow
|
2015-07-21 15:06:07 +00:00
|
|
|
[nil,-1] call FUNC(cycleCamera);
|
2015-07-18 15:20:19 +00:00
|
|
|
};
|
2015-07-18 18:05:18 +00:00
|
|
|
case 208: { // Down arrow
|
2015-07-21 12:31:13 +00:00
|
|
|
[1] call FUNC(cycleCamera);
|
2015-07-18 18:05:18 +00:00
|
|
|
};
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
true
|
|
|
|
};
|
|
|
|
case "onkeyup": {
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_display","_dik","_shift","_ctrl","_alt"];
|
2015-07-15 11:03:54 +00:00
|
|
|
|
2015-07-24 10:12:26 +00:00
|
|
|
// No longer being held
|
2015-08-09 19:59:57 +00:00
|
|
|
GVAR(heldKeys) set [_dik,nil];
|
2015-07-24 10:12:26 +00:00
|
|
|
|
2015-07-15 11:03:54 +00:00
|
|
|
switch (_dik) do {
|
2015-07-15 11:11:19 +00:00
|
|
|
case 16: { // Q
|
2015-07-21 17:26:49 +00:00
|
|
|
GVAR(camBoom) = 0;
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 17: { // W
|
2015-07-21 17:44:24 +00:00
|
|
|
GVAR(camDolly) set [1, 0];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 29: { // Ctrl
|
|
|
|
GVAR(ctrlKey) = false;
|
|
|
|
};
|
|
|
|
case 30: { // A
|
2015-07-21 17:44:24 +00:00
|
|
|
GVAR(camDolly) set [0, 0];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 31: { // S
|
2015-07-21 17:44:24 +00:00
|
|
|
GVAR(camDolly) set [1, 0];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 32: { // D
|
2015-07-21 17:44:24 +00:00
|
|
|
GVAR(camDolly) set [0, 0];
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
|
|
|
case 44: { // Z
|
2015-07-21 17:26:49 +00:00
|
|
|
GVAR(camBoom) = 0;
|
2015-07-15 11:11:19 +00:00
|
|
|
};
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
true
|
|
|
|
};
|
2015-07-16 16:01:04 +00:00
|
|
|
// Tree events
|
|
|
|
case "ontreedblclick": {
|
2015-07-16 17:31:49 +00:00
|
|
|
// Update camera view when listbox unit is double clicked on
|
2015-07-18 17:46:46 +00:00
|
|
|
_args params ["_tree","_sel"];
|
2015-07-16 17:31:49 +00:00
|
|
|
|
|
|
|
// Ensure a unit was selected
|
2015-07-20 16:42:11 +00:00
|
|
|
if (count _sel == 3) then {
|
2015-07-18 17:46:46 +00:00
|
|
|
private ["_netID","_newUnit","_newMode"];
|
2015-07-16 17:31:49 +00:00
|
|
|
_netID = (_args select 0) tvData _sel;
|
2015-07-16 18:43:16 +00:00
|
|
|
_newUnit = objectFromNetId _netID;
|
2015-07-16 17:31:49 +00:00
|
|
|
|
2015-07-16 20:37:20 +00:00
|
|
|
// When unit is reselected, toggle camera mode
|
|
|
|
if (_newUnit == GVAR(camUnit) || GVAR(camMode) == 0) then {
|
2015-07-17 00:52:08 +00:00
|
|
|
_newMode = [2,2,1] select GVAR(camMode);
|
2015-07-16 16:01:04 +00:00
|
|
|
};
|
2015-07-16 20:37:20 +00:00
|
|
|
|
2015-07-21 14:53:20 +00:00
|
|
|
[_newMode,_newUnit] call FUNC(transitionCamera);
|
2015-07-16 16:01:04 +00:00
|
|
|
};
|
|
|
|
};
|
2015-07-19 12:40:08 +00:00
|
|
|
case "onunitsupdate": {
|
2015-07-19 22:03:40 +00:00
|
|
|
_args params ["_tree"];
|
2016-05-11 12:30:17 +00:00
|
|
|
private ["_cachedUnits","_cachedGrps","_cachedSides","_sT","_gT","_uT","_s","_g","_u","_grp","_unit","_side"];
|
2015-07-19 12:40:08 +00:00
|
|
|
|
2015-08-06 23:05:21 +00:00
|
|
|
// Cache existing group and side nodes and cull removed data
|
|
|
|
_cachedUnits = [];
|
|
|
|
_cachedGrps = [];
|
|
|
|
_cachedSides = [];
|
2016-05-11 12:30:17 +00:00
|
|
|
// Track deleted nodes to account for decrease in index
|
|
|
|
_sT = _tree tvCount [];
|
|
|
|
for [{_s = 0;}, {_s < _sT}, {_s = _s + 1}] do {
|
|
|
|
_gT = _tree tvCount [_s];
|
|
|
|
|
|
|
|
for [{_g = 0;}, {_g < _gT}, {_g = _g + 1}] do {
|
2015-08-06 23:05:21 +00:00
|
|
|
_grp = groupFromNetID (_tree tvData [_s,_g]);
|
|
|
|
|
|
|
|
if (_grp in GVAR(groupList)) then {
|
|
|
|
_cachedGrps pushBack _grp;
|
|
|
|
_cachedGrps pushBack _g;
|
|
|
|
|
2016-05-11 12:30:17 +00:00
|
|
|
_uT = _tree tvCount [_s,_g];
|
|
|
|
for [{_u = 0;}, {_u < _uT}, {_u = _u + 1}] do {
|
2015-08-06 23:05:21 +00:00
|
|
|
_unit = objectFromNetId (_tree tvData [_s,_g,_u]);
|
|
|
|
|
|
|
|
if (_unit in GVAR(unitList)) then {
|
|
|
|
_cachedUnits pushBack _unit;
|
|
|
|
} else {
|
|
|
|
_tree tvDelete [_s,_g,_u];
|
2016-05-11 12:30:17 +00:00
|
|
|
_u = _u - 1;
|
|
|
|
_uT = _uT - 1;
|
2015-08-06 23:05:21 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_tree tvDelete [_s,_g];
|
2016-05-11 12:30:17 +00:00
|
|
|
_g = _g - 1;
|
|
|
|
_gT = _gT - 1;
|
2015-08-06 23:05:21 +00:00
|
|
|
};
|
|
|
|
};
|
2015-07-19 12:40:08 +00:00
|
|
|
|
2015-08-06 23:05:21 +00:00
|
|
|
if ((_tree tvCount [_s]) > 0) then {
|
|
|
|
_cachedSides pushBack (_tree tvText [_s]);
|
|
|
|
_cachedSides pushBack _s;
|
|
|
|
} else {
|
|
|
|
_tree tvDelete [_s];
|
2016-05-11 12:30:17 +00:00
|
|
|
_s = _s - 1;
|
|
|
|
_sT = _sT - 1;
|
2015-08-06 23:05:21 +00:00
|
|
|
};
|
|
|
|
};
|
2015-07-19 12:40:08 +00:00
|
|
|
|
|
|
|
// Update the tree from the unit list
|
|
|
|
{
|
|
|
|
_grp = group _x;
|
2015-07-24 14:53:08 +00:00
|
|
|
_side = [side _grp] call BIS_fnc_sideName;
|
2015-07-19 12:40:08 +00:00
|
|
|
|
2015-07-20 16:42:11 +00:00
|
|
|
// Use correct side node
|
2015-07-21 20:21:46 +00:00
|
|
|
if !(_side in _cachedSides) then {
|
|
|
|
// Add side node
|
2015-08-06 23:05:21 +00:00
|
|
|
_s = _tree tvAdd [[], _side];
|
|
|
|
_tree tvExpand [_s];
|
2015-07-21 20:21:46 +00:00
|
|
|
|
|
|
|
_cachedSides pushBack _side;
|
2015-08-06 23:05:21 +00:00
|
|
|
_cachedSides pushBack _s;
|
2015-07-21 20:21:46 +00:00
|
|
|
} else {
|
|
|
|
// If side already processed, use existing node
|
2015-08-06 23:05:21 +00:00
|
|
|
_s = _cachedSides select ((_cachedSides find _side) + 1);
|
2015-07-21 20:21:46 +00:00
|
|
|
};
|
2015-07-20 16:42:11 +00:00
|
|
|
|
|
|
|
// Use correct group node
|
|
|
|
if !(_grp in _cachedGrps) then {
|
|
|
|
// Add group node
|
2015-08-06 23:05:21 +00:00
|
|
|
_g = _tree tvAdd [[_s], groupID _grp];
|
|
|
|
_tree tvSetData [[_s,_g], netID _grp];
|
2015-07-19 12:40:08 +00:00
|
|
|
|
|
|
|
_cachedGrps pushBack _grp;
|
2015-08-06 23:05:21 +00:00
|
|
|
_cachedGrps pushBack _g;
|
2015-07-19 12:40:08 +00:00
|
|
|
} else {
|
2015-07-20 16:42:11 +00:00
|
|
|
// If group already processed, use existing node
|
2015-08-06 23:05:21 +00:00
|
|
|
_g = _cachedGrps select ((_cachedGrps find _grp) + 1);
|
2015-07-19 12:40:08 +00:00
|
|
|
};
|
|
|
|
|
2015-08-06 23:05:21 +00:00
|
|
|
_u = _tree tvAdd [[_s,_g], GETVAR(_x,GVAR(uName),"")];
|
|
|
|
_tree tvSetData [[_s,_g,_u], netID _x];
|
|
|
|
_tree tvSetPicture [[_s,_g,_u], GETVAR(_x,GVAR(uIcon),"")];
|
|
|
|
_tree tvSetPictureColor [[_s,_g,_u], GETVAR(_grp,GVAR(gColor),[ARR_4(1,1,1,1)])];
|
2015-07-19 12:40:08 +00:00
|
|
|
|
2015-08-06 23:05:21 +00:00
|
|
|
_tree tvSort [[_s,_g],false];
|
|
|
|
} forEach (GVAR(unitList) - _cachedUnits);
|
2015-07-21 20:21:46 +00:00
|
|
|
|
|
|
|
_tree tvSort [[],false];
|
2015-08-06 23:05:21 +00:00
|
|
|
|
|
|
|
if ((_tree tvCount []) <= 0) then {
|
|
|
|
_tree tvAdd [[], localize LSTRING(units_none)];
|
|
|
|
};
|
2015-07-19 12:40:08 +00:00
|
|
|
};
|
2015-07-20 19:30:13 +00:00
|
|
|
// Map events
|
2015-08-06 10:34:24 +00:00
|
|
|
case "onmapclick": {
|
|
|
|
_args params ["_map","_button","_x","_y","_shift","_ctrl","_alt"];
|
2015-07-24 14:36:36 +00:00
|
|
|
private ["_newPos","_oldZ"];
|
2015-07-20 19:30:13 +00:00
|
|
|
|
2015-07-25 14:29:53 +00:00
|
|
|
if ((GVAR(camMode) == 0) && (_button == 0)) then {
|
2015-07-20 19:30:13 +00:00
|
|
|
_newPos = _map ctrlMapScreenToWorld [_x,_y];
|
2015-07-21 17:05:29 +00:00
|
|
|
_oldZ = (ASLtoATL GVAR(camPos)) select 2;
|
2015-07-21 17:07:55 +00:00
|
|
|
_newPos set [2, _oldZ];
|
2015-07-25 11:28:03 +00:00
|
|
|
[nil,nil,nil, _newPos] call FUNC(setCameraAttributes);
|
2015-07-20 19:30:13 +00:00
|
|
|
};
|
|
|
|
};
|
2015-08-23 16:50:11 +00:00
|
|
|
// Interrupt events
|
2015-07-25 22:59:15 +00:00
|
|
|
case "escape": {
|
|
|
|
createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer);
|
|
|
|
|
|
|
|
disableSerialization;
|
2016-09-04 14:44:22 +00:00
|
|
|
private _dlg = finddisplay 49;
|
2015-07-25 22:59:15 +00:00
|
|
|
_dlg displayAddEventHandler ["KeyDown", {
|
|
|
|
_key = _this select 1;
|
|
|
|
!(_key == 1)
|
|
|
|
}];
|
|
|
|
|
2015-08-05 23:39:14 +00:00
|
|
|
// Disable save, respawn, options & manual buttons
|
|
|
|
(_dlg displayCtrl 103) ctrlEnable false;
|
|
|
|
if !(alive player) then {
|
|
|
|
(_dlg displayCtrl 1010) ctrlEnable false;
|
2015-07-25 22:59:15 +00:00
|
|
|
};
|
2015-08-05 23:39:14 +00:00
|
|
|
(_dlg displayCtrl 101) ctrlEnable false;
|
|
|
|
(_dlg displayCtrl 122) ctrlEnable false;
|
2015-07-25 22:59:15 +00:00
|
|
|
|
2015-08-05 23:39:14 +00:00
|
|
|
// Initalize abort button (the "spawn" is a necessary evil)
|
|
|
|
(_dlg displayCtrl 104) ctrlAddEventHandler ["ButtonClick",{_this spawn {
|
|
|
|
disableSerialization;
|
|
|
|
_display = ctrlparent (_this select 0);
|
|
|
|
_abort = [localize "str_msg_confirm_return_lobby",nil,localize "str_disp_xbox_hint_yes",localize "str_disp_xbox_hint_no",_display,nil,true] call BIS_fnc_guiMessage;
|
|
|
|
if (_abort) then {_display closeDisplay 2; failMission "loser"};
|
|
|
|
}}];
|
2015-07-25 22:59:15 +00:00
|
|
|
|
|
|
|
// PFH to re-open display when menu closes
|
|
|
|
[{
|
2016-01-13 18:28:36 +00:00
|
|
|
if !(isNull (_this select 0)) exitWith {};
|
2015-07-25 22:59:15 +00:00
|
|
|
|
2015-08-05 23:39:14 +00:00
|
|
|
// If still a spectator then re-enter the interface
|
2015-08-21 23:26:01 +00:00
|
|
|
[QGVAR(escape),false] call FUNC(interrupt);
|
2015-07-25 22:59:15 +00:00
|
|
|
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
2016-01-13 18:28:36 +00:00
|
|
|
},0,_dlg] call CBA_fnc_addPerFrameHandler;
|
2015-08-05 23:52:39 +00:00
|
|
|
};
|
|
|
|
case "zeus": {
|
|
|
|
openCuratorInterface;
|
|
|
|
|
|
|
|
[{
|
|
|
|
// PFH to re-open display when menu closes
|
|
|
|
[{
|
|
|
|
if !((isNull curatorCamera) && {isNull (GETMVAR(bis_fnc_moduleRemoteControl_unit,objNull))}) exitWith {};
|
|
|
|
|
|
|
|
// If still a spectator then re-enter the interface
|
2015-08-23 16:50:11 +00:00
|
|
|
[QGVAR(zeus),false] call FUNC(interrupt);
|
2015-08-05 23:52:39 +00:00
|
|
|
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
},0] call CBA_fnc_addPerFrameHandler;
|
2016-05-22 13:27:24 +00:00
|
|
|
},[],5] call CBA_fnc_waitAndExecute;
|
2015-08-05 23:39:14 +00:00
|
|
|
|
|
|
|
true
|
2015-07-25 22:59:15 +00:00
|
|
|
};
|
2015-07-15 11:03:54 +00:00
|
|
|
};
|