Enable compass, auto-refresh units, pass display to PFHs

This commit is contained in:
SilentSpike 2015-07-19 02:25:52 +01:00
parent 1ba0bcee95
commit d680789d04
7 changed files with 94 additions and 23 deletions

View File

@ -57,12 +57,12 @@ class GVAR(interface) {
}; };
class compass180_270: compass0_90 { class compass180_270: compass0_90 {
idc = IDC_COMP_180; idc = IDC_COMP_180;
x = COMPASS_W * 1.5; x = 0;
text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture0_ca.paa"; text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture0_ca.paa";
}; };
class compass270_0: compass0_90 { class compass270_0: compass0_90 {
idc = IDC_COMP_270; idc = IDC_COMP_270;
x = COMPASS_W * 2; x = COMPASS_W * -0.5;
text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture90_ca.paa"; text = "A3\ui_f_curator\data\cfgIngameUI\compass\texture90_ca.paa";
}; };
class compassCaret: RscFrame { class compassCaret: RscFrame {
@ -147,14 +147,14 @@ class GVAR(interface) {
class unitTools: RscControlsGroupNoScrollbars { class unitTools: RscControlsGroupNoScrollbars {
idc = IDC_UNIT; idc = IDC_UNIT;
x = safeZoneX; x = safeZoneX;
y = safeZoneY; y = safeZoneY + TOOL_H * 2;
w = TOOL_W * 2; w = TOOL_W * 2;
h = safeZoneH; h = safeZoneH;
class controls { class controls {
class unitTree: RscTree { class unitTree: RscTree {
idc = IDC_UNIT_TREE; idc = IDC_UNIT_TREE;
x = 0; x = 0;
y = TOOL_H * 2; y = 0;
w = TOOL_W * 2; w = TOOL_W * 2;
h = safeZoneH - TOOL_H * 5; h = safeZoneH - TOOL_H * 5;
sizeEx = H_PART(0.8); sizeEx = H_PART(0.8);
@ -170,15 +170,15 @@ class GVAR(interface) {
multiselectEnabled = 0; multiselectEnabled = 0;
onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface)); onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface));
}; };
class unitRefresh: RscButtonMenu { class unitRandom: RscButtonMenu {
x = 0; x = 0;
y = safeZoneH - TOOL_H * 3; y = safeZoneH - TOOL_H * 5;
w = TOOL_W * 2; w = TOOL_W * 2;
h = TOOL_H; h = TOOL_H;
sizeEx = TOOL_H; sizeEx = TOOL_H;
colorBackground[] = {COL_FORE_D}; colorBackground[] = {COL_FORE_D};
text = CSTRING(RefreshList); text = CSTRING(RandomUnit);
action = QUOTE([] call FUNC(updateUnits)); action = QUOTE([nil,objNull] call FUNC(updateCamera));
}; };
}; };
}; };

View File

@ -3,6 +3,7 @@
ADDON = false; ADDON = false;
PREP(handleCamera); PREP(handleCamera);
PREP(handleCompass);
PREP(handleInterface); PREP(handleInterface);
PREP(handleKilled); PREP(handleKilled);
PREP(handleMouse); PREP(handleMouse);

View File

@ -3,7 +3,8 @@
* Handles free camera manipulation according to input * Handles free camera manipulation according to input
* *
* Arguments: * Arguments:
* None <NIL> * 0: Parameters <ANY>
* 1: PFH handle <NUMBER>
* *
* Return Value: * Return Value:
* None <NIL> * None <NIL>

View File

@ -0,0 +1,69 @@
/*
* Author: SilentSpike, voiper
* Handles the spectator UI compass
*
* Arguments:
* 0: Parameters <ANY>
* 1: PFH handle <NUMBER>
*
* Return Value:
* None <NIL>
*
* Example:
* [ace_spectator_fnc_handleCompass, 0] call CBA_fnc_addPerFrameHandler;
*
* Public: No
*/
#include "script_component.hpp"
params ["_display"];
// Kill PFH when display is closed
if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
private ["_compass","_NE","_ES","_SW","_WN","_compassW","_degree","_heading","_offset","_positions","_sequence"];
_compass = _display displayCtrl IDC_COMP;
_NE = _compass controlsGroupCtrl IDC_COMP_0;
_ES = _compass controlsGroupCtrl IDC_COMP_90;
_SW = _compass controlsGroupCtrl IDC_COMP_180;
_WN = _compass controlsGroupCtrl IDC_COMP_270;
_compassW = (ctrlPosition _compass) select 2;
_degree = _compassW / 180;
// Get direction of screen rather than object (accounts for unit freelook)
_heading = (positionCameraToWorld [0,0,1]) vectorDiff (positionCameraToWorld [0,0,0]);
_heading = (((_heading select 0) atan2 (_heading select 1)) + 360) % 360;
_offset = -(_heading % 90) * _degree;
_positions = [
[_compassW * -0.5 + _offset, 0],
[_offset, 0],
[_compassW * 0.5 + _offset, 0],
[_compassW + _offset, 0]
];
systemChat str(_heading);
_sequence = if (_heading < 90) then {
[_SW, _WN, _NE, _ES]
} else {
if (_heading < 180) then {
[_WN, _NE, _ES, _SW]
} else {
if (_heading < 270) then {
[_NE, _ES, _SW, _WN]
} else {
[_ES, _SW, _WN, _NE]
};
};
};
{
_x ctrlSetPosition (_positions select _forEachIndex);
_x ctrlCommit 0;
} forEach _sequence;

