diff --git a/ISLE/emscripten/filesystem.cpp b/ISLE/emscripten/filesystem.cpp index 50cd9012..1c21cb03 100644 --- a/ISLE/emscripten/filesystem.cpp +++ b/ISLE/emscripten/filesystem.cpp @@ -1,5 +1,6 @@ #include "filesystem.h" +#include "extensions/textureloader.h" #include "legogamestate.h" #include "misc.h" #include "mxomni.h" @@ -13,6 +14,7 @@ static backend_t opfs = nullptr; static backend_t fetchfs = nullptr; extern const char* g_files[46]; +extern const char* g_textures[120]; bool Emscripten_OPFSDisabled() { @@ -41,7 +43,7 @@ bool Emscripten_SetupConfig(const char* p_iniConfig) void Emscripten_SetupFilesystem() { - fetchfs = wasmfs_create_fetch_backend((MxString(Emscripten_streamHost) + MxString("/LEGO")).GetData(), 512 * 1024); + fetchfs = wasmfs_create_fetch_backend((MxString(Emscripten_streamHost) + "/LEGO").GetData(), 512 * 1024); wasmfs_create_directory("/LEGO", 0644, fetchfs); wasmfs_create_directory("/LEGO/Scripts", 0644, fetchfs); @@ -75,6 +77,20 @@ void Emscripten_SetupFilesystem() registerFile(file); } +#ifdef EXTENSIONS + if (Extensions::TextureLoader::enabled) { + MxString directory = + MxString("/LEGO") + Extensions::TextureLoader::options["texture loader:texture path"].c_str(); + Extensions::TextureLoader::options["texture loader:texture path"] = directory.GetData(); + wasmfs_create_directory(directory.GetData(), 0644, fetchfs); + + for (const char* file : g_textures) { + MxString path = directory + "/" + file + ".bmp"; + registerFile(path.GetData()); + } + } +#endif + if (GameState()->GetSavePath() && *GameState()->GetSavePath() && !Emscripten_OPFSDisabled()) { if (!opfs) { opfs = wasmfs_create_opfs_backend(); diff --git a/ISLE/islefiles.cpp b/ISLE/islefiles.cpp index 6e0bb482..c6f4566d 100644 --- a/ISLE/islefiles.cpp +++ b/ISLE/islefiles.cpp @@ -46,3 +46,24 @@ const char* g_files[46] = { "/LEGO/data/WORLD.WDB", "/LEGO/data/testinf.dta", }; + +const char* g_textures[120] = { + "bank01.gif", "beach.gif", "black.gif", "bowtie.gif", "brela_01.gif", "bth1chst.gif", "bth2chst.gif", + "capch.gif", "capdb.gif", "capjs.gif", "capmd.gif", "caprc.gif", "cave_24x.gif", "caverocx.gif", + "caverokx.gif", "cheker01.gif", "construct.gif", "copchest.gif", "dbfrfn.gif", "doctor.gif", "dogface.gif", + "dummy.gif", "e.gif", "flowers.gif", "fruit.gif", "gasroad.gif", "gdface.gif", "g.gif", + "grassx.gif", "infochst.gif", "infoface.gif", "jailpad.gif", "jfrnt.gif", "jsfrnt4.gif", "jsfrnt.gif", + "jside.gif", "jswnsh5.gif", "jswnsh.gif", "l6.gif", "l.gif", "mamachst.gif", "mamaface.gif", + "mamamap.gif", "mech.gif", "medic01.gif", "mitesx.gif", "mustache.gif", "nickchst.gif", "nickface.gif", + "nickmap.gif", "nopizza.gif", "norachst.gif", "noraface.gif", "noramap.gif", "nwcurve.gif", "octan01.gif", + "octsq01.gif", "o.gif", "papachst.gif", "papaface.gif", "papamap.gif", "pebblesx.gif", "pepperha.gif", + "peppizza.gif", "peppmap.gif", "peprchst.gif", "peprface.gif", "pianokys.gif", "pizcurve.gif", "pizza01.gif", + "pizza.gif", "polbar01.gif", "polbla01.gif", "polkadot.gif", "polwhi01.gif", "postchst.gif", "post.gif", + "rac1chst.gif", "rac2chst.gif", "radar.gif", "raddis01.gif", "rcback.gif", "rc-butn.gif", "rcfrnt5.gif", + "rcfrnt6.gif", "rcfrnt7.gif", "rcfrnt.gif", "rcside1.gif", "rcside2.gif", "rcside3.gif", "rctail.gif", + "redskul.gif", "relrel01.gif", "road1way.gif", "road3wa2.gif", "road3wa3.gif", "road3way.gif", "road4way.gif", + "roadstr8.gif", "rockx.gif", "roofpiz.gif", "sandredx.gif", "se_curve.gif", "shftchst.gif", "shftface2.gif", + "shftface.gif", "shldwn02.gif", "skull.gif", "smile.gif", "smileshd.gif", "supr2_01.gif", "tightcrv.gif", + "unkchst.gif", "val_02.gif", "vest.gif", "water2x.gif", "w_curve.gif", "wnbars.gif", "woman.gif", + "womanshd.gif" +}; diff --git a/extensions/include/extensions/textureloader.h b/extensions/include/extensions/textureloader.h index c476c7ff..38cfc639 100644 --- a/extensions/include/extensions/textureloader.h +++ b/extensions/include/extensions/textureloader.h @@ -17,7 +17,7 @@ public: static bool enabled; static constexpr std::array, 1> defaults = { - {{"texture loader:texture path", "/textures/"}} + {{"texture loader:texture path", "/textures"}} }; private: diff --git a/extensions/src/textureloader.cpp b/extensions/src/textureloader.cpp index 07b53253..1c6ed9b3 100644 --- a/extensions/src/textureloader.cpp +++ b/extensions/src/textureloader.cpp @@ -99,11 +99,11 @@ SDL_Surface* TextureLoader::FindTexture(const char* p_name) { SDL_Surface* surface; const char* texturePath = options["texture loader:texture path"].c_str(); - MxString path = MxString(MxOmni::GetHD()) + texturePath + p_name + ".bmp"; + MxString path = MxString(MxOmni::GetHD()) + texturePath + "/" + p_name + ".bmp"; path.MapPathToFilesystem(); if (!(surface = SDL_LoadBMP(path.GetData()))) { - path = MxString(MxOmni::GetCD()) + texturePath + p_name + ".bmp"; + path = MxString(MxOmni::GetCD()) + texturePath + "/" + p_name + ".bmp"; path.MapPathToFilesystem(); surface = SDL_LoadBMP(path.GetData()); }