Skip to content

Commit

Permalink
themes: translate info page attribute text keys
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito authored and Tupakaveli committed Jan 22, 2020
1 parent 7431497 commit ddb0d97
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 54 deletions.
7 changes: 6 additions & 1 deletion include/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ enum _STR_IDS {
_STR_USE_GENERIC,
_STR_VMC_SCREEN,
_STR_VMC_NAME,
_STR_VMC_SIZE,
_STR_SIZE,
_STR_VMC_STATUS,
_STR_VMC_PROGRESS,
_STR_VMC_FILE_EXISTS,
Expand Down Expand Up @@ -279,6 +279,11 @@ enum _STR_IDS {
_STR_ALL_SETTINGS,
_STR_GAME_SETTINGS_PROMPT,
_STR_FORUM_DETAILS,
_STR_INFO_TITLE,
_STR_INFO_GENRE,
_STR_INFO_RELEASE,
_STR_INFO_DEVELOPER,
_STR_INFO_DESCRIPTION,

LANG_STR_COUNT
};
Expand Down
5 changes: 5 additions & 0 deletions lng/lang_English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,8 @@ Per Game
All
Select settings to remove.
Support Forums:
Title
Genre
Release
Developer
Description
38 changes: 13 additions & 25 deletions misc/conf_theme_OPL.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,79 +96,67 @@ info6:
x=33
y=98
info7:
type=StaticText
value=Description:
aligned=0
x=33
y=117
info8:
type=AttributeText
attribute=Description
display=2
display=0
aligned=0
x=33
y=136
y=117
width=574
height=64
wrap=1
info9:
info8:
type=AttributeImage
attribute=#Media
x=55
y=-242
info10:
info9:
type=AttributeImage
attribute=#Format
x=116
y=-242
info11:
info10:
type=AttributeImage
attribute=Vmode
x=177
y=-242
info12:
info11:
type=AttributeImage
attribute=Aspect
x=238
y=-242
info13:
info12:
type=AttributeImage
attribute=Scan
x=299
y=-242
info14:
info13:
type=AttributeImage
attribute=Rating
default=Rating_0
x=-74
y=-242
info15:
type=StaticText
value=Device
x=-74
y=31
info16:
info14:
type=AttributeImage
attribute=Device
x=-74
y=61
info17:
info15:
type=GameImage
pattern=SCR
default=screen
x=184
y=-133
width=173
height=148
info18:
info16:
type=GameImage
pattern=SCR2
default=screen
x=-186
y=-133
width=173
height=148
info19:
info17:
type=InfoHintText
aligned=1

aligned=1
2 changes: 1 addition & 1 deletion src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ struct UIItem diaVMC[] = {
{UI_STRING, VMC_NAME, 1, 1, -1, 0, 0, {.stringvalue = {"", "", &guiGameVmcNameHandler}}},
{UI_BREAK},

{UI_LABEL, 0, 1, 1, -1, -20, 0, {.label = {NULL, _STR_VMC_SIZE}}},
{UI_LABEL, 0, 1, 1, -1, -20, 0, {.label = {NULL, _STR_SIZE}}},
{UI_SPACER},
{UI_ENUM, VMC_SIZE, 1, 1, _STR_HINT_VMC_SIZE, 0, 0, {.intvalue = {0, 0}}},
{UI_BREAK},
Expand Down
2 changes: 1 addition & 1 deletion src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ int guiConfirmVideoMode(void)
int guiGameShowRemoveSettings(config_set_t *configSet, config_set_t *configGame)
{
int terminate = 0;
char message[128];
char message[256];

sfxPlay(SFX_MESSAGE);

Expand Down
5 changes: 5 additions & 0 deletions src/lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ static char *internalEnglish[LANG_STR_COUNT] = {
"All",
"Select settings to remove.",
"Support Forums:",
"Title",
"Genre",
"Release",
"Developer",
"Description",
};

static int guiLangID = 0;
Expand Down
70 changes: 44 additions & 26 deletions src/themes.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ static void initStaticText(const char *themePath, config_set_t *themeConfig, the

static void drawAttributeText(struct menu_list *menu, struct submenu_list *item, config_set_t *config, struct theme_element *elem)
{
char result[300];
mutable_text_t *mutableText = (mutable_text_t *)elem->extended;

if (config) {
if (mutableText->currentConfigId != config->uid) {
// force refresh
Expand All @@ -192,39 +194,55 @@ static void drawAttributeText(struct menu_list *menu, struct submenu_list *item,
}
}
if (mutableText->currentValue) {
char result[300];
if (mutableText->displayMode == DISPLAY_NEVER) {
if (!strcmp(mutableText->alias, "Size: ")) {
if (!strncmp(mutableText->alias, "Size", 4))
snprintf(result, sizeof(result), "%s MiB", mutableText->currentValue);
if (mutableText->sizingMode == SIZING_NONE)
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, 0, 0, result, elem->color);
else
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, result, elem->color);
} else {
if (mutableText->sizingMode == SIZING_NONE)
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, 0, 0, mutableText->currentValue, elem->color);
else
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, mutableText->currentValue, elem->color);
}
} else {
if (!strcmp(mutableText->alias, "Size: "))
snprintf(result, sizeof(result), "%s%s MiB", mutableText->alias, mutableText->currentValue);
else
snprintf(result, sizeof(result), "%s%s", mutableText->alias, mutableText->currentValue);
if (mutableText->sizingMode == SIZING_NONE)
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, 0, 0, result, elem->color);
else
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, result, elem->color);
snprintf(result, sizeof(result), mutableText->currentValue);

goto render;
}
return;
}
}
if (mutableText->displayMode == DISPLAY_ALWAYS) {
if (mutableText->sizingMode == SIZING_NONE)
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, 0, 0, mutableText->alias, elem->color);
else
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, mutableText->alias, elem->color);

