Updating ace settings

This commit is contained in:
SilentSpike 2015-07-17 16:02:38 +01:00
parent 6de18416bc
commit cfcb9fedb6
10 changed files with 159 additions and 194 deletions

View File

@ -1,26 +1,20 @@
class ACE_Settings { class ACE_Settings {
class GVAR(enabled) { class GVAR(enabledSystem) {
value = 0;
typeName = "BOOL"; typeName = "BOOL";
value = 0;
}; };
class GVAR(limitSide) { class GVAR(filterUnits) {
typeName = "SCALAR";
value = 0; value = 0;
typeName = "BOOL"; values[] = {"$STR_Special_None", CSTRING(units_players), CSTRING(units_all)};
}; };
class GVAR(allowAI) { class GVAR(filterSides) {
typeName = "SCALAR";
value = 0; value = 0;
typeName = "BOOL"; values[] = {"$STR_Special_None", CSTRING(sides_player), CSTRING(sides_friendly), CSTRING(sides_all)};
};
class GVAR(tracking) {
value = 0;
typeName = "BOOL";
};
class GVAR(modulePos) {
value = 0;
typeName = "BOOL";
}; };
class GVAR(endMission) { class GVAR(endMission) {
value = 0;
typeName = "BOOL"; typeName = "BOOL";
value = 0;
}; };
}; };

View File

@ -1,53 +1,67 @@
class CfgVehicles { class CfgVehicles {
class ACE_Module; class ACE_Module;
class ACE_ModuleSpectator: ACE_Module { class GVAR(moduleSettings): ACE_Module {
author = ECSTRING(common,ACETeam);
category = "ACE";
displayName = CSTRING(Module_DisplayName);
function = QFUNC(moduleSpectator);
scope = 2; scope = 2;
isGlobal = 1; displayName = CSTRING(Settings_DisplayName);
icon = PATHTOF(UI\Icon_Module_Spectator_ca.paa); icon = PATHTOF(UI\Icon_Module_Spectator_ca.paa);
category = "ACE";
function = QFUNC(moduleSpectatorSettings);
isGlobal = 1;
author = ECSTRING(common,ACETeam);
class Arguments { class Arguments {
class SpectatorEnabled { class spectatorSystem {
displayName = CSTRING(Enabled_DisplayName); displayName = CSTRING(system_DisplayName);
description = CSTRING(Enabled_Description); description = CSTRING(system_Description);
typeName = "BOOL"; typeName = "BOOL";
defaultValue = 0; defaultValue = 0;
}; };
class SpectatorPlayerSide { class spectatorUnits {
displayName = CSTRING(PlayerSide_DisplayName); displayName = CSTRING(units_DisplayName);
description = CSTRING(PlayerSide_Description); description = CSTRING(units_Description);
typeName = "BOOL"; typeName = "NUMBER";
defaultValue = 0; 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 { class spectatorSides {
displayName = CSTRING(AI_DisplayName); displayName = CSTRING(sides_DisplayName);
description = CSTRING(AI_Description); description = CSTRING(sides_Description);
typeName = "BOOL"; typeName = "NUMBER";
defaultValue = 0; class values {
}; class none {
class SpectatorTracking { name = "$STR_Special_None";
displayName = CSTRING(Tracking_DisplayName); value = 0;
description = CSTRING(Tracking_Description); default = 1;
typeName = "BOOL"; };
defaultValue = 0; class player {
}; name = CSTRING(sides_player);
class SpectatorPos { value = 1;
displayName = CSTRING(Pos_DisplayName); };
description = CSTRING(Pos_Description); class friendly {
typeName = "BOOL"; name = CSTRING(sides_friendly);
defaultValue = 0; value = 2;
}; };
class SpectatorEnd { class all {
displayName = CSTRING(End_DisplayName); name = CSTRING(sides_all);
description = CSTRING(End_Description); value = 3;
typeName = "BOOL"; };
defaultValue = 0; };
}; };
}; };
class ModuleDescription { class ModuleDescription {
description = CSTRING(Module_Description); description = CSTRING(Settings_Description);
}; };
}; };
}; };

View File

@ -1,5 +1,6 @@
class RscButtonMenu; class RscButtonMenu;
class RscControlsGroupNoScrollbars; class RscControlsGroupNoScrollbars;
class RscFrame;
class RscMapControl; class RscMapControl;
class RscPicture; class RscPicture;
class RscStructuredText; class RscStructuredText;
@ -65,15 +66,16 @@ class GVAR(interface) {
x = COMPASS_X + COMPASS_W * 2; x = COMPASS_X + COMPASS_W * 2;
text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture90_ca.paa"; text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture90_ca.paa";
}; };
class compassCaret: compassBack { class compassCaret: RscFrame {
x = COMPASS_X + COMPASS_W * 0.5 - COMPASS_W / 360; x = COMPASS_X + COMPASS_W * 0.5;
w = COMPASS_W / 180; y = 0;
colorBackground[]={1,0,0,1}; w = 0;
h = TOOL_H;
colorText[] = {1,0,0,1};
}; };
class compassLeftBlock: compassCaret { class compassLeftBlock: compassBack {
x = 0; x = 0;
w = (safeZoneW - COMPASS_W) * 0.5; w = (safeZoneW - COMPASS_W) * 0.5;
colorBackground[] = {0.1,0.1,0.1,1};
}; };
class compassRightBlock: compassLeftBlock { class compassRightBlock: compassLeftBlock {
x = COMPASS_X + COMPASS_W; x = COMPASS_X + COMPASS_W;
@ -81,7 +83,7 @@ class GVAR(interface) {
class compassFrame: compassBack { class compassFrame: compassBack {
style = 64; style = 64;
shadow=2; shadow=2;
colorText[]={1,1,1,1}; colorText[] = {1,1,1,1};
}; };
}; };
}; };
@ -175,7 +177,7 @@ class GVAR(interface) {
h = TOOL_H; h = TOOL_H;
sizeEx = TOOL_H; sizeEx = TOOL_H;
text = CSTRING(RefreshList); text = CSTRING(RefreshList);
action = QUOTE([allUnits] call FUNC(updateUnits)); action = QUOTE([] call FUNC(updateUnits));
}; };
}; };
}; };

