Function cleanup

This commit is contained in:
SilentSpike 2015-07-18 18:46:46 +01:00
parent f7cf983e92
commit 7091ac21e9
9 changed files with 62 additions and 44 deletions

View File

@ -17,7 +17,7 @@ PREP(updateUnits);
// Permanent variables
GVAR(camMode) = 0;
GVAR(camPan) = 0;
GVAR(camPos) = getPos cameraOn;
GVAR(camPos) = [worldSize,worldSize,0];
GVAR(camUnit) = objNull;
GVAR(showComp) = true;

View File

@ -19,6 +19,8 @@
// 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"];
_oldPos = getPosASL GVAR(camera);
_mX = 0;
_mY = 0;

View File

@ -17,10 +17,7 @@
#include "script_component.hpp"
private ["_mode","_args"];
_mode = _this select 0;
_args = if (count _this > 1) then {_this select 1} else {[]};
params ["_mode",["_args",[]]];
switch (toLower _mode) do {
// Safely open/close the interface
@ -92,10 +89,9 @@ switch (toLower _mode) do {
GVAR(gunCam) = nil;
// Cleanup display variables
GVAR(ctrlKey) = nil;
GVAR(mouse) = nil;
GVAR(mouseDelta) = nil;
GVAR(mousePos) = nil;
GVAR(mousePosOld) = nil;
// Reset nametag settings
if (["ace_nametags"] call EFUNC(common,isModLoaded)) then {
@ -106,12 +102,11 @@ switch (toLower _mode) do {
};
// Dialog events
case "onload": {
with uiNamespace do {
GVAR(display) = _args select 0;
};
_args params ["_display"];
// Initalize the display
_display = _args select 0;
with uiNamespace do {
GVAR(display) = _display;
};
// Always show interface and hide map upon opening
GVAR(showInterface) = true;
@ -140,8 +135,7 @@ switch (toLower _mode) do {
};
// Mouse events
case "onmousebuttondown": {
private ["_button"];
_button = _args select 1;
_args params ["_ctrl","_button"];
GVAR(mouse) set [_button,true];
// Detect right click
@ -152,13 +146,12 @@ switch (toLower _mode) do {
};
};
case "onmousebuttonup": {
private ["_button"];
_button = _args select 1;
_args params ["_ctrl","_button"];
GVAR(mouse) set [_button,false];
};
case "onmousezchanged": {
private ["_zChange"];
_zChange = _args select 1;
_args params ["_ctrl","_zChange"];
// Scroll to zoom in 3rd person, modifier for FOV
if (GVAR(ctrlKey)) then {
@ -168,20 +161,13 @@ switch (toLower _mode) do {
};
};
case "onmousemoving": {
private ["_x","_y"];
_x = _args select 1;
_y = _args select 2;
_args params ["_ctrl","_x","_y"];
[_x,_y] call FUNC(handleMouse);
};
// Keyboard events
case "onkeydown": {
private ["_display","_dik","_shift","_ctrl","_alt"];
_display = _args select 0;
_dik = _args select 1;
_shift = _args select 2;
_ctrl = _args select 3;
_alt = _args select 4;
_args params ["_display","_dik","_shift","_ctrl","_alt"];
switch (_dik) do {
case 1: { // Esc
@ -253,11 +239,7 @@ switch (toLower _mode) do {
true
};
case "onkeyup": {
private ["_dik","_shift","_ctrl","_alt"];
_dik = _args select 1;
_shift = _args select 2;
_ctrl = _args select 3;
_alt = _args select 4;
_args params ["_display","_dik","_shift","_ctrl","_alt"];
switch (_dik) do {
case 16: { // Q
@ -288,11 +270,11 @@ switch (toLower _mode) do {
// Tree events
case "ontreedblclick": {
// Update camera view when listbox unit is double clicked on
private ["_sel","_netID","_newUnit","_newMode"];
_sel = _args select 1;
_args params ["_tree","_sel"];
// Ensure a unit was selected
if (count _sel == 2) then {
private ["_netID","_newUnit","_newMode"];
_netID = (_args select 0) tvData _sel;
_newUnit = objectFromNetId _netID;

View File

@ -14,9 +14,7 @@
#include "script_component.hpp"
private ["_unit","_killer"];
_unit = _this select 0;
_killer = _this select 1;
params ["_unit","_killer"];
// Remove from group to prevent appearing on HUD upon respawn
[_unit, true, QGVAR(isSpectator), side group _unit] call EFUNC(common,switchToGroupSide);

View File

@ -1,6 +1,7 @@
/*
* Author: SilentSpike
* Tracks the the unit list and updates the unit tree according to its status
* Maintains the unit list and updates the unit tree accordingly
* Also updates current camera unit when status changes
*
* Arguments:
* None <NIL>
@ -28,6 +29,8 @@ if !(GVAR(camUnit) in GVAR(unitList)) then {
[0,objNull] call FUNC(updateCamera);
};
private ["_display","_ctrl","_curSelData","_cachedGrps","_grp","_node","_side","_index"];
// Fetch tree
disableSerialization;
_display = GETUVAR(GVAR(display),displayNull);

View File

@ -15,10 +15,7 @@
#include "script_component.hpp"
private ["_logic", "_units", "_activated"];
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
params ["_logic", "_units", "_activated"];
if !(_activated) exitWith {};

View File

@ -57,7 +57,7 @@ if (_set) then {
[_unit, QGVAR(isSpectator)] call EFUNC(common,unhideUnit);
[_unit, QGVAR(isSpectator)] call EFUNC(common,unmuteUnit);
private ["_marker"];
private "_marker";
_marker = ["respawn_west","respawn_east","respawn_guerrila","respawn_civilian"] select ([west,east,resistance,civilian] find (side group _unit));
_unit setPos (getMarkerPos _marker);
};

View File

@ -1,3 +1,23 @@
/*
* Author: SilentSpike
* Updates the spectator camera view mode and unit
*
* Arguments:
* 0: Camera mode <NUMBER>
* - 0: Free
* - 1: Internal
* - 2: External
* 1: Camera unit <OBJECT>
*
* Return Value:
* None <NIL>
*
* Example:
* [0,objNull] call ace_spectator_fnc_updateCamera
*
* Public: No
*/
#include "script_component.hpp"
params [["_newMode",GVAR(camMode)],["_newUnit",GVAR(camUnit)]];

View File

@ -1,3 +1,19 @@
/*
* Author: SilentSpike
* Correctly handles toggling of spectator interface elements for clean UX
*
* Arguments:
* None <NIL>
*
* Return Value:
* None <NIL>
*
* Example:
* [] call ace_spectator_fnc_updateInterface
*
* Public: No
*/
#include "script_component.hpp"
private ["_display","_elements","_show"];
@ -7,7 +23,7 @@ _display = GETUVAR(GVAR(display),displayNull);
_elements = [IDC_COMP,IDC_HELP,IDC_MAP,IDC_TOOL,IDC_UNIT];
_show = [GVAR(showComp),GVAR(showHelp),GVAR(showMap),GVAR(showTool),GVAR(showUnit)];
// Hide/show interface elements in accordance with good UX design
// Hide/show interface elements as appropriate
if (GVAR(showInterface)) then {
{
(_display displayCtrl _x) ctrlShow (_show select _forEachIndex);