From 225d593246ca6bde755b0d01fd9dfb53fe8e7ac2 Mon Sep 17 00:00:00 2001 From: Sky Date: Sat, 9 Dec 2023 17:51:25 -0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Frontend=E3=80=91Got=20rid=20of=20the?= =?UTF-8?q?=20duplicated=20game=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/main.c b/src/main.c index 094807ede..ea1124b98 100644 --- a/src/main.c +++ b/src/main.c @@ -379,8 +379,7 @@ typedef struct { se_keybind_state_t key; se_controller_state_t controller; se_game_info_t recently_loaded_games[SE_NUM_RECENT_PATHS]; - se_game_info_t sorted_recently_loaded_games[SE_NUM_RECENT_PATHS]; - int num_recently_loaded_games; + int sorted_recently_loaded_games[SE_NUM_RECENT_PATHS]; int recent_games_sort_type; persistent_settings_t settings; persistent_settings_t last_saved_settings; @@ -1312,24 +1311,27 @@ bool se_load_bios_file(const char* name, const char* base_path, const char* file free(bios_data); return loaded_bios; } -static int game_info_comparator(const void* a, const void* b){ - const se_game_info_t* ga = (const se_game_info_t*)a; - const se_game_info_t* gb = (const se_game_info_t*)b; - return strcmp(ga->path,gb->path); +static int se_game_info_alpha_comparator(const void* a, const void* b){ + const int ga = *(int*)a; + const int gb = *(int*)b; + return strcmp(gui_state.recently_loaded_games[ga].path,gui_state.recently_loaded_games[gb].path); +} +static int se_game_info_rev_alpha_comparator(const void* a, const void* b){ + const int ga = *(int*)a; + const int gb = *(int*)b; + return strcmp(gui_state.recently_loaded_games[gb].path,gui_state.recently_loaded_games[ga].path); } static void se_sort_recent_games_list(){ - gui_state.num_recently_loaded_games=32; + int size = 0; for(int i=0;iSE_SORT_ALPHA_DESC)gui_state.recent_games_sort_type=SE_NO_SORT; + se_sort_recent_games_list(); } igSeparator(); int num_entries=0; for(int i=0;ipath,"")==0)break; igPushIDInt(i); const char* base, *file_name, *ext;