summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-09-26 22:28:18 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2020-06-23 14:48:03 +0300
commit2532a2ee9ee9003e2c6b72f8da19979a9e3dd2f6 (patch)
tree73205ed8bedfc5855082205ee5334d7e06f45d80 /indra/llcommon
parent4ae2165c4516a74012d30610b4c53de6d3ccaf90 (diff)
SL-6109 Conflict resolution
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llkeybind.cpp76
-rw-r--r--indra/llcommon/llkeybind.h19
2 files changed, 73 insertions, 22 deletions
diff --git a/indra/llcommon/llkeybind.cpp b/indra/llcommon/llkeybind.cpp
index 0eca289d4b..ff88a9c9aa 100644
--- a/indra/llcommon/llkeybind.cpp
+++ b/indra/llcommon/llkeybind.cpp
@@ -218,13 +218,17 @@ bool LLKeyBind::isEmpty() const
LLSD LLKeyBind::asLLSD() const
{
+ S32 last = mData.size() - 1;
+ while (mData[last].empty())
+ {
+ last--;
+ }
+
LLSD data;
- for (data_vector_t::const_iterator iter = mData.begin(); iter != mData.end(); iter++)
+ for (S32 i = 0; i <= last; ++i)
{
- if (!iter->isEmpty())
- {
- data.append(iter->asLLSD());
- }
+ // append even if empty to not affect visual representation
+ data.append(mData[i].asLLSD());
}
return data;
}
@@ -280,6 +284,43 @@ bool LLKeyBind::hasKeyData(const LLKeyData& data) const
return hasKeyData(data.mMouse, data.mKey, data.mMask, data.mIgnoreMasks);
}
+bool LLKeyBind::hasKeyData(U32 index) const
+{
+ return mData.size() > index;
+}
+
+S32 LLKeyBind::findKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const
+{
+ if (mouse != CLICK_NONE || key != KEY_NONE)
+ {
+ for (S32 i = 0; i < mData.size(); ++i)
+ {
+ if (mData[i].mKey == key
+ && mData[i].mMask == mask
+ && mData[i].mMouse == mouse
+ && mData[i].mIgnoreMasks == ignore)
+ {
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+S32 LLKeyBind::findKeyData(const LLKeyData& data) const
+{
+ return findKeyData(data.mMouse, data.mKey, data.mMask, data.mIgnoreMasks);
+}
+
+LLKeyData LLKeyBind::getKeyData(U32 index) const
+{
+ if (mData.size() > index)
+ {
+ return mData[index];
+ }
+ return LLKeyData();
+}
+
bool LLKeyBind::addKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore)
{
if (!hasKeyData(mouse, key, mask, ignore))
@@ -344,28 +385,29 @@ void LLKeyBind::replaceKeyData(const LLKeyData& data, U32 index)
}
}
}
- if (mData.size() > index)
+ if (mData.size() <= index)
{
- mData[index] = data;
- }
- else
- {
- mData.push_back(data);
+ mData.resize(index + 1);
}
+ mData[index] = data;
}
-bool LLKeyBind::hasKeyData(U32 index) const
+void LLKeyBind::resetKeyData(S32 index)
{
- return mData.size() > index;
+ if (mData.size() > index)
+ {
+ mData[index].reset();
+ }
}
-LLKeyData LLKeyBind::getKeyData(U32 index) const
+void LLKeyBind::trimEmpty()
{
- if (mData.size() > index)
+ S32 last = mData.size() - 1;
+ while (last >= 0 && mData[last].empty())
{
- return mData[index];
+ mData.erase(mData.begin() + last);
+ last--;
}
- return LLKeyData();
}
U32 LLKeyBind::getDataCount()
diff --git a/indra/llcommon/llkeybind.h b/indra/llcommon/llkeybind.h
index 25179a57f3..39cb668aac 100644
--- a/indra/llcommon/llkeybind.h
+++ b/indra/llcommon/llkeybind.h
@@ -74,17 +74,26 @@ public:
bool canHandleKey(KEY key, MASK mask) const;
bool canHandleMouse(EMouseClickType mouse, MASK mask) const;
- bool LLKeyBind::hasKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const;
- bool LLKeyBind::hasKeyData(const LLKeyData& data) const;
+ // contains specified combination
+ bool hasKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const;
+ bool hasKeyData(const LLKeyData& data) const;
+ bool hasKeyData(U32 index) const;
+
+ // index of contained LLKeyData
+ S32 findKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore) const;
+ S32 findKeyData(const LLKeyData& data) const;
+
+ LLKeyData getKeyData(U32 index) const;
// these methods enshure there will be no repeats
bool addKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore);
bool addKeyData(const LLKeyData& data);
void replaceKeyData(EMouseClickType mouse, KEY key, MASK mask, bool ignore, U32 index);
void replaceKeyData(const LLKeyData& data, U32 index);
- bool hasKeyData(U32 index) const;
- void clear() { mData.clear(); };
- LLKeyData getKeyData(U32 index) const;
+ void resetKeyData(S32 index);
+ void clear() { mData.clear(); }
+ // if there any empty LLKeyData in the end of the array, remove them
+ void trimEmpty();
U32 getDataCount();
private: