Merge pull request #267 from KoffeinFlummi/142Markers

1.42 Marker Placement
This commit is contained in:
PabstMirror 2015-04-08 13:24:55 -05:00
commit 023a2d2202
14 changed files with 382 additions and 385 deletions

View File

@ -1,4 +1,3 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));

View File

@ -1,4 +1,3 @@
class RscPicture;
class RscText;
class RscStructuredText;
@ -13,91 +12,34 @@ class RscXSliderH;
class RscDisplayInsertMarker {
onLoad = QUOTE(_this call DFUNC(initInsertMarker););
onUnload = QUOTE(_this call DFUNC(placeMarker););
idd = 54;
// idd = 54;
movingEnable = 1;
class controlsBackground {
class RscText_1000: RscText {
idc = 1000;
/*x = "0 * GUI_GRID_INSERTMARKER_W + GUI_GRID_INSERTMARKER_X";
y = "0 * GUI_GRID_INSERTMARKER_H + GUI_GRID_INSERTMARKER_Y";
w = "8 * GUI_GRID_INSERTMARKER_W";
h = "2.5 * GUI_GRID_INSERTMARKER_H";
colorBackground[] = {0,0,0,0.5};*/
};
class Description: RscStructuredText {
colorBackground[] = {0,0,0,0.7};
idc = 1100;
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "9.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
// class RscText_1000: RscText {idc = 1000;};
};
class controls {
//delete ButtonOK;
class ButtonMenuOK: RscButtonMenuOK {
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "15.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "8.9 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
// size = "0.85 * ( ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
// sizeEx = "0.85 * ( ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
text = "";
// class ButtonMenuOK: RscButtonMenuOK {idc = 1;};
// class ButtonMenuCancel: RscButtonMenuCancel {idc = 2;};
// class Title: RscText {idc = 1001;};
// class Description: RscStructuredText {idc = 1100;};
// class DescriptionChannel: RscStructuredText {idc = 1101;};
// class MarkerPicture: RscPicture {idc = 102;};
// class MarkerText: RscEdit {idc = 101;};
// class MarkerChannel: RscCombo {idc = 103;};
class MarkerShape: RscCombo {
idc = 1210;
};
class ButtonMenuCancel: RscButtonMenuCancel {
x = "23 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "15.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "1.1 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
text = "X";
colorBackground[] = {0.75,0,0,0.5};
colorBackgroundFocused[] = {0.75,0,0,0.5};
colorBackground2[] = {1,0,0,0.5};
class MarkerColor: RscCombo {
idc = 1211;
};
/*class ButtonMenuInfo: RscButtonMenu {
idc = 2400;
text = "$STR_A3_RscDisplayInsertMarker_ButtonMenuInfo";
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "13.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};*/
delete ButtonMenuInfo;
class Title: RscText {
moving = 1;
colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])","(profilenamespace getvariable ['GUI_BCG_RGB_A',0.8])"};
idc = 1001;
text = "$STR_A3_RscDisplayInsertMarker_Title";
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "8.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
class MarkerAngle: RscXSliderH {
idc = 1220;
};
delete Description;
/*class Info: RscStructuredText {
colorBackground[] = {0,0,0,0.7};
idc = 1101;
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "11.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};*/
delete Info;
class Picture: RscPicture {
idc = 102;
x = 0.259984;
y = 0.4;
w = 0.05;
h = 0.0666667;
};
class Text: RscEdit {
idc = 101;
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "10.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
class MarkerAngleText: RscText {
idc = 1221;
};
/*class SizeX: RscEdit {
idc = 1200;
text = "10";
@ -114,34 +56,5 @@ class RscDisplayInsertMarker {
w = "5 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};*/
class MarkerShape: RscCombo {
idc = 1210;
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "11.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class MarkerColor: RscCombo {
idc = 1211;
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "12.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class MarkerAngle: RscXSliderH {
idc = 1220;
text = "10";
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "13.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
class MarkerAngleText: RscText {
idc = 1221;
x = "14 * ( ((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX)";
y = "14.5 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + safezoneH - ( ((safezoneW / safezoneH) min 1.2) / 1.2))";
w = "10 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
h = "1 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};
};
};

View File

@ -11,6 +11,12 @@
if (isMultiplayer && {!isServer} && {hasInterface}) then {
private "_logic";
_logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"];
[QGVAR(sendMarkersJIP), _logic] call EFUNC(common,serverEvent);
[QGVAR(sendMarkersJIP), [_logic]] call EFUNC(common,serverEvent);
};
GVAR(mapDisplaysWithDrawEHs) = [];
GVAR(currentMarkerPosition) = [];
GVAR(currentMarkerAngle) = 0;
GVAR(currentMarkerColorConfigName) = "";
GVAR(currentMarkerConfigName) = "";

View File

@ -3,6 +3,7 @@
ADDON = false;
PREP(initInsertMarker);
PREP(mapDrawEH);
PREP(onLBSelChangedColor);
PREP(onLBSelChangedShape);
PREP(onSliderPosChangedAngle);
@ -14,25 +15,15 @@ PREP(setMarkerNetwork);
// init marker types
if (isNil QGVAR(MarkersCache)) then {
_config = configfile >> "CfgMarkers";
_index = 0;
GVAR(MarkersCache) = [];
for "_a" from 0 to (count _config - 1) do {
_marker = _config select _a;
_scope = getNumber (_marker >> "scope");
_name = getText (_marker >> "name");
_icon = getText (_marker >> "icon");
if (_scope == 2) then {
_shape lbAdd _name;
_shape lbSetValue [_index, _a];
_shape lbSetPicture [_index, _icon];
_name = getText (_marker >> "name");
_icon = getText (_marker >> "icon");
GVAR(MarkersCache) pushBack [_name, _a, _icon];
_index = _index + 1;
};
};
};
@ -40,39 +31,27 @@ if (isNil QGVAR(MarkersCache)) then {
// init marker colors
if (isNil QGVAR(MarkerColorsCache)) then {
_config = configfile >> "CfgMarkerColors";
_index = 0;
GVAR(MarkerColorsCache) = [];
for "_a" from 0 to (count _config - 1) do {
_marker = _config select _a;
_scope = getNumber (_marker >> "scope");
_name = getText (_marker >> "name");
if (_scope == 2) then {
_color lbAdd _name;
_color lbSetValue [_index, _a];
_name = getText (_marker >> "name");
_rgba = getArray (_marker >> "color");
{
if (typeName _x != "SCALAR") 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];
_color lbSetPicture [_index, _icon];
GVAR(MarkerColorsCache) pushBack [_name, _a, _icon];
_index = _index + 1;
};
};
};
//Server Sync JIP markers:
[QGVAR(sendMarkersJIP), FUNC(sendMarkersJIP)] call EFUNC(common,addEventHandler);
ADDON = true;

View File

@ -1,87 +1,84 @@
// stuff taken from bohemia, edited by commy2
/*
* Author: BIS, commy2
* Sets up the marker placement
* Run instead of \a3\ui_f\scripts\GUI\RscDisplayInsertMarker.sqf
*
* Arguments:
* 0: RscDisplayInsertMarker <DISPLAY>
*
* Return Value:
* Nothing
*
* Example:
* [onLoad] call ace_markers_fnc_initInsertMarker;
*
* Public: No
*/
#include "script_component.hpp"
#define BORDER 0.005
[{
disableserialization;
_display = _this select 0;
PARAMS_1(_display);
//Prevent Captive Players from placing markers
/*if (ACE_player getVariable ["ACE_isCaptive", false]) exitWith {
//Can't place markers when can't interact
if (!([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith))) exitWith {
_display closeDisplay 2; //emulate "Cancel" button
};*/
// prevent vanilla key input
_display displayAddEventHandler ["KeyDown", {(_this select 1) in [200, 208]}];
};
//BIS Controls:
_text = _display displayctrl 101;
_picture = _display displayctrl 102;
_channel = _display displayctrl 103;
_buttonOK = _display displayctrl 1;
_buttonCancel = _display displayctrl 2;
_description = _display displayctrl 1100;
_title = _display displayctrl 1001;
_sizeX = _display displayctrl 1200;
_sizeY = _display displayctrl 1201;
_shape = _display displayctrl 1210;
_color = _display displayctrl 1211;
_angle = _display displayctrl 1220;
_angleText = _display displayctrl 1221;
_descriptionChannel = _display displayctrl 1101;
//ACE Controls:
// _sizeX = _display displayctrl 1200;
// _sizeY = _display displayctrl 1201;
_aceShapeLB = _display displayctrl 1210;
_aceColorLB = _display displayctrl 1211;
_aceAngleSlider = _display displayctrl 1220;
_aceAngleSliderText = _display displayctrl 1221;
//Install MapDrawEH on current map
_mapIDD = -1;
{
if (!isNull (findDisplay _x)) exitWith {_mapIDD = _x};
} forEach [12, 37, 52, 53];
if (_mapIDD == -1) exitWith {ERROR("No Map?");};
if (!(_mapIDD in GVAR(mapDisplaysWithDrawEHs))) then {
GVAR(mapDisplaysWithDrawEHs) pushBack _mapIDD;
((finddisplay _mapIDD) displayctrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(mapDrawEH)}];
};
//Calculate center position of the marker placement ctrl
_pos = ctrlPosition _picture;
_pos = [(_pos select 0) + (_pos select 2) / 2, (_pos select 1) + (_pos select 3) / 2];
GVAR(currentMarkerPosition) = ((findDisplay _mapIDD) displayCtrl 51) ctrlMapScreenToWorld _pos;
//Hide the bis picture:
_picture ctrlShow false;
// prevent vanilla key input
_display displayAddEventHandler ["KeyDown", {(_this select 1) in [200, 208]}];
//Focus on the text input
ctrlSetFocus _text;
//Change ok button's text based on current channel
[{
EXPLODE_2_PVT(_this,_params,_pfhId);
EXPLODE_1_PVT(_params,_buttonOK);
if (isNull _buttonOK) exitWith {
[_pfhId] call CBA_fnc_removePerFrameHandler;
};
_channel = "";
_textColor = [1,1,1,1];
switch (call EFUNC(common,currentChannel)) do {
case ("global"): {
_channel = localize "str_channel_global";
_textColor = [(216/255),(216/255),(216/255),1];
};
case ("side"): {
_channel = localize "str_channel_side";
_textColor = [(70/255),(211/255),(252/255),1];
};
case ("group"): {
_channel = localize "str_channel_group";
_textColor = [(181/255),(248/255),(98/255),1];
};
case ("vehicle"): {
_channel = localize "str_channel_vehicle";
_textColor = [(255/255),(208/255),(0/255),1];
};
case ("direct"): {
_channel = localize "str_channel_direct";
_textColor = [(255/255),(255/255),(255/255),1];
};
case ("command"): {
_channel = localize "str_channel_command";
_textColor = [(255/255),(255/255),(70/255),1];
};
};
//If localization not found, then don't touch anything (default is RscButtonMenuOK's localized text)
if (_channel != "") then {
_buttonOK ctrlSetTextColor _textColor;
_buttonOK ctrlSetText format [localize "STR_ACE_Markers_PlaceIn", _channel];
};
}, 0, [_buttonOK]] call CBA_fnc_addPerFrameHandler;
//--- Background
_pos = ctrlposition _text;
_posX = (_pos select 0) + 0.01;
_posY = _pos select 1;
_posW = _pos select 2;
_posH = _pos select 3;
_posY = _posY min ((safeZoneH + safeZoneY) - (6 * _posH + 8 * BORDER)); //prevent buttons being placed below bottom edge of screen
_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];
_text ctrlsetposition _pos;
@ -96,46 +93,67 @@
//--- Description
_pos set [1,_posY - 1*_posH];
_pos set [3,6*_posH + 6 * BORDER];
_description ctrlenable false;
_description ctrlsetposition _pos;
_description ctrlsetstructuredtext parsetext format ["<t size='0.8'>%1</t>","Description:"]; //--- ToDo: Localze
_description ctrlsetstructuredtext parsetext format ["<t size='0.8'>%1</t>", (localize "str_lib_label_description")];
_description ctrlcommit 0;
_activeColor = (["IGUI","WARNING_RGB"] call bis_fnc_displaycolorget) call bis_fnc_colorRGBtoHTML;
//--- Shape
_pos set [1,_posY + 1 * _posH + 2 * BORDER];
_pos set [2,_posW];
_pos set [3,_posH];
_shape ctrlsetposition _pos;
_shape ctrlcommit 0;
_aceShapeLB ctrlsetposition _pos;
_aceShapeLB ctrlcommit 0;
//--- Color
_pos set [1,_posY + 2 * _posH + 3 * BORDER];
_pos set [2,_posW];
_color ctrlsetposition _pos;
_color ctrlcommit 0;
_aceColorLB ctrlsetposition _pos;
_aceColorLB ctrlcommit 0;
//--- Angle
_pos set [1,_posY + 3 * _posH + 4 * BORDER];
_pos set [2,_posW];
_angle ctrlsetposition _pos;
_angle ctrlcommit 0;
_aceAngleSlider ctrlsetposition _pos;
_aceAngleSlider ctrlcommit 0;
//--- Angle Text
_pos set [1,_posY + 4 * _posH + 5 * BORDER];
_pos set [2,_posW];
_angleText ctrlsetposition _pos;
_angleText ctrlcommit 0;
_aceAngleSliderText ctrlsetposition _pos;
_aceAngleSliderText ctrlcommit 0;
_offsetButtons = 0;
if (isMultiplayer) then {
_pos set [1,_posY + 5 * _posH + 7 * BORDER];
_pos set [3,_posH];
_descriptionChannel ctrlsetstructuredtext parsetext format ["<t size='0.8'>%1</t>", (localize "str_a3_cfgvehicles_modulerespawnposition_f_arguments_marker_0") + ":"];
_descriptionChannel ctrlsetposition _pos;
_descriptionChannel ctrlcommit 0;
_pos set [1,_posY + 6 * _posH + 7 * BORDER];
_pos set [3,_posH];
_channel ctrlsetposition _pos;
_channel ctrlcommit 0;
_offsetButtons = 7 * _posH + 8 * BORDER;
} else {
_descriptionChannel ctrlshow false;
_channel ctrlshow false;
_offsetButtons = 5 * _posH + 7 * BORDER;
};
//--- ButtonOK
_pos set [1,_posY + 5 * _posH + 7 * BORDER];
_pos set [2,_posW * (8.9/10) - BORDER];
_pos set [1,_posY + _offsetButtons];
_pos set [2,_posW / 2 - BORDER];
_pos set [3,_posH];
_buttonOk ctrlsetposition _pos;
_buttonOk ctrlcommit 0;
//--- ButtonCancel
_pos set [0,_posX + _posW * (8.9 / 10)];
_pos set [2,_posW * (1.1 / 10)];
_pos set [0,_posX + _posW / 2];
_pos set [1,_posY + _offsetButtons];
_pos set [2,_posW / 2];
_pos set [3,_posH];
_buttonCancel ctrlsetposition _pos;
_buttonCancel ctrlcommit 0;
@ -151,56 +169,41 @@
// init marker shape lb
lbClear _aceShapeLB;
{
_shape lbAdd (_x select 0);
_shape lbSetValue [_forEachIndex, _x select 1];
_shape lbSetPicture [_forEachIndex, _x select 2];
_aceShapeLB lbAdd (_x select 0);
_aceShapeLB lbSetValue [_forEachIndex, _x select 1];
_aceShapeLB lbSetPicture [_forEachIndex, _x select 2];
} forEach GVAR(MarkersCache);
_shape ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedShape)}];
_curSelShape = GETGVAR(curSelMarkerShape,0);
_shape lbSetCurSel _curSelShape;
_data = _shape lbValue _curSelShape;
_config = (configfile >> "CfgMarkers") select _data;
_icon = getText (_config >> "icon");
_picture ctrlSetText _icon;
_aceShapeLB lbSetCurSel _curSelShape;
//Update now and add eventHandler:
[_aceShapeLB, _curSelShape] call FUNC(onLBSelChangedShape);
_aceShapeLB ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedShape)}];
// init marker color lb
lbClear _aceColorLB;
{
_color lbAdd (_x select 0);
_color lbSetValue [_forEachIndex, _x select 1];
_color lbSetPicture [_forEachIndex, _x select 2];
_aceColorLB lbAdd (_x select 0);
_aceColorLB lbSetValue [_forEachIndex, _x select 1];
_aceColorLB lbSetPicture [_forEachIndex, _x select 2];
} forEach GVAR(MarkerColorsCache);
_color ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedColor)}];
_curSelColor = GETGVAR(curSelMarkerColor,0);
_color lbSetCurSel _curSelColor;
_data = _color lbValue _curSelColor;
_config = (configfile >> "CfgMarkerColors") select _data;
_rgba = getArray (_config >> "color");
{
if (typeName _x != "SCALAR") then {
_rgba set [_forEachIndex, call compile _x];
};
} forEach _rgba;
_picture ctrlSetTextColor _rgba;
_aceColorLB lbSetCurSel _curSelColor;
//Update now and add eventHandler:
[_aceColorLB, _curSelColor] call FUNC(onLBSelChangedColor);
_aceColorLB ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedColor)}];
// init marker angle slider
_angle sliderSetRange [-180, 180];
_angle ctrlAddEventHandler ["SliderPosChanged", {_this call FUNC(onSliderPosChangedAngle)}];
_curSelAngle = GETGVAR(curSelMarkerAngle,0);
_angle sliderSetPosition _curSelAngle;
_curSelAngle = round _curSelAngle;
if (_curSelAngle < 0) then {
_curSelAngle = _curSelAngle + 360;
};
_angleText ctrlSetText format [localize "STR_ACE_Markers_MarkerDirection", _curSelAngle];
_aceAngleSlider sliderSetRange [-180, 180];
_curSelAngle = GETGVAR(currentMarkerAngle,0);
_aceAngleSlider sliderSetPosition _curSelAngle;
//Update now and add eventHandler:
[_aceAngleSlider, _curSelAngle] call FUNC(onSliderPosChangedAngle);
_aceAngleSlider ctrlAddEventHandler ["SliderPosChanged", {_this call FUNC(onSliderPosChangedAngle)}];
}, _this] call EFUNC(common,execNextFrame);

