mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Apply dolphin customizations without reboot
This commit is contained in:
@@ -97,7 +97,7 @@ bool momentum_app_apply(MomentumApp* app) {
|
||||
}
|
||||
}
|
||||
|
||||
if(app->save_level || app->save_angry) {
|
||||
if(app->save_dolphin) {
|
||||
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
||||
if(app->save_level) {
|
||||
int32_t xp = app->dolphin_level > 1 ? DOLPHIN_LEVELS[app->dolphin_level - 2] : 0;
|
||||
@@ -107,7 +107,8 @@ bool momentum_app_apply(MomentumApp* app) {
|
||||
dolphin->state->data.butthurt = app->dolphin_angry;
|
||||
}
|
||||
dolphin->state->dirty = true;
|
||||
dolphin_state_save(dolphin->state);
|
||||
dolphin_flush(dolphin);
|
||||
dolphin_reload_state(dolphin);
|
||||
furi_record_close(RECORD_DOLPHIN);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ typedef struct {
|
||||
bool save_name;
|
||||
bool save_level;
|
||||
bool save_angry;
|
||||
bool save_dolphin;
|
||||
bool save_backlight;
|
||||
bool save_settings;
|
||||
bool apply_pack;
|
||||
|
||||
@@ -18,6 +18,7 @@ static void momentum_app_scene_misc_dolphin_dolphin_level_changed(VariableItem*
|
||||
snprintf(level_str, 4, "%li", app->dolphin_level);
|
||||
variable_item_set_current_value_text(item, level_str);
|
||||
app->save_level = true;
|
||||
app->save_dolphin = true;
|
||||
}
|
||||
|
||||
static void momentum_app_scene_misc_dolphin_dolphin_angry_changed(VariableItem* item) {
|
||||
@@ -27,6 +28,7 @@ static void momentum_app_scene_misc_dolphin_dolphin_angry_changed(VariableItem*
|
||||
snprintf(angry_str, 4, "%li", app->dolphin_angry);
|
||||
variable_item_set_current_value_text(item, angry_str);
|
||||
app->save_angry = true;
|
||||
app->save_dolphin = true;
|
||||
}
|
||||
|
||||
const char* const butthurt_timer_names[] = {
|
||||
@@ -59,7 +61,7 @@ static void momentum_app_scene_misc_dolphin_butthurt_timer_changed(VariableItem*
|
||||
variable_item_set_current_value_text(item, butthurt_timer_names[index]);
|
||||
momentum_settings.butthurt_timer = butthurt_timer_values[index];
|
||||
app->save_settings = true;
|
||||
app->require_reboot = true;
|
||||
app->save_dolphin = true;
|
||||
}
|
||||
|
||||
void momentum_app_scene_misc_dolphin_on_enter(void* context) {
|
||||
|
||||
@@ -6,5 +6,5 @@ App(
|
||||
cdefines=["SRV_DOLPHIN"],
|
||||
stack_size=1 * 1024,
|
||||
order=50,
|
||||
sdk_headers=["dolphin.h", "helpers/dolphin_state.h"],
|
||||
sdk_headers=["dolphin.h"],
|
||||
)
|
||||
|
||||
@@ -85,6 +85,15 @@ FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin) {
|
||||
return dolphin->pubsub;
|
||||
}
|
||||
|
||||
void dolphin_reload_state(Dolphin* dolphin) {
|
||||
furi_check(dolphin);
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeReloadState;
|
||||
|
||||
dolphin_event_send_wait(dolphin, &event);
|
||||
}
|
||||
|
||||
// Private functions
|
||||
|
||||
static void dolphin_butthurt_timer_callback(void* context) {
|
||||
@@ -228,6 +237,7 @@ static bool dolphin_process_event(FuriMessageQueue* queue, void* context) {
|
||||
!dolphin_state_xp_to_levelup(dolphin->state->data.icounter);
|
||||
|
||||
} else if(event.type == DolphinEventTypeFlush) {
|
||||
dolphin_flush_timer_callback(dolphin);
|
||||
furi_event_loop_timer_start(dolphin->flush_timer, FLUSH_TIMEOUT_TICKS);
|
||||
|
||||
} else if(event.type == DolphinEventTypeLevel) {
|
||||
|
||||
@@ -45,6 +45,8 @@ void dolphin_upgrade_level(Dolphin* dolphin);
|
||||
|
||||
FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin);
|
||||
|
||||
void dolphin_reload_state(Dolphin* dolphin);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user