summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2018-06-21 15:49:53 +0100
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2018-06-21 15:49:53 +0100
commit9d7b353cbb5c12cd74559a8f3a7365312f95d4d0 (patch)
treeb35c3e3eb0c9c93cea2c01248a3943d5c1277fa7 /indra/newview/llpreviewscript.cpp
parent8abfd8da4fb222382437f4b547567fabc6f75cf8 (diff)
parentdc07de2f4a4c49d1877bf743b6f0d209392f6eb6 (diff)
merge
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--indra/newview/llpreviewscript.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 945f3c370c..d4eecaffce 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -61,6 +61,7 @@
#include "llselectmgr.h"
#include "llviewerinventory.h"
#include "llviewermenu.h"
+#include "llviewermenufile.h" // LLFilePickerReplyThread
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
@@ -1202,17 +1203,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());
@@ -1220,8 +1216,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())
{
@@ -1231,7 +1227,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));
@@ -1247,16 +1244,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);
}
}