MCPcopy Create free account
hub / github.com/devkitPro/3ds-hbmenu / menuEntryLoadExternalIcon

Function menuEntryLoadExternalIcon

source/menu-entry.c:25–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25bool menuEntryLoadExternalIcon(menuEntry_s* me, const char* filepath) {
26 FILE* iconFile = fopen(filepath, "rb");
27
28 if (!iconFile)
29 return false;
30
31 if (!me->icon)
32 me->icon = &me->texture;
33
34 Tex3DS_Texture texture = Tex3DS_TextureImportStdio(iconFile, me->icon, NULL, false);
35 fclose(iconFile);
36
37 if (!texture)
38 return false;
39
40 const Tex3DS_SubTexture* subTexture = Tex3DS_GetSubTexture(texture, 0);
41
42 if (subTexture->width != 64 && subTexture->height != 64) {
43 C3D_TexDelete(me->icon);
44 me->icon = NULL;
45 Tex3DS_TextureFree(texture);
46
47 return false;
48 }
49
50 // Delete the t3x object since we don't need it
51 Tex3DS_TextureFree(texture);
52
53 return true;
54}
55
56bool menuEntryImportIcon(menuEntry_s* me, C3D_Tex* texture)
57{

Callers 2

menuEntryFileAssocLoadFunction · 0.85
menuEntryLoadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected