summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRye Cogtail <rye@lindenlab.com>2024-10-31 01:51:43 -0400
committerRye Cogtail <rye@lindenlab.com>2024-10-31 01:52:24 -0400
commit3fc5545f8a00fec5b15938df1394f664b8396f01 (patch)
tree583087f48108cd53cf9de31fcb8219710ecc7ff7 /indra
parent24e49d9b908969dbfac67364952ec94ef99a6023 (diff)
Fix various bugs in NFD impl and fix usage on windows
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/lldirpicker.cpp6
-rw-r--r--indra/newview/llfilepicker.cpp85
-rw-r--r--indra/newview/llfilepicker.h4
-rw-r--r--indra/newview/llviewermenufile.cpp6
4 files changed, 25 insertions, 76 deletions
diff --git a/indra/newview/lldirpicker.cpp b/indra/newview/lldirpicker.cpp
index 0799d90ce8..032433434d 100644
--- a/indra/newview/lldirpicker.cpp
+++ b/indra/newview/lldirpicker.cpp
@@ -124,6 +124,8 @@ bool LLDirPicker::getDir(std::string* filename, bool blocking)
{
windowHandle = nfdwindowhandle_t();
}
+#elif LL_WINDOWS
+ windowHandle = { NFD_WINDOW_HANDLE_TYPE_WINDOWS, gViewerWindow->getWindow()->getPlatformWindow() };
#endif
// show the dialog
@@ -379,7 +381,7 @@ std::queue<LLDirPickerThread*> LLDirPickerThread::sDeadQ;
void LLDirPickerThread::getFile()
{
-#if (LL_WINDOWS && !LL_NFD) || (LL_LINUX && LL_NFD)
+#if LL_WINDOWS || (LL_NFD && !LL_DARWIN)
start();
#else
run();
@@ -389,7 +391,7 @@ void LLDirPickerThread::getFile()
//virtual
void LLDirPickerThread::run()
{
-#if (LL_WINDOWS && !LL_NFD) || (LL_LINUX && LL_NFD)
+#if LL_WINDOWS || (LL_NFD && !LL_DARWIN)
bool blocking = false;
#else
bool blocking = true; // modal
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index 760f5a700e..ca0b58b611 100644
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -82,7 +82,7 @@ LLFilePicker::LLFilePicker()
{
reset();
-#if LL_WINDOWS
+#if LL_WINDOWS && !LL_NFD
mOFN.lStructSize = sizeof(OPENFILENAMEW);
mOFN.hwndOwner = NULL; // Set later
mOFN.hInstance = NULL;
@@ -179,15 +179,7 @@ std::vector<nfdfilteritem_t> LLFilePicker::setupFilter(ELoadFilter filter)
#endif
break;
case FFLOAD_ALL:
- filter_vec.emplace_back(nfdfilteritem_t{"Executables", "exe"});
- filter_vec.emplace_back(nfdfilteritem_t{"Sounds", "wav"});
- filter_vec.emplace_back(nfdfilteritem_t{"Animations", "bvh,anim"});
- filter_vec.emplace_back(nfdfilteritem_t{"Model files", "dae"});
- filter_vec.emplace_back(nfdfilteritem_t{"RAW files", "raw"});
- filter_vec.emplace_back(nfdfilteritem_t{"Script files (lsl)", "lsl"});
- filter_vec.emplace_back(nfdfilteritem_t{"Dictionary files", "dic,xcu"});
- filter_vec.emplace_back(nfdfilteritem_t{"GLTF Files", "gltf,glb"});
- filter_vec.emplace_back(nfdfilteritem_t{"Script files (lua)", "lua"});
+ // Empty to allow picking all files by default
break;
case FFLOAD_WAV:
filter_vec.emplace_back(nfdfilteritem_t{"Sounds", "wav"});
@@ -219,19 +211,20 @@ std::vector<nfdfilteritem_t> LLFilePicker::setupFilter(ELoadFilter filter)
break;
case FFLOAD_HDRI:
filter_vec.emplace_back(nfdfilteritem_t{"EXR files", "exr"});
+ break;
case FFLOAD_MATERIAL_TEXTURE:
filter_vec.emplace_back(nfdfilteritem_t{"GLTF Import", "gltf,glb,tga,bmp,jpg,jpeg,png"});
filter_vec.emplace_back(nfdfilteritem_t{"GLTF Files", "gltf,glb"});
filter_vec.emplace_back(nfdfilteritem_t{"Images", "tga,bmp,jpg,jpeg,png"});
break;
case FFLOAD_SCRIPT:
- filter_vec.emplace_back(nfdfilteritem_t{"Script files", "lsl"});
+ filter_vec.emplace_back(nfdfilteritem_t{"Script files (*.lsl)", "lsl"});
break;
case FFLOAD_DICTIONARY:
filter_vec.emplace_back(nfdfilteritem_t{"Dictionary files", "dic,xcu"});
break;
case FFLOAD_LUA:
- filter_vec.emplace_back(nfdfilteritem_t{"Script files", "lua"});
+ filter_vec.emplace_back(nfdfilteritem_t{"Script files (*.lua)", "lua"});
break;
default:
break;
@@ -268,6 +261,8 @@ bool LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking)
{
windowHandle = nfdwindowhandle_t();
}
+#elif LL_WINDOWS
+ windowHandle = { NFD_WINDOW_HANDLE_TYPE_WINDOWS, gViewerWindow->getWindow()->getPlatformWindow() };
#endif
if (blocking)
@@ -279,7 +274,7 @@ bool LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking)
reset();
// show the dialog
- nfdresult_t result = NFD::OpenDialog(outPath, filterItem.data(), filterItem.size(), nullptr, windowHandle);
+ nfdresult_t result = NFD::OpenDialog(outPath, filterItem.data(), narrow(filterItem.size()), nullptr, windowHandle);
if (result == NFD_OKAY)
{
mFiles.push_back(outPath.get());
@@ -347,13 +342,15 @@ bool LLFilePicker::getMultipleOpenFiles(ELoadFilter filter, bool blocking)
{
windowHandle = nfdwindowhandle_t();
}
+#elif LL_WINDOWS
+ windowHandle = { NFD_WINDOW_HANDLE_TYPE_WINDOWS, gViewerWindow->getWindow()->getPlatformWindow() };
#endif
// auto-freeing memory
NFD::UniquePathSet outPaths;
// show the dialog
- nfdresult_t result = NFD::OpenDialogMultiple(outPaths, filterItem.data(), filterItem.size(), nullptr, windowHandle);
+ nfdresult_t result = NFD::OpenDialogMultiple(outPaths, filterItem.data(), narrow(filterItem.size()), nullptr, windowHandle);
if (result == NFD_OKAY)
{
LL_INFOS() << "Success!" << LL_ENDL;
@@ -440,10 +437,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.wav";
}
- else
- {
- saved_filename += ".wav";
- }
filter_vec.emplace_back(nfdfilteritem_t{"WAV Sounds", "wav"});
break;
case FFSAVE_TGA:
@@ -451,10 +444,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.tga";
}
- else
- {
- saved_filename += ".tga";
- }
filter_vec.emplace_back(nfdfilteritem_t{"Targa Images", "tga"});
break;
case FFSAVE_BMP:
@@ -462,10 +451,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.bmp";
}
- else
- {
- saved_filename += ".bmp";
- }
filter_vec.emplace_back(nfdfilteritem_t{"Bitmap Images", "bmp"});
break;
case FFSAVE_PNG:
@@ -473,10 +458,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.png";
}
- else
- {
- saved_filename += ".png";
- }
filter_vec.emplace_back(nfdfilteritem_t{"PNG Images", "png"});
break;
case FFSAVE_TGAPNG:
@@ -484,14 +465,10 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.png";
}
- else
- {
- saved_filename += ".png";
- }
filter_vec.emplace_back(nfdfilteritem_t{"PNG Images", "png"});
filter_vec.emplace_back(nfdfilteritem_t{"Targa Images", "tga"});
- filter_vec.emplace_back(nfdfilteritem_t{"Jpeg Images", "jpg,jpeg"});
+ filter_vec.emplace_back(nfdfilteritem_t{"JPEG Images", "jpg,jpeg"});
filter_vec.emplace_back(nfdfilteritem_t{"Jpeg2000 Images", "j2c"});
filter_vec.emplace_back(nfdfilteritem_t{"Bitmap Images", "bmp"});
break;
@@ -500,21 +477,13 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.jpeg";
}
- else
- {
- saved_filename += ".jpeg";
- }
- filter_vec.emplace_back(nfdfilteritem_t{"Jpeg Images", "jpg,jpeg"});
+ filter_vec.emplace_back(nfdfilteritem_t{"JPEG Images", "jpg,jpeg"});
break;
case FFSAVE_AVI:
if (filename.empty())
{
saved_filename = "untitled.avi";
}
- else
- {
- saved_filename += ".avi";
- }
filter_vec.emplace_back(nfdfilteritem_t{"AVI Movie File", "avi"});
break;
case FFSAVE_ANIM:
@@ -522,10 +491,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.xaf";
}
- else
- {
- saved_filename += ".xaf";
- }
filter_vec.emplace_back(nfdfilteritem_t{"XAF Anim File", "xaf"});
break;
case FFSAVE_XML:
@@ -533,10 +498,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.xml";
}
- else
- {
- saved_filename += ".xml";
- }
filter_vec.emplace_back(nfdfilteritem_t{"XML File", "xml"});
break;
case FFSAVE_COLLADA:
@@ -544,10 +505,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.collada";
}
- else
- {
- saved_filename += ".collada";
- }
filter_vec.emplace_back(nfdfilteritem_t{"COLLADA File", "collada"});
break;
case FFSAVE_RAW:
@@ -555,10 +512,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.raw";
}
- else
- {
- saved_filename += ".raw";
- }
filter_vec.emplace_back(nfdfilteritem_t{"RAW files", "raw"});
break;
case FFSAVE_J2C:
@@ -566,10 +519,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.j2c";
}
- else
- {
- saved_filename += ".j2c";
- }
filter_vec.emplace_back(nfdfilteritem_t{"Compressed Images", "j2c"});
break;
case FFSAVE_SCRIPT:
@@ -577,10 +526,6 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
saved_filename = "untitled.lsl";
}
- else
- {
- saved_filename += ".lsl";
- }
filter_vec.emplace_back(nfdfilteritem_t{"LSL Files", "lsl"});
break;
default:
@@ -593,6 +538,8 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
{
windowHandle = nfdwindowhandle_t();
}
+#elif LL_WINDOWS
+ windowHandle = { NFD_WINDOW_HANDLE_TYPE_WINDOWS, gViewerWindow->getWindow()->getPlatformWindow() };
#endif
reset();
@@ -607,7 +554,7 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,
NFD::UniquePath savePath;
// show the dialog
- nfdresult_t result = NFD::SaveDialog(savePath, filter_vec.data(), filter_vec.size(), nullptr, saved_filename.c_str(), windowHandle);
+ nfdresult_t result = NFD::SaveDialog(savePath, filter_vec.data(), narrow(filter_vec.size()), nullptr, saved_filename.c_str(), windowHandle);
if (result == NFD_OKAY) {
mFiles.push_back(savePath.get());
success = true;
diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h
index fadebca96c..8c89570174 100644
--- a/indra/newview/llfilepicker.h
+++ b/indra/newview/llfilepicker.h
@@ -159,14 +159,14 @@ private:
std::vector<nfdfilteritem_t> setupFilter(ELoadFilter filter);
#endif
-#if LL_WINDOWS
+#if LL_WINDOWS && !LL_NFD
OPENFILENAMEW mOFN; // for open and save dialogs
WCHAR mFilesW[FILENAME_BUFFER_SIZE];
bool setupFilter(ELoadFilter filter);
#endif
-#if LL_DARWIN
+#if LL_DARWIN && !LL_NFD
S32 mPickOptions;
std::vector<std::string> mFileVector;
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 2a871a24af..14c9c53a9c 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -137,10 +137,10 @@ std::queue<LLFilePickerThread*> LLFilePickerThread::sDeadQ;
void LLFilePickerThread::getFile()
{
-#if LL_WINDOWS
+#if LL_WINDOWS || (LL_NFD && !LL_DARWIN)
// Todo: get rid of LLFilePickerThread and make this modeless
start();
-#elif LL_DARWIN
+#elif LL_DARWIN && !LL_NFD
runModeless();
#else
run();
@@ -150,7 +150,7 @@ void LLFilePickerThread::getFile()
//virtual
void LLFilePickerThread::run()
{
-#if LL_WINDOWS
+#if LL_WINDOWS || (LL_NFD && !LL_DARWIN)
bool blocking = false;
#else
bool blocking = true; // modal