diff options
Diffstat (limited to 'indra/newview/llfloatermap.cpp')
-rw-r--r-- | indra/newview/llfloatermap.cpp | 75 |
1 files changed, 65 insertions, 10 deletions
diff --git a/indra/newview/llfloatermap.cpp b/indra/newview/llfloatermap.cpp index 0c9a759f32..5677899dd9 100644 --- a/indra/newview/llfloatermap.cpp +++ b/indra/newview/llfloatermap.cpp @@ -41,7 +41,7 @@ #include "llglheaders.h" // Viewer includes -#include "llagent.h" +#include "llagentcamera.h" #include "llviewercontrol.h" #include "llnetmap.h" #include "lltracker.h" @@ -51,11 +51,26 @@ #include "llviewermenu.h" // +// Constants +// +const F32 MAP_MINOR_DIR_THRESHOLD = 0.08f; + +// // Member functions // LLFloaterMap::LLFloaterMap(const LLSD& key) - : LLFloater(key) + : LLFloater(key), + mPopupMenu(NULL), + mTextBoxEast(NULL), + mTextBoxNorth(NULL), + mTextBoxWest(NULL), + mTextBoxSouth(NULL), + mTextBoxSouthEast(NULL), + mTextBoxNorthEast(NULL), + mTextBoxNorthWest(NULL), + mTextBoxSouthWest(NULL), + mMap(NULL) { //Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_map.xml", FALSE); } @@ -68,7 +83,6 @@ BOOL LLFloaterMap::postBuild() { mMap = getChild<LLNetMap>("Net Map"); mMap->setScale(gSavedSettings.getF32("MiniMapScale")); - mMap->setRotateMap(gSavedSettings.getBOOL( "MiniMapRotate" )); mMap->setToolTipMsg(getString("ToolTipMsg")); sendChildToBack(mMap); @@ -92,10 +106,13 @@ BOOL LLFloaterMap::postBuild() mPopupMenu->setItemEnabled ("Stop Tracking", false); } + updateMinorDirections(); + // Get the drag handle all the way in back sendChildToBack(getDragHandle()); setIsChrome(TRUE); + getDragHandle()->setTitleVisible(TRUE); // keep onscreen gFloaterView->adjustToFitScreen(this, FALSE); @@ -125,8 +142,8 @@ void LLFloaterMap::setDirectionPos( LLTextBox* text_box, F32 rotation ) // Rotation is in radians. // Rotation of 0 means x = 1, y = 0 on the unit circle. - F32 map_half_height = (F32)(getRect().getHeight() / 2); - F32 map_half_width = (F32)(getRect().getWidth() / 2); + F32 map_half_height = (F32)(getRect().getHeight() / 2) - getHeaderHeight()/2; + F32 map_half_width = (F32)(getRect().getWidth() / 2) ; F32 text_half_height = (F32)(text_box->getRect().getHeight() / 2); F32 text_half_width = (F32)(text_box->getRect().getWidth() / 2); F32 radius = llmin( map_half_height - text_half_height, map_half_width - text_half_width ); @@ -139,12 +156,30 @@ void LLFloaterMap::setDirectionPos( LLTextBox* text_box, F32 rotation ) llround(map_half_height - text_half_height + radius * sin( rotation )) ); } +void LLFloaterMap::updateMinorDirections() +{ + if (mTextBoxNorthEast == NULL) + { + return; + } + + // Hide minor directions if they cover too much of the map + bool show_minors = mTextBoxNorthEast->getRect().getHeight() < MAP_MINOR_DIR_THRESHOLD * + llmin(getRect().getWidth(), getRect().getHeight()); + + mTextBoxNorthEast->setVisible(show_minors); + mTextBoxNorthWest->setVisible(show_minors); + mTextBoxSouthWest->setVisible(show_minors); + mTextBoxSouthEast->setVisible(show_minors); +} + // virtual void LLFloaterMap::draw() { F32 rotation = 0; - if( mMap->getRotateMap() ) + static LLUICachedControl<bool> rotate_map("MiniMapRotate", true); + if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); @@ -161,7 +196,7 @@ void LLFloaterMap::draw() setDirectionPos( mTextBoxSouthEast, rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2); // Note: we can't just gAgent.check cameraMouselook() because the transition states are wrong. - if( gAgent.cameraMouselook()) + if(gAgentCamera.cameraMouselook()) { setMouseOpaque(FALSE); getDragHandle()->setMouseOpaque(FALSE); @@ -180,17 +215,37 @@ void LLFloaterMap::draw() LLFloater::draw(); } +// virtual +void LLFloaterMap::onFocusReceived() +{ + setBackgroundOpaque(true); + LLPanel::onFocusReceived(); +} + +// virtual +void LLFloaterMap::onFocusLost() +{ + setBackgroundOpaque(false); + LLPanel::onFocusLost(); +} + +void LLFloaterMap::reshape(S32 width, S32 height, BOOL called_from_parent) +{ + LLFloater::reshape(width, height, called_from_parent); + updateMinorDirections(); +} + void LLFloaterMap::handleZoom(const LLSD& userdata) { std::string level = userdata.asString(); F32 scale = 0.0f; if (level == std::string("close")) - scale = MAP_SCALE_MAX; + scale = LLNetMap::MAP_SCALE_MAX; else if (level == std::string("medium")) - scale = MAP_SCALE_MID; + scale = LLNetMap::MAP_SCALE_MID; else if (level == std::string("far")) - scale = MAP_SCALE_MIN; + scale = LLNetMap::MAP_SCALE_MIN; if (scale != 0.0f) { gSavedSettings.setF32("MiniMapScale", scale ); |