-
Notifications
You must be signed in to change notification settings - Fork 749
Zeus - Add spectator module #6202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a4d2a4e
Add Spectator module
mharis001 82cd38c
Use already existing stringtable entries
mharis001 35e3c0e
Stringtable updates and QQGVAR
mharis001 59b7628
Merge branch 'master' into zeus-spectator
654wak654 b5ee071
Merge branch 'master' into pr/6202
johnb432 e696009
Update fnc_ui_spectator.sqf
johnb432 bc62c37
Update fnc_moduleSpectator.sqf
johnb432 552bdae
More cleanup and applied suggestions
johnb432 1d74be4
Make HEMTT stop complaining
johnb432 de185d6
Removed macros
johnb432 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: mharis001 | ||
| * Zeus module function to make the local player an ACE Spectator. | ||
| * | ||
| * Arguments: | ||
| * 0: Force interface <BOOL> | ||
| * 1: Hide player <BOOL> | ||
| * 2: Sides available to spectate <ARRAY> | ||
| * 3: Camera modes available <ARRAY> | ||
| * 4: Vision modes available <ARRAY> | ||
| * | ||
| * Return Value: | ||
| * None | ||
| * | ||
| * Example: | ||
| * [true, true, [west], [0, 1, 2], [-2, -1, 0, 1]] call ace_zeus_fnc_moduleSpectator | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| params ["_force", "_hide", "_sides", "_modes", "_visions"]; | ||
| TRACE_1("params",_this); | ||
|
|
||
| // Update sides available to spectate | ||
| [_sides, [west, east, independent, civilian] - _sides] call EFUNC(spectator,updateSides); | ||
|
|
||
| // Update available camera modes | ||
| [_modes, [0, 1, 2] - _modes] call EFUNC(spectator,updateCameraModes); | ||
|
|
||
| // Update available vision modes | ||
| [_visions, [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] - _visions] call EFUNC(spectator,updateVisionModes); | ||
|
|
||
| // Make unit spectator (close Zeus camera if open) | ||
| if (!isNull curatorCamera) then { | ||
| (findDisplay 312) closeDisplay 2; | ||
| }; | ||
|
|
||
| [true, _force, _hide] call EFUNC(spectator,setSpectator); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,265 @@ | ||
| #include "..\script_component.hpp" | ||
| /* | ||
| * Author: mharis001 | ||
| * Initializes the "Spectator" Zeus module display. | ||
| * | ||
| * Arguments: | ||
| * 0: spectator controls group <CONTROL> | ||
| * | ||
| * Return Value: | ||
| * None | ||
| * | ||
| * Example: | ||
| * [CONTROL] call ace_zeus_fnc_ui_spectator | ||
| * | ||
| * Public: No | ||
| */ | ||
|
|
||
| #define SIDE_IDCs [92540, 92541, 92542, 92543] | ||
| #define CAMERA_IDCs [92550, 92551, 92552] | ||
| #define VISION_IDCs [92558, 92559, 92560, 92561] | ||
|
|
||
| params ["_control"]; | ||
|
|
||
| private _display = ctrlParent _control; | ||
| private _ctrlButtonOK = _display displayCtrl 1; // IDC_OK | ||
| private _logic = missionNamespace getVariable ["BIS_fnc_initCuratorAttributes_target", objNull]; | ||
| TRACE_1("Logic Object",_logic); | ||
|
|
||
| _control ctrlRemoveAllEventHandlers "SetFocus"; | ||
|
|
||
| // Validate module target | ||
| private _unit = attachedTo _logic; | ||
| TRACE_1("Unit",_unit); | ||
|
|
||
| scopeName "Main"; | ||
| private _fnc_errorAndClose = { | ||
| params ["_msg"]; | ||
| _display closeDisplay 0; | ||
| deleteVehicle _logic; | ||
| [_msg] call FUNC(showMessage); | ||
| breakOut "Main"; | ||
| }; | ||
|
|
||
| switch (false) do { | ||
| case (["ace_spectator"] call EFUNC(common,isModLoaded)): { | ||
| [LSTRING(RequiresAddon)] call _fnc_errorAndClose; | ||
| }; | ||
| case (!isNull _unit): { | ||
| [LSTRING(NothingSelected)] call _fnc_errorAndClose; | ||
| }; | ||
| case (_unit isKindOf "CAManBase"): { | ||
| [LSTRING(OnlyInfantry)] call _fnc_errorAndClose; | ||
| }; | ||
| case (alive _unit): { | ||
| [LSTRING(OnlyAlive)] call _fnc_errorAndClose; | ||
| }; | ||
| case ([_unit, true] call EFUNC(common,isPlayer)): { | ||
| [LSTRING(OnlyPlayers)] call _fnc_errorAndClose; | ||
| }; | ||
| }; | ||
|
|
||
| // Specific onLoad stuff | ||
| private _side = side _unit; | ||
|
|
||
| // Spectate sides | ||
| private _fnc_onSideSelection = { | ||
| params ["_ctrl"]; | ||
|
|
||
| private _display = ctrlParent _ctrl; | ||
| if (isNull _display) exitWith {}; | ||
|
|
||
| private _color = _ctrl getVariable "color"; | ||
| private _scale = 1; | ||
|
|
||
| private _sides = _display getVariable [QGVAR(spectateSides), []]; | ||
| private _selectedSide = (ctrlIDC _ctrl) - 92540; | ||
|
|
||
| // Add or remove from spectatable sides and update color and scale | ||
| if (_selectedSide in _sides) then { | ||
| _display setVariable [QGVAR(spectateSides), _sides - [_selectedSide]]; | ||
| _color set [3, 0.5]; | ||
| } else { | ||
| _display setVariable [QGVAR(spectateSides), _sides + [_selectedSide]]; | ||
| _color set [3, 1]; | ||
| _scale = 1.2; | ||
| }; | ||
|
|
||
| _ctrl ctrlSetTextColor _color; | ||
| [_ctrl, _scale, 0.1] call BIS_fnc_ctrlSetScale; | ||
| }; | ||
|
|
||
| // Use the unit's side as default | ||
| private _activeSide = [east, west, independent, civilian] find _side; | ||
|
|
||
| // Handle sides other than default four (sideEnemy) | ||
| if (_activeSide != -1) then { | ||
| _display setVariable [QGVAR(spectateSides), [_activeSide]]; | ||
| }; | ||
|
|
||
| { | ||
| private _ctrl = _display displayCtrl _x; | ||
| private _side = _x - 92540; | ||
| private _color = [_side] call BIS_fnc_sideColor; | ||
| _ctrl setVariable ["color", _color]; | ||
| _ctrl ctrlSetActiveColor _color; | ||
| _color set [3, 0.5]; | ||
|
|
||
| if (_side == _activeSide) then { | ||
| [_ctrl, 1.2, 0] call BIS_fnc_ctrlSetScale; | ||
| _color set [3, 1]; | ||
| }; | ||
|
|
||
| _ctrl ctrlSetTextColor _color; | ||
|
|
||
| _ctrl ctrlAddEventHandler ["ButtonClick", _fnc_onSideSelection]; | ||
| } forEach SIDE_IDCs; | ||
|
|
||
| // Camera modes | ||
| private _fnc_onModesSelection = { | ||
| params ["_ctrl"]; | ||
|
|
||
| private _display = ctrlParent _ctrl; | ||
| if (isNull _display) exitWith {}; | ||
|
|
||
| private _color = [1, 1, 1, 0.5]; | ||
| private _scale = 1; | ||
|
|
||
| private _modes = _display getVariable [QGVAR(cameraModes), []]; | ||
| private _selectedMode = (ctrlIDC _ctrl) - 92550; | ||
|
|
||
| // Add or remove from camera modes and update color and scale | ||
| if (_selectedMode in _modes) then { | ||
| _display setVariable [QGVAR(cameraModes), _modes - [_selectedMode]]; | ||
| } else { | ||
| _display setVariable [QGVAR(cameraModes), _modes + [_selectedMode]]; | ||
| _color set [3, 1]; | ||
| _scale = 1.2; | ||
| }; | ||
|
|
||
| _ctrl ctrlSetTextColor _color; | ||
| [_ctrl, _scale, 0.1] call BIS_fnc_ctrlSetScale; | ||
| }; | ||
|
|
||
| // Use setting as default since global variable will change | ||
| private _availableModes = [[0, 1, 2], [1, 2], [0], [1], [2]] select EGVAR(spectator,restrictModes); | ||
| _display setVariable [QGVAR(cameraModes), _availableModes]; | ||
|
|
||
| { | ||
| private _ctrl = _display displayCtrl _x; | ||
| private _color = [1, 1, 1, 0.5]; | ||
|
|
||
| if ((_x - 92550) in _availableModes) then { | ||
| [_ctrl, 1.2, 0] call BIS_fnc_ctrlSetScale; | ||
| _color set [3, 1]; | ||
| }; | ||
|
|
||
| _ctrl ctrlSetTextColor _color; | ||
|
|
||
| _ctrl ctrlAddEventHandler ["ButtonClick", _fnc_onModesSelection]; | ||
| } forEach CAMERA_IDCs; | ||
|
|
||
| // Vision Modes | ||
| private _fnc_onVisionSelection = { | ||
| params ["_ctrl", "_state"]; | ||
|
|
||
| private _display = ctrlParent _ctrl; | ||
| if (isNull _display) exitwith {}; | ||
|
|
||
| // Convert to boolean since EH returns state as 0 or 1 | ||
| private _state = [false, true] select _state; | ||
|
|
||
| private _visions = _display getVariable [QGVAR(visionModes), []]; | ||
| private _selectedVision = (ctrlIDC _ctrl) - 92560; | ||
|
|
||
| // Add or remove from vision modes | ||
| if (_state) then { | ||
| _display setVariable [QGVAR(visionModes), _visions + [_selectedVision]]; | ||
| } else { | ||
| _display setVariable [QGVAR(visionModes), _visions - [_selectedVision]]; | ||
| }; | ||
|
|
||
| // Handle all checked/unchecked | ||
| private _allCheckboxes = VISION_IDCs apply {cbChecked (_display displayCtrl _x)}; | ||
|
|
||
| if (_allCheckboxes isEqualTo [_state, _state, _state, _state]) then { | ||
| (_display displayCtrl 92557) cbSetChecked _state; | ||
| }; | ||
| }; | ||
|
|
||
| // Use setting as default since global variable will change | ||
| private _availableVisions = [[-2,-1,0,1], [-2,-1], [-2,0,1], [-2]] select EGVAR(spectator,restrictVisions); | ||
| _display setVariable [QGVAR(visionModes), _availableVisions]; | ||
|
|
||
| { | ||
| private _ctrl = _display displayCtrl _x; | ||
|
|
||
| if ((_x - 92560) in _availableVisions) then { | ||
| _ctrl cbSetChecked true; | ||
| }; | ||
|
|
||
| _ctrl ctrlAddEventHandler ["CheckedChanged", _fnc_onVisionSelection]; | ||
| } forEach VISION_IDCs; | ||
|
|
||
| // Init all visions checkbox | ||
| private _fnc_onVisionsAll = { | ||
| params ["_ctrl", "_state"]; | ||
|
|
||
| private _display = ctrlParent _ctrl; | ||
| if (isNull _display) exitWith {}; | ||
|
|
||
| // Convert to boolean since EH returns state as 0 or 1 | ||
| _state = _state == 1; | ||
|
|
||
| // Set state of all checkboxes | ||
| { | ||
| (_display displayCtrl _x) cbSetChecked _state; | ||
| } forEach VISION_IDCs; | ||
|
|
||
| // Store new visions mode setting | ||
| private _setting = [[], [-2, -1, 0, 1]] select _state; | ||
| _display setVariable [QGVAR(visionModes), _setting]; | ||
| }; | ||
|
|
||
| private _allCheckbox = _display displayCtrl 92557; | ||
|
|
||
| // Set to checked by default if setting is all vision modes | ||
| if (_availableVisions isEqualTo [-2, -1, 0, 1]) then { | ||
| _allCheckbox cbSetChecked true; | ||
| }; | ||
|
|
||
| _allCheckbox ctrlAddEventHandler ["CheckedChanged", _fnc_onVisionsAll]; | ||
|
|
||
| // Confirm and Cancel | ||
| private _fnc_onUnload = { | ||
| private _logic = missionNamespace getVariable ["BIS_fnc_initCuratorAttributes_target", objNull]; | ||
| if (isNull _logic) exitWith {}; | ||
|
|
||
| deleteVehicle _logic; | ||
| }; | ||
|
|
||
| private _fnc_onConfirm = { | ||
| params [["_ctrlButtonOK", controlNull, [controlNull]]]; | ||
|
|
||
| private _display = ctrlParent _ctrlButtonOK; | ||
| if (isNull _display) exitWith {}; | ||
|
|
||
| private _logic = missionNamespace getVariable ["BIS_fnc_initCuratorAttributes_target", objNull]; | ||
| if (isNull _logic) exitWith {}; | ||
|
|
||
| private _unit = attachedTo _logic; | ||
| if (isNull _unit) exitWith {}; | ||
|
|
||
| private _force = lbCurSel (_display displayCtrl 92531) > 0; | ||
| private _hide = lbCurSel (_display displayCtrl 92532) > 0; | ||
| private _sides = (_display getVariable [QGVAR(spectateSides), []]) apply {_x call BIS_fnc_sideType}; | ||
| private _modes = _display getVariable [QGVAR(cameraModes), []]; | ||
| private _visions = _display getVariable [QGVAR(visionModes), []]; | ||
|
|
||
| [QGVAR(moduleSpectator), [_force, _hide, _sides, _modes, _visions], _unit] call CBA_fnc_targetEvent; | ||
|
|
||
| deleteVehicle _logic; | ||
| }; | ||
|
|
||
| _display displayAddEventHandler ["Unload", _fnc_onUnload]; | ||
| _ctrlButtonOK ctrlAddEventHandler ["ButtonClick", _fnc_onConfirm]; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.