From b2093b8cbcca57aff49802dcdb199d326675ef72 Mon Sep 17 00:00:00 2001 From: Simon Reuter Date: Fri, 18 Aug 2017 21:28:49 +0200 Subject: [PATCH 1/5] first draft of MapInteractions-system (map context menu) --- .../AAW/addons/AAW_Server/CfgCLibModules.hpp | 20 + .../MapInteractions/fn_addMenuEntry.sqf | 22 + .../MapInteractions/fn_buildHeaderElement.sqf | 99 +++++ .../fn_buildImageStackButton.sqf | 104 +++++ .../MapInteractions/fn_buildLabelElement.sqf | 37 ++ .../MapInteractions/fn_buildListElement.sqf | 84 ++++ .../MapInteractions/fn_clientInit.sqf | 377 ++++++++++++++++++ .../MapInteractions/fn_mouseButtonClick.sqf | 47 +++ .../MapInteractions/fn_openContextMenu.sqf | 108 +++++ .../MapInteractions/fn_registerMapControl.sqf | 26 ++ .../AAW_Server/MapInteractions/macros.hpp | 4 + .../AAW_Server/MapMarker/fn_clientInit.sqf | 36 ++ .../addons/AAW_Server/MapMarker/macros.hpp | 2 + .../AAW_Server/RespawnUI/fn_clientInit.sqf | 1 + 14 files changed, 967 insertions(+) create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_addMenuEntry.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildHeaderElement.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildLabelElement.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapInteractions/macros.hpp create mode 100644 serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp diff --git a/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp b/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp index b644f379..6663a8e0 100644 --- a/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp +++ b/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp @@ -148,6 +148,26 @@ 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); + }; + // Mortar MODULE(Mortar) { dependency[] = {"AAW/Common"}; 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..1ff49c3f --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf @@ -0,0 +1,104 @@ +#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 { + 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..f3ed6a75 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf @@ -0,0 +1,84 @@ +#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 { + 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..53a246e8 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf @@ -0,0 +1,377 @@ +#include "macros.hpp" +/* + Arma At War - AAW + + Author: BadGuy + + Description: + Map Interactions + + Parameter(s): + None + + Returns: + None +*/ +#define ITEM_HEIGHT PY(3) +#define CTXMENU_WIDTH PX(16) + +GVAR(MapControls) = []; +GVAR(ContextMenuEntries) = false call CFUNC(createNamespace); + +[{ + ((findDisplay 12) displayCtrl 51) call FUNC(registerMapControl); +}, {!(isNull ((findDisplay 12) displayCtrl 51))}] call CFUNC(waitUntil); + +DFUNC(buildLabelElement) = { + 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)]]; +}; + +DFUNC(buildImageStackButton) = { + 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 { + 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)]]; +}; + +DFUNC(buildHeaderElement) = { + 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)]]; +}; + +DFUNC(buildListElement) = { + 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 { + 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)]]; +}; + +DFUNC(openContextMenu) = { + 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", { + [ + 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; + hint ("remove from history: " + str _history); + } else { // Go forward + _history pushBack _currentMenuId; + hint ("add to history: " + str _history); + }; + + _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_mouseButtonClick.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf new file mode 100644 index 00000000..24a9e1f7 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf @@ -0,0 +1,47 @@ +#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); +}; + +if (_button == 1) then { + + [ + QGVAR(CursorMarker), + [ + ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [0, 0, 0, 0.7], _control ctrlMapScreenToWorld [_xPos, _yPos], 22, 22], + ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [1, 1, 1, 1], _control ctrlMapScreenToWorld [_xPos, _yPos], 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..fa271e33 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf @@ -0,0 +1,108 @@ +#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", { + [ + 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; + hint ("remove from history: " + str _history); + } else { // Go forward + _history pushBack _currentMenuId; + hint ("add to history: " + str _history); + }; + + _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..20e4736b --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf @@ -0,0 +1,26 @@ +#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)}]; + +_map setVariable [QGVAR(MouseButtonClickEHId), _mcEHId]; + +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/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf new file mode 100644 index 00000000..151cabfe --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf @@ -0,0 +1,36 @@ +#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); + +[QUOTE(MODULE), "header", ["Marker"]] call EFUNC(MapInteractions,addMenuEntry); + +[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\o_inf.paa", 0.6, [0.6, 0, 0, 1]]], [{ +},[]]]] call EFUNC(MapInteractions,addMenuEntry); + +[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\b_mech_inf.paa", 0.6, [0.6, 0, 0, 1]]], [{ +},[]]]] call EFUNC(MapInteractions,addMenuEntry); + +[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\b_mech_inf.paa", 0.6, [0.6, 0, 0, 1]]], [{ +},[]]]] call EFUNC(MapInteractions,addMenuEntry); + +[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\b_armor.paa", 0.6, [0.6, 0, 0, 1]]], [{ +},[]]]] call EFUNC(MapInteractions,addMenuEntry); 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..8ed84117 --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp @@ -0,0 +1,2 @@ +#define MODULE MapMarker +#include "\tc\AAW\addons\AAW_Server\macros.hpp" diff --git a/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf index 97c06e98..155948b3 100644 --- a/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/RespawnUI/fn_clientInit.sqf @@ -124,6 +124,7 @@ // 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 From b398e2b1899ae3d885bbd95a91a4df8fba66c28e Mon Sep 17 00:00:00 2001 From: Simon Reuter Date: Sat, 19 Aug 2017 00:33:21 +0200 Subject: [PATCH 2/5] removed unnecessary code --- .../MapInteractions/fn_clientInit.sqf | 356 +----------------- 1 file changed, 1 insertion(+), 355 deletions(-) diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf index 53a246e8..4a5f149a 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf @@ -13,8 +13,7 @@ Returns: None */ -#define ITEM_HEIGHT PY(3) -#define CTXMENU_WIDTH PX(16) + GVAR(MapControls) = []; GVAR(ContextMenuEntries) = false call CFUNC(createNamespace); @@ -22,356 +21,3 @@ GVAR(ContextMenuEntries) = false call CFUNC(createNamespace); [{ ((findDisplay 12) displayCtrl 51) call FUNC(registerMapControl); }, {!(isNull ((findDisplay 12) displayCtrl 51))}] call CFUNC(waitUntil); - -DFUNC(buildLabelElement) = { - 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)]]; -}; - -DFUNC(buildImageStackButton) = { - 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 { - 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)]]; -}; - -DFUNC(buildHeaderElement) = { - 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)]]; -}; - -DFUNC(buildListElement) = { - 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 { - 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)]]; -}; - -DFUNC(openContextMenu) = { - 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", { - [ - 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; - hint ("remove from history: " + str _history); - } else { // Go forward - _history pushBack _currentMenuId; - hint ("add to history: " + str _history); - }; - - _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]; - -}; From ad82cec08e91a8b67d23e92b2e553abdfbe528ba Mon Sep 17 00:00:00 2001 From: Simon Reuter Date: Sun, 20 Aug 2017 16:29:34 +0200 Subject: [PATCH 3/5] some work on the mapmarker system --- serverAddons/AAW/addons/AAW_Server/AAW.hpp | 1 + .../AAW/addons/AAW_Server/CfgCLibModules.hpp | 3 + .../AAW/addons/AAW_Server/CfgClibSettings.hpp | 1 + .../fn_buildImageStackButton.sqf | 4 ++ .../MapInteractions/fn_buildListElement.sqf | 4 ++ .../MapInteractions/fn_clientInit.sqf | 1 + .../MapInteractions/fn_mouseButtonClick.sqf | 7 ++- .../MapInteractions/fn_openContextMenu.sqf | 1 + .../MapInteractions/fn_registerMapControl.sqf | 4 +- .../AAW_Server/MapMarker/cfgMapMarker.hpp | 17 +++++ .../AAW_Server/MapMarker/fn_clientInit.sqf | 62 ++++++++++++++++--- .../MapMarker/fn_createMapMarker.sqf | 41 ++++++++++++ .../AAW_Server/MapMarker/fn_serverInit.sqf | 19 ++++++ .../AAW_Server/MapMarker/fn_updateMarker.sqf | 61 ++++++++++++++++++ .../addons/AAW_Server/MapMarker/macros.hpp | 1 + 15 files changed, 215 insertions(+), 12 deletions(-) create mode 100644 serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp create mode 100644 serverAddons/AAW/addons/AAW_Server/MapMarker/fn_createMapMarker.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapMarker/fn_serverInit.sqf create mode 100644 serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf 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 6663a8e0..b0f1be7d 100644 --- a/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp +++ b/serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp @@ -166,6 +166,9 @@ class CfgCLibModules { MODULE(MapMarker) { dependency[] = {"AAW/Common", "AAW/MapInteractions"}; FNC(clientInit); + FNC(serverInit); + FNC(createMapMarker); + FNC(updateMarker); }; // Mortar 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_buildImageStackButton.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf index 1ff49c3f..08a57342 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildImageStackButton.sqf @@ -79,6 +79,10 @@ _itemActiveArea ctrlAddEventHandler ["ButtonClick", { 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; }; }]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf index f3ed6a75..28740886 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_buildListElement.sqf @@ -67,6 +67,10 @@ _itemActiveArea ctrlAddEventHandler ["ButtonClick", { 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; }; }]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf index 4a5f149a..338de14c 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_clientInit.sqf @@ -17,6 +17,7 @@ GVAR(MapControls) = []; GVAR(ContextMenuEntries) = false call CFUNC(createNamespace); +GVAR(CurrentContextPosition) = []; [{ ((findDisplay 12) displayCtrl 51) call FUNC(registerMapControl); diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf index 24a9e1f7..cb967d8a 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_mouseButtonClick.sqf @@ -28,15 +28,16 @@ if (!isNull (_control getVariable [QGVAR(ContextMenuGroup), controlNull])) then [ 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], _control ctrlMapScreenToWorld [_xPos, _yPos], 22, 22], - ["ICON", "a3\ui_f\data\map\mapcontrol\waypointeditor_ca.paa", [1, 1, 1, 1], _control ctrlMapScreenToWorld [_xPos, _yPos], 20, 20] + ["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); diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf index fa271e33..f53be890 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf @@ -24,6 +24,7 @@ private _animDirection = 1; if (isNull _contextMenuGrp) then { _contextMenuGrp = _display ctrlCreate ["RscControlsGroupNoScrollbars", -1]; _contextMenuGrp ctrlAddEventHandler ["Unload", { + GVAR(CurrentContextPosition) = []; [ QGVAR(CursorMarker) ] call CFUNC(removeMapGraphicsGroup); diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf index 20e4736b..0ada7af2 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_registerMapControl.sqf @@ -17,9 +17,11 @@ 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)}]; +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; 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..36c7798c --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp @@ -0,0 +1,17 @@ +class CfgMapMarker { + 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 index 151cabfe..816e5a77 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf @@ -23,14 +23,60 @@ [QUOTE(MODULE), "header", ["Marker"]] call EFUNC(MapInteractions,addMenuEntry); -[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\o_inf.paa", 0.6, [0.6, 0, 0, 1]]], [{ -},[]]]] 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)); -[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\b_mech_inf.paa", 0.6, [0.6, 0, 0, 1]]], [{ -},[]]]] call EFUNC(MapInteractions,addMenuEntry); +["markerUpdated", { + [] call FUNC(updateMarker); +}] call CFUNC(addEventhandler); -[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\b_mech_inf.paa", 0.6, [0.6, 0, 0, 1]]], [{ -},[]]]] call EFUNC(MapInteractions,addMenuEntry); +[QEGVAR(MapInteractions,MouseButtonDblClick), { + (_this select 0) params ["_control", "_button", "_xPos", "_yPos", "_shift", "_ctrl", "_alt"]; -[QUOTE(MODULE), "imageStackButton", [[["A3\ui_f\data\map\markers\nato\b_armor.paa", 0.6, [0.6, 0, 0, 1]]], [{ -},[]]]] call EFUNC(MapInteractions,addMenuEntry); + 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..a024599f --- /dev/null +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf @@ -0,0 +1,61 @@ +#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, []]; + DUMP(_markerData); + 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) > 30) then { + private _alpha = 0 max ((serverTime - _time) - 30)/60; + _color set [3, _alpha]; + if (_alpha == 0) then { + [{ + LOG("Remove MapMarker (timeout): " + _groupId); + [_this] call CFUNC(removeMapGraphicsGroup); + }, _groupId] call CFUNC(execNextFrame); + }; + }; + }]; + }; + DUMP(_markerName); + DUMP(_mapGraphicsIcons); + [_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 index 8ed84117..f4006537 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/macros.hpp @@ -1,2 +1,3 @@ #define MODULE MapMarker #include "\tc\AAW\addons\AAW_Server\macros.hpp" +#define CFGMARKER QUOTE(PREFIX/CfgMapMarker) From fffdf3843076284b553ead654b7674838b5f2c6b Mon Sep 17 00:00:00 2001 From: Simon Reuter Date: Sun, 20 Aug 2017 16:57:10 +0200 Subject: [PATCH 4/5] added configurable persistance time for marker removed some dumps --- .../AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp | 2 ++ .../AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf | 3 +++ .../AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf | 7 ++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp b/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp index 36c7798c..b1c27d16 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/cfgMapMarker.hpp @@ -1,4 +1,6 @@ class CfgMapMarker { + persistance = 300; // Marker persistance in seconds + blendoutTime = 60; // How long it takes to blend out the marker; class EnemyUnits { name = ""; class Infantery { diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf index 816e5a77..2c8ceebb 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf @@ -21,6 +21,9 @@ false; },[]]]] call EFUNC(MapInteractions,addMenuEntry); +GVAR(persistance) = ([CFGMARKER + "/persistance", []] call CFUNC(getSetting)); +GVAR(blendoutTime) = ([CFGMARKER + "/blendoutTime", []] call CFUNC(getSetting)); + [QUOTE(MODULE), "header", ["Marker"]] call EFUNC(MapInteractions,addMenuEntry); { diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf index a024599f..7ed601e2 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_updateMarker.sqf @@ -33,7 +33,6 @@ if (isNull _markerNamespace) exitWith {}; private _markerNamespace = missionNamespace getVariable [_markerNamespaceName, objNull]; if (isNull _markerNamespace) exitWith {}; private _markerData = _markerNamespace getVariable [_groupId, []]; - DUMP(_markerData); if (_markerData isEqualTo []) exitWith { [{ LOG("Remove MapMarker (No MapMarker data):" + _groupId); @@ -42,8 +41,8 @@ if (isNull _markerNamespace) exitWith {}; _color = [0, 0, 0, 0]; }; _markerData params ["_type", "_position", "_time"]; - if ((serverTime - _time) > 30) then { - private _alpha = 0 max ((serverTime - _time) - 30)/60; + 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 { [{ @@ -54,8 +53,6 @@ if (isNull _markerNamespace) exitWith {}; }; }]; }; - DUMP(_markerName); - DUMP(_mapGraphicsIcons); [_markerName, _mapGraphicsIcons] call CFUNC(addMapGraphicsGroup); }; } count (allVariables _markerNamespace); From d279ba17115218e054572f78beeba13803cf3f26 Mon Sep 17 00:00:00 2001 From: Simon Reuter Date: Sun, 20 Aug 2017 17:01:28 +0200 Subject: [PATCH 5/5] fixed default values for persistancy settings removed debug hints --- .../addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf | 2 -- .../AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf index f53be890..311a3e55 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapInteractions/fn_openContextMenu.sqf @@ -48,10 +48,8 @@ if (isNull _contextMenuGrp) then { if (_c >= 0) then { // Go back _history resize _c; _animDirection = -1; - hint ("remove from history: " + str _history); } else { // Go forward _history pushBack _currentMenuId; - hint ("add to history: " + str _history); }; _contextMenuItemsGrp ctrlSetPosition [-_animDirection*CTXMENU_WIDTH, 0]; diff --git a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf index 2c8ceebb..12f08bae 100644 --- a/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf +++ b/serverAddons/AAW/addons/AAW_Server/MapMarker/fn_clientInit.sqf @@ -21,8 +21,8 @@ false; },[]]]] call EFUNC(MapInteractions,addMenuEntry); -GVAR(persistance) = ([CFGMARKER + "/persistance", []] call CFUNC(getSetting)); -GVAR(blendoutTime) = ([CFGMARKER + "/blendoutTime", []] call CFUNC(getSetting)); +GVAR(persistance) = [CFGMARKER + "/persistance", 300] call CFUNC(getSetting); +GVAR(blendoutTime) = [CFGMARKER + "/blendoutTime", 60] call CFUNC(getSetting); [QUOTE(MODULE), "header", ["Marker"]] call EFUNC(MapInteractions,addMenuEntry);