From 9c24c207d725eaeb54f861150809d2a731250cfb Mon Sep 17 00:00:00 2001 From: Arrehn Date: Tue, 29 Mar 2011 22:40:09 -0400 Subject: [PATCH] Radar Improvements: Radar always active, Minor Refactoring, Ansariel's colorful range indicator --- indra/newview/llavatarlist.cpp | 25 ++++++++++ indra/newview/llavatarlist.h | 8 ++++ indra/newview/llavatarlistitem.cpp | 49 ++++++++++++++++++-- indra/newview/llavatarlistitem.h | 17 +++++-- indra/newview/llpanelpeople.cpp | 64 ++++++++++++-------------- indra/newview/llpanelpeople.h | 3 -- indra/newview/skins/default/colors.xml | 6 +++ 7 files changed, 126 insertions(+), 46 deletions(-) diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp index d5adcdda10..8ff9e304cc 100644 --- a/indra/newview/llavatarlist.cpp +++ b/indra/newview/llavatarlist.cpp @@ -242,6 +242,9 @@ LLAvatarList::LLAvatarList(const Params& p) , mShowPaymentStatus(false) , mItemHeight(0) // [/RLVa:KB] +// [Ansariel: Colorful radar] +, mUseRangeColors(false) +// [Ansariel: Colorful radar] { setCommitOnSelectionChange(true); @@ -294,6 +297,20 @@ void LLAvatarList::showMiniProfileIcons(bool visible) } } +// [Ansariel: Colorful radar] +void LLAvatarList::setUseRangeColors(bool UseRangeColors) +{ + mUseRangeColors = UseRangeColors; + + std::vector items; + getItems(items); + for( std::vector::const_iterator it = items.begin(); it != items.end(); it++) + { + static_cast(*it)->setUseRangeColors(mUseRangeColors); + } +} +// [Ansariel: Colorful radar] + // virtual void LLAvatarList::draw() { @@ -404,6 +421,7 @@ void LLAvatarList::addAvalineItem(const LLUUID& item_id, const LLUUID& session_i ////////////////////////////////////////////////////////////////////////// void LLAvatarList::refresh() { + llinfos << "AO: refreshing" << llendl; bool have_names = TRUE; bool add_limit_exceeded = false; bool modified = false; @@ -609,6 +627,13 @@ void LLAvatarList::addNewItem(const LLUUID& id, const std::string& name, BOOL is item->showStatusFlags(mShowStatusFlags); item->showPaymentStatus(mShowPaymentStatus); item->showAvatarAge(mShowAge); + + // [Ansariel: Colorful radar] + item->setUseRangeColors(mUseRangeColors); + LLUIColorTable* colorTable = &LLUIColorTable::instance(); + item->setShoutRangeColor(colorTable->getColor("AvatarListItemShoutRange", LLColor4::yellow)); + item->setBeyondShoutRangeColor(colorTable->getColor("AvatarListItemBeyondShoutRange", LLColor4::red)); + // [/Ansariel: Colorful radar] item->setDoubleClickCallback(boost::bind(&LLAvatarList::onItemDoubleClicked, this, _1, _2, _3, _4)); diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h index 1961bb87a2..17046ff939 100644 --- a/indra/newview/llavatarlist.h +++ b/indra/newview/llavatarlist.h @@ -93,6 +93,10 @@ public: bool getIconsVisible() const { return mShowIcons; } const std::string getIconParamName() const{return mIconParamName;} virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); + + // [Ansariel: Colorful radar] + void setUseRangeColors(bool UseRangeColors); + // [/Ansariel: Colorful radar] // Return true if filter has at least one match. bool filterHasMatches(); @@ -147,6 +151,10 @@ private: bool mIgnoreGlobalIcons; S32 mItemHeight; + // [Ansariel: Colorful radar] + bool mUseRangeColors; + // [/Ansariel: Colorful radar] + // [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d bool mRlvCheckShowNames; // [/RLVa:KB] diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp index 66cebbcb9c..1039d7ccdd 100644 --- a/indra/newview/llavatarlistitem.cpp +++ b/indra/newview/llavatarlistitem.cpp @@ -45,6 +45,7 @@ #include "llavatarpropertiesprocessor.h" #include "lldateutil.h" #include "llavatarconstants.h" +#include "indra_constants.h" bool LLAvatarListItem::sStaticInitialized = false; S32 LLAvatarListItem::sLeftPadding = 0; @@ -95,7 +96,11 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/) mShowAvatarAge(false), mShowPaymentStatus(false), mPaymentStatus(NULL), - mAvatarAge(0) + mAvatarAge(0), + // [Ansariel: Colorful radar] + mUseRangeColors(false), + // [Ansariel: Colorful radar] + mDistance(99999.9) // arbitary large number to insure new avatars are considered outside close range until we know for sure. { if (not_from_ui_factory) { @@ -133,7 +138,7 @@ BOOL LLAvatarListItem::postBuild() // radar mNearbyRange = getChild("radar_range"); - mNearbyRange->setValue("100.0"); + mNearbyRange->setValue("N/A"); mNearbyRange->setVisible(false); mFirstSeenDisplay = getChild("first_seen"); mFirstSeenDisplay->setValue(""); @@ -387,13 +392,31 @@ void LLAvatarListItem::updateFirstSeen() void LLAvatarListItem::setRange(F32 distance) { - mNearbyRange->setValue(llformat("%3.2f", distance)); + mDistance = distance; + + // [Ansariel: Colorful radar] + // Get default style params + LLStyle::Params rangeHighlight = LLStyle::Params(); + + if (mUseRangeColors && mDistance > CHAT_NORMAL_RADIUS) + { + if (mDistance < CHAT_SHOUT_RADIUS) + { + rangeHighlight.color = mShoutRangeColor; + } + else + { + rangeHighlight.color = mBeyondShoutRangeColor; + } + } + + mNearbyRange->setText(llformat("%3.2f", mDistance), rangeHighlight); + // [Ansariel: Colorful radar] } F32 LLAvatarListItem::getRange() { - std::string tmp = mNearbyRange->getText(); - return F32(::atof(tmp.c_str())); + return mDistance; } void LLAvatarListItem::setPosition(LLVector3d pos) @@ -451,6 +474,22 @@ void LLAvatarListItem::showUsername(bool show) updateAvatarName(); } +// [Ansariel: Colorful radar] +void LLAvatarListItem::setShoutRangeColor(const LLUIColor& shoutRangeColor) +{ + mShoutRangeColor = shoutRangeColor; +} + +void LLAvatarListItem::setBeyondShoutRangeColor(const LLUIColor& beyondShoutRangeColor) +{ + mBeyondShoutRangeColor = beyondShoutRangeColor; +} + +void LLAvatarListItem::setUseRangeColors(bool UseRangeColors) +{ + mUseRangeColors = UseRangeColors; +} +// [Ansariel: Colorful radar] void LLAvatarListItem::onInfoBtnClick() { diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h index 4078a04f23..b6e89ede0c 100644 --- a/indra/newview/llavatarlistitem.h +++ b/indra/newview/llavatarlistitem.h @@ -133,7 +133,11 @@ public: void onProfileBtnClick(); //Radar state-specific - + // [Ansariel: Colorful radar] + void setUseRangeColors(bool UseRangeColors); + void setShoutRangeColor(const LLUIColor& shoutRangeColor); + void setBeyondShoutRangeColor(const LLUIColor& beyondShoutRangeColor); + // [/Ansariel: Colorful radar] /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); @@ -159,6 +163,12 @@ protected: bool mShowDisplayName; bool mShowUsername; bool mShowFirstSeen; + + // [Ansariel: Colorful radar] + bool mUseRangeColors; + LLUIColor mShoutRangeColor; + LLUIColor mBeyondShoutRangeColor; + // [/Ansariel: Colorful radar] private: @@ -237,9 +247,10 @@ private: LLUUID mAvatarId; time_t mFirstSeen; - S32 mAvStatus; + S32 mAvStatus; LLVector3d mAvPosition; - S32 mAvatarAge; + S32 mAvatarAge; + F32 mDistance; std::string mHighlihtSubstring; // substring to highlight EOnlineStatus mOnlineStatus; diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index f596e7cf45..85b15fe030 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -483,9 +483,7 @@ LLPanelPeople::LLPanelPeople() mNearbyGearButton(NULL), mFriendsGearButton(NULL), mGroupsGearButton(NULL), - mRecentGearButton(NULL), - mChatRadius(20.0), - mDrawRadius(0.0) + mRecentGearButton(NULL) { mFriendListUpdater = new LLFriendListUpdater(boost::bind(&LLPanelPeople::updateFriendList, this)); @@ -533,7 +531,6 @@ void LLPanelPeople::onFriendsAccordionExpandedCollapsed(LLUICtrl* ctrl, const LL BOOL LLPanelPeople::postBuild() { - mDrawRadius = gSavedSettings.getF32("RenderFarClip"); mFilterEditor = getChild("filter_input"); mFilterEditor->setCommitCallback(boost::bind(&LLPanelPeople::onFilterEdit, this, _2)); @@ -553,7 +550,7 @@ BOOL LLPanelPeople::postBuild() mAllFriendList->showPermissions(true); LLPanel* nearby_tab = getChild(NEARBY_TAB_NAME); - nearby_tab->setVisibleCallback(boost::bind(&Updater::setActive, mNearbyListUpdater, _2)); + mNearbyList = nearby_tab->getChild("avatar_list"); mNearbyList->setNoItemsCommentText(getString("no_one_near")); mNearbyList->setNoItemsMsg(getString("no_one_near")); @@ -568,11 +565,16 @@ BOOL LLPanelPeople::postBuild() mNearbyList->showMiniProfileIcons(false); mNearbyList->showPermissions(false); mNearbyList->setItemHeight(20); // AO: Radar item spacing should be more compressed to use less screen space - -// [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d + // [Ansariel: Colorful radar] + mNearbyList->setUseRangeColors(true); + // [/Ansariel: Colorful radar] + // [RLVa:KB] - Checked: 2010-04-05 (RLVa-1.2.2a) | Added: RLVa-1.2.0d mNearbyList->setRlvCheckShowNames(true); -// [/RLVa:KB] + // [/RLVa:KB] + //nearby_tab->setVisibleCallback(boost::bind(&Updater::setActive, mNearbyListUpdater, _2)); + mNearbyListUpdater->setActive(true); // AO: always keep radar active, for chat and channel integration + mRecentList = getChild(RECENT_TAB_NAME)->getChild("avatar_list"); mRecentList->setNoItemsCommentText(getString("no_recent_people")); mRecentList->setNoItemsMsg(getString("no_recent_people")); @@ -800,15 +802,18 @@ void LLPanelPeople::updateFriendList() void LLPanelPeople::updateNearbyList() { if (!mNearbyList) + { return; + } std::vector items; + F32 drawRadius = gSavedSettings.getF32("RenderFarClip"); mNearbyList->getItems(items); // Fetch new list of surrounding Avs std::vector positions; LLWorld::getInstance()->getAvatars(&mNearbyList->getIDs(), &positions, gAgent.getPositionGlobal(), gSavedSettings.getF32("NearMeRange")); - mNearbyList->setDirty(); + mNearbyList->setDirty(true,true); // AO: These optional arguements force updating even when we're not a visible window. DISTANCE_COMPARATOR.updateAvatarsPositions(positions, mNearbyList->getIDs()); //Compare new list with last radar cache, updating fields and processing changes @@ -818,6 +823,7 @@ void LLPanelPeople::updateNearbyList() { LLAvatarListItem* av = static_cast(*itItem); LLUUID avId = av->getAvatarId(); + F32 r = av->getRange(); if (lastRadarSweep.count(avId) > 0) { @@ -826,22 +832,22 @@ void LLPanelPeople::updateNearbyList() if (gSavedSettings.getBOOL("RadarReportChatRange")) { - if ((av->getRange() <= mChatRadius) && (lastRadarSweep[avId].lastDistance > mChatRadius)) + if ((r <= CHAT_NORMAL_RADIUS) && (lastRadarSweep[avId].lastDistance > CHAT_NORMAL_RADIUS)) { reportToNearbyChat(av->getAvatarName() + " entered chat range."); } - else if ((av->getRange() > mChatRadius) && (lastRadarSweep[avId].lastDistance <= mChatRadius)) + else if ((r > CHAT_NORMAL_RADIUS) && (lastRadarSweep[avId].lastDistance <= CHAT_NORMAL_RADIUS)) { reportToNearbyChat(av->getAvatarName() + " left chat range."); } } if (gSavedSettings.getBOOL("RadarReportDrawRange")) { - if ((av->getRange() <= mDrawRadius) && (lastRadarSweep[avId].lastDistance > mDrawRadius)) + if ((r <= drawRadius) && (lastRadarSweep[avId].lastDistance > drawRadius)) { reportToNearbyChat(av->getAvatarName() + " entered draw distance."); } - else if ((av->getRange() > mDrawRadius) && (lastRadarSweep[avId].lastDistance <= mDrawRadius)) + else if ((r > drawRadius) && (lastRadarSweep[avId].lastDistance <= drawRadius)) { reportToNearbyChat(av->getAvatarName() + " left draw distance."); } @@ -851,23 +857,19 @@ void LLPanelPeople::updateNearbyList() // TODO Alert if we entered the sim // TODO Alert if we changed status } + + // Handle new entries else { av->setFirstSeen(time(NULL)); - if (gSavedSettings.getBOOL("RadarReportChatRange")) + if (gSavedSettings.getBOOL("RadarReportChatRange") && (r <= CHAT_NORMAL_RADIUS)) { - if (av->getRange() <= mChatRadius) - { - reportToNearbyChat(av->getAvatarName() + " entered chat range."); - } + reportToNearbyChat(av->getAvatarName()+llformat(" entered chat range (%3.2f m)\n",r)); } - if (gSavedSettings.getBOOL("RadarReportDrawRange")) + if (gSavedSettings.getBOOL("RadarReportDrawRange") && (r <= drawRadius)) { - if (av->getRange() <= mDrawRadius) - { - reportToNearbyChat(av->getAvatarName() + " entered draw distance."); - } + reportToNearbyChat(av->getAvatarName()+llformat(" entered draw distance (%3.2f m)\n",r)); } // TODO Alert if we entered the sim @@ -878,19 +880,13 @@ void LLPanelPeople::updateNearbyList() { radarFields rf = i->second; - if (gSavedSettings.getBOOL("RadarReportChatRange")) + if (gSavedSettings.getBOOL("RadarReportChatRange") && (rf.lastDistance <= CHAT_NORMAL_RADIUS)) { - if (rf.lastDistance <= mChatRadius) - { - reportToNearbyChat(rf.avName + " left chat range."); - } + reportToNearbyChat(rf.avName + " left chat range."); } - if (gSavedSettings.getBOOL("RadarReportDrawRange")) + if (gSavedSettings.getBOOL("RadarReportDrawRange") && (rf.lastDistance <= drawRadius)) { - if (rf.lastDistance <= mDrawRadius) - { - reportToNearbyChat(rf.avName + " left draw distance."); - } + reportToNearbyChat(rf.avName + " left draw distance."); } // TODO Alert if we left the sim } @@ -1409,7 +1405,6 @@ void LLPanelPeople::teleportToAvatar(LLUUID targetAv) // Teleports user to last scanned location of nearby avatar // Note: currently teleportViaLocation is disrupted by enforced landing points set on a parcel. { - llinfos << "AO: Trying to teleport to avatar: " << targetAv << llendl; std::vector items; mNearbyList->getItems(items); for (std::vector::const_iterator itItem = items.begin(); itItem != items.end(); ++itItem) @@ -1417,7 +1412,6 @@ void LLPanelPeople::teleportToAvatar(LLUUID targetAv) LLAvatarListItem* av = static_cast(*itItem); if (av->getAvatarId() == targetAv) { - llinfos << "avatar found, teleporting." << llendl; gAgent.teleportViaLocation(av->getPosition()); return; } diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h index 8ce26fe26a..82073acb2a 100644 --- a/indra/newview/llpanelpeople.h +++ b/indra/newview/llpanelpeople.h @@ -178,9 +178,6 @@ private: std::string mFilterSubString; std::string mFilterSubStringOrig; - F32 mChatRadius; - F32 mDrawRadius; - struct radarFields { std::string avName; diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index aa74d00e8d..b0263584e1 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -342,6 +342,12 @@ + +