From bddf74cbb47c60a2c78918a9794377eeb56967e6 Mon Sep 17 00:00:00 2001 From: Joko Date: Tue, 18 Aug 2020 19:44:16 +0200 Subject: [PATCH] Map Gestures - Add Briefingscreen support, Different Camera Range, Improve Responsiveness, and Toggles for Curators and Spectators Maps (#7782) * Add Variable Range for Camera Users (Zeus, Spectator) + Settings Add Setting to Disable Zeus and/or Spectator Map Draws Add Ability to use Map Gestures on Briefing screen Add Setting for Briefing Screen mode (All, Only Group, Only Side, Proximity, Disabled) * disable DISABLE_COMPILE_CACHE * minor cleanup and add some translations Co-authored-by: PabstMirror --- addons/map_gestures/CfgEventHandlers.hpp | 7 +- .../functions/fnc_drawMapGestures.sqf | 8 +- .../functions/fnc_getProximityPlayers.sqf | 52 ++++++--- .../functions/fnc_initDisplayCurator.sqf | 5 +- .../functions/fnc_initDisplayDiary.sqf | 21 ++-- .../functions/fnc_initDisplaySpectator.sqf | 7 +- addons/map_gestures/initSettings.sqf | 35 +++++- addons/map_gestures/stringtable.xml | 100 +++++++++++++++--- 8 files changed, 184 insertions(+), 51 deletions(-) diff --git a/addons/map_gestures/CfgEventHandlers.hpp b/addons/map_gestures/CfgEventHandlers.hpp index efe179abce..4a54dffabe 100644 --- a/addons/map_gestures/CfgEventHandlers.hpp +++ b/addons/map_gestures/CfgEventHandlers.hpp @@ -23,7 +23,12 @@ class Extended_DisplayLoad_EventHandlers { class RscDisplayEGSpectator { ADDON = QUOTE((((_this select 0) displayCtrl ID_EG_MAP_CONTROL) controlsGroupCtrl ID_EG_MAP_CONTROLGROUP) call FUNC(initDisplaySpectator)); }; + class RscDiary { // for loading saves use uiNamespace because missionNamespace is not restored before map is loaded - ADDON = QUOTE(((_this select 0) displayCtrl ID_DIARY_MAP) call (uiNamespace getVariable 'DFUNC(initDisplayDiary)')); +#ifdef DISABLE_COMPILE_CACHE + ADDON = QUOTE(((_this select 0) displayCtrl ID_DIARY_MAP) call (missionNamespace getVariable [ARR_2('DFUNC(initDisplayDiary)', uiNamespace getVariable 'DFUNC(initDisplayDiary)')]);); +#else + ADDON = QUOTE(((_this select 0) displayCtrl ID_DIARY_MAP) call (uiNamespace getVariable 'DFUNC(initDisplayDiary)');); +#endif }; }; diff --git a/addons/map_gestures/functions/fnc_drawMapGestures.sqf b/addons/map_gestures/functions/fnc_drawMapGestures.sqf index 6fd210eb33..5afd9406b4 100644 --- a/addons/map_gestures/functions/fnc_drawMapGestures.sqf +++ b/addons/map_gestures/functions/fnc_drawMapGestures.sqf @@ -5,13 +5,13 @@ * * Arguments: * 0: Map Handle - * 1: Positions (objects or posAGLs) + * 1: Positions (objects or posAGLs) with render distance >> * * Return Value: * None * * Example: - * [findDisplay 12 displayCtrl 51, [player]] call ace_map_gestures_fnc_drawMapGestures + * [findDisplay 12 displayCtrl 51, [[player, 0]]] call ace_map_gestures_fnc_drawMapGestures * * Public: No */ @@ -29,10 +29,8 @@ BEGIN_COUNTER(draw); #define TEXT_SHADOW 0 if (!GVAR(enabled)) exitWith {}; - params ["_mapHandle", "_positions"]; - -private _players = [[_positions, GVAR(maxRange)], FUNC(getProximityPlayers), missionNamespace, QGVAR(proximityPlayersCache), 1] call EFUNC(common,cachedCall); +private _players = [_positions, FUNC(getProximityPlayers), missionNamespace, QGVAR(proximityPlayersCache), 1] call EFUNC(common,cachedCall); // Iterate over all nearby players and render their pointer if player is transmitting. { private _pos = _x getVariable QGVAR(pointPosition); diff --git a/addons/map_gestures/functions/fnc_getProximityPlayers.sqf b/addons/map_gestures/functions/fnc_getProximityPlayers.sqf index 400449310b..f687dfdfca 100644 --- a/addons/map_gestures/functions/fnc_getProximityPlayers.sqf +++ b/addons/map_gestures/functions/fnc_getProximityPlayers.sqf @@ -8,31 +8,49 @@ * 1: Range * * Return Value: - * All units in proximity > + * All units in proximity with Distances to render from >> * * Example: - * [[player], 7] call ace_map_gestures_fnc_getProximityPlayers + * [[[player, 6]]] call ace_map_gestures_fnc_getProximityPlayers * * Public: No */ -params ["_positions", "_range"]; - private _proximityPlayers = []; -{ - _proximityPlayers append (_x nearEntities [["CAMAnBase"], _range]); - if (_x isEqualType objNull) then { - _proximityPlayers append (crew vehicle _x); - }; -} forEach _positions; - -_proximityPlayers = _proximityPlayers arrayIntersect _proximityPlayers; - -_proximityPlayers = _proximityPlayers select { [_x, false] call EFUNC(common,isPlayer); }; - -if (GVAR(onlyShowFriendlys)) then { - _proximityPlayers = _proximityPlayers select { [side group ace_player, side _x] call BIS_fnc_areFriendly; }; +private _fnc_getProximitsPlayers = { + { + _x params ["_position", ["_range", GVAR(maxRange)]]; + private _temp = (_position nearEntities [["CAMAnBase"], _range]); + if (_position isEqualType objNull) then { + _temp append (crew vehicle _position); + if (GVAR(onlyShowFriendlys)) then { + _temp = _temp select { [side group _position, side _x] call BIS_fnc_areFriendly; }; + }; + }; + _proximityPlayers append _temp; + } forEach _this; }; +switch (_this) do { + case (0): { // All + _proximityPlayers append allUnits; + }; + case (1): { // Players in Group + _proximityPlayers append group ace_player; + }; + case (2): { // Players on Side + _proximityPlayers append (allUnits select {side (group _x) == side (group ace_player)}); + }; + case (3): { // Proximity + [[ace_player, GVAR(maxRange)]] call _fnc_getProximitsPlayers; + }; + case (4): {}; // Disabled + default { + _this call _fnc_getProximitsPlayers; + }; +}; + +_proximityPlayers = _proximityPlayers arrayIntersect _proximityPlayers; +_proximityPlayers = _proximityPlayers select { [_x, false] call EFUNC(common,isPlayer); }; _proximityPlayers diff --git a/addons/map_gestures/functions/fnc_initDisplayCurator.sqf b/addons/map_gestures/functions/fnc_initDisplayCurator.sqf index b85bf2401c..6d32273765 100644 --- a/addons/map_gestures/functions/fnc_initDisplayCurator.sqf +++ b/addons/map_gestures/functions/fnc_initDisplayCurator.sqf @@ -17,4 +17,7 @@ params ["_mapCtrl"]; TRACE_1("initDisplayCurator",_mapCtrl); -_mapCtrl ctrlAddEventHandler ["Draw", { [_this select 0, [ACE_player, positionCameraToWorld [0, 0, 0]]] call FUNC(drawMapGestures);}]; +_mapCtrl ctrlAddEventHandler ["Draw", { + if (!GVAR(allowCurator)) exitWith {}; + [_this select 0, [[ACE_player, GVAR(maxRange)], [positionCameraToWorld [0, 0, 0], GVAR(maxRangeCamera)]]] call FUNC(drawMapGestures); +}]; diff --git a/addons/map_gestures/functions/fnc_initDisplayDiary.sqf b/addons/map_gestures/functions/fnc_initDisplayDiary.sqf index 4fb4bc66a5..18c65e005a 100644 --- a/addons/map_gestures/functions/fnc_initDisplayDiary.sqf +++ b/addons/map_gestures/functions/fnc_initDisplayDiary.sqf @@ -17,39 +17,44 @@ params ["_mapCtrl"]; TRACE_1("initDisplayDiary",_mapCtrl); -_mapCtrl ctrlAddEventHandler ["Draw", { [_this select 0, [ACE_player]] call FUNC(drawMapGestures); }]; +_mapCtrl ctrlAddEventHandler ["Draw", { + if (!GVAR(enabled)) exitWith {}; + if (getClientStateNumber < 10) then { + [_this select 0, GVAR(briefingMode)] call FUNC(drawMapGestures); + } else { + [_this select 0, [[ACE_player, GVAR(maxRange)]]] call FUNC(drawMapGestures); + }; +}]; // MouseMoving EH. _mapCtrl ctrlAddEventHandler ["MouseMoving", { if (!GVAR(enabled)) exitWith {}; params ["_control", "_posX", "_posY"]; - private _position = _control ctrlMapScreenToWorld [_posX, _posY]; - GVAR(cursorPosition) = _position; + GVAR(cursorPosition) = _control ctrlMapScreenToWorld [_posX, _posY]; + // Don't transmit any data if we're using the map tools if (!GVAR(EnableTransmit) || {(["ace_maptools"] call EFUNC(common,isModLoaded)) && {EGVAR(maptools,mapTool_isDragging) || EGVAR(maptools,mapTool_isRotating)}}) exitWith {}; - if (_position distance2D (ACE_player getVariable [QGVAR(pointPosition), [0, 0, 0]]) >= 1) then { - [ACE_player, QGVAR(pointPosition), _position, GVAR(interval)] call EFUNC(common,setVariablePublic); + if (GVAR(cursorPosition) distance2D (ACE_player getVariable [QGVAR(pointPosition), [0, 0, 0]]) >= 1) then { + [ACE_player, QGVAR(pointPosition), GVAR(cursorPosition), GVAR(interval)] call EFUNC(common,setVariablePublic); }; }]; // MouseDown EH _mapCtrl ctrlAddEventHandler ["MouseButtonDown", { - if (getClientStateNumber < 10) exitWith {}; if (!GVAR(enabled)) exitWith {}; params ["", "_button", "_x", "_y", "_shift", "_ctrl", "_alt"]; if (_button == 0 && {[_shift, _ctrl, _alt] isEqualTo [false, false, false]}) then { GVAR(EnableTransmit) = true; + [ACE_player, QGVAR(pointPosition), GVAR(cursorPosition), GVAR(interval)] call EFUNC(common,setVariablePublic); }; }]; // MouseUp EH _mapCtrl ctrlAddEventHandler ["MouseButtonUp", { - if (getClientStateNumber < 10) exitWith {}; if (!GVAR(enabled)) exitWith {}; params ["", "_button"]; if (_button == 0) then { GVAR(EnableTransmit) = false; ACE_player setVariable [QGVAR(pointPosition), nil, true]; // Instantly transmit nil to stop drawing icon - GVAR(cursorPosition) = nil; }; }]; diff --git a/addons/map_gestures/functions/fnc_initDisplaySpectator.sqf b/addons/map_gestures/functions/fnc_initDisplaySpectator.sqf index 4582d6d6f5..20159b5e4a 100644 --- a/addons/map_gestures/functions/fnc_initDisplaySpectator.sqf +++ b/addons/map_gestures/functions/fnc_initDisplaySpectator.sqf @@ -18,15 +18,16 @@ params ["_mapCtrl"]; TRACE_1("initDisplaySpectator",_mapCtrl); _mapCtrl ctrlAddEventHandler ["Draw", { - private _targets = [positionCameraToWorld [0, 0, 0]]; + if (!GVAR(allowSpectator)) exitWith {}; + private _targets = [[positionCameraToWorld [0, 0, 0], GVAR(maxRangeCamera)]]; private _aceSpectatorFocus = missionNamespace getVariable [QEGVAR(spectator,camFocus), objNull]; if (!isNull _aceSpectatorFocus) then { - _targets pushback _aceSpectatorFocus; + _targets pushback [_aceSpectatorFocus, GVAR(maxRange)]; }; private _vanillaSpectatorFocus = uiNamespace getVariable ["RscEGSpectator_focus", objNull]; if (!isNull _vanillaSpectatorFocus) then { - _targets pushback _vanillaSpectatorFocus; + _targets pushback [_vanillaSpectatorFocus, GVAR(maxRange)]; }; [_this select 0, _targets] call FUNC(drawMapGestures); }]; diff --git a/addons/map_gestures/initSettings.sqf b/addons/map_gestures/initSettings.sqf index 8dd2361897..a53b7d9c1d 100644 --- a/addons/map_gestures/initSettings.sqf +++ b/addons/map_gestures/initSettings.sqf @@ -14,6 +14,35 @@ true ] call CBA_fnc_addSetting; +[ + QGVAR(maxRangeCamera), "SLIDER", + [LSTRING(maxRangeCamera_displayName), LSTRING(maxRangeCamera_description)], + LSTRING(mapGestures_category), + [0,50,14,1], + true +] call CBA_fnc_addSetting; + +[ + QGVAR(allowSpectator), "CHECKBOX", + [LSTRING(allowSpectator_displayName), LSTRING(allowSpectator_description)], + LSTRING(mapGestures_category), + true +] call CBA_fnc_addSetting; + +[ + QGVAR(allowCurator), "CHECKBOX", + [LSTRING(allowCurator_displayName), LSTRING(allowCurator_description)], + LSTRING(mapGestures_category), + true +] call CBA_fnc_addSetting; + +[ + QGVAR(briefingMode), "LIST", + [LSTRING(allowCurator_displayName), LSTRING(allowCurator_description)], + LSTRING(mapGestures_category), + [[0, 1, 2, 3, 4], [LSTRING(briefingMode_All), LSTRING(briefingMode_Group), LSTRING(briefingMode_Side), LSTRING(briefingMode_Proximity), LSTRING(briefingMode_Disabled)], 0] +] call CBA_fnc_addSetting; + [ QGVAR(onlyShowFriendlys), "CHECKBOX", @@ -34,7 +63,7 @@ [ QGVAR(nameTextColor), "COLOR", [LSTRING(nameTextColor_displayName), LSTRING(nameTextColor_description)], - LSTRING(mapGestures_category), + [LSTRING(mapGestures_category), LSTRING(mapGestures_subcategory_colors)], [0.2,0.2,0.2,0.3], false ] call CBA_fnc_addSetting; @@ -42,7 +71,7 @@ [ QGVAR(defaultLeadColor), "COLOR", [LSTRING(defaultLeadColor_displayName), LSTRING(defaultLeadColor_description)], - LSTRING(mapGestures_category), + [LSTRING(mapGestures_category), LSTRING(mapGestures_subcategory_colors)], [1,0.88,0,0.95], false ] call CBA_fnc_addSetting; @@ -50,7 +79,7 @@ [ QGVAR(defaultColor), "COLOR", [LSTRING(defaultColor_displayName), LSTRING(defaultColor_description)], - LSTRING(mapGestures_category), + [LSTRING(mapGestures_category), LSTRING(mapGestures_subcategory_colors)], [1,0.88,0,0.7], false ] call CBA_fnc_addSetting; diff --git a/addons/map_gestures/stringtable.xml b/addons/map_gestures/stringtable.xml index f02c0f091a..47cae3471e 100644 --- a/addons/map_gestures/stringtable.xml +++ b/addons/map_gestures/stringtable.xml @@ -66,19 +66,19 @@ Harita Hareketi Max Uzaklık - Max range between players to show the map gesture indicator [default: 7 meters] - Distância max. entre os jogadores para mostrar o indicador de gesto no mapa [padrão: 7 metros] - Maksymalny zasięg, w obrębie którego gesty będą widoczne dla graczy [domyślnie: 7 metrów] - Макс. дистанция между игроками для отображения жестов на карте [по-умолчанию: 7 метров] - Maximální vzdálenost mezi hráči pro zobrazení indikátoru ukázání v mapě [výchozí: 7 metrů] - Distanza massima tra giocatori per mostrare i gesti in mappa [default: 7 metri] - Maximale Reichweite zwischen Spielern um Kartenzeichen anzuzeigen (Standard: 7 Meter) - Máxima distancia a la cual pueden verse el indicador de gestos [defecto: 7 m] - Définit le rayon au-delà duquel les joueurs ne verront plus l'indicateur de pointage de leurs alliés. Valeur par défaut : 7 mètres. - プレイヤーによるマップ ジェスチャーの表示範囲を設定します [標準:7 メートル] - 플레이어간에 지도 신호 표시거리를 설정합니다. [기본: 7 미터] - 设定地图标识器显示的最大范围距离 [预设: 7公尺] - 設定地圖指示器顯示的最大範圍距離 [預設: 7公尺] + Max range between players to show the map gesture indicator + Distância max. entre os jogadores para mostrar o indicador de gesto no mapa + Maksymalny zasięg, w obrębie którego gesty będą widoczne dla graczy + Макс. дистанция между игроками для отображения жестов на карте + Maximální vzdálenost mezi hráči pro zobrazení indikátoru ukázání v mapě + Distanza massima tra giocatori per mostrare i gesti in mappa + Maximale Reichweite zwischen Spielern um Kartenzeichen anzuzeigen + Máxima distancia a la cual pueden verse el indicador de gestos + Définit le rayon au-delà duquel les joueurs ne verront plus l'indicateur de pointage de leurs alliés. + プレイヤーによるマップ ジェスチャーの表示範囲を設定します + 플레이어간에 지도 신호 표시거리를 설정합니다. + 设定地图标识器显示的最大范围距离 + 設定地圖指示器顯示的最大範圍距離 Update Interval @@ -276,6 +276,69 @@ Показывать жесты только от игроков союзной стороны. Affiche uniquement les pointages effectués par des unités qui sont du même camp, ou d'un camp allié. + + Max range Camera + + + Max range between a Camera and players to show the map gesture indicator + + + Allow Spectator + + + Allows Spectator to See Map Gestures + + + Allow Curator + + + Allows Curator to See Map Gestures + + + Briefing Mode + + + What player can see what + + + Disabled + + + Group + Skupina + Groupement + Gruppe + Gruppo + Grupa + Grupo + Группа + Grupo + + + Side + Strana + Camp + Seite + Fazione + Strona + Lado + Сторона + Bando + + + Proximity + + + All + Vše + Tous + Alle + Tutte + Wszystko + Tudo + Все + Todas + Map Gestures - Group Settings Gestos no mapa - Definições de Grupo @@ -307,5 +370,16 @@ ACE 地圖指示器 ACE Harita Hareketleri + + Colors + Barvy + Couleurs + Farben + Colori + Kolory + Cores + Цвета + Colores +