View File

@ -6,26 +6,6 @@
// Run spectator framework if enabled // Run spectator framework if enabled
["SettingsInitialized", { ["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 !(hasInterface) exitWith {};
/*if (GVAR(tracking)) then { /*if (GVAR(tracking)) then {
@ -33,8 +13,9 @@
[FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler; [FUNC(trackUnits), 20] call CBA_fnc_addPerFrameHandler;
};*/ };*/
// Add event handlers to correctly enter spectator upon death if GVAR(system) then {
player addEventHandler ["Killed", FUNC(handleKilled)]; // Add event handlers to correctly enter spectator upon death
player addEventHandler ["Respawn", FUNC(handleRespawn)]; player addEventHandler ["Killed", FUNC(handleKilled)];
player addEventHandler ["Respawn", FUNC(handleRespawn)];
};
}] call EFUNC(common,addEventHandler); }] call EFUNC(common,addEventHandler);

View File

@ -8,7 +8,7 @@ PREP(handleKilled);
PREP(handleMouse); PREP(handleMouse);
PREP(handleRespawn); PREP(handleRespawn);
PREP(handleTree); PREP(handleTree);
PREP(moduleSpectator); PREP(moduleSpectatorSettings);
PREP(setSpectator); PREP(setSpectator);
PREP(updateUnits); PREP(updateUnits);
PREP(updateView); PREP(updateView);

View File

