Add anim speed setting

This commit is contained in:
Willy-JL
2023-01-22 21:19:39 +00:00
parent b72799c69b
commit 443dc93fc3
3 changed files with 29 additions and 0 deletions

View File

@@ -514,6 +514,11 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break; //-V779 if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break; //-V779
animation->active_cycles = u32value; animation->active_cycles = u32value;
if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break; if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break;
uint16_t anim_speed = XTREME_SETTINGS()->anim_speed;
anim_speed = (anim_speed == 0 ? 100 : anim_speed);
u32value = (u32value * anim_speed) / 100;
u32value = u32value < 1 ? 1 : u32value;
u32value = u32value > 10 ? 10 : u32value;
FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value); FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value);
if(!flipper_format_read_uint32(ff, "Duration", &u32value, 1)) break; if(!flipper_format_read_uint32(ff, "Duration", &u32value, 1)) break;
animation->duration = u32value; animation->duration = u32value;

View File

@@ -20,6 +20,18 @@ static void xtreme_settings_scene_start_asset_pack_changed(VariableItem* item) {
app->assets_changed = true; app->assets_changed = true;
} }
const char* const anim_speed_names[] =
{"25%", "50%", "75%", "100%", "125%", "150%", "175%", "200%", "225%", "250%", "275%", "300%"};
const int32_t anim_speed_values[COUNT_OF(anim_speed_names)] =
{25, 50, 75, 0, 125, 150, 175, 200, 225, 250, 275, 300};
static void xtreme_settings_scene_start_anim_speed_changed(VariableItem* item) {
XtremeSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, anim_speed_names[index]);
XTREME_SETTINGS()->anim_speed = anim_speed_values[index];
app->settings_changed = true;
}
const char* const cycle_anims_names[] = const char* const cycle_anims_names[] =
{"OFF", "Meta.txt", "30 S", "1 M", "5 M", "10 M", "15 M", "30 M", "1 H", "2 H", "6 H", "12 H", "24 H"}; {"OFF", "Meta.txt", "30 S", "1 M", "5 M", "10 M", "15 M", "30 M", "1 H", "2 H", "6 H", "12 H", "24 H"};
const int32_t cycle_anims_values[COUNT_OF(cycle_anims_names)] = const int32_t cycle_anims_values[COUNT_OF(cycle_anims_names)] =
@@ -143,6 +155,17 @@ void xtreme_settings_scene_start_on_enter(void* context) {
variable_item_set_current_value_index(item, current_pack); variable_item_set_current_value_index(item, current_pack);
variable_item_set_current_value_text(item, current_pack == 0 ? "OFF" : *asset_packs_get(app->asset_packs, current_pack - 1)); variable_item_set_current_value_text(item, current_pack == 0 ? "OFF" : *asset_packs_get(app->asset_packs, current_pack - 1));
item = variable_item_list_add(
var_item_list,
"Anim Speed",
COUNT_OF(anim_speed_names),
xtreme_settings_scene_start_anim_speed_changed,
app);
value_index = value_index_int32(
xtreme_settings->anim_speed, anim_speed_values, COUNT_OF(anim_speed_names));
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, anim_speed_names[value_index]);
item = variable_item_list_add( item = variable_item_list_add(
var_item_list, var_item_list,
"Cycle Anims", "Cycle Anims",

View File

@@ -21,6 +21,7 @@ typedef struct {
bool sfw_mode; bool sfw_mode;
char asset_pack[MAX_PACK_NAME_LEN]; char asset_pack[MAX_PACK_NAME_LEN];
BatteryStyle battery_style; BatteryStyle battery_style;
uint16_t anim_speed;
} XtremeSettings; } XtremeSettings;
XtremeSettings* XTREME_SETTINGS(); XtremeSettings* XTREME_SETTINGS();