[FL-1995] New dolphin animations (part 1) (#835)

* Desktop Animation (part 1): Ugly naked ohmygod architecture
* fix butthurt, fix locked scene
* Change SD icons, fixes
* Fix level update animation
* Fixes, correct butthurt
* Clean up code
* furi_assert(0) -> furi_crash("msg")
* Gui: rename none layer to desktop, update docs.

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Albert Kharisov
2021-11-24 20:21:12 +04:00
committed by GitHub
parent 92c499b41b
commit 9b8a139e2b
235 changed files with 1869 additions and 661 deletions

View File

@@ -1,4 +1,9 @@
#include "dolphin/dolphin.h"
#include "desktop/desktop.h"
#include "dolphin/helpers/dolphin_state.h"
#include "dolphin_i.h"
#include "furi/pubsub.h"
#include "sys/_stdint.h"
#include <furi.h>
#define DOLPHIN_TIMEGATE 86400 // one day
#define DOLPHIN_LOCK_EVENT_FLAG (0x1)
@@ -39,6 +44,7 @@ Dolphin* dolphin_alloc() {
dolphin->state = dolphin_state_alloc();
dolphin->event_queue = osMessageQueueNew(8, sizeof(DolphinEvent), NULL);
dolphin->pubsub = furi_pubsub_alloc();
return dolphin;
}
@@ -79,7 +85,7 @@ void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) {
static void dolphin_check_butthurt(DolphinState* state) {
furi_assert(state);
float diff_time = difftime(dolphin_state_get_timestamp(state), dolphin_state_timestamp());
float diff_time = difftime(state->data.timestamp, dolphin_state_timestamp());
if((fabs(diff_time)) > DOLPHIN_TIMEGATE) {
FURI_LOG_I("DolphinState", "Increasing butthurt");
@@ -87,6 +93,10 @@ static void dolphin_check_butthurt(DolphinState* state) {
}
}
FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin) {
return dolphin->pubsub;
}
int32_t dolphin_srv(void* p) {
Dolphin* dolphin = dolphin_alloc();
furi_record_create("dolphin", dolphin);
@@ -97,11 +107,17 @@ int32_t dolphin_srv(void* p) {
while(1) {
if(osMessageQueueGet(dolphin->event_queue, &event, NULL, 60000) == osOK) {
if(event.type == DolphinEventTypeDeed) {
dolphin_state_on_deed(dolphin->state, event.deed);
if(dolphin_state_on_deed(dolphin->state, event.deed)) {
DolphinPubsubEvent event = DolphinPubsubEventUpdate;
furi_pubsub_publish(dolphin->pubsub, &event);
}
} else if(event.type == DolphinEventTypeStats) {
event.stats->icounter = dolphin_state_get_icounter(dolphin->state);
event.stats->butthurt = dolphin_state_get_butthurt(dolphin->state);
event.stats->timestamp = dolphin_state_get_timestamp(dolphin->state);
event.stats->icounter = dolphin->state->data.icounter;
event.stats->butthurt = 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 =
!dolphin_state_xp_to_levelup(dolphin->state->data.icounter);
} else if(event.type == DolphinEventTypeFlush) {
dolphin_state_save(dolphin->state);
}
@@ -116,3 +132,8 @@ int32_t dolphin_srv(void* p) {
return 0;
}
void dolphin_upgrade_level(Dolphin* dolphin) {
dolphin_state_increase_level(dolphin->state);
dolphin_flush(dolphin);
}