From f343623f0f92a346fb22ef88db1e0884965f2561 Mon Sep 17 00:00:00 2001 From: ZiRee Date: Tue, 26 Apr 2011 18:08:09 +0200 Subject: [PATCH] Rename AO sets finished, some better UI handling for checking of names and reloading sets. --- indra/newview/ao.cpp | 55 ++++++++++++++++--- indra/newview/ao.h | 1 + indra/newview/aoengine.cpp | 13 +++++ indra/newview/aoengine.h | 1 + .../skins/default/xui/en/notifications.xml | 19 +++++-- 5 files changed, 78 insertions(+), 11 deletions(-) diff --git a/indra/newview/ao.cpp b/indra/newview/ao.cpp index d9b0907a23..2427f837d5 100644 --- a/indra/newview/ao.cpp +++ b/indra/newview/ao.cpp @@ -37,6 +37,7 @@ #include "llspinctrl.h" #include "llviewercontrol.h" #include "llviewerinventory.h" +#include FloaterAO::FloaterAO(const LLSD& key) : LLTransientDockableFloater(NULL,true,key), @@ -270,12 +271,17 @@ void FloaterAO::onOpen(const LLSD& key) void FloaterAO::onSelectSet() { - mSelectedSet=AOEngine::instance().getSetByName(mSetSelector->getSelectedItemLabel()); - if(mSelectedSet) + AOSet* set=AOEngine::instance().getSetByName(mSetSelector->getSelectedItemLabel()); + if(!set) { - updateSetParameters(); - updateAnimationList(); + onRenameSet(); + return; } + + mSelectedSet=set; + + updateSetParameters(); + updateAnimationList(); } void FloaterAO::onSelectSetSmall() @@ -288,6 +294,37 @@ void FloaterAO::onSelectSetSmall() } } +void FloaterAO::onRenameSet() +{ + if(!mSelectedSet) + { + llwarns << "Rename AO set without set selected." << llendl; + return; + } + + std::string name=mSetSelector->getSimple(); + LLStringUtil::trim(name); + + if(!name.empty()) + { + if(name.find_first_of(":|")==std::string::npos) + { + if(AOEngine::instance().renameSet(mSelectedSet,name)) + { + reloading(TRUE); + return; + } + } + else + { + LLSD args; + args["AO_SET_NAME"]=name; + LLNotificationsUtil::add("RenameAOCantContainColon",args); + } + } + mSetSelector->setSimple(mSelectedSet->getName()); +} + void FloaterAO::onClickActivate() { lldebugs << "Set activated: " << mSetSelector->getSelectedItemLabel() << llendl; @@ -371,11 +408,15 @@ BOOL FloaterAO::newSetCallback(const LLSD& notification,const LLSD& response) std::string newSetName=response["message"].asString(); S32 option=LLNotificationsUtil::getSelectedOption(notification,response); - if(newSetName=="") + LLStringUtil::trim(newSetName); + + if(newSetName.empty()) return FALSE; - else if(newSetName.find(":")!=std::string::npos) + else if(newSetName.find_first_of(":|")!=std::string::npos) { - LLNotificationsUtil::add("NewAOCantContainColon",LLSD()); + LLSD args; + args["AO_SET_NAME"]=newSetName; + LLNotificationsUtil::add("NewAOCantContainColon",args); return FALSE; } diff --git a/indra/newview/ao.h b/indra/newview/ao.h index ef898817a6..cf4d05c816 100644 --- a/indra/newview/ao.h +++ b/indra/newview/ao.h @@ -63,6 +63,7 @@ class FloaterAO void onSelectSet(); void onSelectSetSmall(); + void onRenameSet(); void onSelectState(); void onChangeAnimationSelection(); void onClickReload(); diff --git a/indra/newview/aoengine.cpp b/indra/newview/aoengine.cpp index 4cd81673bb..d5d4805319 100644 --- a/indra/newview/aoengine.cpp +++ b/indra/newview/aoengine.cpp @@ -1047,6 +1047,19 @@ void AOEngine::saveSet(const AOSet* set) gInventory.notifyObservers(); */ rename_category(&gInventory,set->getInventoryUUID(),setParams); + + llwarns << "sending update signal" << llendl; + mUpdatedSignal(); +} + +BOOL AOEngine::renameSet(AOSet* set,const std::string name) +{ + if(name.empty() || name.find(":")!=std::string::npos) + return FALSE; + set->setName(name); + set->setDirty(TRUE); + + return TRUE; } void AOEngine::saveState(const AOSet::AOState* state) diff --git a/indra/newview/aoengine.h b/indra/newview/aoengine.h index 6bf655c29b..ff84d8218b 100644 --- a/indra/newview/aoengine.h +++ b/indra/newview/aoengine.h @@ -133,6 +133,7 @@ class AOEngine const std::vector getSetList() const; const std::string getCurrentSetName() const; const AOSet* getDefaultSet() const; + BOOL renameSet(AOSet* set,const std::string name); void setDefaultSet(AOSet* set); void setOverrideSits(AOSet* set,BOOL yes); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 35537de0ad..f472060ddb 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -7032,7 +7032,7 @@ Reset WL settings for '[PARCEL_NAME]' to region default? name="NewAOSet" type="alertmodal"> Specify a name for the new AO set: -(The name may not contain a : character) +(The name may not contain a ":" or "|" character)
New AO Set @@ -7053,8 +7053,19 @@ New AO Set icon="alertmodal.tga" name="NewAOCantContainColon" type="alertmodal"> -Could not create new AO set. -The name may not contain ":" characters. +Could not create new AO set "[AO_SET_NAME]". +The name may not contain ":" or "|" characters. + + + + +Could not rename new AO set to "[AO_SET_NAME]". +The name may not contain ":" or "|" characters. @@ -7064,7 +7075,7 @@ The name may not contain ":" characters. icon="alertmodal.tga" name="RemoveAOSet" type="alertmodal"> -Remove AO set [AO_SET_NAME] from the list? +Remove AO set "[AO_SET_NAME]" from the list?