From 08a1ae6839f07aeadb58326208c2c01b2ef667c3 Mon Sep 17 00:00:00 2001 From: dolphin Date: Tue, 6 Aug 2013 16:05:09 -0700 Subject: Checkpoint script editor --- indra/newview/llfloaterscriptexperience.cpp | 13 + indra/newview/llfloaterscriptexperience.h | 45 ++ indra/newview/llpreviewscript.cpp | 91 +++- indra/newview/llpreviewscript.h | 15 +- .../skins/default/xui/en/panel_script_ed.xml | 509 ++++++++++++--------- .../default/xui/en/panel_script_experience.xml | 97 ++++ 6 files changed, 544 insertions(+), 226 deletions(-) create mode 100644 indra/newview/llfloaterscriptexperience.cpp create mode 100644 indra/newview/llfloaterscriptexperience.h create mode 100644 indra/newview/skins/default/xui/en/panel_script_experience.xml diff --git a/indra/newview/llfloaterscriptexperience.cpp b/indra/newview/llfloaterscriptexperience.cpp new file mode 100644 index 0000000000..497522e821 --- /dev/null +++ b/indra/newview/llfloaterscriptexperience.cpp @@ -0,0 +1,13 @@ +#include "llviewerprecompiledheaders.h" + +#include "llfloaterscriptexperience.h" + +LLFloaterScriptExperience::LLFloaterScriptExperience(const LLSD& data) + :LLFloater(data) +{ +} + +BOOL LLFloaterScriptExperience::postBuild() +{ + return TRUE; +} diff --git a/indra/newview/llfloaterscriptexperience.h b/indra/newview/llfloaterscriptexperience.h new file mode 100644 index 0000000000..c79ff78131 --- /dev/null +++ b/indra/newview/llfloaterscriptexperience.h @@ -0,0 +1,45 @@ +/** + * @file llfloaterscriptexperience.h + * @brief LLFloaterScriptExperience class definition + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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_LLFLOATERSCRIPTEXPERIENCE_H +#define LL_LLFLOATERSCRIPTEXPERIENCE_H + +#include "llfloater.h" + +class LLFloaterScriptExperience : + public LLFloater +{ +public: + LLFloaterScriptExperience(const LLSD& data); + +protected: + /*virtual*/ BOOL postBuild(); + +private: + +}; + +#endif //LL_LLFLOATERSCRIPTEXPERIENCE_H diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index bba0f1330c..ef2eb98ce9 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -378,9 +378,43 @@ LLScriptEdCore::~LLScriptEdCore() void LLScriptEdCore::experienceChanged() { enableSave(TRUE); - getChildView("Save_btn")->setEnabled(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) + { + if(self->mAssociatedExperience.notNull()) + { + self->enableSave(TRUE); + } + self->setAssociatedExperience(LLUUID::null); + } + else if (expand) + { + self->mExperiences->selectFirstItem(); + self->setAssociatedExperience(self->mExperiences->getSelectedValue().asUUID()); + self->enableSave(TRUE); + } +} + +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("lsl errors"); @@ -390,6 +424,14 @@ BOOL LLScriptEdCore::postBuild() mExperiences = getChild("Experiences..."); mExperiences->setCommitCallback(boost::bind(&LLScriptEdCore::experienceChanged, this)); + mExperienceEnabled = getChild("enable_xp"); + mExpandExperience = getChild("Expand Experience"); + mExperienceDetails = getChild("Experience Details"); + mExpandExperience->setClickedCallback(boost::bind(&LLScriptEdCore::onToggleExperienceDetails, this)); + + childSetCommitCallback("enable_xp", onToggleExperience, this); + + childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this); mEditor = getChild("Script Editor"); @@ -1258,10 +1300,15 @@ public: LLLiveLSLEditor* scriptCore = LLFloaterReg::findTypedInstance("preview_scriptedit", mParent); - if(!scriptCore || !content.has("experience")) + if(!scriptCore) return; - scriptCore->setAssociatedExperience(content["experience"].asUUID()); + LLUUID id; + if(content.has("experience")) + { + id=content["experience"].asUUID(); + } + scriptCore->setAssociatedExperience(id); } virtual void error(U32 status, const std::string& reason) @@ -1294,31 +1341,53 @@ void LLScriptEdCore::addExperienceInfo( const LLSD& experience ) { setAssociatedExperience(mAssociatedExperience); } + LLUICtrl* no_experiences=getChild("No Experiences"); + if(no_experiences) + { + no_experiences->setVisible(FALSE); + } } void LLScriptEdCore::clearExperiences() { mExperiences->removeall(); - mExperiences->add("No Experience", LLUUID::null); + mExperiences->setEnabled(FALSE); + LLUICtrl* no_experiences=getChild("No Experiences"); + if(no_experiences) + { + no_experiences->setVisible(TRUE); + } } -LLUUID LLScriptEdCore::getSelectedExperience()const +LLUUID LLScriptEdCore::getAssociatedExperience()const { - return mExperiences->getSelectedValue().asUUID(); + return mAssociatedExperience; } void LLScriptEdCore::setAssociatedExperience( const LLUUID& experience_id ) { + mExperienceEnabled->setEnabled(TRUE); mAssociatedExperience = experience_id; if(experience_id.notNull()) { - if(!mExperiences->setSelectedByValue(mAssociatedExperience, TRUE)) - { - mExperiences->setSelectedByValue(LLUUID::null, TRUE); - } + LLExperienceCache::get(experience_id, boost::bind(&LLScriptEdCore::addAssociatedExperience, this, _1)); } } +void LLScriptEdCore::addAssociatedExperience(const LLSD& experience) +{ + + if(mExperiences->setSelectedByValue(mAssociatedExperience, TRUE)) + { + mExperienceEnabled->set(TRUE); + mExpandExperience->setEnabled(TRUE); + } + else + { + mExperiences->add(experience[LLExperienceCache::NAME], experience[LLExperienceCache::EXPERIENCE_ID].asUUID(), ADD_TOP, FALSE); + mExperienceEnabled->set(FALSE); + } +} @@ -2284,7 +2353,7 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/) BOOL is_running = getChild( "running")->get(); if (!url.empty()) { - uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running, mScriptEd->getSelectedExperience()); + uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running, mScriptEd->getAssociatedExperience()); } else if (gAssetStorage) { diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 28e71b111a..043bf9c0b7 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -100,7 +100,9 @@ public: static void onBtnInsertSample(void*); static void onBtnInsertFunction(LLUICtrl*, void*); static void onBtnLoadFromFile(void*); - static void onBtnSaveToFile(void*); + static void onBtnSaveToFile(void*); + static void onToggleExperience(LLUICtrl *ui, void* userdata); + static void onToggleExperienceDetails(void* userdata); static bool enableSaveToFileMenu(void* userdata); static bool enableLoadFromFileMenu(void* userdata); @@ -108,7 +110,8 @@ public: virtual bool hasAccelerators() const { return true; } void addExperienceInfo( const LLSD& experience ); void clearExperiences(); - LLUUID getSelectedExperience()const; + LLUUID getAssociatedExperience()const; + void setAssociatedExperience( const LLUUID& experience_id ); private: @@ -125,7 +128,8 @@ private: void enableSave(BOOL b) {mEnableSave = b;} void requestExperiences(); - void experienceChanged(); + void experienceChanged(); + void addAssociatedExperience(const LLSD& experience); protected: void deleteBridges(); @@ -142,7 +146,10 @@ private: void (*mSearchReplaceCallback) (void* userdata); void* mUserdata; LLComboBox *mFunctions; - LLComboBox *mExperiences; + LLComboBox *mExperiences; + LLCheckBoxCtrl *mExperienceEnabled; + LLUICtrl *mExperienceDetails; + LLButton *mExpandExperience; BOOL mForceClose; LLPanel* mCodePanel; LLScrollListCtrl* mErrorList; diff --git a/indra/newview/skins/default/xui/en/panel_script_ed.xml b/indra/newview/skins/default/xui/en/panel_script_ed.xml index 7e4ac1d7fb..331157d713 100755 --- a/indra/newview/skins/default/xui/en/panel_script_ed.xml +++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml @@ -1,216 +1,303 @@ - - Loading... - - - 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. - - - Public Objects cannot run scripts - - - Running - - - Script: [NAME] - - - Select an editor by setting the environment variable LL_SCRIPT_EDITOR or the ExternalEditor setting. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Loading... - - + + Loading... + + + 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. + + + Public Objects cannot run scripts + + + Running + + + Script: [NAME] + + + Select an editor by setting the environment variable LL_SCRIPT_EDITOR or the ExternalEditor setting. + + - - - + + + + + + + + + + + Associate with: + + + + + + + + + You are not a contributor to any experiences. + + + + diff --git a/indra/newview/skins/default/xui/en/panel_script_experience.xml b/indra/newview/skins/default/xui/en/panel_script_experience.xml new file mode 100644 index 0000000000..e798638751 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_script_experience.xml @@ -0,0 +1,97 @@ + + + + + + + + + Script: + + + Associated with: + + + You can contribute: + + + Associate with: + + + + + + EasySit Animator 1.2.4 + + + Kyle's Superhero RPG + + + Yes + + + + + + You are not a contributor to any experiences. + + -- cgit v1.2.3