DIRECTOR: Fix FileIO::m_displaySave

This commit is contained in:
Scott Percival 2024-06-18 23:46:44 +08:00
parent f44988d423
commit 707a854668
No known key found for this signature in database
4 changed files with 10 additions and 8 deletions

View File

@ -226,7 +226,7 @@ FileIOError FileObject::open(const Common::String &origpath, const Common::Strin
if (option.hasPrefix("?")) {
option = option.substr(1);
path = getFileNameFromModal(option.equalsIgnoreCase("write"), origpath, "txt");
path = getFileNameFromModal(option.equalsIgnoreCase("write"), origpath, Common::String(), "txt");
if (path.empty()) {
return kErrorFileNotFound;
}
@ -376,11 +376,13 @@ void FileIO::m_closeFile(int nargs) {
XOBJSTUB(FileIO::m_createFile, 0)
void FileIO::m_displayOpen(int nargs) {
g_lingo->push(getFileNameFromModal(false, Common::String(), "txt"));
g_lingo->push(getFileNameFromModal(false, Common::String(), Common::String(), "txt"));
}
void FileIO::m_displaySave(int nargs) {
g_lingo->push(getFileNameFromModal(true, Common::String(), "txt"));
Datum defaultFileName = g_lingo->pop();
Datum title = g_lingo->pop();
g_lingo->push(getFileNameFromModal(true, Common::String(), title.asString(), "txt"));
}
XOBJSTUB(FileIO::m_setFilterMask, 0)

View File

@ -585,7 +585,7 @@ void MMovieXObj::m_readFile(int nargs) {
Common::String prefix = savePrefix();
Common::String result;
if (origPath.empty()) {
path = getFileNameFromModal(false, Common::String(), "txt");
path = getFileNameFromModal(false, Common::String(), Common::String(), "txt");
if (path.empty()) {
debugC(5, kDebugXObj, "MMovieXObj::m_readFile(): read cancelled by modal");
g_lingo->push(result);
@ -646,7 +646,7 @@ void MMovieXObj::m_writeFile(int nargs) {
Common::String prefix = savePrefix();
if (origPath.empty()) {
path = getFileNameFromModal(true, Common::String(), "txt");
path = getFileNameFromModal(true, Common::String(), Common::String(), "txt");
if (path.empty()) {
debugC(5, kDebugXObj, "MMovieXObj::m_writeFile(): read cancelled by modal");
g_lingo->push(result);

View File

@ -974,14 +974,14 @@ Common::Path findAudioPath(const Common::String &path, bool currentFolder, bool
return result;
}
Common::String getFileNameFromModal(bool save, const Common::String &suggested, const char *ext) {
Common::String getFileNameFromModal(bool save, const Common::String &suggested, const Common::String &title, const char *ext) {
Common::String prefix = savePrefix();
Common::String mask = prefix + "*";
if (ext) {
mask += ".";
mask += ext;
}
GUI::FileBrowserDialog browser(nullptr, "txt", save ? GUI::kFBModeSave : GUI::kFBModeLoad, mask.c_str(), suggested.c_str());
GUI::FileBrowserDialog browser(title.c_str(), "txt", save ? GUI::kFBModeSave : GUI::kFBModeLoad, mask.c_str(), suggested.c_str());
if (browser.runModal() <= 0) {
return Common::String();
}

View File

@ -54,7 +54,7 @@ Common::Path findMoviePath(const Common::String &path, bool currentFolder = true
Common::Path findXLibPath(const Common::String &path, bool currentFolder = true, bool searchPaths = true);
Common::Path findAudioPath(const Common::String &path, bool currentFolder = true, bool searchPaths = true);
Common::String getFileNameFromModal(bool save, const Common::String &suggested, const char *ext = "txt");
Common::String getFileNameFromModal(bool save, const Common::String &suggested, const Common::String &title, const char *ext = "txt");
Common::String savePrefix();
bool hasExtension(Common::String filename);