diff options
author | McCabe Maxsted | 2009-06-13 01:18:31 -0700 |
---|---|---|
committer | McCabe Maxsted | 2009-06-13 01:18:31 -0700 |
commit | 6ca9572497f3ccfa3cd46130685baada752e7fe1 (patch) | |
tree | 7f4be21c3cbadbfd079cb32ac3585009cad88a0d /linden/indra/newview/llnetmap.cpp | |
parent | Applied Aimee's patch for VWR-6918: Hide/Show Selection Outlines (diff) | |
download | meta-impy-6ca9572497f3ccfa3cd46130685baada752e7fe1.zip meta-impy-6ca9572497f3ccfa3cd46130685baada752e7fe1.tar.gz meta-impy-6ca9572497f3ccfa3cd46130685baada752e7fe1.tar.bz2 meta-impy-6ca9572497f3ccfa3cd46130685baada752e7fe1.tar.xz |
Applied Aimee's patch for VWR-13221: Allow panning of the mini-map
Diffstat (limited to 'linden/indra/newview/llnetmap.cpp')
-rw-r--r-- | linden/indra/newview/llnetmap.cpp | 148 |
1 files changed, 135 insertions, 13 deletions
diff --git a/linden/indra/newview/llnetmap.cpp b/linden/indra/newview/llnetmap.cpp index 71eb35b..585e8eb 100644 --- a/linden/indra/newview/llnetmap.cpp +++ b/linden/indra/newview/llnetmap.cpp | |||
@@ -94,6 +94,8 @@ LLNetMap::LLNetMap(const std::string& name) : | |||
94 | 94 | ||
95 | // Register event listeners for popup menu | 95 | // Register event listeners for popup menu |
96 | (new LLScaleMap())->registerListener(this, "MiniMap.ZoomLevel"); | 96 | (new LLScaleMap())->registerListener(this, "MiniMap.ZoomLevel"); |
97 | (new LLCenterMap())->registerListener(this, "MiniMap.Center"); | ||
98 | (new LLCheckCenterMap())->registerListener(this, "MiniMap.CheckCenter"); | ||
97 | (new LLStopTracking())->registerListener(this, "MiniMap.StopTracking"); | 99 | (new LLStopTracking())->registerListener(this, "MiniMap.StopTracking"); |
98 | (new LLEnableTracking())->registerListener(this, "MiniMap.EnableTracking"); | 100 | (new LLEnableTracking())->registerListener(this, "MiniMap.EnableTracking"); |
99 | (new LLShowAgentProfile())->registerListener(this, "MiniMap.ShowProfile"); | 101 | (new LLShowAgentProfile())->registerListener(this, "MiniMap.ShowProfile"); |
@@ -160,8 +162,11 @@ void LLNetMap::draw() | |||
160 | createObjectImage(); | 162 | createObjectImage(); |
161 | } | 163 | } |
162 | 164 | ||
163 | mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); | 165 | if (gSavedSettings.getS32( "MiniMapCenter" ) != MAP_CENTER_NONE) |
164 | mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); | 166 | { |
167 | mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); | ||
168 | mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); | ||
169 | } | ||
165 | 170 | ||
166 | F32 rotation = 0; | 171 | F32 rotation = 0; |
167 | 172 | ||
@@ -261,26 +266,24 @@ void LLNetMap::draw() | |||
261 | } | 266 | } |
262 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); | 267 | gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); |
263 | } | 268 | } |
264 | |||
265 | |||
266 | LLVector3d old_center = mObjectImageCenterGlobal; | ||
267 | LLVector3d new_center = gAgent.getCameraPositionGlobal(); | ||
268 | |||
269 | new_center.mdV[0] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[0]); | ||
270 | new_center.mdV[1] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[1]); | ||
271 | new_center.mdV[2] = 0.f; | ||
272 | 269 | ||
270 | // Redraw object layer periodically | ||
273 | if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) | 271 | if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) |
274 | { | 272 | { |
275 | mUpdateNow = FALSE; | 273 | mUpdateNow = FALSE; |
276 | mObjectImageCenterGlobal = new_center; | ||
277 | 274 | ||
278 | // Center moved enough. | 275 | // Locate the centre of the object layer, accounting for panning |
276 | LLVector3 new_center = globalPosToView(gAgent.getCameraPositionGlobal(), rotate_map); | ||
277 | new_center.mV[0] -= mCurPanX; | ||
278 | new_center.mV[1] -= mCurPanY; | ||
279 | new_center.mV[2] = 0.f; | ||
280 | mObjectImageCenterGlobal = viewPosToGlobal(llround(new_center.mV[0]), llround(new_center.mV[1]), rotate_map); | ||
281 | |||
279 | // Create the base texture. | 282 | // Create the base texture. |
280 | U8 *default_texture = mObjectRawImagep->getData(); | 283 | U8 *default_texture = mObjectRawImagep->getData(); |
281 | memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); | 284 | memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); |
282 | 285 | ||
283 | // Draw buildings | 286 | // Draw objects |
284 | gObjectList.renderObjectsForMap(*this); | 287 | gObjectList.renderObjectsForMap(*this); |
285 | 288 | ||
286 | mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); | 289 | mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); |
@@ -728,6 +731,99 @@ void LLNetMap::createObjectImage() | |||
728 | mUpdateNow = TRUE; | 731 | mUpdateNow = TRUE; |
729 | } | 732 | } |
730 | 733 | ||
734 | BOOL LLNetMap::handleMouseDown( S32 x, S32 y, MASK mask ) | ||
735 | { | ||
736 | if (!(mask & MASK_SHIFT)) return FALSE; | ||
737 | |||
738 | // Start panning | ||
739 | gFocusMgr.setMouseCapture( this ); | ||
740 | |||
741 | mMouseDownPanX = llround(mCurPanX); | ||
742 | mMouseDownPanY = llround(mCurPanY); | ||
743 | mMouseDownX = x; | ||
744 | mMouseDownY = y; | ||
745 | return TRUE; | ||
746 | } | ||
747 | |||
748 | BOOL LLNetMap::handleMouseUp( S32 x, S32 y, MASK mask ) | ||
749 | { | ||
750 | if (hasMouseCapture()) | ||
751 | { | ||
752 | if (mPanning) | ||
753 | { | ||
754 | // restore mouse cursor | ||
755 | S32 local_x, local_y; | ||
756 | local_x = mMouseDownX + llfloor(mCurPanX - mMouseDownPanX); | ||
757 | local_y = mMouseDownY + llfloor(mCurPanY - mMouseDownPanY); | ||
758 | LLRect clip_rect = getRect(); | ||
759 | clip_rect.stretch(-8); | ||
760 | clip_rect.clipPointToRect(mMouseDownX, mMouseDownY, local_x, local_y); | ||
761 | LLUI::setCursorPositionLocal(this, local_x, local_y); | ||
762 | |||
763 | // finish the pan | ||
764 | mPanning = FALSE; | ||
765 | |||
766 | mMouseDownX = 0; | ||
767 | mMouseDownY = 0; | ||
768 | |||
769 | // auto centre | ||
770 | mTargetPanX = 0; | ||
771 | mTargetPanY = 0; | ||
772 | } | ||
773 | gViewerWindow->showCursor(); | ||
774 | gFocusMgr.setMouseCapture( NULL ); | ||
775 | return TRUE; | ||
776 | } | ||
777 | return FALSE; | ||
778 | } | ||
779 | |||
780 | // static | ||
781 | BOOL LLNetMap::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y) | ||
782 | { | ||
783 | S32 dx = x - start_x; | ||
784 | S32 dy = y - start_y; | ||
785 | S32 SLOP = 4; | ||
786 | |||
787 | return (dx <= -SLOP || SLOP <= dx || dy <= -SLOP || SLOP <= dy); | ||
788 | } | ||
789 | |||
790 | BOOL LLNetMap::handleHover( S32 x, S32 y, MASK mask ) | ||
791 | { | ||
792 | if (hasMouseCapture()) | ||
793 | { | ||
794 | if (mPanning || outsideSlop(x, y, mMouseDownX, mMouseDownY)) | ||
795 | { | ||
796 | // just started panning, so hide cursor | ||
797 | if (!mPanning) | ||
798 | { | ||
799 | mPanning = TRUE; | ||
800 | gViewerWindow->hideCursor(); | ||
801 | } | ||
802 | |||
803 | F32 delta_x = (F32)(gViewerWindow->getCurrentMouseDX()); | ||
804 | F32 delta_y = (F32)(gViewerWindow->getCurrentMouseDY()); | ||
805 | |||
806 | // Set pan to value at start of drag + offset | ||
807 | mCurPanX += delta_x; | ||
808 | mCurPanY += delta_y; | ||
809 | mTargetPanX = mCurPanX; | ||
810 | mTargetPanY = mCurPanY; | ||
811 | |||
812 | gViewerWindow->moveCursorToCenter(); | ||
813 | } | ||
814 | |||
815 | // Doesn't matter, cursor should be hidden | ||
816 | gViewerWindow->setCursor( UI_CURSOR_CROSS ); | ||
817 | return TRUE; | ||
818 | } | ||
819 | else | ||
820 | { | ||
821 | gViewerWindow->setCursor( UI_CURSOR_CROSS ); | ||
822 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLNetMap" << llendl; | ||
823 | return TRUE; | ||
824 | } | ||
825 | } | ||
826 | |||
731 | BOOL LLNetMap::handleDoubleClick( S32 x, S32 y, MASK mask ) | 827 | BOOL LLNetMap::handleDoubleClick( S32 x, S32 y, MASK mask ) |
732 | { | 828 | { |
733 | if (gSavedSettings.getBOOL( "MiniMapTeleport" )) | 829 | if (gSavedSettings.getBOOL( "MiniMapTeleport" )) |
@@ -780,6 +876,32 @@ bool LLNetMap::LLScaleMap::handleEvent(LLPointer<LLEvent> event, const LLSD& use | |||
780 | return true; | 876 | return true; |
781 | } | 877 | } |
782 | 878 | ||
879 | bool LLNetMap::LLCenterMap::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
880 | { | ||
881 | S32 center = userdata.asInteger(); | ||
882 | |||
883 | if (gSavedSettings.getS32("MiniMapCenter") == center) | ||
884 | { | ||
885 | gSavedSettings.setS32("MiniMapCenter", MAP_CENTER_NONE); | ||
886 | } | ||
887 | else | ||
888 | { | ||
889 | gSavedSettings.setS32("MiniMapCenter", userdata.asInteger()); | ||
890 | } | ||
891 | |||
892 | return true; | ||
893 | } | ||
894 | |||
895 | bool LLNetMap::LLCheckCenterMap::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | ||
896 | { | ||
897 | LLNetMap *self = mPtr; | ||
898 | EMiniMapCenter center = (EMiniMapCenter)userdata["data"].asInteger(); | ||
899 | BOOL enabled = (gSavedSettings.getS32("MiniMapCenter") == center); | ||
900 | |||
901 | self->findControl(userdata["control"].asString())->setValue(enabled); | ||
902 | return true; | ||
903 | } | ||
904 | |||
783 | bool LLNetMap::LLStopTracking::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 905 | bool LLNetMap::LLStopTracking::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
784 | { | 906 | { |
785 | LLTracker::stopTracking(NULL); | 907 | LLTracker::stopTracking(NULL); |