From e0561134ee559f9ea729f940cf9d4390f60c66d5 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 12 Oct 2009 00:51:28 -0700 Subject: Added script load/save from Meerkat viewer --- linden/indra/newview/llfilepicker.cpp | 12 +++ linden/indra/newview/llfilepicker.h | 3 + linden/indra/newview/llpreviewscript.cpp | 64 ++++++++++++++++ linden/indra/newview/llpreviewscript.h | 2 + .../default/xui/en-us/floater_script_ed_panel.xml | 6 ++ .../silver/xui/en-us/floater_script_ed_panel.xml | 86 ---------------------- .../silver/xui/en-us/floater_script_queue.xml | 13 ---- 7 files changed, 87 insertions(+), 99 deletions(-) delete mode 100644 linden/indra/newview/skins/silver/xui/en-us/floater_script_ed_panel.xml delete mode 100644 linden/indra/newview/skins/silver/xui/en-us/floater_script_queue.xml (limited to 'linden') diff --git a/linden/indra/newview/llfilepicker.cpp b/linden/indra/newview/llfilepicker.cpp index 954a274..ece30dd 100644 --- a/linden/indra/newview/llfilepicker.cpp +++ b/linden/indra/newview/llfilepicker.cpp @@ -327,6 +327,18 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) L"Targa, Bitmap Images (*.tga; *.bmp)\0*.tga;*.bmp\0" \ L"\0"; break; + case FFSAVE_TEXT: + if (filename.empty()) + { + wcsncpy( mFilesW,L"untitled.txt", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ + } + mOFN.lpstrDefExt = L"txt"; + mOFN.lpstrFilter = + L"Text files (*.txt)\0*.txt\0" + L"RTF Files (*.rtf)\0*.rtf\0" + L"LSL Files (*.lsl)\0*.lsl\0" + L"\0"; + break; case FFSAVE_WAV: if (filename.empty()) { diff --git a/linden/indra/newview/llfilepicker.h b/linden/indra/newview/llfilepicker.h index aea414a..f9f859f 100644 --- a/linden/indra/newview/llfilepicker.h +++ b/linden/indra/newview/llfilepicker.h @@ -90,6 +90,7 @@ public: FFLOAD_XML = 6, FFLOAD_SLOBJECT = 7, FFLOAD_RAW = 8, + FFLOAD_TEXT = 9, }; enum ESaveFilter @@ -109,6 +110,8 @@ public: FFSAVE_J2C = 12, FFSAVE_PNG = 13, FFSAVE_JPEG = 14, + FFSAVE_HPA = 15, + FFSAVE_TEXT = 16, }; // open the dialog. This is a modal operation diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp index 1e9def3..6273011 100644 --- a/linden/indra/newview/llpreviewscript.cpp +++ b/linden/indra/newview/llpreviewscript.cpp @@ -436,6 +436,14 @@ void LLScriptEdCore::initMenu() menuItem->setMenuCallback(onBtnHelp, this); menuItem->setEnabledCallback(NULL); + menuItem = getChild("Load from Disk"); + menuItem->setMenuCallback(onBtnLoadFromDisc, this); + menuItem->setEnabledCallback(NULL); + + menuItem = getChild("Save to Disk"); + menuItem->setMenuCallback(onBtnSaveToDisc, this); + menuItem->setEnabledCallback(NULL); + menuItem = getChild("LSL Wiki Help..."); menuItem->setMenuCallback(onBtnDynamicHelp, this); menuItem->setEnabledCallback(NULL); @@ -547,6 +555,7 @@ void LLScriptEdCore::setHelpPage(const std::string& help_string) if (!history_combo) return; LLUIString url_string = gSavedSettings.getString("LSLHelpURL"); + url_string.setArg("[APP_DIRECTORY]", gDirUtilp->getWorkingDir()); url_string.setArg("[LSL_STRING]", help_string); addHelpItemToHistory(help_string); @@ -773,6 +782,7 @@ void LLScriptEdCore::onHelpComboCommit(LLUICtrl* ctrl, void* userdata) LLWebBrowserCtrl* web_browser = live_help_floater->getChild("lsl_guide_html"); LLUIString url_string = gSavedSettings.getString("LSLHelpURL"); + url_string.setArg("[APP_DIRECTORY]", gDirUtilp->getWorkingDir()); url_string.setArg("[LSL_STRING]", help_string); web_browser->navigateTo(url_string); } @@ -823,6 +833,60 @@ void LLScriptEdCore::onBtnUndoChanges( void* userdata ) } } +void LLScriptEdCore::onBtnSaveToDisc( void* userdata ) +{ + + LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); + + LLScriptEdCore* self = (LLScriptEdCore*) userdata; + + if( self->mSaveCallback ) + { + LLFilePicker& file_picker = LLFilePicker::instance(); + if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TEXT ) ) + { + return; + } + + std::string filename = file_picker.getFirstFile(); + std::string scriptText=self->mEditor->getText(); + std::ofstream fout(filename.c_str()); + fout<<(scriptText); + fout.close(); + self->mSaveCallback( self->mUserdata, FALSE ); + + } + +} +void LLScriptEdCore::onBtnLoadFromDisc( void* data ) +{ + + LLScriptEdCore* self = (LLScriptEdCore*) data; + + LLFilePicker& file_picker = LLFilePicker::instance(); + if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_TEXT ) ) + { + return; + } + + std::string filename = file_picker.getFirstFile(); + + std::ifstream fin(filename.c_str()); + + std::string line; + std::string linetotal; + self->mEditor->clear(); + while (!fin.eof()) + { + getline(fin,line); + line=line+"\n"; + self->mEditor->insertText(line); + + } + fin.close(); + +} + void LLScriptEdCore::onSearchMenu(void* userdata) { LLScriptEdCore* sec = (LLScriptEdCore*)userdata; diff --git a/linden/indra/newview/llpreviewscript.h b/linden/indra/newview/llpreviewscript.h index 7026482..97e721d 100644 --- a/linden/indra/newview/llpreviewscript.h +++ b/linden/indra/newview/llpreviewscript.h @@ -95,6 +95,8 @@ public: static void doSave( void* userdata, BOOL close_after_save ); static void onBtnSave(void*); static void onBtnUndoChanges(void*); + static void onBtnSaveToDisc(void*); + static void onBtnLoadFromDisc(void*); static void onSearchMenu(void* userdata); static void onUndoMenu(void* userdata); diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_script_ed_panel.xml b/linden/indra/newview/skins/default/xui/en-us/floater_script_ed_panel.xml index b83a6df..653c75b 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_script_ed_panel.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_script_ed_panel.xml @@ -35,6 +35,12 @@ width="138" /> + + + - - - Loading... - -