diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index e8bc6c210f..a3ad215ea2 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -190,8 +190,8 @@ class GVAR(interface) { 1 }; multiselectEnabled = 0; + maxHistoryDelay = 10e10; onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface)); - onTreeSelChanged = QUOTE([ARR_2('onTreeSelChanged',_this)] call FUNC(handleInterface)); }; class unitFrame: RscFrame { x = 0; diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index 35b463837f..a9737868a0 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -8,3 +8,6 @@ GVAR(availableModes) = [[0,1,2], [1,2], [0], [1], [2]] select GVAR(restrictModes); GVAR(availableVisions) = [[-2,-1,0,1], [-2,-1], [-2,0,1], [-2]] select GVAR(restrictVisions); }] call EFUNC(common,addEventHandler); + +// Should prevent unending spectator on mission end +addMissionEventHandler ["Ended",{ [false] call FUNC(setSpectator) }]; diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index e26dc27d07..13f2ba1708 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -35,7 +35,7 @@ GVAR(camDistance) = 10; GVAR(camMode) = 0; GVAR(camPan) = 0; GVAR(camPos) = ATLtoASL [worldSize * 0.5, worldSize * 0.5, 20]; -GVAR(camSpeed) = 2.5; +GVAR(camSpeed) = 1.5; GVAR(camTilt) = -10; GVAR(camUnit) = objNull; GVAR(camVision) = -2; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 7c961071c3..8f29b20296 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -45,37 +45,36 @@ switch (toLower _mode) do { }; } forEach [ [localize LSTRING(uiControls),""], - [localize LSTRING(uiToggleUnits),"1"], - [localize LSTRING(uiToggleHelp),"2"], - [localize LSTRING(uiToggleTools),"3"], - [localize LSTRING(uiToggleCompass),"4"], - [localize LSTRING(uiToggleIcons),"5"], - [localize LSTRING(uiToggleMap),"M"], - [localize LSTRING(uiToggleInterface),"Backspace"], + [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], [localize LSTRING(freeCamControls),""], - [localize LSTRING(freeCamForward),"W"], - [localize LSTRING(freeCamBackward),"S"], - [localize LSTRING(freeCamLeft),"A"], - [localize LSTRING(freeCamRight),"D"], - [localize LSTRING(freeCamUp),"Q"], - [localize LSTRING(freeCamDown),"Z"], + [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], [localize LSTRING(freeCamPan),"RMB (Hold)"], [localize LSTRING(freeCamDolly),"LMB (Hold)"], [localize LSTRING(freeCamBoost),"Shift (Hold)"], - [localize LSTRING(freeCamFocus),"F"], [localize LSTRING(attributeControls),""], - [localize LSTRING(nextCam),"Up Arrow"], - [localize LSTRING(prevCam),"Down Arrow"], - [localize LSTRING(nextUnit),"Right Arrow"], - [localize LSTRING(prevUnit),"Left Arrow"], - [localize LSTRING(nextVis),"N"], - [localize LSTRING(prevVis),"Ctrl + N"], + [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]], [localize LSTRING(adjZoom),"Scrollwheel"], - [localize LSTRING(adjSpeed),"Ctrl + Scrollwheel"], - [localize LSTRING(incZoom),"Num-/Num+"], - [localize LSTRING(incSpeed),"Ctrl + Num-/Num+"], - [localize LSTRING(reZoom),"Alt + Num-"], - [localize LSTRING(reSpeed),"Alt + Num+"] + [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]] ]; // Handle support for BI's respawn counter @@ -126,7 +125,6 @@ switch (toLower _mode) do { GVAR(heldKeys) resize 255; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; - GVAR(treeSel) = objNull; }; // Mouse events case "onmousebuttondown": { @@ -226,19 +224,11 @@ switch (toLower _mode) do { case 32: { // D GVAR(camDolly) set [0, GVAR(camSpeed) * ([1, 2] select _shift)]; }; - case 33: { // F - private ["_sel","_vector"]; - _sel = GVAR(treeSel); - if ((GVAR(camMode) == 0) && {!isNull _sel} && {_sel in GVAR(unitList)}) then { - _vector = (positionCameraToWorld [0,0,0]) vectorDiff (positionCameraToWorld [0,0,25]); - [nil,nil,nil,(getPosATL _sel) vectorAdd _vector] call FUNC(setCameraAttributes); - }; - }; case 44: { // Z GVAR(camBoom) = -0.5 * GVAR(camSpeed) * ([1, 2] select _shift); }; case 49: { // N - if (GVAR(camMode) == 0) then { + if (GVAR(camMode) != 1) then { if (_ctrl) then { [nil,nil,-1] call FUNC(cycleCamera); } else { @@ -250,7 +240,7 @@ switch (toLower _mode) do { [_display,nil,nil,nil,true] call FUNC(toggleInterface); }; case 57: { // Spacebar - // Freecam attachment here, if in external then set cam pos and attach + // Switch between unit and freecam here }; case 74: { // Num - if (_alt) exitWith { [nil,nil,nil,nil,nil,nil, 1.25] call FUNC(setCameraAttributes); }; @@ -261,7 +251,7 @@ switch (toLower _mode) do { }; }; case 78: { // Num + - if (_alt) exitWith { [nil,nil,nil,nil,nil,nil,nil, 2.5] call FUNC(setCameraAttributes); }; + if (_alt) exitWith { [nil,nil,nil,nil,nil,nil,nil, 1.5] call FUNC(setCameraAttributes); }; if (_ctrl) then { [nil,nil,nil,nil,nil,nil,nil, GVAR(camSpeed) + 0.05] call FUNC(setCameraAttributes); } else { @@ -335,15 +325,6 @@ switch (toLower _mode) do { [_newMode,_newUnit] call FUNC(transitionCamera); }; }; - case "ontreeselchanged": { - _args params ["_tree","_sel"]; - - if (count _sel == 3) then { - GVAR(treeSel) = objectFromNetId (_tree tvData _sel); - } else { - GVAR(treeSel) = objNull; - }; - }; case "onunitsupdate": { _args params ["_tree"]; private ["_cachedUnits","_cachedGrps","_cachedSides","_s","_g","_grp","_u","_unit","_side"]; diff --git a/addons/spectator/functions/fnc_handleMap.sqf b/addons/spectator/functions/fnc_handleMap.sqf index fd084f9967..b83ccdcd7d 100644 --- a/addons/spectator/functions/fnc_handleMap.sqf +++ b/addons/spectator/functions/fnc_handleMap.sqf @@ -18,12 +18,32 @@ #include "script_component.hpp" params ["_map"]; -private ["_cachedVehicles","_unit","_color","_icon","_txt"]; +private ["_center","_radius","_scaled","_drawVehicles","_leader","_color","_cachedVehicles","_unit","_icon","_txt"]; if (GVAR(camMode) == 0) then { _map drawIcon ["\A3\UI_F\Data\GUI\Rsc\RscDisplayMissionEditor\iconcamera_ca.paa",[0,0,0,1],GVAR(freeCamera),20,20,GVAR(camPan)]; }; +_center = _map ctrlMapScreenToWorld [0.5,0.5]; +_radius = (_map ctrlMapScreenToWorld [safeZoneX,safeZoneY]) distance2D _center; +_scaled = (ctrlMapScale _map) > 0.2; + +// Draw only group icons when scaled out +_drawVehicles = []; +{ + _leader = leader _x; + if (_scaled) then { + _color = GETVAR(_x,GVAR(gColor),[ARR_4(0,0,0,0)]); + _map drawIcon ["\A3\ui_f\data\map\markers\nato\b_inf.paa", _color, _leader, 20, 20, 0, "", 0, 0]; + } else { + if ((_leader distance2D _center) < _radius) then { + _drawVehicles append (units _x); + }; + }; + nil +} count GVAR(groupList); + +// Draw units when group leader is within screen bounds _cachedVehicles = []; { _unit = vehicle _x; @@ -41,7 +61,7 @@ _cachedVehicles = []; _icon = GETVAR(_unit,GVAR(uIcon),""); _txt = ["", GETVAR(_x,GVAR(uName),"")] select (isPlayer _x); - _map drawIcon [_icon, _color, _unit, 19, 19, getDir _unit, _txt, 1, 0.03]; + _map drawIcon [_icon, _color, _unit, 19, 19, getDir _unit, _txt, 1, 0.04]; }; - false -} count GVAR(unitList); + nil +} count (_drawVehicles arrayIntersect GVAR(unitList)); diff --git a/addons/spectator/functions/fnc_handleToolbar.sqf b/addons/spectator/functions/fnc_handleToolbar.sqf index 878f3e46de..4e79c172bd 100644 --- a/addons/spectator/functions/fnc_handleToolbar.sqf +++ b/addons/spectator/functions/fnc_handleToolbar.sqf @@ -26,8 +26,13 @@ private ["_name","_vision","_fov","_speed","_mode","_time","_toolbar"]; _toolbar = _display displayCtrl IDC_TOOL; // Find all tool values +if (GVAR(camVision) >= 0) then { + _vision = localize LSTRING(VisionThermal); +} else { + _vision = [localize LSTRING(VisionNight), localize LSTRING(VisionNormal)] select (GVAR(camVision) < -1); +}; + if (GVAR(camMode) == 0) then { - _vision = if (GVAR(camVision) >= 0) then {localize LSTRING(VisionThermal)} else { [localize LSTRING(VisionNight), localize LSTRING(VisionNormal)] select (GVAR(camVision) < -1) }; _fov = format ["%1x", floor(GVAR(camZoom) * 100) * 0.01]; _speed = format ["%1 m/s", floor(GVAR(camSpeed) * 100) * 0.01]; } else { diff --git a/addons/spectator/functions/fnc_interrupt.sqf b/addons/spectator/functions/fnc_interrupt.sqf index 48cca7d102..72bb3eaa32 100644 --- a/addons/spectator/functions/fnc_interrupt.sqf +++ b/addons/spectator/functions/fnc_interrupt.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Reason - * 1: Interrupting + * 1: Interrupting (default: true) * * Return Value: * None diff --git a/addons/spectator/functions/fnc_respawnTemplate.sqf b/addons/spectator/functions/fnc_respawnTemplate.sqf index d903e3ecc4..4584a1fc3c 100644 --- a/addons/spectator/functions/fnc_respawnTemplate.sqf +++ b/addons/spectator/functions/fnc_respawnTemplate.sqf @@ -34,7 +34,7 @@ _pos = (getPosATL _unit) vectorAdd [0,0,5]; // Enter/exit spectator based on the respawn type and whether killed/respawned if (alive _unit) then { if (_respawn == 1) then { - [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); + [_unit] call FUNC(stageSpectator); [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); [true] call FUNC(setSpectator); } else { diff --git a/addons/spectator/functions/fnc_setCameraAttributes.sqf b/addons/spectator/functions/fnc_setCameraAttributes.sqf index dd8dd3ef6a..f908b30b76 100644 --- a/addons/spectator/functions/fnc_setCameraAttributes.sqf +++ b/addons/spectator/functions/fnc_setCameraAttributes.sqf @@ -1,23 +1,24 @@ /* * Author: SilentSpike * Sets the spectator camera attributes as desired + * All values are optional and default to whatever the current value is * * Arguments: - * 0: Camera mode + * 0: Camera mode * - 0: Free * - 1: Internal * - 2: External - * 1: Camera unit (objNull for random) - * 2: Camera vision + * 1: Camera unit (objNull for random) + * 2: Camera vision * - -2: Normal * - -1: Night vision * - 0: Thermal white hot * - 1: Thermal black hot - * 3: Camera position (ATL) - * 4: Camera pan (0 - 360) - * 5: Camera tilt (-90 - 90) - * 6: Camera zoom (0.01 - 2) - * 7: Camera speed in m/s (0.05 - 10) + * 3: Camera position (ATL) + * 4: Camera pan (0 - 360) + * 5: Camera tilt (-90 - 90) + * 6: Camera zoom (0.01 - 2) + * 7: Camera speed in m/s (0.05 - 10) * * Return Value: * None diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index efa7000b8f..065ca0079b 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -7,7 +7,8 @@ * The spectator interface will be opened/closed * * Arguments: - * 0: Spectator state of local client + * 0: Spectator state of local client (default: true) + * 1: Force interface (default: true) * * Return Value: * None @@ -20,7 +21,7 @@ #include "script_component.hpp" -params [["_set",true,[true]]]; +params [["_set",true,[true]], ["_force",true,[true]]]; // Only clients can be spectators if (!hasInterface) exitWith {}; @@ -29,7 +30,10 @@ if (!hasInterface) exitWith {}; if (_set isEqualTo GVAR(isSet)) exitwith {}; // Handle common addon audio -if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set}; +if (["ace_hearing"] call EFUNC(common,isModLoaded)) then { + EGVAR(hearing,disableVolumeUpdate) = _set; + EGVAR(hearing,deafnessDV) = 0; +}; if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[player, _set] call TFAR_fnc_forceSpectator}; @@ -45,7 +49,6 @@ if (_set) then { GVAR(heldKeys) resize 255; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; - GVAR(treeSel) = objNull; // Update units before opening to support pre-set camera unit [] call FUNC(updateUnits); @@ -75,7 +78,17 @@ if (_set) then { [{ // Create the display (findDisplay 46) createDisplay QGVAR(interface); - }, []] call EFUNC(common,execNextFrame); + + // If not forced, make esc end spectator + if (_this) then { + (findDisplay 12249) displayAddEventHandler ["KeyDown", { + if (_this select 1 == 1) then { + [false] call ace_spectator_fnc_setSpectator; + true + }; + }]; + }; + }, !_force] call EFUNC(common,execNextFrame); // Cache and disable nametag settings if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { @@ -119,7 +132,6 @@ if (_set) then { GVAR(heldKeys) = nil; GVAR(mouse) = nil; GVAR(mousePos) = nil; - GVAR(treeSel) = nil; // Reset nametag settings if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 7f0d862719..61445f3dd9 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -7,8 +7,8 @@ * Upon unstage, units will be moved to the position they were in upon staging * * Arguments: - * 0: Unit to put into spectator stage - * 1: Spectator stage + * 0: Unit to put into spectator stage (default: player) + * 1: Unit should be staged (default: true) * * Return Value: * None diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index edc7fa23a2..0f6eb3ffc7 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -49,7 +49,6 @@ if (_newMode == 0) then { // Free // Preserve camUnit value for consistency when manually changing view _camera cameraEffect ["internal", "back"]; - showCinemaBorder false; // Apply the camera zoom _camera camSetFov -(linearConversion [0.01,2,GVAR(camZoom),-2,-0.01,true]); @@ -63,23 +62,6 @@ if (_newMode == 0) then { // Free GVAR(camAgent) switchCamera "internal"; clearRadio; - - // If new vision isn't available then keep current (unless current also isn't) - if !(_newVision in GVAR(availableVisions)) then { - _newVision = GVAR(availableVisions) select ((GVAR(availableVisions) find GVAR(camVision)) max 0); - }; - - // Vision mode only applies to free cam - if (_newVision < 0) then { - false setCamUseTi 0; - camUseNVG (_newVision >= -1); - } else { - true setCamUseTi _newVision; - }; - GVAR(camVision) = _newVision; - - // Handle camera movement - if (isNil QGVAR(camHandler)) then { GVAR(camHandler) = [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; }; } else { _camera = GVAR(unitCamera); @@ -103,10 +85,6 @@ if (_newMode == 0) then { // Free } else { // Switch to the camera _camera cameraEffect ["internal", "back"]; - showCinemaBorder false; - - // Handle camera orbit movement - if (isNil QGVAR(camHandler)) then { GVAR(camHandler) = [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; }; }; // Clear radio if group changed @@ -117,4 +95,27 @@ if (_newMode == 0) then { // Free GVAR(camUnit) = _newUnit; }; +if (_newMode in [0,2]) then { + // Set up camera UI + showCinemaBorder false; + cameraEffectEnableHUD true; + + // Handle camera movement + if (isNil QGVAR(camHandler)) then { GVAR(camHandler) = [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; }; + + // If new vision isn't available then keep current (unless current also isn't) + if !(_newVision in GVAR(availableVisions)) then { + _newVision = GVAR(availableVisions) select ((GVAR(availableVisions) find GVAR(camVision)) max 0); + }; + + // Vision mode applies to free and external cam + if (_newVision < 0) then { + false setCamUseTi 0; + camUseNVG (_newVision >= -1); + } else { + true setCamUseTi _newVision; + }; + GVAR(camVision) = _newVision; +}; + GVAR(camMode) = _newMode; diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf index 0297b31b8d..e5b15b6bc1 100644 --- a/addons/spectator/functions/fnc_updateUnits.sqf +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Units to add to the whitelist - * 1: Use blacklist + * 1: Use blacklist (default: false) * * Return Value: * None diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 00d50e4704..d8c7cd1310 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -344,14 +344,6 @@ Ускорение камеры Aumento de velocidad - - Focus on Unit - Skup na jednostce - Focar na unidade - Фокус на юните - Zaměřit se na Jednotku - Centrarse en la unidad - Interface Interfejs