From 020cf2ddd8934d776f015344cca43c7cd0bfc8dc Mon Sep 17 00:00:00 2001 From: b-mayr-1984 <76476468+b-mayr-1984@users.noreply.github.com> Date: Wed, 6 Apr 2022 23:49:27 +0200 Subject: [PATCH] maptools - Improve behaviour upon first open (show under mouse position instead of bottom-left corner) (#8848) * open map tools in center of screen upon first open Don't show the map tools at the bottom-left corner of the map when you first open it, but right where your mouse is. * always move to mouse position when opened (not just once) incorporated feedback from co-authors Co-Authored-By: Drofseh Co-Authored-By: PabstMirror * replace tabs by 4x whitespaces in order for checks to complete successfully * move code to fnc_updateMapToolMarkers so it always runs Co-authored-by: Drofseh Co-authored-by: PabstMirror --- addons/maptools/CfgVehicles.hpp | 4 ++-- addons/maptools/XEH_postInitClient.sqf | 1 + addons/maptools/functions/fnc_updateMapToolMarkers.sqf | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/maptools/CfgVehicles.hpp b/addons/maptools/CfgVehicles.hpp index 5ab3eac165..8f0c95be92 100644 --- a/addons/maptools/CfgVehicles.hpp +++ b/addons/maptools/CfgVehicles.hpp @@ -32,14 +32,14 @@ class CfgVehicles { class ACE_MapToolsShowNormal { displayName = CSTRING(MapToolsShowNormal); condition = QUOTE(GVAR(mapTool_Shown) != 1); - statement = QUOTE(GVAR(mapTool_Shown) = 1;); + statement = QUOTE(if (GVAR(mapTool_Shown) == 0) then {GVAR(mapTool_moveToMouse) = true}; GVAR(mapTool_Shown) = 1;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; }; class ACE_MapToolsShowSmall { displayName = CSTRING(MapToolsShowSmall); condition = QUOTE(GVAR(mapTool_Shown) != 2); - statement = QUOTE(GVAR(mapTool_Shown) = 2;); + statement = QUOTE(if (GVAR(mapTool_Shown) == 0) then {GVAR(mapTool_moveToMouse) = true}; GVAR(mapTool_Shown) = 2;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; }; diff --git a/addons/maptools/XEH_postInitClient.sqf b/addons/maptools/XEH_postInitClient.sqf index c7dceacd75..eede4db015 100644 --- a/addons/maptools/XEH_postInitClient.sqf +++ b/addons/maptools/XEH_postInitClient.sqf @@ -13,6 +13,7 @@ GVAR(mapTool_pos) = [0,0]; GVAR(mapTool_angle) = 0; GVAR(mapTool_isDragging) = false; GVAR(mapTool_isRotating) = false; +GVAR(mapTool_moveToMouse) = true; // used to display it in center of screen when opened //Install the event handers for the map tools on the main in-game map [{!isNull findDisplay 12}, diff --git a/addons/maptools/functions/fnc_updateMapToolMarkers.sqf b/addons/maptools/functions/fnc_updateMapToolMarkers.sqf index e9cb14d7ed..a3be0e2c97 100644 --- a/addons/maptools/functions/fnc_updateMapToolMarkers.sqf +++ b/addons/maptools/functions/fnc_updateMapToolMarkers.sqf @@ -19,6 +19,13 @@ params ["_theMap"]; if ((GVAR(mapTool_Shown) == 0) || {!("ACE_MapTools" in (ACE_player call EFUNC(common,uniqueItems)))}) exitWith {}; +// open map tools in center of screen when toggled to be shown +if (GVAR(mapTool_moveToMouse)) then { + private _mousePosition = _theMap ctrlMapScreenToWorld getMousePosition; + GVAR(mapTool_pos) = _mousePosition; + GVAR(mapTool_moveToMouse) = false; // we only need to do this once after opening the map tool +}; + private _rotatingTexture = ""; private _textureWidth = 0; if (GVAR(mapTool_Shown) == 1) then {