From cfcb9fedb617743a12188c3720e100eaf4a26537 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Fri, 17 Jul 2015 16:02:38 +0100 Subject: [PATCH] Updating ace settings --- addons/spectator/ACE_Settings.hpp | 24 ++--- addons/spectator/CfgVehicles.hpp | 90 +++++++++++-------- addons/spectator/UI/interface.hpp | 18 ++-- addons/spectator/XEH_postInit.sqf | 29 ++---- addons/spectator/XEH_preInit.sqf | 2 +- .../functions/fnc_handleInterface.sqf | 2 +- .../functions/fnc_moduleSpectator.sqf | 32 ------- .../functions/fnc_moduleSpectatorSettings.sqf | 27 ++++++ .../spectator/functions/fnc_updateUnits.sqf | 56 ++++++------ addons/spectator/stringtable.xml | 73 ++++++--------- 10 files changed, 159 insertions(+), 194 deletions(-) delete mode 100644 addons/spectator/functions/fnc_moduleSpectator.sqf create mode 100644 addons/spectator/functions/fnc_moduleSpectatorSettings.sqf diff --git a/addons/spectator/ACE_Settings.hpp b/addons/spectator/ACE_Settings.hpp index 46cb4b5a89..5c1b71d45c 100644 --- a/addons/spectator/ACE_Settings.hpp +++ b/addons/spectator/ACE_Settings.hpp @@ -1,26 +1,20 @@ class ACE_Settings { - class GVAR(enabled) { - value = 0; + class GVAR(enabledSystem) { typeName = "BOOL"; + value = 0; }; - class GVAR(limitSide) { + class GVAR(filterUnits) { + typeName = "SCALAR"; value = 0; - typeName = "BOOL"; + values[] = {"$STR_Special_None", CSTRING(units_players), CSTRING(units_all)}; }; - class GVAR(allowAI) { + class GVAR(filterSides) { + typeName = "SCALAR"; value = 0; - typeName = "BOOL"; - }; - class GVAR(tracking) { - value = 0; - typeName = "BOOL"; - }; - class GVAR(modulePos) { - value = 0; - typeName = "BOOL"; + values[] = {"$STR_Special_None", CSTRING(sides_player), CSTRING(sides_friendly), CSTRING(sides_all)}; }; class GVAR(endMission) { - value = 0; typeName = "BOOL"; + value = 0; }; }; diff --git a/addons/spectator/CfgVehicles.hpp b/addons/spectator/CfgVehicles.hpp index ceed6d3f3b..a25c758bbd 100644 --- a/addons/spectator/CfgVehicles.hpp +++ b/addons/spectator/CfgVehicles.hpp @@ -1,53 +1,67 @@ class CfgVehicles { class ACE_Module; - class ACE_ModuleSpectator: ACE_Module { - author = ECSTRING(common,ACETeam); - category = "ACE"; - displayName = CSTRING(Module_DisplayName); - function = QFUNC(moduleSpectator); + class GVAR(moduleSettings): ACE_Module { scope = 2; - isGlobal = 1; + displayName = CSTRING(Settings_DisplayName); icon = PATHTOF(UI\Icon_Module_Spectator_ca.paa); + category = "ACE"; + function = QFUNC(moduleSpectatorSettings); + isGlobal = 1; + author = ECSTRING(common,ACETeam); class Arguments { - class SpectatorEnabled { - displayName = CSTRING(Enabled_DisplayName); - description = CSTRING(Enabled_Description); + class spectatorSystem { + displayName = CSTRING(system_DisplayName); + description = CSTRING(system_Description); typeName = "BOOL"; defaultValue = 0; }; - class SpectatorPlayerSide { - displayName = CSTRING(PlayerSide_DisplayName); - description = CSTRING(PlayerSide_Description); - typeName = "BOOL"; - defaultValue = 0; + class spectatorUnits { + displayName = CSTRING(units_DisplayName); + description = CSTRING(units_Description); + typeName = "NUMBER"; + class values { + class none { + name = "$STR_Special_None"; + value = 0; + default = 1; + }; + class players { + name = CSTRING(units_players); + value = 1; + }; + class all { + name = CSTRING(units_all); + value = 2; + }; + }; }; - class SpectatorAI { - displayName = CSTRING(AI_DisplayName); - description = CSTRING(AI_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class SpectatorTracking { - displayName = CSTRING(Tracking_DisplayName); - description = CSTRING(Tracking_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class SpectatorPos { - displayName = CSTRING(Pos_DisplayName); - description = CSTRING(Pos_Description); - typeName = "BOOL"; - defaultValue = 0; - }; - class SpectatorEnd { - displayName = CSTRING(End_DisplayName); - description = CSTRING(End_Description); - typeName = "BOOL"; - defaultValue = 0; + class spectatorSides { + displayName = CSTRING(sides_DisplayName); + description = CSTRING(sides_Description); + typeName = "NUMBER"; + class values { + class none { + name = "$STR_Special_None"; + value = 0; + default = 1; + }; + class player { + name = CSTRING(sides_player); + value = 1; + }; + class friendly { + name = CSTRING(sides_friendly); + value = 2; + }; + class all { + name = CSTRING(sides_all); + value = 3; + }; + }; }; }; class ModuleDescription { - description = CSTRING(Module_Description); + description = CSTRING(Settings_Description); }; }; }; diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index 7f8b62b294..e1cc553c82 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -1,5 +1,6 @@ class RscButtonMenu; class RscControlsGroupNoScrollbars; +class RscFrame; class RscMapControl; class RscPicture; class RscStructuredText; @@ -65,15 +66,16 @@ class GVAR(interface) { x = COMPASS_X + COMPASS_W * 2; text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture90_ca.paa"; }; - class compassCaret: compassBack { - x = COMPASS_X + COMPASS_W * 0.5 - COMPASS_W / 360; - w = COMPASS_W / 180; - colorBackground[]={1,0,0,1}; + class compassCaret: RscFrame { + x = COMPASS_X + COMPASS_W * 0.5; + y = 0; + w = 0; + h = TOOL_H; + colorText[] = {1,0,0,1}; }; - class compassLeftBlock: compassCaret { + class compassLeftBlock: compassBack { x = 0; w = (safeZoneW - COMPASS_W) * 0.5; - colorBackground[] = {0.1,0.1,0.1,1}; }; class compassRightBlock: compassLeftBlock { x = COMPASS_X + COMPASS_W; @@ -81,7 +83,7 @@ class GVAR(interface) { class compassFrame: compassBack { style = 64; shadow=2; - colorText[]={1,1,1,1}; + colorText[] = {1,1,1,1}; }; }; }; @@ -175,7 +177,7 @@ class GVAR(interface) { h = TOOL_H; sizeEx = TOOL_H; text = CSTRING(RefreshList); - action = QUOTE([allUnits] call FUNC(updateUnits)); + action = QUOTE([] call FUNC(updateUnits)); }; }; }; diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index ca251d3536..e96bbf2c10 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -6,26 +6,6 @@ // Run spectator framework if enabled ["SettingsInitialized", { - if !(GVAR(enabled)) exitWith {}; - - //check if respawn is set up properly - _fail = if (getNumber (missionConfigFile >> "respawn") != 3 && getText (missionConfigFile >> "respawn") != "Base") then {true} else {false}; - if (_fail) exitWith { - _errorMsg = "This mission does not have respawn set up properly. Add 'respawn=3' or 'respawn=""BASE""' to description.ext."; - ["[ACE_Spectator] ERROR", _errorMsg, {}] call EFUNC(common,errorMessage); - diag_log text format ["[ACE_Spectator] ERROR: %1", _errorMsg]; - }; - - // Handle end mission setting - if (GVAR(endMission) && isServer) then { - [{ - if ({(isPlayer _x) && (alive _x) && !(_x getVariable [QGVAR(isSpectator), false])} count allUnits == 0) then { - [["endDeath", false], "BIS_fnc_endMission"] call BIS_fnc_MP; - [_this select 1] call CBA_fnc_removePerFrameHandler; - }; - }, 2] call CBA_fnc_addPerFrameHandler; - }; - if !(hasInterface) exitWith {}; /*if (GVAR(tracking)) then { @@ -33,8 +13,9 @@ [FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler; };*/ - // Add event handlers to correctly enter spectator upon death - player addEventHandler ["Killed", FUNC(handleKilled)]; - player addEventHandler ["Respawn", FUNC(handleRespawn)]; - + if GVAR(system) then { + // Add event handlers to correctly enter spectator upon death + 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 9e71c9bdc5..6b5081c000 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -8,7 +8,7 @@ PREP(handleKilled); PREP(handleMouse); PREP(handleRespawn); PREP(handleTree); -PREP(moduleSpectator); +PREP(moduleSpectatorSettings); PREP(setSpectator); PREP(updateUnits); PREP(updateView); diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 377bce9124..0b2dcdc30c 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -67,7 +67,7 @@ switch (toLower _mode) do { [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; // Populate the unit list - [allUnits] call FUNC(updateUnits); + [] call FUNC(updateUnits); // Create the dialog createDialog QGVAR(interface); diff --git a/addons/spectator/functions/fnc_moduleSpectator.sqf b/addons/spectator/functions/fnc_moduleSpectator.sqf deleted file mode 100644 index 7a85f40fcb..0000000000 --- a/addons/spectator/functions/fnc_moduleSpectator.sqf +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Author: voiper - * Read spectator settings from module - * - * Arguments: - * 0: The module logic - * 1: units - * 2: activated - * - * Return Value: - * None - * - * Public: No - */ - -#include "script_component.hpp" - -PARAMS_3(_logic,_units,_activated); - -if !(_activated) exitWith {}; - -[_logic, QGVAR(enabled), "SpectatorEnabled"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(limitSide), "SpectatorPlayerSide"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(allowAI), "SpectatorAI"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(tracking), "SpectatorTracking"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(modulePos), "SpectatorPos"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(endMission), "SpectatorEnd"] call EFUNC(common,readSettingFromModule); - -if (GVAR(modulePos)) then { - GVAR(startingPos) = getPosATL _logic; - GVAR(startingDir) = getDir _logic; -}; diff --git a/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf b/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf new file mode 100644 index 0000000000..bda2479df9 --- /dev/null +++ b/addons/spectator/functions/fnc_moduleSpectatorSettings.sqf @@ -0,0 +1,27 @@ +/* + * Author: SilentSpike + * Read spectator settings from module + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_logic", "_units", "_activated"]; +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if !(_activated) exitWith {}; + +[_logic, QGVAR(enabledSystem), "spectatorSystem"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(filterUnits), "spectatorUnits"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(filterSides), "spectatorSides"] call EFUNC(common,readSettingFromModule); diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf index 9586e41535..f7c08f7fda 100644 --- a/addons/spectator/functions/fnc_updateUnits.sqf +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -1,11 +1,10 @@ /* * Author: SilentSpike - * Updates the list of units available to spectate via addition/subtraction + * Adds units to spectator whitelist/blacklist and refreshes the filter units * * Arguments: * 0: Units to add to the list - * 1: Add or remove units - * 2: Permanent change (force add/remove) + * 1: Use blacklist * * Return Value: * None @@ -18,39 +17,34 @@ #include "script_component.hpp" -params [["_newUnits",[]],["_append",true,[true]],["_permanent",false,[false]]]; +params [["_newUnits",[],[[]]],["_blacklist",false,[false]]]; -if (_permanent) then { - if (_append) then { - GVAR(unitBlacklist) = GVAR(unitBlacklist) - _newUnits; - GVAR(unitWhitelist) append _newUnits; - } else { +if !(_newUnits isEqualTo []) then { + if (_blacklist) then { GVAR(unitWhitelist) = GVAR(unitWhitelist) - _newUnits; GVAR(unitBlacklist) append _newUnits; + } else { + GVAR(unitBlacklist) = GVAR(unitBlacklist) - _newUnits; + GVAR(unitWhitelist) append _newUnits; }; - _newUnits = []; }; -if (_append) then { - // Append only valid units to the list - { - if ( - (alive _x) && - {(_x isKindOf "CAManBase")} && - {(side _x) in [west,east,resistance,civilian]} && // Side filter - {(isPlayer _x) || GVAR(allowAI)} && // AI restriction - {(simulationEnabled _x) && !isObjectHidden _unit} && - {!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen? - ) then { - GVAR(unitList) pushBack _x; - }; - } forEach _newUnits; -} else { - GVAR(unitList) = GVAR(unitList) - _newUnits; -}; +// Get filter units from setting +_newUnits = [[],allPlayers,allUnits] select GVAR(filterUnits); -// Apply whitelist and blacklist +// Append only valid units to the list +{ + if ( + (alive _x) && + {(_x isKindOf "CAManBase")} && + {(side _x) in [west,east,resistance,civilian]} && // Side filter + {(simulationEnabled _x)} && + {!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen? + ) then { + GVAR(unitList) pushBack _x; + }; +} forEach (_newUnits - GVAR(unitBlacklist)); + +// Apply whitelist GVAR(unitList) append GVAR(unitWhitelist); -GVAR(unitList) = GVAR(unitList) - GVAR(unitBlacklist); - -GVAR(unitList) arrayIntersect GVAR(unitList); +GVAR(unitList) = GVAR(unitList) arrayIntersect GVAR(unitList); diff --git a/addons/spectator/stringtable.xml b/addons/spectator/stringtable.xml index 1e35d3e9d2..2c4e6570ed 100644 --- a/addons/spectator/stringtable.xml +++ b/addons/spectator/stringtable.xml @@ -1,61 +1,46 @@  - - Spectator - Obserwator - Pozorovatel + + Spectator Setings - - Enable Spectator - Aktywuj obserwatora - Povolit pozorovatele + + Configure how the spectator system will operate by default. - - Begin spectating on player death? - Włącz obserwatora po śmierci gracza? - Přepnout do pozorovatele po hráčově smrti? + + Spectator System - - Player Side Only - Tylko strona gracza - Pouze strana hráče + + Enter spectator mode upon respawn. - - Only spectate units belonging to player's side? - Pozwól obserwować jednostki będące tylko po stronie gracza? - Pozorovat pouze jednotky patřící k hráčově straně? + + Spectatable Units - - Spectate AI - Obserwacja AI - Pozorovat AI + + Units automatically made available to spectate. - - Allow spectating of AI units? - Pozwól obserwować jednostki AI? - Umožnit pozorovat AI jednotky? + + Only players - - Track Units - Śledź jednostki - Sledovat jednotky + + All units - - Track units' movements throughout mission? - Śledź ruch jednostek w trakcie misji? - Sledovat pohyby jednotek napříč misí? + + Spectatable Sides - - Start Position - Pozycja startowa - Počáteční pozice + + Sides automatically made available to spectate. - - Use this module as a starting position for spectator camera? - Użyj pozycji modułu jako pozycje startową dla kamery obserwatora? - Použít tento modul jako počáteční pozici pro pozorovací kameru? + + Player side + + Friendly sides + + + All sides + + End Mission Zakończ misję