aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview')
-rw-r--r--linden/indra/newview/llfilepicker.cpp12
-rw-r--r--linden/indra/newview/llfilepicker.h1
-rw-r--r--linden/indra/newview/llpreviewnotecard.cpp126
-rw-r--r--linden/indra/newview/llpreviewnotecard.h6
-rw-r--r--linden/indra/newview/llpreviewscript.cpp45
-rw-r--r--linden/indra/newview/llpreviewscript.h1
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml6
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard_keep_discard.xml6
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_script_ed_panel.xml14
9 files changed, 183 insertions, 34 deletions
diff --git a/linden/indra/newview/llfilepicker.cpp b/linden/indra/newview/llfilepicker.cpp
index 7b4caa8..d953e45 100644
--- a/linden/indra/newview/llfilepicker.cpp
+++ b/linden/indra/newview/llfilepicker.cpp
@@ -329,6 +329,17 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename)
329 L"Targa, Bitmap Images (*.tga; *.bmp)\0*.tga;*.bmp\0" \ 329 L"Targa, Bitmap Images (*.tga; *.bmp)\0*.tga;*.bmp\0" \
330 L"\0"; 330 L"\0";
331 break; 331 break;
332 case FFSAVE_LSL:
333 if (filename.empty())
334 {
335 wcsncpy( mFilesW,L"untitled.lsl", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/
336 }
337 mOFN.lpstrDefExt = L"lsl";
338 mOFN.lpstrFilter =
339 L"LSL Files (*.lsl)\0*.lsl\0"
340 L"Text files (*.txt)\0*.txt\0"
341 L"\0";
342 break;
332 case FFSAVE_TEXT: 343 case FFSAVE_TEXT:
333 if (filename.empty()) 344 if (filename.empty())
334 { 345 {
@@ -338,7 +349,6 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename)
338 mOFN.lpstrFilter = 349 mOFN.lpstrFilter =
339 L"Text files (*.txt)\0*.txt\0" 350 L"Text files (*.txt)\0*.txt\0"
340 L"RTF Files (*.rtf)\0*.rtf\0" 351 L"RTF Files (*.rtf)\0*.rtf\0"
341 L"LSL Files (*.lsl)\0*.lsl\0"
342 L"\0"; 352 L"\0";
343 break; 353 break;
344 case FFSAVE_WAV: 354 case FFSAVE_WAV:
diff --git a/linden/indra/newview/llfilepicker.h b/linden/indra/newview/llfilepicker.h
index 63699b2..fb20ed3 100644
--- a/linden/indra/newview/llfilepicker.h
+++ b/linden/indra/newview/llfilepicker.h
@@ -113,6 +113,7 @@ public:
113 FFSAVE_JPEG = 14, 113 FFSAVE_JPEG = 14,
114 FFSAVE_HPA = 15, 114 FFSAVE_HPA = 15,
115 FFSAVE_TEXT = 16, 115 FFSAVE_TEXT = 16,
116 FFSAVE_LSL = 17
116 }; 117 };
117 118
118 // open the dialog. This is a modal operation 119 // open the dialog. This is a modal operation
diff --git a/linden/indra/newview/llpreviewnotecard.cpp b/linden/indra/newview/llpreviewnotecard.cpp
index 4260434..be5d801 100644
--- a/linden/indra/newview/llpreviewnotecard.cpp
+++ b/linden/indra/newview/llpreviewnotecard.cpp
@@ -40,6 +40,7 @@
40#include "llassetuploadresponders.h" 40#include "llassetuploadresponders.h"
41#include "llviewerwindow.h" 41#include "llviewerwindow.h"
42#include "llbutton.h" 42#include "llbutton.h"
43#include "llfilepicker.h"
43#include "llfloatersearchreplace.h" 44#include "llfloatersearchreplace.h"
44#include "llinventorymodel.h" 45#include "llinventorymodel.h"
45#include "lllineeditor.h" 46#include "lllineeditor.h"
@@ -664,7 +665,23 @@ LLTextEditor* LLPreviewNotecard::getEditor()
664 665
665void LLPreviewNotecard::initMenu() 666void LLPreviewNotecard::initMenu()
666{ 667{
667 LLMenuItemCallGL* menuItem = getChild<LLMenuItemCallGL>("Undo"); 668 // File menu
669
670 LLMenuItemCallGL* menuItem = getChild<LLMenuItemCallGL>("Save Menu");
671 menuItem->setMenuCallback(onSaveMenu, this);
672 menuItem->setEnabledCallback(enableSaveMenu);
673
674 menuItem = getChild<LLMenuItemCallGL>("Export Text...");
675 menuItem->setMenuCallback(onExportTextMenu, this);
676 menuItem->setEnabledCallback(enableExportTextMenu);
677
678 menuItem = getChild<LLMenuItemCallGL>("Import Text...");
679 menuItem->setMenuCallback(onImportTextMenu, this);
680 menuItem->setEnabledCallback(enableImportTextMenu);
681
682 // Edit menu
683
684 menuItem = getChild<LLMenuItemCallGL>("Undo");
668 menuItem->setMenuCallback(onUndoMenu, this); 685 menuItem->setMenuCallback(onUndoMenu, this);
669 menuItem->setEnabledCallback(enableUndoMenu); 686 menuItem->setEnabledCallback(enableUndoMenu);
670 687
@@ -697,6 +714,77 @@ void LLPreviewNotecard::initMenu()
697 menuItem->setEnabledCallback(NULL); 714 menuItem->setEnabledCallback(NULL);
698} 715}
699 716
717//static
718void LLPreviewNotecard::onSaveMenu(void* userdata)
719{
720 LLPreviewNotecard* preview = (LLPreviewNotecard*)userdata;
721 if (preview)
722 {
723 preview->saveIfNeeded();
724 }
725}
726
727//static
728void LLPreviewNotecard::onExportTextMenu(void* userdata)
729{
730 LLPreviewNotecard* preview = (LLPreviewNotecard*)userdata;
731
732 if (preview)
733 {
734 LLViewerTextEditor* editor = preview->getChild<LLViewerTextEditor>("Notecard Editor");
735 if (editor)
736 {
737 LLFilePicker& file_picker = LLFilePicker::instance();
738 const LLViewerInventoryItem *item = preview->getItem();
739 if (!file_picker.getSaveFile(LLFilePicker::FFSAVE_TEXT, item ? LLDir::getScrubbedFileName(item->getName()) : LLStringUtil::null))
740 {
741 return;
742 }
743
744 std::string filename = file_picker.getFirstFile();
745 std::string scriptText = editor->getText();
746 std::ofstream fout(filename.c_str());
747 fout << scriptText;
748 fout.close();
749 }
750 }
751}
752
753//static
754void LLPreviewNotecard::onImportTextMenu(void* userdata)
755{
756 LLPreviewNotecard* preview = (LLPreviewNotecard*)userdata;
757
758 if (preview)
759 {
760 LLViewerTextEditor* editor = preview->getChild<LLViewerTextEditor>("Notecard Editor");
761 if (editor)
762 {
763 LLFilePicker& file_picker = LLFilePicker::instance();
764 if (!file_picker.getOpenFile(LLFilePicker::FFLOAD_TEXT))
765 {
766 return;
767 }
768
769 std::string filename = file_picker.getFirstFile();
770 std::ifstream fin(filename.c_str());
771
772 editor->clear();
773
774 std::string line;
775 while (!fin.eof())
776 {
777 getline(fin, line);
778 line = line + "\n";
779 editor->insertText(line);
780 }
781 fin.close();
782
783 preview->saveIfNeeded();
784 }
785 }
786}
787
700// static 788// static
701void LLPreviewNotecard::onSearchMenu(void* userdata) 789void LLPreviewNotecard::onSearchMenu(void* userdata)
702{ 790{
@@ -809,6 +897,42 @@ void LLPreviewNotecard::onDeselectMenu(void* userdata)
809 } 897 }
810} 898}
811 899
900//static
901BOOL LLPreviewNotecard::enableSaveMenu(void* userdata)
902{
903 LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
904 if (!self) return FALSE;
905 LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
906 if (!editor) return FALSE;
907 return !editor->isPristine();
908}
909
910//static
911BOOL LLPreviewNotecard::enableExportTextMenu(void* userdata)
912{
913 LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
914 if (!self) return FALSE;
915 LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
916 if (!editor) return FALSE;
917
918 // request the asset
919 const LLInventoryItem* item = self->getItem();
920 return (item && (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE) || gAgent.isGodlike()));
921}
922
923//static
924BOOL LLPreviewNotecard::enableImportTextMenu(void* userdata)
925{
926 LLPreviewNotecard* self = (LLPreviewNotecard*)userdata;
927 if (!self) return FALSE;
928 LLViewerTextEditor* editor = self->getChild<LLViewerTextEditor>("Notecard Editor");
929 if (!editor) return FALSE;
930
931 // request the asset
932 const LLInventoryItem* item = self->getItem();
933 return (item && (gAgent.allowOperation(PERM_MODIFY, item->getPermissions(), GP_OBJECT_MANIPULATE) || gAgent.isGodlike()));
934}
935
812// static 936// static
813BOOL LLPreviewNotecard::enableUndoMenu(void* userdata) 937BOOL LLPreviewNotecard::enableUndoMenu(void* userdata)
814{ 938{
diff --git a/linden/indra/newview/llpreviewnotecard.h b/linden/indra/newview/llpreviewnotecard.h
index a879fec..e3129ec 100644
--- a/linden/indra/newview/llpreviewnotecard.h
+++ b/linden/indra/newview/llpreviewnotecard.h
@@ -112,6 +112,9 @@ protected:
112 112
113 void initMenu(); 113 void initMenu();
114 114
115 static void onSaveMenu(void* userdata);
116 static void onExportTextMenu(void* userdata);
117 static void onImportTextMenu(void* userdata);
115 static void onSearchMenu(void* userdata); 118 static void onSearchMenu(void* userdata);
116 static void onUndoMenu(void* userdata); 119 static void onUndoMenu(void* userdata);
117 static void onRedoMenu(void* userdata); 120 static void onRedoMenu(void* userdata);
@@ -121,6 +124,9 @@ protected:
121 static void onSelectAllMenu(void* userdata); 124 static void onSelectAllMenu(void* userdata);
122 static void onDeselectMenu(void* userdata); 125 static void onDeselectMenu(void* userdata);
123 126
127 static BOOL enableSaveMenu(void* userdata);
128 static BOOL enableExportTextMenu(void* userdata);
129 static BOOL enableImportTextMenu(void* userdata);
124 static BOOL enableUndoMenu(void* userdata); 130 static BOOL enableUndoMenu(void* userdata);
125 static BOOL enableRedoMenu(void* userdata); 131 static BOOL enableRedoMenu(void* userdata);
126 static BOOL enableCutMenu(void* userdata); 132 static BOOL enableCutMenu(void* userdata);
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)
diff --git a/linden/indra/newview/llpreviewscript.h b/linden/indra/newview/llpreviewscript.h
index 0d5c300..8e61435 100644
--- a/linden/indra/newview/llpreviewscript.h
+++ b/linden/indra/newview/llpreviewscript.h
@@ -138,6 +138,7 @@ protected:
138private: 138private:
139 std::string mSampleText; 139 std::string mSampleText;
140 std::string mHelpURL; 140 std::string mHelpURL;
141 std::string mScriptTitle;
141 LLTextEditor* mEditor; 142 LLTextEditor* mEditor;
142 void (*mLoadCallback)(void* userdata); 143 void (*mLoadCallback)(void* userdata);
143 void (*mSaveCallback)(void* userdata, BOOL close_after_save); 144 void (*mSaveCallback)(void* userdata, BOOL close_after_save);
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml b/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml
index ed26e11..a625598 100644
--- a/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml
@@ -20,6 +20,12 @@
20 <menu_bar bottom="-56" drop_shadow="false" enabled="true" follows="left|top|right" 20 <menu_bar bottom="-56" drop_shadow="false" enabled="true" follows="left|top|right"
21 height="18" left="8" mouse_opaque="false" name="motecard_menu" opaque="false" 21 height="18" left="8" mouse_opaque="false" name="motecard_menu" opaque="false"
22 tear_off="false" width="220"> 22 tear_off="false" width="220">
23 <menu drop_shadow="true" enabled="true" mouse_opaque="false" name="File" opaque="true" tear_off="false">
24 <menu_item_call enabled="false" mouse_opaque="true" label="Save" name="Save Menu" shortcut="control|S" />
25 <menu_item_separator />
26 <menu_item_call enabled="false" mouse_opaque="true" label="Export Text..." name="Export Text..." />
27 <menu_item_call enabled="false" mouse_opaque="true" label="Import Text..." name="Import Text..." />
28 </menu>
23 <menu bottom_delta="16" left="0" drop_shadow="true" enabled="true" height="198" width="150" 29 <menu bottom_delta="16" left="0" drop_shadow="true" enabled="true" height="198" width="150"
24 mouse_opaque="false" name="Edit" opaque="true" tear_off="false"> 30 mouse_opaque="false" name="Edit" opaque="true" tear_off="false">
25 <menu_item_call bottom_delta="-30" enabled="false" height="20" label="Undo" left="0" 31 <menu_item_call bottom_delta="-30" enabled="false" height="20" label="Undo" left="0"
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard_keep_discard.xml b/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard_keep_discard.xml
index cd651dd..ec3ce5a 100644
--- a/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard_keep_discard.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_preview_notecard_keep_discard.xml
@@ -20,6 +20,12 @@
20 <menu_bar bottom="-56" drop_shadow="false" enabled="true" follows="left|top|right" 20 <menu_bar bottom="-56" drop_shadow="false" enabled="true" follows="left|top|right"
21 height="18" left="8" mouse_opaque="false" name="motecard_menu" opaque="false" 21 height="18" left="8" mouse_opaque="false" name="motecard_menu" opaque="false"
22 tear_off="false" width="220"> 22 tear_off="false" width="220">
23 <menu drop_shadow="true" enabled="true" mouse_opaque="false" name="File" opaque="true" tear_off="false">
24 <menu_item_call enabled="false" mouse_opaque="true" label="Save" name="Save Menu" shortcut="control|S" />
25 <menu_item_separator />
26 <menu_item_call enabled="false" mouse_opaque="true" label="Export Text..." name="Export Text..." />
27 <menu_item_call enabled="false" mouse_opaque="true" label="Import Text..." name="Import Text..." />
28 </menu>
23 <menu bottom_delta="16" left="0" drop_shadow="true" enabled="true" height="198" width="150" 29 <menu bottom_delta="16" left="0" drop_shadow="true" enabled="true" height="198" width="150"
24 mouse_opaque="false" name="Edit" opaque="true" tear_off="false"> 30 mouse_opaque="false" name="Edit" opaque="true" tear_off="false">
25 <menu_item_call bottom_delta="-30" enabled="false" height="20" label="Undo" left="0" 31 <menu_item_call bottom_delta="-30" enabled="false" height="20" label="Undo" left="0"
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 b4577e6..82a65b8 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
@@ -37,10 +37,10 @@
37 mouse_opaque="true" name="Revert All Changes" width="138" /> 37 mouse_opaque="true" name="Revert All Changes" width="138" />
38 <menu_item_separator bottom_delta="-66" height="8" left="0" mouse_opaque="true" name="separator" 38 <menu_item_separator bottom_delta="-66" height="8" left="0" mouse_opaque="true" name="separator"
39 width="138" /> 39 width="138" />
40 <menu_item_call bottom_delta="-76" height="20" label="Save to Disk" left="0" 40 <menu_item_call bottom_delta="-76" height="20" label="Export Script..." left="0"
41 mouse_opaque="true" name="Save to Disk" width="138" /> 41 mouse_opaque="true" name="Export Script..." width="138" />
42 <menu_item_call bottom_delta="-96" height="20" label="Load from Disk" left="0" 42 <menu_item_call bottom_delta="-96" height="20" label="Import Script..." left="0"
43 mouse_opaque="true" name="Load from Disk" width="138" /> 43 mouse_opaque="true" name="Import Script..." width="138" />
44 </menu> 44 </menu>
45 <menu bottom="665" drop_shadow="true" enabled="true" height="198" 45 <menu bottom="665" drop_shadow="true" enabled="true" height="198"
46 left="222" mouse_opaque="false" name="Edit" opaque="true" tear_off="false" 46 left="222" mouse_opaque="false" name="Edit" opaque="true" tear_off="false"
@@ -71,11 +71,11 @@
71 <menu bottom="-18" drop_shadow="true" enabled="true" height="34" 71 <menu bottom="-18" drop_shadow="true" enabled="true" height="34"
72 left="0" mouse_opaque="false" name="Help" opaque="true" tear_off="false" 72 left="0" mouse_opaque="false" name="Help" opaque="true" tear_off="false"
73 width="112"> 73 width="112">
74 <menu_item_call bottom="-30" enabled="true" height="20" label="Help..." left="0" 74 <menu_item_call bottom="-30" enabled="true" height="20" label="Help" left="0"
75 mouse_opaque="true" name="Help..." width="112" /> 75 mouse_opaque="true" name="Help..." width="112" />
76 <menu_item_call bottom="-30" enabled="true" height="20" label="Launch Autoscript..." left="0" 76 <menu_item_call bottom="-30" enabled="true" height="20" label="Launch Autoscript" left="0"
77 mouse_opaque="true" name="Launch Autoscript..." width="112" /> 77 mouse_opaque="true" name="Launch Autoscript..." width="112" />
78 <menu_item_call bottom="-30" enabled="true" height="20" label="LSL Wiki Help..." left="0" 78 <menu_item_call bottom="-30" enabled="true" height="20" label="LSL Wiki Help" left="0"
79 mouse_opaque="true" name="LSL Wiki Help..." width="112" /> 79 mouse_opaque="true" name="LSL Wiki Help..." width="112" />
80 </menu> 80 </menu>
81 </menu_bar> 81 </menu_bar>