View File

@ -0,0 +1,45 @@
/*
* Author: PabstMirror
* Draws the current temp marker. Allows rotation.
*
* Arguments:
* 0: TheMap <Control>
*
* Return Value:
* Nothing
*
* Example:
* [theMapControl] call ace_markers_fnc_mapDrawEH;
*
* Public: No
*/
#include "script_component.hpp"
private ["_theMap", "_sizeX", "_sizeY", "_textureConfig", "_texture", "_markerSize", "_markerShadow", "_colorConfig", "_drawColor"];
PARAMS_1(_theMap);
//Only show if marker place is open:
if (isNull (findDisplay 54)) exitWith {};
//Error checking:
if ((GVAR(currentMarkerConfigName) == "") || {GVAR(currentMarkerColorConfigName) == ""} || {GVAR(currentMarkerPosition) isEqualTo []}) exitWith {ERROR("Bad Data");};
_sizeX = 1;
_sizeY = 1;
_textureConfig = configFile >> "CfgMarkers" >> GVAR(currentMarkerConfigName);
_texture = getText (_textureConfig >> "icon");
_markerSize = getNumber (_textureConfig >> "size");
_markerShadow = getNumber (_textureConfig >> "shadow");
_colorConfig = (configFile >> "CfgMarkerColors" >> GVAR(currentMarkerColorConfigName));
_drawColor = getArray (_colorConfig >> "color");
//Convert possible code into numbers
{
if (typeName _x == "STRING") then {
_drawColor set [_forEachIndex, (call compile _x)];
};
} forEach _drawColor;
_drawColor set [3, ((_drawColor select 3) * 0.875)]; //Arma adds a slight transparency
_theMap drawIcon [_texture, _drawColor, GVAR(currentMarkerPosition), (_sizeX * _markerSize), (_sizeY * _markerSize), GVAR(currentMarkerAngle), "", _markerShadow];

