summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2025-01-24 00:26:00 +0100
committerAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2025-01-25 03:02:29 +0100
commit7f88aedbc3b53496bc99d8e0e64a818c7a3f6d6f (patch)
tree2877cdffc55025608cfd756ece65a34ddad3dd57 /indra/newview/llpreviewscript.cpp
parent5029f0322f264e17f7509952f7bf9812db17a9ec (diff)
#3423 Add Lua as Compile Target in Viewer Script Editor
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--indra/newview/llpreviewscript.cpp189
1 files changed, 94 insertions, 95 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 02a4c7fb26..432aaa8f18 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -441,42 +441,37 @@ void LLLiveLSLEditor::experienceChanged()
}
}
-void LLLiveLSLEditor::onViewProfile( LLUICtrl *ui, void* userdata )
+void LLLiveLSLEditor::onViewProfile()
{
- LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata;
-
- LLUUID id;
- if(self->mExperienceEnabled->get())
+ if (mExperienceEnabled->get())
{
- id=self->mScriptEd->getAssociatedExperience();
- if(id.notNull())
+ LLUUID id = mScriptEd->getAssociatedExperience();
+ if (id.notNull())
{
LLFloaterReg::showInstance("experience_profile", id, true);
}
}
-
}
-void LLLiveLSLEditor::onToggleExperience( LLUICtrl *ui, void* userdata )
+void LLLiveLSLEditor::onToggleExperience()
{
- LLLiveLSLEditor* self = (LLLiveLSLEditor*)userdata;
-
LLUUID id;
- if(self->mExperienceEnabled->get())
+ if (mExperienceEnabled->get())
{
- if(self->mScriptEd->getAssociatedExperience().isNull())
+ if (mScriptEd->getAssociatedExperience().isNull())
{
- id=self->mExperienceIds.beginArray()->asUUID();
+ id = mExperienceIds.beginArray()->asUUID();
}
}
- if(id != self->mScriptEd->getAssociatedExperience())
+ if (id != mScriptEd->getAssociatedExperience())
{
- self->mScriptEd->enableSave(self->getIsModifiable());
+ mScriptEd->enableSave(getIsModifiable());
}
- self->mScriptEd->setAssociatedExperience(id);
- self->updateExperiencePanel();
+ mScriptEd->setAssociatedExperience(id);
+
+ updateExperiencePanel();
}
bool LLScriptEdCore::postBuild()
@@ -1375,7 +1370,7 @@ void LLLiveLSLEditor::updateExperiencePanel()
mExperienceEnabled->setEnabled(false);
mExperienceEnabled->setToolTip(getString("no_experiences"));
}
- getChild<LLButton>("view_profile")->setVisible(false);
+ mViewProfileButton->setVisible(false);
}
else
{
@@ -1383,7 +1378,7 @@ void LLLiveLSLEditor::updateExperiencePanel()
mExperienceEnabled->setEnabled(getIsModifiable());
mExperiences->setVisible(true);
mExperienceEnabled->set(true);
- getChild<LLButton>("view_profile")->setToolTip(getString("show_experience_profile"));
+ mViewProfileButton->setToolTip(getString("show_experience_profile"));
buildExperienceList();
}
}
@@ -1452,7 +1447,7 @@ void LLLiveLSLEditor::buildExperienceList()
mExperiences->setEnabled(true);
mExperiences->sortByName(true);
mExperiences->setCurrentByIndex(mExperiences->getCurrentIndex());
- getChild<LLButton>("view_profile")->setVisible(true);
+ mViewProfileButton->setVisible(true);
}
}
@@ -1960,28 +1955,26 @@ LLLiveLSLEditor::LLLiveLSLEditor(const LLSD& key) :
bool LLLiveLSLEditor::postBuild()
{
- childSetCommitCallback("running", LLLiveLSLEditor::onRunningCheckboxClicked, this);
- getChildView("running")->setEnabled(false);
+ mResetButton = getChild<LLButton>("reset");
+ mResetButton->setClickedCallback([&](LLUICtrl*, const LLSD&) { onReset(); });
- childSetAction("Reset",&LLLiveLSLEditor::onReset,this);
- getChildView("Reset")->setEnabled(true);
-
- mMonoCheckbox = getChild<LLCheckBoxCtrl>("mono");
- childSetCommitCallback("mono", &LLLiveLSLEditor::onMonoCheckboxClicked, this);
- getChildView("mono")->setEnabled(true);
-
- mScriptEd->mEditor->makePristine();
- mScriptEd->mEditor->setFocus(true);
+ mRunningCheckbox = getChild<LLCheckBoxCtrl>("running");
+ mRunningCheckbox->setCommitCallback([&](LLUICtrl*, const LLSD&) { onRunningCheckboxClicked(); });
+ mCompileTarget = getChild<LLComboBox>("compile_target");
+ mCompileTarget->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCompileTargetChanged(); });
mExperiences = getChild<LLComboBox>("Experiences...");
- mExperiences->setCommitCallback(boost::bind(&LLLiveLSLEditor::experienceChanged, this));
+ mExperiences->setCommitCallback([&](LLUICtrl*, const LLSD&) { experienceChanged(); });
mExperienceEnabled = getChild<LLCheckBoxCtrl>("enable_xp");
+ mExperienceEnabled->setCommitCallback([&](LLUICtrl*, const LLSD&) { onToggleExperience(); });
- childSetCommitCallback("enable_xp", onToggleExperience, this);
- childSetCommitCallback("view_profile", onViewProfile, this);
+ mViewProfileButton = getChild<LLButton>("view_profile");
+ mViewProfileButton->setClickedCallback([&](LLUICtrl*, const LLSD&) { onViewProfile(); });
+ mScriptEd->mEditor->makePristine();
+ mScriptEd->mEditor->setFocus(true);
return LLPreview::postBuild();
}
@@ -1994,7 +1987,7 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id,
LL_DEBUGS() << "LSL Bytecode saved" << LL_ENDL;
mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
- getChild<LLCheckBoxCtrl>("running")->set(is_script_running);
+ mRunningCheckbox->set(is_script_running);
mIsSaving = false;
closeIfNeeded();
}
@@ -2057,9 +2050,10 @@ void LLLiveLSLEditor::loadAsset()
{
mItem = new LLViewerInventoryItem(item);
// request the text from the object
- LLSD* user_data = new LLSD();
- user_data->with("taskid", mObjectUUID).with("itemid", mItemUUID);
- gAssetStorage->getInvItemAsset(object->getRegion()->getHost(),
+ LLSD* user_data = new LLSD();
+ user_data->with("taskid", mObjectUUID).with("itemid", mItemUUID);
+ gAssetStorage->getInvItemAsset(
+ object->getRegion()->getHost(),
gAgent.getID(),
gAgent.getSessionID(),
item->getPermissions().getOwner(),
@@ -2067,8 +2061,8 @@ void LLLiveLSLEditor::loadAsset()
item->getUUID(),
item->getAssetUUID(),
item->getType(),
- &LLLiveLSLEditor::onLoadComplete,
- (void*)user_data,
+ LLLiveLSLEditor::onLoadComplete,
+ user_data,
true);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_GetScriptRunning);
@@ -2202,14 +2196,9 @@ void LLLiveLSLEditor::loadScriptText(const LLUUID &uuid, LLAssetType::EType type
}
-void LLLiveLSLEditor::onRunningCheckboxClicked( LLUICtrl*, void* userdata )
+void LLLiveLSLEditor::onRunningCheckboxClicked()
{
- LLLiveLSLEditor* self = (LLLiveLSLEditor*) userdata;
- LLViewerObject* object = gObjectList.findObject( self->mObjectUUID );
- LLCheckBoxCtrl* runningCheckbox = self->getChild<LLCheckBoxCtrl>("running");
- bool running = runningCheckbox->get();
- //self->mRunningCheckbox->get();
- if( object )
+ if (LLViewerObject* object = gObjectList.findObject(mObjectUUID))
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_SetScriptRunning);
@@ -2217,24 +2206,21 @@ void LLLiveLSLEditor::onRunningCheckboxClicked( LLUICtrl*, void* userdata )
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_Script);
- msg->addUUIDFast(_PREHASH_ObjectID, self->mObjectUUID);
- msg->addUUIDFast(_PREHASH_ItemID, self->mItemUUID);
- msg->addBOOLFast(_PREHASH_Running, running);
+ msg->addUUIDFast(_PREHASH_ObjectID, mObjectUUID);
+ msg->addUUIDFast(_PREHASH_ItemID, mItemUUID);
+ msg->addBOOLFast(_PREHASH_Running, mRunningCheckbox->get());
msg->sendReliable(object->getRegion()->getHost());
}
else
{
- runningCheckbox->set(!running);
+ mRunningCheckbox->set(!mRunningCheckbox->get());
LLNotificationsUtil::add("CouldNotStartStopScript");
}
}
-void LLLiveLSLEditor::onReset(void *userdata)
+void LLLiveLSLEditor::onReset()
{
- LLLiveLSLEditor* self = (LLLiveLSLEditor*) userdata;
-
- LLViewerObject* object = gObjectList.findObject( self->mObjectUUID );
- if(object)
+ if (LLViewerObject* object = gObjectList.findObject(mObjectUUID))
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ScriptReset);
@@ -2242,8 +2228,8 @@ void LLLiveLSLEditor::onReset(void *userdata)
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_Script);
- msg->addUUIDFast(_PREHASH_ObjectID, self->mObjectUUID);
- msg->addUUIDFast(_PREHASH_ItemID, self->mItemUUID);
+ msg->addUUIDFast(_PREHASH_ObjectID, mObjectUUID);
+ msg->addUUIDFast(_PREHASH_ItemID, mItemUUID);
msg->sendReliable(object->getRegion()->getHost());
}
else
@@ -2255,34 +2241,33 @@ void LLLiveLSLEditor::onReset(void *userdata)
void LLLiveLSLEditor::draw()
{
LLViewerObject* object = gObjectList.findObject(mObjectUUID);
- LLCheckBoxCtrl* runningCheckbox = getChild<LLCheckBoxCtrl>( "running");
- if(object && mAskedForRunningInfo && mHaveRunningInfo)
+ if (object && mAskedForRunningInfo && mHaveRunningInfo)
{
- if(object->permAnyOwner())
+ if (object->permAnyOwner())
{
- runningCheckbox->setLabel(getString("script_running"));
- runningCheckbox->setEnabled(!mIsSaving);
+ mRunningCheckbox->setLabel(getString("script_running"));
+ mRunningCheckbox->setEnabled(!mIsSaving);
}
else
{
- runningCheckbox->setLabel(getString("public_objects_can_not_run"));
- runningCheckbox->setEnabled(false);
+ mRunningCheckbox->setLabel(getString("public_objects_can_not_run"));
+ mRunningCheckbox->setEnabled(false);
// *FIX: Set it to false so that the ui is correct for
// a box that is released to public. It could be
// incorrect after a release/claim cycle, but will be
// correct after clicking on it.
- runningCheckbox->set(false);
- mMonoCheckbox->set(false);
+ mRunningCheckbox->set(false);
+ mCompileTarget->clear();
}
}
- else if(!object)
+ else if (!object)
{
// HACK: Display this information in the title bar.
// Really ought to put in main window.
setTitle(LLTrans::getString("ObjectOutOfRange"));
- runningCheckbox->setEnabled(false);
- mMonoCheckbox->setEnabled(false);
+ mRunningCheckbox->setEnabled(false);
+ mCompileTarget->setEnabled(false);
// object may have fallen out of range.
mHaveRunningInfo = false;
}
@@ -2389,7 +2374,7 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
mScriptEd->sync();
}
- bool isRunning = getChild<LLCheckBoxCtrl>("running")->get();
+ bool is_running = mRunningCheckbox->get();
getWindow()->incBusyCount();
mPendingUploads++;
@@ -2397,17 +2382,18 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
if (!url.empty())
{
+ std::string compile_target(mCompileTarget->getValue());
std::string buffer(mScriptEd->mEditor->getText());
LLUUID old_asset_id = mScriptEd->getAssetID();
LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mObjectUUID, mItemUUID,
- monoChecked() ? LLScriptAssetUpload::MONO : LLScriptAssetUpload::LSL2,
- isRunning, mScriptEd->getAssociatedExperience(), buffer,
- [isRunning, old_asset_id](LLUUID itemId, LLUUID taskId, LLUUID newAssetId, LLSD response) {
- LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
- LLLiveLSLEditor::finishLSLUpload(itemId, taskId, newAssetId, response, isRunning);
- },
- nullptr)); // needs failure handling?
+ compile_target, is_running, mScriptEd->getAssociatedExperience(), buffer,
+ [is_running, old_asset_id](LLUUID item_id, LLUUID task_id, LLUUID new_asset_id, LLSD response)
+ {
+ LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
+ LLLiveLSLEditor::finishLSLUpload(item_id, task_id, new_asset_id, response, is_running);
+ },
+ nullptr)); // needs failure handling?
LLViewerAssetUpload::EnqueueInventoryUpload(url, uploadInfo);
}
@@ -2460,28 +2446,41 @@ void LLLiveLSLEditor::processScriptRunningReply(LLMessageSystem* msg, void**)
if (LLLiveLSLEditor* instance = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", floater_key))
{
instance->mHaveRunningInfo = true;
+
bool running;
msg->getBOOLFast(_PREHASH_Script, _PREHASH_Running, running);
- LLCheckBoxCtrl* runningCheckbox = instance->getChild<LLCheckBoxCtrl>("running");
- runningCheckbox->set(running);
- bool mono;
- msg->getBOOLFast(_PREHASH_Script, "Mono", mono);
- LLCheckBoxCtrl* monoCheckbox = instance->getChild<LLCheckBoxCtrl>("mono");
- monoCheckbox->setEnabled(instance->getIsModifiable() && have_script_upload_cap(object_id));
- monoCheckbox->set(mono);
- }
-}
+ instance->mRunningCheckbox->set(running);
-void LLLiveLSLEditor::onMonoCheckboxClicked(LLUICtrl*, void* userdata)
-{
- LLLiveLSLEditor* self = static_cast<LLLiveLSLEditor*>(userdata);
- self->mMonoCheckbox->setEnabled(have_script_upload_cap(self->mObjectUUID));
- self->mScriptEd->enableSave(self->getIsModifiable());
+ std::string compile_target;
+ msg->getStringFast(_PREHASH_Script, _PREHASH_CompileTarget, compile_target);
+ if (compile_target.empty()) // Old sim not providing CompileTarget field
+ {
+ bool mono;
+ msg->getBOOLFast(_PREHASH_Script, _PREHASH_Mono, mono); // Use Mono field
+ instance->mCompileTarget->setValue(mono ? "mono" : "lso2");
+ }
+ else if (instance->mCompileTarget->valueExists(compile_target))
+ {
+ instance->mCompileTarget->setValue(compile_target); // Use CompileTarget field
+ }
+ else
+ {
+ instance->mCompileTarget->setValue("mono"); // Use default value
+ }
+
+ if (LLScrollListItem* item = instance->mCompileTarget->findItemByValue("luau"))
+ {
+ item->setEnabled(!compile_target.empty());
+ }
+
+ instance->mCompileTarget->setEnabled(instance->getIsModifiable() && have_script_upload_cap(object_id));
+ }
}
-bool LLLiveLSLEditor::monoChecked() const
+void LLLiveLSLEditor::onCompileTargetChanged()
{
- return mMonoCheckbox && mMonoCheckbox->getValue();
+ mCompileTarget->setEnabled(have_script_upload_cap(mObjectUUID));
+ mScriptEd->enableSave(getIsModifiable());
}
void LLLiveLSLEditor::setAssociatedExperience( LLHandle<LLLiveLSLEditor> editor, const LLSD& experience )