Merge pull request #2226 from acemod/codeCleanupMarker

Code Cleanup Marker Module
This commit is contained in:
PabstMirror 2015-08-23 14:27:07 -05:00
commit 58f4ef5b62
10 changed files with 57 additions and 44 deletions

View File

@ -46,7 +46,8 @@ if (isNil QGVAR(MarkerColorsCache)) then {
_rgba set [_forEachIndex, call compile _x];
};
} forEach _rgba;
_icon = format ["#(argb,8,8,3)color(%1,%2,%3,%4)", _rgba select 0, _rgba select 1, _rgba select 2, _rgba select 3];
_rgba params ["_red", "_green", "_blue", "_alpha"];
_icon = format ["#(argb,8,8,3)color(%1,%2,%3,%4)", _red, _green, _blue, _alpha];
GVAR(MarkerColorsCache) pushBack [_name, _a, _icon];
};

View File

@ -7,7 +7,7 @@
* 0: RscDisplayInsertMarker <DISPLAY>
*
* Return Value:
* Nothing
* None
*
* Example:
* [onLoad] call ace_markers_fnc_initInsertMarker;
@ -19,10 +19,11 @@
#define BORDER 0.005
[{
private ["_display", "_text", "_picture", "_channel", "_buttonOK", "_buttonCancel", "_description", "_title", "_descriptionChannel", "_sizeX", "_sizeY", "_aceShapeLB", "_aceColorLB", "_aceAngleSlider", "_aceAngleSliderText", "_mapIDD", "_pos", "_posX", "_posY", "_posW", "_posH", "_offsetButtons", "_buttonOk", "_curSelShape", "_curSelColor", "_curSelAngle"];
private ["_text", "_picture", "_channel", "_buttonOK", "_buttonCancel", "_description", "_title", "_descriptionChannel", "_sizeX", "_sizeY", "_aceShapeLB", "_aceColorLB", "_aceAngleSlider", "_aceAngleSliderText", "_mapIDD", "_pos", "_offsetButtons", "_buttonOk", "_curSelShape", "_curSelColor", "_curSelAngle"];
disableserialization;
PARAMS_1(_display);
params ["_display"];
TRACE_1("params",_display);
//Can't place markers when can't interact
if (!([ACE_player, objNull, ["notOnMap", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith))) exitWith {
@ -76,10 +77,8 @@
//--- Background
_pos = ctrlposition _text;
_posX = (_pos select 0) + 0.01;
_posY = _pos select 1;
_posW = _pos select 2;
_posH = _pos select 3;
_pos params ["_posX", "_posY", "_posW", "_posH"];
_posX = _posX + 0.01;
_posY = _posY min ((safeZoneH + safeZoneY) - (8 * _posH + 8 * BORDER)); //prevent buttons being placed below bottom edge of screen
_pos set [0,_posX];
_pos set [1,_posY];
@ -173,9 +172,10 @@
// init marker shape lb
lbClear _aceShapeLB;
{
_aceShapeLB lbAdd (_x select 0);
_aceShapeLB lbSetValue [_forEachIndex, _x select 1];
_aceShapeLB lbSetPicture [_forEachIndex, _x select 2];
_x params ["_add", "_set", "_pic"];
_aceShapeLB lbAdd _add;
_aceShapeLB lbSetValue [_forEachIndex, _set];
_aceShapeLB lbSetPicture [_forEachIndex, _pic];
} forEach GVAR(MarkersCache);
_curSelShape = GETGVAR(curSelMarkerShape,0);
_aceShapeLB lbSetCurSel _curSelShape;
@ -188,9 +188,10 @@
// init marker color lb
lbClear _aceColorLB;
{
_aceColorLB lbAdd (_x select 0);
_aceColorLB lbSetValue [_forEachIndex, _x select 1];
_aceColorLB lbSetPicture [_forEachIndex, _x select 2];
_x params ["_add", "_set", "_pic"];
_aceColorLB lbAdd _add;
_aceColorLB lbSetValue [_forEachIndex, _set];
_aceColorLB lbSetPicture [_forEachIndex, _pic];
} forEach GVAR(MarkerColorsCache);
_curSelColor = GETGVAR(curSelMarkerColor,0);
_aceColorLB lbSetCurSel _curSelColor;

View File

@ -6,7 +6,7 @@
* 0: TheMap <Control>
*
* Return Value:
* Nothing
* None
*
* Example:
* [theMapControl] call ace_markers_fnc_mapDrawEH;
@ -15,9 +15,10 @@
*/
#include "script_component.hpp"
private ["_theMap", "_sizeX", "_sizeY", "_textureConfig", "_texture", "_markerSize", "_markerShadow", "_colorConfig", "_drawColor"];
private ["_sizeX", "_sizeY", "_textureConfig", "_texture", "_markerSize", "_markerShadow", "_colorConfig", "_drawColor"];
PARAMS_1(_theMap);
params ["_theMap"];
// TRACE_1("params",_theMap);
//Only show if marker place is open:
if (isNull (findDisplay 54)) exitWith {};

View File

@ -7,7 +7,7 @@
* 1: Selected Index <NUMBER>
*
* Return Value:
* Nothing
* None
*
* Example:
* [ColorLB, 5] call ace_markers_fnc_onLBSelChangedColor;
@ -18,7 +18,9 @@
private ["_data", "_config"];
PARAMS_2(_ctrl,_index);
params ["_ctrl", "_index"];
TRACE_2("params",_ctrl,_index);
_data = _ctrl lbValue _index;
GVAR(curSelMarkerColor) = _index;

View File

@ -7,7 +7,7 @@
* 1: Selected Index <NUMBER>
*
* Return Value:
* Nothing
* None
*
* Example:
* [ColorLB, 5] call ace_markers_fnc_onLBSelChangedShape;
@ -18,7 +18,9 @@
private ["_data", "_config"];
PARAMS_2(_ctrl,_index);
params ["_ctrl", "_index"];
TRACE_2("params",_ctrl,_index);
_data = _ctrl lbValue _index;
GVAR(curSelMarkerShape) = _index;

View File

@ -7,7 +7,7 @@
* 1: Slider Data (angle: -180..180) <NUMBER>
*
* Return Value:
* Nothing
* None
*
* Example:
* [Slider, 2] call ace_markers_fnc_onSliderPosChangedAngle;
@ -18,7 +18,8 @@
private ["_direction"];
PARAMS_2(_ctrl,_data);
params ["_ctrl", "_data"];
TRACE_2("params",_ctrl,_data);
_direction = round _data;
if (_direction < 0) then {

View File

@ -7,7 +7,7 @@
* 1: CloseNumber (1 = ButtonOk) <NUMBER>
*
* Return Value:
* Nothing
* None
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_placeMarker;
@ -17,7 +17,8 @@
#include "script_component.hpp"
disableserialization;
PARAMS_2(_display,_closeNum);
params ["_display", "_closeNum"];
TRACE_2("params",_display,_closeNum);
if (_closeNum == 1) then {

View File

@ -6,7 +6,7 @@
* 0: Logic <OBJECT>
*
* Return Value:
* Nothing
* None
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_sendMarkerJIP;
@ -15,11 +15,11 @@
*/
#include "script_component.hpp"
PARAMS_1(_logic);
params ["_logic"];
TRACE_1("params",_logic);
[QGVAR(setMarkerJIP), [_logic], [
GETGVAR(allMapMarkers,[]),
GETGVAR(allMapMarkersProperties,[]),
_logic
]
[
QGVAR(setMarkerJIP),
[_logic],
[GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[]), _logic]
] call EFUNC(common,targetEvent);

View File

@ -8,7 +8,7 @@
* 2: Logic <OBJECT>
*
* Return Value:
* Nothing
* None
*
* Example:
* [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP;
@ -17,32 +17,34 @@
*/
#include "script_component.hpp"
private ["_index", "_data", "_config"];
PARAMS_3(_allMapMarkers,_allMapMarkersProperties,_logic);
params ["_allMapMarkers", "_allMapMarkersProperties", "_logic"];
TRACE_3("params",_allMapMarkers,_allMapMarkersProperties,_logic);
{
private ["_index", "_data", "_config"];
_index = _allMapMarkers find _x;
if (_index != -1) then {
_data = _allMapMarkersProperties select _index;
_data params ["_name", "_color", "_pos", "_dir"];
_config = (configfile >> "CfgMarkers") >> (_data select 0);
_config = (configfile >> "CfgMarkers") >> _name;
if (!isClass _config) then {
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
};
_x setMarkerTypeLocal (configName _config);
_config = (configfile >> "CfgMarkerColors") >> (_data select 1);
_config = (configfile >> "CfgMarkerColors") >> _color;
if (!isClass _config) then {
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
};
_x setMarkerColorLocal (configName _config);
_x setMarkerPosLocal (_data select 2);
_x setMarkerDirLocal (_data select 3);
_x setMarkerPosLocal _pos;
_x setMarkerDirLocal _dir;
};
} forEach allMapMarkers;

View File

@ -8,7 +8,7 @@
* 1: Marker Data <ARRAY>
*
* Return Value:
* Nothing
* None
*
* Example:
* [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP;
@ -19,8 +19,10 @@
private ["_config"];
PARAMS_2(_marker,_data);
EXPLODE_4_PVT(_data,_markerClassname,_colorClassname,_markerPos,_markerDir);
params ["_marker", "_data"];
_data params ["_markerClassname", "_colorClassname", "_markerPos", "_markerDir"];
TRACE_2("params",_marker,_data);
_config = (configfile >> "CfgMarkers") >> _markerClassname;
if (!isClass _config) then {