View File

@ -1,23 +1,28 @@
// by commy2
/*
* Author: commy2
* When the color list box is changed.
*
* Arguments:
* 0: Color ListBox (idc 1211) <CONTROL>
* 1: Selected Index <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [ColorLB, 5] call ace_markers_fnc_onLBSelChangedColor;
*
* Public: No
*/
#include "script_component.hpp"
private ["_ctrl", "_data", "_config", "_color"];
private ["_data", "_config"];
_ctrl = _this select 0;
_data = _ctrl lbValue (_this select 1);
PARAMS_2(_ctrl,_index);
_data = _ctrl lbValue _index;
GVAR(curSelMarkerColor) = _this select 1;
GVAR(curSelMarkerColor) = _index;
_config = (configfile >> "CfgMarkerColors") select _data;
_color = getArray (_config >> "color");
{
if (typeName _x != "SCALAR") then {
_color set [_forEachIndex, call compile _x];
};
} forEach _color;
((ctrlParent _ctrl) displayCtrl 102) ctrlSetTextColor _color;
GVAR(currentMarkerColorConfigName) = (configName _config);

View File

@ -1,17 +1,28 @@
// by commy2
/*
* Author: commy2
* When the shape list box is changed.
*
* Arguments:
* 0: Shape ListBox (idc 1210) <CONTROL>
* 1: Selected Index <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [ColorLB, 5] call ace_markers_fnc_onLBSelChangedShape;
*
* Public: No
*/
#include "script_component.hpp"
private ["_ctrl", "_data", "_config", "_icon"];
private ["_data", "_config"];
_ctrl = _this select 0;
_data = _ctrl lbValue (_this select 1);
PARAMS_2(_ctrl,_index);
_data = _ctrl lbValue _index;
GVAR(curSelMarkerShape) = _this select 1;
GVAR(curSelMarkerShape) = _index;
_config = (configfile >> "CfgMarkers") select _data;
_icon = getText (_config >> "icon");
((ctrlParent _ctrl) displayCtrl 102) ctrlSetText _icon;
GVAR(currentMarkerConfigName) = (configName _config);

