aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorMcCabe Maxsted2009-06-13 01:18:31 -0700
committerMcCabe Maxsted2009-06-13 01:18:31 -0700
commit6ca9572497f3ccfa3cd46130685baada752e7fe1 (patch)
tree7f4be21c3cbadbfd079cb32ac3585009cad88a0d /linden/indra
parentApplied Aimee's patch for VWR-6918: Hide/Show Selection Outlines (diff)
downloadmeta-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')
-rw-r--r--linden/indra/newview/app_settings/settings.xml11
-rw-r--r--linden/indra/newview/llnetmap.cpp148
-rw-r--r--linden/indra/newview/llnetmap.h33
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/menu_mini_map.xml6
4 files changed, 183 insertions, 15 deletions
diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml
index ba2a9e4..f23daee 100644
--- a/linden/indra/newview/app_settings/settings.xml
+++ b/linden/indra/newview/app_settings/settings.xml
@@ -4797,6 +4797,17 @@
4797 <key>Value</key> 4797 <key>Value</key>
4798 <integer>410</integer> 4798 <integer>410</integer>
4799 </map> 4799 </map>
4800 <key>MiniMapCenter</key>
4801 <map>
4802 <key>Comment</key>
4803 <string>Sets the focal point of the minimap. (0=None, 1=Camera)</string>
4804 <key>Persist</key>
4805 <integer>1</integer>
4806 <key>Type</key>
4807 <string>S32</string>
4808 <key>Value</key>
4809 <integer>1</integer>
4810 </map>
4800 <key>MiniMapRotate</key> 4811 <key>MiniMapRotate</key>
4801 <map> 4812 <map>
4802 <key>Comment</key> 4813 <key>Comment</key>
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
734BOOL 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
748BOOL 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
781BOOL 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
790BOOL 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
731BOOL LLNetMap::handleDoubleClick( S32 x, S32 y, MASK mask ) 827BOOL 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
879bool 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
895bool 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
783bool LLNetMap::LLStopTracking::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 905bool LLNetMap::LLStopTracking::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
784{ 906{
785 LLTracker::stopTracking(NULL); 907 LLTracker::stopTracking(NULL);
diff --git a/linden/indra/newview/llnetmap.h b/linden/indra/newview/llnetmap.h
index be5593d..508e882 100644
--- a/linden/indra/newview/llnetmap.h
+++ b/linden/indra/newview/llnetmap.h
@@ -40,9 +40,14 @@
40#include "llimage.h" 40#include "llimage.h"
41#include "llimagegl.h" 41#include "llimagegl.h"
42 42
43
44class LLTextBox; 43class LLTextBox;
45 44
45typedef enum e_minimap_center
46{
47 MAP_CENTER_NONE = 0,
48 MAP_CENTER_CAMERA = 1
49} EMiniMapCenter;
50
46class LLNetMap : public LLPanel 51class LLNetMap : public LLPanel
47{ 52{
48public: 53public:
@@ -51,6 +56,9 @@ public:
51 56
52 virtual void draw(); 57 virtual void draw();
53 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); 58 virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
59 virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
60 virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
61 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
54 virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask ); 62 virtual BOOL handleDoubleClick( S32 x, S32 y, MASK mask );
55 virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask ); 63 virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
56 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); 64 virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
@@ -62,7 +70,7 @@ private:
62 70
63 void setScale( F32 scale ); 71 void setScale( F32 scale );
64 72
65 // *TODO: Enable panning of the mini-map 73 // Not used at present
66 void translatePan( F32 delta_x, F32 delta_y ); 74 void translatePan( F32 delta_x, F32 delta_y );
67 void setPan( F32 x, F32 y ) { mTargetPanX = x; mTargetPanY = y; } 75 void setPan( F32 x, F32 y ) { mTargetPanX = x; mTargetPanY = y; }
68 76
@@ -90,6 +98,13 @@ private:
90 F32 mTargetPanY; 98 F32 mTargetPanY;
91 F32 mCurPanX; 99 F32 mCurPanX;
92 F32 mCurPanY; 100 F32 mCurPanY;
101
102 BOOL mPanning; // map has been dragged
103 S32 mMouseDownPanX; // value at start of drag
104 S32 mMouseDownPanY; // value at start of drag
105 S32 mMouseDownX;
106 S32 mMouseDownY;
107
93 BOOL mUpdateNow; 108 BOOL mUpdateNow;
94 LLVector3d mObjectImageCenterGlobal; 109 LLVector3d mObjectImageCenterGlobal;
95 LLPointer<LLImageRaw> mObjectRawImagep; 110 LLPointer<LLImageRaw> mObjectRawImagep;
@@ -102,6 +117,8 @@ private:
102 static BOOL sRotateMap; 117 static BOOL sRotateMap;
103 static LLNetMap* sInstance; 118 static LLNetMap* sInstance;
104 static BOOL isAgentUnderCursor(void*) { return sInstance && sInstance->mClosestAgentToCursor.notNull(); } 119 static BOOL isAgentUnderCursor(void*) { return sInstance && sInstance->mClosestAgentToCursor.notNull(); }
120 static BOOL outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y);
121
105 static void showAgentProfile(void*); 122 static void showAgentProfile(void*);
106 BOOL isAgentUnderCursor() { return mClosestAgentToCursor.notNull(); } 123 BOOL isAgentUnderCursor() { return mClosestAgentToCursor.notNull(); }
107 124
@@ -111,6 +128,18 @@ private:
111 /*virtual*/ bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); 128 /*virtual*/ bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
112 }; 129 };
113 130
131 class LLCenterMap : public LLMemberListener<LLNetMap>
132 {
133 public:
134 /*virtual*/ bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
135 };
136
137 class LLCheckCenterMap : public LLMemberListener<LLNetMap>
138 {
139 public:
140 /*virtual*/ bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
141 };
142
114 class LLStopTracking : public LLMemberListener<LLNetMap> 143 class LLStopTracking : public LLMemberListener<LLNetMap>
115 { 144 {
116 public: 145 public:
diff --git a/linden/indra/newview/skins/default/xui/en-us/menu_mini_map.xml b/linden/indra/newview/skins/default/xui/en-us/menu_mini_map.xml
index 1fee7d1..68eb4e6 100644
--- a/linden/indra/newview/skins/default/xui/en-us/menu_mini_map.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/menu_mini_map.xml
@@ -14,6 +14,12 @@
14 <on_click function="MiniMap.ZoomLevel" userdata="0" /> 14 <on_click function="MiniMap.ZoomLevel" userdata="0" />
15 </menu_item_call> 15 </menu_item_call>
16 <menu_item_separator /> 16 <menu_item_separator />
17 <menu_item_check bottom_delta="-18" enabled="true" height="18" label="Center on Camera"
18 left="0" mouse_opaque="true" name="Center on Camera" width="128">
19 <on_click function="MiniMap.Center" userdata="1" />
20 <on_check function="MiniMap.CheckCenter" userdata="1" />
21 </menu_item_check>
22 <menu_item_separator />
17 <menu_item_call bottom_delta="-18" enabled = "false" height="18" label="Stop Tracking" 23 <menu_item_call bottom_delta="-18" enabled = "false" height="18" label="Stop Tracking"
18 left="0" mouse_opaque="true" name="Stop Tracking" width="128"> 24 left="0" mouse_opaque="true" name="Stop Tracking" width="128">
19 <on_click function="MiniMap.StopTracking" /> 25 <on_click function="MiniMap.StopTracking" />