mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-16 16:50:06 +02:00
196 lines
4.0 KiB
Plaintext
196 lines
4.0 KiB
Plaintext
From 5d511569366a61473e82430b9af320b237a6ca8b Mon Sep 17 00:00:00 2001
|
|
From: Andrew Lobanov <spline1986@yandex.ru>
|
|
Date: Sat, 7 Jan 2023 22:44:16 +0000
|
|
Subject: HaikuOS specific fixes
|
|
|
|
|
|
diff --git a/Rules.make.system b/Rules.make.system
|
|
index 5a12b45..67ea14a 100644
|
|
--- a/Rules.make.system
|
|
+++ b/Rules.make.system
|
|
@@ -28,7 +28,8 @@ LUA_LFLAGS=$(shell pkg-config --libs lua5.1)
|
|
SDL_CFLAGS=$(shell sdl2-config --cflags)
|
|
SDL_LFLAGS=$(shell sdl2-config --libs) -lSDL2_ttf -lSDL2_mixer -lSDL2_image -lm
|
|
|
|
-CFLAGS += -Wall -Dunix -D_USE_UNPACK # -D_SDL_MOD_BUG
|
|
+CFLAGS += -O2 -Wall -Dunix -D_USE_UNPACK -D_USE_BROWSE -D_LOCAL_APPDATA # -D_SDL_MOD_BUG
|
|
+EXTRA_LDFLAGS += -ltracker -lbe -lstdc++
|
|
|
|
INSTALLD=install -d -m 0755
|
|
INSTALLB=install -m 0755
|
|
@@ -36,7 +37,7 @@ INSTALL=install -m 0644
|
|
LN=ln -sf
|
|
|
|
EXE=
|
|
-PLATFORM=unix.c
|
|
+PLATFORM=haiku.cpp unix.c
|
|
RESOURCES=
|
|
RM=rm
|
|
AR=ar rc
|
|
diff --git a/src/haiku.cpp b/src/haiku.cpp
|
|
new file mode 100644
|
|
index 0000000..c54b321
|
|
--- /dev/null
|
|
+++ b/src/haiku.cpp
|
|
@@ -0,0 +1,128 @@
|
|
+#include <FilePanel.h>
|
|
+#include <FindDirectory.h>
|
|
+#include <Looper.h>
|
|
+#include <Path.h>
|
|
+#include <Messenger.h>
|
|
+#include <Window.h>
|
|
+#include <MenuItem.h>
|
|
+#include <MenuBar.h>
|
|
+#include <stdio.h>
|
|
+#include <compat/sys/stat.h>
|
|
+#include <string.h>
|
|
+
|
|
+extern "C" char *open_file_dialog(void);
|
|
+
|
|
+class FileFilter: public BRefFilter
|
|
+{
|
|
+ public:
|
|
+ bool Filter(const entry_ref *ref,
|
|
+ BNode *node,
|
|
+ struct stat_beos *stat,
|
|
+ const char *mimeType)
|
|
+ {
|
|
+ int len = strlen(ref->name);
|
|
+ if (S_ISDIR(stat->st_mode))
|
|
+ return true;
|
|
+ if (!strcmp(mimeType, "application/zip"))
|
|
+ return true;
|
|
+ if (!strcasecmp(ref->name, "main.lua") ||
|
|
+ !strcasecmp(ref->name, "main3.lua"))
|
|
+ return true;
|
|
+ if (len > 3 &&
|
|
+ (!strcasecmp(ref->name + len - 4, ".idf") ||
|
|
+ !strcasecmp(ref->name + len - 4, ".zip")))
|
|
+ return true;
|
|
+ return false;
|
|
+ }
|
|
+};
|
|
+
|
|
+class FileHandler: public BLooper
|
|
+{
|
|
+ public:
|
|
+
|
|
+ FileHandler()
|
|
+ : BLooper("filepanel listener")
|
|
+ {
|
|
+ lock = create_sem(0, "filepanel sem");
|
|
+ path = NULL;
|
|
+ Run();
|
|
+ }
|
|
+
|
|
+ ~FileHandler()
|
|
+ {
|
|
+ delete_sem(lock);
|
|
+ if (path != NULL)
|
|
+ free(path);
|
|
+ }
|
|
+ void MessageReceived(BMessage* message)
|
|
+ {
|
|
+ switch(message->what)
|
|
+ {
|
|
+ case B_REFS_RECEIVED:
|
|
+ {
|
|
+ entry_ref ref;
|
|
+
|
|
+ message->FindRef("refs", 0, &ref);
|
|
+ BEntry entry(&ref, true);
|
|
+ BPath xpath;
|
|
+ entry.GetPath(&xpath);
|
|
+ path = strdup(xpath.Path());
|
|
+ break;
|
|
+ }
|
|
+ case B_CANCEL:
|
|
+ break;
|
|
+ default:
|
|
+ BHandler::MessageReceived(message);
|
|
+ return;
|
|
+ }
|
|
+ release_sem(lock);
|
|
+ }
|
|
+
|
|
+ void Wait() {
|
|
+ acquire_sem(lock);
|
|
+ }
|
|
+
|
|
+ char* path;
|
|
+
|
|
+ private:
|
|
+ sem_id lock;
|
|
+};
|
|
+
|
|
+static char ret[PATH_MAX];
|
|
+
|
|
+char *open_file_dialog(void)
|
|
+{
|
|
+ FileHandler *handler = new FileHandler();
|
|
+ FileFilter filter;
|
|
+ BMessenger messenger(handler);
|
|
+ BFilePanel panel(B_OPEN_PANEL,
|
|
+ &messenger,
|
|
+ NULL,
|
|
+ B_FILE_NODE,
|
|
+ false,
|
|
+ NULL,
|
|
+ &filter,
|
|
+ true);
|
|
+ panel.Show();
|
|
+ handler->Wait();
|
|
+ if (handler->path == NULL) {
|
|
+ messenger.SendMessage(B_QUIT_REQUESTED);
|
|
+ return NULL;
|
|
+ }
|
|
+ snprintf(ret, sizeof(ret), "%s", handler->path);
|
|
+ ret[sizeof(ret) - 1] = 0;
|
|
+ messenger.SendMessage(B_QUIT_REQUESTED);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+extern "C" char *appdir(void);
|
|
+
|
|
+char *appdir(void)
|
|
+{
|
|
+ static char dir[PATH_MAX] = "";
|
|
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) != B_OK)
|
|
+ sprintf(dir, "/boot/home/config/settings");
|
|
+ strncat(dir, "/Instead", sizeof(dir));
|
|
+ dir[sizeof(dir) - 1] = 0;
|
|
+ return dir;
|
|
+}
|
|
diff --git a/src/unix.c b/src/unix.c
|
|
index 6dbda98..0b63327 100644
|
|
--- a/src/unix.c
|
|
+++ b/src/unix.c
|
|
@@ -104,6 +104,7 @@ GdkPixbuf *create_pixbuf(const gchar * filename)
|
|
|
|
extern char *BROWSE_MENU;
|
|
|
|
+#ifndef __HAIKU__
|
|
char *open_file_dialog(void)
|
|
{
|
|
#ifndef _USE_GTK
|
|
@@ -236,7 +237,6 @@ char *open_file_dialog(void)
|
|
return (file[0])?file:NULL;
|
|
#endif
|
|
}
|
|
-
|
|
char *appdir(void)
|
|
{
|
|
static char dir[PATH_MAX] = "";
|
|
@@ -257,7 +257,7 @@ char *appdir(void)
|
|
snprintf(dir, sizeof(dir) - 1 , "%s/.instead", pw->pw_dir);
|
|
return dir;
|
|
}
|
|
-
|
|
+#endif
|
|
char *game_local_games_path(int cr)
|
|
{
|
|
char *app = appdir();
|
|
--
|
|
2.37.3
|
|
|