diff options
author | Cosmic Linden <cosmic@lindenlab.com> | 2022-03-03 11:06:16 -0800 |
---|---|---|
committer | Cosmic Linden <cosmic@lindenlab.com> | 2022-03-03 17:12:50 -0800 |
commit | 39e553fc11ef1a96707abb0a26c3b1be06954436 (patch) | |
tree | 82cf61f22094239a563368315dd7e83f22defd02 /indra/newview | |
parent | fcbd928679619f2d1cb8550a30234dcdfc50ef81 (diff) |
SL-16918: Re-add "Auto-center map" button to minimap context menu, enable minimap auto-center by default again
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llnetmap.cpp | 45 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_mini_map.xml | 10 |
3 files changed, 46 insertions, 20 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d6836dd8ba..3ecfa4ef9a 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -6049,6 +6049,17 @@ <key>Value</key> <integer>1</integer> </map> + <key>MiniMapAutoCenter</key> + <map> + <key>Comment</key> + <string>Center the focal point of the minimap.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>Marker</key> <map> <key>Comment</key> diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index f7bcee2bbc..387964f4e8 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -169,17 +169,25 @@ void LLNetMap::draw() createObjectImage(); } + static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); + bool auto_centering = auto_center && !mPanning; mCentering = mCentering && !mPanning; - if (mCentering) + bool centered = mCurPan.mV[VX] == 0.0f && mCurPan.mV[VY] == 0.0f; + + if (auto_centering || mCentering) { mCurPan = lerp(mCurPan, LLVector2(0.0f, 0.0f) , LLSmoothInterpolation::getInterpolant(0.1f)); - if (abs(mCurPan.mV[0]) < 0.5f && abs(mCurPan.mV[1]) < 0.5f){ - mCurPan.mV[0] = 0.0f; - mCurPan.mV[1] = 0.0f; - mCentering = false; - mPopupMenu->setItemEnabled("Re-Center Map", false); - } } + centered = abs(mCurPan.mV[VX]) < 0.5f && abs(mCurPan.mV[VY]) < 0.5f; + if (centered) + { + mCurPan.mV[0] = 0.0f; + mCurPan.mV[1] = 0.0f; + mCentering = false; + } + + bool can_recenter_map = !(centered || mCentering || auto_centering); + mPopupMenu->setItemEnabled("Re-Center Map", can_recenter_map); // Prepare a scissor region F32 rotation = 0; @@ -600,21 +608,19 @@ BOOL LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { // note that clicks are reversed from what you'd think: i.e. > 0 means zoom out, < 0 means zoom in F32 new_scale = mScale * pow(MAP_SCALE_ZOOM_FACTOR, -clicks); - // *TODO: Decide if we want this feature -#if 0 F32 old_scale = mScale; -#endif setScale(new_scale); - // *TODO: Decide if we want this feature -#if 0 - // Adjust pan to center the zoom on the mouse pointer - LLVector2 zoom_offset; - zoom_offset.mV[VX] = x - getRect().getWidth() / 2; - zoom_offset.mV[VY] = y - getRect().getHeight() / 2; - mCurPan -= zoom_offset * mScale / old_scale - zoom_offset; -#endif + static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); + if (!auto_center) + { + // Adjust pan to center the zoom on the mouse pointer + LLVector2 zoom_offset; + zoom_offset.mV[VX] = x - getRect().getWidth() / 2; + zoom_offset.mV[VY] = y - getRect().getHeight() / 2; + mCurPan -= zoom_offset * mScale / old_scale - zoom_offset; + } return true; } @@ -1024,10 +1030,9 @@ BOOL LLNetMap::handleHover( S32 x, S32 y, MASK mask ) { if (!mPanning) { - // Just started panning. Hide cursor and enable the "Re-Center Map" button. + // Just started panning. Hide cursor. mPanning = true; gViewerWindow->hideCursor(); - mPopupMenu->setItemEnabled("Re-Center Map", true); } LLVector2 delta(static_cast<F32>(gViewerWindow->getCurrentMouseDX()), diff --git a/indra/newview/skins/default/xui/en/menu_mini_map.xml b/indra/newview/skins/default/xui/en/menu_mini_map.xml index ddc952dfe7..402e1b34d0 100644 --- a/indra/newview/skins/default/xui/en/menu_mini_map.xml +++ b/indra/newview/skins/default/xui/en/menu_mini_map.xml @@ -47,6 +47,16 @@ parameter="MiniMapRotate" /> </menu_item_check> <menu_item_separator /> + <menu_item_check + label="Auto-center map" + name="Auto-center map"> + <menu_item_check.on_check + control="MiniMapAutoCenter" /> + <menu_item_check.on_click + function="ToggleControl" + parameter="MiniMapAutoCenter" /> + </menu_item_check> + <menu_item_separator /> <menu_item_call label="Re-Center Map" name="Re-Center Map"> |