Added ability to save scripts from objects from File -> Save as... and merged fixes for Unix systems, new detection for viewer 2.0

This commit is contained in:
phr0z3nt04st
2010-07-20 21:44:16 -05:00
parent 05b83e0179
commit 9e14b03165
6 changed files with 104 additions and 17 deletions

View File

@@ -2611,3 +2611,37 @@ BOOL LLLiveLSLEditor::monoChecked() const
}
return FALSE;
}
// <edit>
// virtual
BOOL LLLiveLSLEditor::canSaveAs() const
{
return TRUE;
}
// virtual
void LLLiveLSLEditor::saveAs()
{
std::string default_filename("untitled.lsl");
const LLInventoryItem *item = getItem();
if(item)
{
default_filename = LLDir::getScrubbedFileName(item->getName());
}
LLFilePicker& file_picker = LLFilePicker::instance();
if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_LSL, default_filename ) )
{
// User canceled or we failed to acquire save file.
return;
}
// remember the user-approved/edited file name.
std::string filename = file_picker.getFirstFile();
std::string utf8text = mScriptEd->mEditor->getText();
LLFILE* fp = LLFile::fopen(filename, "wb");
fputs(utf8text.c_str(), fp);
fclose(fp);
fp = NULL;
}
// </edit>