diff options
author | dolphin <dolphin@lindenlab.com> | 2013-08-08 09:26:09 -0700 |
---|---|---|
committer | dolphin <dolphin@lindenlab.com> | 2013-08-08 09:26:09 -0700 |
commit | 6354ad379d0850b4cc3969130fb1b30b0e2c0ee9 (patch) | |
tree | ae9feb0a651f54d8f1b2a4a21911d66fff54a30b /indra/newview/llpreviewscript.cpp | |
parent | 08a1ae6839f07aeadb58326208c2c01b2ef667c3 (diff) |
Simplified the experience panel to only the required elements
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rwxr-xr-x | indra/newview/llpreviewscript.cpp | 259 |
1 files changed, 126 insertions, 133 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index ef2eb98ce9..bd8f65e767 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -119,6 +119,57 @@ static bool have_script_upload_cap(LLUUID& object_id) return object && (! object->getRegion()->getCapability("UpdateScriptTask").empty()); } +class ExperienceAssociationResponder : public LLHTTPClient::Responder +{ +public: + ExperienceAssociationResponder(const LLUUID& parent):mParent(parent) + { + } + + LLUUID mParent; + + virtual void result(const LLSD& content) + { + + LLLiveLSLEditor* scriptCore = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", mParent); + + if(!scriptCore) + return; + + LLUUID id; + if(content.has("experience")) + { + id=content["experience"].asUUID(); + } + scriptCore->setAssociatedExperience(id); + } + + virtual void error(U32 status, const std::string& reason) + { + llinfos << "Failed to look up associated script: " << status << ": " << reason << llendl; + } + +}; + +class ExperienceResponder : public LLHTTPClient::Responder +{ +public: + ExperienceResponder(const LLHandle<LLScriptEdCore>& parent):mParent(parent) + { + } + + LLHandle<LLScriptEdCore> mParent; + + virtual void result(const LLSD& content) + { + LLScriptEdCore* scriptCore = mParent.get(); + if(!scriptCore) + return; + + scriptCore->setExperienceIds(content["experience_ids"]); + } +}; + /// --------------------------------------------------------------------------- /// LLLiveLSLFile /// --------------------------------------------------------------------------- @@ -377,44 +428,34 @@ LLScriptEdCore::~LLScriptEdCore() void LLScriptEdCore::experienceChanged() { - enableSave(TRUE); - getChildView("Save_btn")->setEnabled(TRUE); - mAssociatedExperience = mExperiences->getSelectedValue().asUUID(); + if(mAssociatedExperience != mExperiences->getSelectedValue().asUUID()) + { + enableSave(TRUE); + getChildView("Save_btn")->setEnabled(TRUE); + mAssociatedExperience = mExperiences->getSelectedValue().asUUID(); + } } void LLScriptEdCore::onToggleExperience( LLUICtrl *ui, void* userdata ) { LLScriptEdCore* self = (LLScriptEdCore*)userdata; - BOOL checked = self->mExperienceEnabled->get(); - BOOL expand = checked && self->mAssociatedExperience.isNull(); - self->mExpandExperience->setToggleState(expand); - self->mExpandExperience->setEnabled(checked); - self->mExperienceDetails->setVisible(expand); - if(!checked) + + LLUUID id; + if(self->mExperienceEnabled->get()) { - if(self->mAssociatedExperience.notNull()) + if(self->mAssociatedExperience.isNull()) { - self->enableSave(TRUE); + id=self->mExperienceIds.beginArray()->asUUID(); } - self->setAssociatedExperience(LLUUID::null); } - else if (expand) + + if(id != self->mAssociatedExperience) { - self->mExperiences->selectFirstItem(); - self->setAssociatedExperience(self->mExperiences->getSelectedValue().asUUID()); self->enableSave(TRUE); } + self->setAssociatedExperience(id); } -void LLScriptEdCore::onToggleExperienceDetails( void* userdata ) -{ - LLScriptEdCore* self = (LLScriptEdCore*)userdata; - BOOL checked = self->mExperienceEnabled->get(); - BOOL expanded = self->mExpandExperience->getToggleState(); - self->mExperienceDetails->setVisible(checked && expanded); -} - - BOOL LLScriptEdCore::postBuild() { mErrorList = getChild<LLScrollListCtrl>("lsl errors"); @@ -425,9 +466,6 @@ BOOL LLScriptEdCore::postBuild() mExperiences->setCommitCallback(boost::bind(&LLScriptEdCore::experienceChanged, this)); mExperienceEnabled = getChild<LLCheckBoxCtrl>("enable_xp"); - mExpandExperience = getChild<LLButton>("Expand Experience"); - mExperienceDetails = getChild<LLUICtrl>("Experience Details"); - mExpandExperience->setClickedCallback(boost::bind(&LLScriptEdCore::onToggleExperienceDetails, this)); childSetCommitCallback("enable_xp", onToggleExperience, this); @@ -1247,152 +1285,107 @@ bool LLScriptEdCore::enableLoadFromFileMenu(void* userdata) return (self && self->mEditor) ? self->mEditor->canLoadOrSaveToFile() : FALSE; } - -void AddExperienceResult(LLHandle<LLScriptEdCore> panel, const LLSD& experience) +LLUUID LLScriptEdCore::getAssociatedExperience()const { - LLScriptEdCore* scriptCore = panel.get(); - if(scriptCore) - { - scriptCore->addExperienceInfo(experience); - } + return mAssociatedExperience; } - -class ExperienceResponder : public LLHTTPClient::Responder +void LLScriptEdCore::setExperienceIds( const LLSD& experience_ids ) { -public: - ExperienceResponder(const LLHandle<LLScriptEdCore>& parent):mParent(parent) - { - } - - LLHandle<LLScriptEdCore> mParent; - - virtual void result(const LLSD& content) - { - LLScriptEdCore* scriptCore = mParent.get(); - if(!scriptCore) - return; - - scriptCore->clearExperiences(); + mExperienceIds=experience_ids; + updateExperiencePanel(); +} - LLSD experiences = content["experience_ids"]; - LLSD::array_const_iterator it = experiences.beginArray(); - for( /**/ ; it != experiences.endArray(); ++it) - { - LLUUID public_key = it->asUUID(); - LLExperienceCache::get(public_key, boost::bind(AddExperienceResult, mParent, _1)); - } - } -}; - -class ExperienceAssociationResponder : public LLHTTPClient::Responder +void LLScriptEdCore::updateExperiencePanel() { -public: - ExperienceAssociationResponder(const LLUUID& parent):mParent(parent) - { - } + BOOL editable = mEditor->getEnabled(); - LLUUID mParent; - - virtual void result(const LLSD& content) + if(mAssociatedExperience.isNull()) { - - LLLiveLSLEditor* scriptCore = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", mParent); - - if(!scriptCore) - return; - - LLUUID id; - if(content.has("experience")) + mExperienceEnabled->set(FALSE); + mExperiences->setVisible(FALSE); + if(mExperienceIds.size()>0) { - id=content["experience"].asUUID(); + mExperienceEnabled->setEnabled(TRUE); + mExperienceEnabled->setToolTip(getString("add_experiences")); } - scriptCore->setAssociatedExperience(id); + else + { + mExperienceEnabled->setEnabled(FALSE); + mExperienceEnabled->setToolTip(getString("no_experiences")); + } + getChild<LLButton>("view_profile")->setVisible(FALSE); } - - virtual void error(U32 status, const std::string& reason) + else { - llinfos << "Failed to look up associated script: " << status << ": " << reason << llendl; + mExperienceEnabled->setToolTip(getString("experience_enabled")); + mExperienceEnabled->setEnabled(editable); + mExperienceEnabled->set(TRUE); + mExperiences->setVisible(TRUE); + getChild<LLButton>("view_profile")->setVisible(TRUE); + buildExperienceList(); } - -}; - -void LLScriptEdCore::requestExperiences() -{ - mExperiences->setEnabled(FALSE); - - LLViewerRegion* region = gAgent.getRegion(); - if (region) - { - std::string lookup_url=region->getCapability("GetCreatorExperiences"); - if(!lookup_url.empty()) - { - LLHTTPClient::get(lookup_url, new ExperienceResponder(getDerivedHandle<LLScriptEdCore>())); - } - } } -void LLScriptEdCore::addExperienceInfo( const LLSD& experience ) -{ - mExperiences->setEnabled(TRUE); - mExperiences->add(experience[LLExperienceCache::NAME], experience[LLExperienceCache::EXPERIENCE_ID].asUUID()); - if(mAssociatedExperience == experience[LLExperienceCache::EXPERIENCE_ID].asUUID()) +void LLScriptEdCore::addExperienceInfo(const LLSD& experience, BOOL enabled) +{ + LLUUID id = experience[LLExperienceCache::EXPERIENCE_ID].asUUID(); + EAddPosition position = (id == mAssociatedExperience)?ADD_TOP:ADD_BOTTOM; + LLScrollListItem* item=mExperiences->add(experience[LLExperienceCache::NAME], id, position ); + if(!enabled) { - setAssociatedExperience(mAssociatedExperience); - } - LLUICtrl* no_experiences=getChild<LLUICtrl>("No Experiences"); - if(no_experiences) - { - no_experiences->setVisible(FALSE); + item->setEnabled(FALSE); } } -void LLScriptEdCore::clearExperiences() +void LLScriptEdCore::buildExperienceList() { - mExperiences->removeall(); - mExperiences->setEnabled(FALSE); - LLUICtrl* no_experiences=getChild<LLUICtrl>("No Experiences"); - if(no_experiences) + mExperiences->clear(); + bool foundAssociated=false; + for(LLSD::array_const_iterator it = mExperienceIds.beginArray(); it != mExperienceIds.endArray(); ++it) { - no_experiences->setVisible(TRUE); + LLUUID id = it->asUUID(); + foundAssociated |= (id == mAssociatedExperience); + LLExperienceCache::get(id, boost::bind(&LLScriptEdCore::addExperienceInfo, this, _1, TRUE)); + } + + if(!foundAssociated ) + { + LLExperienceCache::get(mAssociatedExperience, boost::bind(&LLScriptEdCore::addExperienceInfo, this, _1, FALSE)); } -} -LLUUID LLScriptEdCore::getAssociatedExperience()const -{ - return mAssociatedExperience; } + void LLScriptEdCore::setAssociatedExperience( const LLUUID& experience_id ) { - mExperienceEnabled->setEnabled(TRUE); mAssociatedExperience = experience_id; - if(experience_id.notNull()) - { - LLExperienceCache::get(experience_id, boost::bind(&LLScriptEdCore::addAssociatedExperience, this, _1)); - } + updateExperiencePanel(); } -void LLScriptEdCore::addAssociatedExperience(const LLSD& experience) -{ - if(mExperiences->setSelectedByValue(mAssociatedExperience, TRUE)) + +void LLScriptEdCore::requestExperiences() +{ + if (!mEditor->getEnabled()) { - mExperienceEnabled->set(TRUE); - mExpandExperience->setEnabled(TRUE); + return; } - else + + LLViewerRegion* region = gAgent.getRegion(); + if (region) { - mExperiences->add(experience[LLExperienceCache::NAME], experience[LLExperienceCache::EXPERIENCE_ID].asUUID(), ADD_TOP, FALSE); - mExperienceEnabled->set(FALSE); + std::string lookup_url=region->getCapability("GetCreatorExperiences"); + if(!lookup_url.empty()) + { + LLHTTPClient::get(lookup_url, new ExperienceResponder(getDerivedHandle<LLScriptEdCore>())); + } } } - - /// --------------------------------------------------------------------------- /// LLScriptEdContainer /// --------------------------------------------------------------------------- |