mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Webclient: Read default texture pack in less hacky way
This commit is contained in:
parent
dbbf0cbc66
commit
bfd9c01e89
13
src/Menus.c
13
src/Menus.c
@ -1492,16 +1492,11 @@ void SaveLevelScreen_Show(void) {
|
|||||||
*---------------------------------------------------TexturePackScreen-----------------------------------------------------*
|
*---------------------------------------------------TexturePackScreen-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void TexturePackScreen_EntryClick(void* screen, void* widget) {
|
static void TexturePackScreen_EntryClick(void* screen, void* widget) {
|
||||||
cc_string path; char pathBuffer[FILENAME_SIZE];
|
|
||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
cc_string relPath;
|
cc_string file = ListScreen_UNSAFE_GetCur(s, widget);
|
||||||
|
if (String_CaselessEqualsConst(&file, LISTSCREEN_EMPTY)) return;
|
||||||
relPath = ListScreen_UNSAFE_GetCur(s, widget);
|
|
||||||
String_InitArray(path, pathBuffer);
|
TexturePack_SetDefault(&file);
|
||||||
String_Format1(&path, "texpacks/%s", &relPath);
|
|
||||||
if (!File_Exists(&path)) return;
|
|
||||||
|
|
||||||
TexturePack_SetDefault(&relPath);
|
|
||||||
TexturePack_Url.length = 0;
|
TexturePack_Url.length = 0;
|
||||||
TexturePack_ExtractCurrent(true);
|
TexturePack_ExtractCurrent(true);
|
||||||
}
|
}
|
||||||
|
@ -337,17 +337,14 @@ static void ExtractFromFile(const cc_string* filename) {
|
|||||||
struct Stream stream;
|
struct Stream stream;
|
||||||
cc_result res;
|
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);
|
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);
|
String_Format1(&path, "texpacks/%s", filename);
|
||||||
|
#endif
|
||||||
|
|
||||||
res = Stream_OpenFile(&stream, &path);
|
res = Stream_OpenFile(&stream, &path);
|
||||||
if (res) { Logger_SysWarn2(res, "opening", &path); return; }
|
if (res) { Logger_SysWarn2(res, "opening", &path); return; }
|
||||||
@ -355,10 +352,6 @@ static void ExtractFromFile(const cc_string* filename) {
|
|||||||
|
|
||||||
res = stream.Close(&stream);
|
res = stream.Close(&stream);
|
||||||
if (res) { Logger_SysWarn2(res, "closing", &path); }
|
if (res) { Logger_SysWarn2(res, "closing", &path); }
|
||||||
|
|
||||||
#ifdef CC_BUILD_WEB
|
|
||||||
Platform_SetDefaultCurrentDirectory(0, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ExtractDefault(void) {
|
static void ExtractDefault(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user