diff options
Diffstat (limited to 'indra/newview/lllocationinputctrl.cpp')
-rw-r--r-- | indra/newview/lllocationinputctrl.cpp | 112 |
1 files changed, 94 insertions, 18 deletions
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 7e35cfa04c..be96d7b43a 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -157,15 +157,21 @@ LLLocationInputCtrl::Params::Params() add_landmark_image_disabled("add_landmark_image_disabled"), add_landmark_image_hover("add_landmark_image_hover"), add_landmark_image_selected("add_landmark_image_selected"), + icon_hpad("icon_hpad", 0), add_landmark_button("add_landmark_button"), - add_landmark_hpad("add_landmark_hpad", 0), - info_button("info_button") + info_button("info_button"), + voice_icon("voice_icon"), + fly_icon("fly_icon"), + push_icon("push_icon"), + build_icon("build_icon"), + scripts_icon("scripts_icon"), + damage_icon("damage_icon") { } LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) : LLComboBox(p), - mAddLandmarkHPad(p.add_landmark_hpad), + mIconHPad(p.icon_hpad), mInfoBtn(NULL), mLocationContextMenu(NULL), mAddLandmarkBtn(NULL), @@ -230,6 +236,32 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p) mAddLandmarkBtn = LLUICtrlFactory::create<LLButton>(al_params); enableAddLandmarkButton(true); addChild(mAddLandmarkBtn); + + // Parcel property icons + LLIconCtrl::Params voice_icon = p.voice_icon; + mParcelIcon[VOICE_ICON] = LLUICtrlFactory::create<LLIconCtrl>(voice_icon); + addChild(mParcelIcon[VOICE_ICON]); + + LLIconCtrl::Params fly_icon = p.fly_icon; + mParcelIcon[FLY_ICON] = LLUICtrlFactory::create<LLIconCtrl>(fly_icon); + addChild(mParcelIcon[FLY_ICON]); + + LLIconCtrl::Params push_icon = p.push_icon; + mParcelIcon[PUSH_ICON] = LLUICtrlFactory::create<LLIconCtrl>(push_icon); + addChild(mParcelIcon[PUSH_ICON]); + + LLIconCtrl::Params build_icon = p.build_icon; + mParcelIcon[BUILD_ICON] = LLUICtrlFactory::create<LLIconCtrl>(build_icon); + addChild(mParcelIcon[BUILD_ICON]); + + LLIconCtrl::Params scripts_icon = p.scripts_icon; + mParcelIcon[SCRIPTS_ICON] = LLUICtrlFactory::create<LLIconCtrl>(scripts_icon); + addChild(mParcelIcon[SCRIPTS_ICON]); + + LLIconCtrl::Params damage_icon = p.damage_icon; + mParcelIcon[DAMAGE_ICON] = LLUICtrlFactory::create<LLIconCtrl>(damage_icon); + addChild(mParcelIcon[DAMAGE_ICON]); + // TODO: health number? // Register callbacks and load the location field context menu (NB: the order matters). LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Navbar.Action", boost::bind(&LLLocationInputCtrl::onLocationContextMenuItemClicked, this, _2)); @@ -410,9 +442,10 @@ void LLLocationInputCtrl::onFocusLost() mTextEntry->deselect(); } } -void LLLocationInputCtrl::draw(){ - - if(!hasFocus() && gSavedSettings.getBOOL("ShowCoordinatesOption")){ + +void LLLocationInputCtrl::draw() +{ + if(!hasFocus() && gSavedSettings.getBOOL("NavBarShowCoordinates")){ refreshLocation(); } LLComboBox::draw(); @@ -532,6 +565,7 @@ void LLLocationInputCtrl::onTextEditorRightClicked(S32 x, S32 y, MASK mask) void LLLocationInputCtrl::refresh() { refreshLocation(); // update location string + refreshParcelIcons(); updateAddLandmarkButton(); // indicate whether current parcel has been landmarked } @@ -548,13 +582,57 @@ void LLLocationInputCtrl::refreshLocation() // Update location field. std::string location_name; - LLAgentUI::ELocationFormat format = (gSavedSettings.getBOOL("ShowCoordinatesOption") ? - LLAgentUI::LOCATION_FORMAT_WITHOUT_SIM: LLAgentUI::LOCATION_FORMAT_NORMAL); + LLAgentUI::ELocationFormat format = + (gSavedSettings.getBOOL("NavBarShowCoordinates") + ? LLAgentUI::LOCATION_FORMAT_FULL + : LLAgentUI::LOCATION_FORMAT_NO_COORDS); - if (!LLAgentUI::buildLocationString(location_name, format)) location_name = "Unknown"; + if (!LLAgentUI::buildLocationString(location_name, format)) + { + location_name = "???"; + } setText(location_name); } +void LLLocationInputCtrl::refreshParcelIcons() +{ + LLViewerParcelMgr* vpm = LLViewerParcelMgr::getInstance(); + // *TODO buy + //bool allow_buy = vpm->canAgentBuyParcel( vpm->getAgentParcel(), false); + bool allow_voice = vpm->allowAgentVoice(); + bool allow_fly = vpm->allowAgentFly(); + bool allow_push = vpm->allowAgentPush(); + bool allow_build = vpm->allowAgentBuild(); + bool allow_scripts = vpm->allowAgentScripts(); + bool allow_damage = vpm->allowAgentDamage(); + + // Most icons are "block this ability" + mParcelIcon[VOICE_ICON]->setVisible( !allow_voice ); + mParcelIcon[FLY_ICON]->setVisible( !allow_fly ); + mParcelIcon[PUSH_ICON]->setVisible( !allow_push ); + mParcelIcon[BUILD_ICON]->setVisible( !allow_build ); + mParcelIcon[SCRIPTS_ICON]->setVisible( !allow_scripts ); + mParcelIcon[DAMAGE_ICON]->setVisible( allow_damage ); + // *TODO damage meter + + // Slide the parcel icons rect from right to left, adjusting rectangles of + // visible icons. Assumes all icon rects are the same. + LLRect icon_rect = mParcelIcon[0]->getRect(); + S32 icon_width = icon_rect.getWidth(); + icon_rect.mRight = mAddLandmarkBtn->getRect().mLeft - mIconHPad; + icon_rect.mLeft = icon_rect.mRight - icon_width; + + for (S32 i = 0; i < ICON_COUNT; ++i) + { + if (mParcelIcon[i]->getVisible()) + { + mParcelIcon[i]->setRect( icon_rect ); + icon_rect.translate( -icon_width - mIconHPad, 0); + } + } + // *TODO: health meter +} + void LLLocationInputCtrl::rebuildLocationHistory(std::string filter) { LLLocationHistory::location_list_t filtered_items; @@ -651,13 +729,11 @@ void LLLocationInputCtrl::updateWidgetlayout() mInfoBtn->setRect(info_btn_rect); // "Add Landmark" button - { - LLRect al_btn_rect = mAddLandmarkBtn->getRect(); - al_btn_rect.translate( - hist_btn_rect.mLeft - mAddLandmarkHPad - al_btn_rect.getWidth(), - (rect.getHeight() - al_btn_rect.getHeight()) / 2); - mAddLandmarkBtn->setRect(al_btn_rect); - } + LLRect al_btn_rect = mAddLandmarkBtn->getRect(); + al_btn_rect.translate( + hist_btn_rect.mLeft - mIconHPad - al_btn_rect.getWidth(), + (rect.getHeight() - al_btn_rect.getHeight()) / 2); + mAddLandmarkBtn->setRect(al_btn_rect); } void LLLocationInputCtrl::changeLocationPresentation() @@ -680,7 +756,7 @@ void LLLocationInputCtrl::onLocationContextMenuItemClicked(const LLSD& userdata) if (item == std::string("show_coordinates")) { - gSavedSettings.setBOOL("ShowCoordinatesOption",!gSavedSettings.getBOOL("ShowCoordinatesOption")); + gSavedSettings.setBOOL("NavBarShowCoordinates",!gSavedSettings.getBOOL("NavBarShowCoordinates")); } else if (item == std::string("landmark")) { @@ -744,7 +820,7 @@ bool LLLocationInputCtrl::onLocationContextMenuItemEnabled(const LLSD& userdata) } else if(item == std::string("show_coordinates")){ - return gSavedSettings.getBOOL("ShowCoordinatesOption"); + return gSavedSettings.getBOOL("NavBarShowCoordinates"); } return false; |