mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 06:18:35 -07:00
fix(animation-manager): fix only 1 valid anim showing fallback (#455)
This commit is contained in:
@@ -387,31 +387,22 @@ static StorageAnimation*
|
|||||||
furi_record_close(RECORD_DOLPHIN);
|
furi_record_close(RECORD_DOLPHIN);
|
||||||
uint32_t whole_weight = 0;
|
uint32_t whole_weight = 0;
|
||||||
|
|
||||||
|
// Filter valid animations
|
||||||
bool fallback = xtreme_settings.fallback_anim;
|
bool fallback = xtreme_settings.fallback_anim;
|
||||||
if(StorageAnimationList_size(animation_list) == dolphin_internal_size + 1 && !fallback) {
|
|
||||||
// One ext anim and fallback disabled, dont skip current anim (current = only ext one)
|
|
||||||
avoid_animation = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
StorageAnimationList_it_t it;
|
|
||||||
bool unlock = xtreme_settings.unlock_anims;
|
bool unlock = xtreme_settings.unlock_anims;
|
||||||
|
StorageAnimationList_it_t it;
|
||||||
for(StorageAnimationList_it(it, animation_list); !StorageAnimationList_end_p(it);) {
|
for(StorageAnimationList_it(it, animation_list); !StorageAnimationList_end_p(it);) {
|
||||||
StorageAnimation* storage_animation = *StorageAnimationList_ref(it);
|
StorageAnimation* storage_animation = *StorageAnimationList_ref(it);
|
||||||
const StorageAnimationManifestInfo* manifest_info =
|
const StorageAnimationManifestInfo* manifest_info =
|
||||||
animation_storage_get_meta(storage_animation);
|
animation_storage_get_meta(storage_animation);
|
||||||
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats, unlock);
|
bool valid = animation_manager_is_valid_idle_animation(manifest_info, &stats, unlock);
|
||||||
|
|
||||||
if(avoid_animation != NULL && strcmp(manifest_info->name, avoid_animation) == 0) {
|
|
||||||
// Avoid repeating same animation twice
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
if(strcmp(manifest_info->name, HARDCODED_ANIMATION_NAME) == 0 && !fallback) {
|
if(strcmp(manifest_info->name, HARDCODED_ANIMATION_NAME) == 0 && !fallback) {
|
||||||
// Skip fallback animation
|
// Skip fallback animation
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(valid) {
|
if(valid) {
|
||||||
whole_weight += manifest_info->weight;
|
|
||||||
StorageAnimationList_next(it);
|
StorageAnimationList_next(it);
|
||||||
} else {
|
} else {
|
||||||
animation_storage_free_storage_animation(&storage_animation);
|
animation_storage_free_storage_animation(&storage_animation);
|
||||||
@@ -420,6 +411,28 @@ static StorageAnimation*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(StorageAnimationList_size(animation_list) == 1) {
|
||||||
|
// One valid anim, dont skip current anim (current = only ext one)
|
||||||
|
avoid_animation = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Avoid repeating current animation and calculate weights
|
||||||
|
for(StorageAnimationList_it(it, animation_list); !StorageAnimationList_end_p(it);) {
|
||||||
|
StorageAnimation* storage_animation = *StorageAnimationList_ref(it);
|
||||||
|
const StorageAnimationManifestInfo* manifest_info =
|
||||||
|
animation_storage_get_meta(storage_animation);
|
||||||
|
|
||||||
|
if(avoid_animation && strcmp(manifest_info->name, avoid_animation) == 0) {
|
||||||
|
// Avoid repeating same animation twice
|
||||||
|
animation_storage_free_storage_animation(&storage_animation);
|
||||||
|
/* remove and increase iterator */
|
||||||
|
StorageAnimationList_remove(animation_list, it);
|
||||||
|
} else {
|
||||||
|
whole_weight += manifest_info->weight;
|
||||||
|
StorageAnimationList_next(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t lucky_number = furi_hal_random_get() % whole_weight;
|
uint32_t lucky_number = furi_hal_random_get() % whole_weight;
|
||||||
uint32_t weight = 0;
|
uint32_t weight = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user