diff options
author | Rider Linden <rider@lindenlab.com> | 2018-06-21 09:13:19 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2018-06-21 09:13:19 -0700 |
commit | f07dc421e81d945531dc6f4befc19ea4fe4b9a47 (patch) | |
tree | 7ac8fa1fbfad64c616161488a5d0be10c1eaba34 /indra/newview/llpreviewscript.cpp | |
parent | 8b3957b310afa23e543c3eb33aca9131dba52b31 (diff) | |
parent | dc07de2f4a4c49d1877bf743b6f0d209392f6eb6 (diff) |
Merge
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r-- | indra/newview/llpreviewscript.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 54a47f6e6e..b85e48ec77 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -60,6 +60,7 @@ #include "llselectmgr.h" #include "llviewerinventory.h" #include "llviewermenu.h" +#include "llviewermenufile.h" // LLFilePickerReplyThread #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" @@ -1201,17 +1202,12 @@ BOOL LLScriptEdCore::handleKeyHere(KEY key, MASK mask) void LLScriptEdCore::onBtnLoadFromFile( void* data ) { - LLScriptEdCore* self = (LLScriptEdCore*) data; - - // TODO Maybe add a dialogue warning here if the current file has unsaved changes. - LLFilePicker& file_picker = LLFilePicker::instance(); - if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_SCRIPT ) ) - { - //File picking cancelled by user, so nothing to do. - return; - } + (new LLFilePickerReplyThread(boost::bind(&LLScriptEdCore::loadScriptFromFile, _1, data), LLFilePicker::FFLOAD_SCRIPT, false))->getFile(); +} - std::string filename = file_picker.getFirstFile(); +void LLScriptEdCore::loadScriptFromFile(const std::vector<std::string>& filenames, void* data) +{ + std::string filename = filenames[0]; llifstream fin(filename.c_str()); @@ -1219,8 +1215,8 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data ) std::string text; std::string linetotal; while (!fin.eof()) - { - getline(fin,line); + { + getline(fin, line); text += line; if (!fin.eof()) { @@ -1230,7 +1226,8 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data ) fin.close(); // Only replace the script if there is something to replace with. - if (text.length() > 0) + LLScriptEdCore* self = (LLScriptEdCore*)data; + if (self && (text.length() > 0)) { self->mEditor->selectAll(); LLWString script(utf8str_to_wstring(text)); @@ -1246,16 +1243,21 @@ void LLScriptEdCore::onBtnSaveToFile( void* userdata ) if( self->mSaveCallback ) { - LLFilePicker& file_picker = LLFilePicker::instance(); - if( file_picker.getSaveFile( LLFilePicker::FFSAVE_SCRIPT, self->mScriptName ) ) - { - std::string filename = file_picker.getFirstFile(); - std::string scriptText=self->mEditor->getText(); - llofstream fout(filename.c_str()); - fout<<(scriptText); - fout.close(); - self->mSaveCallback( self->mUserdata, FALSE ); - } + (new LLFilePickerReplyThread(boost::bind(&LLScriptEdCore::saveScriptToFile, _1, userdata), LLFilePicker::FFSAVE_SCRIPT, self->mScriptName))->getFile(); + } +} + +void LLScriptEdCore::saveScriptToFile(const std::vector<std::string>& filenames, void* data) +{ + LLScriptEdCore* self = (LLScriptEdCore*)data; + if (self) + { + std::string filename = filenames[0]; + std::string scriptText = self->mEditor->getText(); + llofstream fout(filename.c_str()); + fout << (scriptText); + fout.close(); + self->mSaveCallback(self->mUserdata, FALSE); } } |