mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 20:28:36 -07:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
@@ -51,8 +51,7 @@ static bool animation_storage_load_single_manifest_info(
|
||||
if(furi_string_cmp_str(read_string, name)) break;
|
||||
flipper_format_set_strict_mode(file, true);
|
||||
|
||||
manifest_info->name = malloc(furi_string_size(read_string) + 1);
|
||||
strcpy((char*)manifest_info->name, furi_string_get_cstr(read_string));
|
||||
manifest_info->name = strdup(furi_string_get_cstr(read_string));
|
||||
|
||||
if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
|
||||
manifest_info->min_butthurt = u32value;
|
||||
@@ -104,9 +103,7 @@ void animation_storage_fill_animation_list(StorageAnimationList_t* animation_lis
|
||||
storage_animation->manifest_info.name = NULL;
|
||||
|
||||
if(!flipper_format_read_string(file, "Name", read_string)) break;
|
||||
storage_animation->manifest_info.name = malloc(furi_string_size(read_string) + 1);
|
||||
strcpy(
|
||||
(char*)storage_animation->manifest_info.name, furi_string_get_cstr(read_string));
|
||||
storage_animation->manifest_info.name = strdup(furi_string_get_cstr(read_string));
|
||||
|
||||
if(!flipper_format_read_uint32(file, "Min butthurt", &u32value, 1)) break;
|
||||
storage_animation->manifest_info.min_butthurt = u32value;
|
||||
@@ -400,8 +397,7 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFo
|
||||
|
||||
furi_string_replace_all(str, "\\n", "\n");
|
||||
|
||||
FURI_CONST_ASSIGN_PTR(bubble->bubble.text, malloc(furi_string_size(str) + 1));
|
||||
strcpy((char*)bubble->bubble.text, furi_string_get_cstr(str));
|
||||
FURI_CONST_ASSIGN_PTR(bubble->bubble.text, strdup(furi_string_get_cstr(str)));
|
||||
|
||||
if(!flipper_format_read_string(ff, "AlignH", str)) break;
|
||||
if(!animation_storage_cast_align(str, (Align*)&bubble->bubble.align_h)) break;
|
||||
|
||||
@@ -47,6 +47,26 @@ void dolphin_deed(DolphinDeed deed) {
|
||||
furi_record_close(RECORD_DOLPHIN);
|
||||
}
|
||||
|
||||
void dolphin_get_settings(Dolphin* dolphin, DolphinSettings* settings) {
|
||||
furi_check(dolphin);
|
||||
furi_check(settings);
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeSettingsGet;
|
||||
event.settings = settings;
|
||||
dolphin_event_send_wait(dolphin, &event);
|
||||
}
|
||||
|
||||
void dolphin_set_settings(Dolphin* dolphin, DolphinSettings* settings) {
|
||||
furi_check(dolphin);
|
||||
furi_check(settings);
|
||||
|
||||
DolphinEvent event;
|
||||
event.type = DolphinEventTypeSettingsSet;
|
||||
event.settings = settings;
|
||||
dolphin_event_send_wait(dolphin, &event);
|
||||
}
|
||||
|
||||
DolphinStats dolphin_stats(Dolphin* dolphin) {
|
||||
furi_check(dolphin);
|
||||
|
||||
@@ -211,7 +231,9 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) {
|
||||
|
||||
} else if(event.type == DolphinEventTypeStats) {
|
||||
event.stats->icounter = dolphin->state->data.icounter;
|
||||
event.stats->butthurt = dolphin->state->data.butthurt;
|
||||
event.stats->butthurt = (dolphin->state->data.flags & DolphinFlagHappyMode) ?
|
||||
0 :
|
||||
dolphin->state->data.butthurt;
|
||||
event.stats->timestamp = dolphin->state->data.timestamp;
|
||||
event.stats->level = dolphin_get_level(dolphin->state->data.icounter);
|
||||
event.stats->level_up_is_pending =
|
||||
@@ -228,6 +250,15 @@ static bool dolphin_process_event(FuriEventLoopObject* object, void* context) {
|
||||
dolphin_state_load(dolphin->state);
|
||||
furi_event_loop_timer_start(dolphin->butthurt_timer, BUTTHURT_INCREASE_PERIOD_TICKS);
|
||||
|
||||
} else if(event.type == DolphinEventTypeSettingsGet) {
|
||||
event.settings->happy_mode = dolphin->state->data.flags & DolphinFlagHappyMode;
|
||||
|
||||
} else if(event.type == DolphinEventTypeSettingsSet) {
|
||||
dolphin->state->data.flags &= ~DolphinFlagHappyMode;
|
||||
if(event.settings->happy_mode) dolphin->state->data.flags |= DolphinFlagHappyMode;
|
||||
dolphin->state->dirty = true;
|
||||
dolphin_state_save(dolphin->state);
|
||||
|
||||
} else {
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ typedef struct {
|
||||
bool level_up_is_pending;
|
||||
} DolphinStats;
|
||||
|
||||
typedef struct {
|
||||
bool happy_mode;
|
||||
} DolphinSettings;
|
||||
|
||||
typedef enum {
|
||||
DolphinPubsubEventUpdate,
|
||||
} DolphinPubsubEvent;
|
||||
@@ -31,6 +35,10 @@ typedef enum {
|
||||
*/
|
||||
void dolphin_deed(DolphinDeed deed);
|
||||
|
||||
void dolphin_get_settings(Dolphin* dolphin, DolphinSettings* settings);
|
||||
|
||||
void dolphin_set_settings(Dolphin* dolphin, DolphinSettings* settings);
|
||||
|
||||
/** Retrieve dolphin stats
|
||||
* Thread safe, blocking
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,8 @@ typedef enum {
|
||||
DolphinEventTypeFlush,
|
||||
DolphinEventTypeLevel,
|
||||
DolphinEventTypeReloadState,
|
||||
DolphinEventTypeSettingsGet,
|
||||
DolphinEventTypeSettingsSet,
|
||||
} DolphinEventType;
|
||||
|
||||
typedef struct {
|
||||
@@ -21,6 +23,7 @@ typedef struct {
|
||||
union {
|
||||
DolphinDeed deed;
|
||||
DolphinStats* stats;
|
||||
DolphinSettings* settings;
|
||||
};
|
||||
} DolphinEvent;
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
#include "dolphin_deed.h"
|
||||
|
||||
typedef enum {
|
||||
DolphinFlagHappyMode = 1,
|
||||
} DolphinFlags;
|
||||
|
||||
typedef struct DolphinState DolphinState;
|
||||
typedef struct {
|
||||
uint8_t icounter_daily_limit[DolphinAppMAX];
|
||||
|
||||
@@ -767,7 +767,7 @@ static bool loader_do_signal(Loader* loader, uint32_t signal, void* arg) {
|
||||
|
||||
static bool loader_do_get_application_name(Loader* loader, FuriString* name) {
|
||||
if(loader_is_application_running(loader)) {
|
||||
furi_string_set(name, furi_thread_get_name(loader->app.thread));
|
||||
furi_string_set(name, furi_thread_get_name(furi_thread_get_id(loader->app.thread)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,9 +226,7 @@ static void rpc_system_storage_list_root(const PB_Main* request, void* context)
|
||||
response.content.storage_list_response.file[i].data = NULL;
|
||||
response.content.storage_list_response.file[i].size = 0;
|
||||
response.content.storage_list_response.file[i].type = PB_Storage_File_FileType_DIR;
|
||||
char* str = malloc(strlen(hard_coded_dirs[i]) + 1);
|
||||
strcpy(str, hard_coded_dirs[i]);
|
||||
response.content.storage_list_response.file[i].name = str;
|
||||
response.content.storage_list_response.file[i].name = strdup(hard_coded_dirs[i]);
|
||||
}
|
||||
|
||||
rpc_send_and_release(session, &response);
|
||||
|
||||
Reference in New Issue
Block a user