When chat scrolls, IDBearer URL menus shouldn't lead to the wrong place

Optimizes away multiple iterations over scroll lists and
multiple parsings of urls to determine the target(s)
At the cost of the last selection being stored statically in a vector

Removes virtual LFIDBearer::getNumSelected
This commit is contained in:
Liru Færs
2020-01-10 13:22:55 -05:00
parent 0efddbd9ff
commit c3428c6d57
6 changed files with 11 additions and 11 deletions

View File

@@ -26,12 +26,13 @@ const std::array<const std::string, LFIDBearer::COUNT> LFIDBearer::sMenuStrings
{
"menu_avs_list.xml" // 0
, "menu_groups_list.xml" // 1
, "menu_objects_list.xml" // 2 // Singu TODO
, "menu_objects_list.xml" // 2
};
std::array<LLMenuGL*, LFIDBearer::COUNT> LFIDBearer::sMenus {};
const LFIDBearer* LFIDBearer::sActive = nullptr;
LFIDBearer::Type LFIDBearer::sActiveType = LFIDBearer::AVATAR;
uuid_vec_t LFIDBearer::sActiveIDs {};
void LFIDBearer::buildMenus()
{

View File

@@ -40,19 +40,19 @@ struct LFIDBearer
virtual ~LFIDBearer() { if (sActive == this) sActive = nullptr; }
virtual LLUUID getStringUUIDSelectedItem() const = 0;
virtual uuid_vec_t getSelectedIDs() const { return { getStringUUIDSelectedItem() }; }
virtual S32 getNumSelected() const { return getStringUUIDSelectedItem().notNull(); }
virtual Type getSelectedType() const { return AVATAR; }
template<typename T> static const T* getActive() { return static_cast<const T*>(sActive); }
static LLUUID getActiveSelectedID() { return sActive->getStringUUIDSelectedItem(); }
static uuid_vec_t getActiveSelectedIDs() { return sActive->getSelectedIDs(); }
static S32 getActiveNumSelected() { return sActive->getNumSelected(); }
static const LLUUID& getActiveSelectedID() { return sActiveIDs.empty() ? LLUUID::null : sActiveIDs[0]; }
static const uuid_vec_t& getActiveSelectedIDs() { return sActiveIDs; }
static size_t getActiveNumSelected() { return sActiveIDs.size(); }
static const Type& getActiveType() { return sActiveType; }
void setActive() const
{
sActive = this;
sActiveType = getSelectedType();
sActiveIDs = getSelectedIDs();
//sActiveIDs or even some kinda hybrid map, if Type is MULTIPLE fill the vals? and remove a buncha virtual functions?
}
@@ -68,4 +68,5 @@ protected:
private:
static const LFIDBearer* sActive;
static Type sActiveType;
static uuid_vec_t sActiveIDs;
};

View File

@@ -202,7 +202,7 @@ public:
virtual S32 getFirstSelectedIndex() const;
std::vector<LLScrollListItem*> getAllSelected() const;
uuid_vec_t getSelectedIDs() const override final; //Helper. Much like getAllSelected, but just provides a LLUUID vec
S32 getNumSelected() const override final;
S32 getNumSelected() const;
LLScrollListItem* getLastSelectedItem() const { return mLastSelected; }
// iterate over all items

View File

@@ -47,7 +47,6 @@ struct LLNameUI : public LFIDBearer
}
LLUUID getStringUUIDSelectedItem() const override final { return mNameID; }
S32 getNumSelected() const override final { return 1; }
Type getSelectedType() const override final { return mType; }
void setType(const Type& type);

View File

@@ -70,7 +70,6 @@ public:
LLUUID getStringUUIDSelectedItem() const override final { return mClosestAgentAtLastRightClick; }
uuid_vec_t getSelectedIDs() const override final { return mClosestAgentsAtLastClick; }
S32 getNumSelected() const override final { return mClosestAgentsAtLastClick.size(); }
// [SL:KB] - Patch: World-MinimapOverlay | Checked: 2012-06-20 (Catznip-3.3.0)
void refreshParcelOverlay() { mUpdateParcelImage = true; }

View File

@@ -9100,7 +9100,7 @@ class ListEnableAnySelected : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
gMenuHolder->findControl(userdata["control"].asString())->setValue(LFIDBearer::getActiveNumSelected());
gMenuHolder->findControl(userdata["control"].asString())->setValue(LFIDBearer::getActiveNumSelected() != 0);
return true;
}
};
@@ -9414,7 +9414,7 @@ class ListTeleportTo : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
const auto&& id = LFIDBearer::getActiveSelectedID();
const auto& id = LFIDBearer::getActiveSelectedID();
gAgent.teleportViaLocation(LFIDBearer::getActiveType() == LFIDBearer::OBJECT ? gObjectList.findObject(id)->getPositionGlobal() : get_av_pos(id));
return true;
}
@@ -9452,7 +9452,7 @@ class ListIsNearby : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
const auto&& id = LFIDBearer::getActiveSelectedID();
const auto& id = LFIDBearer::getActiveSelectedID();
gMenuHolder->findControl(userdata["control"].asString())->setValue(LFIDBearer::getActiveType() == LFIDBearer::OBJECT ? !!gObjectList.findObject(id) : is_nearby(id));
return true;
}