if (mutableText->displayMode == DISPLAY_DEFINED && mutableText->currentValue == NULL)
return;

char colon[4];
if (mutableText->sizingMode == SIZING_WRAP)
snprintf(colon, sizeof(colon), ":\n");
else
snprintf(colon, sizeof(colon), ": ");

int addSuffix = 0;
if (!strncmp(mutableText->alias, "Title", 5))
snprintf(result, sizeof(result), "%s%s", _l(_STR_INFO_TITLE), colon);
else if (!strncmp(mutableText->alias, "Genre", 5))
snprintf(result, sizeof(result), "%s%s", _l(_STR_INFO_GENRE), colon);
else if (!strncmp(mutableText->alias, "Release", 7))
snprintf(result, sizeof(result), "%s%s", _l(_STR_INFO_RELEASE), colon);
else if (!strncmp(mutableText->alias, "Developer", 9))
snprintf(result, sizeof(result), "%s%s", _l(_STR_INFO_DEVELOPER), colon);
else if (!strncmp(mutableText->alias, "Size", 4)) {
snprintf(result, sizeof(result), "%s%s", _l(_STR_SIZE), colon);
addSuffix = 1;
}
else if (!strncmp(mutableText->alias, "Description", 11))
snprintf(result, sizeof(result), "%s%s", _l(_STR_INFO_DESCRIPTION), colon);
else
snprintf(result, sizeof(result), "%s", mutableText->alias);

if (mutableText->currentValue) {
strcat(result, mutableText->currentValue);
if (addSuffix)
strcat(result, " MiB");
}

render:
if (mutableText->sizingMode == SIZING_NONE)
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, 0, 0, result, elem->color);
else
fntRenderString(elem->font, elem->posX, elem->posY, elem->aligned, elem->width, elem->height, result, elem->color);
}

static void initAttributeText(const char *themePath, config_set_t *themeConfig, theme_t *theme, theme_element_t *elem, const char *name)
Expand Down

0 comments on commit ddb0d97

Please sign in to comment.