2019-06-16 18:32:27 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2015-2016 - Andre Leiradella
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-10-01 13:02:20 +00:00
|
|
|
#include <file/file_path.h>
|
|
|
|
|
|
|
|
#include "../file_path_special.h"
|
|
|
|
#include "../configuration.h"
|
2020-02-23 17:38:27 +00:00
|
|
|
#include "../gfx/gfx_display.h"
|
2018-10-01 13:02:20 +00:00
|
|
|
|
|
|
|
#include "badges.h"
|
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
#ifdef HAVE_MENU
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
#define CHEEVOS_MENU_BADGE_LIMIT 256
|
|
|
|
static uintptr_t cheevos_badge_menu_texture_list[CHEEVOS_MENU_BADGE_LIMIT] = { 0 };
|
|
|
|
|
|
|
|
void cheevos_reset_menu_badges(void)
|
2018-10-01 13:02:20 +00:00
|
|
|
{
|
2020-02-28 15:49:00 +00:00
|
|
|
int index;
|
|
|
|
for (index = 0; index < CHEEVOS_MENU_BADGE_LIMIT; ++index)
|
|
|
|
{
|
|
|
|
if (cheevos_badge_menu_texture_list[index])
|
|
|
|
video_driver_texture_unload(&cheevos_badge_menu_texture_list[index]);
|
|
|
|
}
|
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
memset(&cheevos_badge_menu_texture_list, 0, sizeof(cheevos_badge_menu_texture_list));
|
2018-10-01 13:02:20 +00:00
|
|
|
}
|
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
void cheevos_set_menu_badge(int index, const char *badge, bool locked)
|
2018-10-01 13:02:20 +00:00
|
|
|
{
|
2020-02-23 17:38:27 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
if (index >= CHEEVOS_MENU_BADGE_LIMIT)
|
|
|
|
return;
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
if (!settings || !settings->bools.cheevos_badges_enable)
|
|
|
|
cheevos_badge_menu_texture_list[index] = 0;
|
|
|
|
else
|
|
|
|
cheevos_badge_menu_texture_list[index] = cheevos_get_badge_texture(badge, locked);
|
2018-10-01 13:02:20 +00:00
|
|
|
}
|
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
uintptr_t cheevos_get_menu_badge_texture(int index)
|
2018-10-01 13:02:20 +00:00
|
|
|
{
|
2020-02-23 17:38:27 +00:00
|
|
|
if (index < CHEEVOS_MENU_BADGE_LIMIT)
|
|
|
|
return cheevos_badge_menu_texture_list[index];
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
return 0;
|
2018-10-01 13:02:20 +00:00
|
|
|
}
|
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
uintptr_t cheevos_get_badge_texture(const char *badge, bool locked)
|
2018-10-01 13:02:20 +00:00
|
|
|
{
|
2020-02-23 17:38:27 +00:00
|
|
|
char badge_file[24];
|
|
|
|
char fullpath[PATH_MAX_LENGTH];
|
|
|
|
uintptr_t tex;
|
|
|
|
|
|
|
|
if (!badge)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
snprintf(badge_file, sizeof(badge_file), "%s%s.png", badge, locked ? "_lock" : "");
|
|
|
|
|
|
|
|
fill_pathname_application_special(fullpath,
|
|
|
|
PATH_MAX_LENGTH * sizeof(char),
|
|
|
|
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES);
|
|
|
|
|
|
|
|
gfx_display_reset_textures_list(badge_file, fullpath,
|
|
|
|
&tex, TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL);
|
2018-10-01 13:02:20 +00:00
|
|
|
|
2020-02-23 17:38:27 +00:00
|
|
|
return tex;
|
2018-10-01 13:02:20 +00:00
|
|
|
}
|