@ -67,7 +67,7 @@ switch (toLower _mode) do {
[FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler; [FUNC(handleCamera), 0] call CBA_fnc_addPerFrameHandler;
// Populate the unit list // Populate the unit list
[allUnits] call FUNC(updateUnits); [] call FUNC(updateUnits);
// Create the dialog // Create the dialog
createDialog QGVAR(interface); createDialog QGVAR(interface);

View File

@ -1,32 +0,0 @@
/*
* Author: voiper
* Read spectator settings from module
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* None <NIL>
*
* 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;
};

View File

@ -0,0 +1,27 @@
/*
* Author: SilentSpike
* Read spectator settings from module
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* None <NIL>
*
* 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);

View File

@ -1,11 +1,10 @@
/* /*
* Author: SilentSpike * 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: * Arguments:
* 0: Units to add to the list <ARRAY> * 0: Units to add to the list <ARRAY>
* 1: Add or remove units <BOOL> <OPTIONAL> * 1: Use blacklist <BOOL> <OPTIONAL>
* 2: Permanent change (force add/remove) <BOOL> <OPTIONAL>
* *
* Return Value: * Return Value:
* None <NIL> * None <NIL>
@ -18,39 +17,34 @@
#include "script_component.hpp" #include "script_component.hpp"
params [["_newUnits",[]],["_append",true,[true]],["_permanent",false,[false]]]; params [["_newUnits",[],[[]]],["_blacklist",false,[false]]];
if (_permanent) then { if !(_newUnits isEqualTo []) then {
if (_append) then { if (_blacklist) then {
GVAR(unitBlacklist) = GVAR(unitBlacklist) - _newUnits;
GVAR(unitWhitelist) append _newUnits;
} else {
GVAR(unitWhitelist) = GVAR(unitWhitelist) - _newUnits; GVAR(unitWhitelist) = GVAR(unitWhitelist) - _newUnits;
GVAR(unitBlacklist) append _newUnits; GVAR(unitBlacklist) append _newUnits;
} else {
GVAR(unitBlacklist) = GVAR(unitBlacklist) - _newUnits;
GVAR(unitWhitelist) append _newUnits;
}; };
_newUnits = [];
}; };
if (_append) then { // Get filter units from setting
// Append only valid units to the list _newUnits = [[],allPlayers,allUnits] select GVAR(filterUnits);
{
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;
};
// 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) append GVAR(unitWhitelist);
GVAR(unitList) = GVAR(unitList) - GVAR(unitBlacklist); GVAR(unitList) = GVAR(unitList) arrayIntersect GVAR(unitList);
GVAR(unitList) arrayIntersect GVAR(unitList);

View File

@ -1,61 +1,46 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project name="ACE"> <Project name="ACE">
<Package name="Spectator"> <Package name="Spectator">
<Key ID="STR_ACE_Spectator_Module_DisplayName"> <Key ID="STR_ACE_Spectator_Settings_DisplayName">
<English>Spectator</English> <English>Spectator Setings</English>
<Polish>Obserwator</Polish>
<Czech>Pozorovatel</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Enabled_DisplayName"> <Key ID="STR_ACE_Spectator_Settings_Descripton">
<English>Enable Spectator</English> <English>Configure how the spectator system will operate by default.</English>
<Polish>Aktywuj obserwatora</Polish>
<Czech>Povolit pozorovatele</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Enabled_Description"> <Key ID="STR_ACE_Spectator_system_DisplayName">
<English>Begin spectating on player death?</English> <English>Spectator System</English>
<Polish>Włącz obserwatora po śmierci gracza?</Polish>
<Czech>Přepnout do pozorovatele po hráčově smrti?</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_PlayerSide_DisplayName"> <Key ID="STR_ACE_Spectator_system_Description">
<English>Player Side Only</English> <English>Enter spectator mode upon respawn.</English>
<Polish>Tylko strona gracza</Polish>
<Czech>Pouze strana hráče</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_PlayerSide_Description"> <Key ID="STR_ACE_Spectator_units_DisplayName">
<English>Only spectate units belonging to player's side?</English> <English>Spectatable Units</English>
<Polish>Pozwól obserwować jednostki będące tylko po stronie gracza?</Polish>
<Czech>Pozorovat pouze jednotky patřící k hráčově straně?</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_AI_DisplayName"> <Key ID="STR_ACE_Spectator_units_Description">
<English>Spectate AI</English> <English>Units automatically made available to spectate.</English>
<Polish>Obserwacja AI</Polish>
<Czech>Pozorovat AI</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_AI_Description"> <Key ID="STR_ACE_Spectator_units_players">
<English>Allow spectating of AI units?</English> <English>Only players</English>
<Polish>Pozwól obserwować jednostki AI?</Polish>
<Czech>Umožnit pozorovat AI jednotky?</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Tracking_DisplayName"> <Key ID="STR_ACE_Spectator_units_all">
<English>Track Units</English> <English>All units</English>
<Polish>Śledź jednostki</Polish>
<Czech>Sledovat jednotky</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Tracking_Description"> <Key ID="STR_ACE_Spectator_sides_DisplayName">
<English>Track units' movements throughout mission?</English> <English>Spectatable Sides</English>
<Polish>Śledź ruch jednostek w trakcie misji?</Polish>
<Czech>Sledovat pohyby jednotek napříč misí?</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Pos_DisplayName"> <Key ID="STR_ACE_Spectator_sides_Description">
<English>Start Position</English> <English>Sides automatically made available to spectate.</English>
<Polish>Pozycja startowa</Polish>
<Czech>Počáteční pozice</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_Pos_Description"> <Key ID="STR_ACE_Spectator_sides_player">
<English>Use this module as a starting position for spectator camera?</English> <English>Player side</English>
<Polish>Użyj pozycji modułu jako pozycje startową dla kamery obserwatora?</Polish>
<Czech>Použít tento modul jako počáteční pozici pro pozorovací kameru?</Czech>
</Key> </Key>
<Key ID="STR_ACE_Spectator_sides_friendly">
<English>Friendly sides</English>
</Key>
<Key ID="STR_ACE_Spectator_sides_all">
<English>All sides</English>
</Key>
<Key ID="STR_ACE_Spectator_End_DisplayName"> <Key ID="STR_ACE_Spectator_End_DisplayName">
<English>End Mission</English> <English>End Mission</English>
<Polish>Zakończ misję</Polish> <Polish>Zakończ misję</Polish>