Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map interactions #625

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions serverAddons/AAW/addons/AAW_Server/AAW.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
23 changes: 23 additions & 0 deletions serverAddons/AAW/addons/AAW_Server/CfgCLibModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand Down
1 change: 1 addition & 0 deletions serverAddons/AAW/addons/AAW_Server/CfgClibSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class CfgCLibSettings {
aaw_cfgSides[] = {"AAW", "Sides"};
aaw_cfgGroupTypes[] = {"AAW", "CfgGroupTypes"};
aaw_cfgRespawn[] = {"AAW", "CfgRespawn"};
aaw_cfgMapMarker[] = {"AAW", "CfgMapMarker"};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "macros.hpp"
/*
Arma At War - AAW

Author: BadGuy

Description:
Adds a Context Menu Entry

Parameter(s):
0: Map <Control>

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include "macros.hpp"
/*
Arma At War - AAW

Author: BadGuy

Description:
Builds a Header element

Parameter(s):
0: Context Menu Group <Control>
1: Element specific arguments <Array>
0: Text <String>

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)]];
Original file line number Diff line number Diff line change
@@ -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 <Control>
1: Element specific arguments <Array>
0: Images <Array>
0: Image Path <String>
1: relative size (1) <Number>
2: color ([1, 1, 1, 1]) <Array>
1: button action <Array>
0: Code <Code> // if Code returns false, menu will close
1: custom arguments ([]) <Array>

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)]];
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "macros.hpp"
/*
Arma At War - AAW

Author: BadGuy

Description:
Builds a label element

Parameter(s):
0: Context Menu Group <Control>
1: Element specific arguments <Array>
0: Text <String>

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)]];
Loading