mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 10:31:16 +00:00
Allow Web port to be playable in Firefox Private (#513)
This commit is contained in:
parent
c63d725b64
commit
f1b22ee025
@ -139,3 +139,21 @@ index e8c9f7e21..caf1971d2 100644
|
||||
},
|
||||
-
|
||||
});
|
||||
diff --git a/src/preamble.js b/src/preamble.js
|
||||
index 572694517..0d2f4421b 100644
|
||||
--- a/src/preamble.js
|
||||
+++ b/src/preamble.js
|
||||
@@ -1062,3 +1062,13 @@ function getCompilerSetting(name) {
|
||||
// dynamic linker as symbols are loaded.
|
||||
var asyncifyStubs = {};
|
||||
#endif
|
||||
+
|
||||
+(async () => {
|
||||
+ try {
|
||||
+ await navigator.storage.getDirectory();
|
||||
+ Module["disableOpfs"] = false;
|
||||
+ } catch (e) {
|
||||
+ Module["disableOpfs"] = true;
|
||||
+ }
|
||||
+})();
|
||||
+
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include <SDL3/SDL_filesystem.h>
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/wasmfs.h>
|
||||
|
||||
static backend_t opfs = nullptr;
|
||||
@ -13,10 +14,16 @@ static backend_t fetchfs = nullptr;
|
||||
|
||||
extern const char* g_files[46];
|
||||
|
||||
void Emscripten_SetupConfig(const char* p_iniConfig)
|
||||
bool Emscripten_OPFSDisabled()
|
||||
{
|
||||
if (!p_iniConfig || !*p_iniConfig) {
|
||||
return;
|
||||
return MAIN_THREAD_EM_ASM_INT({return !!Module["disableOpfs"]});
|
||||
}
|
||||
|
||||
bool Emscripten_SetupConfig(const char* p_iniConfig)
|
||||
{
|
||||
if (Emscripten_OPFSDisabled()) {
|
||||
SDL_Log("OPFS is disabled; ignoring .ini path");
|
||||
return false;
|
||||
}
|
||||
|
||||
opfs = wasmfs_create_opfs_backend();
|
||||
@ -28,6 +35,8 @@ void Emscripten_SetupConfig(const char* p_iniConfig)
|
||||
wasmfs_create_directory(iniConfig.GetData(), 0644, opfs);
|
||||
*parse = '/';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Emscripten_SetupFilesystem()
|
||||
@ -66,7 +75,7 @@ void Emscripten_SetupFilesystem()
|
||||
registerFile(file);
|
||||
}
|
||||
|
||||
if (GameState()->GetSavePath() && *GameState()->GetSavePath()) {
|
||||
if (GameState()->GetSavePath() && *GameState()->GetSavePath() && !Emscripten_OPFSDisabled()) {
|
||||
if (!opfs) {
|
||||
opfs = wasmfs_create_opfs_backend();
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ inline static const char* Emscripten_savePath = "/save";
|
||||
inline static const char* Emscripten_streamPath = "/";
|
||||
inline static const char* Emscripten_streamHost = ISLE_EMSCRIPTEN_HOST;
|
||||
|
||||
void Emscripten_SetupConfig(const char* p_iniConfig);
|
||||
bool Emscripten_SetupConfig(const char* p_iniConfig);
|
||||
void Emscripten_SetupFilesystem();
|
||||
|
||||
#endif // EMSCRIPTEN_FILESYSTEM_H
|
||||
|
||||
@ -778,6 +778,13 @@ bool IsleApp::LoadConfig()
|
||||
{
|
||||
char* prefPath = SDL_GetPrefPath("isledecomp", "isle");
|
||||
char* iniConfig;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (m_iniPath && !Emscripten_SetupConfig(m_iniPath)) {
|
||||
m_iniPath = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_iniPath) {
|
||||
iniConfig = new char[strlen(m_iniPath) + 1];
|
||||
strcpy(iniConfig, m_iniPath);
|
||||
@ -793,10 +800,6 @@ bool IsleApp::LoadConfig()
|
||||
}
|
||||
SDL_Log("Reading configuration from \"%s\"", iniConfig);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
Emscripten_SetupConfig(iniConfig);
|
||||
#endif
|
||||
|
||||
dictionary* dict = iniparser_load(iniConfig);
|
||||
|
||||
// [library:config]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user