From f35b82ddb902ed836a6ad3fdadabe9dff083fb86 Mon Sep 17 00:00:00 2001 From: jokoho48 Date: Sat, 22 Aug 2015 14:08:35 +0200 Subject: [PATCH 1/2] Code Cleanup Marker Module. --- addons/markers/XEH_preInit.sqf | 3 ++- .../functions/fnc_initInsertMarker.sqf | 26 +++++++++---------- addons/markers/functions/fnc_mapDrawEH.sqf | 6 ++--- .../functions/fnc_onLBSelChangedColor.sqf | 4 +-- .../functions/fnc_onLBSelChangedShape.sqf | 4 +-- .../functions/fnc_onSliderPosChangedAngle.sqf | 4 +-- addons/markers/functions/fnc_placeMarker.sqf | 4 +-- .../markers/functions/fnc_sendMarkersJIP.sqf | 12 ++++----- addons/markers/functions/fnc_setMarkerJIP.sqf | 17 +++++++----- .../functions/fnc_setMarkerNetwork.sqf | 6 ++--- 10 files changed, 44 insertions(+), 42 deletions(-) diff --git a/addons/markers/XEH_preInit.sqf b/addons/markers/XEH_preInit.sqf index b2b9ed5c00..f134983c2d 100644 --- a/addons/markers/XEH_preInit.sqf +++ b/addons/markers/XEH_preInit.sqf @@ -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, _blue]; GVAR(MarkerColorsCache) pushBack [_name, _a, _icon]; }; diff --git a/addons/markers/functions/fnc_initInsertMarker.sqf b/addons/markers/functions/fnc_initInsertMarker.sqf index c55e07c360..8b2365fb2d 100644 --- a/addons/markers/functions/fnc_initInsertMarker.sqf +++ b/addons/markers/functions/fnc_initInsertMarker.sqf @@ -7,7 +7,7 @@ * 0: RscDisplayInsertMarker * * Return Value: - * Nothing + * None * * Example: * [onLoad] call ace_markers_fnc_initInsertMarker; @@ -19,10 +19,10 @@ #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"]; //Can't place markers when can't interact if (!([ACE_player, objNull, ["notOnMap", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith))) exitWith { @@ -76,10 +76,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 +171,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 +187,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; diff --git a/addons/markers/functions/fnc_mapDrawEH.sqf b/addons/markers/functions/fnc_mapDrawEH.sqf index 2e23dacec8..9bd03ac8d9 100644 --- a/addons/markers/functions/fnc_mapDrawEH.sqf +++ b/addons/markers/functions/fnc_mapDrawEH.sqf @@ -6,7 +6,7 @@ * 0: TheMap * * Return Value: - * Nothing + * None * * Example: * [theMapControl] call ace_markers_fnc_mapDrawEH; @@ -15,9 +15,9 @@ */ #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"]; //Only show if marker place is open: if (isNull (findDisplay 54)) exitWith {}; diff --git a/addons/markers/functions/fnc_onLBSelChangedColor.sqf b/addons/markers/functions/fnc_onLBSelChangedColor.sqf index e089569761..d2f3c3a7e1 100644 --- a/addons/markers/functions/fnc_onLBSelChangedColor.sqf +++ b/addons/markers/functions/fnc_onLBSelChangedColor.sqf @@ -7,7 +7,7 @@ * 1: Selected Index * * Return Value: - * Nothing + * None * * Example: * [ColorLB, 5] call ace_markers_fnc_onLBSelChangedColor; @@ -18,7 +18,7 @@ private ["_data", "_config"]; -PARAMS_2(_ctrl,_index); +params ["_ctrl", "_index"]; _data = _ctrl lbValue _index; GVAR(curSelMarkerColor) = _index; diff --git a/addons/markers/functions/fnc_onLBSelChangedShape.sqf b/addons/markers/functions/fnc_onLBSelChangedShape.sqf index ff067a467b..528097861b 100644 --- a/addons/markers/functions/fnc_onLBSelChangedShape.sqf +++ b/addons/markers/functions/fnc_onLBSelChangedShape.sqf @@ -7,7 +7,7 @@ * 1: Selected Index * * Return Value: - * Nothing + * None * * Example: * [ColorLB, 5] call ace_markers_fnc_onLBSelChangedShape; @@ -18,7 +18,7 @@ private ["_data", "_config"]; -PARAMS_2(_ctrl,_index); +params ["_ctrl", "_index"]; _data = _ctrl lbValue _index; GVAR(curSelMarkerShape) = _index; diff --git a/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf b/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf index 1210b8ce71..a2ebbf0e6e 100644 --- a/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf +++ b/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf @@ -7,7 +7,7 @@ * 1: Slider Data (angle: -180..180) * * Return Value: - * Nothing + * None * * Example: * [Slider, 2] call ace_markers_fnc_onSliderPosChangedAngle; @@ -18,7 +18,7 @@ private ["_direction"]; -PARAMS_2(_ctrl,_data); +params ["_ctrl", "_data"]; _direction = round _data; if (_direction < 0) then { diff --git a/addons/markers/functions/fnc_placeMarker.sqf b/addons/markers/functions/fnc_placeMarker.sqf index fd584c1c99..dca8cac2e9 100644 --- a/addons/markers/functions/fnc_placeMarker.sqf +++ b/addons/markers/functions/fnc_placeMarker.sqf @@ -7,7 +7,7 @@ * 1: CloseNumber (1 = ButtonOk) * * Return Value: - * Nothing + * None * * Example: * [onUnloadEvent] call ace_markers_fnc_placeMarker; @@ -17,7 +17,7 @@ #include "script_component.hpp" disableserialization; -PARAMS_2(_display,_closeNum); +params ["_display", "_closeNum"]; if (_closeNum == 1) then { diff --git a/addons/markers/functions/fnc_sendMarkersJIP.sqf b/addons/markers/functions/fnc_sendMarkersJIP.sqf index 99eea2f2d9..1854f21e13 100644 --- a/addons/markers/functions/fnc_sendMarkersJIP.sqf +++ b/addons/markers/functions/fnc_sendMarkersJIP.sqf @@ -6,7 +6,7 @@ * 0: Logic * * Return Value: - * Nothing + * None * * Example: * [onUnloadEvent] call ace_markers_fnc_sendMarkerJIP; @@ -15,11 +15,9 @@ */ #include "script_component.hpp" -PARAMS_1(_logic); -[QGVAR(setMarkerJIP), [_logic], [ -GETGVAR(allMapMarkers,[]), -GETGVAR(allMapMarkersProperties,[]), -_logic -] +[ + QGVAR(setMarkerJIP), + _this, + [GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[]), _logic] ] call EFUNC(common,targetEvent); diff --git a/addons/markers/functions/fnc_setMarkerJIP.sqf b/addons/markers/functions/fnc_setMarkerJIP.sqf index 0760cc6fe5..0bbbc1ed3e 100644 --- a/addons/markers/functions/fnc_setMarkerJIP.sqf +++ b/addons/markers/functions/fnc_setMarkerJIP.sqf @@ -8,7 +8,7 @@ * 2: Logic * * Return Value: - * Nothing + * None * * Example: * [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP; @@ -17,32 +17,35 @@ */ #include "script_component.hpp" -private ["_index", "_data", "_config"]; -PARAMS_3(_allMapMarkers,_allMapMarkersProperties,_logic); + +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; diff --git a/addons/markers/functions/fnc_setMarkerNetwork.sqf b/addons/markers/functions/fnc_setMarkerNetwork.sqf index 457d5dac37..cc7e7526e6 100644 --- a/addons/markers/functions/fnc_setMarkerNetwork.sqf +++ b/addons/markers/functions/fnc_setMarkerNetwork.sqf @@ -8,7 +8,7 @@ * 1: Marker Data * * Return Value: - * Nothing + * None * * Example: * [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP; @@ -19,8 +19,8 @@ private ["_config"]; -PARAMS_2(_marker,_data); -EXPLODE_4_PVT(_data,_markerClassname,_colorClassname,_markerPos,_markerDir); +params ["_marker", "_data"]; +_data params ["_markerClassname", "_colorClassname", "_markerPos", "_markerDir"]; _config = (configfile >> "CfgMarkers") >> _markerClassname; if (!isClass _config) then { From a82e5b5436e954d3c4f0b2401c9f7e7ab20b4067 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 23 Aug 2015 14:25:41 -0500 Subject: [PATCH 2/2] Fix Colors + Debug Trace --- addons/markers/XEH_preInit.sqf | 2 +- addons/markers/functions/fnc_initInsertMarker.sqf | 3 ++- addons/markers/functions/fnc_mapDrawEH.sqf | 1 + addons/markers/functions/fnc_onLBSelChangedColor.sqf | 2 ++ addons/markers/functions/fnc_onLBSelChangedShape.sqf | 2 ++ addons/markers/functions/fnc_onSliderPosChangedAngle.sqf | 1 + addons/markers/functions/fnc_placeMarker.sqf | 1 + addons/markers/functions/fnc_sendMarkersJIP.sqf | 4 +++- addons/markers/functions/fnc_setMarkerJIP.sqf | 3 +-- addons/markers/functions/fnc_setMarkerNetwork.sqf | 2 ++ 10 files changed, 16 insertions(+), 5 deletions(-) diff --git a/addons/markers/XEH_preInit.sqf b/addons/markers/XEH_preInit.sqf index f134983c2d..e47514f4fa 100644 --- a/addons/markers/XEH_preInit.sqf +++ b/addons/markers/XEH_preInit.sqf @@ -47,7 +47,7 @@ if (isNil QGVAR(MarkerColorsCache)) then { }; } forEach _rgba; _rgba params ["_red", "_green", "_blue", "_alpha"]; - _icon = format ["#(argb,8,8,3)color(%1,%2,%3,%4)", _red, _green, _blue, _blue]; + _icon = format ["#(argb,8,8,3)color(%1,%2,%3,%4)", _red, _green, _blue, _alpha]; GVAR(MarkerColorsCache) pushBack [_name, _a, _icon]; }; diff --git a/addons/markers/functions/fnc_initInsertMarker.sqf b/addons/markers/functions/fnc_initInsertMarker.sqf index 8b2365fb2d..07e2bc46c4 100644 --- a/addons/markers/functions/fnc_initInsertMarker.sqf +++ b/addons/markers/functions/fnc_initInsertMarker.sqf @@ -23,7 +23,8 @@ disableserialization; 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 { _display closeDisplay 2; //emulate "Cancel" button diff --git a/addons/markers/functions/fnc_mapDrawEH.sqf b/addons/markers/functions/fnc_mapDrawEH.sqf index 9bd03ac8d9..babdfbbb44 100644 --- a/addons/markers/functions/fnc_mapDrawEH.sqf +++ b/addons/markers/functions/fnc_mapDrawEH.sqf @@ -18,6 +18,7 @@ private ["_sizeX", "_sizeY", "_textureConfig", "_texture", "_markerSize", "_markerShadow", "_colorConfig", "_drawColor"]; params ["_theMap"]; +// TRACE_1("params",_theMap); //Only show if marker place is open: if (isNull (findDisplay 54)) exitWith {}; diff --git a/addons/markers/functions/fnc_onLBSelChangedColor.sqf b/addons/markers/functions/fnc_onLBSelChangedColor.sqf index d2f3c3a7e1..0b9c5af209 100644 --- a/addons/markers/functions/fnc_onLBSelChangedColor.sqf +++ b/addons/markers/functions/fnc_onLBSelChangedColor.sqf @@ -19,6 +19,8 @@ private ["_data", "_config"]; params ["_ctrl", "_index"]; +TRACE_2("params",_ctrl,_index); + _data = _ctrl lbValue _index; GVAR(curSelMarkerColor) = _index; diff --git a/addons/markers/functions/fnc_onLBSelChangedShape.sqf b/addons/markers/functions/fnc_onLBSelChangedShape.sqf index 528097861b..c8587e6205 100644 --- a/addons/markers/functions/fnc_onLBSelChangedShape.sqf +++ b/addons/markers/functions/fnc_onLBSelChangedShape.sqf @@ -19,6 +19,8 @@ private ["_data", "_config"]; params ["_ctrl", "_index"]; +TRACE_2("params",_ctrl,_index); + _data = _ctrl lbValue _index; GVAR(curSelMarkerShape) = _index; diff --git a/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf b/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf index a2ebbf0e6e..16c6acfad9 100644 --- a/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf +++ b/addons/markers/functions/fnc_onSliderPosChangedAngle.sqf @@ -19,6 +19,7 @@ private ["_direction"]; params ["_ctrl", "_data"]; +TRACE_2("params",_ctrl,_data); _direction = round _data; if (_direction < 0) then { diff --git a/addons/markers/functions/fnc_placeMarker.sqf b/addons/markers/functions/fnc_placeMarker.sqf index dca8cac2e9..36b61151ee 100644 --- a/addons/markers/functions/fnc_placeMarker.sqf +++ b/addons/markers/functions/fnc_placeMarker.sqf @@ -18,6 +18,7 @@ disableserialization; params ["_display", "_closeNum"]; +TRACE_2("params",_display,_closeNum); if (_closeNum == 1) then { diff --git a/addons/markers/functions/fnc_sendMarkersJIP.sqf b/addons/markers/functions/fnc_sendMarkersJIP.sqf index 1854f21e13..73a00519e3 100644 --- a/addons/markers/functions/fnc_sendMarkersJIP.sqf +++ b/addons/markers/functions/fnc_sendMarkersJIP.sqf @@ -15,9 +15,11 @@ */ #include "script_component.hpp" +params ["_logic"]; +TRACE_1("params",_logic); [ QGVAR(setMarkerJIP), - _this, + [_logic], [GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[]), _logic] ] call EFUNC(common,targetEvent); diff --git a/addons/markers/functions/fnc_setMarkerJIP.sqf b/addons/markers/functions/fnc_setMarkerJIP.sqf index 0bbbc1ed3e..4e6b47b46b 100644 --- a/addons/markers/functions/fnc_setMarkerJIP.sqf +++ b/addons/markers/functions/fnc_setMarkerJIP.sqf @@ -17,9 +17,8 @@ */ #include "script_component.hpp" - - params ["_allMapMarkers", "_allMapMarkersProperties", "_logic"]; +TRACE_3("params",_allMapMarkers,_allMapMarkersProperties,_logic); { private ["_index", "_data", "_config"]; diff --git a/addons/markers/functions/fnc_setMarkerNetwork.sqf b/addons/markers/functions/fnc_setMarkerNetwork.sqf index cc7e7526e6..c56a1fb93c 100644 --- a/addons/markers/functions/fnc_setMarkerNetwork.sqf +++ b/addons/markers/functions/fnc_setMarkerNetwork.sqf @@ -21,6 +21,8 @@ private ["_config"]; params ["_marker", "_data"]; _data params ["_markerClassname", "_colorClassname", "_markerPos", "_markerDir"]; +TRACE_2("params",_marker,_data); + _config = (configfile >> "CfgMarkers") >> _markerClassname; if (!isClass _config) then {