Skip to content

Commit

Permalink
Cleanups - less settings pointer grabbing
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Feb 11, 2025
1 parent 6559f44 commit 98681ac
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 123 deletions.
146 changes: 77 additions & 69 deletions cheevos/cheevos.c

Large diffs are not rendered by default.

31 changes: 9 additions & 22 deletions cheevos/cheevos_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

#include "cheevos.h"

#include "../configuration.h"
#include "../file_path_special.h"
#include "../paths.h"
#include "../retroarch.h"
#include "../version.h"

#include <features/features_cpu.h>
#include <file/file_path.h>
#include <streams/file_stream.h>
Expand All @@ -31,6 +25,11 @@
#include "../frontend/frontend_driver.h"
#include "../tasks/tasks_internal.h"

#include "../file_path_special.h"
#include "../paths.h"
#include "../runloop.h"
#include "../version.h"

#ifdef HAVE_PRESENCE
#include "../network/presence.h"
#endif
Expand Down Expand Up @@ -598,25 +597,13 @@ void rcheevos_client_download_game_badge(const rc_client_game_t* game)

void rcheevos_client_download_achievement_badges(rc_client_t* client)
{
rc_client_download_queue_t* queue;
uint32_t i;
rc_client_download_queue_t *queue = (rc_client_download_queue_t*)
calloc(1, sizeof(*queue));

#if !defined(HAVE_GFX_WIDGETS) /* we always want badges if widgets are enabled */
settings_t* settings = config_get_ptr();
/* User has explicitly disabled badges */
if (!settings->bools.cheevos_badges_enable)
return;

/* badges are only needed for xmb and ozone menus */
if (!string_is_equal(settings->arrays.menu_driver, "xmb") &&
!string_is_equal(settings->arrays.menu_driver, "ozone"))
return;
#endif /* !defined(HAVE_GFX_WIDGETS) */

queue = (rc_client_download_queue_t*)calloc(1, sizeof(*queue));
queue->client = client;
queue->game = rc_client_get_game_info(client);
queue->list = rc_client_create_achievement_list(client,
queue->game = rc_client_get_game_info(client);
queue->list = rc_client_create_achievement_list(client,
RC_CLIENT_ACHIEVEMENT_CATEGORY_CORE_AND_UNOFFICIAL,
RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS);
queue->outstanding_requests = RCHEEVOS_CONCURRENT_BADGE_DOWNLOADS;
Expand Down
16 changes: 8 additions & 8 deletions cheevos/cheevos_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,10 @@ uintptr_t rcheevos_menu_get_badge_texture(unsigned menu_offset)
return 0;
}

void rcheevos_menu_populate_hardcore_pause_submenu(void* data)
void rcheevos_menu_populate_hardcore_pause_submenu(void* data, bool cheevos_hardcore_mode_enable)
{
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
menu_displaylist_info_t* info = (menu_displaylist_info_t*)data;
const settings_t* settings = config_get_ptr();
const bool cheevos_hardcore_mode_enable = settings->bools.cheevos_hardcore_mode_enable;
menu_displaylist_info_t* info = (menu_displaylist_info_t*)data;

if (cheevos_hardcore_mode_enable && rc_client_get_game_info(rcheevos_locals->client))
{
Expand Down Expand Up @@ -288,12 +286,12 @@ void rcheevos_menu_populate_hardcore_pause_submenu(void* data)
}
}

void rcheevos_menu_populate(void* data)
void rcheevos_menu_populate(void* data, bool cheevos_enable,
bool cheevos_hardcore_mode_enable)
{
menu_displaylist_info_t* info = (menu_displaylist_info_t*)data;
rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
const rc_client_game_t* game = rc_client_get_game_info(rcheevos_locals->client);
const settings_t* settings = config_get_ptr();

rc_client_achievement_list_t* list = rc_client_create_achievement_list(rcheevos_locals->client,
RC_CLIENT_ACHIEVEMENT_CATEGORY_CORE_AND_UNOFFICIAL,
Expand All @@ -314,8 +312,10 @@ void rcheevos_menu_populate(void* data)

if (game && game->id != 0)
{
/* first menu item is the Pause/Resume Hardcore option (unless hardcore is completely disabled) */
if (settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable)
/* First menu item is the Pause/Resume Hardcore option
* (unless hardcore is completely disabled) */
if ( cheevos_enable
&& cheevos_hardcore_mode_enable)
{
if (rc_client_get_hardcore_enabled(rcheevos_locals->client))
menu_entries_append(info->list,
Expand Down
5 changes: 3 additions & 2 deletions cheevos/cheevos_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

RETRO_BEGIN_DECLS

void rcheevos_menu_populate(void* data);
void rcheevos_menu_populate_hardcore_pause_submenu(void* data);
void rcheevos_menu_populate(void* data, bool cheevos_enable,
bool cheevos_hardcore_mode_enable);
void rcheevos_menu_populate_hardcore_pause_submenu(void* data, bool cheevos_hardcore_mode_enable);
bool rcheevos_menu_get_state(unsigned menu_offset, char* buffer, size_t buffer_size);
bool rcheevos_menu_get_sublabel(unsigned menu_offset, char* buffer, size_t buffer_size);
uintptr_t rcheevos_menu_get_badge_texture(unsigned menu_offset);
Expand Down
2 changes: 2 additions & 0 deletions gfx/gfx_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ float gfx_display_get_dpi_scale(
menu_scale_factor = 1.0f;
else
#endif
#ifdef HAVE_GFX_WIDGETS
menu_scale_factor = settings->floats.menu_scale_factor;
#endif
}
}
#endif
Expand Down
29 changes: 16 additions & 13 deletions gfx/gfx_thumbnail_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,13 @@ bool gfx_thumbnail_update_path(
enum gfx_thumbnail_id thumbnail_id)
{
char content_dir[DIR_MAX_LENGTH];
settings_t *settings = config_get_ptr();
const char *system_name = NULL;
char *thumbnail_path = NULL;
const char *dir_thumbnails = settings->paths.directory_thumbnails;
bool playlist_allow_non_png = settings->bools.playlist_allow_non_png;
settings_t *settings = config_get_ptr();
const char *system_name = NULL;
char *thumbnail_path = NULL;
const char *dir_thumbnails = settings->paths.directory_thumbnails;
bool playlist_allow_non_png = settings->bools.playlist_allow_non_png;
unsigned menu_left_thumbnails = settings->uints.menu_left_thumbnails;
unsigned gfx_thumbnails = settings->uints.gfx_thumbnails;
/* Thumbnail extension order. The default (i.e. png) is always the first. */
#define MAX_SUPPORTED_THUMBNAIL_EXTENSIONS 5
const char* const SUPPORTED_THUMBNAIL_EXTENSIONS[] = { ".png", ".jpg", ".jpeg", ".bmp", ".tga", 0 };
Expand Down Expand Up @@ -639,12 +641,10 @@ bool gfx_thumbnail_update_path(
}
else
{
char tmp_buf[DIR_MAX_LENGTH];
const char *type = gfx_thumbnail_get_type(
settings->uints.menu_left_thumbnails,
settings->uints.gfx_thumbnails,
path_data, thumbnail_id);
int i;
char tmp_buf[DIR_MAX_LENGTH];
const char *type = gfx_thumbnail_get_type(menu_left_thumbnails,
gfx_thumbnails, path_data, thumbnail_id);
bool thumbnail_found = false;
/* > Normal content: assemble path */

Expand All @@ -669,7 +669,8 @@ bool gfx_thumbnail_update_path(
&& thumbnail_path[0]!='\0'
&& i < MAX_SUPPORTED_THUMBNAIL_EXTENSIONS; i++ )
{
strlcpy(path_get_extension_mutable(thumbnail_path),SUPPORTED_THUMBNAIL_EXTENSIONS[i],6);
strlcpy(path_get_extension_mutable(thumbnail_path),
SUPPORTED_THUMBNAIL_EXTENSIONS[i], 6);
thumbnail_found = path_is_valid(thumbnail_path);
}

Expand All @@ -687,7 +688,8 @@ bool gfx_thumbnail_update_path(
&& !thumbnail_found
&& i < MAX_SUPPORTED_THUMBNAIL_EXTENSIONS ; i++ )
{
strlcpy(path_get_extension_mutable(thumbnail_path),SUPPORTED_THUMBNAIL_EXTENSIONS[i],6);
strlcpy(path_get_extension_mutable(thumbnail_path),
SUPPORTED_THUMBNAIL_EXTENSIONS[i], 6);
thumbnail_found = path_is_valid(thumbnail_path);
}

Expand All @@ -705,7 +707,8 @@ bool gfx_thumbnail_update_path(
&& !thumbnail_found
&& i < MAX_SUPPORTED_THUMBNAIL_EXTENSIONS ; i++ )
{
strlcpy(path_get_extension_mutable(thumbnail_path),SUPPORTED_THUMBNAIL_EXTENSIONS[i],6);
strlcpy(path_get_extension_mutable(thumbnail_path),
SUPPORTED_THUMBNAIL_EXTENSIONS[i], 6);
thumbnail_found = path_is_valid(thumbnail_path);
}
/* This logic is valid for locally stored thumbnails. For optional downloads,
Expand Down
9 changes: 4 additions & 5 deletions gfx/video_crt_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <libretro.h>
#include <math.h>

#include "../retroarch.h"
#include <retro_common_api.h>
#include "video_crt_switch.h"
#include "video_display_server.h"
Expand Down Expand Up @@ -386,9 +385,9 @@ void crt_switch_res_core(
int crt_switch_center_adjust,
int crt_switch_porch_adjust,
int monitor_index, bool dynamic,
int super_width, bool hires_menu)
int super_width, bool hires_menu,
unsigned video_aspect_ratio_idx)
{
settings_t *settings = config_get_ptr();
if (height <= 4)
{
hz = 60;
Expand Down Expand Up @@ -446,8 +445,8 @@ void crt_switch_res_core(
crt_store_temp_changes(p_switch);
}

if ( (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CORE)
&& video_driver_get_aspect_ratio() != p_switch->fly_aspect)
if ( (video_aspect_ratio_idx == ASPECT_RATIO_CORE)
&& video_driver_get_aspect_ratio() != p_switch->fly_aspect)
{
video_driver_state_t *video_st = video_state_get_ptr();
float fly_aspect = (float)p_switch->fly_aspect;
Expand Down
3 changes: 2 additions & 1 deletion gfx/video_crt_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void crt_switch_res_core(
int monitor_index,
bool dynamic,
int super_width,
bool hires_menu);
bool hires_menu,
unsigned video_aspect_ratio_idx);

void crt_destroy_modes(videocrt_switch_t *p_switch);

Expand Down
4 changes: 3 additions & 1 deletion gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -4300,7 +4300,9 @@ void video_driver_frame(const void *data, unsigned width,
video_info.monitor_index,
dynamic_super_width,
video_info.crt_switch_resolution_super,
video_info.crt_switch_hires_menu);
video_info.crt_switch_hires_menu,
config_get_ptr()->uints.video_aspect_ratio_idx
);
}
else if (!video_info.crt_switch_resolution)
#endif
Expand Down
6 changes: 4 additions & 2 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -13699,15 +13699,17 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_ACHIEVEMENT_PAUSE_MENU:
#ifdef HAVE_CHEEVOS
menu_entries_clear(info->list);
rcheevos_menu_populate_hardcore_pause_submenu(info);
rcheevos_menu_populate_hardcore_pause_submenu(info, settings->bools.cheevos_hardcore_mode_enable);
#endif
info->flags |= MD_FLAG_NEED_REFRESH
| MD_FLAG_NEED_PUSH;
break;
case DISPLAYLIST_ACHIEVEMENT_LIST:
#ifdef HAVE_CHEEVOS
menu_entries_clear(info->list);
rcheevos_menu_populate(info);
rcheevos_menu_populate(info,
settings->bools.cheevos_enable,
settings->bools.cheevos_hardcore_mode_enable);
#endif
info->flags |= MD_FLAG_NEED_REFRESH
| MD_FLAG_NEED_PUSH;
Expand Down

0 comments on commit 98681ac

Please sign in to comment.