Android: Also download and extract touch.png

Implementation is still a bit hacky and needs to be redone though
This commit is contained in:
UnknownShadow200 2020-10-27 23:20:12 +11:00
parent 5a850f55d0
commit a99e3d8121
2 changed files with 41 additions and 12 deletions

View File

@ -16,11 +16,6 @@
/*########################################################################################################################* /*########################################################################################################################*
*--------------------------------------------------------Resources list---------------------------------------------------* *--------------------------------------------------------Resources list---------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
#define FLAG_CLASSIC 0x01 /* file depends on classic.jar */
#define FLAG_MODERN 0x02 /* file depends on modern jar */
#define FLAG_GUI 0x04 /* file depends on patched gui.png */
#define FLAG_TERRAIN 0x08 /* file depends on patched terrain.png */
static struct FileResource { static struct FileResource {
const char* name; const char* name;
const char* url; const char* url;
@ -33,14 +28,18 @@ static struct FileResource {
{ "classic jar", "http://launcher.mojang.com/mc/game/c0.30_01c/client/54622801f5ef1bcc1549a842c5b04cb5d5583005/client.jar", 291 }, { "classic jar", "http://launcher.mojang.com/mc/game/c0.30_01c/client/54622801f5ef1bcc1549a842c5b04cb5d5583005/client.jar", 291 },
{ "1.6.2 jar", "http://launcher.mojang.com/mc/game/1.6.2/client/b6cb68afde1d9cf4a20cbf27fa90d0828bf440a4/client.jar", 4621 }, { "1.6.2 jar", "http://launcher.mojang.com/mc/game/1.6.2/client/b6cb68afde1d9cf4a20cbf27fa90d0828bf440a4/client.jar", 4621 },
{ "terrain.png patch", "http://static.classicube.net/terrain-patch2.png", 7 }, { "terrain.png patch", "http://static.classicube.net/terrain-patch2.png", 7 },
#ifdef CC_BUILD_ANDROID
{ "new textures", "http://static.classicube.net/default.zip", 87 }
#else
{ "gui.png patch", "http://static.classicube.net/gui.png", 21 } { "gui.png patch", "http://static.classicube.net/gui.png", 21 }
#endif
}; };
static struct ResourceTexture { static struct ResourceTexture {
const char* filename; const char* filename;
/* zip data */ /* zip data */
cc_uint32 size, offset, crc32; cc_uint32 size, offset, crc32;
} textureResources[20] = { } textureResources[] = {
/* classic jar files */ /* classic jar files */
{ "char.png" }, { "clouds.png" }, { "default.png" }, { "particles.png" }, { "char.png" }, { "clouds.png" }, { "default.png" }, { "particles.png" },
{ "rain.png" }, { "gui_classic.png" }, { "icons.png" }, { "terrain.png" }, { "rain.png" }, { "gui_classic.png" }, { "icons.png" }, { "terrain.png" },
@ -48,7 +47,10 @@ static struct ResourceTexture {
{ "skeleton.png" }, { "spider.png" }, { "zombie.png" }, /* "arrows.png", "sign.png" */ { "skeleton.png" }, { "spider.png" }, { "zombie.png" }, /* "arrows.png", "sign.png" */
/* other files */ /* other files */
{ "snow.png" }, { "chicken.png" }, { "gui.png" }, { "snow.png" }, { "chicken.png" }, { "gui.png" },
{ "animations.png" }, { "animations.txt" } { "animations.png" }, { "animations.txt" },
#ifdef CC_BUILD_ANDROID
{ "touch.png" }
#endif
}; };
static struct SoundResource { static struct SoundResource {
@ -520,6 +522,37 @@ static cc_result ModernPatcher_ExtractFiles(struct Stream* s) {
return Zip_Extract(&zip); return Zip_Extract(&zip);
} }
#ifdef CC_BUILD_ANDROID
/* Android has both a gui.png and a touch.png */
/* TODO: Unify both android and desktop platforms to both just extract from default.zip */
static cc_bool TexPatcher_SelectEntry(const cc_string* path) {
return String_CaselessEqualsConst(path, "gui.png") || String_CaselessEqualsConst(path, "touch.png");
}
static cc_result TexPatcher_ProcessEntry(const cc_string* path, struct Stream* data, struct ZipState* state) {
struct ResourceTexture* entry = Resources_FindTex(path);
return ZipPatcher_WriteZipEntry(data, entry, state);
}
static cc_result TexPactcher_ExtractGui(struct Stream* s) {
struct ZipState zip;
struct Stream src;
Stream_ReadonlyMemory(&src, fileResources[3].data, fileResources[3].len);
Zip_Init(&zip, &src);
zip.obj = s;
zip.SelectEntry = TexPatcher_SelectEntry;
zip.ProcessEntry = TexPatcher_ProcessEntry;
return Zip_Extract(&zip);
}
#else
static cc_result TexPactcher_ExtractGui(struct Stream* s) {
static const cc_string guiPng = String_FromConst("gui.png");
struct ResourceTexture* entry = Resources_FindTex(&guiPng);
return ZipPatcher_WriteData(s, entry, fileResources[3].data, fileResources[3].len);
}
#endif
static cc_result TexPatcher_NewFiles(struct Stream* s) { static cc_result TexPatcher_NewFiles(struct Stream* s) {
static const cc_string guiPng = String_FromConst("gui.png"); static const cc_string guiPng = String_FromConst("gui.png");
static const cc_string animsTxt = String_FromConst("animations.txt"); static const cc_string animsTxt = String_FromConst("animations.txt");
@ -532,10 +565,7 @@ static cc_result TexPatcher_NewFiles(struct Stream* s) {
if (res) return res; if (res) return res;
/* make ClassiCube gui.png */ /* make ClassiCube gui.png */
entry = Resources_FindTex(&guiPng); return TexPactcher_ExtractGui(s);
res = ZipPatcher_WriteData(s, entry, fileResources[3].data, fileResources[3].len);
return res;
} }
static void TexPatcher_PatchTile(struct Bitmap* src, int srcX, int srcY, int dstX, int dstY) { static void TexPatcher_PatchTile(struct Bitmap* src, int srcX, int srcY, int dstX, int dstY) {

View File

@ -2535,7 +2535,6 @@ static void ThumbstickWidget_BuildGroup(void* widget, struct Texture* tex, struc
tmp = tex->uv.V1; tex->uv.V1 = tex->uv.V2; tex->uv.V2 = tmp; tmp = tex->uv.V1; tex->uv.V1 = tex->uv.V2; tex->uv.V2 = tmp;
Gfx_Make2DQuad(tex, PACKEDCOL_WHITE, vertices); Gfx_Make2DQuad(tex, PACKEDCOL_WHITE, vertices);
/* TODO: The two X sides */
Gfx_Make2DQuad(tex, PACKEDCOL_WHITE, vertices); Gfx_Make2DQuad(tex, PACKEDCOL_WHITE, vertices);
ThumbstickWidget_Rotate(widget, vertices, w->width); ThumbstickWidget_Rotate(widget, vertices, w->width);