From 02b501e4dc9a389878cd323e4f781bc752fec737 Mon Sep 17 00:00:00 2001 From: dolphin Date: Thu, 15 Aug 2013 09:32:12 -0700 Subject: Move the experience panel to the bottom of the editor floater --- indra/newview/CMakeLists.txt | 2 + indra/newview/llexperienceassociationresponder.cpp | 80 ++ indra/newview/llexperienceassociationresponder.h | 53 ++ indra/newview/llpreviewscript.cpp | 132 ++- indra/newview/llpreviewscript.h | 35 +- .../default/xui/en/floater_live_lsleditor.xml | 167 ++-- .../skins/default/xui/en/panel_script_ed.xml | 41 +- .../skins/default/xui/en/sidepanel_item_info.xml | 889 +++++++++++---------- indra/tools/vstool/DispatchUtility.cs | 271 +++++++ indra/tools/vstool/app.config | 3 + 10 files changed, 1051 insertions(+), 622 deletions(-) create mode 100644 indra/newview/llexperienceassociationresponder.cpp create mode 100644 indra/newview/llexperienceassociationresponder.h create mode 100644 indra/tools/vstool/DispatchUtility.cs create mode 100644 indra/tools/vstool/app.config diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 7d361e4f6a..9caff9e038 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -188,6 +188,7 @@ set(viewer_SOURCE_FILES lleventnotifier.cpp lleventpoll.cpp llexpandabletextbox.cpp + llexperienceassociationresponder.cpp llexternaleditor.cpp llface.cpp llfasttimerview.cpp @@ -773,6 +774,7 @@ set(viewer_HEADER_FILES lleventnotifier.h lleventpoll.h llexpandabletextbox.h + llexperienceassociationresponder.h llexternaleditor.h llface.h llfasttimerview.h diff --git a/indra/newview/llexperienceassociationresponder.cpp b/indra/newview/llexperienceassociationresponder.cpp new file mode 100644 index 0000000000..69451bc054 --- /dev/null +++ b/indra/newview/llexperienceassociationresponder.cpp @@ -0,0 +1,80 @@ +/** + * @file llexperienceassociationresponder.cpp + * @brief llexperienceassociationresponder implementation + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llexperienceassociationresponder.h" +#include "llexperiencecache.h" + +ExperienceAssociationResponder::ExperienceAssociationResponder(ExperienceAssociationResponder::callback_t callback):mCallback(callback) +{ + ref(); +} + +void ExperienceAssociationResponder::error( U32 status, const std::string& reason ) +{ + LLSD msg; + msg["error"]=(LLSD::Integer)status; + msg["message"]=reason; + LL_INFOS("ExperienceAssociation") << "Failed to look up associated experience: " << status << ": " << reason << LL_ENDL; + + sendResult(msg); + +} +void ExperienceAssociationResponder::result( const LLSD& content ) +{ + if(!content.has("experience")) + { + + LLSD msg; + msg["message"]="no experience"; + msg["error"]=-1; + sendResult(msg); + LL_ERRS("ExperienceAssociation") << "Associated experience missing" << LL_ENDL; + } + + LLExperienceCache::get(content["experience"].asUUID(), boost::bind(&ExperienceAssociationResponder::sendResult, this, _1)); + + /* LLLiveLSLEditor* scriptCore = LLFloaterReg::findTypedInstance("preview_scriptedit", mParent); + + if(!scriptCore) + return; + + LLUUID id; + if(content.has("experience")) + { + id=content["experience"].asUUID(); + } + scriptCore->setAssociatedExperience(id);*/ +} + +void ExperienceAssociationResponder::sendResult( const LLSD& experience ) +{ + mCallback(experience); + unref(); +} + + + diff --git a/indra/newview/llexperienceassociationresponder.h b/indra/newview/llexperienceassociationresponder.h new file mode 100644 index 0000000000..aa0c51abb5 --- /dev/null +++ b/indra/newview/llexperienceassociationresponder.h @@ -0,0 +1,53 @@ +#include "llhttpclient.h" +#include "llsd.h" +/** + * @file llexperienceassociationresponder.h + * @brief llexperienceassociationresponder and related class definitions + * + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + + + +#ifndef LL_LLEXPERIENCEASSOCIATIONRESPONDER_H +#define LL_LLEXPERIENCEASSOCIATIONRESPONDER_H + +#include "llhttpclient.h" +#include "llsd.h" + +class ExperienceAssociationResponder : public LLHTTPClient::Responder +{ +public: + typedef boost::function callback_t; + + ExperienceAssociationResponder(callback_t callback); + virtual void result(const LLSD& content); + virtual void error(U32 status, const std::string& reason); + +private: + void sendResult(const LLSD& experience); + + callback_t mCallback; + +}; + +#endif // LL_LLEXPERIENCEASSOCIATIONRESPONDER_H diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index bd8f65e767..09152ac060 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -87,6 +87,7 @@ #include "llviewercontrol.h" #include "llappviewer.h" #include "llexperiencecache.h" +#include "llexperienceassociationresponder.h" const std::string HELLO_LSL = "default\n" @@ -119,54 +120,23 @@ 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("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& parent):mParent(parent) + ExperienceResponder(const LLHandle& parent):mParent(parent) { } - LLHandle mParent; + LLHandle mParent; virtual void result(const LLSD& content) { - LLScriptEdCore* scriptCore = mParent.get(); - if(!scriptCore) + LLLiveLSLEditor* parent = mParent.get(); + if(!parent) return; - scriptCore->setExperienceIds(content["experience_ids"]); + parent->setExperienceIds(content["experience_ids"]); } }; @@ -426,34 +396,37 @@ LLScriptEdCore::~LLScriptEdCore() delete mLiveFile; } -void LLScriptEdCore::experienceChanged() +void LLLiveLSLEditor::experienceChanged() { - if(mAssociatedExperience != mExperiences->getSelectedValue().asUUID()) + if(mScriptEd->getAssociatedExperience() != mExperiences->getSelectedValue().asUUID()) { - enableSave(TRUE); - getChildView("Save_btn")->setEnabled(TRUE); - mAssociatedExperience = mExperiences->getSelectedValue().asUUID(); + mScriptEd->enableSave(getIsModifiable()); + //getChildView("Save_btn")->setEnabled(TRUE); + mScriptEd->setAssociatedExperience(mExperiences->getSelectedValue().asUUID()); + updateExperiencePanel(); } } -void LLScriptEdCore::onToggleExperience( LLUICtrl *ui, void* userdata ) +void LLLiveLSLEditor::onToggleExperience( LLUICtrl *ui, void* userdata ) { - LLScriptEdCore* self = (LLScriptEdCore*)userdata; + LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata; LLUUID id; if(self->mExperienceEnabled->get()) { - if(self->mAssociatedExperience.isNull()) + if(self->mScriptEd->getAssociatedExperience().isNull()) { id=self->mExperienceIds.beginArray()->asUUID(); } } - if(id != self->mAssociatedExperience) + if(id != self->mScriptEd->getAssociatedExperience()) { - self->enableSave(TRUE); + self->mScriptEd->enableSave(self->getIsModifiable()); } - self->setAssociatedExperience(id); + self->mScriptEd->setAssociatedExperience(id); + + self->updateExperiencePanel(); } BOOL LLScriptEdCore::postBuild() @@ -462,12 +435,6 @@ BOOL LLScriptEdCore::postBuild() mFunctions = getChild( "Insert..."); - mExperiences = getChild("Experiences..."); - mExperiences->setCommitCallback(boost::bind(&LLScriptEdCore::experienceChanged, this)); - - mExperienceEnabled = getChild("enable_xp"); - - childSetCommitCallback("enable_xp", onToggleExperience, this); childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this); @@ -482,8 +449,6 @@ BOOL LLScriptEdCore::postBuild() - requestExperiences(); - std::vector funcs; std::vector tooltips; @@ -1290,18 +1255,18 @@ LLUUID LLScriptEdCore::getAssociatedExperience()const return mAssociatedExperience; } -void LLScriptEdCore::setExperienceIds( const LLSD& experience_ids ) +void LLLiveLSLEditor::setExperienceIds( const LLSD& experience_ids ) { mExperienceIds=experience_ids; updateExperiencePanel(); } -void LLScriptEdCore::updateExperiencePanel() +void LLLiveLSLEditor::updateExperiencePanel() { - BOOL editable = mEditor->getEnabled(); + BOOL editable = getIsModifiable(); - if(mAssociatedExperience.isNull()) + if(mScriptEd->getAssociatedExperience().isNull()) { mExperienceEnabled->set(FALSE); mExperiences->setVisible(FALSE); @@ -1328,10 +1293,10 @@ void LLScriptEdCore::updateExperiencePanel() } } -void LLScriptEdCore::addExperienceInfo(const LLSD& experience, BOOL enabled) +void LLLiveLSLEditor::addExperienceInfo(const LLSD& experience, BOOL enabled) { LLUUID id = experience[LLExperienceCache::EXPERIENCE_ID].asUUID(); - EAddPosition position = (id == mAssociatedExperience)?ADD_TOP:ADD_BOTTOM; + EAddPosition position = (id == mScriptEd->getAssociatedExperience())?ADD_TOP:ADD_BOTTOM; LLScrollListItem* item=mExperiences->add(experience[LLExperienceCache::NAME], id, position ); if(!enabled) { @@ -1339,20 +1304,20 @@ void LLScriptEdCore::addExperienceInfo(const LLSD& experience, BOOL enabled) } } -void LLScriptEdCore::buildExperienceList() +void LLLiveLSLEditor::buildExperienceList() { mExperiences->clear(); bool foundAssociated=false; for(LLSD::array_const_iterator it = mExperienceIds.beginArray(); it != mExperienceIds.endArray(); ++it) { LLUUID id = it->asUUID(); - foundAssociated |= (id == mAssociatedExperience); - LLExperienceCache::get(id, boost::bind(&LLScriptEdCore::addExperienceInfo, this, _1, TRUE)); + foundAssociated |= (id == mScriptEd->getAssociatedExperience()); + LLExperienceCache::get(id, boost::bind(&LLLiveLSLEditor::addExperienceInfo, this, _1, TRUE)); } if(!foundAssociated ) { - LLExperienceCache::get(mAssociatedExperience, boost::bind(&LLScriptEdCore::addExperienceInfo, this, _1, FALSE)); + LLExperienceCache::get(mScriptEd->getAssociatedExperience(), boost::bind(&LLLiveLSLEditor::addExperienceInfo, this, _1, FALSE)); } } @@ -1361,14 +1326,13 @@ void LLScriptEdCore::buildExperienceList() void LLScriptEdCore::setAssociatedExperience( const LLUUID& experience_id ) { mAssociatedExperience = experience_id; - updateExperiencePanel(); } -void LLScriptEdCore::requestExperiences() +void LLLiveLSLEditor::requestExperiences() { - if (!mEditor->getEnabled()) + if (!getIsModifiable()) { return; } @@ -1379,7 +1343,7 @@ void LLScriptEdCore::requestExperiences() std::string lookup_url=region->getCapability("GetCreatorExperiences"); if(!lookup_url.empty()) { - LLHTTPClient::get(lookup_url, new ExperienceResponder(getDerivedHandle())); + LLHTTPClient::get(lookup_url, new ExperienceResponder(getDerivedHandle())); } } } @@ -1945,6 +1909,15 @@ BOOL LLLiveLSLEditor::postBuild() mScriptEd->mEditor->makePristine(); mScriptEd->mEditor->setFocus(TRUE); + + mExperiences = getChild("Experiences..."); + mExperiences->setCommitCallback(boost::bind(&LLLiveLSLEditor::experienceChanged, this)); + + mExperienceEnabled = getChild("enable_xp"); + + childSetCommitCallback("enable_xp", onToggleExperience, this); + + return LLPreview::postBuild(); } @@ -2078,6 +2051,8 @@ void LLLiveLSLEditor::loadAsset() time_corrected()); mAssetStatus = PREVIEW_ASSET_LOADED; } + + requestExperiences(); } // static @@ -2556,7 +2531,11 @@ void LLLiveLSLEditor::fetchAssociatedExperience(const LLUUID& asset_id) LLSD fields; fields.append("experience"); request["fields"] = fields; - LLHTTPClient::post(lookup_url, request, new ExperienceAssociationResponder(getKey())); + + ExperienceAssociationResponder::callback_t f = boost::bind(&LLLiveLSLEditor::setAssociatedExperience, getDerivedHandle(), _1); + LLHTTPClient::post(lookup_url, request, new ExperienceAssociationResponder(f)); + + //test me pls } } } @@ -2634,10 +2613,17 @@ BOOL LLLiveLSLEditor::monoChecked() const return FALSE; } -void LLLiveLSLEditor::setAssociatedExperience( const LLUUID& experience_id ) +void LLLiveLSLEditor::setAssociatedExperience( LLHandle editor, const LLSD& experience ) { - if(mScriptEd) + LLLiveLSLEditor* scriptEd = editor.get(); + if(scriptEd) { - mScriptEd->setAssociatedExperience(experience_id); + LLUUID id; + if(experience.has(LLExperienceCache::EXPERIENCE_ID)) + { + id=experience[LLExperienceCache::EXPERIENCE_ID].asUUID(); + } + scriptEd->mScriptEd->setAssociatedExperience(id); + scriptEd->updateExperiencePanel(); } } diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 9578396f91..bd594cdb9d 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -101,19 +101,13 @@ public: static void onBtnInsertFunction(LLUICtrl*, void*); static void onBtnLoadFromFile(void*); static void onBtnSaveToFile(void*); - static void onToggleExperience(LLUICtrl *ui, void* userdata); static bool enableSaveToFileMenu(void* userdata); static bool enableLoadFromFileMenu(void* userdata); - virtual bool hasAccelerators() const { return true; } - void addExperienceInfo( const LLSD& experience, BOOL enabled ); - void setExperienceIds(const LLSD& experience_ids); - void buildExperienceList(); + virtual bool hasAccelerators() const { return true; } LLUUID getAssociatedExperience()const; - void setAssociatedExperience( const LLUUID& experience_id ); - void updateExperiencePanel(); private: void onBtnHelp(); @@ -128,10 +122,6 @@ private: void enableSave(BOOL b) {mEnableSave = b;} - void requestExperiences(); - void experienceChanged(); - void addAssociatedExperience(const LLSD& experience); - protected: void deleteBridges(); void setHelpPage(const std::string& help_string); @@ -146,9 +136,7 @@ private: void (*mSaveCallback)(void* userdata, BOOL close_after_save); void (*mSearchReplaceCallback) (void* userdata); void* mUserdata; - LLComboBox *mFunctions; - LLComboBox *mExperiences; - LLCheckBoxCtrl *mExperienceEnabled; + LLComboBox *mFunctions; BOOL mForceClose; LLPanel* mCodePanel; LLScrollListCtrl* mErrorList; @@ -161,7 +149,6 @@ private: BOOL mHasScriptData; LLLiveLSLFile* mLiveFile; LLUUID mAssociatedExperience; - LLSD mExperienceIds; LLScriptEdContainer* mContainer; // parent view }; @@ -244,8 +231,19 @@ public: /*virtual*/ BOOL postBuild(); void setIsNew() { mIsNew = TRUE; } - void setAssociatedExperience( const LLUUID& experience_id ); + + static void setAssociatedExperience( LLHandle editor, const LLSD& experience ); + static void onToggleExperience(LLUICtrl *ui, void* userdata); + void fetchAssociatedExperience(const LLUUID& asset_id); + + void addExperienceInfo( const LLSD& experience, BOOL enabled ); + void setExperienceIds(const LLSD& experience_ids); + void buildExperienceList(); + void updateExperiencePanel(); + void requestExperiences(); + void experienceChanged(); + void addAssociatedExperience(const LLSD& experience); private: virtual BOOL canClose(); @@ -299,6 +297,11 @@ private: LLCheckBoxCtrl* mMonoCheckbox; BOOL mIsModifiable; + + + LLComboBox *mExperiences; + LLCheckBoxCtrl *mExperienceEnabled; + LLSD mExperienceIds; }; #endif // LL_LLPREVIEWSCRIPT_H diff --git a/indra/newview/skins/default/xui/en/floater_live_lsleditor.xml b/indra/newview/skins/default/xui/en/floater_live_lsleditor.xml index 562936ed80..d8c2a753a1 100755 --- a/indra/newview/skins/default/xui/en/floater_live_lsleditor.xml +++ b/indra/newview/skins/default/xui/en/floater_live_lsleditor.xml @@ -1,71 +1,110 @@  - - You can not view or edit this script, since it has been set as "no copy". You need full permissions to view or edit a script inside an object. - - - Running - - - SCRIPT: [NAME] - - + + You can not view or edit this script, since it has been set as "no copy". You need full permissions to view or edit a script inside an object. + + + Running + + + SCRIPT: [NAME] + + + Uncheck to remove the current experience + + + You are not authorized for any experiences + + + Select to add an experience + + -