Skip to content
Permalink
Browse files
themes: allow internal theme to use AttributeImage
  • Loading branch information
Tupakaveli committed Nov 8, 2019
1 parent b3123f6 commit 4661c0d5a2f3efda7220bbf169838db85f3b5d84
Showing with 32 additions and 11 deletions.
  1. +7 −3 src/texcache.c
  2. +25 −8 src/themes.c
@@ -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));
@@ -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;
}
}
}
}

0 comments on commit 4661c0d

Please sign in to comment.