diff --git a/src/Menus.c b/src/Menus.c index 983fdbe99..2436384f3 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -1492,16 +1492,11 @@ void SaveLevelScreen_Show(void) { *---------------------------------------------------TexturePackScreen-----------------------------------------------------* *#########################################################################################################################*/ static void TexturePackScreen_EntryClick(void* screen, void* widget) { - cc_string path; char pathBuffer[FILENAME_SIZE]; struct ListScreen* s = (struct ListScreen*)screen; - cc_string relPath; - - relPath = ListScreen_UNSAFE_GetCur(s, widget); - String_InitArray(path, pathBuffer); - String_Format1(&path, "texpacks/%s", &relPath); - if (!File_Exists(&path)) return; - - TexturePack_SetDefault(&relPath); + cc_string file = ListScreen_UNSAFE_GetCur(s, widget); + if (String_CaselessEqualsConst(&file, LISTSCREEN_EMPTY)) return; + + TexturePack_SetDefault(&file); TexturePack_Url.length = 0; TexturePack_ExtractCurrent(true); } diff --git a/src/TexturePack.c b/src/TexturePack.c index 03471ed64..c7309d5c2 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -337,17 +337,14 @@ static void ExtractFromFile(const cc_string* filename) { struct Stream stream; cc_result res; - /* TODO: This is an ugly hack to load textures from memory. */ - /* We need to mount /classicube to IndexedDB, but texpacks folder */ - /* should be read from memory. I don't know how to do that, */ - /* since mounting /classicube/texpacks to memory doesn't work.. */ -#ifdef CC_BUILD_WEB - extern int chdir(const char* path); - chdir("/"); -#endif - String_InitArray(path, pathBuffer); +#ifdef CC_BUILD_WEB + /* texpacks/default.zip must be read from memory */ + /* instead of the default filesystem */ + String_Format1(&path, "/texpacks/%s", filename); +#else String_Format1(&path, "texpacks/%s", filename); +#endif res = Stream_OpenFile(&stream, &path); if (res) { Logger_SysWarn2(res, "opening", &path); return; } @@ -355,10 +352,6 @@ static void ExtractFromFile(const cc_string* filename) { res = stream.Close(&stream); if (res) { Logger_SysWarn2(res, "closing", &path); } - -#ifdef CC_BUILD_WEB - Platform_SetDefaultCurrentDirectory(0, NULL); -#endif } static void ExtractDefault(void) {