diff --git a/Makefile b/Makefile
index e4fc082..f32d1f2 100644
--- a/Makefile
+++ b/Makefile
@@ -257,11 +257,13 @@ SDL_NET = \
bin/SDLnetselect.o \
bin/net.o
+FILE_DIALOG = \
+ bin/file_dialog.o
+
TIC_O=\
bin/studio.o \
bin/console.o \
bin/run.o \
- bin/file_dialog.o \
bin/md5.o \
bin/gif.o \
bin/fs.o \
@@ -320,8 +322,8 @@ emscripten:
wasm:
$(EMS_CC) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(EMS_OPT) -s WASM=1 $(EMS_LINKER_FLAGS) -o build/html/tic.js
-mingw: $(STUDIO_DLL) $(SDL_NET) bin/main.o bin/res.o
- $(CC) bin/main.o bin/res.o $(STUDIO_A) $(SDL_NET) $(OPT) $(INCLUDES) $(MINGW_LINKER_FLAGS) -o $(MINGW_OUTPUT)
+mingw: $(STUDIO_DLL) $(SDL_NET) $(FILE_DIALOG) bin/main.o bin/res.o
+ $(CC) bin/main.o bin/res.o $(STUDIO_A) $(SDL_NET) $(FILE_DIALOG) $(OPT) $(INCLUDES) $(MINGW_LINKER_FLAGS) -o $(MINGW_OUTPUT)
mingw-pro:
$(eval OPT += $(OPT_PRO))
diff --git a/build/windows/studio/studio.vcxproj b/build/windows/studio/studio.vcxproj
index d9155e4..09ecb3a 100644
--- a/build/windows/studio/studio.vcxproj
+++ b/build/windows/studio/studio.vcxproj
@@ -280,7 +280,6 @@
-
diff --git a/build/windows/studio/studio.vcxproj.filters b/build/windows/studio/studio.vcxproj.filters
index 0c852f2..d573ef5 100644
--- a/build/windows/studio/studio.vcxproj.filters
+++ b/build/windows/studio/studio.vcxproj.filters
@@ -63,9 +63,6 @@
src
-
- src\ext
-
src\ext
diff --git a/build/windows/tic/tic.vcxproj b/build/windows/tic/tic.vcxproj
index 8dba28a..42de149 100644
--- a/build/windows/tic/tic.vcxproj
+++ b/build/windows/tic/tic.vcxproj
@@ -52,6 +52,7 @@
+
diff --git a/build/windows/tic/tic.vcxproj.filters b/build/windows/tic/tic.vcxproj.filters
index 2f23a40..32519de 100644
--- a/build/windows/tic/tic.vcxproj.filters
+++ b/build/windows/tic/tic.vcxproj.filters
@@ -30,6 +30,9 @@
src
+
+ src\ext
+
diff --git a/src/ext/file_dialog.c b/src/ext/file_dialog.c
index 222db17..6c98d50 100644
--- a/src/ext/file_dialog.c
+++ b/src/ext/file_dialog.c
@@ -24,7 +24,7 @@
#include
-#if defined(__TIC_WINDOWS__)
+#if defined(__WINDOWS__)
#include
#include
@@ -104,7 +104,7 @@ void file_dialog_save(file_dialog_save_callback callback, const char* name, cons
fwrite(buffer, 1, size, file);
fclose(file);
-#if !defined(__TIC_WINDOWS__)
+#if !defined(__WINDOWS__)
chmod(filename, mode);
#endif
callback(true, data);
@@ -115,40 +115,6 @@ void file_dialog_save(file_dialog_save_callback callback, const char* name, cons
callback(false, data);
}
-#include
-
-const char* folder_dialog(void* data)
-{
-
- BROWSEINFOW bi = { 0 };
- bi.lpszTitle = L"Browse for folder...";
- bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
- bi.lParam = (LPARAM) NULL;
-
- LPITEMIDLIST pidl = SHBrowseForFolderW ( &bi );
-
- if ( pidl != 0 )
- {
- wchar_t path[MAX_PATH];
- SHGetPathFromIDListW (pidl, path);
-
- LPMALLOC imalloc = NULL;
- if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
- {
- imalloc->lpVtbl->Free (imalloc, pidl );
- imalloc->lpVtbl->Release (imalloc);
- }
-
- {
- static char result[MAX_PATH];
- strcpy(result, StringToUTF8(path));
- return result;
- }
- }
-
- return NULL;
-}
-
#elif defined(__EMSCRIPTEN__)
#include
diff --git a/src/ext/file_dialog.h b/src/ext/file_dialog.h
index 7a28c77..b64c84f 100644
--- a/src/ext/file_dialog.h
+++ b/src/ext/file_dialog.h
@@ -34,7 +34,6 @@ typedef void(*file_dialog_save_callback)(bool result, void* data);
void file_dialog_load(file_dialog_load_callback callback, void* data);
void file_dialog_save(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);
-const char* folder_dialog(void* data);
#ifdef __cplusplus
}
diff --git a/src/fs.c b/src/fs.c
index 6c16b0a..c9c43aa 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -300,7 +300,7 @@ void fsAddFile(FileSystem* fs, AddCallback callback, void* data)
*addFileData = (AddFileData) { fs, callback, data };
- file_dialog_load(&onAddFile, addFileData);
+ _file_dialog_load(&onAddFile, addFileData);
}
typedef struct
@@ -432,7 +432,7 @@ void fsGetFileData(GetCallback callback, const char* name, void* buffer, size_t
GetFileData* command = (GetFileData*)malloc(sizeof(GetFileData));
*command = (GetFileData) {callback, data, buffer};
- file_dialog_save(onGetFile, name, buffer, size, command, mode);
+ _file_dialog_save(onGetFile, name, buffer, size, command, mode);
}
typedef struct
@@ -456,7 +456,7 @@ void fsOpenFileData(OpenCallback callback, void* data)
*command = (OpenFileData){callback, data};
- file_dialog_load(onOpenFileData, command);
+ _file_dialog_load(onOpenFileData, command);
}
void fsGetFile(FileSystem* fs, GetCallback callback, const char* name, void* data)
@@ -470,7 +470,7 @@ void fsGetFile(FileSystem* fs, GetCallback callback, const char* name, void* dat
*command = (GetFileData) {callback, data, buffer};
s32 mode = fsGetMode(fs, name);
- file_dialog_save(onGetFile, name, buffer, size, command, mode);
+ _file_dialog_save(onGetFile, name, buffer, size, command, mode);
}
else callback(FS_FILE_NOT_DOWNLOADED, data);
}
diff --git a/src/main.c b/src/main.c
index 342ac46..59b0b87 100644
--- a/src/main.c
+++ b/src/main.c
@@ -904,6 +904,9 @@ static System sysHandlers =
.netGetRequest = netGetRequest,
.createNet = createNet,
.closeNet = closeNet,
+
+ .file_dialog_load = file_dialog_load,
+ .file_dialog_save = file_dialog_save,
};
s32 main(s32 argc, char **argv)
diff --git a/src/studio.c b/src/studio.c
index 7c227b3..6cc0a27 100644
--- a/src/studio.c
+++ b/src/studio.c
@@ -3128,4 +3128,14 @@ Net* _createNet()
void _closeNet(Net* net)
{
return studioImpl.system->closeNet(net);
-}
\ No newline at end of file
+}
+
+void _file_dialog_load(file_dialog_load_callback callback, void* data)
+{
+ studioImpl.system->file_dialog_load(callback, data);
+}
+
+void _file_dialog_save(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode)
+{
+ studioImpl.system->file_dialog_save(callback, name, buffer, size, data, mode);
+}
diff --git a/src/studio.h b/src/studio.h
index 01f2e07..23210db 100644
--- a/src/studio.h
+++ b/src/studio.h
@@ -38,6 +38,7 @@
#include "defines.h"
#include "tools.h"
#include "net.h"
+#include "ext/file_dialog.h"
#define TIC_LOCAL ".local/"
#define TIC_CACHE TIC_LOCAL "cache/"
@@ -232,6 +233,9 @@ typedef struct
Net* (*createNet)();
void (*closeNet)(Net* net);
+ void (*file_dialog_load)(file_dialog_load_callback callback, void* data);
+ void (*file_dialog_save)(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);
+
} System;
TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system);
@@ -254,3 +258,6 @@ void _netDirRequest(Net* net, const char* path, ListCallback callback, void* dat
void* _netGetRequest(Net* net, const char* path, s32* size);
Net* _createNet();
void _closeNet(Net* net);
+
+void _file_dialog_load(file_dialog_load_callback callback, void* data);
+void _file_dialog_save(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);