summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-03-06 11:45:15 +0200
committerGitHub <noreply@github.com>2025-03-06 11:45:15 +0200
commit7aad509d19c75277519dbcf119c3ba2e1f8a9c7c (patch)
treef2a3d64dc75ae9d8067716bef76e78cd2cf7de4d
parent0aaf2e446f34b951a970474a68131d575606909c (diff)
parent359f604a8d92294c782f41a4383ffe6f63753589 (diff)
Merge pull request #3662 from secondlife/marchcat/lua_editor
Lua editor: script editor in the inventory
-rw-r--r--indra/newview/llpreviewscript.cpp87
-rw-r--r--indra/newview/llpreviewscript.h3
-rw-r--r--indra/newview/llviewerassetupload.cpp6
-rw-r--r--indra/newview/llviewerassetupload.h2
-rw-r--r--indra/newview/skins/default/xui/en/floater_live_lsleditor.xml32
-rw-r--r--indra/newview/skins/default/xui/en/floater_script_preview.xml2
-rw-r--r--indra/newview/skins/default/xui/en/panel_script_ed.xml35
7 files changed, 101 insertions, 66 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 9a03b36831..28988f9564 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -119,6 +119,29 @@ static bool have_script_upload_cap(LLUUID& object_id)
return object && (! object->getRegion()->getCapability("UpdateScriptTask").empty());
}
+static bool have_lua_enabled(const LLUUID& object_id)
+{
+ LLViewerRegion* region = nullptr;
+ LLViewerObject* object = gObjectList.findObject(object_id);
+ if (object)
+ {
+ region = object->getRegion();
+ }
+ else
+ {
+ region = gAgent.getRegion();
+ }
+
+ if (region && region->simulatorFeaturesReceived())
+ {
+ LLSD simulatorFeatures;
+ region->getSimulatorFeatures(simulatorFeatures);
+ return simulatorFeatures["LuaScriptsEnabled"].asBoolean();
+ }
+
+ return false;
+}
+
/// ---------------------------------------------------------------------------
/// LLLiveLSLFile
/// ---------------------------------------------------------------------------
@@ -497,7 +520,7 @@ bool LLScriptEdCore::postBuild()
// Intialise keyword highlighting for the current simulator's version of LSL
LLSyntaxIdLSL::getInstance()->initialize();
LLSyntaxLua::getInstance()->initialize();
- //processKeywords();
+ processKeywords();
mCommitCallbackRegistrar.add("FontSize.Set", boost::bind(&LLScriptEdCore::onChangeFontSize, this, _2));
mEnableCallbackRegistrar.add("FontSize.Check", boost::bind(&LLScriptEdCore::isFontSizeChecked, this, _2));
@@ -506,6 +529,18 @@ bool LLScriptEdCore::postBuild()
"menu_lsl_font_size.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
getChild<LLMenuButton>("font_btn")->setMenu(context_menu, LLMenuButton::MP_BOTTOM_LEFT, true);
+
+ bool lua_scripts_enabled = have_lua_enabled(LLUUID::null);
+ mCompileTarget = getChild<LLComboBox>("compile_target");
+ if (LLScrollListItem* luau_item = mCompileTarget->findItemByValue("luau"))
+ {
+ luau_item->setEnabled(lua_scripts_enabled);
+ }
+ if (LLScrollListItem* lsl_luau_item = mCompileTarget->findItemByValue("lsl-luau"))
+ {
+ lsl_luau_item->setEnabled(lua_scripts_enabled);
+ }
+
return true;
}
@@ -1626,6 +1661,9 @@ bool LLPreviewLSL::postBuild()
childSetCommitCallback("desc", LLPreview::onText, this);
getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
+ mScriptEd->mCompileTarget = getChild<LLComboBox>("compile_target");
+ mScriptEd->mCompileTarget->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCompileTargetChanged(); });
+
return LLPreview::postBuild();
}
@@ -1841,11 +1879,12 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
mPendingUploads++;
if (!url.empty())
{
+ std::string compile_target(mScriptEd->mCompileTarget->getValue());
std::string buffer(mScriptEd->mEditor->getText());
LLUUID old_asset_id = inv_item->getAssetUUID().isNull() ? mScriptEd->getAssetID() : inv_item->getAssetUUID();
- LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mItemUUID, buffer,
+ LLResourceUploadInfo::ptr_t uploadInfo(std::make_shared<LLScriptAssetUpload>(mItemUUID, compile_target, buffer,
[old_asset_id](LLUUID itemId, LLUUID, LLUUID, LLSD response) {
LLFileSystem::removeFile(old_asset_id, LLAssetType::AT_LSL_TEXT);
LLPreviewLSL::finishedLSLUpload(itemId, response);
@@ -1857,6 +1896,11 @@ void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
}
}
+void LLPreviewLSL::onCompileTargetChanged()
+{
+ mScriptEd->processKeywords(mScriptEd->mCompileTarget->getValue().asString() == "luau");
+}
+
// static
void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType type,
void* user_data, S32 status, LLExtStat ext_status)
@@ -1969,9 +2013,6 @@ bool LLLiveLSLEditor::postBuild()
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([&](LLUICtrl*, const LLSD&) { experienceChanged(); });
@@ -1984,6 +2025,9 @@ bool LLLiveLSLEditor::postBuild()
mScriptEd->mEditor->makePristine();
mScriptEd->mEditor->setFocus(true);
+ mScriptEd->mCompileTarget = getChild<LLComboBox>("compile_target");
+ mScriptEd->mCompileTarget->setCommitCallback([&](LLUICtrl*, const LLSD&) { onCompileTargetChanged(); });
+
return LLPreview::postBuild();
}
@@ -2266,7 +2310,7 @@ void LLLiveLSLEditor::draw()
// incorrect after a release/claim cycle, but will be
// correct after clicking on it.
mRunningCheckbox->set(false);
- mCompileTarget->clear();
+ mScriptEd->mCompileTarget->clear();
}
}
else if (!object)
@@ -2275,7 +2319,7 @@ void LLLiveLSLEditor::draw()
// Really ought to put in main window.
setTitle(LLTrans::getString("ObjectOutOfRange"));
mRunningCheckbox->setEnabled(false);
- mCompileTarget->setEnabled(false);
+ mScriptEd->mCompileTarget->setEnabled(false);
// object may have fallen out of range.
mHaveRunningInfo = false;
}
@@ -2390,7 +2434,7 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
if (!url.empty())
{
- std::string compile_target(mCompileTarget->getValue());
+ std::string compile_target(mScriptEd->mCompileTarget->getValue());
std::string buffer(mScriptEd->mEditor->getText());
LLUUID old_asset_id = mScriptEd->getAssetID();
@@ -2485,42 +2529,29 @@ void LLLiveLSLEditor::processScriptRunningReply(LLMessageSystem* msg, void**)
compile_target = "lsl2";
}
- instance->mCompileTarget->setValue(compile_target);
+ instance->mScriptEd->mCompileTarget->setValue(compile_target);
instance->mScriptEd->processKeywords(luau && luau_language); // Use Luau syntax highlighting for Luau scripts
- bool lua_scripts_enabled = false;
-
- LLViewerObject* object = gObjectList.findObject(object_id);
- if (object)
- {
- LLViewerRegion* region = object->getRegion();
- if (region && region->simulatorFeaturesReceived())
- {
- LLSD simulatorFeatures;
- region->getSimulatorFeatures(simulatorFeatures);
- lua_scripts_enabled = simulatorFeatures["LuaScriptsEnabled"].asBoolean();
- }
- }
-
- if (LLScrollListItem* luau_item = instance->mCompileTarget->findItemByValue("luau"))
+ bool lua_scripts_enabled = have_lua_enabled(object_id);
+ if (LLScrollListItem* luau_item = instance->mScriptEd->mCompileTarget->findItemByValue("luau"))
{
luau_item->setEnabled(lua_scripts_enabled);
}
- if (LLScrollListItem* lsl_luau_item = instance->mCompileTarget->findItemByValue("lsl-luau"))
+ if (LLScrollListItem* lsl_luau_item = instance->mScriptEd->mCompileTarget->findItemByValue("lsl-luau"))
{
lsl_luau_item->setEnabled(lua_scripts_enabled);
}
- instance->mCompileTarget->setEnabled(instance->getIsModifiable() && have_script_upload_cap(object_id));
+ instance->mScriptEd->mCompileTarget->setEnabled(instance->getIsModifiable() && have_script_upload_cap(object_id));
}
}
void LLLiveLSLEditor::onCompileTargetChanged()
{
- mCompileTarget->setEnabled(have_script_upload_cap(mObjectUUID));
+ mScriptEd->mCompileTarget->setEnabled(have_script_upload_cap(mObjectUUID));
mScriptEd->enableSave(getIsModifiable());
- mScriptEd->processKeywords(mCompileTarget->getValue().asString() == "luau");
+ mScriptEd->processKeywords(mScriptEd->mCompileTarget->getValue().asString() == "luau");
}
void LLLiveLSLEditor::setAssociatedExperience( LLHandle<LLLiveLSLEditor> editor, const LLSD& experience )
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 4e184fdcc1..430ca4cc76 100644
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -198,6 +198,7 @@ private:
LLUUID mAssetID;
LLTextBox* mLineCol = nullptr;
LLButton* mSaveBtn = nullptr;
+ LLComboBox* mCompileTarget = nullptr;
LLScriptEdContainer* mContainer; // parent view
@@ -247,6 +248,7 @@ protected:
virtual void loadAsset();
/*virtual*/ void saveIfNeeded(bool sync = true);
+ void onCompileTargetChanged();
static void onSearchReplace(void* userdata);
static void onLoad(void* userdata);
@@ -348,7 +350,6 @@ private:
LLButton* mResetButton { nullptr };
LLCheckBoxCtrl* mRunningCheckbox { nullptr };
- LLComboBox* mCompileTarget { nullptr };
LLComboBox* mExperiences { nullptr };
LLCheckBoxCtrl* mExperienceEnabled { nullptr };
LLButton* mViewProfileButton { nullptr };
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index 1784179237..1e74e32817 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -801,10 +801,10 @@ bool LLBufferedAssetUploadInfo::failedUpload(LLSD &result, std::string &reason)
//=========================================================================
-LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed):
+LLScriptAssetUpload::LLScriptAssetUpload(LLUUID itemId, std::string compileTarget, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed) :
LLBufferedAssetUploadInfo(itemId, LLAssetType::AT_LSL_TEXT, buffer, finish, failed),
mExerienceId(),
- mCompileTarget("mono"),
+ mCompileTarget(compileTarget),
mIsRunning(false)
{
}
@@ -825,7 +825,7 @@ LLSD LLScriptAssetUpload::generatePostBody()
if (getTaskId().isNull())
{
body["item_id"] = getItemId();
- body["target"] = "mono";
+ body["target"] = getCompileTarget();
}
else
{
diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h
index c3c570efb2..3eaba6461d 100644
--- a/indra/newview/llviewerassetupload.h
+++ b/indra/newview/llviewerassetupload.h
@@ -251,7 +251,7 @@ private:
class LLScriptAssetUpload : public LLBufferedAssetUploadInfo
{
public:
- LLScriptAssetUpload(LLUUID itemId, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed);
+ LLScriptAssetUpload(LLUUID itemId, std::string compileTarget, std::string buffer, invnUploadFinish_f finish, uploadFailed_f failed);
LLScriptAssetUpload(LLUUID taskId, LLUUID itemId, std::string compileTarget,
bool isRunning, LLUUID exerienceId, std::string buffer, taskUploadFinish_f finish, uploadFailed_f failed);
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 bbc85cdc9d..26281989a7 100644
--- a/indra/newview/skins/default/xui/en/floater_live_lsleditor.xml
+++ b/indra/newview/skins/default/xui/en/floater_live_lsleditor.xml
@@ -7,7 +7,7 @@
height="607"
layout="topleft"
min_height="271"
- min_width="600"
+ min_width="500"
name="script ed float"
help_topic="script_ed_float"
save_rect="true"
@@ -120,34 +120,4 @@
top_pad="-23"
follows="right"
visible="false"/>
- <text
- name="compile_target_label"
- follows="right|bottom"
- right="180"
- top="-100"
- width="100"
- >Compiler:</text>
- <combo_box
- name="compile_target"
- follows="right|bottom"
- right="300"
- top="-105"
- width="140">
- <combo_box.item
- label="LSL: Legacy (LSO2)"
- name="compile_target_lsl2"
- value="lsl2" />
- <combo_box.item
- label="LSL: Mono"
- name="compile_target_mono"
- value="mono" />
- <combo_box.item
- label="Lua"
- name="compile_target_luau"
- value="luau" />
- <combo_box.item
- label="LSL/Luau"
- name="compile_target_lsl_luau"
- value="lsl-luau" />
- </combo_box>
</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_script_preview.xml b/indra/newview/skins/default/xui/en/floater_script_preview.xml
index b0b105fe58..f82224cc9e 100644
--- a/indra/newview/skins/default/xui/en/floater_script_preview.xml
+++ b/indra/newview/skins/default/xui/en/floater_script_preview.xml
@@ -5,7 +5,7 @@
height="593"
layout="topleft"
min_height="271"
- min_width="320"
+ min_width="500"
name="preview lsl text"
help_topic="preview_lsl_text"
save_rect="true"
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 f8761d2b24..3f1aeeb626 100644
--- a/indra/newview/skins/default/xui/en/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml
@@ -219,7 +219,7 @@
label="Save"
label_selected="Save"
layout="topleft"
- top_pad="-35"
+ top_pad="-23"
right="487"
name="Save_btn"
width="81" />
@@ -233,4 +233,37 @@
right="400"
name="Edit_btn"
width="81" />
+ <combo_box
+ name="compile_target"
+ follows="right|bottom"
+ height="23"
+ layout="topleft"
+ top_pad="-23"
+ right="300"
+ width="140">
+ <combo_box.item
+ label="LSL: Legacy (LSO2)"
+ name="compile_target_lsl2"
+ value="lsl2" />
+ <combo_box.item
+ label="LSL: Mono"
+ name="compile_target_mono"
+ value="mono" />
+ <combo_box.item
+ label="Lua"
+ name="compile_target_luau"
+ value="luau" />
+ <combo_box.item
+ label="LSL/Luau"
+ name="compile_target_lsl_luau"
+ value="lsl-luau" />
+ </combo_box>
+ <text
+ name="compile_target_label"
+ follows="right|bottom"
+ layout="topleft"
+ top_pad="-39"
+ width="90">
+ Compiler:
+ </text>
</panel>