Skip to content

Commit

Permalink
themes: allow internal theme to use AttributeImage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tupakaveli committed Nov 8, 2019
1 parent b3123f6 commit 4661c0d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/texcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ image_cache_t *cacheInitCache(int userId, const char *prefix, int isPrefixRelati
image_cache_t *cache = (image_cache_t *)malloc(sizeof(image_cache_t));
cache->userId = userId;
cache->count = count;
int length = strlen(prefix) + 1;
cache->prefix = (char *)malloc(length * sizeof(char));
memcpy(cache->prefix, prefix, length);
cache->prefix = NULL;
int length;
if (prefix) {
length = strlen(prefix) + 1;
cache->prefix = (char *)malloc(length * sizeof(char));
memcpy(cache->prefix, prefix, length);
}
cache->isPrefixRelative = isPrefixRelative;
length = strlen(suffix) + 1;
cache->suffix = (char *)malloc(length * sizeof(char));
Expand Down
33 changes: 25 additions & 8 deletions src/themes.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,34 @@ static void drawAttributeImage(struct menu_list *menu, struct submenu_list *item
configGetStr(config, attributeImage->cache->suffix, (const char **)&attributeImage->currentValue);
}
if (attributeImage->currentValue) {
int posZ = 0;
GSTEXTURE *texture = cacheGetTexture(attributeImage->cache, menu->item->userdata, &posZ, &attributeImage->currentUid, attributeImage->currentValue);
if (texture && texture->Mem) {
if (attributeImage->overlayTexture) {
rmDrawOverlayPixmap(&attributeImage->overlayTexture->source, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, elem->scaled, gDefaultCol,
texture, attributeImage->overlayTexture->upperLeft_x, attributeImage->overlayTexture->upperLeft_y, attributeImage->overlayTexture->upperRight_x, attributeImage->overlayTexture->upperRight_y,
attributeImage->overlayTexture->lowerLeft_x, attributeImage->overlayTexture->lowerLeft_y, attributeImage->overlayTexture->lowerRight_x, attributeImage->overlayTexture->lowerRight_y);
} else
if (thmGetGuiValue() == 0) {
int texId;
char *seppos = strchr(attributeImage->currentValue, '/');
if (!seppos)
texId = texLookupInternalTexId(attributeImage->currentValue);
else {
char imgName[32];
snprintf(imgName, sizeof(imgName), "%s_%s", attributeImage->cache->suffix, &seppos[1]);
texId = texLookupInternalTexId(&imgName[0]);
}
GSTEXTURE *texture = thmGetTexture(texId);
if (texture && texture->Mem)
rmDrawPixmap(texture, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, elem->scaled, gDefaultCol);

return;
} else {
int posZ = 0;
GSTEXTURE *texture = cacheGetTexture(attributeImage->cache, menu->item->userdata, &posZ, &attributeImage->currentUid, attributeImage->currentValue);
if (texture && texture->Mem) {
if (attributeImage->overlayTexture) {
rmDrawOverlayPixmap(&attributeImage->overlayTexture->source, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, elem->scaled, gDefaultCol,
texture, attributeImage->overlayTexture->upperLeft_x, attributeImage->overlayTexture->upperLeft_y, attributeImage->overlayTexture->upperRight_x, attributeImage->overlayTexture->upperRight_y,
attributeImage->overlayTexture->lowerLeft_x, attributeImage->overlayTexture->lowerLeft_y, attributeImage->overlayTexture->lowerRight_x, attributeImage->overlayTexture->lowerRight_y);
} else
rmDrawPixmap(texture, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, elem->scaled, gDefaultCol);

return;
}
}
}
}
Expand Down

0 comments on commit 4661c0d

Please sign in to comment.