Skip to content

Commit

Permalink
themes: allow internal theme to use overlays and multiple default tex…
Browse files Browse the repository at this point in the history
…tures
  • Loading branch information
Tupakaveli committed Nov 8, 2019
1 parent 7c2c5f6 commit b3123f6
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/themes.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,21 @@ static image_texture_t *initImageTexture(const char *themePath, config_set_t *th
texPrepare(&texture->source, psm);
texture->name = NULL;

char path[256];
snprintf(path, sizeof(path), "%s%s", themePath, imgName);
if (texDiscoverLoad(&texture->source, path, -1, psm) >= 0) {
int texId = -1;
int result = 0;

if (themePath) {
char path[256];
snprintf(path, sizeof(path), "%s%s", themePath, imgName);
if (texDiscoverLoad(&texture->source, path, texId, psm) >= 0);
result = 1;
} else {
texId = texLookupInternalTexId(imgName);
if (texDiscoverLoad(&texture->source, NULL, texId, psm) >= 0);
result = 1;
}

if (result) {
int length = strlen(imgName) + 1;
texture->name = (char *)malloc(length * sizeof(char));
memcpy(texture->name, imgName, length);
Expand Down Expand Up @@ -347,6 +359,9 @@ static image_texture_t *initImageInternalTexture(config_set_t *themeConfig, cons

if ((result = texLookupInternalTexId(name)) >= 0) {
result = texDiscoverLoad(&texture->source, NULL, result, GS_PSM_CT24);
int length = strlen(name) + 1;
texture->name = (char *)malloc(length * sizeof(char));
memcpy(texture->name, name, length);
}

if (result < 0) {
Expand Down Expand Up @@ -395,7 +410,7 @@ static mutable_image_t *initMutableImage(const char *themePath, config_set_t *th
snprintf(elemProp, sizeof(elemProp), "%s_attribute", name);
configGetStr(themeConfig, elemProp, &cachePattern);
LOG("THEMES MutableImage %s: type: %s using cache pattern: %s\n", name, elementsType[type], cachePattern);
} else if ((type == ELEM_TYPE_GAME_IMAGE) || type == (ELEM_TYPE_BACKGROUND)) {
} else if ((type == ELEM_TYPE_GAME_IMAGE) || (type == ELEM_TYPE_BACKGROUND)) {
snprintf(elemProp, sizeof(elemProp), "%s_pattern", name);
configGetStr(themeConfig, elemProp, &cachePattern);
snprintf(elemProp, sizeof(elemProp), "%s_count", name);
Expand All @@ -421,22 +436,15 @@ static mutable_image_t *initMutableImage(const char *themePath, config_set_t *th
mutableImage->cache = cacheInitCache(theme->gameCacheCount++, "ART", 1, cachePattern, cacheCount);
}

if (themePath != NULL) {
if (!themePath)
if (defaultTexture && !mutableImage->defaultTexture)
mutableImage->defaultTexture = initImageTexture(themePath, themeConfig, name, defaultTexture, 0);

if (overlayTexture && !mutableImage->overlayTexture)
mutableImage->overlayTexture = initImageTexture(themePath, themeConfig, name, overlayTexture, 1);
}
mutableImage->defaultTexture = initImageInternalTexture(themeConfig, defaultTexture);

if (defaultTexture && !mutableImage->defaultTexture)
mutableImage->defaultTexture = initImageInternalTexture(themeConfig, defaultTexture);
mutableImage->defaultTexture = initImageTexture(themePath, themeConfig, name, defaultTexture, 0);

if (overlayTexture && !mutableImage->overlayTexture)
mutableImage->overlayTexture = initImageInternalTexture(themeConfig, overlayTexture);

if (!mutableImage->defaultTexture && !mutableImage->overlayTexture)
mutableImage->defaultTexture = initImageInternalTexture(themeConfig, name);
mutableImage->overlayTexture = initImageTexture(themePath, themeConfig, name, overlayTexture, 1);

return mutableImage;
}
Expand Down

0 comments on commit b3123f6

Please sign in to comment.