Create CHEEVOS_CTL_GET_DESCRIPTION
This commit is contained in:
parent
e8e0917c9c
commit
ff9f433243
31
cheevos.c
31
cheevos.c
|
@ -2146,22 +2146,6 @@ static void cheevos_populate_menu(void *data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void cheevos_get_description(unsigned idx, char *str, size_t len)
|
|
||||||
{
|
|
||||||
cheevo_t *cheevos = NULL;
|
|
||||||
|
|
||||||
if (idx >= cheevos_locals.core.count)
|
|
||||||
{
|
|
||||||
cheevos = cheevos_locals.unofficial.cheevos;
|
|
||||||
idx -= cheevos_locals.unofficial.count;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cheevos = cheevos_locals.core.cheevos;
|
|
||||||
|
|
||||||
strncpy(str, cheevos[idx].description, len);
|
|
||||||
str[len - 1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cheevos_ctl(enum cheevos_ctl_state state, void *data)
|
bool cheevos_ctl(enum cheevos_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
static int cheats_are_enabled = 0;
|
static int cheats_are_enabled = 0;
|
||||||
|
@ -2170,6 +2154,21 @@ bool cheevos_ctl(enum cheevos_ctl_state state, void *data)
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
case CHEEVOS_CTL_GET_DESCRIPTION:
|
||||||
|
{
|
||||||
|
cheevos_ctx_desc_t *desc = (cheevos_ctx_desc_t*)data;
|
||||||
|
cheevo_t *cheevos = cheevos_locals.core.cheevos;
|
||||||
|
|
||||||
|
if (desc->idx >= cheevos_locals.core.count)
|
||||||
|
{
|
||||||
|
cheevos = cheevos_locals.unofficial.cheevos;
|
||||||
|
desc->idx -= cheevos_locals.unofficial.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(desc->s, cheevos[desc->idx].description, desc->len);
|
||||||
|
desc->s[desc->len - 1] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CHEEVOS_CTL_APPLY_CHEATS:
|
case CHEEVOS_CTL_APPLY_CHEATS:
|
||||||
{
|
{
|
||||||
bool *data_bool = (bool*)data;
|
bool *data_bool = (bool*)data;
|
||||||
|
|
|
@ -34,10 +34,17 @@ enum cheevos_ctl_state
|
||||||
* the game has content. */
|
* the game has content. */
|
||||||
CHEEVOS_CTL_SET_CHEATS,
|
CHEEVOS_CTL_SET_CHEATS,
|
||||||
|
|
||||||
|
CHEEVOS_CTL_GET_DESCRIPTION,
|
||||||
|
|
||||||
CHEEVOS_CTL_POPULATE_MENU
|
CHEEVOS_CTL_POPULATE_MENU
|
||||||
};
|
};
|
||||||
|
|
||||||
void cheevos_get_description(unsigned idx, char *str, size_t len);
|
typedef struct cheevos_ctx_desc
|
||||||
|
{
|
||||||
|
unsigned idx;
|
||||||
|
char *s;
|
||||||
|
size_t len;
|
||||||
|
} cheevos_ctx_desc_t;
|
||||||
|
|
||||||
bool cheevos_ctl(enum cheevos_ctl_state state, void *data);
|
bool cheevos_ctl(enum cheevos_ctl_state state, void *data);
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
static int action_iterate_help(menu_handle_t *menu,
|
static int action_iterate_help(menu_handle_t *menu,
|
||||||
char *s, size_t len, const char *label)
|
char *s, size_t len, const char *label)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_CHEEVOS
|
||||||
|
cheevos_ctx_desc_t desc_info;
|
||||||
|
#endif
|
||||||
bool do_exit = false;
|
bool do_exit = false;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
@ -172,7 +175,10 @@ static int action_iterate_help(menu_handle_t *menu,
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
case MENU_HELP_CHEEVOS_DESCRIPTION:
|
case MENU_HELP_CHEEVOS_DESCRIPTION:
|
||||||
cheevos_get_description(menu->help_screen_id, s, len);
|
desc_info.idx = menu->help_screen_id;
|
||||||
|
desc_info.s = s;
|
||||||
|
desc_info.len = len;
|
||||||
|
cheevos_ctl(CHEEVOS_CTL_GET_DESCRIPTION, &desc_info);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue