[Scummvm-git-logs] scummvm master -> a434791bf88c1edc9ab8ab8e7da9639562494f20
aquadran
aquadran at gmail.com
Sat Oct 31 08:44:59 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a434791bf8 MORPHOS: Add native file browser via Asl (#2574)
Commit: a434791bf88c1edc9ab8ab8e7da9639562494f20
https://github.com/scummvm/scummvm/commit/a434791bf88c1edc9ab8ab8e7da9639562494f20
Author: BeWorld (36823759+BeWorld2018 at users.noreply.github.com)
Date: 2020-10-31T09:44:55+01:00
Commit Message:
MORPHOS: Add native file browser via Asl (#2574)
MORPHOS: Add native file browser via Asl
Changed paths:
A backends/dialogs/morphos/morphos-dialogs.cpp
A backends/dialogs/morphos/morphos-dialogs.h
backends/module.mk
backends/platform/sdl/morphos/morphos.cpp
configure
diff --git a/backends/dialogs/morphos/morphos-dialogs.cpp b/backends/dialogs/morphos/morphos-dialogs.cpp
new file mode 100644
index 0000000000..4ba308f024
--- /dev/null
+++ b/backends/dialogs/morphos/morphos-dialogs.cpp
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
+#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+#define FORBIDDEN_SYMBOL_EXCEPTION_strdup
+#include "common/scummsys.h"
+
+#if defined(__MORPHOS__) && defined(USE_SYSDIALOGS)
+
+#include "backends/dialogs/morphos/morphos-dialogs.h"
+
+#include "common/config-manager.h"
+#include "common/encoding.h"
+#include "common/translation.h"
+
+#include <proto/exec.h>
+#include <proto/dos.h>
+#define __NOLIBBASE__
+#include <proto/asl.h>
+#include <proto/charsets.h>
+
+char *MorphosDialogManager::utf8ToLocal(char *in) {
+
+ if (!in) {
+ return strdup("");
+ }
+
+ struct Library *CharsetsBase = OpenLibrary("charsets.library", 0);
+ if (CharsetsBase) {
+
+ LONG dstmib = GetSystemCharset(NULL, 0);
+ if (dstmib != MIBENUM_INVALID) {
+ LONG dstlen = GetByteSize((APTR)in, -1, MIBENUM_UTF_8, dstmib);
+ char *out = (char *)malloc(dstlen + 1);
+ if (out) {
+ if (ConvertTagList((APTR)in, -1, (APTR)out, -1, MIBENUM_UTF_8, dstmib, NULL) != -1) {
+ return out;
+ }
+ free(out);
+ }
+ }
+ CloseLibrary(CharsetsBase);
+ }
+
+ return strdup(in);
+}
+
+Common::DialogManager::DialogResult MorphosDialogManager::showFileBrowser(const Common::U32String &title, Common::FSNode &choice, bool isDirBrowser) {
+
+ DialogResult result = kDialogCancel;
+ char pathBuffer[PATH_MAX];
+ Common::String utf8Title = title.encode();
+ struct Library *AslBase = OpenLibrary(AslName, 39);
+
+ if (AslBase) {
+
+ struct FileRequester *fr = NULL;
+
+ if (ConfMan.hasKey("browser_lastpath")) {
+ strncpy(pathBuffer, ConfMan.get("browser_lastpath").c_str(), sizeof(pathBuffer) - 1);
+ }
+
+ fr = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest, TAG_DONE);
+
+ if (!fr)
+ return result;
+
+ char *newTitle = utf8ToLocal((char *)utf8Title.c_str());
+
+ if (AslRequestTags(fr, ASLFR_TitleText, (IPTR)newTitle, ASLFR_RejectIcons, TRUE, ASLFR_InitialDrawer, (IPTR)pathBuffer, ASLFR_DrawersOnly, (isDirBrowser ? TRUE : FALSE), TAG_DONE)) {
+
+ if (strlen(fr->fr_Drawer) < sizeof(pathBuffer)) {
+ strncpy(pathBuffer, fr->fr_Drawer, sizeof(pathBuffer));
+ if (!isDirBrowser) {
+ AddPart(pathBuffer, fr->fr_File, sizeof(pathBuffer));
+ }
+ choice = Common::FSNode(pathBuffer);
+ ConfMan.set("browser_lastpath", pathBuffer);
+ result = kDialogOk;
+ }
+ }
+
+ free(newTitle);
+ FreeAslRequest((APTR)fr);
+ CloseLibrary(AslBase);
+ }
+
+ return result;
+}
+
+#endif
diff --git a/backends/dialogs/morphos/morphos-dialogs.h b/backends/dialogs/morphos/morphos-dialogs.h
new file mode 100644
index 0000000000..7bc1272584
--- /dev/null
+++ b/backends/dialogs/morphos/morphos-dialogs.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef BACKEND_MORPHOS_DIALOGS_H
+#define BACKEND_MORPHOS_DIALOGS_H
+
+#if defined(__MORPHOS__) && defined(USE_SYSDIALOGS)
+
+#include "common/fs.h"
+#include "common/dialogs.h"
+
+class MorphosDialogManager : public Common::DialogManager {
+public:
+ virtual DialogResult showFileBrowser(const Common::U32String &title, Common::FSNode &choice, bool isDirBrowser);
+
+private:
+ char *utf8ToLocal(char *in);
+};
+
+#endif
+
+#endif // BACKEND_MORPHOS_DIALOGS_H
diff --git a/backends/module.mk b/backends/module.mk
index edb58f275b..b9550bfb1e 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -249,7 +249,8 @@ endif
ifdef MORPHOS
MODULE_OBJS += \
fs/morphos/morphos-fs.o \
- fs/morphos/morphos-fs-factory.o
+ fs/morphos/morphos-fs-factory.o \
+ dialogs/morphos/morphos-dialogs.o
endif
ifdef RISCOS
diff --git a/backends/platform/sdl/morphos/morphos.cpp b/backends/platform/sdl/morphos/morphos.cpp
index 96a7dfd169..405fe854e3 100644
--- a/backends/platform/sdl/morphos/morphos.cpp
+++ b/backends/platform/sdl/morphos/morphos.cpp
@@ -26,6 +26,7 @@
#include "backends/platform/sdl/morphos/morphos.h"
#include "backends/fs/morphos/morphos-fs-factory.h"
+#include "backends/dialogs/morphos/morphos-dialogs.h"
#include <proto/openurl.h>
void OSystem_MorphOS::init() {
@@ -34,12 +35,21 @@ void OSystem_MorphOS::init() {
// Invoke parent implementation of this method
OSystem_SDL::init();
+
+#if defined(USE_SYSDIALOGS)
+ _dialogManager = new MorphosDialogManager();
+#endif
}
bool OSystem_MorphOS::hasFeature(Feature f) {
if (f == kFeatureOpenUrl)
return true;
-
+
+#if defined(USE_SYSDIALOGS)
+ if (f == kFeatureSystemBrowserDialog)
+ return true;
+#endif
+
return OSystem_SDL::hasFeature(f);
}
diff --git a/configure b/configure
index 4ad99758c7..16ee81c32e 100755
--- a/configure
+++ b/configure
@@ -5821,6 +5821,10 @@ if test "$_dialogs" = "no"; then
echo "no"
else
case $_host_os in
+ morphos*)
+ echo "morphos"
+ _dialogs=yes
+ ;;
mingw*)
append_var LIBS "-lole32 -luuid"
echo "win32"
More information about the Scummvm-git-logs
mailing list