From 33314f8a9e7675f7e6694ebf86062d9e02213924 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 31 Jul 2015 23:32:25 +0100 Subject: [PATCH 01/43] Adjust spectator camera boom speed Vertical camera movement (boom) was previously at a constant speed. However this felt too slow at times, half the horizontal (dolly) speed should improve this. --- addons/spectator/functions/fnc_handleInterface.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 864ae32adc..709c0263b2 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -224,7 +224,7 @@ switch (toLower _mode) do { [_display,nil,nil,true] call FUNC(toggleInterface); }; case 16: { // Q - GVAR(camBoom) = 0.5; + GVAR(camBoom) = 0.5 * GVAR(camSpeed); }; case 17: { // W GVAR(camDolly) set [1, GVAR(camSpeed)]; @@ -245,7 +245,7 @@ switch (toLower _mode) do { [_display,nil,true] call FUNC(toggleInterface); }; case 44: { // Z - GVAR(camBoom) = -0.5; + GVAR(camBoom) = -0.5 * GVAR(camSpeed); }; case 49: { // N if (_ctrl) then { From 612aa2d679515c0d74156c823852efe10083bf5a Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 1 Aug 2015 18:10:11 +0100 Subject: [PATCH 02/43] Separate spectator physical and virtual states With the changes planned to allow spectator in the true death state, physical changes aren't applicable in all of the possible usage cases. This separates the physical process into new function ace_spectator_fnc_stageSpectator --- addons/spectator/XEH_preInit.sqf | 1 + .../spectator/functions/fnc_setSpectator.sqf | 49 +++---------- .../functions/fnc_stageSpectator.sqf | 68 +++++++++++++++++++ 3 files changed, 77 insertions(+), 41 deletions(-) create mode 100644 addons/spectator/functions/fnc_stageSpectator.sqf diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index e5872c3272..2cc65602cc 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -16,6 +16,7 @@ PREP(handleUnits); PREP(moduleSpectatorSettings); PREP(setCameraAttributes); PREP(setSpectator); +PREP(stageSpectator); PREP(transitionCamera); PREP(toggleInterface); PREP(updateCameraModes); diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index fd3dd9861c..f4dc86c3da 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -1,10 +1,14 @@ /* * Author: SilentSpike - * Sets target unit to the given spectator state + * Sets target unit to the given spectator state (virtually) + * To physically handle a spectator see ace_spectator_fnc_stageSpectator + * + * Units will be able to communicate in ACRE/TFAR as appropriate + * The spectator interface will be opened/closed * * Arguments: * 0: Unit to put into spectator state <OBJECT> - * 1: New spectator state <BOOL> <OPTIONAL> + * 1: Spectator state <BOOL> <OPTIONAL> * * Return Value: * None <NIL> @@ -17,10 +21,7 @@ #include "script_component.hpp" -params ["_unit",["_set",true,[true]],["_target",objNull,[objNull]]]; - -// No change, no service (but allow spectators who respawn to be reset) -if !(_set || (_unit getVariable [QGVAR(isSpectator), false])) exitWith {}; +params ["_unit", ["_set",true,[true]]]; // Only run for player units if !(isPlayer _unit) exitWith {}; @@ -29,49 +30,15 @@ if !(local _unit) exitwith { [[_unit, _set, _target], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc); }; -// Prevent player falling into water -_unit enableSimulation !_set; - -// Move to/from group as appropriate -[_unit, _set, QGVAR(isSpectator), side group _unit] call EFUNC(common,switchToGroupSide); - if (_set) then { - // Move and hide the player ASAP to avoid being seen - _unit setPos (getMarkerPos QGVAR(respawn)); - - // Ghosts can't talk - [_unit, QGVAR(isSpectator)] call EFUNC(common,hideUnit); - [_unit, QGVAR(isSpectator)] call EFUNC(common,muteUnit); - ["open"] call FUNC(handleInterface); } else { ["close"] call FUNC(handleInterface); - - // Physical beings can talk - [_unit, QGVAR(isSpectator)] call EFUNC(common,unhideUnit); - [_unit, QGVAR(isSpectator)] call EFUNC(common,unmuteUnit); - - private "_marker"; - _marker = ["respawn_west","respawn_east","respawn_guerrila","respawn_civilian"] select ([west,east,resistance,civilian] find (side group _unit)); - _unit setPos (getMarkerPos _marker); }; -// Enable/disable input as appropriate -//[QGVAR(isSpectator), _set] call EFUNC(common,setDisableUserInputStatus); - // Handle common addon audio if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set}; if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator}; -// Spectators ignore damage (vanilla and ace_medical) -_unit allowDamage !_set; -_unit setVariable [QEGVAR(medical,allowDamage), !_set]; - -// No theoretical change if an existing spectator was reset -if !(_set && (_unit getVariable [QGVAR(isSpectator), false])) then { - // Mark spectator state for reference - _unit setVariable [QGVAR(isSpectator), _set, true]; - - ["spectatorChanged",[_set]] call EFUNC(common,localEvent); -}; +["spectatorSet",[_set]] call EFUNC(common,localEvent); diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf new file mode 100644 index 0000000000..2f6741e35a --- /dev/null +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -0,0 +1,68 @@ +/* + * Author: SilentSpike + * Sets target unit to the given spectator state (physically) + * To virtually handle a spectator see ace_spectator_fnc_setSpectator + * + * Units will be gathered at marker ace_spectator_respawn (or [0,0,0] by default) + * Upon unstage, units will be moved to the position they were in upon staging + * + * Arguments: + * 0: Unit to put into spectator stage <OBJECT> + * 1: Spectator stage <BOOL> <OPTIONAL> + * + * Return Value: + * None <NIL> + * + * Example: + * [player, false] call ace_spectator_fnc_stageSpectator + * + * Public: Yes + */ + +#include "script_component.hpp" + +params ["_unit", ["_set",true,[true]]]; + +// No change, no service (but allow spectators who respawn to be reset) +if !(_set || (GETVAR(_unit,GVAR(isSpectator),false))) exitWith {}; + +// Only run for player units +if !(isPlayer _unit) exitWith {}; + +if !(local _unit) exitwith { + [[_unit, _set, _target], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); +}; + +// Prevent player falling into water +_unit enableSimulation !_set; + +// Move to/from group as appropriate +[_unit, _set, QGVAR(isSpectator), side group _unit] call EFUNC(common,switchToGroupSide); + +if (_set) then { + // Move and hide the player ASAP to avoid being seen + GVAR(oldPos) = getPosATL _unit; + _unit setPos (getMarkerPos QGVAR(respawn)); + + // Ghosts can't talk + [_unit, QGVAR(isSpectator)] call EFUNC(common,hideUnit); + [_unit, QGVAR(isSpectator)] call EFUNC(common,muteUnit); +} else { + // Physical beings can talk + [_unit, QGVAR(isSpectator)] call EFUNC(common,unhideUnit); + [_unit, QGVAR(isSpectator)] call EFUNC(common,unmuteUnit); + + _unit setPosATL GVAR(oldPos); +}; + +// Spectators ignore damage (vanilla and ace_medical) +_unit allowDamage !_set; +_unit setVariable [QEGVAR(medical,allowDamage), !_set]; + +// No theoretical change if an existing spectator was reset +if !(_set isEqualTo (GETVAR(_unit,GVAR(isSpectator),false))) then { + // Mark spectator state for reference + _unit setVariable [QGVAR(isSpectator), _set, true]; + + ["spectatorStaged",[_set]] call EFUNC(common,localEvent); +}; From 38e08d513a91fe0c084ecfd2d8dfd575224961d2 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sun, 2 Aug 2015 12:34:35 +0100 Subject: [PATCH 03/43] Clear spectator display variable at preInit uiNamespace persists between missions and should be reset on mission start --- addons/spectator/XEH_preInit.sqf | 2 ++ addons/spectator/functions/fnc_handleInterface.sqf | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 2cc65602cc..a77d731478 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -38,6 +38,8 @@ GVAR(camUnit) = objNull; GVAR(camVision) = -2; GVAR(camZoom) = 1.25; +SETUVAR(GVAR(display),nil); + GVAR(showComp) = true; GVAR(showHelp) = true; GVAR(showIcons) = true; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 709c0263b2..2fa0d1439c 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -95,9 +95,7 @@ switch (toLower _mode) do { case "onload": { _args params ["_display"]; - with uiNamespace do { - GVAR(display) = _display; - }; + SETUVAR(GVAR(display),_display); // Always show interface and hide map upon opening [_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(toggleInterface); @@ -151,9 +149,7 @@ switch (toLower _mode) do { //_display displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}]; }; case "onunload": { - with uiNamespace do { - GVAR(display) = nil; - }; + SETUVAR(GVAR(display),nil); GVAR(camHandler) = nil; GVAR(compHandler) = nil; From 63c034e348421d22a01e84f923841b48e76deebc Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sun, 2 Aug 2015 12:47:26 +0100 Subject: [PATCH 04/43] Differentiate between staged and set spectators Existing variable "ace_spectator_isSpectator" split into counterparts "ace_spectator_isSet" and "ace_spectator_isStaged" in order to better manage spectator events --- addons/spectator/XEH_postInit.sqf | 2 +- .../spectator/functions/fnc_setSpectator.sqf | 11 ++++++++++- .../spectator/functions/fnc_stageSpectator.sqf | 18 +++++++++--------- addons/spectator/functions/fnc_updateUnits.sqf | 2 +- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index bad3758c19..45ac78e89c 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -2,7 +2,7 @@ //#include "initKeybinds.sqf"; // Add interaction menu exception -["isNotSpectating", {!((_this select 0) getVariable [QGVAR(isSpectator), false])}] call EFUNC(common,addCanInteractWithCondition); +["isNotSpectating", {!(GETVAR((_this select 0),GVAR(isStaged),false))}] call EFUNC(common,addCanInteractWithCondition); ["SettingsInitialized", { GVAR(availableModes) = [[0,1,2], [1,2], [0], [1], [2]] select GVAR(restrictModes); diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index f4dc86c3da..2f8e1d3c2d 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -23,6 +23,9 @@ params ["_unit", ["_set",true,[true]]]; +// No change, no service (but allow spectators to be reset) +if !(_set || (GETVAR(_unit,GVAR(isSet),false))) exitWith {}; + // Only run for player units if !(isPlayer _unit) exitWith {}; @@ -41,4 +44,10 @@ if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableV if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator}; -["spectatorSet",[_set]] call EFUNC(common,localEvent); +// No theoretical change if an existing spectator was reset +if !(_set isEqualTo (GETVAR(_unit,GVAR(isSet),false))) then { + // Mark spectator state for reference + _unit setVariable [QGVAR(isSet), _set, true]; + + ["spectatorSet",[_set]] call EFUNC(common,localEvent); +}; diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 2f6741e35a..84bd6ffced 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -23,8 +23,8 @@ params ["_unit", ["_set",true,[true]]]; -// No change, no service (but allow spectators who respawn to be reset) -if !(_set || (GETVAR(_unit,GVAR(isSpectator),false))) exitWith {}; +// No change, no service (but allow spectators to be reset) +if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {}; // Only run for player units if !(isPlayer _unit) exitWith {}; @@ -37,7 +37,7 @@ if !(local _unit) exitwith { _unit enableSimulation !_set; // Move to/from group as appropriate -[_unit, _set, QGVAR(isSpectator), side group _unit] call EFUNC(common,switchToGroupSide); +[_unit, _set, QGVAR(isStaged), side group _unit] call EFUNC(common,switchToGroupSide); if (_set) then { // Move and hide the player ASAP to avoid being seen @@ -45,12 +45,12 @@ if (_set) then { _unit setPos (getMarkerPos QGVAR(respawn)); // Ghosts can't talk - [_unit, QGVAR(isSpectator)] call EFUNC(common,hideUnit); - [_unit, QGVAR(isSpectator)] call EFUNC(common,muteUnit); + [_unit, QGVAR(isStaged)] call EFUNC(common,hideUnit); + [_unit, QGVAR(isStaged)] call EFUNC(common,muteUnit); } else { // Physical beings can talk - [_unit, QGVAR(isSpectator)] call EFUNC(common,unhideUnit); - [_unit, QGVAR(isSpectator)] call EFUNC(common,unmuteUnit); + [_unit, QGVAR(isStaged)] call EFUNC(common,unhideUnit); + [_unit, QGVAR(isStaged)] call EFUNC(common,unmuteUnit); _unit setPosATL GVAR(oldPos); }; @@ -60,9 +60,9 @@ _unit allowDamage !_set; _unit setVariable [QEGVAR(medical,allowDamage), !_set]; // No theoretical change if an existing spectator was reset -if !(_set isEqualTo (GETVAR(_unit,GVAR(isSpectator),false))) then { +if !(_set isEqualTo (GETVAR(_unit,GVAR(isStaged),false))) then { // Mark spectator state for reference - _unit setVariable [QGVAR(isSpectator), _set, true]; + _unit setVariable [QGVAR(isStaged), _set, true]; ["spectatorStaged",[_set]] call EFUNC(common,localEvent); }; diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf index 0393fa0e36..ef8fc3b4f1 100644 --- a/addons/spectator/functions/fnc_updateUnits.sqf +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -55,7 +55,7 @@ _filteredUnits = []; {(_x isKindOf "CAManBase")} && {(side group _x) in _sides} && // Side filter {simulationEnabled _x} && - {!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen? + {!(_x getVariable [QGVAR(isStaged), false])} // Who watches the watchmen? ) then { _filteredUnits pushBack _x; }; From 52460182c9c662dacc76e27f21a5d9e8b37786e8 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sun, 2 Aug 2015 16:42:24 +0100 Subject: [PATCH 05/43] Enable spectator on death system New spectator on death system should enter spectator mode upon dying and exit upon respawning. Only virtual spectator state is suitable for this system since the body should remain as is. --- addons/spectator/functions/fnc_handleKilled.sqf | 9 ++++----- addons/spectator/functions/fnc_handleRespawn.sqf | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/addons/spectator/functions/fnc_handleKilled.sqf b/addons/spectator/functions/fnc_handleKilled.sqf index 67c556cc3f..05671ed749 100644 --- a/addons/spectator/functions/fnc_handleKilled.sqf +++ b/addons/spectator/functions/fnc_handleKilled.sqf @@ -1,7 +1,7 @@ /* * Author: SilentSpike - * Cache necessary details and process unit for spectator on death - * Part of the basic spectator system + * Set inital camera attributes and set as spectator on death + * Part of the spectator during death system * * Arguments: * 0: Corpse <OBJECT> @@ -17,11 +17,10 @@ params ["_unit","_killer"]; -// Remove from group to prevent appearing on HUD upon respawn -[_unit, true, QGVAR(isSpectator), side group _unit] call EFUNC(common,switchToGroupSide); - if (isNull _killer) then { [2,_unit] call FUNC(setCameraAttributes); } else { [2,_killer] call FUNC(setCameraAttributes); }; + +[_unit] call FUNC(setSpectator); diff --git a/addons/spectator/functions/fnc_handleRespawn.sqf b/addons/spectator/functions/fnc_handleRespawn.sqf index 9b6b0bb802..3e7dfa41f3 100644 --- a/addons/spectator/functions/fnc_handleRespawn.sqf +++ b/addons/spectator/functions/fnc_handleRespawn.sqf @@ -1,7 +1,7 @@ /* * Author: SilentSpike - * Start the interface on respawn - * Part of the basic spectator system + * Un-set as spectator on respawn + * Part of the spectator during death system * * Arguments: * 0: New unit <OBJECT> @@ -15,4 +15,4 @@ #include "script_component.hpp" -[_this select 0] call FUNC(setSpectator); +[_unit,false] call FUNC(setSpectator); From 9b764bbba45a3980114676842d07c260379c55c2 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sun, 2 Aug 2015 17:27:32 +0100 Subject: [PATCH 06/43] Preserve Polish translations from master branch Since spectator was pushed back to a feature branch from the release branch these translations from a PR were also lost (as the commits were prior to the removal commit) when it was merged after the fact. --- addons/spectator/stringtable.xml | 70 +++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 8b91608981..1f74d08c43 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -3,195 +3,253 @@ <Package name="Spectator"> <Key ID="STR_ACE_Spectator_Settings_DisplayName"> <English>Spectator Settings</English> + <Polish>Ustawienia obserwatora</Polish> </Key> <Key ID="STR_ACE_Spectator_Settings_Descripton"> <English>Configure how the spectator system will operate by default.</English> + <Polish>Skonfiguruj domyślne ustawienia obserwatora.</Polish> </Key> <Key ID="STR_ACE_Spectator_system_DisplayName"> <English>Spectate on death</English> + <Polish>Obserwator po śmierci</Polish> </Key> <Key ID="STR_ACE_Spectator_system_Description"> <English>Enables spectator upon death.</English> + <Polish>Włącz obserwatora po śmierci</Polish> </Key> <Key ID="STR_ACE_Spectator_units_DisplayName"> <English>Unit filter</English> + <Polish>Filtr jednostek</Polish> </Key> <Key ID="STR_ACE_Spectator_units_Description"> <English>Method of filtering spectatable units.</English> + <Polish>Wybierz jednostki, jakie będzie można obserwować po uruchomeniu obserwatora.</Polish> </Key> <Key ID="STR_ACE_Spectator_units_none"> <English>No units</English> + <Polish>Brak jednostek</Polish> </Key> <Key ID="STR_ACE_Spectator_units_players"> <English>Only players</English> + <Polish>Tylko gracze</Polish> </Key> <Key ID="STR_ACE_Spectator_units_all"> <English>All units</English> + <Polish>Wszystkie jednostki</Polish> </Key> <Key ID="STR_ACE_Spectator_sides_DisplayName"> <English>Side filter</English> + <Polish>Filtr stron</Polish> </Key> <Key ID="STR_ACE_Spectator_sides_Description"> <English>Method of filtering spectatable sides.</English> + <Polish>Wybierz strony, jakie będzie można obserwować po uruchomeniu obserwatora.</Polish> </Key> <Key ID="STR_ACE_Spectator_sides_player"> <English>Player side</English> + <Polish>Strona gracza</Polish> </Key> <Key ID="STR_ACE_Spectator_sides_friendly"> <English>Friendly sides</English> + <Polish>Strony sojusznicze</Polish> </Key> <Key ID="STR_ACE_Spectator_sides_hostile"> <English>Hostile sides</English> + <Polish>Strony wrogie</Polish> </Key> <Key ID="STR_ACE_Spectator_sides_all"> <English>All sides</English> + <Polish>Wszystkie strony</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_DisplayName"> <English>Camera modes</English> + <Polish>Tryby kamery</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_Description"> <English>Camera modes that can be used.</English> + <Polish>Tryby kamery, jakie mogą być używane.</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_all"> <English>All</English> + <Polish>Wszystkie</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_free"> <English>Free only</English> + <Polish>Tylko wolna</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_internal"> <English>Internal only</English> + <Polish>Tylko wewnętrzna</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_external"> <English>External only</English> + <Polish>Tylko zewnętrzna</Polish> </Key> <Key ID="STR_ACE_Spectator_modes_unit"> <English>Internal and external</English> + <Polish>Wewnętrzna i zewnętrzna</Polish> </Key> <Key ID="STR_ACE_Spectator_visions_DisplayName"> <English>Vision modes</English> + <Polish>Tryby wizji</Polish> </Key> <Key ID="STR_ACE_Spectator_visions_Description"> <English>Vision modes that can be used.</English> + <Polish>Tryby wizji, jakie mogą być używane.</Polish> </Key> <Key ID="STR_ACE_Spectator_visions_nv"> <English>Night vision</English> + <Polish>Noktowizja</Polish> </Key> <Key ID="STR_ACE_Spectator_visions_ti"> <English>Thermal imaging</English> + <Polish>Termowizja</Polish> </Key> <Key ID="STR_ACE_Spectator_icons_DisplayName"> <English>Unit icons</English> + <Polish>Ikony jednostek</Polish> </Key> <Key ID="STR_ACE_Spectator_icons_Description"> <English>Render icons above spectatable units.</English> + <Polish>Renderuj ikony nad głowami jednostek, które można obserwować.</Polish> </Key> - <!-- Interface strings --> <Key ID="STR_ACE_Spectator_HelpTitle"> <English>Spectator Controls</English> + <Polish>Sterowanie obserwatorem</Polish> </Key> <Key ID="STR_ACE_Spectator_ViewFree"> <English>Free</English> + <Polish>Wolna</Polish> </Key> <Key ID="STR_ACE_Spectator_ViewInternal"> <English>Internal</English> + <Polish>Wewnętrzna</Polish> </Key> <Key ID="STR_ACE_Spectator_ViewExternal"> <English>External</English> + <Polish>Zewnętrzna</Polish> </Key> <Key ID="STR_ACE_Spectator_VisionNormal"> <English>Normal</English> + <Polish>Normalna</Polish> </Key> <Key ID="STR_ACE_Spectator_VisionNight"> <English>Night</English> + <Polish>Noc</Polish> </Key> <Key ID="STR_ACE_Spectator_VisionThermal"> <English>Thermal</English> + <Polish>Termo</Polish> </Key> - <!-- Controls --> <Key ID="STR_ACE_Spectator_freeCamControls"> <English>Free Camera Controls</English> + <Polish>Wolne sterowanie kamerą</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamForward"> <English>Camera Forward</English> + <Polish>Kamera naprzód</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamBackward"> <English>Camera Backward</English> + <Polish>Kamera w tył</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamLeft"> <English>Camera Left</English> + <Polish>Kamera w lewo</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamRight"> <English>Camera Right</English> + <Polish>Kamera w prawo</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamUp"> <English>Camera Up</English> + <Polish>Kamera w górę</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamDown"> <English>Camera Down</English> + <Polish>Kamera w dół</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamPan"> <English>Pan Camera</English> + <Polish>Panoramowanie</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamDolly"> <English>Dolly Camera</English> + <Polish>Płynna kamera</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamLock"> <English>Lock Camera to Target</English> + <Polish>Zablokuj kamerę na celu</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamZoom"> - <English>Zoom In/Out</English> + <English>Zoom +/-</English> + <Polish>Zoom +/-</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamSpeed"> - <English>Speed Up/Down</English> + <English>Speed +/-</English> + <Polish>Prędkość +/-</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamNextVis"> <English>Next Vision Mode</English> + <Polish>Następny tryb wizji</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamPrevVis"> <English>Previous Vision Mode</English> + <Polish>Poprzedni tryb wizji</Polish> </Key> - <Key ID="STR_ACE_Spectator_uiControls"> <English>Interface Controls</English> + <Polish>Sterowanie interfejsem</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleInterface"> <English>Toggle Interface</English> + <Polish>Przełącz interfejs</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleIcons"> <English>Toggle Unit Icons</English> + <Polish>Przełącz ikony jednostek</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleUnits"> <English>Toggle Unit List</English> + <Polish>Przełącz listę jednostek</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleTools"> <English>Toggle Toolbar</English> + <Polish>Przełącz pasek narzędzi</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleCompass"> <English>Toggle Compass</English> + <Polish>Przełącz kompas</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleMap"> <English>Toggle Map</English> + <Polish>Przełącz mapę</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleHelp"> <English>Toggle Help</English> + <Polish>Przełącz pomoc</Polish> </Key> - <Key ID="STR_ACE_Spectator_otherControls"> <English>Other Controls</English> + <Polish>Pozostałe sterowanie</Polish> </Key> <Key ID="STR_ACE_Spectator_nextCam"> <English>Next Camera</English> + <Polish>Następna kamera</Polish> </Key> <Key ID="STR_ACE_Spectator_prevCam"> <English>Previous Camera</English> + <Polish>Poprzednia kamera</Polish> </Key> <Key ID="STR_ACE_Spectator_nextUnit"> <English>Next Unit</English> + <Polish>Następna jednostka</Polish> </Key> <Key ID="STR_ACE_Spectator_prevUnit"> <English>Previous Unit</English> + <Polish>Poprzednia jednostka</Polish> </Key> </Package> </Project> From b87b4ea16aba273aca2ad287239bd45f60c890c5 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Mon, 3 Aug 2015 00:22:50 +0100 Subject: [PATCH 07/43] Improve spectator GUI reopening prevention Using boolean instead of simply checking for the display. Checking for diplay was unreliable since it can be technically closed while theoretically open during the escape menu and such. --- addons/spectator/XEH_preInit.sqf | 2 +- addons/spectator/functions/fnc_handleInterface.sqf | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index a77d731478..3b317ba904 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -38,7 +38,7 @@ GVAR(camUnit) = objNull; GVAR(camVision) = -2; GVAR(camZoom) = 1.25; -SETUVAR(GVAR(display),nil); +GVAR(open) = false; GVAR(showComp) = true; GVAR(showHelp) = true; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 2fa0d1439c..114f4e163b 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -23,7 +23,8 @@ switch (toLower _mode) do { // Safely open/close the interface case "open": { // Prevent reopening - if !(isNull (GETUVAR(GVAR(display),displayNull))) exitWith {}; + if (GVAR(open)) exitWith {}; + GVAR(open) = true; // Initalize camera variables GVAR(camBoom) = 0; @@ -57,13 +58,13 @@ switch (toLower _mode) do { }; case "close": { // Can't close a second time - if (isNull (GETUVAR(GVAR(display),displayNull))) exitWith {}; + if !(GVAR(open)) exitWith {}; + GVAR(open) = false; // Terminate interface while {dialog} do { closeDialog 0; }; - GETUVAR(GVAR(display),displayNull) closeDisplay 0; // Terminate camera GVAR(camera) cameraEffect ["terminate", "back"]; @@ -95,8 +96,6 @@ switch (toLower _mode) do { case "onload": { _args params ["_display"]; - SETUVAR(GVAR(display),_display); - // Always show interface and hide map upon opening [_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(toggleInterface); @@ -149,8 +148,7 @@ switch (toLower _mode) do { //_display displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}]; }; case "onunload": { - SETUVAR(GVAR(display),nil); - + // Kill GUI PFHs GVAR(camHandler) = nil; GVAR(compHandler) = nil; GVAR(iconHandler) = nil; From 98b088f26f717d172c3bdb5e1a0695412ce38c5a Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Mon, 3 Aug 2015 00:24:36 +0100 Subject: [PATCH 08/43] Fix pre-spectator position saving When staging a spectator (physically applying the spectator state) the unit position is saved for potential later restoration. This shouldn't be done multiple times since the function can be called again to reset staged units. --- addons/spectator/functions/fnc_handleRespawn.sqf | 2 ++ addons/spectator/functions/fnc_stageSpectator.sqf | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/spectator/functions/fnc_handleRespawn.sqf b/addons/spectator/functions/fnc_handleRespawn.sqf index 3e7dfa41f3..aa695dd553 100644 --- a/addons/spectator/functions/fnc_handleRespawn.sqf +++ b/addons/spectator/functions/fnc_handleRespawn.sqf @@ -15,4 +15,6 @@ #include "script_component.hpp" +params ["_unit","_oldUnit"]; + [_unit,false] call FUNC(setSpectator); diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 84bd6ffced..bac5174601 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -40,13 +40,16 @@ _unit enableSimulation !_set; [_unit, _set, QGVAR(isStaged), side group _unit] call EFUNC(common,switchToGroupSide); if (_set) then { - // Move and hide the player ASAP to avoid being seen - GVAR(oldPos) = getPosATL _unit; - _unit setPos (getMarkerPos QGVAR(respawn)); + // Position should only be saved on first entry + if !(GETVAR(_unit,GVAR(isStaged),false)) then { + GVAR(oldPos) = getPosATL _unit; + }; // Ghosts can't talk [_unit, QGVAR(isStaged)] call EFUNC(common,hideUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,muteUnit); + + _unit setPos (getMarkerPos QGVAR(respawn)); } else { // Physical beings can talk [_unit, QGVAR(isStaged)] call EFUNC(common,unhideUnit); From f5e7185aec965d0166cf8cae2e85a6b81d717a44 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Mon, 3 Aug 2015 13:04:36 +0100 Subject: [PATCH 09/43] Fix spectator camera exiting mechanism When using ACE_Player the camera would return to the dead body. It makes sense to simply pass the reset unit by reference to the camera exit code. --- addons/spectator/functions/fnc_handleInterface.sqf | 4 +++- addons/spectator/functions/fnc_setSpectator.sqf | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 114f4e163b..255d282983 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -57,6 +57,8 @@ switch (toLower _mode) do { }; }; case "close": { + _args params ["_unit"]; + // Can't close a second time if !(GVAR(open)) exitWith {}; GVAR(open) = false; @@ -71,7 +73,7 @@ switch (toLower _mode) do { camDestroy GVAR(camera); // Return to player view - ACE_Player switchCamera "internal"; + _unit switchCamera "internal"; // Cleanup camera variables GVAR(camera) = nil; diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index 2f8e1d3c2d..b6e85926c5 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -36,7 +36,7 @@ if !(local _unit) exitwith { if (_set) then { ["open"] call FUNC(handleInterface); } else { - ["close"] call FUNC(handleInterface); + ["close",_unit] call FUNC(handleInterface); }; // Handle common addon audio From 5bfa4e597113356d534d28cef9b5dc011b761e6f Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Mon, 3 Aug 2015 15:18:09 +0100 Subject: [PATCH 10/43] Improve spectator camera vision mode on start The spectator camera should start in night vision mode if the sun to moon transition state is appropriate --- addons/spectator/functions/fnc_handleInterface.sqf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 255d282983..315398ab0c 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -37,6 +37,11 @@ switch (toLower _mode) do { GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; + // Camera starts with night vision if it's dark + if (sunOrMoon < 1) then { + [nil,nil,-1] call FUNC(setCameraAttributes); + }; + // Initalize the camera view GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); [] call FUNC(transitionCamera); From 7e9500f2ca6a240458b16031153565ff8e451efa Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Mon, 3 Aug 2015 21:38:44 +0100 Subject: [PATCH 11/43] Enable ace_spectator respawn framework integration Seamlessly integrates the spectator system with the vanilla respawn framework when the onDeath setting is enabled. This commit makes a lot of changes: - Edit BI functions used by the vanilla respawn framework to enable support for ace_spectator. - Set spectator state is now tracked using a GVAR for the local player since using a unit won't be reliable all of the time. However unit is still marked for any filtering purposes. - Instead of NV being used based on the sun to moon transition state by default, that functionality only takes place in the integrated system so that custom frameworks can do what they want. - Seagull units are hidden when using framework integration since they're spawned by the engine with respawn type 1 and they just hang around undesirably --- addons/spectator/XEH_postInit.sqf | 7 - addons/spectator/XEH_preInit.sqf | 12 +- addons/spectator/config.cpp | 35 +++ .../functions/fnc_bi_respawnBase.sqf | 35 +++ .../functions/fnc_bi_respawnCounter.sqf | 35 +++ .../functions/fnc_bi_respawnEndMission.sqf | 62 ++++ .../functions/fnc_bi_respawnInstant.sqf | 35 +++ .../functions/fnc_bi_respawnNone.sqf | 293 ++++++++++++++++++ .../functions/fnc_bi_respawnSeagull.sqf | 101 ++++++ .../functions/fnc_bi_respawnSpectator.sqf | 59 ++++ .../functions/fnc_bi_respawnWave.sqf | 43 +++ .../functions/fnc_handleInterface.sqf | 22 +- .../spectator/functions/fnc_handleKilled.sqf | 26 -- .../spectator/functions/fnc_handleRespawn.sqf | 20 -- .../functions/fnc_setCameraAttributes.sqf | 2 +- .../spectator/functions/fnc_setSpectator.sqf | 31 +- .../functions/fnc_stageSpectator.sqf | 4 +- 17 files changed, 736 insertions(+), 86 deletions(-) create mode 100644 addons/spectator/functions/fnc_bi_respawnBase.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnCounter.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnEndMission.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnInstant.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnNone.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnSeagull.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnSpectator.sqf create mode 100644 addons/spectator/functions/fnc_bi_respawnWave.sqf delete mode 100644 addons/spectator/functions/fnc_handleKilled.sqf delete mode 100644 addons/spectator/functions/fnc_handleRespawn.sqf diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index 45ac78e89c..35b463837f 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -7,11 +7,4 @@ ["SettingsInitialized", { 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); - - if !(hasInterface) exitWith {}; - - if (GVAR(onDeath)) then { - player addEventHandler ["Killed",FUNC(handleKilled)]; - player addEventHandler ["Respawn",FUNC(handleRespawn)]; - }; }] call EFUNC(common,addEventHandler); diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 3b317ba904..73c629a0ce 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -2,15 +2,21 @@ ADDON = false; +PREP(bi_respawnBase); +PREP(bi_respawnCounter); +PREP(bi_respawnEndMission); +PREP(bi_respawnInstant); +PREP(bi_respawnNone); +PREP(bi_respawnSeagull); +PREP(bi_respawnSpectator); +PREP(bi_respawnWave); PREP(cacheUnitInfo); PREP(cycleCamera); PREP(handleCamera); PREP(handleCompass); PREP(handleIcons); PREP(handleInterface); -PREP(handleKilled); PREP(handleMouse); -PREP(handleRespawn); PREP(handleToolbar); PREP(handleUnits); PREP(moduleSpectatorSettings); @@ -38,7 +44,7 @@ GVAR(camUnit) = objNull; GVAR(camVision) = -2; GVAR(camZoom) = 1.25; -GVAR(open) = false; +GVAR(isSet) = false; GVAR(showComp) = true; GVAR(showHelp) = true; diff --git a/addons/spectator/config.cpp b/addons/spectator/config.cpp index e686c75294..eb73761e5f 100644 --- a/addons/spectator/config.cpp +++ b/addons/spectator/config.cpp @@ -16,3 +16,38 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "ui\interface.hpp" + +class CfgRespawnTemplates { + class None { + onPlayerKilled = QFUNC(bi_respawnNone); + }; + class Spectator { + onPlayerKilled = QFUNC(bi_respawnSpectator); + onPlayerRespawn = QFUNC(bi_respawnSpectator); + }; + class Instant { + onPlayerKilled = QFUNC(bi_respawnInstant); + onPlayerRespawn = QFUNC(bi_respawnInstant); + }; + class Base { + onPlayerKilled = QFUNC(bi_respawnBase); + onPlayerRespawn = QFUNC(bi_respawnBase); + }; + class EndMission + { + onPlayerKilled = QFUNC(bi_respawnEndMission); + onPlayerRespawn = QFUNC(bi_respawnEndMission); + }; + class Seagull { + onPlayerRespawn = QFUNC(bi_respawnSeagull); + }; + class Wave + { + onPlayerKilled = QFUNC(bi_respawnWave); + onPlayerRespawn = QFUNC(bi_respawnWave); + }; + class Counter { + onPlayerKilled = QFUNC(bi_respawnCounter); + onPlayerRespawn = QFUNC(bi_respawnCounter); + }; +}; diff --git a/addons/spectator/functions/fnc_bi_respawnBase.sqf b/addons/spectator/functions/fnc_bi_respawnBase.sqf new file mode 100644 index 0000000000..7ea5b0c745 --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnBase.sqf @@ -0,0 +1,35 @@ +/* + * Author: Bohemia Interactive + * Part of the BI respawn framework + * Handles base respawn type (respawn on marker) + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +if !(GVAR(onDeath)) exitWith {}; + +params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]]]; + +if (alive _unit) then { + [_unit,false] call FUNC(setSpectator); +} else { + private ["_vision","_pos"]; + if (isNull _killer) then {_killer = _unit}; + _vision = [-2,-1] select (sunOrMoon < 1); + _pos = (getPosATL _unit) vectorAdd [0,0,5]; + + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); +}; diff --git a/addons/spectator/functions/fnc_bi_respawnCounter.sqf b/addons/spectator/functions/fnc_bi_respawnCounter.sqf new file mode 100644 index 0000000000..0bee90ec61 --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnCounter.sqf @@ -0,0 +1,35 @@ +/* + * Author: Bohemia Interactive (Karel Moricky) + * Part of the BI respawn framework + * Handles the respawn timer display + * Edited to disable counter when spectator is opened + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +_player = [_this,0,objNull,[objnull]] call bis_fnc_param; + +_respawnDelay = [_this,3,0,[0]] call bis_fnc_param; + +if (!isplayer _player && !isnull _player && _respawnDelay > 0) exitwith {["Attempting to use the function on AI unit %1, can be used only on players."] call bis_fnc_error;}; + +//--- Engine-triggered respawn +_layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer; + +if (!alive _player) then { + if (GVAR(onDeath) || (playerrespawntime < 1)) exitwith {}; + _layer cutrsc ["RscRespawnCounter","plain"]; +} else { + _layer cuttext ["","plain"]; +}; diff --git a/addons/spectator/functions/fnc_bi_respawnEndMission.sqf b/addons/spectator/functions/fnc_bi_respawnEndMission.sqf new file mode 100644 index 0000000000..23b8dacc17 --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnEndMission.sqf @@ -0,0 +1,62 @@ +/* + * Author: Bohemia Interactive (Karel Moricky) + * Part of the BI respawn framework + * Ends the mission when all players are dead + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]]]; +private ["_vision","_pos"]; + +if (isNull _killer) then {_killer = _unit}; +_vision = [-2,-1] select (sunOrMoon < 1); +_pos = (getPosATL _unit) vectorAdd [0,0,5]; + +if (ismultiplayer) then { + + _respawnType = 0 call bis_fnc_missionRespawnType; + if (_respawnType in [0,1,4,5]) then { + + //--- No more respawn slots + if ({isplayer _x && alive _x} count playableunits == 0) then { + [["endDeath",false],"bis_fnc_endmission"] call bis_fnc_mp; + } else { + if (GVAR(onDeath) && (_respawnType in [0,1])) then { + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); + }; + }; + + //--- Don't end the script to prevent premature mission end + waituntil {false}; + } else { + + if (!alive _unit) then { + + //--- No more respawn tickets + if ([] call bis_fnc_respawntickets == 0 && {isplayer _x} count playableunits == 0) then { + [["endDeath",false],"bis_fnc_endmission"] call bis_fnc_mp; + } else { + if (GVAR(onDeath)) then { + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); + }; + }; + } else { + [_unit,false] call FUNC(setSpectator); + }; + }; +}; diff --git a/addons/spectator/functions/fnc_bi_respawnInstant.sqf b/addons/spectator/functions/fnc_bi_respawnInstant.sqf new file mode 100644 index 0000000000..fd1d255cf9 --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnInstant.sqf @@ -0,0 +1,35 @@ +/* + * Author: Bohemia Interactive + * Part of the BI respawn framework + * Handles instant respawn type (respawn at position of death) + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +if !(GVAR(onDeath)) exitWith {}; + +params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]]]; + +if (alive _unit) then { + [_unit,false] call FUNC(setSpectator); +} else { + private ["_vision","_pos"]; + if (isNull _killer) then {_killer = _unit}; + _vision = [-2,-1] select (sunOrMoon < 1); + _pos = (getPosATL _unit) vectorAdd [0,0,5]; + + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); +}; diff --git a/addons/spectator/functions/fnc_bi_respawnNone.sqf b/addons/spectator/functions/fnc_bi_respawnNone.sqf new file mode 100644 index 0000000000..a5031a8fd9 --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnNone.sqf @@ -0,0 +1,293 @@ +/* + * Author: Bohemia Interactive (Karel Moricky) + * Part of the BI respawn framework + * Shows death screen for respawn type "None" + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse <OBJECT> + * 1: Killer <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ +private ["_soundvolume","_musicvolume"]; + +#define BI_CONTROL (_display displayctrl _n) + +#include "script_component.hpp" + +disableserialization; +_player = _this select 0; +_killer = _this select 1; +if (isnull _killer) then {_killer = _player}; + +_musicvolume = musicvolume; +_soundvolume = soundvolume; //MUF-TODO: check if this is done before sound is faded in fn_feedbackMain.fsm + +_start = isnil "bis_fnc_respawnNone_start"; +if (_start) then { + bis_fnc_respawnNone_start = [daytime,time / 3600]; + + //3.5 fadesound 0; //MUF-commented + + sleep 2; + if (alive player) exitwith {}; + cutText ["","BLACK OUT",1]; + sleep 1.5; + BIS_fnc_feedback_allowPP = false; //MUF-switch health PP off + //(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",1];//MUF-black in (remove black screen that was launched in FSM PP) + + if (ismultiplayer) then { + if (GVAR(onDeath)) then { + private ["_vision","_pos"]; + _vision = [-2,-1] select (sunOrMoon < 1); + _pos = (getPosATL _player) vectorAdd [0,0,5]; + + [2,_killer,_vision,_pos,getDir _player] call FUNC(setCameraAttributes); + [_player] call FUNC(setSpectator); + } else { + (finddisplay 46) createdisplay "RscDisplayMissionEnd"; + }; + } else {enableenddialog}; +}; +if (alive player) exitwith { + [player,false] call FUNC(setSpectator); + cuttext ["","plain"]; +}; //--- Terminate when player manages to switch do different unit already + +if (GVAR(onDeath)) exitWith {}; + +waituntil {!isnull (finddisplay 58)}; +_display = finddisplay 58; + +//--- Black fade in +_n = 1060; +BI_CONTROL ctrlsetfade 1; +if (_start) then { + + //--- Play ambient radio + setacctime 1; + 0 fademusic 0; + 4 fademusic 0.8; + playmusic format ['RadioAmbient%1',ceil random 1/*30*/]; + _musicEH = addMusicEventHandler ["MusicStop",{[] spawn {playmusic format ['RadioAmbient%1',ceil random 1/*30*/];};}]; + uinamespace setvariable ["bis_fnc_respawnNone_musicEH",_musicEH]; + _display displayaddeventhandler ["unload","removeMusicEventHandler ['MusicStop',uinamespace getvariable ['bis_fnc_respawnNone_musicEH',-1]];"]; + + BI_CONTROL ctrlcommit 4; +} else { + BI_CONTROL ctrlcommit 0; +}; +cuttext ["","plain"]; + +//--- HUD +_n = 5800; +BI_CONTROL ctrlsettext gettext (configfile >> "cfgingameui" >> "cursor" >> "select"); +BI_CONTROL ctrlsetposition [-10,-10,safezoneH * 0.07 * 3/4,safezoneH * 0.07]; +BI_CONTROL ctrlsettextcolor [1,1,1,1]; +BI_CONTROL ctrlcommit 0; + +//--- SITREP (ToDO: Localize) +_sitrep = "SITREP||"; +if (name _player != "Error: No unit") then { + _sitrep = _sitrep + "KIA: %4. %5|"; +}; +_sitrep = _sitrep + "TOD: %2 [%3]|LOC: %6 \ %7"; +if (_killer != _player) then { + _sitrep = _sitrep + "||ENY: %8"; + if (currentweapon _killer != "") then { + _sitrep = _sitrep + "|ENW: %9</t>" + }; +}; +_sitrep = format [ + _sitrep, + 1 * safezoneH, + [bis_fnc_respawnNone_start select 0,"HH:MM:SS"] call bis_fnc_timetostring, + [bis_fnc_respawnNone_start select 1,"HH:MM:SS"] call bis_fnc_timetostring, + toupper localize format ["STR_SHORT_%1",rank _player], + toupper name _player, + mapGridPosition _player, + toupper worldname, + toupper ((configfile >> "cfgvehicles" >> typeof _killer) call bis_fnc_displayname), + toupper ((configfile >> "cfgweapons" >> currentweapon _killer) call bis_fnc_displayname) + +]; + +_n = 11000; +_bcgPos = ctrlposition BI_CONTROL; +_n = 5858; +//BI_CONTROL ctrlsetposition [_bcgPos select 0,safezoneY + ((_bcgPos select 0) - safezoneX) * 4/3,safezoneW - 2 * (_bcgPos select 2),safezoneH / 2]; +BI_CONTROL ctrlsetposition [(((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX), + ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY), + safezoneW - 2 * (_bcgPos select 2), + safezoneH / 2]; +BI_CONTROL ctrlcommit 0; +[BI_CONTROL,_sitrep] spawn { + scriptname "bis_fnc_respawnNone: SITREP"; + disableserialization; + _control = _this select 0; + _sitrepArray = toarray (_this select 1); + {_sitrepArray set [_foreachindex,tostring [_x]]} foreach _sitrepArray; + _sitrep = ""; + //_sitrepFormat = "<t align='left' font='EtelkaMonospacePro' shadow='1' size='" + str safezoneH + "'>%1</t>"; + _sitrepFormat = "<t align='left' font='EtelkaMonospacePro' shadow='1'>%1</t>"; + + sleep 1; + for "_i" from 0 to (count _sitrepArray - 1) do { + _letter = _sitrepArray select _i; + _delay = if (_letter == "|") then {_letter = "<br />"; 1} else {0.01}; + _sitrep = _sitrep + _letter; + _control ctrlsetstructuredtext parsetext format [_sitrepFormat,_sitrep + "_"]; + //playsound ["IncomingChallenge",true]; + sleep _delay; + if (isnull _control) exitwith {}; + }; + _control ctrlsetstructuredtext parsetext format [_sitrepFormat,_sitrep]; +}; + + +//--- Create UAV camera +_camera = "camera" camcreate position player; +_camera cameraeffect ["internal","back"]; +_camera campreparefov 0.4; +_camera campreparetarget _killer; +showcinemaborder false; + +//--- Set PP effects +_saturation = 0.0 + random 0.3; +_ppColor = ppEffectCreate ["ColorCorrections", 1999]; +_ppColor ppEffectEnable true; +_ppColor ppEffectAdjust [1, 1, 0, [1, 1, 1, 0], [1 - _saturation, 1 - _saturation, 1 - _saturation, _saturation], [1, 0.25, 0, 1.0]]; +_ppColor ppEffectCommit 0; + +_ppGrain = ppEffectCreate ["filmGrain", 2012]; +_ppGrain ppEffectEnable true; +_ppGrain ppEffectAdjust [random 0.2, 1, 1, 0, 1]; +_ppGrain ppEffectCommit 0; + +//--- Camera update executed every frame +bis_fnc_respawnNone_player = _player; +bis_fnc_respawnNone_killer = _killer; +bis_fnc_respawnNone_camera = _camera; +bis_fnc_respawnNone_loop = { + scriptname "bis_fnc_respawnNone: camera"; + _display = _this select 0; + _player = bis_fnc_respawnNone_player; + _killer = bis_fnc_respawnNone_killer; + _camera = bis_fnc_respawnNone_camera; + + _sin = 20 * sin (time * 7); + _killerPos = [ + (visiblepositionasl _killer select 0), + (visiblepositionasl _killer select 1) + (_sin), + (visiblepositionasl _killer select 2) + (_sin) + ]; + + _dirToKiller = if (_killer == _player) then { + direction _player; + } else { + ([_player,_killerPos] call bis_fnc_dirto) + _sin; + }; + _pos = [ + visiblepositionasl _player, + -20, + _dirToKiller + ] call bis_fnc_relpos; + _pos set [2,((_pos select 2) + 7) max (getterrainheightasl _pos + 7)]; + + //--- Pitch + _heightCamera = getterrainheightasl _pos; + _heightKiller = getterrainheightasl _killerPos; + _height = _heightCamera - _heightKiller; + _dis = _killerPos distance _pos; + _angle = (asin (_height/_dis)); + + _camera setdir _dirtokiller; + [_camera,-_angle,_sin] call bis_fnc_setpitchbank; + _camera setposasl _pos; + + //--- HUD + _n = 5800; + _hudPos = (worldtoscreen position _player); + if (count _hudPos > 0) then { + _hudPosW = ctrlposition BI_CONTROL select 2; + _hudPosH = ctrlposition BI_CONTROL select 3; + _hudPos = [ + (_hudPos select 0) - _hudPosW / 2, + (_hudPos select 1) - _hudPosH / 2, + _hudPosW, + _hudPosH + ]; + BI_CONTROL ctrlsetposition _hudPos; + BI_CONTROL ctrlcommit 0; + }; +}; + +bis_fnc_respawnNone_keydown = { + _key = _this select 1; + + if (_key in (actionkeys 'nightvision') || _key < 0) then { + bis_fnc_respawnNone_vision = bis_fnc_respawnNone_vision + 1; + _vision = bis_fnc_respawnNone_vision % 4; + switch (_vision) do { + case 0: { + camusenvg false; + call compile 'false SetCamUseTi 0'; + }; + case 1: { + camusenvg true; + call compile 'false SetCamUseTi 0'; + }; + case 2: { + camusenvg false; + call compile 'true SetCamUseTi 0'; + }; + case 3: { + camusenvg false; + call compile 'true SetCamUseTi 1'; + }; + }; + }; +}; +//bis_fnc_respawnNone_vision = (1 + floor random 3) % 4; //--- Random vision (not NVG) +bis_fnc_respawnNone_vision = -1; +if (sunormoon < 1) then {bis_fnc_respawnNone_vision = 0;}; +[-1,-1] call bis_fnc_respawnNone_keydown; + +_display displayaddeventhandler ["mousemoving","_this call bis_fnc_respawnNone_loop"]; +_display displayaddeventhandler ["mouseholding","_this call bis_fnc_respawnNone_loop"]; +_display displayaddeventhandler ["keydown","_this call bis_fnc_respawnNone_keydown"]; + + +//--- Team Switch display opened +waituntil {isnull _display}; +_displayTeamSwitch = finddisplay 632; + +//--- Team Switch display closed - cleanup and restart the view +waituntil {isnull _displayTeamSwitch}; + +_camera cameraeffect ["terminate","back"]; +camdestroy _camera; + +bis_fnc_respawnNone_player = nil; +bis_fnc_respawnNone_killer = nil; +bis_fnc_respawnNone_camera = nil; +bis_fnc_respawnNone_loop = nil; + +ppeffectdestroy _ppColor; +ppeffectdestroy _ppGrain; + +if (!alive player) exitwith {_this call bis_fnc_respawnNone;}; + + +//--- Resurrection! +BIS_fnc_feedback_allowPP = true; +0 fadesound _soundvolume; +0 fademusic _musicvolume; +playmusic ""; +bis_fnc_respawnNone_start = nil; diff --git a/addons/spectator/functions/fnc_bi_respawnSeagull.sqf b/addons/spectator/functions/fnc_bi_respawnSeagull.sqf new file mode 100644 index 0000000000..2e01ffa6ea --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnSeagull.sqf @@ -0,0 +1,101 @@ +/* + * Author: Bohemia Interactive + * Part of the BI respawn framework + * Correctly handles seagull respawn (not used by default) + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +_seagull = _this select 0; +_player = _this select 1; +_this call bis_fnc_log; + +if (!isplayer _player && !isplayer _seagull) exitwith {["Attempting to use the function on AI unit %1, can be used only on players."] call bis_fnc_error;}; + +waituntil {missionnamespace getvariable ["BIS_fnc_feedback_allowDeathScreen",true]}; +BIS_fnc_feedback_allowPP = false; +//(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",8]; + +if (GVAR(onDeath)) exitWith { + private ["_vision","_pos"]; + + if (isNull _player) then {_player = _seagull}; + _vision = [-2,-1] select (sunOrMoon < 1); + _pos = (getPosATL _player) vectorAdd [0,0,5]; + + [_seagull,QGVAR(isSeagull)] call EFUNC(common,hideUnit); + [2,_player,_vision,_pos,getDir _seagull] call FUNC(setCameraAttributes); + [_seagull] call FUNC(setSpectator); +}; + +_camera = "camera" camCreate [(position _player select 0)-0.75, (position _player select 1)-0.75,(position _player select 2) + 0.5]; +_camera cameraEffect ["internal","back"]; +_camera camSetFOV 0.800; +_camera camCommit 0; +waituntil {camCommitted _camera}; + +0 fadeMusic 0.5; +playMusic "Track06_Abandoned_Battlespace"; + +_camera camSetTarget vehicle _player; +_camera camSetRelPos [-0.82,-3.12,3.38]; +_camera camSetFOV 0.800; +_camera camCommit 7; + +sleep 1; +_preload = _player spawn {waitUntil {(preloadCamera getPos _this) && (2 preloadObject _this)}}; +sleep 5; +waituntil {camCommitted _camera}; + +_camera camSetRelPos [1.17,-21.71,2.07]; +_camera camSetFOV 0.400; +_camera camCommit 10; +sleep 2; +terminate _preload; +sleep 3; +_preload = _player spawn {waitUntil {(preloadCamera getPos _this) && (3 preloadObject _this)}}; +waituntil {camCommitted _camera}; + +_camera camSetTarget vehicle _player; +_camera camSetRelPos [5.80,1.29,5.07]; +_camera camSetFOV 0.300; +_camera camCommit 7; +sleep 2; +terminate _preload; +_preload = _seagull spawn {waitUntil {(preloadCamera getPos _this) && (4 preloadObject _this)}}; +waituntil {camCommitted _camera}; + +_camera camSetRelPos [2.71,19.55,12.94]; +_camera camSetFOV 0.700; +_camera camCommit 2; +waituntil {camCommitted _camera}; + +_camera camSetTarget _seagull; +_camera camSetRelPos [-6.66,18.99,2.59]; +_camera camSetFOV 0.700; +_camera camCommit 3; +waituntil {camCommitted _camera}; + +3 fadeMusic 0; + +_camera camSetRelPos [1.17,-21.71,-1.07]; +_camera camSetFOV 0.300; +_camera camCommit 3; +waituntil {camCommitted _camera}; +terminate _preload; + +_seagull switchCamera "EXTERNAL"; +_seagull cameraEffect ["terminate","back"]; +camDestroy _camera; diff --git a/addons/spectator/functions/fnc_bi_respawnSpectator.sqf b/addons/spectator/functions/fnc_bi_respawnSpectator.sqf new file mode 100644 index 0000000000..5097b61ab2 --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnSpectator.sqf @@ -0,0 +1,59 @@ +/* + * Author: Bohemia Interactive + * Part of the BI respawn framework + * Opens BI spectator interface (default used by seagull respawn) + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",-1,[0]]]; +private ["_vision","_pos"]; + +if (isNull _killer) then {_killer = _unit}; +_vision = [-2,-1] select (sunOrMoon < 1); +_pos = (getPosATL _unit) vectorAdd [0,0,5]; + +_layer = "BIS_fnc_respawnSpectator" call bis_fnc_rscLayer; + +if (!alive _unit) then { + if (GVAR(onDeath)) then { + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); + } else { + _layer cutrsc ["RscSpectator","plain"]; + }; +} else { + if (_respawn == 1) then { + + //--- Open + waituntil {missionnamespace getvariable ["BIS_fnc_feedback_allowDeathScreen",true]}; + BIS_fnc_feedback_allowPP = false; + //(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",1]; + if (GVAR(onDeath)) then { + [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); + } else { + _layer cutrsc ["RscSpectator","plain"]; + }; + } else { + if (GVAR(onDeath)) then { + [_unit,false] call FUNC(setSpectator); + }; + + //--- Close + _layer cuttext ["","plain"]; + }; +}; diff --git a/addons/spectator/functions/fnc_bi_respawnWave.sqf b/addons/spectator/functions/fnc_bi_respawnWave.sqf new file mode 100644 index 0000000000..371a8edcdc --- /dev/null +++ b/addons/spectator/functions/fnc_bi_respawnWave.sqf @@ -0,0 +1,43 @@ +/* + * Author: Bohemia Interactive + * Part of the BI respawn framework + * Handles wave respawning system + * Edited to support ace_spectator integration + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; + +if (!isplayer _unit && !isnull _unit) exitwith {["Attempting to use the function on AI unit %1, can be used only on players."] call bis_fnc_error;}; + +if (!alive _unit) then { + //--- Set the time only when it was not modified already + if (_respawnDelay != 0 && _respawnDelay == playerrespawntime) then { + setplayerrespawntime (_respawnDelay + _respawnDelay - (servertime % _respawnDelay)); + + if !(GVAR(onDeath)) exitWith {}; + private ["_vision","_pos"]; + + if (isNull _killer) then {_killer = _unit}; + _vision = [-2,-1] select (sunOrMoon < 1); + _pos = (getPosATL _unit) vectorAdd [0,0,5]; + + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); + }; +} else { + setplayerrespawntime _respawndelay; + [_unit,false] call FUNC(setSpectator); +}; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 315398ab0c..5c8c958451 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -23,8 +23,7 @@ switch (toLower _mode) do { // Safely open/close the interface case "open": { // Prevent reopening - if (GVAR(open)) exitWith {}; - GVAR(open) = true; + if (GVAR(isSet)) exitWith {}; // Initalize camera variables GVAR(camBoom) = 0; @@ -37,15 +36,17 @@ switch (toLower _mode) do { GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; - // Camera starts with night vision if it's dark - if (sunOrMoon < 1) then { - [nil,nil,-1] call FUNC(setCameraAttributes); - }; - // Initalize the camera view GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); [] call FUNC(transitionCamera); + // Close map + openMap [false,false]; + + // Close any BI layers/effects + BIS_fnc_feedback_allowPP = false; + ("BIS_fnc_respawnCounter" call BIS_fnc_rscLayer) cutText ["","plain"]; + // Close all existing dialogs while {dialog} do { closeDialog 0; @@ -65,8 +66,7 @@ switch (toLower _mode) do { _args params ["_unit"]; // Can't close a second time - if !(GVAR(open)) exitWith {}; - GVAR(open) = false; + if !(GVAR(isSet)) exitWith {}; // Terminate interface while {dialog} do { @@ -80,6 +80,10 @@ switch (toLower _mode) do { // Return to player view _unit switchCamera "internal"; + // Re-enable any BI effects + BIS_fnc_feedback_allowPP = true; + BIS_fnc_respawnNone_start = nil; + // Cleanup camera variables GVAR(camera) = nil; GVAR(camBoom) = nil; diff --git a/addons/spectator/functions/fnc_handleKilled.sqf b/addons/spectator/functions/fnc_handleKilled.sqf deleted file mode 100644 index 05671ed749..0000000000 --- a/addons/spectator/functions/fnc_handleKilled.sqf +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Author: SilentSpike - * Set inital camera attributes and set as spectator on death - * Part of the spectator during death system - * - * Arguments: - * 0: Corpse <OBJECT> - * 1: Killer <OBJECT> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -params ["_unit","_killer"]; - -if (isNull _killer) then { - [2,_unit] call FUNC(setCameraAttributes); -} else { - [2,_killer] call FUNC(setCameraAttributes); -}; - -[_unit] call FUNC(setSpectator); diff --git a/addons/spectator/functions/fnc_handleRespawn.sqf b/addons/spectator/functions/fnc_handleRespawn.sqf deleted file mode 100644 index aa695dd553..0000000000 --- a/addons/spectator/functions/fnc_handleRespawn.sqf +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Author: SilentSpike - * Un-set as spectator on respawn - * Part of the spectator during death system - * - * Arguments: - * 0: New unit <OBJECT> - * 1: Old unit <OBJECT> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -params ["_unit","_oldUnit"]; - -[_unit,false] call FUNC(setSpectator); diff --git a/addons/spectator/functions/fnc_setCameraAttributes.sqf b/addons/spectator/functions/fnc_setCameraAttributes.sqf index da2373318d..278a8c4758 100644 --- a/addons/spectator/functions/fnc_setCameraAttributes.sqf +++ b/addons/spectator/functions/fnc_setCameraAttributes.sqf @@ -51,7 +51,7 @@ if !(_vision in GVAR(availableVisions)) then { }; GVAR(camPan) = _heading % 360; -GVAR(camPosition) = (ATLtoASL _position); +GVAR(camPos) = (ATLtoASL _position); GVAR(camSpeed) = (_speed max 0.05) min 10; GVAR(camTilt) = (_tilt max -89) min 89; GVAR(camUnit) = _unit; diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index b6e85926c5..2d5ada415c 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -1,9 +1,9 @@ /* * Author: SilentSpike - * Sets target unit to the given spectator state (virtually) + * Sets target player to the given spectator state (virtually) * To physically handle a spectator see ace_spectator_fnc_stageSpectator * - * Units will be able to communicate in ACRE/TFAR as appropriate + * Player will be able to communicate in ACRE/TFAR as appropriate * The spectator interface will be opened/closed * * Arguments: @@ -23,20 +23,11 @@ params ["_unit", ["_set",true,[true]]]; -// No change, no service (but allow spectators to be reset) -if !(_set || (GETVAR(_unit,GVAR(isSet),false))) exitWith {}; - // Only run for player units if !(isPlayer _unit) exitWith {}; if !(local _unit) exitwith { - [[_unit, _set, _target], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc); -}; - -if (_set) then { - ["open"] call FUNC(handleInterface); -} else { - ["close",_unit] call FUNC(handleInterface); + [[_unit, _set], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc); }; // Handle common addon audio @@ -44,10 +35,14 @@ if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableV if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator}; -// No theoretical change if an existing spectator was reset -if !(_set isEqualTo (GETVAR(_unit,GVAR(isSet),false))) then { - // Mark spectator state for reference - _unit setVariable [QGVAR(isSet), _set, true]; - - ["spectatorSet",[_set]] call EFUNC(common,localEvent); +if (_set) then { + ["open"] call FUNC(handleInterface); +} else { + ["close",_unit] call FUNC(handleInterface); }; + +// Mark spectator state for reference +_unit setVariable [QGVAR(isSet), _set, true]; +GVAR(isSet) = _set; + +["spectatorSet",[_set,_unit]] call EFUNC(common,localEvent); diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index bac5174601..3e17235e3e 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -30,7 +30,7 @@ if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {}; if !(isPlayer _unit) exitWith {}; if !(local _unit) exitwith { - [[_unit, _set, _target], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); + [[_unit, _set], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); }; // Prevent player falling into water @@ -49,7 +49,7 @@ if (_set) then { [_unit, QGVAR(isStaged)] call EFUNC(common,hideUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,muteUnit); - _unit setPos (getMarkerPos QGVAR(respawn)); + _unit setPos (markerPos QGVAR(respawn)); } else { // Physical beings can talk [_unit, QGVAR(isStaged)] call EFUNC(common,unhideUnit); From 1b12d3728437a948d4e6779f724f7a6387e50396 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Tue, 4 Aug 2015 22:11:34 +0100 Subject: [PATCH 12/43] Replace spectator respawn changes with a template Hacking the BI respawn framework to support a spectator setting was intrusive and limiting. Instead of using a setting, I've opted to introduce a new respawn template that can be used within BI's respawn framework. The benefits of this approach are: - Compatibility isn't a concern, that responsibility is shifted onto mission designers. - Mission designers can use the functionality of the BI framework alongside the spectator system (combining templates, using different templates for different sides, etc.). - If a custom respawn framework is used, then this doesn't change anything. Custom frameworks are still fully supported via the public functions provided. - Remains simple to set up, just requires a description.ext edit --- addons/spectator/ACE_Settings.hpp | 4 - addons/spectator/CfgVehicles.hpp | 6 - addons/spectator/XEH_preInit.sqf | 10 +- addons/spectator/config.cpp | 34 +- .../functions/fnc_bi_respawnBase.sqf | 35 --- .../functions/fnc_bi_respawnCounter.sqf | 35 --- .../functions/fnc_bi_respawnEndMission.sqf | 62 ---- .../functions/fnc_bi_respawnInstant.sqf | 35 --- .../functions/fnc_bi_respawnNone.sqf | 293 ------------------ .../functions/fnc_bi_respawnSeagull.sqf | 101 ------ .../functions/fnc_bi_respawnSpectator.sqf | 59 ---- .../functions/fnc_bi_respawnWave.sqf | 43 --- .../functions/fnc_handleInterface.sqf | 5 +- .../functions/fnc_moduleSpectatorSettings.sqf | 1 - .../functions/fnc_respawnTemplate.sqf | 39 +++ .../functions/fnc_transitionCamera.sqf | 8 +- addons/spectator/stringtable.xml | 8 - 17 files changed, 52 insertions(+), 726 deletions(-) delete mode 100644 addons/spectator/functions/fnc_bi_respawnBase.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnCounter.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnEndMission.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnInstant.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnNone.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnSeagull.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnSpectator.sqf delete mode 100644 addons/spectator/functions/fnc_bi_respawnWave.sqf create mode 100644 addons/spectator/functions/fnc_respawnTemplate.sqf diff --git a/addons/spectator/ACE_Settings.hpp b/addons/spectator/ACE_Settings.hpp index 5e7907d19f..539f7cef2d 100644 --- a/addons/spectator/ACE_Settings.hpp +++ b/addons/spectator/ACE_Settings.hpp @@ -1,8 +1,4 @@ class ACE_Settings { - class GVAR(onDeath) { - typeName = "BOOL"; - value = 0; - }; class GVAR(filterUnits) { typeName = "SCALAR"; value = 1; diff --git a/addons/spectator/CfgVehicles.hpp b/addons/spectator/CfgVehicles.hpp index 7067257f23..8e685dae07 100644 --- a/addons/spectator/CfgVehicles.hpp +++ b/addons/spectator/CfgVehicles.hpp @@ -9,12 +9,6 @@ class CfgVehicles { isGlobal = 1; author = ECSTRING(common,ACETeam); class Arguments { - class systemEnable { - displayName = CSTRING(system_DisplayName); - description = CSTRING(system_Description); - typeName = "BOOL"; - defaultValue = 0; - }; class unitsFilter { displayName = CSTRING(units_DisplayName); description = CSTRING(units_Description); diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 73c629a0ce..95c18f4a54 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -2,14 +2,6 @@ ADDON = false; -PREP(bi_respawnBase); -PREP(bi_respawnCounter); -PREP(bi_respawnEndMission); -PREP(bi_respawnInstant); -PREP(bi_respawnNone); -PREP(bi_respawnSeagull); -PREP(bi_respawnSpectator); -PREP(bi_respawnWave); PREP(cacheUnitInfo); PREP(cycleCamera); PREP(handleCamera); @@ -20,6 +12,7 @@ PREP(handleMouse); PREP(handleToolbar); PREP(handleUnits); PREP(moduleSpectatorSettings); +PREP(respawnTemplate); PREP(setCameraAttributes); PREP(setSpectator); PREP(stageSpectator); @@ -35,6 +28,7 @@ GVAR(availableModes) = [0,1,2]; GVAR(availableSides) = [west,east,resistance,civilian]; GVAR(availableVisions) = [-2,-1,0,1]; +GVAR(camAgent) = objNull; GVAR(camMode) = 0; GVAR(camPan) = 0; GVAR(camPos) = ATLtoASL [worldSize * 0.5, worldSize * 0.5, 20]; diff --git a/addons/spectator/config.cpp b/addons/spectator/config.cpp index eb73761e5f..6e32ed0413 100644 --- a/addons/spectator/config.cpp +++ b/addons/spectator/config.cpp @@ -18,36 +18,8 @@ class CfgPatches { #include "ui\interface.hpp" class CfgRespawnTemplates { - class None { - onPlayerKilled = QFUNC(bi_respawnNone); - }; - class Spectator { - onPlayerKilled = QFUNC(bi_respawnSpectator); - onPlayerRespawn = QFUNC(bi_respawnSpectator); - }; - class Instant { - onPlayerKilled = QFUNC(bi_respawnInstant); - onPlayerRespawn = QFUNC(bi_respawnInstant); - }; - class Base { - onPlayerKilled = QFUNC(bi_respawnBase); - onPlayerRespawn = QFUNC(bi_respawnBase); - }; - class EndMission - { - onPlayerKilled = QFUNC(bi_respawnEndMission); - onPlayerRespawn = QFUNC(bi_respawnEndMission); - }; - class Seagull { - onPlayerRespawn = QFUNC(bi_respawnSeagull); - }; - class Wave - { - onPlayerKilled = QFUNC(bi_respawnWave); - onPlayerRespawn = QFUNC(bi_respawnWave); - }; - class Counter { - onPlayerKilled = QFUNC(bi_respawnCounter); - onPlayerRespawn = QFUNC(bi_respawnCounter); + class ADDON { + onPlayerKilled = QFUNC(respawnTemplate); + onPlayerRespawn = QFUNC(respawnTemplate); }; }; diff --git a/addons/spectator/functions/fnc_bi_respawnBase.sqf b/addons/spectator/functions/fnc_bi_respawnBase.sqf deleted file mode 100644 index 7ea5b0c745..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnBase.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: Bohemia Interactive - * Part of the BI respawn framework - * Handles base respawn type (respawn on marker) - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -if !(GVAR(onDeath)) exitWith {}; - -params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]]]; - -if (alive _unit) then { - [_unit,false] call FUNC(setSpectator); -} else { - private ["_vision","_pos"]; - if (isNull _killer) then {_killer = _unit}; - _vision = [-2,-1] select (sunOrMoon < 1); - _pos = (getPosATL _unit) vectorAdd [0,0,5]; - - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); -}; diff --git a/addons/spectator/functions/fnc_bi_respawnCounter.sqf b/addons/spectator/functions/fnc_bi_respawnCounter.sqf deleted file mode 100644 index 0bee90ec61..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnCounter.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: Bohemia Interactive (Karel Moricky) - * Part of the BI respawn framework - * Handles the respawn timer display - * Edited to disable counter when spectator is opened - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -_player = [_this,0,objNull,[objnull]] call bis_fnc_param; - -_respawnDelay = [_this,3,0,[0]] call bis_fnc_param; - -if (!isplayer _player && !isnull _player && _respawnDelay > 0) exitwith {["Attempting to use the function on AI unit %1, can be used only on players."] call bis_fnc_error;}; - -//--- Engine-triggered respawn -_layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer; - -if (!alive _player) then { - if (GVAR(onDeath) || (playerrespawntime < 1)) exitwith {}; - _layer cutrsc ["RscRespawnCounter","plain"]; -} else { - _layer cuttext ["","plain"]; -}; diff --git a/addons/spectator/functions/fnc_bi_respawnEndMission.sqf b/addons/spectator/functions/fnc_bi_respawnEndMission.sqf deleted file mode 100644 index 23b8dacc17..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnEndMission.sqf +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Bohemia Interactive (Karel Moricky) - * Part of the BI respawn framework - * Ends the mission when all players are dead - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]]]; -private ["_vision","_pos"]; - -if (isNull _killer) then {_killer = _unit}; -_vision = [-2,-1] select (sunOrMoon < 1); -_pos = (getPosATL _unit) vectorAdd [0,0,5]; - -if (ismultiplayer) then { - - _respawnType = 0 call bis_fnc_missionRespawnType; - if (_respawnType in [0,1,4,5]) then { - - //--- No more respawn slots - if ({isplayer _x && alive _x} count playableunits == 0) then { - [["endDeath",false],"bis_fnc_endmission"] call bis_fnc_mp; - } else { - if (GVAR(onDeath) && (_respawnType in [0,1])) then { - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); - }; - }; - - //--- Don't end the script to prevent premature mission end - waituntil {false}; - } else { - - if (!alive _unit) then { - - //--- No more respawn tickets - if ([] call bis_fnc_respawntickets == 0 && {isplayer _x} count playableunits == 0) then { - [["endDeath",false],"bis_fnc_endmission"] call bis_fnc_mp; - } else { - if (GVAR(onDeath)) then { - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); - }; - }; - } else { - [_unit,false] call FUNC(setSpectator); - }; - }; -}; diff --git a/addons/spectator/functions/fnc_bi_respawnInstant.sqf b/addons/spectator/functions/fnc_bi_respawnInstant.sqf deleted file mode 100644 index fd1d255cf9..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnInstant.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: Bohemia Interactive - * Part of the BI respawn framework - * Handles instant respawn type (respawn at position of death) - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -if !(GVAR(onDeath)) exitWith {}; - -params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]]]; - -if (alive _unit) then { - [_unit,false] call FUNC(setSpectator); -} else { - private ["_vision","_pos"]; - if (isNull _killer) then {_killer = _unit}; - _vision = [-2,-1] select (sunOrMoon < 1); - _pos = (getPosATL _unit) vectorAdd [0,0,5]; - - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); -}; diff --git a/addons/spectator/functions/fnc_bi_respawnNone.sqf b/addons/spectator/functions/fnc_bi_respawnNone.sqf deleted file mode 100644 index a5031a8fd9..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnNone.sqf +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Author: Bohemia Interactive (Karel Moricky) - * Part of the BI respawn framework - * Shows death screen for respawn type "None" - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse <OBJECT> - * 1: Killer <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ -private ["_soundvolume","_musicvolume"]; - -#define BI_CONTROL (_display displayctrl _n) - -#include "script_component.hpp" - -disableserialization; -_player = _this select 0; -_killer = _this select 1; -if (isnull _killer) then {_killer = _player}; - -_musicvolume = musicvolume; -_soundvolume = soundvolume; //MUF-TODO: check if this is done before sound is faded in fn_feedbackMain.fsm - -_start = isnil "bis_fnc_respawnNone_start"; -if (_start) then { - bis_fnc_respawnNone_start = [daytime,time / 3600]; - - //3.5 fadesound 0; //MUF-commented - - sleep 2; - if (alive player) exitwith {}; - cutText ["","BLACK OUT",1]; - sleep 1.5; - BIS_fnc_feedback_allowPP = false; //MUF-switch health PP off - //(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",1];//MUF-black in (remove black screen that was launched in FSM PP) - - if (ismultiplayer) then { - if (GVAR(onDeath)) then { - private ["_vision","_pos"]; - _vision = [-2,-1] select (sunOrMoon < 1); - _pos = (getPosATL _player) vectorAdd [0,0,5]; - - [2,_killer,_vision,_pos,getDir _player] call FUNC(setCameraAttributes); - [_player] call FUNC(setSpectator); - } else { - (finddisplay 46) createdisplay "RscDisplayMissionEnd"; - }; - } else {enableenddialog}; -}; -if (alive player) exitwith { - [player,false] call FUNC(setSpectator); - cuttext ["","plain"]; -}; //--- Terminate when player manages to switch do different unit already - -if (GVAR(onDeath)) exitWith {}; - -waituntil {!isnull (finddisplay 58)}; -_display = finddisplay 58; - -//--- Black fade in -_n = 1060; -BI_CONTROL ctrlsetfade 1; -if (_start) then { - - //--- Play ambient radio - setacctime 1; - 0 fademusic 0; - 4 fademusic 0.8; - playmusic format ['RadioAmbient%1',ceil random 1/*30*/]; - _musicEH = addMusicEventHandler ["MusicStop",{[] spawn {playmusic format ['RadioAmbient%1',ceil random 1/*30*/];};}]; - uinamespace setvariable ["bis_fnc_respawnNone_musicEH",_musicEH]; - _display displayaddeventhandler ["unload","removeMusicEventHandler ['MusicStop',uinamespace getvariable ['bis_fnc_respawnNone_musicEH',-1]];"]; - - BI_CONTROL ctrlcommit 4; -} else { - BI_CONTROL ctrlcommit 0; -}; -cuttext ["","plain"]; - -//--- HUD -_n = 5800; -BI_CONTROL ctrlsettext gettext (configfile >> "cfgingameui" >> "cursor" >> "select"); -BI_CONTROL ctrlsetposition [-10,-10,safezoneH * 0.07 * 3/4,safezoneH * 0.07]; -BI_CONTROL ctrlsettextcolor [1,1,1,1]; -BI_CONTROL ctrlcommit 0; - -//--- SITREP (ToDO: Localize) -_sitrep = "SITREP||"; -if (name _player != "Error: No unit") then { - _sitrep = _sitrep + "KIA: %4. %5|"; -}; -_sitrep = _sitrep + "TOD: %2 [%3]|LOC: %6 \ %7"; -if (_killer != _player) then { - _sitrep = _sitrep + "||ENY: %8"; - if (currentweapon _killer != "") then { - _sitrep = _sitrep + "|ENW: %9</t>" - }; -}; -_sitrep = format [ - _sitrep, - 1 * safezoneH, - [bis_fnc_respawnNone_start select 0,"HH:MM:SS"] call bis_fnc_timetostring, - [bis_fnc_respawnNone_start select 1,"HH:MM:SS"] call bis_fnc_timetostring, - toupper localize format ["STR_SHORT_%1",rank _player], - toupper name _player, - mapGridPosition _player, - toupper worldname, - toupper ((configfile >> "cfgvehicles" >> typeof _killer) call bis_fnc_displayname), - toupper ((configfile >> "cfgweapons" >> currentweapon _killer) call bis_fnc_displayname) - -]; - -_n = 11000; -_bcgPos = ctrlposition BI_CONTROL; -_n = 5858; -//BI_CONTROL ctrlsetposition [_bcgPos select 0,safezoneY + ((_bcgPos select 0) - safezoneX) * 4/3,safezoneW - 2 * (_bcgPos select 2),safezoneH / 2]; -BI_CONTROL ctrlsetposition [(((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX), - ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY), - safezoneW - 2 * (_bcgPos select 2), - safezoneH / 2]; -BI_CONTROL ctrlcommit 0; -[BI_CONTROL,_sitrep] spawn { - scriptname "bis_fnc_respawnNone: SITREP"; - disableserialization; - _control = _this select 0; - _sitrepArray = toarray (_this select 1); - {_sitrepArray set [_foreachindex,tostring [_x]]} foreach _sitrepArray; - _sitrep = ""; - //_sitrepFormat = "<t align='left' font='EtelkaMonospacePro' shadow='1' size='" + str safezoneH + "'>%1</t>"; - _sitrepFormat = "<t align='left' font='EtelkaMonospacePro' shadow='1'>%1</t>"; - - sleep 1; - for "_i" from 0 to (count _sitrepArray - 1) do { - _letter = _sitrepArray select _i; - _delay = if (_letter == "|") then {_letter = "<br />"; 1} else {0.01}; - _sitrep = _sitrep + _letter; - _control ctrlsetstructuredtext parsetext format [_sitrepFormat,_sitrep + "_"]; - //playsound ["IncomingChallenge",true]; - sleep _delay; - if (isnull _control) exitwith {}; - }; - _control ctrlsetstructuredtext parsetext format [_sitrepFormat,_sitrep]; -}; - - -//--- Create UAV camera -_camera = "camera" camcreate position player; -_camera cameraeffect ["internal","back"]; -_camera campreparefov 0.4; -_camera campreparetarget _killer; -showcinemaborder false; - -//--- Set PP effects -_saturation = 0.0 + random 0.3; -_ppColor = ppEffectCreate ["ColorCorrections", 1999]; -_ppColor ppEffectEnable true; -_ppColor ppEffectAdjust [1, 1, 0, [1, 1, 1, 0], [1 - _saturation, 1 - _saturation, 1 - _saturation, _saturation], [1, 0.25, 0, 1.0]]; -_ppColor ppEffectCommit 0; - -_ppGrain = ppEffectCreate ["filmGrain", 2012]; -_ppGrain ppEffectEnable true; -_ppGrain ppEffectAdjust [random 0.2, 1, 1, 0, 1]; -_ppGrain ppEffectCommit 0; - -//--- Camera update executed every frame -bis_fnc_respawnNone_player = _player; -bis_fnc_respawnNone_killer = _killer; -bis_fnc_respawnNone_camera = _camera; -bis_fnc_respawnNone_loop = { - scriptname "bis_fnc_respawnNone: camera"; - _display = _this select 0; - _player = bis_fnc_respawnNone_player; - _killer = bis_fnc_respawnNone_killer; - _camera = bis_fnc_respawnNone_camera; - - _sin = 20 * sin (time * 7); - _killerPos = [ - (visiblepositionasl _killer select 0), - (visiblepositionasl _killer select 1) + (_sin), - (visiblepositionasl _killer select 2) + (_sin) - ]; - - _dirToKiller = if (_killer == _player) then { - direction _player; - } else { - ([_player,_killerPos] call bis_fnc_dirto) + _sin; - }; - _pos = [ - visiblepositionasl _player, - -20, - _dirToKiller - ] call bis_fnc_relpos; - _pos set [2,((_pos select 2) + 7) max (getterrainheightasl _pos + 7)]; - - //--- Pitch - _heightCamera = getterrainheightasl _pos; - _heightKiller = getterrainheightasl _killerPos; - _height = _heightCamera - _heightKiller; - _dis = _killerPos distance _pos; - _angle = (asin (_height/_dis)); - - _camera setdir _dirtokiller; - [_camera,-_angle,_sin] call bis_fnc_setpitchbank; - _camera setposasl _pos; - - //--- HUD - _n = 5800; - _hudPos = (worldtoscreen position _player); - if (count _hudPos > 0) then { - _hudPosW = ctrlposition BI_CONTROL select 2; - _hudPosH = ctrlposition BI_CONTROL select 3; - _hudPos = [ - (_hudPos select 0) - _hudPosW / 2, - (_hudPos select 1) - _hudPosH / 2, - _hudPosW, - _hudPosH - ]; - BI_CONTROL ctrlsetposition _hudPos; - BI_CONTROL ctrlcommit 0; - }; -}; - -bis_fnc_respawnNone_keydown = { - _key = _this select 1; - - if (_key in (actionkeys 'nightvision') || _key < 0) then { - bis_fnc_respawnNone_vision = bis_fnc_respawnNone_vision + 1; - _vision = bis_fnc_respawnNone_vision % 4; - switch (_vision) do { - case 0: { - camusenvg false; - call compile 'false SetCamUseTi 0'; - }; - case 1: { - camusenvg true; - call compile 'false SetCamUseTi 0'; - }; - case 2: { - camusenvg false; - call compile 'true SetCamUseTi 0'; - }; - case 3: { - camusenvg false; - call compile 'true SetCamUseTi 1'; - }; - }; - }; -}; -//bis_fnc_respawnNone_vision = (1 + floor random 3) % 4; //--- Random vision (not NVG) -bis_fnc_respawnNone_vision = -1; -if (sunormoon < 1) then {bis_fnc_respawnNone_vision = 0;}; -[-1,-1] call bis_fnc_respawnNone_keydown; - -_display displayaddeventhandler ["mousemoving","_this call bis_fnc_respawnNone_loop"]; -_display displayaddeventhandler ["mouseholding","_this call bis_fnc_respawnNone_loop"]; -_display displayaddeventhandler ["keydown","_this call bis_fnc_respawnNone_keydown"]; - - -//--- Team Switch display opened -waituntil {isnull _display}; -_displayTeamSwitch = finddisplay 632; - -//--- Team Switch display closed - cleanup and restart the view -waituntil {isnull _displayTeamSwitch}; - -_camera cameraeffect ["terminate","back"]; -camdestroy _camera; - -bis_fnc_respawnNone_player = nil; -bis_fnc_respawnNone_killer = nil; -bis_fnc_respawnNone_camera = nil; -bis_fnc_respawnNone_loop = nil; - -ppeffectdestroy _ppColor; -ppeffectdestroy _ppGrain; - -if (!alive player) exitwith {_this call bis_fnc_respawnNone;}; - - -//--- Resurrection! -BIS_fnc_feedback_allowPP = true; -0 fadesound _soundvolume; -0 fademusic _musicvolume; -playmusic ""; -bis_fnc_respawnNone_start = nil; diff --git a/addons/spectator/functions/fnc_bi_respawnSeagull.sqf b/addons/spectator/functions/fnc_bi_respawnSeagull.sqf deleted file mode 100644 index 2e01ffa6ea..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnSeagull.sqf +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Author: Bohemia Interactive - * Part of the BI respawn framework - * Correctly handles seagull respawn (not used by default) - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -_seagull = _this select 0; -_player = _this select 1; -_this call bis_fnc_log; - -if (!isplayer _player && !isplayer _seagull) exitwith {["Attempting to use the function on AI unit %1, can be used only on players."] call bis_fnc_error;}; - -waituntil {missionnamespace getvariable ["BIS_fnc_feedback_allowDeathScreen",true]}; -BIS_fnc_feedback_allowPP = false; -//(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",8]; - -if (GVAR(onDeath)) exitWith { - private ["_vision","_pos"]; - - if (isNull _player) then {_player = _seagull}; - _vision = [-2,-1] select (sunOrMoon < 1); - _pos = (getPosATL _player) vectorAdd [0,0,5]; - - [_seagull,QGVAR(isSeagull)] call EFUNC(common,hideUnit); - [2,_player,_vision,_pos,getDir _seagull] call FUNC(setCameraAttributes); - [_seagull] call FUNC(setSpectator); -}; - -_camera = "camera" camCreate [(position _player select 0)-0.75, (position _player select 1)-0.75,(position _player select 2) + 0.5]; -_camera cameraEffect ["internal","back"]; -_camera camSetFOV 0.800; -_camera camCommit 0; -waituntil {camCommitted _camera}; - -0 fadeMusic 0.5; -playMusic "Track06_Abandoned_Battlespace"; - -_camera camSetTarget vehicle _player; -_camera camSetRelPos [-0.82,-3.12,3.38]; -_camera camSetFOV 0.800; -_camera camCommit 7; - -sleep 1; -_preload = _player spawn {waitUntil {(preloadCamera getPos _this) && (2 preloadObject _this)}}; -sleep 5; -waituntil {camCommitted _camera}; - -_camera camSetRelPos [1.17,-21.71,2.07]; -_camera camSetFOV 0.400; -_camera camCommit 10; -sleep 2; -terminate _preload; -sleep 3; -_preload = _player spawn {waitUntil {(preloadCamera getPos _this) && (3 preloadObject _this)}}; -waituntil {camCommitted _camera}; - -_camera camSetTarget vehicle _player; -_camera camSetRelPos [5.80,1.29,5.07]; -_camera camSetFOV 0.300; -_camera camCommit 7; -sleep 2; -terminate _preload; -_preload = _seagull spawn {waitUntil {(preloadCamera getPos _this) && (4 preloadObject _this)}}; -waituntil {camCommitted _camera}; - -_camera camSetRelPos [2.71,19.55,12.94]; -_camera camSetFOV 0.700; -_camera camCommit 2; -waituntil {camCommitted _camera}; - -_camera camSetTarget _seagull; -_camera camSetRelPos [-6.66,18.99,2.59]; -_camera camSetFOV 0.700; -_camera camCommit 3; -waituntil {camCommitted _camera}; - -3 fadeMusic 0; - -_camera camSetRelPos [1.17,-21.71,-1.07]; -_camera camSetFOV 0.300; -_camera camCommit 3; -waituntil {camCommitted _camera}; -terminate _preload; - -_seagull switchCamera "EXTERNAL"; -_seagull cameraEffect ["terminate","back"]; -camDestroy _camera; diff --git a/addons/spectator/functions/fnc_bi_respawnSpectator.sqf b/addons/spectator/functions/fnc_bi_respawnSpectator.sqf deleted file mode 100644 index 5097b61ab2..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnSpectator.sqf +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Author: Bohemia Interactive - * Part of the BI respawn framework - * Opens BI spectator interface (default used by seagull respawn) - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",-1,[0]]]; -private ["_vision","_pos"]; - -if (isNull _killer) then {_killer = _unit}; -_vision = [-2,-1] select (sunOrMoon < 1); -_pos = (getPosATL _unit) vectorAdd [0,0,5]; - -_layer = "BIS_fnc_respawnSpectator" call bis_fnc_rscLayer; - -if (!alive _unit) then { - if (GVAR(onDeath)) then { - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); - } else { - _layer cutrsc ["RscSpectator","plain"]; - }; -} else { - if (_respawn == 1) then { - - //--- Open - waituntil {missionnamespace getvariable ["BIS_fnc_feedback_allowDeathScreen",true]}; - BIS_fnc_feedback_allowPP = false; - //(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",1]; - if (GVAR(onDeath)) then { - [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); - } else { - _layer cutrsc ["RscSpectator","plain"]; - }; - } else { - if (GVAR(onDeath)) then { - [_unit,false] call FUNC(setSpectator); - }; - - //--- Close - _layer cuttext ["","plain"]; - }; -}; diff --git a/addons/spectator/functions/fnc_bi_respawnWave.sqf b/addons/spectator/functions/fnc_bi_respawnWave.sqf deleted file mode 100644 index 371a8edcdc..0000000000 --- a/addons/spectator/functions/fnc_bi_respawnWave.sqf +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Author: Bohemia Interactive - * Part of the BI respawn framework - * Handles wave respawning system - * Edited to support ace_spectator integration - * - * Arguments: - * 0: Corpse/New Unit <OBJECT> - * 1: Killer/Old Unit <OBJECT> - * 2: Respawn Type <NUMBER> - * 3: Respawn Delay <NUMBER> - * - * Return Value: - * None <NIL> - * - * Public: No - */ - -#include "script_component.hpp" - -params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; - -if (!isplayer _unit && !isnull _unit) exitwith {["Attempting to use the function on AI unit %1, can be used only on players."] call bis_fnc_error;}; - -if (!alive _unit) then { - //--- Set the time only when it was not modified already - if (_respawnDelay != 0 && _respawnDelay == playerrespawntime) then { - setplayerrespawntime (_respawnDelay + _respawnDelay - (servertime % _respawnDelay)); - - if !(GVAR(onDeath)) exitWith {}; - private ["_vision","_pos"]; - - if (isNull _killer) then {_killer = _unit}; - _vision = [-2,-1] select (sunOrMoon < 1); - _pos = (getPosATL _unit) vectorAdd [0,0,5]; - - [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); - }; -} else { - setplayerrespawntime _respawndelay; - [_unit,false] call FUNC(setSpectator); -}; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 5c8c958451..777e8d2ea9 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -43,7 +43,7 @@ switch (toLower _mode) do { // Close map openMap [false,false]; - // Close any BI layers/effects + // Disable BI damage effects and remove counter layer BIS_fnc_feedback_allowPP = false; ("BIS_fnc_respawnCounter" call BIS_fnc_rscLayer) cutText ["","plain"]; @@ -80,9 +80,8 @@ switch (toLower _mode) do { // Return to player view _unit switchCamera "internal"; - // Re-enable any BI effects + // Re-enable BI damage effects BIS_fnc_feedback_allowPP = true; - BIS_fnc_respawnNone_start = nil; // Cleanup camera variables GVAR(camera) = nil; diff --git a/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf b/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf index 1fd20f50e4..c23fb7ad20 100644 --- a/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf +++ b/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf @@ -19,7 +19,6 @@ params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; -[_logic, QGVAR(onDeath), "systemEnable"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(filterUnits), "unitsFilter"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(filterSides), "sidesFilter"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(restrictModes), "cameraModes"] call EFUNC(common,readSettingFromModule); diff --git a/addons/spectator/functions/fnc_respawnTemplate.sqf b/addons/spectator/functions/fnc_respawnTemplate.sqf new file mode 100644 index 0000000000..b03c6dfb06 --- /dev/null +++ b/addons/spectator/functions/fnc_respawnTemplate.sqf @@ -0,0 +1,39 @@ +/* + * Author: SilentSpike + * The ace_spectator respawn template, handles killed + respawn + * Can be used via BI's respawn framework, see: + * https://community.bistudio.com/wiki/Arma_3_Respawn + * + * Arguments: + * 0: Corpse/New Unit <OBJECT> + * 1: Killer/Old Unit <OBJECT> + * 2: Respawn Type <NUMBER> + * 3: Respawn Delay <NUMBER> + * + * Return Value: + * None <NIL> + * + * Public: No + */ + +#include "script_component.hpp" + +params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; +private ["_vision","_pos"]; + +if (isNull _killer) then {_killer = _unit}; +_vision = [-2,-1] select (sunOrMoon < 1); +_pos = (getPosATL _unit) vectorAdd [0,0,5]; + +if (alive _unit) then { + if (_respawn == 1) then { + [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); + } else { + [_unit,false] call FUNC(setSpectator); + }; +} else { + [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); + [_unit] call FUNC(setSpectator); +}; diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index 07abbc94ab..a4d99445fb 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -53,8 +53,12 @@ if (_newMode == 0) then { // Free GVAR(camera) camSetFov -(linearConversion [0.01,2,GVAR(camZoom),-2,-0.01,true]); GVAR(camera) camCommit 0; - // Switch to camera to stop AI group chat - ACE_Player switchCamera "internal"; + // Agent is switched to in free cam to hide death table and prevent AI chat + if (isNull GVAR(camAgent)) then { + GVAR(camAgent) = createAgent ["VirtualMan_F",markerPos QGVAR(respawn),[],0,""]; + }; + + GVAR(camAgent) switchCamera "internal"; clearRadio; // If new vision isn't available then keep current (unless current also isn't) diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 1f74d08c43..4eb0e25c0a 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -9,14 +9,6 @@ <English>Configure how the spectator system will operate by default.</English> <Polish>Skonfiguruj domyślne ustawienia obserwatora.</Polish> </Key> - <Key ID="STR_ACE_Spectator_system_DisplayName"> - <English>Spectate on death</English> - <Polish>Obserwator po śmierci</Polish> - </Key> - <Key ID="STR_ACE_Spectator_system_Description"> - <English>Enables spectator upon death.</English> - <Polish>Włącz obserwatora po śmierci</Polish> - </Key> <Key ID="STR_ACE_Spectator_units_DisplayName"> <English>Unit filter</English> <Polish>Filtr jednostek</Polish> From 79e607836b20f828f00f5c0525c42a779e64d123 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Wed, 5 Aug 2015 12:51:13 +0100 Subject: [PATCH 13/43] Add contributor email for Head --- AUTHORS.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 70bd7af086..814ab311a3 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -68,8 +68,8 @@ Hamburger SV Harakhti <shadowdragonphd@gmail.com> havena <silveredenis@gmail.com> Hawkins -Head -jokoho482 <jokoho482@gmail.com>` +Head <brobergsebastian@gmail.com> +jokoho482 <jokoho482@gmail.com> Jonpas <jonpas33@gmail.com> Karneck <dschultz26@hotmail.com> Kavinsky <nmunozfernandez@gmail.com> From 07e09b60faa7b4b09663d53cb7baa414259bdbb8 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Wed, 5 Aug 2015 13:19:47 +0100 Subject: [PATCH 14/43] Stop spectator camera unit changing on corpses Previously the camera would be automatically moved away from corpses (when the unit currently being watched dies). This changes it to stay on them until the view is manually switched as users might want to stick around and watch whatever was going on at the time of death. --- addons/spectator/functions/fnc_handleInterface.sqf | 1 + addons/spectator/functions/fnc_handleUnits.sqf | 6 ++++-- addons/spectator/functions/fnc_transitionCamera.sqf | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 777e8d2ea9..b85e73dabb 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -78,6 +78,7 @@ switch (toLower _mode) do { camDestroy GVAR(camera); // Return to player view + clearRadio; _unit switchCamera "internal"; // Re-enable BI damage effects diff --git a/addons/spectator/functions/fnc_handleUnits.sqf b/addons/spectator/functions/fnc_handleUnits.sqf index b64a1a2717..e8cd561da0 100644 --- a/addons/spectator/functions/fnc_handleUnits.sqf +++ b/addons/spectator/functions/fnc_handleUnits.sqf @@ -26,9 +26,11 @@ if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHand // Remove all dead and null units from the list [] call FUNC(updateUnits); -// Camera shouldn't stay on unit that isn't in the list +// Camera shouldn't stay on unit that isn't in the list (unless dead) if !(GVAR(camUnit) in GVAR(unitList)) then { - [nil,1] call FUNC(cycleCamera); + if (alive GVAR(camUnit) || isNull GVAR(camUnit)) then { + [nil,1] call FUNC(cycleCamera); + }; }; // Reduce overhead when unit tree is hidden diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index a4d99445fb..4957540fa4 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -33,7 +33,7 @@ if !(_newMode in GVAR(availableModes)) then { }; // When no units available to spectate, exit to freecam -if (GVAR(unitList) isEqualTo []) then { +if ((GVAR(unitList) isEqualTo []) && (alive _newUnit || isNull _newUnit)) then { _newMode = 0; _newUnit = objNull; }; From 5200fd6a0298a593fc21d4233de494ff2867a927 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Wed, 5 Aug 2015 14:15:27 +0100 Subject: [PATCH 15/43] Add new option to spectator unit filter setting Adds an option to use playableUnits for scenarios where AI playable units are enabled. --- addons/spectator/ACE_Settings.hpp | 4 ++-- addons/spectator/CfgVehicles.hpp | 6 +++++- addons/spectator/functions/fnc_updateUnits.sqf | 2 +- addons/spectator/stringtable.xml | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/spectator/ACE_Settings.hpp b/addons/spectator/ACE_Settings.hpp index 539f7cef2d..2889fd2e0f 100644 --- a/addons/spectator/ACE_Settings.hpp +++ b/addons/spectator/ACE_Settings.hpp @@ -1,8 +1,8 @@ class ACE_Settings { class GVAR(filterUnits) { typeName = "SCALAR"; - value = 1; - values[] = {CSTRING(units_none), CSTRING(units_players), CSTRING(units_all)}; + value = 2; + values[] = {CSTRING(units_none), CSTRING(units_players), CSTRING(units_playable), CSTRING(units_all)}; }; class GVAR(filterSides) { typeName = "SCALAR"; diff --git a/addons/spectator/CfgVehicles.hpp b/addons/spectator/CfgVehicles.hpp index 8e685dae07..b63f349b0a 100644 --- a/addons/spectator/CfgVehicles.hpp +++ b/addons/spectator/CfgVehicles.hpp @@ -21,11 +21,15 @@ class CfgVehicles { class players { name = CSTRING(units_players); value = 1; + }; + class playable { + name = CSTRING(units_playable); + value = 2; default = 1; }; class all { name = CSTRING(units_all); - value = 2; + value = 3; }; }; }; diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf index ef8fc3b4f1..75f1402179 100644 --- a/addons/spectator/functions/fnc_updateUnits.sqf +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -36,7 +36,7 @@ if !(_newUnits isEqualTo []) exitWith { private ["_sides","_cond","_filteredUnits","_color","_icon"]; // Unit setting filter -_newUnits = [[],allPlayers,allUnits] select GVAR(filterUnits); +_newUnits = [[],allPlayers,playableUnits,allUnits] select GVAR(filterUnits); // Side setting filter _sides = []; diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 4eb0e25c0a..5219ba7e2d 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -25,6 +25,9 @@ <English>Only players</English> <Polish>Tylko gracze</Polish> </Key> + <Key ID="STR_ACE_Spectator_units_playable"> + <English>Playable Units</English> + </Key> <Key ID="STR_ACE_Spectator_units_all"> <English>All units</English> <Polish>Wszystkie jednostki</Polish> From 42b5abae116c27cad907aee5cc5dd85ad978c59c Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Wed, 5 Aug 2015 19:25:38 +0100 Subject: [PATCH 16/43] Add support for respawn counter to spectator UI Rather than hiding the BI respawn counter, it should be "integrated" into the UI via code if present. --- addons/spectator/UI/interface.hpp | 11 +++++- .../functions/fnc_handleInterface.sqf | 35 +++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index e8df31c280..bd6d34339f 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -1,6 +1,15 @@ +// Temporary fix until BI take care of it +class RscFrame { + x = 0; + y = 0; + w = 0; + h = 0; +}; + + class RscButtonMenu; class RscControlsGroupNoScrollbars; -class RscFrame; +//class RscFrame; class RscListNBox; class RscMapControl; class RscPicture; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index b85e73dabb..b6608959b7 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -43,9 +43,8 @@ switch (toLower _mode) do { // Close map openMap [false,false]; - // Disable BI damage effects and remove counter layer + // Disable BI damage effects BIS_fnc_feedback_allowPP = false; - ("BIS_fnc_respawnCounter" call BIS_fnc_rscLayer) cutText ["","plain"]; // Close all existing dialogs while {dialog} do { @@ -81,7 +80,7 @@ switch (toLower _mode) do { clearRadio; _unit switchCamera "internal"; - // Re-enable BI damage effects + // Enable BI damage effects BIS_fnc_feedback_allowPP = true; // Cleanup camera variables @@ -154,9 +153,33 @@ switch (toLower _mode) do { [localize LSTRING(prevUnit),"Left Arrow"] ]; - // Hacky way to enable keybindings - //_display displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}]; - //_display displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}]; + // 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]; + _timer ctrlSetFontHeight TOOL_H; + + _title ctrlCommit 0; + _back ctrlCommit 0; + _timer ctrlCommit 0; + _frame ctrlCommit 0; + }; + },[],0.5] call EFUNC(common,waitAndExecute); }; case "onunload": { // Kill GUI PFHs From c808021c7c9ae480d2d27a4735516ed02f688049 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Wed, 5 Aug 2015 21:11:25 +0100 Subject: [PATCH 17/43] Tweak spectator interface layout - Swap the FOV and vision mode tools into a more logical order. - Shorten the unit list to prevent overlay with main UI - Fix name tool on dead units --- addons/spectator/UI/interface.hpp | 14 +++++++------- addons/spectator/functions/fnc_handleToolbar.sqf | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index bd6d34339f..2ac33e4a64 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -121,11 +121,11 @@ class GVAR(interface) { idc = -1; style = 64; }; - class fovTool: viewTool { - idc = IDC_TOOL_FOV; + class visionTool: viewTool { + idc = IDC_TOOL_VISION; x = TOOL_W * 3 + MARGIN * 2; }; - class fovFrame: fovTool { + class visionFrame: visionTool { idc = -1; style = 64; }; @@ -137,11 +137,11 @@ class GVAR(interface) { idc = -1; style = 64; }; - class visionTool: viewTool { - idc = IDC_TOOL_VISION; + class fovTool: viewTool { + idc = IDC_TOOL_FOV; x = safeZoneW - TOOL_W * 2 - MARGIN; }; - class visionFrame: visionTool { + class fovFrame: fovTool { idc = -1; style = 64; }; @@ -160,7 +160,7 @@ class GVAR(interface) { x = safeZoneX; y = safeZoneY + TOOL_H * 2; w = TOOL_W * 2; - h = safeZoneH - TOOL_H * 4; + h = safeZoneH - TOOL_H * 6; sizeEx = H_PART(0.8); borderSize = 1; colorBorder[] = {COL_FORE}; diff --git a/addons/spectator/functions/fnc_handleToolbar.sqf b/addons/spectator/functions/fnc_handleToolbar.sqf index fd29ca532e..878f3e46de 100644 --- a/addons/spectator/functions/fnc_handleToolbar.sqf +++ b/addons/spectator/functions/fnc_handleToolbar.sqf @@ -1,6 +1,6 @@ /* * Author: Karel Moricky, SilentSpike - * Handles the spectator UI toolbar values and applies them to the camera + * Handles the spectator UI toolbar values * * Arguments: * 0: Parameters <ANY> @@ -31,15 +31,15 @@ if (GVAR(camMode) == 0) then { _fov = format ["%1x", floor(GVAR(camZoom) * 100) * 0.01]; _speed = format ["%1 m/s", floor(GVAR(camSpeed) * 100) * 0.01]; } else { - _vision = format ["%1 m", floor(getPosASL GVAR(camUnit) select 2)]; - _fov = [side group GVAR(camUnit)] call BIS_fnc_sideName; + _vision = [side group GVAR(camUnit)] call BIS_fnc_sideName; + _fov = format ["%1 m", floor(getPosASL GVAR(camUnit) select 2)]; _speed = format ["%1 km/h", floor(speed GVAR(camUnit)) max 0]; }; -if (isNull GVAR(camUnit)) then { - _name = localize "STR_Special_None"; -} else { +if (alive GVAR(camUnit)) then { _name = GETVAR(GVAR(camUnit),GVAR(uName),""); +} else { + _name = localize "STR_Special_None"; }; _mode = [localize LSTRING(ViewFree),localize LSTRING(ViewInternal),localize LSTRING(ViewExternal)] select GVAR(camMode); From d1975a593dc6d88755b5792b1bd627181bc6d9f0 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Thu, 6 Aug 2015 00:39:14 +0100 Subject: [PATCH 18/43] Improve spectator pause menu emulation Makes the fake pause menu closer to the real thing for UX purposes --- .../functions/fnc_handleInterface.sqf | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index b6608959b7..fdd84ee5ef 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -457,10 +457,10 @@ switch (toLower _mode) do { }; } forEach GVAR(unitList); }; - // Other + // Break from interface for escape menu case "escape": { _args params ["_display"]; - private ["_dlg","_key","_index","_ctrl","_config"]; + private "_dlg"; // Kill display _display closeDisplay 0; @@ -474,7 +474,6 @@ switch (toLower _mode) do { GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; - // Below is from EFUNC(common,disableUserInput) createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); disableSerialization; @@ -484,30 +483,35 @@ switch (toLower _mode) do { !(_key == 1) }]; - for "_index" from 100 to 2000 do { - (_dlg displayCtrl _index) ctrlEnable false; + // Disable save, respawn, options & manual buttons + (_dlg displayCtrl 103) ctrlEnable false; + if !(alive player) then { + (_dlg displayCtrl 1010) ctrlEnable false; }; + (_dlg displayCtrl 101) ctrlEnable false; + (_dlg displayCtrl 122) ctrlEnable false; - _ctrl = _dlg displayctrl 103; - _ctrl ctrlSetEventHandler ["buttonClick", QUOTE(while {dialog} do {closeDialog 0}; failMission 'LOSER';)]; - _ctrl ctrlEnable true; - _ctrl ctrlSetText "ABORT"; - _ctrl ctrlSetTooltip "Abort."; - - _ctrl = _dlg displayctrl ([104, 1010] select isMultiplayer); - _ctrl ctrlSetEventHandler ["buttonClick", QUOTE(closeDialog 0; player setDamage 1;)]; - _ctrl ctrlEnable (call {_config = missionConfigFile >> "respawnButton"; !isNumber _config || {getNumber _config == 1}}); - _ctrl ctrlSetText "RESPAWN"; - _ctrl ctrlSetTooltip "Respawn."; + // 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"}; + }}]; // PFH to re-open display when menu closes [{ if !(isNull (findDisplay 49)) exitWith {}; - createDialog QGVAR(interface); - [] call FUNC(transitionCamera); + // If still a spectator then re-enter the interface + if (GVAR(isSet)) then { + createDialog QGVAR(interface); + [] call FUNC(transitionCamera); + }; [_this select 1] call CBA_fnc_removePerFrameHandler; },0] call CBA_fnc_addPerFrameHandler; + + true }; }; From d6cc14a39d20afbd4734ab4c90ddfdbde63cee12 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Thu, 6 Aug 2015 00:52:39 +0100 Subject: [PATCH 19/43] Add zeus support to spectator UI Can only use zeus while alive, so it won't work using the respawn template. However it's useful for communities usign custom frameworks --- .../functions/fnc_handleInterface.sqf | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index fdd84ee5ef..defe5332ba 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -225,6 +225,10 @@ switch (toLower _mode) do { case "onkeydown": { _args params ["_display","_dik","_shift","_ctrl","_alt"]; + if ((alive player) && {_dik in (actionKeys "curatorInterface")} && {!isNull (getAssignedCuratorLogic player)}) exitWith { + ["zeus", [_display]] call FUNC(handleInterface); + }; + // Handle held keys (prevent repeat calling) if (_dik in GVAR(heldKeys)) exitwith {}; // Exclude movement keys so that speed can be adjusted on fly @@ -457,7 +461,7 @@ switch (toLower _mode) do { }; } forEach GVAR(unitList); }; - // Break from interface for escape menu + // Break from interface for eexternal events case "escape": { _args params ["_display"]; private "_dlg"; @@ -511,6 +515,38 @@ switch (toLower _mode) do { [_this select 1] call CBA_fnc_removePerFrameHandler; },0] call CBA_fnc_addPerFrameHandler; + }; + case "zeus": { + _args params ["_display"]; + + // Kill display + _display closeDisplay 0; + + // Reset cam/UI vars + GVAR(camBoom) = 0; + GVAR(camDolly) = [0,0]; + + GVAR(ctrlKey) = false; + GVAR(heldKeys) = []; + GVAR(mouse) = [false,false]; + GVAR(mousePos) = [0.5,0.5]; + + 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 + if (GVAR(isSet)) then { + createDialog QGVAR(interface); + [] call FUNC(transitionCamera); + }; + + [_this select 1] call CBA_fnc_removePerFrameHandler; + },0] call CBA_fnc_addPerFrameHandler; + },[],5] call EFUNC(common,waitAndExecute); true }; From 92ef0bfe995632527c255099d45862a99a913a3f Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Thu, 6 Aug 2015 11:34:24 +0100 Subject: [PATCH 20/43] Whitelist spectator free camera boom keys Now that booming the free camera is influenced by the camera speed, the keys should be whitelisted from the held-key prevention system to allow the speed to be adjusted on the move. Also includes a failed attempt to fix the free camera map teleporting functionality. --- addons/spectator/UI/interface.hpp | 2 +- addons/spectator/functions/fnc_handleInterface.sqf | 12 +++++++----- addons/spectator/functions/fnc_transitionCamera.sqf | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index 2ac33e4a64..182263e7b4 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -180,7 +180,7 @@ class GVAR(interface) { y = safeZoneY; w = safeZoneW; h = safeZoneH; - onMouseButtonDblClick = QUOTE([ARR_2('onMapDblClick',_this)] call FUNC(handleInterface)); + onMouseButtonDown = QUOTE([ARR_2('onMapClick',_this)] call FUNC(handleInterface)); onDraw = QUOTE([ARR_2('onDraw',_this)] call FUNC(handleInterface)); }; class helpSplash: RscControlsGroupNoScrollbars { diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index defe5332ba..502ce65fd4 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -40,8 +40,9 @@ switch (toLower _mode) do { GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); [] call FUNC(transitionCamera); - // Close map + // Close map and clear radio openMap [false,false]; + clearRadio; // Disable BI damage effects BIS_fnc_feedback_allowPP = false; @@ -76,8 +77,9 @@ switch (toLower _mode) do { GVAR(camera) cameraEffect ["terminate", "back"]; camDestroy GVAR(camera); - // Return to player view clearRadio; + + // Return to player view _unit switchCamera "internal"; // Enable BI damage effects @@ -232,7 +234,7 @@ switch (toLower _mode) do { // Handle held keys (prevent repeat calling) if (_dik in GVAR(heldKeys)) exitwith {}; // Exclude movement keys so that speed can be adjusted on fly - if !(_dik in [17,30,31,32]) then { + if !(_dik in [16,17,30,31,32,44]) then { GVAR(heldKeys) pushBack _dik; }; @@ -422,8 +424,8 @@ switch (toLower _mode) do { _tree tvSort [[],false]; }; // Map events - case "onmapdblclick": { - _args params ["_map","_button","_x","_y"]; + case "onmapclick": { + _args params ["_map","_button","_x","_y","_shift","_ctrl","_alt"]; private ["_newPos","_oldZ"]; if ((GVAR(camMode) == 0) && (_button == 0)) then { diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index 4957540fa4..90a2dc776b 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -53,7 +53,9 @@ if (_newMode == 0) then { // Free GVAR(camera) camSetFov -(linearConversion [0.01,2,GVAR(camZoom),-2,-0.01,true]); GVAR(camera) camCommit 0; - // Agent is switched to in free cam to hide death table and prevent AI chat + // Agent is switched to in free cam to hide death table and prevent AI chat while allowing icons to draw + // However, map click events don't fire in free cam for some reason... + // (Why is so much stuff tied into the current camera unit BI?!) if (isNull GVAR(camAgent)) then { GVAR(camAgent) = createAgent ["VirtualMan_F",markerPos QGVAR(respawn),[],0,""]; }; From bcb21b782e1ed9d52ca5c7ac61b30d09e90ef795 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Thu, 6 Aug 2015 13:42:31 +0100 Subject: [PATCH 21/43] Overhaul spectator icon handling and rendering - Optimize and improve 3D icon drawing - Combine 2D and 3D PFHs into 1 - Render group icons outside of 200m, unit icons within - Store list of groups on units update to cut down on what needs to be done each frame - Change map control type to 100 to remove all default unit icons - Improve colour caching, group colours don't change, unit colours do - Remove icon setting, toggling should be at users discretion --- addons/spectator/ACE_Settings.hpp | 4 -- addons/spectator/UI/interface.hpp | 3 +- addons/spectator/XEH_preInit.sqf | 2 + .../spectator/functions/fnc_cacheUnitInfo.sqf | 11 +++- .../spectator/functions/fnc_handleIcons.sqf | 57 ++++++++----------- .../functions/fnc_handleInterface.sqf | 32 ++--------- addons/spectator/functions/fnc_handleMap.sqf | 46 +++++++++++++++ .../functions/fnc_transitionCamera.sqf | 6 -- .../spectator/functions/fnc_updateUnits.sqf | 7 ++- addons/spectator/stringtable.xml | 8 --- 10 files changed, 90 insertions(+), 86 deletions(-) create mode 100644 addons/spectator/functions/fnc_handleMap.sqf diff --git a/addons/spectator/ACE_Settings.hpp b/addons/spectator/ACE_Settings.hpp index 2889fd2e0f..78402cff23 100644 --- a/addons/spectator/ACE_Settings.hpp +++ b/addons/spectator/ACE_Settings.hpp @@ -19,8 +19,4 @@ class ACE_Settings { value = 0; values[] = {CSTRING(modes_all), CSTRING(visions_nv), CSTRING(visions_ti), "$STR_Special_None"}; }; - class GVAR(unitIcons) { - typeName = "BOOL"; - value = 1; - }; }; diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index 182263e7b4..0b4d33ea75 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -176,12 +176,13 @@ class GVAR(interface) { }; class mapOverlay: RscMapControl { idc = IDC_MAP; + type = 100; x = safeZoneX; y = safeZoneY; w = safeZoneW; h = safeZoneH; onMouseButtonDown = QUOTE([ARR_2('onMapClick',_this)] call FUNC(handleInterface)); - onDraw = QUOTE([ARR_2('onDraw',_this)] call FUNC(handleInterface)); + onDraw = QUOTE(_this call FUNC(handleMap)); }; class helpSplash: RscControlsGroupNoScrollbars { idc = IDC_HELP; diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 95c18f4a54..2c29598ebc 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -8,6 +8,7 @@ PREP(handleCamera); PREP(handleCompass); PREP(handleIcons); PREP(handleInterface); +PREP(handleMap); PREP(handleMouse); PREP(handleToolbar); PREP(handleUnits); @@ -51,5 +52,6 @@ GVAR(showUnit) = true; GVAR(unitList) = []; GVAR(unitBlacklist) = []; GVAR(unitWhitelist) = []; +GVAR(groupList) = []; ADDON = true; diff --git a/addons/spectator/functions/fnc_cacheUnitInfo.sqf b/addons/spectator/functions/fnc_cacheUnitInfo.sqf index 13977bf398..9f40651748 100644 --- a/addons/spectator/functions/fnc_cacheUnitInfo.sqf +++ b/addons/spectator/functions/fnc_cacheUnitInfo.sqf @@ -19,15 +19,20 @@ params ["_unit"]; private ["_color","_icon","_name"]; -_color = [side group _unit] call BIS_fnc_sideColor; +// Group info only needs to be cached once (groups can't change) +if (isNil { GETVAR((group _unit),GVAR(gColor),nil) }) then { + _color = [side group _unit] call BIS_fnc_sideColor; + SETVAR((group _unit),GVAR(gColor),_color); +}; + +// Unit info should be updated each time _icon = getText (configFile >> "CfgVehicles" >> typeOf _unit >> "Icon"); _name = [_unit,false] call EFUNC(common,getName); // Handle CfgVehicleIcons -if isText (configFile >> "CfgVehicleIcons" >> _icon) then { +if (isText (configFile >> "CfgVehicleIcons" >> _icon)) then { _icon = getText (configFile >> "CfgVehicleIcons" >> _icon); }; -SETVAR(_unit,GVAR(uColor),_color); SETVAR(_unit,GVAR(uIcon),_icon); SETVAR(_unit,GVAR(uName),_name); diff --git a/addons/spectator/functions/fnc_handleIcons.sqf b/addons/spectator/functions/fnc_handleIcons.sqf index c52943ad10..72c0d7dee6 100644 --- a/addons/spectator/functions/fnc_handleIcons.sqf +++ b/addons/spectator/functions/fnc_handleIcons.sqf @@ -1,5 +1,5 @@ /* - * Author: SilentSpike + * Author: Head, SilentSpike * Handles rendering the spectator 3D unit icons * * Arguments: @@ -17,41 +17,30 @@ #include "script_component.hpp" -// Kill PFH when not in free cam (or display is closed) -if (isNil QGVAR(iconHandler)) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; - if !(GVAR(showIcons)) exitWith {}; +private ["_refPoint","_drawVehicles","_leader","_color","_txt","_unit"]; -private ["_cachedVehicles","_unit","_cameraPos","_cameraDir","_lambda","_uPos","_cmd","_txt"]; -_cachedVehicles = []; +// Draw groups unless leader is within distance +_refPoint = [GVAR(camera),GVAR(camUnit)] select (GVAR(camMode) > 0); +_drawVehicles = []; { - _unit = vehicle _x; + _leader = leader _x; + if ((_leader distanceSqr _refPoint) > 40000) then { + _color = GETVAR(_x,GVAR(gColor),[ARR_4(0,0,0,0)]); + _txt = groupID _x; - // Only try each vehicle once - if !(_unit in _cachedVehicles) then { - _cachedVehicles pushBack _unit; - - // Within 200m - if ((GVAR(camera) distanceSqr _unit) < 40000) then { - _cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL); - _cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos; - - // Quick oclussion test (taken from interact_menu) - _lambda = ((getPosASL _x) vectorDiff _cameraPos) vectorDotProduct _cameraDir; - if (_lambda > -1) then { - _uPos = worldToScreen (visiblePosition _unit); - - // Only draw if onscreen - if ((_uPos select 0 > safeZoneXAbs) && (_uPos select 0 < safeZoneXAbs + safeZoneWAbs)) then { - if ((_uPos select 1 > safeZoneY) && (_uPos select 1 < safeZoneY + safeZoneH)) then { - // Use commander's info if available - _cmd = [_x, effectiveCommander _unit] select ((effectiveCommander _unit) in GVAR(unitList)); - _txt = ["", GETVAR(_cmd,GVAR(uName),"")] select (isPlayer _cmd); - - drawIcon3D ["\A3\ui_f\data\map\markers\military\dot_CA.paa", GETVAR(_cmd,GVAR(uColor),[ARR_4(0,0,0,0)]), _unit modelToWorldVisual [0,0,3], 0.7, 0.7, 0, _txt, 1, 0.02]; - }; - }; - }; - }; + drawIcon3D ["\A3\ui_f\data\map\markers\nato\b_inf.paa", _color, _leader modelToWorldVisual [0,0,30], 1, 1, 0, _txt, 2, 0.02]; + } else { + _drawVehicles append (units _x); }; -} forEach GVAR(unitList); + false +} count GVAR(groupList); + +// Draw units for groups within distance +{ + _color = GETVAR((group _x),GVAR(gColor),[ARR_4(0,0,0,0)]); + _txt = ["", GETVAR(_x,GVAR(uName),"")] select (isPlayer _x); + + drawIcon3D ["\A3\ui_f\data\map\markers\military\dot_CA.paa", _color, _x modelToWorldVisual [0,0,3], 0.7, 0.7, 0, _txt, 1, 0.02]; + false +} count (_drawVehicles arrayIntersect GVAR(unitList)); diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 502ce65fd4..d58566968c 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -114,6 +114,9 @@ switch (toLower _mode) do { // Keep unit list and tree up to date [FUNC(handleUnits), 21, _display] call CBA_fnc_addPerFrameHandler; + // Handle unit icons on map and 3D + GVAR(iconHandler) = addMissionEventHandler ["Draw3D",FUNC(handleIcons)]; + // Populate the help splash private "_help"; _help = (_display displayCtrl IDC_HELP) controlsGroupCtrl IDC_HELP_LIST; @@ -187,6 +190,7 @@ switch (toLower _mode) do { // Kill GUI PFHs GVAR(camHandler) = nil; GVAR(compHandler) = nil; + removeMissionEventHandler ["Draw3D",GVAR(iconHandler)]; GVAR(iconHandler) = nil; GVAR(toolHandler) = nil; }; @@ -435,34 +439,6 @@ switch (toLower _mode) do { [nil,nil,nil, _newPos] call FUNC(setCameraAttributes); }; }; - case "ondraw": { - _args params ["_map"]; - - if (GVAR(camMode) == 0) then { - _map drawIcon ["\A3\UI_F\Data\GUI\Rsc\RscDisplayMissionEditor\iconcamera_ca.paa",[0,0,0,1],GVAR(camera),24,24,GVAR(camPan)]; - }; - - if !(GVAR(showIcons)) exitWith {}; - - private ["_cachedVehicles","_unit","_color","_icon"]; - _cachedVehicles = []; - { - _unit = vehicle _x; - - if !(_unit in _cachedVehicles) then { - _cachedVehicles pushBack _unit; - - // Use previously cached info where possible - if (isNil { GETVAR(_unit,GVAR(uIcon),nil) }) then { - [_unit] call FUNC(cacheUnitInfo); - }; - - _color = GETVAR(_unit,GVAR(uColor),[ARR_4(0,0,0,0)]); - _icon = GETVAR(_unit,GVAR(uIcon),""); - _map drawIcon [_icon, _color, _unit, 24, 24, getDir _unit]; - }; - } forEach GVAR(unitList); - }; // Break from interface for eexternal events case "escape": { _args params ["_display"]; diff --git a/addons/spectator/functions/fnc_handleMap.sqf b/addons/spectator/functions/fnc_handleMap.sqf new file mode 100644 index 0000000000..a0000718bd --- /dev/null +++ b/addons/spectator/functions/fnc_handleMap.sqf @@ -0,0 +1,46 @@ +/* + * Author: Head, SilentSpike + * Handles rendering the spectator map icons + * + * Arguments: + * 0: Parameters <ANY> + * 1: PFH handle <NUMBER> + * + * Return Value: + * None <NIL> + * + * Example: + * [ace_spectator_fnc_handleIcons, 0] call CBA_fnc_addPerFrameHandler; + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_map"]; +private ["_cachedVehicles","_unit","_color","_icon"]; + +if (GVAR(camMode) == 0) then { + _map drawIcon ["\A3\UI_F\Data\GUI\Rsc\RscDisplayMissionEditor\iconcamera_ca.paa",[0,0,0,1],GVAR(camera),20,20,GVAR(camPan)]; +}; + +_cachedVehicles = []; +{ + _unit = vehicle _x; + + if !(_unit in _cachedVehicles) then { + _cachedVehicles pushBack _unit; + + // Use previously cached info where possible + if (GETVAR(_unit,GVAR(uIcon),"") == "") then { + [_unit] call FUNC(cacheUnitInfo); + }; + + // Function has caching built in + _color = [side effectiveCommander _unit] call BIS_fnc_sideColor; + _icon = GETVAR(_unit,GVAR(uIcon),""); + + _map drawIcon [_icon, _color, _unit, 19, 19, getDir _unit]; + }; + false +} count GVAR(unitList); diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index 90a2dc776b..b35b61b311 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -79,11 +79,6 @@ if (_newMode == 0) then { // Free // Handle camera movement if (isNil QGVAR(camHandler)) then { GVAR(camHandler) = [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; }; - - // Handle unit icons - if (GVAR(unitIcons)) then { - if (isNil QGVAR(iconHandler)) then { GVAR(iconHandler) = [FUNC(handleIcons), 0] call CBA_fnc_addPerFrameHandler; }; - }; } else { // When null unit is given choose random if (isNull _newUnit) then { @@ -111,7 +106,6 @@ if (_newMode == 0) then { // Free // Terminate camera view GVAR(camera) cameraEffect ["terminate", "back"]; GVAR(camHandler) = nil; - GVAR(iconHandler) = nil; cameraEffectEnableHUD true; }; diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf index 75f1402179..50494cf499 100644 --- a/addons/spectator/functions/fnc_updateUnits.sqf +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -33,7 +33,7 @@ if !(_newUnits isEqualTo []) exitWith { }; }; -private ["_sides","_cond","_filteredUnits","_color","_icon"]; +private ["_sides","_cond","_filteredUnits","_filteredGroups"]; // Unit setting filter _newUnits = [[],allPlayers,playableUnits,allUnits] select GVAR(filterUnits); @@ -63,10 +63,13 @@ _filteredUnits = []; _filteredUnits append GVAR(unitWhitelist); // Cache icons and colour for drawing +_filteredGroups = []; { // Intentionally re-applied to units in case their status changes [_x] call FUNC(cacheUnitInfo); + _filteredGroups pushBack (group _x); } forEach _filteredUnits; -// Replace previous list entirely (removes any no longer valid) +// Replace previous lists entirely (removes any no longer valid) GVAR(unitList) = _filteredUnits arrayIntersect _filteredUnits; +GVAR(groupList) = _filteredGroups arrayIntersect _filteredGroups; diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 5219ba7e2d..4d615d4e1e 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -100,14 +100,6 @@ <English>Thermal imaging</English> <Polish>Termowizja</Polish> </Key> - <Key ID="STR_ACE_Spectator_icons_DisplayName"> - <English>Unit icons</English> - <Polish>Ikony jednostek</Polish> - </Key> - <Key ID="STR_ACE_Spectator_icons_Description"> - <English>Render icons above spectatable units.</English> - <Polish>Renderuj ikony nad głowami jednostek, które można obserwować.</Polish> - </Key> <!-- Interface strings --> <Key ID="STR_ACE_Spectator_HelpTitle"> <English>Spectator Controls</English> From 4c9b6e94cfa915a70b3911d18acda892c7ff8c66 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 00:05:21 +0100 Subject: [PATCH 22/43] Overhaul and improve spectator unit tree UX The old method of refreshing the tree on each update would reset all expanded/collapsed nodes. Now the code will cull any units/groups/sides no longer spectatable from the list and cache the ones that are still valid. The cached data is then used to populate the list with new units. Add coloured unit icons beside units in the list for quick user reference of side and type. Store group netIDs in respective nodes for possible use in code. --- addons/spectator/UI/interface.hpp | 4 +- .../functions/fnc_handleInterface.sqf | 85 ++++++++++++------- 2 files changed, 55 insertions(+), 34 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index 0b4d33ea75..ea5f5f0e53 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -158,9 +158,9 @@ class GVAR(interface) { class unitTree: RscTree { idc = IDC_UNIT; x = safeZoneX; - y = safeZoneY + TOOL_H * 2; + y = safeZoneY + TOOL_H * 6; w = TOOL_W * 2; - h = safeZoneH - TOOL_H * 6; + h = safeZoneH - TOOL_H * 13; sizeEx = H_PART(0.8); borderSize = 1; colorBorder[] = {COL_FORE}; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index d58566968c..9687ba8b2a 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -367,17 +367,43 @@ switch (toLower _mode) do { }; case "onunitsupdate": { _args params ["_tree"]; - private ["_curSelData","_cachedGrps","_cachedSides","_grp","_side","_sNode","_gNode","_uNode"]; + private ["_cachedUnits","_cachedGrps","_cachedSides","_s","_g","_grp","_u","_unit","_side"]; - // Cache current selection - _curSelData = _tree tvData (tvCurSel _tree); - - // Clear the tree - tvClear _tree; - - // Update the tree from the unit list + // Cache existing group and side nodes and cull removed data + _cachedUnits = []; _cachedGrps = []; _cachedSides = []; + for "_s" from 0 to ((_tree tvCount []) - 1) do { + for "_g" from 0 to ((_tree tvCount [_s]) - 1) do { + _grp = groupFromNetID (_tree tvData [_s,_g]); + + if (_grp in GVAR(groupList)) then { + _cachedGrps pushBack _grp; + _cachedGrps pushBack _g; + + for "_u" from 0 to ((_tree tvCount [_s,_g])) do { + _unit = objectFromNetId (_tree tvData [_s,_g,_u]); + + if (_unit in GVAR(unitList)) then { + _cachedUnits pushBack _unit; + } else { + _tree tvDelete [_s,_g,_u]; + }; + }; + } else { + _tree tvDelete [_s,_g]; + }; + }; + + if ((_tree tvCount [_s]) > 0) then { + _cachedSides pushBack (_tree tvText [_s]); + _cachedSides pushBack _s; + } else { + _tree tvDelete [_s]; + }; + }; + + // Update the tree from the unit list { _grp = group _x; _side = [side _grp] call BIS_fnc_sideName; @@ -385,47 +411,42 @@ switch (toLower _mode) do { // Use correct side node if !(_side in _cachedSides) then { // Add side node - _sNode = _tree tvAdd [[], _side]; + _s = _tree tvAdd [[], _side]; + _tree tvExpand [_s]; _cachedSides pushBack _side; - _cachedSides pushBack _sNode; + _cachedSides pushBack _s; } else { // If side already processed, use existing node - _sNode = _cachedSides select ((_cachedSides find _side) + 1); + _s = _cachedSides select ((_cachedSides find _side) + 1); }; // Use correct group node if !(_grp in _cachedGrps) then { // Add group node - _gNode = _tree tvAdd [[_sNode], groupID _grp]; + _g = _tree tvAdd [[_s], groupID _grp]; + _tree tvSetData [[_s,_g], netID _grp]; _cachedGrps pushBack _grp; - _cachedGrps pushBack _gNode; + _cachedGrps pushBack _g; } else { // If group already processed, use existing node - _gNode = _cachedGrps select ((_cachedGrps find _grp) + 1); + _g = _cachedGrps select ((_cachedGrps find _grp) + 1); }; - _uNode = _tree tvAdd [[_sNode,_gNode], GETVAR(_x,GVAR(uName),"")]; - _tree tvSetData [[_sNode,_gNode,_uNode], netID _x]; + _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)])]; - // Preserve the previous selection - if (_curSelData == (_tree tvData [_sNode,_gNode,_uNode])) then { - _tree tvSetCurSel [_sNode,_gNode,_uNode]; - }; - - _tree tvSort [[_sNode,_gNode],false]; - _tree tvExpand [_sNode,_gNode]; - } forEach GVAR(unitList); - - { - if (typeName _x == "SCALAR") then { - _tree tvSort [[_x],false]; - _tree tvExpand [_x]; - }; - } forEach _cachedSides; + _tree tvSort [[_s,_g],false]; + } forEach (GVAR(unitList) - _cachedUnits); _tree tvSort [[],false]; + + if ((_tree tvCount []) <= 0) then { + _tree tvAdd [[], localize LSTRING(units_none)]; + }; }; // Map events case "onmapclick": { @@ -439,7 +460,7 @@ switch (toLower _mode) do { [nil,nil,nil, _newPos] call FUNC(setCameraAttributes); }; }; - // Break from interface for eexternal events + // Break from interface for external events case "escape": { _args params ["_display"]; private "_dlg"; From f59536b5a3c26c1bee28f77ae01c8d739c06ad19 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 00:28:54 +0100 Subject: [PATCH 23/43] Remove legacy spectator settings module argument --- addons/spectator/CfgVehicles.hpp | 6 ------ addons/spectator/functions/fnc_moduleSpectatorSettings.sqf | 1 - 2 files changed, 7 deletions(-) diff --git a/addons/spectator/CfgVehicles.hpp b/addons/spectator/CfgVehicles.hpp index b63f349b0a..f6869462ac 100644 --- a/addons/spectator/CfgVehicles.hpp +++ b/addons/spectator/CfgVehicles.hpp @@ -109,12 +109,6 @@ class CfgVehicles { }; }; }; - class unitIcons { - displayName = CSTRING(icons_DisplayName); - description = CSTRING(icons_Description); - typeName = "BOOL"; - defaultValue = 1; - }; }; class ModuleDescription { description = CSTRING(Settings_Description); diff --git a/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf b/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf index c23fb7ad20..52b6e5d8fa 100644 --- a/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf +++ b/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf @@ -23,4 +23,3 @@ if !(_activated) exitWith {}; [_logic, QGVAR(filterSides), "sidesFilter"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(restrictModes), "cameraModes"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(restrictVisions), "visionModes"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(unitIcons), "unitIcons"] call EFUNC(common,readSettingFromModule); From 043c5c47c5765c64d32e8df23d408db87a8df75b Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 01:44:32 +0100 Subject: [PATCH 24/43] Improve spectator help window layout Having the help window in the centre of the screen blocked too much of the users view and also clashed with the MPTable element (the table that appears on death, aka "respawnDialog"). It was moved to the right of the screen and now mirrors the unit list. To save screen space, the action keys are given as tooltips for the listbox entries so users must mouse over for more info. --- addons/spectator/UI/interface.hpp | 53 +++++++++++-------- .../functions/fnc_handleInterface.sqf | 39 +++++++------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index ea5f5f0e53..5dbea22273 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -10,7 +10,7 @@ class RscFrame { class RscButtonMenu; class RscControlsGroupNoScrollbars; //class RscFrame; -class RscListNBox; +class RscListBox; class RscMapControl; class RscPicture; class RscText; @@ -163,12 +163,13 @@ class GVAR(interface) { h = safeZoneH - TOOL_H * 13; sizeEx = H_PART(0.8); borderSize = 1; + colorText[] = {COL_FORE}; colorBorder[] = {COL_FORE}; colorBackground[] = {COL_BACK}; colorSelect[] = { - "(profilenamespace getvariable ['GUI_BCG_RGB_R',0.77])", - "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.51])", - "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.08])", + QUOTE(GETPRVAR(GUI_BCG_RGB_R,0.77)), + QUOTE(GETPRVAR(GUI_BCG_RGB_G,0.51)), + QUOTE(GETPRVAR(GUI_BCG_RGB_B,0.08)), 1 }; multiselectEnabled = 0; @@ -184,35 +185,43 @@ class GVAR(interface) { onMouseButtonDown = QUOTE([ARR_2('onMapClick',_this)] call FUNC(handleInterface)); onDraw = QUOTE(_this call FUNC(handleMap)); }; - class helpSplash: RscControlsGroupNoScrollbars { + class helpWindow: RscControlsGroupNoScrollbars { idc = IDC_HELP; - x = 0.5 - W_PART(12); - y = 0.5 - H_PART(12); - w = W_PART(24); - h = H_PART(24); + x = safeZoneX + safeZoneW - TOOL_W * 2; + y = safeZoneY + TOOL_H * 6; + w = TOOL_W * 2; + h = safeZoneH - TOOL_H * 13; + colorText[] = {COL_FORE}; + colorSelectBackground[] = {COL_FORE_D}; + colorSelectBackground2[] = {COL_BACK}; + colorBackground[] = {0,0,0,0}; class controls { - class helpBack: RscText { + class helpTitle: RscText { x = 0; y = 0; - w = W_PART(24); - h = H_PART(24); - colorBackground[] = {COL_BACK}; - }; - class helpTitle: helpBack { + w = TOOL_W * 2; h = H_PART(1); - colorText[]={COL_FORE}; + colorText[] = {COL_FORE}; colorBackground[] = {COL_FORE_D}; sizeEx = H_PART(1); text = CSTRING(HelpTitle); }; - class helpContent: RscListNBox { + class helpContent: RscListBox { idc = IDC_HELP_LIST; - x = W_PART(1); - y = H_PART(2); - W = W_PART(22); - H = H_PART(21); + x = 0; + y = H_PART(1); + w = TOOL_W * 2; + h = safeZoneH - TOOL_H * 14; + colorBackground[] = {COL_BACK}; default = 1; - columns[] = {0.01,0.5}; + }; + class helpFrame: RscText { + x = 0; + y = 0; + w = TOOL_W * 2; + h = safeZoneH - TOOL_H * 13; + colorText[] = {COL_FORE}; + style = 64; }; }; }; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 9687ba8b2a..ef3363b72c 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -117,27 +117,27 @@ switch (toLower _mode) do { // Handle unit icons on map and 3D GVAR(iconHandler) = addMissionEventHandler ["Draw3D",FUNC(handleIcons)]; - // Populate the help splash + // Populate the help window private "_help"; _help = (_display displayCtrl IDC_HELP) controlsGroupCtrl IDC_HELP_LIST; { - // Add space before category titles - if (count _x == 1) then { - _help lnbAddRow [""]; + _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]; }; - - _help lnbAddRow _x; } forEach [ [localize LSTRING(uiControls),""], - [localize LSTRING(uiToggleHelp),"H"], - [localize LSTRING(uiToggleMap),"M"], [localize LSTRING(uiToggleUnits),"1"], - [localize LSTRING(uiToggleTools),"2"], - [localize LSTRING(uiToggleCompass),"3"], - [localize LSTRING(uiToggleIcons),"4"], + [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(freeCamControls)], + [localize LSTRING(freeCamControls),""], [localize LSTRING(freeCamForward),"W"], [localize LSTRING(freeCamBackward),"S"], [localize LSTRING(freeCamLeft),"A"], @@ -150,8 +150,7 @@ switch (toLower _mode) do { [localize LSTRING(freeCamZoom),"Ctrl + Scrollwheel"], [localize LSTRING(freeCamNextVis),"N"], [localize LSTRING(freeCamPrevVis),"Ctrl + N"], - - [localize LSTRING(otherControls)], + [localize LSTRING(otherControls),""], [localize LSTRING(nextCam),"Up Arrow"], [localize LSTRING(prevCam),"Down Arrow"], [localize LSTRING(nextUnit),"Right Arrow"], @@ -250,12 +249,15 @@ switch (toLower _mode) do { [_display,nil,nil,nil,nil,nil,true] call FUNC(toggleInterface); }; case 3: { // 2 - [_display,nil,nil,nil,nil,true] call FUNC(toggleInterface); + [_display,nil,true] call FUNC(toggleInterface); }; case 4: { // 3 - [_display,true] call FUNC(toggleInterface); + [_display,nil,nil,nil,nil,true] call FUNC(toggleInterface); }; case 5: { // 4 + [_display,true] call FUNC(toggleInterface); + }; + case 6: { // 5 GVAR(showIcons) = !GVAR(showIcons); }; case 14: { // Backspace @@ -279,9 +281,6 @@ switch (toLower _mode) do { case 32: { // D GVAR(camDolly) set [0, GVAR(camSpeed)]; }; - case 35: { // H - [_display,nil,true] call FUNC(toggleInterface); - }; case 44: { // Z GVAR(camBoom) = -0.5 * GVAR(camSpeed); }; From 485f9438bb1e2aa56e908156b0a7fd5f883a69d5 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 01:51:46 +0100 Subject: [PATCH 25/43] Change spectator UI toggle to include help window With new layout of help window the toggle UX also changes. User expects help window to toggle as part of overall UI. --- .../spectator/functions/fnc_toggleInterface.sqf | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/addons/spectator/functions/fnc_toggleInterface.sqf b/addons/spectator/functions/fnc_toggleInterface.sqf index 609c7cd757..4a03de4271 100644 --- a/addons/spectator/functions/fnc_toggleInterface.sqf +++ b/addons/spectator/functions/fnc_toggleInterface.sqf @@ -31,17 +31,8 @@ _map = _display displayCtrl IDC_MAP; _tool = _display displayCtrl IDC_TOOL; _unit = _display displayCtrl IDC_UNIT; -// Map and help operate outside of interface -GVAR(showHelp) = [GVAR(showHelp), !GVAR(showHelp)] select _toggleHelp; +// Map operates outside of interface GVAR(showMap) = [GVAR(showMap), !GVAR(showMap)] select _toggleMap; - -// When help changes with map open, minimise the map -if (GVAR(showMap) && _toggleHelp) then { - GVAR(showHelp) = true; - GVAR(showMap) = false; -}; - -_help ctrlShow GVAR(showHelp); _map ctrlShow GVAR(showMap); if (GVAR(showMap)) then { @@ -62,16 +53,18 @@ if (GVAR(showMap)) then { if (GVAR(showInterface)) then { // Can only toggle interface elements with interface shown GVAR(showComp) = [GVAR(showComp), !GVAR(showComp)] select _toggleComp; + GVAR(showHelp) = [GVAR(showHelp), !GVAR(showHelp)] select _toggleHelp; GVAR(showTool) = [GVAR(showTool), !GVAR(showTool)] select _toggleTool; GVAR(showUnit) = [GVAR(showUnit), !GVAR(showUnit)] select _toggleUnit; _comp ctrlShow GVAR(showComp); + _help ctrlShow GVAR(showHelp); _tool ctrlShow GVAR(showTool); _unit ctrlShow GVAR(showUnit); } else { { _x ctrlShow false; - } forEach [_comp,_tool,_unit]; + } forEach [_comp,_help,_tool,_unit]; }; }; From f143db7fc067133e53e81897ff614297a5a25109 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 12:07:22 +0100 Subject: [PATCH 26/43] Draw player names on spectator map --- addons/spectator/UI/interface.hpp | 6 +++--- addons/spectator/functions/fnc_handleMap.sqf | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index 5dbea22273..51105b216b 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -167,9 +167,9 @@ class GVAR(interface) { colorBorder[] = {COL_FORE}; colorBackground[] = {COL_BACK}; colorSelect[] = { - QUOTE(GETPRVAR(GUI_BCG_RGB_R,0.77)), - QUOTE(GETPRVAR(GUI_BCG_RGB_G,0.51)), - QUOTE(GETPRVAR(GUI_BCG_RGB_B,0.08)), + "profilenamespace getvariable ['GUI_BCG_RGB_R',0.77]", + "profilenamespace getvariable ['GUI_BCG_RGB_G',0.51]", + "profilenamespace getvariable ['GUI_BCG_RGB_B',0.08]", 1 }; multiselectEnabled = 0; diff --git a/addons/spectator/functions/fnc_handleMap.sqf b/addons/spectator/functions/fnc_handleMap.sqf index a0000718bd..4eeb5fd7e1 100644 --- a/addons/spectator/functions/fnc_handleMap.sqf +++ b/addons/spectator/functions/fnc_handleMap.sqf @@ -18,7 +18,7 @@ #include "script_component.hpp" params ["_map"]; -private ["_cachedVehicles","_unit","_color","_icon"]; +private ["_cachedVehicles","_unit","_color","_icon","_txt"]; if (GVAR(camMode) == 0) then { _map drawIcon ["\A3\UI_F\Data\GUI\Rsc\RscDisplayMissionEditor\iconcamera_ca.paa",[0,0,0,1],GVAR(camera),20,20,GVAR(camPan)]; @@ -39,8 +39,9 @@ _cachedVehicles = []; // Function has caching built in _color = [side effectiveCommander _unit] call BIS_fnc_sideColor; _icon = GETVAR(_unit,GVAR(uIcon),""); + _txt = ["", GETVAR(_x,GVAR(uName),"")] select (isPlayer _x); - _map drawIcon [_icon, _color, _unit, 19, 19, getDir _unit]; + _map drawIcon [_icon, _color, _unit, 19, 19, getDir _unit, _txt, 1, 0.03]; }; false } count GVAR(unitList); From 702e50b731fd849c59a1ee1a7e531601ff703b52 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 12:30:50 +0100 Subject: [PATCH 27/43] Improve spectator UI respawn counter blending When the BI respawn counter is blended with the spectator UI its colours are also updated to match --- addons/spectator/functions/fnc_handleInterface.sqf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index ef3363b72c..db701366b0 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -176,7 +176,11 @@ switch (toLower _mode) do { _back ctrlSetPosition [_x,_y,TOOL_W,TOOL_H]; _timer ctrlSetPosition [_x,_y,TOOL_W,TOOL_H]; _frame ctrlSetPosition [_x,_y,TOOL_W,TOOL_H]; + + _title ctrlSetBackgroundColor [0,0,0,0]; + _back ctrlSetBackgroundColor [COL_BACK]; _timer ctrlSetFontHeight TOOL_H; + _frame ctrlSetTextColor [COL_FORE]; _title ctrlCommit 0; _back ctrlCommit 0; From 1c79c8fa45fc55c85cd90458803879ae22a8e6de Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 15:15:04 +0100 Subject: [PATCH 28/43] Update spectator UI styling Adds a title to the unit tree to match the help list and enters the title text. --- addons/spectator/UI/interface.hpp | 67 +++++++++++++------ .../spectator/functions/fnc_handleUnits.sqf | 2 +- addons/spectator/script_component.hpp | 5 +- addons/spectator/stringtable.xml | 3 + 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index 51105b216b..a7790d6da0 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -137,11 +137,11 @@ class GVAR(interface) { idc = -1; style = 64; }; - class fovTool: viewTool { + class zoomTool: viewTool { idc = IDC_TOOL_FOV; x = safeZoneW - TOOL_W * 2 - MARGIN; }; - class fovFrame: fovTool { + class zoomFrame: zoomTool { idc = -1; style = 64; }; @@ -155,25 +155,52 @@ class GVAR(interface) { }; }; }; - class unitTree: RscTree { + class unitTree: RscControlsGroupNoScrollbars { idc = IDC_UNIT; x = safeZoneX; y = safeZoneY + TOOL_H * 6; w = TOOL_W * 2; h = safeZoneH - TOOL_H * 13; - sizeEx = H_PART(0.8); - borderSize = 1; - colorText[] = {COL_FORE}; - colorBorder[] = {COL_FORE}; - colorBackground[] = {COL_BACK}; - colorSelect[] = { - "profilenamespace getvariable ['GUI_BCG_RGB_R',0.77]", - "profilenamespace getvariable ['GUI_BCG_RGB_G',0.51]", - "profilenamespace getvariable ['GUI_BCG_RGB_B',0.08]", - 1 + class controls { + class unitTitle: RscText { + x = 0; + y = 0; + w = TOOL_W * 2; + h = H_PART(1); + style = 2; + colorText[] = {COL_FORE}; + colorBackground[] = {COL_FORE_D}; + sizeEx = H_PART(1); + text = CSTRING(UnitTitle); + }; + class unitTree: RscTree { + idc = IDC_UNIT_TREE; + x = 0; + y = H_PART(1); + w = TOOL_W * 2; + h = safeZoneH - TOOL_H * 14; + sizeEx = H_PART(0.8); + colorText[] = {COL_FORE}; + colorBorder[] = {0,0,0,0}; + colorBackground[] = {COL_BACK}; + colorSelect[] = { + "profilenamespace getvariable ['GUI_BCG_RGB_R',0.77]", + "profilenamespace getvariable ['GUI_BCG_RGB_G',0.51]", + "profilenamespace getvariable ['GUI_BCG_RGB_B',0.08]", + 1 + }; + multiselectEnabled = 0; + onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface)); + }; + class unitFrame: RscFrame { + x = 0; + y = 0; + w = TOOL_W * 2; + h = safeZoneH - TOOL_H * 13; + shadow = 2; + colorText[] = {COL_FORE}; + }; }; - multiselectEnabled = 0; - onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface)); }; class mapOverlay: RscMapControl { idc = IDC_MAP; @@ -191,16 +218,13 @@ class GVAR(interface) { y = safeZoneY + TOOL_H * 6; w = TOOL_W * 2; h = safeZoneH - TOOL_H * 13; - colorText[] = {COL_FORE}; - colorSelectBackground[] = {COL_FORE_D}; - colorSelectBackground2[] = {COL_BACK}; - colorBackground[] = {0,0,0,0}; class controls { class helpTitle: RscText { x = 0; y = 0; w = TOOL_W * 2; h = H_PART(1); + style = 2; colorText[] = {COL_FORE}; colorBackground[] = {COL_FORE_D}; sizeEx = H_PART(1); @@ -213,15 +237,16 @@ class GVAR(interface) { w = TOOL_W * 2; h = safeZoneH - TOOL_H * 14; colorBackground[] = {COL_BACK}; + sizeEx = H_PART(0.8); default = 1; }; - class helpFrame: RscText { + class helpFrame: RscFrame { x = 0; y = 0; w = TOOL_W * 2; h = safeZoneH - TOOL_H * 13; + shadow = 2; colorText[] = {COL_FORE}; - style = 64; }; }; }; diff --git a/addons/spectator/functions/fnc_handleUnits.sqf b/addons/spectator/functions/fnc_handleUnits.sqf index e8cd561da0..c32961024c 100644 --- a/addons/spectator/functions/fnc_handleUnits.sqf +++ b/addons/spectator/functions/fnc_handleUnits.sqf @@ -36,5 +36,5 @@ if !(GVAR(camUnit) in GVAR(unitList)) then { // Reduce overhead when unit tree is hidden if (ctrlShown (_display displayCtrl IDC_UNIT)) then { // Reduce overhead by spreading across frames - [FUNC(handleInterface),["onUnitsUpdate",[_display displayCtrl IDC_UNIT]],1] call EFUNC(common,waitAndExecute); + [FUNC(handleInterface),["onUnitsUpdate",[(_display displayCtrl IDC_UNIT) controlsGroupCtrl IDC_UNIT_TREE]],1] call EFUNC(common,waitAndExecute); }; diff --git a/addons/spectator/script_component.hpp b/addons/spectator/script_component.hpp index a726c6c67f..de2ee22363 100644 --- a/addons/spectator/script_component.hpp +++ b/addons/spectator/script_component.hpp @@ -49,8 +49,9 @@ #define IDC_TOOL_VISION 3004 #define IDC_UNIT 6002 +#define IDC_UNIT_TREE 6005 // UI colours -#define COL_BACK 0.1,0.1,0.1,0.8 +#define COL_BACK 0.1,0.1,0.1,0.7 #define COL_FORE 1,1,1,1 -#define COL_FORE_D 0.1,0.1,0.1,1 +#define COL_FORE_D 0.1,0.1,0.1,0.8 diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 4d615d4e1e..30af5d1aa6 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -101,6 +101,9 @@ <Polish>Termowizja</Polish> </Key> <!-- Interface strings --> + <Key ID="STR_ACE_Spectator_UnitTitle"> + <English>Spectator Units</English> + </Key> <Key ID="STR_ACE_Spectator_HelpTitle"> <English>Spectator Controls</English> <Polish>Sterowanie obserwatorem</Polish> From c5d9ec5d500a83db1bc3e85c4dc9c005f89f8fb0 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 18:59:48 +0100 Subject: [PATCH 29/43] Add speed boost button to spectator free camera Sometimes you just want a burst of speed rather than to adjust it and then adjust it back. Also swapped the speed/zoom scrolling modifier around. --- .../functions/fnc_handleInterface.sqf | 33 ++++++++++--------- addons/spectator/stringtable.xml | 3 ++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index db701366b0..80d87cf40a 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -114,7 +114,7 @@ switch (toLower _mode) do { // Keep unit list and tree up to date [FUNC(handleUnits), 21, _display] call CBA_fnc_addPerFrameHandler; - // Handle unit icons on map and 3D + // Handle 3D unit icons GVAR(iconHandler) = addMissionEventHandler ["Draw3D",FUNC(handleIcons)]; // Populate the help window @@ -146,8 +146,9 @@ switch (toLower _mode) do { [localize LSTRING(freeCamDown),"Z"], [localize LSTRING(freeCamPan),"RMB (Hold)"], [localize LSTRING(freeCamDolly),"LMB (Hold)"], - [localize LSTRING(freeCamSpeed),"Scrollwheel"], - [localize LSTRING(freeCamZoom),"Ctrl + Scrollwheel"], + [localize LSTRING(freeCamZoom),"Scrollwheel"], + [localize LSTRING(freeCamSpeed),"Ctrl + Scrollwheel"], + [localize LSTRING(freeCamBoost),"Shift (Hold)"], [localize LSTRING(freeCamNextVis),"N"], [localize LSTRING(freeCamPrevVis),"Ctrl + N"], [localize LSTRING(otherControls),""], @@ -220,9 +221,9 @@ switch (toLower _mode) do { // Scroll to change speed, modifier for zoom if (GVAR(ctrlKey)) then { - [nil,nil,nil,nil,nil,nil, GVAR(camZoom) + _zChange * 0.1] call FUNC(setCameraAttributes); - } else { [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); }; }; case "onmousemoving": { @@ -268,31 +269,33 @@ switch (toLower _mode) do { [_display,nil,nil,true] call FUNC(toggleInterface); }; case 16: { // Q - GVAR(camBoom) = 0.5 * GVAR(camSpeed); + GVAR(camBoom) = 0.5 * GVAR(camSpeed) * ([1, 2] select _shift); }; case 17: { // W - GVAR(camDolly) set [1, GVAR(camSpeed)]; + GVAR(camDolly) set [1, GVAR(camSpeed) * ([1, 2] select _shift)]; }; case 29: { // Ctrl GVAR(ctrlKey) = true; }; case 30: { // A - GVAR(camDolly) set [0, -GVAR(camSpeed)]; + GVAR(camDolly) set [0, -GVAR(camSpeed) * ([1, 2] select _shift)]; }; case 31: { // S - GVAR(camDolly) set [1, -GVAR(camSpeed)]; + GVAR(camDolly) set [1, -GVAR(camSpeed) * ([1, 2] select _shift)]; }; case 32: { // D - GVAR(camDolly) set [0, GVAR(camSpeed)]; + GVAR(camDolly) set [0, GVAR(camSpeed) * ([1, 2] select _shift)]; }; case 44: { // Z - GVAR(camBoom) = -0.5 * GVAR(camSpeed); + GVAR(camBoom) = -0.5 * GVAR(camSpeed) * ([1, 2] select _shift); }; case 49: { // N - if (_ctrl) then { - [nil,nil,-1] call FUNC(cycleCamera); - } else { - [nil,nil,1] call FUNC(cycleCamera); + if (GVAR(camMode) == 0) then { + if (_ctrl) then { + [nil,nil,-1] call FUNC(cycleCamera); + } else { + [nil,nil,1] call FUNC(cycleCamera); + }; }; }; case 50: { // M diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 30af5d1aa6..b174608d03 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -181,6 +181,9 @@ <English>Speed +/-</English> <Polish>Prędkość +/-</Polish> </Key> + <Key ID="STR_ACE_Spectator_freeCamBoost"> + <English>Speed Boost</English> + </Key> <Key ID="STR_ACE_Spectator_freeCamNextVis"> <English>Next Vision Mode</English> <Polish>Następny tryb wizji</Polish> From 57bda372f0f221f049ecbeebf9d9f0d2ff88ae15 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Fri, 7 Aug 2015 19:00:31 +0100 Subject: [PATCH 30/43] Adjust spectator free camera speed with zoom --- addons/spectator/functions/fnc_handleCamera.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/spectator/functions/fnc_handleCamera.sqf b/addons/spectator/functions/fnc_handleCamera.sqf index 7f53b59009..1d1d5bef9e 100644 --- a/addons/spectator/functions/fnc_handleCamera.sqf +++ b/addons/spectator/functions/fnc_handleCamera.sqf @@ -23,9 +23,9 @@ if (isNil QGVAR(camHandler)) exitWith { [_this select 1] call CBA_fnc_removePerF private ["_oldPos","_mX","_mY","_mZ","_pan","_x","_y","_z"]; _oldPos = getPosASL GVAR(camera); -_mX = GVAR(camDolly) select 0; -_mY = GVAR(camDolly) select 1; -_mZ = GVAR(camBoom); +_mX = (GVAR(camDolly) select 0) / ((GVAR(camZoom) * 0.8) max 1); +_mY = (GVAR(camDolly) select 1) / ((GVAR(camZoom) * 0.8) max 1); +_mZ = GVAR(camBoom) / ((GVAR(camZoom) * 0.8) max 1); _pan = (GVAR(camPan) + 360) % 360; _x = (_oldPos select 0) + (_mX * cos(_pan)) + (_mY * sin(_pan)); From e59f0ce822ab64c8a8fd6c330341e16113437282 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 8 Aug 2015 12:24:49 +0100 Subject: [PATCH 31/43] Fix spectator respawn template for types 0 and 1 Type 0 worked, but the mission didn't end when all players were killed. Type 1 didn't work because isPlayer isn't true for seagulls. So spectator virtual state is now entirely unassociated from objects in the game. --- .../functions/fnc_handleInterface.sqf | 2 +- .../functions/fnc_respawnTemplate.sqf | 11 +++++--- .../spectator/functions/fnc_setSpectator.sqf | 26 +++++++------------ .../functions/fnc_stageSpectator.sqf | 9 +++---- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 80d87cf40a..d06c19bd38 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -80,7 +80,7 @@ switch (toLower _mode) do { clearRadio; // Return to player view - _unit switchCamera "internal"; + player switchCamera "internal"; // Enable BI damage effects BIS_fnc_feedback_allowPP = true; diff --git a/addons/spectator/functions/fnc_respawnTemplate.sqf b/addons/spectator/functions/fnc_respawnTemplate.sqf index b03c6dfb06..b808c43eab 100644 --- a/addons/spectator/functions/fnc_respawnTemplate.sqf +++ b/addons/spectator/functions/fnc_respawnTemplate.sqf @@ -21,6 +21,11 @@ params [["_unit",objNull,[objNull]], ["_killer",objNull,[objNull]], ["_respawn",0,[0]], ["_respawnDelay",0,[0]]]; private ["_vision","_pos"]; +// End mission when all are dead with respawn type "None" +if ((_respawn == 0) && {{alive _x} count allPlayers <= 0}) exitWith { + [["endDeath",false],"BIS_fnc_endMission"] call EFUNC(common,execRemoteFnc); +}; + if (isNull _killer) then {_killer = _unit}; _vision = [-2,-1] select (sunOrMoon < 1); _pos = (getPosATL _unit) vectorAdd [0,0,5]; @@ -29,11 +34,11 @@ if (alive _unit) then { if (_respawn == 1) then { [_unit,QGVAR(isSeagull)] call EFUNC(common,hideUnit); [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); + [true] call FUNC(setSpectator); } else { - [_unit,false] call FUNC(setSpectator); + [false] call FUNC(setSpectator); }; } else { [2,_killer,_vision,_pos,getDir _unit] call FUNC(setCameraAttributes); - [_unit] call FUNC(setSpectator); + [true] call FUNC(setSpectator); }; diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index 2d5ada415c..4f41e073d7 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -1,48 +1,42 @@ /* * Author: SilentSpike - * Sets target player to the given spectator state (virtually) + * Sets local client to the given spectator state (virtually) * To physically handle a spectator see ace_spectator_fnc_stageSpectator * - * Player will be able to communicate in ACRE/TFAR as appropriate + * Client will be able to communicate in ACRE/TFAR as appropriate * The spectator interface will be opened/closed * * Arguments: - * 0: Unit to put into spectator state <OBJECT> - * 1: Spectator state <BOOL> <OPTIONAL> + * 0: Spectator state of local client <BOOL> <OPTIONAL> * * Return Value: * None <NIL> * * Example: - * [player, true] call ace_spectator_fnc_setSpectator + * [true] call ace_spectator_fnc_setSpectator * * Public: Yes */ #include "script_component.hpp" -params ["_unit", ["_set",true,[true]]]; +params [["_set",true,[true]]]; -// Only run for player units -if !(isPlayer _unit) exitWith {}; - -if !(local _unit) exitwith { - [[_unit, _set], QFUNC(setSpectator), _unit] call EFUNC(common,execRemoteFnc); -}; +// Only clients can be spectators +if !(hasInterface) exitWith {}; // Handle common addon audio if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set}; if (["acre_sys_radio"] call EFUNC(common,isModLoaded)) then {[_set] call acre_api_fnc_setSpectator}; -if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[_unit, _set] call TFAR_fnc_forceSpectator}; +if (["task_force_radio"] call EFUNC(common,isModLoaded)) then {[player, _set] call TFAR_fnc_forceSpectator}; if (_set) then { ["open"] call FUNC(handleInterface); } else { - ["close",_unit] call FUNC(handleInterface); + ["close"] call FUNC(handleInterface); }; // Mark spectator state for reference -_unit setVariable [QGVAR(isSet), _set, true]; GVAR(isSet) = _set; -["spectatorSet",[_set,_unit]] call EFUNC(common,localEvent); +["spectatorSet",[_set]] call EFUNC(common,localEvent); diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 3e17235e3e..7f0d862719 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -7,7 +7,7 @@ * Upon unstage, units will be moved to the position they were in upon staging * * Arguments: - * 0: Unit to put into spectator stage <OBJECT> + * 0: Unit to put into spectator stage <OBJECT> <OPTIONAL> * 1: Spectator stage <BOOL> <OPTIONAL> * * Return Value: @@ -21,19 +21,16 @@ #include "script_component.hpp" -params ["_unit", ["_set",true,[true]]]; +params [["_unit",player,[objNull]], ["_set",true,[true]]]; // No change, no service (but allow spectators to be reset) if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {}; -// Only run for player units -if !(isPlayer _unit) exitWith {}; - if !(local _unit) exitwith { [[_unit, _set], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); }; -// Prevent player falling into water +// Prevent unit falling into water _unit enableSimulation !_set; // Move to/from group as appropriate From 5b881224c5a231c35fb96d79183f240265915e89 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 8 Aug 2015 13:19:07 +0100 Subject: [PATCH 32/43] Allow admins to use chat in the spectator UI --- addons/spectator/functions/fnc_handleInterface.sqf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index d06c19bd38..21d6266fba 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -238,6 +238,9 @@ switch (toLower _mode) do { if ((alive player) && {_dik in (actionKeys "curatorInterface")} && {!isNull (getAssignedCuratorLogic player)}) exitWith { ["zeus", [_display]] call FUNC(handleInterface); }; + if ((isServer || {serverCommandAvailable "#kick"}) && {_dik in (actionKeys "Chat" + actionKeys "PrevChannel" + actionKeys "NextChannel")}) exitWith { + false + }; // Handle held keys (prevent repeat calling) if (_dik in GVAR(heldKeys)) exitwith {}; From be7b156c49170da938b120cd16d45ec7c6daa245 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 8 Aug 2015 15:49:07 +0100 Subject: [PATCH 33/43] Add "focus on unit" to spectator free camera Pressing F will move the free camera to a position viewing the unit currently selected in the list. Fixes map teleporting functionality also. --- addons/spectator/UI/interface.hpp | 23 ++++++++-------- .../functions/fnc_handleInterface.sqf | 26 +++++++++++++++++-- .../functions/fnc_setCameraAttributes.sqf | 9 ++++--- .../functions/fnc_transitionCamera.sqf | 3 +-- addons/spectator/stringtable.xml | 3 +++ 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index a7790d6da0..e8bc6c210f 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -155,7 +155,7 @@ class GVAR(interface) { }; }; }; - class unitTree: RscControlsGroupNoScrollbars { + class unitWindow: RscControlsGroupNoScrollbars { idc = IDC_UNIT; x = safeZoneX; y = safeZoneY + TOOL_H * 6; @@ -191,6 +191,7 @@ class GVAR(interface) { }; multiselectEnabled = 0; onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface)); + onTreeSelChanged = QUOTE([ARR_2('onTreeSelChanged',_this)] call FUNC(handleInterface)); }; class unitFrame: RscFrame { x = 0; @@ -202,16 +203,6 @@ class GVAR(interface) { }; }; }; - class mapOverlay: RscMapControl { - idc = IDC_MAP; - type = 100; - x = safeZoneX; - y = safeZoneY; - w = safeZoneW; - h = safeZoneH; - onMouseButtonDown = QUOTE([ARR_2('onMapClick',_this)] call FUNC(handleInterface)); - onDraw = QUOTE(_this call FUNC(handleMap)); - }; class helpWindow: RscControlsGroupNoScrollbars { idc = IDC_HELP; x = safeZoneX + safeZoneW - TOOL_W * 2; @@ -250,5 +241,15 @@ class GVAR(interface) { }; }; }; + class mapOverlay: RscMapControl { + idc = IDC_MAP; + type = 100; + x = safeZoneX; + y = safeZoneY; + w = safeZoneW; + h = safeZoneH; + onMouseButtonDown = QUOTE([ARR_2('onMapClick',_this)] call FUNC(handleInterface)); + onDraw = QUOTE(_this call FUNC(handleMap)); + }; }; }; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 21d6266fba..eda24dccf6 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -35,6 +35,7 @@ switch (toLower _mode) do { GVAR(heldKeys) = []; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; + GVAR(treeSel) = objNull; // Initalize the camera view GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); @@ -96,6 +97,7 @@ switch (toLower _mode) do { GVAR(heldKeys) = nil; GVAR(mouse) = nil; GVAR(mousePos) = nil; + GVAR(treeSel) = nil; // Reset nametag settings if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { @@ -146,11 +148,12 @@ switch (toLower _mode) do { [localize LSTRING(freeCamDown),"Z"], [localize LSTRING(freeCamPan),"RMB (Hold)"], [localize LSTRING(freeCamDolly),"LMB (Hold)"], + [localize LSTRING(freeCamFocus),"F"], + [localize LSTRING(freeCamNextVis),"N"], + [localize LSTRING(freeCamPrevVis),"Ctrl + N"], [localize LSTRING(freeCamZoom),"Scrollwheel"], [localize LSTRING(freeCamSpeed),"Ctrl + Scrollwheel"], [localize LSTRING(freeCamBoost),"Shift (Hold)"], - [localize LSTRING(freeCamNextVis),"N"], - [localize LSTRING(freeCamPrevVis),"Ctrl + N"], [localize LSTRING(otherControls),""], [localize LSTRING(nextCam),"Up Arrow"], [localize LSTRING(prevCam),"Down Arrow"], @@ -289,6 +292,14 @@ 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); }; @@ -374,6 +385,15 @@ 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"]; @@ -485,6 +505,7 @@ switch (toLower _mode) do { GVAR(heldKeys) = []; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; + GVAR(treeSel) = objNull; createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); @@ -538,6 +559,7 @@ switch (toLower _mode) do { GVAR(heldKeys) = []; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; + GVAR(treeSel) = objNull; openCuratorInterface; diff --git a/addons/spectator/functions/fnc_setCameraAttributes.sqf b/addons/spectator/functions/fnc_setCameraAttributes.sqf index 278a8c4758..8eb6fe51ac 100644 --- a/addons/spectator/functions/fnc_setCameraAttributes.sqf +++ b/addons/spectator/functions/fnc_setCameraAttributes.sqf @@ -51,7 +51,6 @@ if !(_vision in GVAR(availableVisions)) then { }; GVAR(camPan) = _heading % 360; -GVAR(camPos) = (ATLtoASL _position); GVAR(camSpeed) = (_speed max 0.05) min 10; GVAR(camTilt) = (_tilt max -89) min 89; GVAR(camUnit) = _unit; @@ -59,8 +58,10 @@ GVAR(camVision) = _vision; GVAR(camZoom) = (_zoom min 2) max 0.01; // Apply if camera exists -if !(isNil QGVAR(camera)) then { - [_mode,_unit,_vision] call FUNC(transitionCamera); -} else { +if (isNil QGVAR(camera)) then { GVAR(camMode) = _mode; + GVAR(camPos) = (ATLtoASL _position); +} else { + [_mode,_unit,_vision] call FUNC(transitionCamera); + GVAR(camera) setPosATL _position; }; diff --git a/addons/spectator/functions/fnc_transitionCamera.sqf b/addons/spectator/functions/fnc_transitionCamera.sqf index b35b61b311..72cb9f1a45 100644 --- a/addons/spectator/functions/fnc_transitionCamera.sqf +++ b/addons/spectator/functions/fnc_transitionCamera.sqf @@ -53,8 +53,7 @@ if (_newMode == 0) then { // Free GVAR(camera) camSetFov -(linearConversion [0.01,2,GVAR(camZoom),-2,-0.01,true]); GVAR(camera) camCommit 0; - // Agent is switched to in free cam to hide death table and prevent AI chat while allowing icons to draw - // However, map click events don't fire in free cam for some reason... + // Agent is switched to in free cam to hide death table and prevent AI chat while allowing icons to draw (also prevents systemChat and unit HUD) // (Why is so much stuff tied into the current camera unit BI?!) if (isNull GVAR(camAgent)) then { GVAR(camAgent) = createAgent ["VirtualMan_F",markerPos QGVAR(respawn),[],0,""]; diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index b174608d03..c4b9b6b631 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -184,6 +184,9 @@ <Key ID="STR_ACE_Spectator_freeCamBoost"> <English>Speed Boost</English> </Key> + <Key ID="STR_ACE_Spectator_freeCamFocus"> + <English>Focus on Unit</English> + </Key> <Key ID="STR_ACE_Spectator_freeCamNextVis"> <English>Next Vision Mode</English> <Polish>Następny tryb wizji</Polish> From d7730103c98c0cf5d677abeb42128de29e375aaf Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 8 Aug 2015 17:22:04 +0100 Subject: [PATCH 34/43] Update ace_spectator readme --- addons/spectator/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/spectator/README.md b/addons/spectator/README.md index b3e586149b..b827bdcc49 100644 --- a/addons/spectator/README.md +++ b/addons/spectator/README.md @@ -1,7 +1,11 @@ ace_spectator ======= -Spectator. Includes features from Splendid Cam, and much more. +A flexible spectator framework for mission makers to use. + +Includes a public API for integration into custom respawn frameworks and a template for use with the vanilla respawn framework. + +For more information, see: http://ace3mod.com/wiki/feature/spectator.html ## Maintainers From 213deeffb405ac85138bd8376b25274922b6af02 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 8 Aug 2015 18:31:37 +0100 Subject: [PATCH 35/43] Add keys to adjust spectator camera speed and zoom Allows for finer control of the speed and zoom, as well as a quick way to reset either. --- addons/spectator/XEH_preInit.sqf | 2 +- .../functions/fnc_handleInterface.sqf | 40 ++++++++++---- addons/spectator/stringtable.xml | 53 +++++++++++-------- 3 files changed, 61 insertions(+), 34 deletions(-) diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 2c29598ebc..a40f4a0dcb 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -33,7 +33,7 @@ GVAR(camAgent) = objNull; GVAR(camMode) = 0; GVAR(camPan) = 0; GVAR(camPos) = ATLtoASL [worldSize * 0.5, worldSize * 0.5, 20]; -GVAR(camSpeed) = 1; +GVAR(camSpeed) = 2.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 eda24dccf6..80ee564ab5 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -148,17 +148,21 @@ switch (toLower _mode) do { [localize LSTRING(freeCamDown),"Z"], [localize LSTRING(freeCamPan),"RMB (Hold)"], [localize LSTRING(freeCamDolly),"LMB (Hold)"], - [localize LSTRING(freeCamFocus),"F"], - [localize LSTRING(freeCamNextVis),"N"], - [localize LSTRING(freeCamPrevVis),"Ctrl + N"], - [localize LSTRING(freeCamZoom),"Scrollwheel"], - [localize LSTRING(freeCamSpeed),"Ctrl + Scrollwheel"], [localize LSTRING(freeCamBoost),"Shift (Hold)"], - [localize LSTRING(otherControls),""], + [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(prevUnit),"Left Arrow"], + [localize LSTRING(nextVis),"N"], + [localize LSTRING(prevVis),"Ctrl + N"], + [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+"] ]; // Handle support for BI's respawn counter @@ -247,8 +251,8 @@ switch (toLower _mode) do { // Handle held keys (prevent repeat calling) if (_dik in GVAR(heldKeys)) exitwith {}; - // Exclude movement keys so that speed can be adjusted on fly - if !(_dik in [16,17,30,31,32,44]) then { + // Exclude movement/adjustment keys so that speed can be adjusted on fly + if !(_dik in [16,17,30,31,32,44,74,78]) then { GVAR(heldKeys) pushBack _dik; }; @@ -295,7 +299,7 @@ switch (toLower _mode) do { case 33: { // F private ["_sel","_vector"]; _sel = GVAR(treeSel); - if !((GVAR(camMode) == 0) && {isNull _sel} && {_sel in GVAR(unitList)}) then { + 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); }; @@ -318,6 +322,22 @@ switch (toLower _mode) do { case 57: { // Spacebar // Freecam attachment here, if in external then set cam pos and attach }; + 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 + + if (_alt) exitWith { [nil,nil,nil,nil,nil,nil,nil, 2.5] 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 200: { // Up arrow [-1] call FUNC(cycleCamera); }; diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index c4b9b6b631..895a279844 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -134,8 +134,7 @@ </Key> <!-- Controls --> <Key ID="STR_ACE_Spectator_freeCamControls"> - <English>Free Camera Controls</English> - <Polish>Wolne sterowanie kamerą</Polish> + <English>Free Camera</English> </Key> <Key ID="STR_ACE_Spectator_freeCamForward"> <English>Camera Forward</English> @@ -173,31 +172,14 @@ <English>Lock Camera to Target</English> <Polish>Zablokuj kamerę na celu</Polish> </Key> - <Key ID="STR_ACE_Spectator_freeCamZoom"> - <English>Zoom +/-</English> - <Polish>Zoom +/-</Polish> - </Key> - <Key ID="STR_ACE_Spectator_freeCamSpeed"> - <English>Speed +/-</English> - <Polish>Prędkość +/-</Polish> - </Key> <Key ID="STR_ACE_Spectator_freeCamBoost"> <English>Speed Boost</English> </Key> <Key ID="STR_ACE_Spectator_freeCamFocus"> <English>Focus on Unit</English> </Key> - <Key ID="STR_ACE_Spectator_freeCamNextVis"> - <English>Next Vision Mode</English> - <Polish>Następny tryb wizji</Polish> - </Key> - <Key ID="STR_ACE_Spectator_freeCamPrevVis"> - <English>Previous Vision Mode</English> - <Polish>Poprzedni tryb wizji</Polish> - </Key> <Key ID="STR_ACE_Spectator_uiControls"> - <English>Interface Controls</English> - <Polish>Sterowanie interfejsem</Polish> + <English>Interface</English> </Key> <Key ID="STR_ACE_Spectator_uiToggleInterface"> <English>Toggle Interface</English> @@ -227,9 +209,8 @@ <English>Toggle Help</English> <Polish>Przełącz pomoc</Polish> </Key> - <Key ID="STR_ACE_Spectator_otherControls"> - <English>Other Controls</English> - <Polish>Pozostałe sterowanie</Polish> + <Key ID="STR_ACE_Spectator_attributeControls"> + <English>Camera Attributes</English> </Key> <Key ID="STR_ACE_Spectator_nextCam"> <English>Next Camera</English> @@ -247,5 +228,31 @@ <English>Previous Unit</English> <Polish>Poprzednia jednostka</Polish> </Key> + <Key ID="STR_ACE_Spectator_nextVis"> + <English>Next Vision Mode</English> + <Polish>Następny tryb wizji</Polish> + </Key> + <Key ID="STR_ACE_Spectator_prevVis"> + <English>Previous Vision Mode</English> + <Polish>Poprzedni tryb wizji</Polish> + </Key> + <Key ID="STR_ACE_Spectator_adjZoom"> + <English>Adjust Zoom</English> + </Key> + <Key ID="STR_ACE_Spectator_adjSpeed"> + <English>Adjust Speed</English> + </Key> + <Key ID="STR_ACE_Spectator_incZoom"> + <English>Increment Zoom</English> + </Key> + <Key ID="STR_ACE_Spectator_incSpeed"> + <English>Increment Speed</English> + </Key> + <Key ID="STR_ACE_Spectator_reZoom"> + <English>Reset Zoom</English> + </Key> + <Key ID="STR_ACE_Spectator_reSpeed"> + <English>Reset Speed</English> + </Key> </Package> </Project> From 182eef39de65cc53d413df36db6b7286bca20c68 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 8 Aug 2015 18:41:38 +0100 Subject: [PATCH 36/43] Adjust spectator camera pan and tilt with zoom --- addons/spectator/functions/fnc_handleCamera.sqf | 11 +++++++---- addons/spectator/functions/fnc_handleMouse.sqf | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/addons/spectator/functions/fnc_handleCamera.sqf b/addons/spectator/functions/fnc_handleCamera.sqf index 1d1d5bef9e..960a20df80 100644 --- a/addons/spectator/functions/fnc_handleCamera.sqf +++ b/addons/spectator/functions/fnc_handleCamera.sqf @@ -20,12 +20,15 @@ // Kill PFH when not in free cam (or display is closed) if (isNil QGVAR(camHandler)) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -private ["_oldPos","_mX","_mY","_mZ","_pan","_x","_y","_z"]; +private ["_oldPos","_zoomMod","_mX","_mY","_mZ","_pan","_x","_y","_z"]; _oldPos = getPosASL GVAR(camera); -_mX = (GVAR(camDolly) select 0) / ((GVAR(camZoom) * 0.8) max 1); -_mY = (GVAR(camDolly) select 1) / ((GVAR(camZoom) * 0.8) max 1); -_mZ = GVAR(camBoom) / ((GVAR(camZoom) * 0.8) max 1); + +// Dolly/Boom amount should be influnced by zoom level (it should really be exponential) +_zoomMod = (GVAR(camZoom) * 0.8) max 1; +_mX = (GVAR(camDolly) select 0) / _zoomMod; +_mY = (GVAR(camDolly) select 1) / _zoomMod; +_mZ = GVAR(camBoom) / _zoomMod; _pan = (GVAR(camPan) + 360) % 360; _x = (_oldPos select 0) + (_mX * cos(_pan)) + (_mY * sin(_pan)); diff --git a/addons/spectator/functions/fnc_handleMouse.sqf b/addons/spectator/functions/fnc_handleMouse.sqf index 8158ba95b5..1c2b62798c 100644 --- a/addons/spectator/functions/fnc_handleMouse.sqf +++ b/addons/spectator/functions/fnc_handleMouse.sqf @@ -18,7 +18,7 @@ #include "script_component.hpp" params ["_x","_y"]; -private ["_leftButton","_rightButton","_oldX","_oldY","_deltaX","_deltaY"]; +private ["_leftButton","_rightButton","_oldX","_oldY","_deltaX","_deltaY","_zoomMod"]; _leftButton = GVAR(mouse) select 0; _rightButton = GVAR(mouse) select 1; @@ -35,8 +35,11 @@ if (_leftButton) then { GVAR(camDolly) set [1, _deltaY * 100 * GVAR(camSpeed)]; } else { if (_rightButton) then { - GVAR(camPan) = GVAR(camPan) - (_deltaX * 360); - GVAR(camTilt) = ((GVAR(camTilt) + (_deltaY * 180)) min 89) max -89; + // Pan/Tilt amount should be influnced by zoom level (it should really be exponential) + _zoomMod = (GVAR(camZoom) * 0.8) max 1; + + GVAR(camPan) = GVAR(camPan) - ((_deltaX * 360) / _zoomMod); + GVAR(camTilt) = ((GVAR(camTilt) + ((_deltaY * 180) / _zoomMod)) min 89) max -89; }; }; From c30cb45bd63fc40a0f6d8087f82655ac0363227d Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sun, 9 Aug 2015 20:59:57 +0100 Subject: [PATCH 37/43] Optimize spectator UI held key prevention system --- addons/spectator/functions/fnc_handleInterface.sqf | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 80ee564ab5..335b71bbe1 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -33,6 +33,7 @@ switch (toLower _mode) do { // Initalize display variables GVAR(ctrlKey) = false; GVAR(heldKeys) = []; + GVAR(heldKeys) resize 255; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; GVAR(treeSel) = objNull; @@ -250,10 +251,10 @@ switch (toLower _mode) do { }; // Handle held keys (prevent repeat calling) - if (_dik in GVAR(heldKeys)) exitwith {}; + if (GVAR(heldKeys) param [_dik,false]) exitwith {}; // Exclude movement/adjustment keys so that speed can be adjusted on fly if !(_dik in [16,17,30,31,32,44,74,78]) then { - GVAR(heldKeys) pushBack _dik; + GVAR(heldKeys) set [_dik,true]; }; switch (_dik) do { @@ -358,7 +359,7 @@ switch (toLower _mode) do { _args params ["_display","_dik","_shift","_ctrl","_alt"]; // No longer being held - GVAR(heldKeys) = GVAR(heldKeys) - [_dik]; + GVAR(heldKeys) set [_dik,nil]; switch (_dik) do { case 16: { // Q @@ -523,6 +524,7 @@ switch (toLower _mode) do { GVAR(ctrlKey) = false; GVAR(heldKeys) = []; + GVAR(heldKeys) resize 255; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; GVAR(treeSel) = objNull; @@ -577,6 +579,7 @@ switch (toLower _mode) do { GVAR(ctrlKey) = false; GVAR(heldKeys) = []; + GVAR(heldKeys) resize 255; GVAR(mouse) = [false,false]; GVAR(mousePos) = [0.5,0.5]; GVAR(treeSel) = objNull; From 95aa9f604bf83d29ad51267cc1d62ded6eaf2f18 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Tue, 11 Aug 2015 13:53:55 +0100 Subject: [PATCH 38/43] Fix manual pre-setting of spectator camera unit If the spectator camera unit was set before the camera had ever opened then the unit list wouldn't be populated and as such the camera would automatically abort to free mode since the unit wasn't available to spectate. So now I'm running the updateUnits function before opening the camera to pre-populate the list. --- addons/spectator/functions/fnc_handleInterface.sqf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 335b71bbe1..95f05d01ec 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -38,6 +38,9 @@ switch (toLower _mode) do { GVAR(mousePos) = [0.5,0.5]; GVAR(treeSel) = objNull; + // Update units before opening to support pre-set camera unit + [] call FUNC(updateUnits); + // Initalize the camera view GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); [] call FUNC(transitionCamera); From 21b0ee087a48d55d7b86e901da6eeb6644882967 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 22 Aug 2015 00:26:01 +0100 Subject: [PATCH 39/43] Add spectator UI interrupt system A public API system to allow external systems to interrupt and resume the spectator interface. Also made use of it for the escape menu and zeus support. --- addons/spectator/XEH_preInit.sqf | 2 + .../functions/fnc_handleInterface.sqf | 66 +++++++------------ addons/spectator/functions/fnc_interrupt.sqf | 44 +++++++++++++ 3 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 addons/spectator/functions/fnc_interrupt.sqf diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index a40f4a0dcb..d1bf48d106 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -12,6 +12,7 @@ PREP(handleMap); PREP(handleMouse); PREP(handleToolbar); PREP(handleUnits); +PREP(interrupt); PREP(moduleSpectatorSettings); PREP(respawnTemplate); PREP(setCameraAttributes); @@ -39,6 +40,7 @@ GVAR(camUnit) = objNull; GVAR(camVision) = -2; GVAR(camZoom) = 1.25; +GVAR(interrupts) = []; GVAR(isSet) = false; GVAR(showComp) = true; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 95f05d01ec..57026fb6fa 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -24,6 +24,7 @@ switch (toLower _mode) do { case "open": { // Prevent reopening if (GVAR(isSet)) exitWith {}; + GVAR(interrupts) = []; // Initalize camera variables GVAR(camBoom) = 0; @@ -68,16 +69,18 @@ switch (toLower _mode) do { }; }; case "close": { - _args params ["_unit"]; - // Can't close a second time if !(GVAR(isSet)) exitWith {}; + GVAR(interrupts) = []; // Terminate interface while {dialog} do { closeDialog 0; }; + // Kill the display + (findDisplay 12249) closeDisplay 0; + // Terminate camera GVAR(camera) cameraEffect ["terminate", "back"]; camDestroy GVAR(camera); @@ -203,11 +206,21 @@ switch (toLower _mode) do { }; case "onunload": { // Kill GUI PFHs + removeMissionEventHandler ["Draw3D",GVAR(iconHandler)]; GVAR(camHandler) = nil; GVAR(compHandler) = nil; - removeMissionEventHandler ["Draw3D",GVAR(iconHandler)]; GVAR(iconHandler) = nil; GVAR(toolHandler) = nil; + + // 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]; + GVAR(treeSel) = objNull; }; // Mouse events case "onmousebuttondown": { @@ -247,7 +260,8 @@ switch (toLower _mode) do { _args params ["_display","_dik","_shift","_ctrl","_alt"]; if ((alive player) && {_dik in (actionKeys "curatorInterface")} && {!isNull (getAssignedCuratorLogic player)}) exitWith { - ["zeus", [_display]] call FUNC(handleInterface); + [QGVAR(zeus)] call FUNC(interrupt); + ["zeus"] call FUNC(handleInterface); }; if ((isServer || {serverCommandAvailable "#kick"}) && {_dik in (actionKeys "Chat" + actionKeys "PrevChannel" + actionKeys "NextChannel")}) exitWith { false @@ -262,7 +276,8 @@ switch (toLower _mode) do { switch (_dik) do { case 1: { // Esc - ["escape", [_display]] call FUNC(handleInterface); + [QGVAR(escape)] call FUNC(interrupt); + ["escape"] call FUNC(handleInterface); }; case 2: { // 1 [_display,nil,nil,nil,nil,nil,true] call FUNC(toggleInterface); @@ -515,23 +530,8 @@ switch (toLower _mode) do { }; // Break from interface for external events case "escape": { - _args params ["_display"]; private "_dlg"; - // Kill display - _display closeDisplay 0; - - // Reset cam/UI vars - 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]; - GVAR(treeSel) = objNull; - createDialog (["RscDisplayInterrupt", "RscDisplayMPInterrupt"] select isMultiplayer); disableSerialization; @@ -562,31 +562,12 @@ switch (toLower _mode) do { if !(isNull (findDisplay 49)) exitWith {}; // If still a spectator then re-enter the interface - if (GVAR(isSet)) then { - createDialog QGVAR(interface); - [] call FUNC(transitionCamera); - }; + [QGVAR(escape),false] call FUNC(interrupt); [_this select 1] call CBA_fnc_removePerFrameHandler; },0] call CBA_fnc_addPerFrameHandler; }; case "zeus": { - _args params ["_display"]; - - // Kill display - _display closeDisplay 0; - - // Reset cam/UI vars - 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]; - GVAR(treeSel) = objNull; - openCuratorInterface; [{ @@ -595,10 +576,7 @@ switch (toLower _mode) do { if !((isNull curatorCamera) && {isNull (GETMVAR(bis_fnc_moduleRemoteControl_unit,objNull))}) exitWith {}; // If still a spectator then re-enter the interface - if (GVAR(isSet)) then { - createDialog QGVAR(interface); - [] call FUNC(transitionCamera); - }; + [QGVAR(zeus),false] call FUNC(interrupt) [_this select 1] call CBA_fnc_removePerFrameHandler; },0] call CBA_fnc_addPerFrameHandler; diff --git a/addons/spectator/functions/fnc_interrupt.sqf b/addons/spectator/functions/fnc_interrupt.sqf new file mode 100644 index 0000000000..48cca7d102 --- /dev/null +++ b/addons/spectator/functions/fnc_interrupt.sqf @@ -0,0 +1,44 @@ +/* + * Author: SilentSpike + * Interrupts the spectator interface for external systems + * + * Arguments: + * 0: Reason <STRING> + * 1: Interrupting <BOOL> + * + * Return Value: + * None <NIL> + * + * Example: + * ["mySystem"] call ace_spectator_fnc_interrupt + * + * Public: Yes + */ +#include "script_component.hpp" + +params [["_reason", "", [""]], ["_interrupt", true, [true]]]; + +// Nothing to do when spectator is closed +if !(GVAR(isSet)) exitWith {}; + +if (_reason == "") exitWith { ERROR("Invalid Reason"); }; +if (_interrupt) then { + GVAR(interrupts) pushBack _reason; +} else { + GVAR(interrupts) = GVAR(interrupts) - [_reason]; +}; + +if (GVAR(interrupts) isEqualTo []) then { + if (isNull (findDisplay 12249)) then { + createDialog QGVAR(interface); + [] call FUNC(transitionCamera); + }; +} else { + if !(isNull (findDisplay 12249)) then { + while {dialog} do { + closeDialog 0; + }; + + (findDisplay 12249) closeDisplay 0; + }; +}; From 152faf63886e43e752b8fc53498a5cf1b3b86a58 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sun, 23 Aug 2015 17:50:11 +0100 Subject: [PATCH 40/43] Improve spectator interface entry and exit - Use a display rather than a dialog (contextually makes more sense). - Move the entry/exit functionality to the setSpectator function. Preserves the handleInterface function for purely display related events and makes more sense. - Fix missing semi-colon --- .../functions/fnc_handleInterface.sqf | 98 +------------------ .../spectator/functions/fnc_setSpectator.sqf | 88 ++++++++++++++++- 2 files changed, 88 insertions(+), 98 deletions(-) diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 57026fb6fa..93c6ca3ddd 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -20,100 +20,6 @@ params ["_mode",["_args",[]]]; switch (toLower _mode) do { - // Safely open/close the interface - case "open": { - // Prevent reopening - if (GVAR(isSet)) exitWith {}; - GVAR(interrupts) = []; - - // Initalize camera variables - GVAR(camBoom) = 0; - GVAR(camDolly) = [0,0]; - GVAR(camGun) = false; - - // Initalize display variables - GVAR(ctrlKey) = false; - GVAR(heldKeys) = []; - 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); - - // Initalize the camera view - GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); - [] call FUNC(transitionCamera); - - // Close map and clear radio - openMap [false,false]; - clearRadio; - - // Disable BI damage effects - BIS_fnc_feedback_allowPP = false; - - // Close all existing dialogs - while {dialog} do { - closeDialog 0; - }; - - // Create the dialog - createDialog QGVAR(interface); - - // Cache and disable nametag settings - if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { - GVAR(nametagSettingCache) = [EGVAR(nametags,showPlayerNames), EGVAR(nametags,showNamesForAI)]; - EGVAR(nametags,showPlayerNames) = 0; - EGVAR(nametags,showNamesForAI) = false; - }; - }; - case "close": { - // Can't close a second time - if !(GVAR(isSet)) exitWith {}; - GVAR(interrupts) = []; - - // Terminate interface - while {dialog} do { - closeDialog 0; - }; - - // Kill the display - (findDisplay 12249) closeDisplay 0; - - // Terminate camera - GVAR(camera) cameraEffect ["terminate", "back"]; - camDestroy GVAR(camera); - - clearRadio; - - // Return to player view - player switchCamera "internal"; - - // Enable BI damage effects - BIS_fnc_feedback_allowPP = true; - - // Cleanup camera variables - GVAR(camera) = nil; - GVAR(camBoom) = nil; - GVAR(camDolly) = nil; - GVAR(camGun) = nil; - - // Cleanup display variables - GVAR(ctrlKey) = nil; - GVAR(heldKeys) = nil; - GVAR(mouse) = nil; - GVAR(mousePos) = nil; - GVAR(treeSel) = nil; - - // Reset nametag settings - if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { - EGVAR(nametags,showPlayerNames) = GVAR(nametagSettingCache) select 0; - EGVAR(nametags,showNamesForAI) = GVAR(nametagSettingCache) select 1; - GVAR(nametagSettingCache) = nil; - }; - }; - // Dialog events case "onload": { _args params ["_display"]; @@ -528,7 +434,7 @@ switch (toLower _mode) do { [nil,nil,nil, _newPos] call FUNC(setCameraAttributes); }; }; - // Break from interface for external events + // Interrupt events case "escape": { private "_dlg"; @@ -576,7 +482,7 @@ switch (toLower _mode) do { if !((isNull curatorCamera) && {isNull (GETMVAR(bis_fnc_moduleRemoteControl_unit,objNull))}) exitWith {}; // If still a spectator then re-enter the interface - [QGVAR(zeus),false] call FUNC(interrupt) + [QGVAR(zeus),false] call FUNC(interrupt); [_this select 1] call CBA_fnc_removePerFrameHandler; },0] call CBA_fnc_addPerFrameHandler; diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index 4f41e073d7..621100a5ba 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -25,17 +25,101 @@ params [["_set",true,[true]]]; // Only clients can be spectators if !(hasInterface) exitWith {}; +// Exit if no change +if (_set isEqualTo GVAR(isSet)) exitwith {}; + // Handle common addon audio if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = _set}; 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}; if (_set) then { - ["open"] call FUNC(handleInterface); + // Initalize camera variables + GVAR(camBoom) = 0; + GVAR(camDolly) = [0,0]; + GVAR(camGun) = false; + + // Initalize display variables + GVAR(ctrlKey) = false; + GVAR(heldKeys) = []; + 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); + + // Initalize the camera view + GVAR(camera) = "Camera" camCreate (ASLtoATL GVAR(camPos)); + [] call FUNC(transitionCamera); + + // Close map and clear radio + openMap [false,false]; + clearRadio; + + // Disable BI damage effects + BIS_fnc_feedback_allowPP = false; + + // Close any open dialogs + while {dialog} do { + closeDialog 0; + }; + + // Create the display + (findDisplay 46) createDisplay QGVAR(interface); + + // Cache and disable nametag settings + if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { + GVAR(nametagSettingCache) = [EGVAR(nametags,showPlayerNames), EGVAR(nametags,showNamesForAI)]; + EGVAR(nametags,showPlayerNames) = 0; + EGVAR(nametags,showNamesForAI) = false; + }; } else { - ["close"] call FUNC(handleInterface); + // Close any open dialogs (could be interrupts) + while {dialog} do { + closeDialog 0; + }; + + // Kill the display + (findDisplay 12249) closeDisplay 0; + + // Terminate camera + GVAR(camera) cameraEffect ["terminate", "back"]; + camDestroy GVAR(camera); + + clearRadio; + + // Return to player view + player switchCamera "internal"; + + // Enable BI damage effects + BIS_fnc_feedback_allowPP = true; + + // Cleanup camera variables + GVAR(camera) = nil; + GVAR(camBoom) = nil; + GVAR(camDolly) = nil; + GVAR(camGun) = nil; + + // Cleanup display variables + GVAR(ctrlKey) = nil; + GVAR(heldKeys) = nil; + GVAR(mouse) = nil; + GVAR(mousePos) = nil; + GVAR(treeSel) = nil; + + // Reset nametag settings + if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { + EGVAR(nametags,showPlayerNames) = GVAR(nametagSettingCache) select 0; + EGVAR(nametags,showNamesForAI) = GVAR(nametagSettingCache) select 1; + GVAR(nametagSettingCache) = nil; + }; }; +// Reset interruptions +GVAR(interrupts) = []; + // Mark spectator state for reference GVAR(isSet) = _set; From 0fa10045d2507bf4a42247c5576c28d804a460af Mon Sep 17 00:00:00 2001 From: gienkov <gienkov.grzegorz@gmail.com> Date: Mon, 24 Aug 2015 14:35:15 +0200 Subject: [PATCH 41/43] pl translation of spectator --- addons/spectator/stringtable.xml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 895a279844..e6cf1d7fd4 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -27,6 +27,7 @@ </Key> <Key ID="STR_ACE_Spectator_units_playable"> <English>Playable Units</English> + <Polish>Grywalne jednostki</Polish> </Key> <Key ID="STR_ACE_Spectator_units_all"> <English>All units</English> @@ -103,6 +104,7 @@ <!-- Interface strings --> <Key ID="STR_ACE_Spectator_UnitTitle"> <English>Spectator Units</English> + <Polish>Obserwatorzy</Polish> </Key> <Key ID="STR_ACE_Spectator_HelpTitle"> <English>Spectator Controls</English> @@ -135,6 +137,7 @@ <!-- Controls --> <Key ID="STR_ACE_Spectator_freeCamControls"> <English>Free Camera</English> + <Polish>Kamera swobodna</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamForward"> <English>Camera Forward</English> @@ -174,12 +177,15 @@ </Key> <Key ID="STR_ACE_Spectator_freeCamBoost"> <English>Speed Boost</English> + <Polish>Przyśpieszenie kamery</Polish> </Key> <Key ID="STR_ACE_Spectator_freeCamFocus"> <English>Focus on Unit</English> + <Polish>Skup na jednostce</Polish> </Key> <Key ID="STR_ACE_Spectator_uiControls"> <English>Interface</English> + <Polish>Interfejs</Polish> </Key> <Key ID="STR_ACE_Spectator_uiToggleInterface"> <English>Toggle Interface</English> @@ -211,6 +217,7 @@ </Key> <Key ID="STR_ACE_Spectator_attributeControls"> <English>Camera Attributes</English> + <Polish>Atrybuty kamery</Polish> </Key> <Key ID="STR_ACE_Spectator_nextCam"> <English>Next Camera</English> @@ -238,21 +245,27 @@ </Key> <Key ID="STR_ACE_Spectator_adjZoom"> <English>Adjust Zoom</English> + <Polish>Reguluj zoom</Polish> </Key> <Key ID="STR_ACE_Spectator_adjSpeed"> <English>Adjust Speed</English> + <Polish>Reguluj prędkość</Polish> </Key> <Key ID="STR_ACE_Spectator_incZoom"> <English>Increment Zoom</English> + <Polish>Reguluj zoom (krok)</Polish> </Key> <Key ID="STR_ACE_Spectator_incSpeed"> <English>Increment Speed</English> + <Polish>Reguluj prędkość (krok)</Polish> </Key> <Key ID="STR_ACE_Spectator_reZoom"> <English>Reset Zoom</English> + <Polish>Resetuj zoom</Polish> </Key> <Key ID="STR_ACE_Spectator_reSpeed"> <English>Reset Speed</English> + <Polish>Resetuj prędkość</Polish> </Key> </Package> -</Project> +</Project> \ No newline at end of file From 288457d3665d43125a60ccfff56f6b462205ad8f Mon Sep 17 00:00:00 2001 From: Grzegorz <gienkov.grzegorz@gmail.com> Date: Mon, 24 Aug 2015 17:43:02 +0200 Subject: [PATCH 42/43] fix --- addons/spectator/stringtable.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index e6cf1d7fd4..5c24224b72 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -104,7 +104,7 @@ <!-- Interface strings --> <Key ID="STR_ACE_Spectator_UnitTitle"> <English>Spectator Units</English> - <Polish>Obserwatorzy</Polish> + <Polish>Jednostki obserwatora</Polish> </Key> <Key ID="STR_ACE_Spectator_HelpTitle"> <English>Spectator Controls</English> @@ -268,4 +268,4 @@ <Polish>Resetuj prędkość</Polish> </Key> </Package> -</Project> \ No newline at end of file +</Project> From 200f44d96336c08eb8f4e1b055de5e052761a808 Mon Sep 17 00:00:00 2001 From: SilentSpike <silentspike100+Github@gmail.com> Date: Sat, 29 Aug 2015 16:03:43 +0100 Subject: [PATCH 43/43] Adjust spectator camera speed based on height Slows the camera movement close to the ground as it feels more natural when spectating units up close and such --- .../spectator/functions/fnc_handleCamera.sqf | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/spectator/functions/fnc_handleCamera.sqf b/addons/spectator/functions/fnc_handleCamera.sqf index 960a20df80..db196c8504 100644 --- a/addons/spectator/functions/fnc_handleCamera.sqf +++ b/addons/spectator/functions/fnc_handleCamera.sqf @@ -20,14 +20,18 @@ // Kill PFH when not in free cam (or display is closed) if (isNil QGVAR(camHandler)) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; -private ["_oldPos","_zoomMod","_mX","_mY","_mZ","_pan","_x","_y","_z"]; +private ["_camera","_oldPos","_altMod","_zoomMod","_mX","_mY","_mZ","_pan","_x","_y","_z"]; -_oldPos = getPosASL GVAR(camera); +_camera = GVAR(camera); +_oldPos = getPosASL _camera; // Dolly/Boom amount should be influnced by zoom level (it should really be exponential) +// Dollying should also slow as the camera gets close to the ground _zoomMod = (GVAR(camZoom) * 0.8) max 1; -_mX = (GVAR(camDolly) select 0) / _zoomMod; -_mY = (GVAR(camDolly) select 1) / _zoomMod; +_altMod = ((((getPos _camera) select 2) * 0.05) max 0.1) min 1; + +_mX = (GVAR(camDolly) select 0) * _altMod / _zoomMod; +_mY = (GVAR(camDolly) select 1) * _altMod / _zoomMod; _mZ = GVAR(camBoom) / _zoomMod; _pan = (GVAR(camPan) + 360) % 360; @@ -39,6 +43,6 @@ _z = (_oldPos select 2) + _mZ; GVAR(camPos) = [_x,_y,_z max (getTerrainHeightASL [_x,_y])]; // Update camera position and rotation -GVAR(camera) setPosASL GVAR(camPos); -GVAR(camera) setDir GVAR(camPan); -[GVAR(camera), GVAR(camTilt), 0] call BIS_fnc_setPitchBank; +_camera setPosASL GVAR(camPos); +_camera setDir GVAR(camPan); +[_camera, GVAR(camTilt), 0] call BIS_fnc_setPitchBank;