diff --git a/serverAddons/AAW/addons/AAW_Server/AAW.hpp b/serverAddons/AAW/addons/AAW_Server/AAW.hpp index ed350989..1462ab42 100644 --- a/serverAddons/AAW/addons/AAW_Server/AAW.hpp +++ b/serverAddons/AAW/addons/AAW_Server/AAW.hpp @@ -10,5 +10,6 @@ class PREFIX { #include "\tc\AAW\addons\AAW_Server\Logistic\cfgLogistics.hpp" #include "\tc\AAW\addons\AAW_Server\Squad\cfgGroupTypes.hpp" #include "\tc\AAW\addons\AAW_Server\RespawnUI\cfgRespawn.hpp" + #include "\tc\AAW\addons\AAW_Server\MapMarker\cfgMapMarker.hpp" #include "\tc\AAW\addons\AAW_Server\CfgEntities.hpp" }; diff --git a/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp b/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp index 1585bbb6..d3927264 100644 --- a/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp +++ b/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp @@ -164,6 +164,29 @@ class CfgCLibModules { FNC(updateResourcesDisplay); }; + // MapInteractions + MODULE(MapInteractions) { + dependency[] = {"AAW/Common"}; + FNC(clientInit); + FNC(mouseButtonClick); + FNC(registerMapControl); + FNC(addMenuEntry); + FNC(openContextMenu); + FNC(buildHeaderElement); + FNC(buildLabelElement); + FNC(buildImageStackButton); + FNC(buildListElement); + }; + + // MapMarker + MODULE(MapMarker) { + dependency[] = {"AAW/Common", "AAW/MapInteractions"}; + FNC(clientInit); + FNC(serverInit); + FNC(createMapMarker); + FNC(updateMarker); + }; + // Mortar MODULE(Mortar) { dependency[] = {"AAW/Common"}; diff --git a/serverAddons/AAW/addons/AAW_Server/CfgClibSettings.hpp b/serverAddons/AAW/addons/AAW_Server/CfgClibSettings.hpp index df4a96fd..ed628201 100644 --- a/serverAddons/AAW/addons/AAW_Server/CfgClibSettings.hpp +++ b/serverAddons/AAW/addons/AAW_Server/CfgClibSettings.hpp @@ -9,4 +9,5 @@ class CfgCLibSettings { aaw_cfgSides[] = {"AAW", "Sides"}; aaw_cfgGroupTypes[] = {"AAW", "CfgGroupTypes"}; aaw_cfgRespawn[] = {"AAW", "CfgRespawn"}; + aaw_cfgMapMarker[] = {"AAW", "CfgMapMarker"}; }; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_addMenuEntry.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_addMenuEntry.sqf new file mode 100644 index 00000000..46a1a828 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_addMenuEntry.sqf @@ -0,0 +1,22 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Adds a Context Menu Entry + + Parameter(s): + 0: Map + + Returns: + None +*/ +params ["_menuId", "_type", ["_attributes", []]]; +// make sure that the control not already have a draw function + +private _currentEntry = GVAR(ContextMenuEntries) getVariable ["ContextMenu_"+_menuId, []]; +private _idx = _currentEntry pushBack [_type, _attributes]; +GVAR(ContextMenuEntries) setVariable ["ContextMenu_"+_menuId, _currentEntry]; +_idx diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildHeaderElement.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildHeaderElement.sqf new file mode 100644 index 00000000..97b8578b --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildHeaderElement.sqf @@ -0,0 +1,99 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Builds a Header element + + Parameter(s): + 0: Context Menu Group + 1: Element specific arguments + 0: Text + + Returns: + None +*/ +params ["_grp", "_args"]; +_args params ["_text"]; + +private _display = ctrlParent _grp; + +private _currentPosition = _grp getVariable ["currentPosition", [0, 0]]; +private _currentSize = _grp getVariable ["currentSize", [0, 0]]; +private _yOffset = _currentPosition select 1; +private _grpPos = ctrlPosition _grp; +private _ctxMenuWidth = _grpPos select 2; + +private _itemGrp = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1, _grp]; +_itemGrp ctrlSetPosition [0, _yOffset, _ctxMenuWidth, ITEM_HEIGHT]; + +private _itemBackground = _display ctrlCreate ["RscPicture", -1,_itemGrp]; +_itemBackground ctrlSetText "#(argb,8,8,3)color(0.5,0.5,0.5,0.5)"; +_itemBackground ctrlSetFade 1; + +private _itemText = _display ctrlCreate ["RscTitle", -1, _itemGrp]; +_itemText ctrlSetText toUpper _text; +_itemText ctrlSetFontHeight PY(2.2); +_itemText ctrlSetFont "RobotoCondensed"; +_itemText ctrlSetPosition [PX(3), 0, (_ctxMenuWidth-PX(3)), ITEM_HEIGHT]; +_itemText ctrlCommit 0; + +private _itemBackText = _display ctrlCreate ["RscPicture", -1, _itemGrp]; +_itemBackText ctrlSetText "A3\ui_f\data\gui\rsc\rscdisplayarcademap\icon_sidebar_show.paa"; +_itemBackText ctrlSetPosition [PX(0.5), PY(0.5), PX(2), PY(2)]; +_itemBackText ctrlCommit 0; + +private _itemActiveArea = _display ctrlCreate ["RscButton", -1, _itemGrp]; +_itemActiveArea ctrlSetActiveColor [0,0,0,0]; +_itemActiveArea ctrlSetBackgroundColor [0,0,0,0]; +_itemActiveArea ctrlSetFade 1; +_itemActiveArea ctrlAddEventHandler ["MouseEnter", { + params ["_ctrl"]; + _ctrl = _ctrl getVariable ["background", controlNull]; + if (!isNull _ctrl) then { + _ctrl ctrlSetFade 0; + _ctrl ctrlCommit 0.2; + }; +}]; +_itemActiveArea ctrlAddEventHandler ["MouseExit", { + params ["_ctrl"]; + _ctrl = _ctrl getVariable ["background", controlNull]; + if (!isNull _ctrl) then { + _ctrl ctrlSetFade 1; + _ctrl ctrlCommit 0.2; + }; +}]; + +_itemActiveArea ctrlAddEventHandler ["ButtonClick", { + params ["_ctrl"]; + (_ctrl getVariable ["action", []]) params [["_code", {}], ["_attributes", []]]; + private _contextMenu = ctrlParentControlsGroup ctrlParentControlsGroup _ctrl; + private _history = _contextMenu getVariable ["history", [""]]; + private _mapControl = _contextMenu getVariable ["mapControl", controlNull]; + private _menuId = if (count _history >= 1) then { + _history select ((count _history) - 1); + } else { + ""; + }; + + [{ + _this call EFUNC(MapInteractions,openContextMenu); + }, [_mapControl, _menuId]] call CFUNC(execNextFrame); + +}]; + + +_itemActiveArea setVariable ["background", _itemBackground]; +_itemActiveArea setVariable ["contextMenu", _grp]; + +{ + _x ctrlSetPosition [0, 0, PX(3), PY(3)]; + _x ctrlCommit 0; + false; +} count [_itemBackground, _itemActiveArea]; +_itemGrp ctrlCommit 0; + +_grp setVariable ["currentPosition", [0, _yOffset + ITEM_HEIGHT]]; +_grp setVariable ["currentSize", [_currentSize select 0, (_yOffset + ITEM_HEIGHT) max (_currentSize select 1)]]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf new file mode 100644 index 00000000..08a57342 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf @@ -0,0 +1,108 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Builds a Image Stack Button element + + Parameter(s): + 0: Context Menu Group + 1: Element specific arguments + 0: Images + 0: Image Path + 1: relative size (1) + 2: color ([1, 1, 1, 1]) + 1: button action + 0: Code // if Code returns false, menu will close + 1: custom arguments ([]) + + Returns: + None +*/ +params ["_grp", "_args"]; +_args params ["_images", "_action"]; + +private _display = ctrlParent _grp; + +private _currentPosition = _grp getVariable ["currentPosition", [0, 0]]; +private _currentSize = _grp getVariable ["currentSize", [0, 0]]; +private _grpPos = ctrlPosition _grp; +private _ctxMenuWidth = _grpPos select 2; + +private _itemGrp = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1, _grp]; +_itemGrp ctrlSetPosition [_currentPosition select 0, _currentPosition select 1, PX(4), PY(4)]; + +private _itemBackground = _display ctrlCreate ["RscPicture", -1,_itemGrp]; +_itemBackground ctrlSetText "#(argb,8,8,3)color(0.5,0.5,0.5,0.5)"; +_itemBackground ctrlSetFade 1; + +{ + _x params ["_imagePath", ["_relSize", 1], ["_color", [1,1,1,1]]]; + private _sizeX = _relSize*PX(4); + private _sizeY = _relSize*PY(4); + private _offsetX = (PX(4)-_sizeX)/2; + private _offsetY = (PY(4)-_sizeY)/2; + private _itemBackText = _display ctrlCreate ["RscPicture", -1, _itemGrp]; + _itemBackText ctrlSetText _imagePath; + _itemBackText ctrlSetTextColor _color; + _itemBackText ctrlSetPosition [_offsetX, _offsetY, _sizeX, _sizeY]; + _itemBackText ctrlCommit 0; +} count _images; + + +private _itemActiveArea = _display ctrlCreate ["RscButton", -1, _itemGrp]; +_itemActiveArea ctrlSetActiveColor [0,0,0,0]; +_itemActiveArea ctrlSetBackgroundColor [0,0,0,0]; +_itemActiveArea ctrlSetFade 1; +_itemActiveArea ctrlAddEventHandler ["MouseEnter", { + params ["_ctrl"]; + _ctrl = _ctrl getVariable ["background", controlNull]; + if (!isNull _ctrl) then { + _ctrl ctrlSetFade 0; + _ctrl ctrlCommit 0.2; + }; +}]; +_itemActiveArea ctrlAddEventHandler ["MouseExit", { + params ["_ctrl"]; + _ctrl = _ctrl getVariable ["background", controlNull]; + if (!isNull _ctrl) then { + _ctrl ctrlSetFade 1; + _ctrl ctrlCommit 0.2; + }; +}]; + +_itemActiveArea ctrlAddEventHandler ["ButtonClick", { + params ["_ctrl"]; + (_ctrl getVariable ["action", []]) params [["_code", {}], ["_attributes", []]]; + private _contextMenu = ctrlParentControlsGroup ctrlParentControlsGroup _ctrl; + private _return = [_contextMenu, _attributes, _this] call _code; + if (isNil "_return" || {_return}) then { + [ + QGVAR(CursorMarker) + ] call CFUNC(removeMapGraphicsGroup); + GVAR(CurrentContextPosition) = []; + ctrlDelete ctrlParentControlsGroup _contextMenu; + }; +}]; +_itemActiveArea setVariable ["background", _itemBackground]; +_itemActiveArea setVariable ["action", _action]; + + +{ + _x ctrlSetPosition [0, 0, PX(4), PY(4)]; + _x ctrlCommit 0; + false; +} count [_itemBackground, _itemActiveArea]; +_itemGrp ctrlCommit 0; + +if ((_currentPosition select 0) + PX(4) > (_grpPos select 2)) then { + _currentPosition set [0, 0]; + _currentPosition set [1, (_currentPosition select 1) + PY(4)]; +} else { + _currentPosition set [0, (_currentPosition select 0) + PX(4)]; +}; + +_grp setVariable ["currentPosition", _currentPosition]; +_grp setVariable ["currentSize", [_currentSize select 0, ((_currentPosition select 1) + PY(4)) max (_currentSize select 1)]]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildLabelElement.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildLabelElement.sqf new file mode 100644 index 00000000..b41b0603 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildLabelElement.sqf @@ -0,0 +1,37 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Builds a label element + + Parameter(s): + 0: Context Menu Group + 1: Element specific arguments + 0: Text + + Returns: + None +*/ +params ["_grp", "_args"]; +_args params ["_text"]; + +private _display = ctrlParent _grp; + +private _currentPosition = _grp getVariable ["currentPosition", [0, 0]]; +private _currentSize = _grp getVariable ["currentSize", [0, 0]]; +private _yOffset = _currentPosition select 1; +private _grpPos = ctrlPosition _grp; +private _ctxMenuWidth = _grpPos select 2; + +private _itemText = _display ctrlCreate ["RscTitle", -1, _grp]; +_itemText ctrlSetText toUpper _text; +_itemText ctrlSetFontHeight PY(2); +_itemText ctrlSetFont "RobotoCondensed"; +_itemText ctrlSetPosition [0, _currentPosition select 1, _ctxMenuWidth, ITEM_HEIGHT]; +_itemText ctrlCommit 0; + +_grp setVariable ["currentPosition", [0, _yOffset + ITEM_HEIGHT]]; +_grp setVariable ["currentSize", [_currentSize select 0, (_yOffset + ITEM_HEIGHT) max (_currentSize select 1)]]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf new file mode 100644 index 00000000..28740886 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf @@ -0,0 +1,88 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Builds a List Button element + + Parameter(s): + 0: Context Menu Group + 1: Element specific arguments + 0: Text + 1: button action + 0: Code // if Code returns false, menu will close + 1: custom arguments ([]) + + Returns: + None +*/ +params ["_grp", "_args"]; +_args params ["_text", "_action"]; + +private _display = ctrlParent _grp; + +private _currentPosition = _grp getVariable ["currentPosition", [0, 0]]; +private _currentSize = _grp getVariable ["currentSize", [0, 0]]; +private _yOffset = _currentPosition select 1; +private _grpPos = ctrlPosition _grp; +private _ctxMenuWidth = _grpPos select 2; + +private _itemGrp = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1, _grp]; +_itemGrp ctrlSetPosition [0, _yOffset, _ctxMenuWidth, ITEM_HEIGHT]; + +private _itemBackground = _display ctrlCreate ["RscPicture", -1,_itemGrp]; +_itemBackground ctrlSetText "#(argb,8,8,3)color(0.5,0.5,0.5,0.5)"; +_itemBackground ctrlSetFade 1; + +private _itemText = _display ctrlCreate ["RscTitle", -1, _itemGrp]; +_itemText ctrlSetText toUpper _text; +_itemText ctrlSetFontHeight PY(2.2); +_itemText ctrlSetFont "RobotoCondensed"; + +private _itemActiveArea = _display ctrlCreate ["RscButton", -1, _itemGrp]; +_itemActiveArea ctrlSetActiveColor [0,0,0,0]; +_itemActiveArea ctrlSetBackgroundColor [0,0,0,0]; +_itemActiveArea ctrlSetFade 1; +_itemActiveArea ctrlAddEventHandler ["MouseEnter", { + params ["_ctrl"]; + _ctrl = _ctrl getVariable ["background", controlNull]; + if (!isNull _ctrl) then { + _ctrl ctrlSetFade 0; + _ctrl ctrlCommit 0.2; + }; +}]; +_itemActiveArea ctrlAddEventHandler ["MouseExit", { + params ["_ctrl"]; + _ctrl = _ctrl getVariable ["background", controlNull]; + if (!isNull _ctrl) then { + _ctrl ctrlSetFade 1; + _ctrl ctrlCommit 0.2; + }; +}]; +_itemActiveArea ctrlAddEventHandler ["ButtonClick", { + params ["_ctrl"]; + (_ctrl getVariable ["action", []]) params [["_code", {}], ["_attributes", []]]; + private _contextMenu = ctrlParentControlsGroup ctrlParentControlsGroup _ctrl; + private _return = [_contextMenu, _attributes, _this] call _code; + if (isNil "_return" || {_return}) then { + [ + QGVAR(CursorMarker) + ] call CFUNC(removeMapGraphicsGroup); + GVAR(CurrentContextPosition) = []; + ctrlDelete ctrlParentControlsGroup _contextMenu; + }; +}]; +_itemActiveArea setVariable ["background", _itemBackground]; +_itemActiveArea setVariable ["action", _action]; + +{ + _x ctrlSetPosition [0, 0, _ctxMenuWidth, ITEM_HEIGHT]; + _x ctrlCommit 0; + false; +} count [_itemBackground, _itemText, _itemActiveArea]; +_itemGrp ctrlCommit 0; + +_grp setVariable ["currentPosition", [0, _yOffset + ITEM_HEIGHT]]; +_grp setVariable ["currentSize", [_currentSize select 0, (_yOffset + ITEM_HEIGHT) max (_currentSize select 1)]]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf new file mode 100644 index 00000000..338de14c --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf @@ -0,0 +1,24 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Map Interactions + + Parameter(s): + None + + Returns: + None +*/ + + +GVAR(MapControls) = []; +GVAR(ContextMenuEntries) = false call CFUNC(createNamespace); +GVAR(CurrentContextPosition) = []; + +[{ + ((findDisplay 12) displayCtrl 51) call FUNC(registerMapControl); +}, {!(isNull ((findDisplay 12) displayCtrl 51))}] call CFUNC(waitUntil); diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf new file mode 100644 index 00000000..cb967d8a --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf @@ -0,0 +1,48 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Handles a mouse button click event + + Parameter(s): + 0: Control + 1: Mouse button + 2: Mouse x position + 3: Mouse y position + 4: shift state + 5: ctrl state + 6: alt state + + Returns: + None +*/ + + +params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"]; + +if (!isNull (_control getVariable [QGVAR(ContextMenuGroup), controlNull])) then { + ctrlDelete (_control getVariable [QGVAR(ContextMenuGroup), controlNull]); + [ + QGVAR(CursorMarker) + ] call CFUNC(removeMapGraphicsGroup); + GVAR(CurrentContextPosition) = []; +}; + +if (_button == 1) then { + GVAR(CurrentContextPosition) = _control ctrlMapScreenToWorld [_xPos, _yPos]; + [ + QGVAR(CursorMarker), + [ + ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [0, 0, 0, 0.7], GVAR(CurrentContextPosition), 22, 22], + ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [1, 1, 1, 1], GVAR(CurrentContextPosition), 20, 20] + ] + ] call CFUNC(addMapGraphicsGroup); + + [_control, "", _xPos, _yPos] call FUNC(openContextMenu); + +}; + +true; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf new file mode 100644 index 00000000..311a3e55 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf @@ -0,0 +1,107 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Opens a specific context menu + + Parameter(s): + 0: map control + 1: menu id ("") + 2: screen x position (-1) + 3: screen y position (-1) + + Returns: + None +*/ +params ["_mapControl", ["_menuId", ""], ["_xPos", -1], ["_yPos", -1]]; +private _display = ctrlParent _mapControl; +private _contextMenuGrp = _mapControl getVariable [QGVAR(ContextMenuGroup), controlNull]; +private _contextMenuBackground = controlNull; +private _animDirection = 1; +if (isNull _contextMenuGrp) then { + _contextMenuGrp = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1]; + _contextMenuGrp ctrlAddEventHandler ["Unload", { + GVAR(CurrentContextPosition) = []; + [ + QGVAR(CursorMarker) + ] call CFUNC(removeMapGraphicsGroup); + }]; + _contextMenuBackground = _display ctrlCreate ["RscPicture", -1, _contextMenuGrp]; + _xPos = _xPos+PX(2); + _contextMenuGrp ctrlSetPosition [_xPos, _yPos, CTXMENU_WIDTH, 0]; + _contextMenuGrp ctrlCommit 0; + _contextMenuGrp setVariable ["mapControl", _mapControl]; + _contextMenuGrp setVariable ["history", []]; +} else { + _contextMenuBackground = _contextMenuGrp getVariable ["background", _contextMenuBackground]; + // Calculate Position + private _pos = ctrlPosition _contextMenuGrp; + _xPos = _pos select 0; + _yPos = (_pos select 1) + (_pos select 3)/2; + private _history = _contextMenuGrp getVariable ["history", []]; + private _contextMenuItemsGrp = _contextMenuGrp getVariable ["contextMenuItemsGroup", controlNull]; + private _currentMenuId = _contextMenuItemsGrp getVariable ["menuId", ""]; + private _c = _history find _menuId; + if (_c >= 0) then { // Go back + _history resize _c; + _animDirection = -1; + } else { // Go forward + _history pushBack _currentMenuId; + }; + + _contextMenuItemsGrp ctrlSetPosition [-_animDirection*CTXMENU_WIDTH, 0]; + _contextMenuItemsGrp ctrlCommit 0.2; + [{ + ctrlDelete _this; + }, 0.2, _contextMenuItemsGrp] call CFUNC(wait); + + _contextMenuGrp setVariable ["history", _history]; +}; + + +private _contextMenuItemsGrp = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1, _contextMenuGrp]; +_contextMenuItemsGrp ctrlCommit 0; +_contextMenuItemsGrp setVariable ["currentPosition", [0, 0]]; +_contextMenuItemsGrp setVariable ["currentSize", [CTXMENU_WIDTH, 0]]; +_contextMenuItemsGrp setVariable ["menuId", _menuId]; +_contextMenuItemsGrp setVariable ["mapControl", _mapControl]; + +_contextMenuGrp setVariable ["contextMenuItemsGroup", _contextMenuItemsGrp]; + +private _nbrElements = { + _x params ["_type", "_arguments"]; + if (_type == "header") then { + [_contextMenuItemsGrp, _arguments] call FUNC(buildHeaderElement); + }; + if (_type == "list") then { + [_contextMenuItemsGrp, _arguments] call FUNC(buildListElement); + }; + if (_type == "label") then { + [_contextMenuItemsGrp, _arguments] call FUNC(buildLabelElement); + }; + if (_type == "imageStackButton") then { + [_contextMenuItemsGrp, _arguments] call FUNC(buildImageStackButton); + }; + + true; +} count (GVAR(ContextMenuEntries) getVariable ["ContextMenu_" + _menuId, []]); + +private _currentSize = _contextMenuItemsGrp getVariable ["currentSize", [0, 0]]; + +_contextMenuBackground ctrlSetText "#(argb,8,8,3)color(0.2,0.2,0.2,0.6)"; +_contextMenuBackground ctrlSetPosition [0, 0, _currentSize select 0, _currentSize select 1]; +_contextMenuBackground ctrlCommit 0; + +_contextMenuGrp ctrlSetPosition [_xPos, _yPos-(_currentSize select 1)/2, _currentSize select 0, _currentSize select 1]; +_contextMenuGrp ctrlCommit 0.2; + +_contextMenuItemsGrp ctrlSetPosition [_animDirection*(_currentSize select 0), 0, _currentSize select 0, _currentSize select 1]; +_contextMenuItemsGrp ctrlCommit 0; +_contextMenuItemsGrp ctrlSetPosition [0, 0]; +_contextMenuItemsGrp ctrlCommit 0.2; + +_mapControl setVariable [QGVAR(ContextMenuGroup), _contextMenuGrp]; +_contextMenuGrp setVariable ["background", _contextMenuBackground]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf new file mode 100644 index 00000000..0ada7af2 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf @@ -0,0 +1,28 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Registers a Map Control for MapGraphics + + Parameter(s): + 0: Map + + Returns: + None +*/ +params ["_map"]; +// make sure that the control not already have a draw function +if (_map in GVAR(MapControls)) exitWith {nil}; + +private _mcEHId = _map ctrlAddEventHandler ["MouseButtonClick", {_this call FUNC(mouseButtonClick);[QGVAR(MouseButtonClick), _this] call CFUNC(localEvent);}]; +private _mdcEHId = _map ctrlAddEventHandler ["MouseButtonDblClick", {[QGVAR(MouseButtonDblClick), _this] call CFUNC(localEvent);}]; + +_map setVariable [QGVAR(MouseButtonClickEHId), _mcEHId]; +_map setVariable [QGVAR(MouseButtonDblClickEHId), _mdcEHId]; + +GVAR(MapControls) pushBackUnique _map; + +nil diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/macros.hpp b/serverAddons/AAW/addons/AAW_Server/MapInteractions/macros.hpp new file mode 100644 index 00000000..fbb21665 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/macros.hpp @@ -0,0 +1,4 @@ +#define MODULE MapInteractions +#include "\tc\AAW\addons\AAW_Server\macros.hpp" +#define ITEM_HEIGHT PY(3) +#define CTXMENU_WIDTH PX(16) diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp b/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp new file mode 100644 index 00000000..b1c27d16 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp @@ -0,0 +1,19 @@ +class CfgMapMarker { + persistance = 300; // Marker persistance in seconds + blendoutTime = 60; // How long it takes to blend out the marker; + class EnemyUnits { + name = ""; + class Infantery { + name = "Infantery"; + icons[] = {{"A3\ui_f\data\map\markers\nato\o_inf.paa", 1, {0.6, 0, 0, 1}}}; + }; + class MechInf { + name = "Mechanized Infantery"; + icons[] = {{"A3\ui_f\data\map\markers\nato\o_mech_inf.paa", 1, {0.6, 0, 0, 1}}}; + }; + class Armored { + name = "Armored"; + icons[] = {{"A3\ui_f\data\map\markers\nato\o_armor.paa", 1, {0.6, 0, 0, 1}}}; + }; + }; +}; diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf new file mode 100644 index 00000000..12f08bae --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf @@ -0,0 +1,85 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Map Marker + + Parameter(s): + None + + Returns: + None +*/ + +["", "list", ["Marker", [{ + params ["_contextMenuGrp"]; + private _mapControl = _contextMenuGrp getVariable ["mapControl", controlNull]; + [_mapControl, QUOTE(MODULE)] call EFUNC(MapInteractions,openContextMenu); + false; +},[]]]] call EFUNC(MapInteractions,addMenuEntry); + +GVAR(persistance) = [CFGMARKER + "/persistance", 300] call CFUNC(getSetting); +GVAR(blendoutTime) = [CFGMARKER + "/blendoutTime", 60] call CFUNC(getSetting); + +[QUOTE(MODULE), "header", ["Marker"]] call EFUNC(MapInteractions,addMenuEntry); + +{ + private _categorySetting = CFGMARKER+"/"+_x; + { + private _markerSetting = _categorySetting + "/" + _x; + private _icons = +([_markerSetting + "/icons", []] call CFUNC(getSetting)); + { + _x set [1, 0.6*(_x select 1)]; + true; + } count _icons; + [QUOTE(MODULE), "imageStackButton", [_icons, [{ + params ["_currentCtxMenu", "_attributes"]; + _attributes params ["_type"]; + private _mapMarkerPosition = EGVAR(MapInteractions,CurrentContextPosition); + if (_mapMarkerPosition isEqualTo []) exitWith {}; + ["createMarker", [_type, _mapMarkerPosition, CLib_player, serverTime]] call CFUNC(serverEvent); + true; + },[_markerSetting]]]] call EFUNC(MapInteractions,addMenuEntry); + true; + } count ([_categorySetting] call CFUNC(getSettingSubClasses)); + true; +} count ([CFGMARKER] call CFUNC(getSettingSubClasses)); + +["markerUpdated", { + [] call FUNC(updateMarker); +}] call CFUNC(addEventhandler); + +[QEGVAR(MapInteractions,MouseButtonDblClick), { + (_this select 0) params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"]; + + GVAR(timeout) = time + 2; + + [{}, { + private _nbrClosed = { + if (ctrlIDD _x == 54 && !isNull _x) then { + _x closeDisplay 0; + true; + } else { + false; + }; + } count (uiNamespace getVariable "GUI_displays"); + _nbrClosed > 0 || GVAR(timeout) < time; + }] call CFUNC(waitUntil); + + if (_button == 0) then { + EGVAR(MapInteractions,CurrentContextPosition) = _control ctrlMapScreenToWorld [_xPos, _yPos]; + [ + QEGVAR(MapInteractions,CursorMarker), + [ + ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [0, 0, 0, 0.7], EGVAR(MapInteractions,CurrentContextPosition), 22, 22], + ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [1, 1, 1, 1], EGVAR(MapInteractions,CurrentContextPosition), 20, 20] + ] + ] call CFUNC(addMapGraphicsGroup); + + [_control, QUOTE(MODULE), _xPos, _yPos] call EFUNC(MapInteractions,openContextMenu); + + }; +}] call CFUNC(addEventhandler); diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_createMapMarker.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_createMapMarker.sqf new file mode 100644 index 00000000..80743257 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_createMapMarker.sqf @@ -0,0 +1,41 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Create a Map Marker (server side function) + + Parameter(s): + None + + Returns: + None +*/ +params ["_type", "_position", "_owner", "_time"]; +private _side = sideUnknown; +private _ownerId = str _owner; +private _group = grpNull; +if (_owner isEqualType sideUnknown) then { + _side = _owner; +} else { + _side = side _owner; + _group = group _owner; + if (_owner in allPlayers) then { + _ownerId = getPlayerUID _owner; + }; +}; + +private _id = format ["%1_%2_%3_%4", _side, _type, _position, _ownerId]; + +private _markerNamespaceName = QGVAR(allMarker_) + str _side; +private _markerNamespace = missionNamespace getVariable [_markerNamespaceName, objNull]; +if (isNull _markerNamespace) then { + _markerNamespace = true call CFUNC(createNamespace); + missionNamespace setVariable [_markerNamespaceName, _markerNamespace]; +}; + +private _markerData = [_type, _position, _time, [_owner] call CFUNC(name), _ownerId, _owner, _group, _side]; +_markerNamespace setVariable [_id, _markerData, true]; +["markerUpdated", _side, [_id, _markerData]] call CFUNC(targetEvent); diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_serverInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_serverInit.sqf new file mode 100644 index 00000000..4fbb5ab1 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_serverInit.sqf @@ -0,0 +1,19 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Server Init of Map Marker System + + Parameter(s): + None + + Returns: + None +*/ + +["createMarker", { + (_this select 0) call FUNC(createMapMarker); +}] call CFUNC(addEventhandler); diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf new file mode 100644 index 00000000..7ed601e2 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf @@ -0,0 +1,58 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Updates all Map Marker (client side function) + + Parameter(s): + None + + Returns: + None +*/ + +private _markerNamespaceName = QGVAR(allMarker_) + str side group CLib_player; +private _markerNamespace = missionNamespace getVariable [_markerNamespaceName, objNull]; + +if (isNull _markerNamespace) exitWith {}; + +{ + private _markerName = _x; + private _markerData = _markerNamespace getVariable [_markerName, []]; + if (_markerData isEqualTo []) then { + [_markerName] call CFUNC(removeMapGraphicsGroup); + } else { + _markerData params ["_type", "_position"]; + private _icons = +([_type + "/icons", []] call CFUNC(getSetting)); + private _mapGraphicsIcons = _icons apply { + ["ICON", _x select 0, _x select 2, _position, 25, 25, 0, "", 0, 0.08, "RobotoCondensed", "right", { + private _markerNamespaceName = QGVAR(allMarker_) + str side group CLib_player; + private _markerNamespace = missionNamespace getVariable [_markerNamespaceName, objNull]; + if (isNull _markerNamespace) exitWith {}; + private _markerData = _markerNamespace getVariable [_groupId, []]; + if (_markerData isEqualTo []) exitWith { + [{ + LOG("Remove MapMarker (No MapMarker data):" + _groupId); + [_this] call CFUNC(removeMapGraphicsGroup); + }, _groupId] call CFUNC(execNextFrame); + _color = [0, 0, 0, 0]; + }; + _markerData params ["_type", "_position", "_time"]; + if ((serverTime - _time) > GVAR(persistance)) then { + private _alpha = 0 max (1-((serverTime - _time) - GVAR(persistance))/GVAR(blendoutTime)); + _color set [3, _alpha]; + if (_alpha == 0) then { + [{ + LOG("Remove MapMarker (timeout): " + _groupId); + [_this] call CFUNC(removeMapGraphicsGroup); + }, _groupId] call CFUNC(execNextFrame); + }; + }; + }]; + }; + [_markerName, _mapGraphicsIcons] call CFUNC(addMapGraphicsGroup); + }; +} count (allVariables _markerNamespace); diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp b/serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp new file mode 100644 index 00000000..f4006537 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp @@ -0,0 +1,3 @@ +#define MODULE MapMarker +#include "\tc\AAW\addons\AAW_Server\macros.hpp" +#define CFGMARKER QUOTE(PREFIX/CfgMapMarker) diff --git a/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf index bb578dbb..5c92a2f4 100644 --- a/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf @@ -128,6 +128,7 @@ if (side CLib_player == sideLogic && {CLib_player isKindOf "VirtualSpectator_F"} // Register the map for the marker system [_display displayCtrl 800] call CFUNC(registerMapControl); [_display, [-PX(40), 0]] call EFUNC(Common,registerDisplayNotification); + [_display displayCtrl 800] call EFUNC(MapInteractions,registerMapControl); if (!(alive CLib_Player) || (CLib_Player getVariable [QEGVAR(Common,tempUnit), false])) then { // Catch the escape key