View File

@ -49,9 +49,6 @@ switch (toLower _mode) do {
GVAR(camera) camSetFOV GVAR(camFOV); GVAR(camera) camSetFOV GVAR(camFOV);
// Populate the unit list
[] call FUNC(updateUnits);
// Create the dialog // Create the dialog
createDialog QGVAR(interface); createDialog QGVAR(interface);
@ -120,7 +117,10 @@ switch (toLower _mode) do {
(_display displayCtrl IDC_TOOL_VIEW) ctrlSetText (["FREE","FIRST","THIRD"] select GVAR(camMode)); (_display displayCtrl IDC_TOOL_VIEW) ctrlSetText (["FREE","FIRST","THIRD"] select GVAR(camMode));
// Keep unit tree up to date // Keep unit tree up to date
[FUNC(handleUnits), 10] call CBA_fnc_addPerFrameHandler; [FUNC(handleUnits), 20, _display] call CBA_fnc_addPerFrameHandler;
// Handle the compass heading
[FUNC(handleCompass), 0, _display] call CBA_fnc_addPerFrameHandler;
// Hacky way to enable keybindings // Hacky way to enable keybindings
//_display displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}]; //_display displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];

View File

@ -1,10 +1,11 @@
/* /*
* Author: SilentSpike * Author: SilentSpike
* Maintains the unit list and updates the unit tree accordingly * Maintains the spectatable unit list and updates the unit tree accordingly
* Also updates current camera unit when status changes * Also updates current camera unit when status changes
* *
* Arguments: * Arguments:
* None <NIL> * 0: Parameters <ANY>
* 1: PFH handle <NUMBER>
* *
* Return Value: * Return Value:
* None <NIL> * None <NIL>
@ -17,23 +18,22 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_display"];
// Kill PFH when display is closed // Kill PFH when display is closed
if (isNull (GETUVAR(GVAR(display),displayNull))) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; }; if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
// Remove all dead and null units from the list // Remove all dead and null units from the list
GVAR(unitList) = GVAR(unitList) - allDead; [] call FUNC(updateUnits);
GVAR(unitList) = GVAR(unitList) - [objNull];
// Camera shouldn't stay on unit that isn't in the list // Camera shouldn't stay on unit that isn't in the list
if !(GVAR(camUnit) in GVAR(unitList)) then { if !(GVAR(camUnit) in GVAR(unitList)) then {
[0,objNull] call FUNC(updateCamera); [0,objNull] call FUNC(updateCamera);
}; };
private ["_display","_ctrl","_curSelData","_cachedGrps","_grp","_node","_side","_index"]; private ["_ctrl","_curSelData","_cachedGrps","_grp","_node","_side","_index"];
// Fetch tree // Fetch tree
disableSerialization;
_display = GETUVAR(GVAR(display),displayNull);
_ctrl = (_display displayCtrl IDC_UNIT) controlsGroupCtrl IDC_UNIT_TREE; _ctrl = (_display displayCtrl IDC_UNIT) controlsGroupCtrl IDC_UNIT_TREE;
// Cache current selection // Cache current selection

View File

@ -56,8 +56,8 @@
<Key ID="STR_ACE_Spectator_HelpTitle"> <Key ID="STR_ACE_Spectator_HelpTitle">
<English>Spectator Controls</English> <English>Spectator Controls</English>
</Key> </Key>
<Key ID="STR_ACE_Spectator_RefreshList"> <Key ID="STR_ACE_Spectator_RandomUnit">
<English>Refresh Units</English> <English>Random Unit</English>
</Key> </Key>
<!-- Keybinds --> <!-- Keybinds -->