From a2d08f62ecdb777efa12930bf337f3f64dfe1779 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sat, 26 Jun 2021 00:24:57 -0400 Subject: [PATCH] Same macosx palette search logic added for palette editor window. --- src/drivers/Qt/PaletteEditor.cpp | 39 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/drivers/Qt/PaletteEditor.cpp b/src/drivers/Qt/PaletteEditor.cpp index ba1dee3e..2c4e22c9 100644 --- a/src/drivers/Qt/PaletteEditor.cpp +++ b/src/drivers/Qt/PaletteEditor.cpp @@ -326,15 +326,46 @@ void PaletteEditorDialog_t::openPaletteFileDialog(void) urls << QUrl::fromLocalFile( d.absolutePath() ); iniPath = d.absolutePath().toStdString(); } + + #ifdef __APPLE__ + // Search for MacOSX DragNDrop Resources + d.setPath(QString(exePath) + "/../Resources/palettes"); + + //printf("Looking for: '%s'\n", d.path().toStdString().c_str()); + + if (d.exists()) + { + urls << QUrl::fromLocalFile(d.absolutePath()); + iniPath = d.absolutePath().toStdString(); + } + #endif } #ifdef WIN32 #else - d.setPath("/usr/share/fceux/palettes"); - - if ( d.exists() ) + // Linux and MacOSX (homebrew) expect shared data folder to be relative to bin/fceux executable. + if (exePath[0] != 0) { - urls << QUrl::fromLocalFile( d.absolutePath() ); + d.setPath(QString(exePath) + "/../share/fceux/palettes"); + } + else + { + d.setPath(QString("/usr/local/share/fceux/palettes")); + } + if (!d.exists()) + { + d.setPath(QString("/usr/local/share/fceux/palettes")); + } + if (!d.exists()) + { + d.setPath(QString("/usr/share/fceux/palettes")); + } + + //printf("Looking for: '%s'\n", d.path().toStdString().c_str()); + + if (d.exists()) + { + urls << QUrl::fromLocalFile(d.absolutePath()); iniPath = d.absolutePath().toStdString(); } #endif