From bcf74d96853303addb9f812ba2253727157275a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 8 Jul 2016 16:24:05 +0200 Subject: [PATCH] Start adding menu_cbs_label.c --- Makefile.common | 1 + griffin/griffin.c | 1 + menu/cbs/menu_cbs_label.c | 40 +++++++++++++++++++++++++++++++++++++++ menu/menu_cbs.c | 4 ++++ menu/menu_cbs.h | 3 +++ menu/menu_entries.h | 3 +++ menu/menu_entry.c | 4 ++++ menu/menu_entry.h | 1 + 8 files changed, 57 insertions(+) create mode 100644 menu/cbs/menu_cbs_label.c diff --git a/Makefile.common b/Makefile.common index d38990e1bf..b6afcc8bc0 100644 --- a/Makefile.common +++ b/Makefile.common @@ -512,6 +512,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/cbs/menu_cbs_deferred_push.o \ menu/cbs/menu_cbs_scan.o \ menu/cbs/menu_cbs_get_value.o \ + menu/cbs/menu_cbs_label.o \ menu/cbs/menu_cbs_title.o \ menu/cbs/menu_cbs_up.o \ menu/cbs/menu_cbs_down.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 97114e52e5..3c99aff945 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -876,6 +876,7 @@ MENU #include "../menu/cbs/menu_cbs_deferred_push.c" #include "../menu/cbs/menu_cbs_scan.c" #include "../menu/cbs/menu_cbs_get_value.c" +#include "../menu/cbs/menu_cbs_label.c" #include "../menu/cbs/menu_cbs_up.c" #include "../menu/cbs/menu_cbs_down.c" #include "../menu/cbs/menu_cbs_contentlist_switch.c" diff --git a/menu/cbs/menu_cbs_label.c b/menu/cbs/menu_cbs_label.c new file mode 100644 index 0000000000..efdb6b1f0a --- /dev/null +++ b/menu/cbs/menu_cbs_label.c @@ -0,0 +1,40 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "../menu_driver.h" +#include "../menu_cbs.h" +#include "../menu_navigation.h" + +#ifndef BIND_ACTION_LABEL +#define BIND_ACTION_LABEL(cbs, name) \ + cbs->action_label = name; \ + cbs->action_label_ident = #name; +#endif + +static int action_bind_label_generic(char *s, size_t len) +{ + return 0; +} + +int menu_cbs_init_bind_label(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx) +{ + if (!cbs) + return -1; + + BIND_ACTION_LABEL(cbs, action_bind_label_generic); + + return -1; +} diff --git a/menu/menu_cbs.c b/menu/menu_cbs.c index 03fcb9c3e3..1d6b03218a 100644 --- a/menu/menu_cbs.c +++ b/menu/menu_cbs.c @@ -126,6 +126,10 @@ void menu_cbs_init(void *data, menu_cbs_init_log(repr_label, "GET TITLE", cbs->action_get_title_ident); + menu_cbs_init_bind_label(cbs, path, label, type, idx); + + menu_cbs_init_log(repr_label, "LABEL", cbs->action_label_ident); + bind_info.cbs = cbs; bind_info.path = path; bind_info.label = label; diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index 89ef31ae25..d8940c7d3e 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -148,6 +148,9 @@ int menu_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, uint32_t label_hash, uint32_t menu_label_hash); +int menu_cbs_init_bind_label(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx); + int menu_cbs_init_bind_up(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx); diff --git a/menu/menu_entries.h b/menu/menu_entries.h index c14d43a69a..e6ddcff6ad 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -111,6 +111,9 @@ typedef struct menu_file_list_cbs int (*action_up)(unsigned type, const char *label); const char *action_up_ident; + int (*action_label)(char *s, size_t len); + const char *action_label_ident; + int (*action_down)(unsigned type, const char *label); const char *action_down_ident; diff --git a/menu/menu_entry.c b/menu/menu_entry.c index bf22607291..70c4a14146 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -292,6 +292,10 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx, entry_label, path, entry->path, sizeof(entry->path)); } + + if (cbs && cbs->action_label) + cbs->action_label(entry->rich_label, + sizeof(entry->rich_label)); } entry->idx = i; diff --git a/menu/menu_entry.h b/menu/menu_entry.h index 97ec896087..615725c200 100644 --- a/menu/menu_entry.h +++ b/menu/menu_entry.h @@ -45,6 +45,7 @@ typedef struct menu_entry { char path[PATH_MAX_LENGTH]; char label[PATH_MAX_LENGTH]; + char rich_label[PATH_MAX_LENGTH]; char value[PATH_MAX_LENGTH]; size_t entry_idx; enum msg_hash_enums enum_idx;