From 668c8c61a12842d33cb83b79ba3d68ba3db7aa8b Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 7 Mar 2025 05:01:56 +0200 Subject: #3422 Code cleanup --- indra/newview/llpreviewscript.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 28988f9564..9449768d79 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -396,9 +396,9 @@ LLScriptEdCore::LLScriptEdCore( LLScriptEdContainer* container, const std::string& sample, const LLHandle& floater_handle, - void (*load_callback)(void*), - void (*save_callback)(void*, bool), - void (*search_replace_callback) (void* userdata), + script_ed_callback_t load_callback, + save_callback_t save_callback, + script_ed_callback_t search_replace_callback, void* userdata, bool live, S32 bottom_pad) -- cgit v1.3 From f5a6851f1fb0e847bef4dff4f7878b52e9c6e0d3 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Sat, 8 Mar 2025 02:37:26 +0200 Subject: #3691 Fix Reset button --- indra/newview/llpreviewscript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 9449768d79..fd01cf1311 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -2007,7 +2007,7 @@ LLLiveLSLEditor::LLLiveLSLEditor(const LLSD& key) : bool LLLiveLSLEditor::postBuild() { - mResetButton = getChild("reset"); + mResetButton = getChild("Reset"); mResetButton->setClickedCallback([&](LLUICtrl*, const LLSD&) { onReset(); }); mRunningCheckbox = getChild("running"); -- cgit v1.3 From 5b23e28703dd6bb2dfee6fc9a446679467d4ab99 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 14 Mar 2025 12:39:10 +0200 Subject: #3731 Remove unused code --- indra/newview/llpreviewscript.cpp | 43 ++------------------------------------- indra/newview/llscripteditor.h | 1 + 2 files changed, 3 insertions(+), 41 deletions(-) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index fd01cf1311..5ab624a4c1 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -91,19 +91,6 @@ #include "llmenubutton.h" #include "llinventoryfunctions.h" -const std::string HELLO_LSL = - "default\n" - "{\n" - " state_entry()\n" - " {\n" - " llSay(0, \"Hello, Avatar!\");\n" - " }\n" - "\n" - " touch_start(integer total_number)\n" - " {\n" - " llSay(0, \"Touched.\");\n" - " }\n" - "}\n"; const std::string HELP_LSL_PORTAL_TOPIC = "LSL_Portal"; const std::string DEFAULT_SCRIPT_NAME = "New Script"; // *TODO:Translate? @@ -1617,7 +1604,7 @@ void* LLPreviewLSL::createScriptEdPanel(void* userdata) self->mScriptEd = new LLScriptEdCore( self, - HELLO_LSL, + std::string(), self->getHandle(), LLPreviewLSL::onLoad, LLPreviewLSL::onSave, @@ -1758,12 +1745,6 @@ void LLPreviewLSL::loadAsset() getChildView("lock")->setVisible( !is_modifiable); mScriptEd->getChildView("Insert...")->setEnabled(is_modifiable); } - else - { - mScriptEd->setScriptText(std::string(HELLO_LSL), true); - mScriptEd->setEnableEditing(true); - mAssetStatus = PREVIEW_ASSET_LOADED; - } } @@ -1979,7 +1960,7 @@ void* LLLiveLSLEditor::createScriptEdPanel(void* userdata) self->mScriptEd = new LLScriptEdCore( self, - HELLO_LSL, + std::string(), self->getHandle(), &LLLiveLSLEditor::onLoad, &LLLiveLSLEditor::onSave, @@ -2153,26 +2134,6 @@ void LLLiveLSLEditor::loadAsset() */ } } - else - { - mScriptEd->setScriptText(std::string(HELLO_LSL), true); - mScriptEd->enableSave(false); - LLPermissions perm; - perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); - perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); - mItem = new LLViewerInventoryItem(mItemUUID, - mObjectUUID, - perm, - LLUUID::null, - LLAssetType::AT_LSL_TEXT, - LLInventoryType::IT_LSL, - DEFAULT_SCRIPT_NAME, - DEFAULT_SCRIPT_DESC, - LLSaleInfo::DEFAULT, - LLInventoryItemFlags::II_FLAGS_NONE, - time_corrected()); - mAssetStatus = PREVIEW_ASSET_LOADED; - } requestExperiences(); } diff --git a/indra/newview/llscripteditor.h b/indra/newview/llscripteditor.h index 1586a43160..ba44d77ea0 100644 --- a/indra/newview/llscripteditor.h +++ b/indra/newview/llscripteditor.h @@ -54,6 +54,7 @@ public: LLKeywords::keyword_iterator_t keywordsEnd(); LLKeywords& getKeywords(); bool getIsLuauLanguage() { return mLuauLanguage; } + void setLuauLanguage(bool luau_language) { mLuauLanguage = luau_language; } static std::string getScriptFontSize(); LLFontGL* getScriptFont(); -- cgit v1.3 From da0a819d64514cad17cf306c3ebe2ac79db8283a Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Fri, 14 Mar 2025 07:20:07 +0200 Subject: Temporary hack to determine script language when opened from inventory --- indra/newview/llpreviewscript.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'indra/newview/llpreviewscript.cpp') diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 5ab624a4c1..98c28ffadc 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -90,6 +90,7 @@ #include "lltoggleablemenu.h" #include "llmenubutton.h" #include "llinventoryfunctions.h" +#include const std::string HELP_LSL_PORTAL_TOPIC = "LSL_Portal"; @@ -129,6 +130,19 @@ static bool have_lua_enabled(const LLUUID& object_id) return false; } +// TEMPORARY: Quick check to see if the code is Lua +// since we don't have another way to determine the language yet +static bool is_lua_script(const std::string& code) +{ + // Check for LSL's signature "default" state pattern + std::regex lsl_pattern("\\s*default\\s*\\{"); + if (std::regex_search(code, lsl_pattern)) + return false; + + // "default" state not found, assuming it's Lua + return true; +} + /// --------------------------------------------------------------------------- /// LLLiveLSLFile /// --------------------------------------------------------------------------- @@ -1923,6 +1937,12 @@ void LLPreviewLSL::onLoadComplete(const LLUUID& asset_uuid, LLAssetType::EType t preview->mScriptEd->setEnableEditing(is_modifiable); preview->mScriptEd->setAssetID(asset_uuid); preview->mAssetStatus = PREVIEW_ASSET_LOADED; + + // Temporary hack to determine if the script is LSL or SLua when loaded from the inventory. + bool is_lua = is_lua_script(std::string(buffer.begin(), buffer.end())); + preview->mScriptEd->mEditor->setLuauLanguage(is_lua); + preview->mScriptEd->mCompileTarget->setValue(is_lua ? "luau" : "lsl-luau"); + preview->mScriptEd->processKeywords(is_lua); } else { -- cgit v1.3