From 05ddeb3066190f2397ee0806a46ab40d035e060b Mon Sep 17 00:00:00 2001 From: Willy-JL Date: Mon, 6 Feb 2023 19:28:26 +0000 Subject: [PATCH] Alpha sort asset packs setting --- .../scenes/xtreme_settings_scene_start.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/applications/settings/xtreme_settings/scenes/xtreme_settings_scene_start.c b/applications/settings/xtreme_settings/scenes/xtreme_settings_scene_start.c index 53d679efb..f3e41ba70 100644 --- a/applications/settings/xtreme_settings/scenes/xtreme_settings_scene_start.c +++ b/applications/settings/xtreme_settings/scenes/xtreme_settings_scene_start.c @@ -145,9 +145,20 @@ void xtreme_settings_scene_start_on_enter(void* context) { if(info.flags & FSF_DIRECTORY) { char* copy = malloc(MAX_PACK_NAME_LEN); strlcpy(copy, name, MAX_PACK_NAME_LEN); - asset_packs_push_back(app->asset_packs, copy); - if(strcmp(name, xtreme_settings->asset_pack) == 0) - current_pack = asset_packs_size(app->asset_packs); + uint idx; + for(idx = 0; idx < asset_packs_size(app->asset_packs); idx++) { + if(strcasecmp(copy, *asset_packs_get(app->asset_packs, idx)) < 0) { + break; + } + } + asset_packs_push_at(app->asset_packs, idx, copy); + if(current_pack != 0) { + if(idx <= current_pack) + current_pack++; + } else { + if(strcmp(copy, xtreme_settings->asset_pack) == 0) + current_pack = idx + 1; + } } } } while(false);