aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2010-07-14 05:37:58 -0700
committerMcCabe Maxsted2010-07-15 02:10:45 -0700
commit369e736e3f0cc5ca043c5f29dfc5193f688a637f (patch)
tree3bd98dc61cd19a256c04fd6c39439ca0f713dfb3 /linden/indra/newview/llpreviewscript.cpp
parentApplied slviewer-0-v12350-StutteringAndLagInAudioEngine_v2.patch from Cool Vi... (diff)
downloadmeta-impy-369e736e3f0cc5ca043c5f29dfc5193f688a637f.zip
meta-impy-369e736e3f0cc5ca043c5f29dfc5193f688a637f.tar.gz
meta-impy-369e736e3f0cc5ca043c5f29dfc5193f688a637f.tar.bz2
meta-impy-369e736e3f0cc5ca043c5f29dfc5193f688a637f.tar.xz
Added basic File menu to notecards (save, import, export) and made the script editor File menu consistent with it. TODO: create new notecard format that includes attached inventory
Diffstat (limited to 'linden/indra/newview/llpreviewscript.cpp')
-rw-r--r--linden/indra/newview/llpreviewscript.cpp45
1 files changed, 20 insertions, 25 deletions
diff --git a/linden/indra/newview/llpreviewscript.cpp b/linden/indra/newview/llpreviewscript.cpp
index d200e32..c77f7ff 100644
--- a/linden/indra/newview/llpreviewscript.cpp
+++ b/linden/indra/newview/llpreviewscript.cpp
@@ -294,11 +294,11 @@ void LLScriptEdCore::initMenu()
294 menuItem->setMenuCallback(onBtnHelp, this); 294 menuItem->setMenuCallback(onBtnHelp, this);
295 menuItem->setEnabledCallback(NULL); 295 menuItem->setEnabledCallback(NULL);
296 296
297 menuItem = getChild<LLMenuItemCallGL>("Load from Disk"); 297 menuItem = getChild<LLMenuItemCallGL>("Import Script...");
298 menuItem->setMenuCallback(onBtnLoadFromDisc, this); 298 menuItem->setMenuCallback(onBtnLoadFromDisc, this);
299 menuItem->setEnabledCallback(NULL); 299 menuItem->setEnabledCallback(NULL);
300 300
301 menuItem = getChild<LLMenuItemCallGL>("Save to Disk"); 301 menuItem = getChild<LLMenuItemCallGL>("Export Script...");
302 menuItem->setMenuCallback(onBtnSaveToDisc, this); 302 menuItem->setMenuCallback(onBtnSaveToDisc, this);
303 menuItem->setEnabledCallback(NULL); 303 menuItem->setEnabledCallback(NULL);
304 304
@@ -732,36 +732,34 @@ void LLScriptEdCore::onBtnUndoChanges( void* userdata )
732 732
733void LLScriptEdCore::onBtnSaveToDisc( void* userdata ) 733void LLScriptEdCore::onBtnSaveToDisc( void* userdata )
734{ 734{
735
736 LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT ); 735 LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
737 736
738 LLScriptEdCore* self = (LLScriptEdCore*) userdata; 737 LLScriptEdCore* self = (LLScriptEdCore*) userdata;
739 738
740 if( self->mSaveCallback ) 739 if (self->mSaveCallback)
741 {
742 LLFilePicker& file_picker = LLFilePicker::instance();
743 if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_TEXT ) )
744 { 740 {
745 return; 741 LLFilePicker& file_picker = LLFilePicker::instance();
746 } 742 const LLViewerInventoryItem *item = ((LLPreviewLSL*)self->getParent())->getItem();
747 743 if (!file_picker.getSaveFile(LLFilePicker::FFSAVE_LSL, item ? LLDir::getScrubbedFileName(item->getName()) : LLStringUtil::null))
744 {
745 return;
746 }
747
748 std::string filename = file_picker.getFirstFile(); 748 std::string filename = file_picker.getFirstFile();
749 std::string scriptText=self->mEditor->getText(); 749 std::string scriptText=self->mEditor->getText();
750 std::ofstream fout(filename.c_str()); 750 std::ofstream fout(filename.c_str());
751 fout<<(scriptText); 751 fout << scriptText;
752 fout.close(); 752 fout.close();
753 self->mSaveCallback( self->mUserdata, FALSE ); 753 self->mSaveCallback(self->mUserdata, FALSE);
754 754 }
755 }
756
757} 755}
756
758void LLScriptEdCore::onBtnLoadFromDisc( void* data ) 757void LLScriptEdCore::onBtnLoadFromDisc( void* data )
759{ 758{
760
761 LLScriptEdCore* self = (LLScriptEdCore*) data; 759 LLScriptEdCore* self = (LLScriptEdCore*) data;
762 760
763 LLFilePicker& file_picker = LLFilePicker::instance(); 761 LLFilePicker& file_picker = LLFilePicker::instance();
764 if( !file_picker.getOpenFile( LLFilePicker::FFLOAD_TEXT ) ) 762 if (!file_picker.getOpenFile(LLFilePicker::FFLOAD_TEXT))
765 { 763 {
766 return; 764 return;
767 } 765 }
@@ -771,17 +769,14 @@ void LLScriptEdCore::onBtnLoadFromDisc( void* data )
771 std::ifstream fin(filename.c_str()); 769 std::ifstream fin(filename.c_str());
772 770
773 std::string line; 771 std::string line;
774 std::string linetotal;
775 self->mEditor->clear(); 772 self->mEditor->clear();
776 while (!fin.eof()) 773 while (!fin.eof())
777 { 774 {
778 getline(fin,line); 775 getline(fin,line);
779 line=line+"\n"; 776 line = line + "\n";
780 self->mEditor->insertText(line); 777 self->mEditor->insertText(line);
781
782 } 778 }
783 fin.close(); 779 fin.close();
784
785} 780}
786 781
787void LLScriptEdCore::onSearchMenu(void* userdata) 782void LLScriptEdCore::onSearchMenu(void* userdata)