From f51290b92f93818e16c059810c4a770e4cdb8798 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 1 Apr 2012 00:30:02 +1000 Subject: Refactor all those little checks to see if a notecard is a WindLight setting card. --- linden/indra/newview/llfloaterwindlight.cpp | 2 +- linden/indra/newview/llinventorybridge.cpp | 28 +++++++--------------------- linden/indra/newview/llinventorybridge.h | 3 --- linden/indra/newview/llpanelinventory.cpp | 26 ++++---------------------- linden/indra/newview/llviewermessage.cpp | 5 ++--- linden/indra/newview/llwlparammanager.cpp | 18 ++++++++++++++++++ linden/indra/newview/llwlparammanager.h | 5 +++++ 7 files changed, 37 insertions(+), 50 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llfloaterwindlight.cpp b/linden/indra/newview/llfloaterwindlight.cpp index 4937232..9955783 100644 --- a/linden/indra/newview/llfloaterwindlight.cpp +++ b/linden/indra/newview/llfloaterwindlight.cpp @@ -873,7 +873,7 @@ void LLFloaterWindLight::onSavePreset(LLUICtrl* ctrl, void* userData) { // Make sure we have a ".wl" extension. std::string name = comboBox->getSelectedItemLabel(); - if(name.length() > 2 && name.compare(name.length() - 3, 3, ".wl") != 0) + if(!LLWLParamManager::isSkySettingsNotecard(name)) { name += ".wl"; } diff --git a/linden/indra/newview/llinventorybridge.cpp b/linden/indra/newview/llinventorybridge.cpp index eb2170a..23d864e 100644 --- a/linden/indra/newview/llinventorybridge.cpp +++ b/linden/indra/newview/llinventorybridge.cpp @@ -3123,11 +3123,11 @@ void LLNotecardBridge::openItem() LLViewerInventoryItem* item = getItem(); if (item) { - if(isSkySetting()) + if(LLWLParamManager::isSkySettingsNotecard(getName())) { LLWLParamManager::instance()->loadPresetNotecard(item->getName(), item->getAssetUUID(), mUUID); } - else if(isWaterSetting()) + else if(LLWLParamManager::isWaterSettingsNotecard(getName())) { LLWaterParamManager::instance()->loadPresetNotecard(item->getName(), item->getAssetUUID(), mUUID); } @@ -3158,13 +3158,13 @@ void LLNotecardBridge::buildContextMenu(LLMenuGL& menu, U32 flags) else { - if(isWindLight()) + if(LLWLParamManager::isSettingsNotecard(getName())) { - if(isSkySetting()) + if(LLWLParamManager::isSkySettingsNotecard(getName())) { items.push_back(std::string("Use WindLight Settings")); } - else if(isWaterSetting()) + else if(LLWLParamManager::isWaterSettingsNotecard(getName())) { items.push_back(std::string("Use WaterLight Settings")); } @@ -3221,11 +3221,11 @@ void LLNotecardBridge::performAction(LLFolderView* folder, LLInventoryModel* mod LLUIImagePtr LLNotecardBridge::getIcon() const { - if(isSkySetting()) + if(LLWLParamManager::isSkySettingsNotecard(getName())) { return LLUI::getUIImage("Inv_WindLight"); } - else if(isWaterSetting()) + else if(LLWLParamManager::isWaterSettingsNotecard(getName())) { return LLUI::getUIImage("Inv_WaterLight"); } @@ -3235,20 +3235,6 @@ LLUIImagePtr LLNotecardBridge::getIcon() const } } -bool LLNotecardBridge::isSkySetting() const -{ - return (getName().length() > 2 && getName().compare(getName().length() - 3, 3, ".wl") == 0); -} - -bool LLNotecardBridge::isWaterSetting() const -{ - return (getName().length() > 2 && getName().compare(getName().length() - 3, 3, ".ww") == 0); -} - -bool LLNotecardBridge::isWindLight() const -{ - return (isSkySetting() || isWaterSetting()); -} // +=================================================+ // | LLGestureBridge | diff --git a/linden/indra/newview/llinventorybridge.h b/linden/indra/newview/llinventorybridge.h index 5a53aa5..0318e6c 100644 --- a/linden/indra/newview/llinventorybridge.h +++ b/linden/indra/newview/llinventorybridge.h @@ -511,9 +511,6 @@ public: virtual const std::string& getPrefix() { return sPrefix; } virtual LLUIImagePtr getIcon() const; - bool isSkySetting() const; - bool isWaterSetting() const; - bool isWindLight() const; virtual void openItem(); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual void performAction(LLFolderView* folder, LLInventoryModel* model, std::string action); diff --git a/linden/indra/newview/llpanelinventory.cpp b/linden/indra/newview/llpanelinventory.cpp index 277ab15..8103ee9 100644 --- a/linden/indra/newview/llpanelinventory.cpp +++ b/linden/indra/newview/llpanelinventory.cpp @@ -81,6 +81,7 @@ #include "llviewerobjectlist.h" #include "llviewerwindow.h" #include "llwearable.h" +#include "llwlparammanager.h" #include "hippogridmanager.h" @@ -1380,9 +1381,6 @@ public: virtual LLUIImagePtr getIcon() const; virtual void openItem(); virtual BOOL removeItem(); - bool isSkySetting() const; - bool isWaterSetting() const; - bool isWindLight() const; }; LLTaskNotecardBridge::LLTaskNotecardBridge( @@ -1412,7 +1410,7 @@ void LLTaskNotecardBridge::openItem() return; } // [/RLVa:KB] - if(isWindLight()) + if(LLWLParamManager::isSettingsNotecard(getName())) { return; } @@ -1442,11 +1440,11 @@ BOOL LLTaskNotecardBridge::removeItem() } LLUIImagePtr LLTaskNotecardBridge::getIcon() const { - if(isSkySetting()) + if(LLWLParamManager::isSkySettingsNotecard(getName())) { return LLUI::getUIImage("Inv_WindLight"); } - else if(isWaterSetting()) + else if(LLWLParamManager::isWaterSettingsNotecard(getName())) { return LLUI::getUIImage("Inv_WaterLight"); } @@ -1456,22 +1454,6 @@ LLUIImagePtr LLTaskNotecardBridge::getIcon() const } } -bool LLTaskNotecardBridge::isSkySetting() const -{ - return (getName().length() > 2 && getName().compare(getName().length() - 3, 3, ".wl") == 0); -} - -bool LLTaskNotecardBridge::isWaterSetting() const -{ - return (getName().length() > 2 && getName().compare(getName().length() - 3, 3, ".ww") == 0); -} - -bool LLTaskNotecardBridge::isWindLight() const -{ - return (isSkySetting() || isWaterSetting()); -} - - ///---------------------------------------------------------------------------- /// Class LLTaskGestureBridge ///---------------------------------------------------------------------------- diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index f0c7c0c..9b1b00d 100755 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp @@ -132,6 +132,7 @@ #include "llvlmanager.h" #include "llvoavatar.h" #include "llvotextbubble.h" +#include "llwlparammanager.h" #include "llweb.h" #include "llworld.h" #include "pipeline.h" @@ -924,9 +925,7 @@ void open_offer(const std::vector& items, const std::string& from_name) { case LLAssetType::AT_NOTECARD: // Don't show WindLight settings as notecards. - // *TODO: centralise all these damned .wl/.ww checks somewhere. - if((item->getName().length() > 2 && item->getName().compare(item->getName().length() - 3, 3, ".wl") != 0) && - (item->getName().compare(item->getName().length() - 3, 3, ".ww") != 0)) + if(!LLWLParamManager::isSettingsNotecard(item->getName())) { open_notecard((LLViewerInventoryItem*)item, std::string("Note: ") + item->getName(), LLUUID::null, show_keep_discard, LLUUID::null, FALSE); diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index 010aa3d..1148576 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp @@ -836,3 +836,21 @@ void LLWLParamManager::notifyObservers() observer->changed(); } } + +// static +bool LLWLParamManager::isWaterSettingsNotecard(std::string name) +{ + return (name.length() > 2 && name.compare(name.length() - 3, 3, ".ww") == 0); +} + +// static +bool LLWLParamManager::isSkySettingsNotecard(std::string name) +{ + return (name.length() > 2 && name.compare(name.length() - 3, 3, ".wl") == 0); +} + +// static +bool LLWLParamManager::isSettingsNotecard(std::string name) +{ + return (isSkySettingsNotecard(name) || isWaterSettingsNotecard(name)); +} diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h index 0f7b84a..5995b9d 100644 --- a/linden/indra/newview/llwlparammanager.h +++ b/linden/indra/newview/llwlparammanager.h @@ -223,6 +223,11 @@ public: void SetMixTime(LLWLParamSet* mixSet, F32 mixTime); + // Notecard settings checkers. + static bool isWaterSettingsNotecard(std::string name); + static bool isSkySettingsNotecard(std::string name); + static bool isSettingsNotecard(std::string name); + public: // helper variables -- cgit v1.1