View File

@ -1,12 +1,24 @@
// by commy2
/*
* Author: commy2
* Angle Slider Pos changed
*
* Arguments:
* 0: Slider (idc 1210) <CONTROL>
* 1: Slider Data (angle: -180..180) <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [Slider, 2] call ace_markers_fnc_onSliderPosChangedAngle;
*
* Public: No
*/
#include "script_component.hpp"
private ["_ctrl", "_data", "_direction"];
private ["_direction"];
_ctrl = _this select 0;
_data = _this select 1;
GVAR(curSelMarkerAngle) = _data;
PARAMS_2(_ctrl,_data);
_direction = round _data;
if (_direction < 0) then {

View File

@ -1,46 +1,36 @@
// by commy2
/*
* Author: commy2
* MarkerPlacement closed
*
* Arguments:
* 0: RscDisplayInsertMarker <DISPLAY>
* 1: CloseNumber (1 = ButtonOk) <NUMBER>
*
* Return Value:
* Nothing
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_placeMarker;
*
* Public: No
*/
#include "script_component.hpp"
if (_this select 1 == 1) then {
disableserialization;
_display = _this select 0;
disableserialization;
PARAMS_2(_display,_closeNum);
_pos = ctrlPosition (_display displayCtrl 102);
_pos = [
(_pos select 0) + (_pos select 2) / 2,
(_pos select 1) + (_pos select 3) / 2
];
switch (true) do {
case (!isNull findDisplay 12): {
_pos = (findDisplay 12 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
case (!isNull findDisplay 37): {
_pos = (findDisplay 37 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
case (!isNull findDisplay 52): {
_pos = (findDisplay 52 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
case (!isNull findDisplay 53): {
_pos = (findDisplay 53 displayCtrl 51) ctrlMapScreenToWorld _pos;
};
};
if (_closeNum == 1) then {
// set and send marker data the next frame. the actual marker isn't created yet
[
{
[QGVAR(setMarkerNetwork), [
allMapMarkers select (count allMapMarkers - 1), [
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
_this,
GETGVAR(currentMarkerAngle,0)
]
]] call EFUNC(common,globalEvent);
},
_pos
] call EFUNC(common,execNextFrame);
[{
[QGVAR(setMarkerNetwork), [
allMapMarkers select (count allMapMarkers - 1), [
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
GETGVAR(currentMarkerPosition,[]),
GETGVAR(currentMarkerAngle,0)
]
]] call EFUNC(common,globalEvent);
}, []] call EFUNC(common,execNextFrame);
};

View File

@ -1,13 +1,25 @@
// by commy2
/*
* Author: commy2
* Server: Recives a dummy logic, sends marker data back to the owner.
*
* Arguments:
* 0: Logic <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_sendMarkerJIP;
*
* Public: No
*/
#include "script_component.hpp"
private "_logic";
PARAMS_1(_logic);
_logic = _this;
[QGVAR(setMarkerJIP), _logic, [
GETGVAR(allMapMarkers,[]),
GETGVAR(allMapMarkersProperties,[]),
_logic
]
[QGVAR(setMarkerJIP), [_logic], [
GETGVAR(allMapMarkers,[]),
GETGVAR(allMapMarkersProperties,[]),
_logic
]
] call EFUNC(common,targetEvent);

View File

@ -1,35 +1,49 @@
// by commy2
/*
* Author: commy2
* Client: Recives a marker data from server.
*
* Arguments:
* 0: Array of map marker names <ARRAY>
* 1: Array of map marker data <ARRAY>
* 2: Logic <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP;
*
* Public: No
*/
#include "script_component.hpp"
private ["_allMapMarkers", "_allMapMarkersProperties", "_index", "_data", "_config"];
private ["_index", "_data", "_config"];
_allMapMarkers = _this select 0;
_allMapMarkersProperties = _this select 1;
_logic = _this select 2;
PARAMS_3(_allMapMarkers,_allMapMarkersProperties,_logic);
{
_index = _allMapMarkers find _x;
_index = _allMapMarkers find _x;
if (_index != -1) then {
_data = _allMapMarkersProperties select _index;
if (_index != -1) then {
_data = _allMapMarkersProperties select _index;
_config = (configfile >> "CfgMarkers") >> (_data select 0);
if (!isClass _config) then {
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
_config = (configfile >> "CfgMarkers") >> (_data select 0);
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);
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 setMarkerTypeLocal (configName _config);
_config = (configfile >> "CfgMarkerColors") >> (_data select 1);
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);
};
} forEach allMapMarkers;
deleteVehicle _logic;

View File

@ -1,45 +1,61 @@
// by commy2
/*
* Author: commy2
* Sets newly placed marker
* Handles the QGVAR(setMarkerNetwork) event.
*
* Arguments:
* 0: Markername <STRING>
* 1: Marker Data <ARRAY>
*
* Return Value:
* Nothing
*
* Example:
* [[],[],dummyLogic] call ace_markers_fnc_setMarkerJIP;
*
* Public: No
*/
#include "script_component.hpp"
private ["_marker", "_data", "_config"];
private ["_config"];
_marker = _this select 0;
_data = _this select 1;
PARAMS_2(_marker,_data);
EXPLODE_4_PVT(_data,_markerClassname,_colorClassname,_markerPos,_markerDir);
_config = (configfile >> "CfgMarkers") >> (_data select 0);
_config = (configfile >> "CfgMarkers") >> _markerClassname;
if (!isClass _config) then {
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
WARNING("CfgMarker not found, changed to milDot");
_config == (configFile >> "CfgMarkers" >> "MilDot");
};
_marker setMarkerTypeLocal (configName _config);
_config = (configfile >> "CfgMarkerColors") >> (_data select 1);
_config = (configfile >> "CfgMarkerColors") >> _colorClassname;
if (!isClass _config) then {
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
WARNING("CfgMarkerColors not found, changed to Default");
_config == (configFile >> "CfgMarkerColors" >> "Default");
};
_marker setMarkerColorLocal configName _config;
_marker setMarkerPosLocal (_data select 2);
_marker setMarkerDirLocal (_data select 3);
_marker setMarkerPosLocal _markerPos;
_marker setMarkerDirLocal _markerDir;
// save properties on server machine for JIP, marker editing ready
if (isMultiplayer && {isServer}) then {
private ["_allMapMarkers", "_allMapMarkersProperties", "_index"];
private ["_allMapMarkers", "_allMapMarkersProperties", "_index"];
_allMapMarkers = GETMVAR(allMapMarkers,[]);
_allMapMarkersProperties = GETMVAR(allMapMarkersProperties,[]);
_allMapMarkers = GETGVAR(allMapMarkers,[]);
_allMapMarkersProperties = GETGVAR(allMapMarkersProperties,[]);
_index = _allMapMarkers find _marker;
_index = _allMapMarkers find _marker;
if (_index == -1) then {
_allMapMarkers pushBack _marker;
_allMapMarkersProperties pushBack _data;
} else {
_allMapMarkers set [_index, _marker];
_allMapMarkersProperties set [_index, _data];
};
if (_index == -1) then {
_allMapMarkers pushBack _marker;
_allMapMarkersProperties pushBack _data;
} else {
_allMapMarkers set [_index, _marker];
_allMapMarkersProperties set [_index, _data];
};
GVAR(allMapMarkers) = _allMapMarkers;
GVAR(allMapMarkersProperties) = _allMapMarkersProperties;
GVAR(allMapMarkers) = _allMapMarkers;
GVAR(allMapMarkersProperties) = _allMapMarkersProperties;
};

View File

@ -11,13 +11,5 @@
<Spanish>Dirección: %1°</Spanish>
<Russian>Направление: %1</Russian>
</Key>
<Key ID="STR_ACE_Markers_PlaceIn">
<English>Place in: %1</English>
<German>Platz in: %1</German>
<Spanish>Colocar en: %1</Spanish>
<Polish>Umieść na: %1</Polish>
<Czech>Umístit do: %1</Czech>
<Russian>Место в: %1</Russian>
</Key>
</Package>
</Project>