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 +++--- indra/newview/llpreviewscript.h | 33 ++++++++++++++++----------------- indra/newview/llscripteditor.cpp | 8 ++++---- indra/newview/llscripteditor.h | 2 -- 4 files changed, 23 insertions(+), 26 deletions(-) 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) diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 430ca4cc76..117be03fc6 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -82,15 +82,19 @@ class LLScriptEdCore : public LLPanel friend class LLScriptEdContainer; friend class LLFloaterGotoLine; +public: + typedef boost::function script_ed_callback_t; + typedef boost::function save_callback_t; + protected: // Supposed to be invoked only by the container. LLScriptEdCore( LLScriptEdContainer* container, const std::string& sample, const LLHandle& floater_handle, - void (*load_callback)(void* userdata), - void (*save_callback)(void* userdata, bool close_after_save), - 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 = 0); // pad below bottom row of buttons @@ -139,11 +143,11 @@ public: LLUUID getAssociatedExperience()const; void setAssociatedExperience( const LLUUID& experience_id ); - void setScriptName(const std::string& name){mScriptName = name;}; + void setScriptName(const std::string& name) { mScriptName = name; } - void setItemRemoved(bool script_removed){mScriptRemoved = script_removed;}; + void setItemRemoved(bool script_removed) { mScriptRemoved = script_removed; } - void setAssetID( const LLUUID& asset_id){ mAssetID = asset_id; }; + void setAssetID(const LLUUID& asset_id) { mAssetID = asset_id; } LLUUID getAssetID() { return mAssetID; } bool isFontSizeChecked(const LLSD &userdata); @@ -152,16 +156,15 @@ public: virtual bool handleKeyHere(KEY key, MASK mask); void selectAll() { mEditor->selectAll(); } + void enableSave(bool b) { mEnableSave = b; } + bool hasChanged(); + private: void onBtnDynamicHelp(); void onBtnUndoChanges(); - bool hasChanged(); - void selectFirstError(); - void enableSave(bool b) {mEnableSave = b;} - protected: void deleteBridges(); void setHelpPage(const std::string& help_string); @@ -176,9 +179,9 @@ private: std::string mSampleText; std::string mScriptName; LLScriptEditor* mEditor; - void (*mLoadCallback)(void* userdata); - void (*mSaveCallback)(void* userdata, bool close_after_save); - void (*mSearchReplaceCallback) (void* userdata); + script_ed_callback_t mLoadCallback; + save_callback_t mSaveCallback; + script_ed_callback_t mSearchReplaceCallback; void* mUserdata; LLComboBox *mFunctions; bool mForceClose; @@ -204,7 +207,6 @@ private: public: boost::signals2::connection mSyntaxIDConnection; - }; class LLScriptEdContainer : public LLPreview @@ -269,10 +271,8 @@ protected: S32 mPendingUploads; LLScriptMovedObserver* mItemObserver; - }; - // Used to view and edit an LSL script that is attached to an object. class LLLiveLSLEditor : public LLScriptEdContainer { @@ -280,7 +280,6 @@ class LLLiveLSLEditor : public LLScriptEdContainer public: LLLiveLSLEditor(const LLSD& key); - static void processScriptRunningReply(LLMessageSystem* msg, void**); virtual void callbackLSLCompileSucceeded(const LLUUID& task_id, diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 0edaf43753..2a9dd73936 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -45,7 +45,8 @@ LLScriptEditor::Params::Params() LLScriptEditor::LLScriptEditor(const Params& p) : LLTextEditor(p) , mShowLineNumbers(p.show_line_numbers), - mUseDefaultFontSize(p.default_font_size) + mUseDefaultFontSize(p.default_font_size), + mLuauLanguage(false) { if (mShowLineNumbers) { @@ -200,12 +201,12 @@ void LLScriptEditor::clearSegments() LLKeywords::keyword_iterator_t LLScriptEditor::keywordsBegin() { - return mLuauLanguage ? mKeywordsLua.begin() : mKeywordsLSL.begin(); + return getKeywords().begin(); } LLKeywords::keyword_iterator_t LLScriptEditor::keywordsEnd() { - return mLuauLanguage ? mKeywordsLua.end() : mKeywordsLSL.end(); + return getKeywords().end(); } LLKeywords& LLScriptEditor::getKeywords() @@ -237,7 +238,6 @@ void LLScriptEditor::drawSelectionBackground() ++rect_it) { LLRect selection_rect = *rect_it; - selection_rect = *rect_it; selection_rect.translate(mVisibleTextRect.mLeft - content_display_rect.mLeft, mVisibleTextRect.mBottom - content_display_rect.mBottom); gl_rect_2d(selection_rect, selection_color); } diff --git a/indra/newview/llscripteditor.h b/indra/newview/llscripteditor.h index ad61405917..1586a43160 100644 --- a/indra/newview/llscripteditor.h +++ b/indra/newview/llscripteditor.h @@ -67,8 +67,6 @@ private: void drawLineNumbers(); /* virtual */ void updateSegments(); /* virtual */ void drawSelectionBackground(); - void loadKeywords(const std::string& filename_keywords, - const std::string& filename_colors); LLKeywords mKeywordsLua; LLKeywords mKeywordsLSL; -- cgit v1.3