summaryrefslogtreecommitdiff
path: root/indra/newview/llfilepicker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfilepicker.cpp')
-rw-r--r--indra/newview/llfilepicker.cpp88
1 files changed, 68 insertions, 20 deletions
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index 8c0ed29855..8986a694f9 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -49,7 +49,7 @@ LLFilePicker LLFilePicker::sInstance;
#if LL_WINDOWS
#define SOUND_FILTER L"Sounds (*.wav)\0*.wav\0"
#define IMAGE_FILTER L"Images (*.tga; *.bmp; *.jpg; *.jpeg; *.png)\0*.tga;*.bmp;*.jpg;*.jpeg;*.png\0"
-#define ANIM_FILTER L"Animations (*.bvh)\0*.bvh\0"
+#define ANIM_FILTER L"Animations (*.bvh; *.anim)\0*.bvh;*.anim\0"
#define COLLADA_FILTER L"Scene (*.dae)\0*.dae\0"
#ifdef _CORY_TESTING
#define GEOMETRY_FILTER L"SL Geometry (*.slg)\0*.slg\0"
@@ -58,6 +58,7 @@ LLFilePicker LLFilePicker::sInstance;
#define SLOBJECT_FILTER L"Objects (*.slobject)\0*.slobject\0"
#define RAW_FILTER L"RAW files (*.raw)\0*.raw\0"
#define MODEL_FILTER L"Model files (*.dae)\0*.dae\0"
+#define SCRIPT_FILTER L"Script files (*.lsl)\0*.lsl\0"
#endif
//
@@ -213,6 +214,10 @@ BOOL LLFilePicker::setupFilter(ELoadFilter filter)
mOFN.lpstrFilter = MODEL_FILTER \
L"\0";
break;
+ case FFLOAD_SCRIPT:
+ mOFN.lpstrFilter = SCRIPT_FILTER \
+ L"\0";
+ break;
default:
res = FALSE;
break;
@@ -497,6 +502,14 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename)
L"Compressed Images (*.j2c)\0*.j2c\0" \
L"\0";
break;
+ case FFSAVE_SCRIPT:
+ if (filename.empty())
+ {
+ wcsncpy( mFilesW,L"untitled.lsl", FILENAME_BUFFER_SIZE);
+ }
+ mOFN.lpstrDefExt = L"txt";
+ mOFN.lpstrFilter = L"LSL Files (*.lsl)\0*.lsl\0" L"\0";
+ break;
default:
return FALSE;
}
@@ -580,8 +593,10 @@ Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callB
}
else if (filter == FFLOAD_ANIM)
{
- if (fileInfo.filetype != 'BVH ' &&
- (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("bvh"), kCFCompareCaseInsensitive) != kCFCompareEqualTo))
+ if (fileInfo.filetype != 'BVH ' &&
+ fileInfo.filetype != 'ANIM' &&
+ (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("bvh"), kCFCompareCaseInsensitive) != kCFCompareEqualTo) &&
+ fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("anim"), kCFCompareCaseInsensitive) != kCFCompareEqualTo))
)
{
result = false;
@@ -620,6 +635,14 @@ Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callB
result = false;
}
}
+ else if (filter == FFLOAD_SCRIPT)
+ {
+ if (fileInfo.filetype != 'LSL ' &&
+ (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("lsl"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) )
+ {
+ result = false;
+ }
+ }
if (fileInfo.extension)
{
@@ -653,12 +676,12 @@ OSStatus LLFilePicker::doNavChooseDialog(ELoadFilter filter)
// (It is destroyed by NavDialogDispose() below.)
error = NavCreateChooseFileDialog(&mNavOptions, NULL, NULL, NULL, navOpenFilterProc, (void*)(&filter), &navRef);
- gViewerWindow->mWindow->beforeDialog();
+ gViewerWindow->getWindow()->beforeDialog();
if (error == noErr)
error = NavDialogRun(navRef);
- gViewerWindow->mWindow->afterDialog();
+ gViewerWindow->getWindow()->afterDialog();
if (error == noErr)
error = NavDialogGetReply(navRef, &navReply);
@@ -766,6 +789,12 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& fi
extension = CFSTR(".j2c");
break;
+ case FFSAVE_SCRIPT:
+ type = 'LSL ';
+ creator = '\?\?\?\?';
+ extension = CFSTR(".lsl");
+ break;
+
case FFSAVE_ALL:
default:
type = '\?\?\?\?';
@@ -808,13 +837,13 @@ OSStatus LLFilePicker::doNavSaveDialog(ESaveFilter filter, const std::string& fi
}
}
- gViewerWindow->mWindow->beforeDialog();
+ gViewerWindow->getWindow()->beforeDialog();
// Run the dialog
if (error == noErr)
error = NavDialogRun(navRef);
- gViewerWindow->mWindow->afterDialog();
+ gViewerWindow->getWindow()->afterDialog();
if (error == noErr)
error = NavDialogGetReply(navRef, &navReply);
@@ -1046,8 +1075,11 @@ void LLFilePicker::chooser_responder(GtkWidget *widget, gint response, gpointer
}
// set the default path for this usage context.
- picker->mContextToPathMap[picker->mCurContextName] =
- gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(widget));
+ const char* cur_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(widget));
+ if (cur_folder != NULL)
+ {
+ picker->mContextToPathMap[picker->mCurContextName] = cur_folder;
+ }
gtk_widget_destroy(widget);
gtk_main_quit();
@@ -1169,10 +1201,14 @@ static std::string add_wav_filter_to_gtkchooser(GtkWindow *picker)
LLTrans::getString("sound_files") + " (*.wav)");
}
-static std::string add_bvh_filter_to_gtkchooser(GtkWindow *picker)
+static std::string add_anim_filter_to_gtkchooser(GtkWindow *picker)
{
- return add_simple_pattern_filter_to_gtkchooser(picker, "*.bvh",
- LLTrans::getString("animation_files") + " (*.bvh)");
+ GtkFileFilter *gfilter = gtk_file_filter_new();
+ gtk_file_filter_add_pattern(gfilter, "*.bvh");
+ gtk_file_filter_add_pattern(gfilter, "*.anim");
+ std::string filtername = LLTrans::getString("animation_files") + " (*.bvh; *.anim)";
+ add_common_filters_to_gtkchooser(gfilter, picker, filtername);
+ return filtername;
}
static std::string add_collada_filter_to_gtkchooser(GtkWindow *picker)
@@ -1192,7 +1228,12 @@ static std::string add_imageload_filter_to_gtkchooser(GtkWindow *picker)
add_common_filters_to_gtkchooser(gfilter, picker, filtername);
return filtername;
}
-
+
+static std::string add_script_filter_to_gtkchooser(GtkWindow *picker)
+{
+ return add_simple_mime_filter_to_gtkchooser(picker, "text/plain",
+ LLTrans::getString("script_files") + " (*.lsl)");
+}
BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename )
{
@@ -1204,7 +1245,7 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename
return FALSE;
}
- gViewerWindow->mWindow->beforeDialog();
+ gViewerWindow->getWindow()->beforeDialog();
reset();
@@ -1258,6 +1299,10 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename
LLTrans::getString("compressed_image_files") + " (*.j2c)");
suggest_ext = ".j2c";
break;
+ case FFSAVE_SCRIPT:
+ caption += add_script_filter_to_gtkchooser(picker);
+ suggest_ext = ".lsl";
+ break;
default:;
break;
}
@@ -1284,7 +1329,7 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename
rtn = (getFileCount() == 1);
}
- gViewerWindow->mWindow->afterDialog();
+ gViewerWindow->getWindow()->afterDialog();
return rtn;
}
@@ -1299,7 +1344,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking )
return FALSE;
}
- gViewerWindow->mWindow->beforeDialog();
+ gViewerWindow->getWindow()->beforeDialog();
reset();
@@ -1315,7 +1360,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking )
filtername = add_wav_filter_to_gtkchooser(picker);
break;
case FFLOAD_ANIM:
- filtername = add_bvh_filter_to_gtkchooser(picker);
+ filtername = add_anim_filter_to_gtkchooser(picker);
break;
case FFLOAD_COLLADA:
filtername = add_collada_filter_to_gtkchooser(picker);
@@ -1323,6 +1368,9 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking )
case FFLOAD_IMAGE:
filtername = add_imageload_filter_to_gtkchooser(picker);
break;
+ case FFLOAD_SCRIPT:
+ filtername = add_script_filter_to_gtkchooser(picker);
+ break;
default:;
break;
}
@@ -1337,7 +1385,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking )
rtn = (getFileCount() == 1);
}
- gViewerWindow->mWindow->afterDialog();
+ gViewerWindow->getWindow()->afterDialog();
return rtn;
}
@@ -1352,7 +1400,7 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter )
return FALSE;
}
- gViewerWindow->mWindow->beforeDialog();
+ gViewerWindow->getWindow()->beforeDialog();
reset();
@@ -1370,7 +1418,7 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter )
rtn = !mFiles.empty();
}
- gViewerWindow->mWindow->afterDialog();
+ gViewerWindow->getWindow()->afterDialog();
return rtn;
}