Press left/right on a cheat entry now to turn it ON/OFF

This commit is contained in:
twinaphex 2014-12-16 02:20:06 +01:00
parent 03f2421154
commit 21b99c3ac5
4 changed files with 34 additions and 7 deletions

View File

@ -171,13 +171,15 @@ void cheat_manager_free(cheat_manager_t *handle)
free(handle);
}
static void cheat_manager_update(cheat_manager_t *handle)
void cheat_manager_update(cheat_manager_t *handle)
{
msg_queue_clear(g_extern.msg_queue);
char msg[256];
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
handle->ptr, handle->cheats[handle->ptr].state ? "ON" : "OFF",
handle->cheats[handle->ptr].desc);
(handle->cheats[handle->ptr].desc) ?
(handle->cheats[handle->ptr].desc) : (handle->cheats[handle->ptr].code)
);
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
RARCH_LOG("%s\n", msg);
}

View File

@ -55,6 +55,8 @@ void cheat_manager_toggle(cheat_manager_t *handle);
void cheat_manager_apply_cheats(cheat_manager_t *handle);
void cheat_manager_update(cheat_manager_t *handle);
#ifdef __cplusplus
}
#endif

View File

@ -342,8 +342,6 @@ static int action_ok_cheat_file_load(const char *path,
fill_pathname_join(cheat_path, menu_path, path, sizeof(cheat_path));
RARCH_LOG("menu path is: %s\n", menu_path);
if (g_extern.cheat)
cheat_manager_free(g_extern.cheat);
@ -927,6 +925,27 @@ static int shader_action_parameter_preset_toggle(unsigned type, const char *labe
return 0;
}
static int action_toggle_cheat(unsigned type, const char *label,
unsigned action)
{
cheat_manager_t *cheat = g_extern.cheat;
size_t idx = type - MENU_SETTINGS_CHEAT_BEGIN;
if (!cheat)
return -1;
switch (action)
{
case MENU_ACTION_LEFT:
case MENU_ACTION_RIGHT:
cheat->cheats[idx].state = !cheat->cheats[idx].state;
cheat_manager_update(cheat);
break;
}
return 0;
}
#ifdef HAVE_SHADER_MANAGER
extern size_t hack_shader_pass;
#endif
@ -2531,6 +2550,9 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs,
else if (type >= MENU_SETTINGS_SHADER_PRESET_PARAMETER_0
&& type <= MENU_SETTINGS_SHADER_PRESET_PARAMETER_LAST)
cbs->action_toggle = shader_action_parameter_preset_toggle;
else if (type >= MENU_SETTINGS_CHEAT_BEGIN
&& type <= MENU_SETTINGS_CHEAT_END)
cbs->action_toggle = action_toggle_cheat;
else if (
!strcmp(label, "core_list") ||
!strcmp(label, "history_list") ||

View File

@ -2405,10 +2405,11 @@ void setting_data_get_label(char *type_str,
{
unsigned cheat_index = type - MENU_SETTINGS_CHEAT_BEGIN;
if (cheat_index < g_extern.cheat->buf_size)
snprintf(type_str, type_str_size, "%s",
(
snprintf(type_str, type_str_size, "%s : (%s)",
(g_extern.cheat->cheats[cheat_index].code != NULL)
) ? g_extern.cheat->cheats[cheat_index].code : "N/A");
? g_extern.cheat->cheats[cheat_index].code : "N/A",
g_extern.cheat->cheats[cheat_index].state ? "ON" : "OFF"
);
}
else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN
&& type <= MENU_SETTINGS_PERF_COUNTERS_END)