[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:
@@ -5,3 +5,4 @@ ADD_SCENE(desktop, debug, Debug)
|
||||
ADD_SCENE(desktop, first_start, FirstStart)
|
||||
ADD_SCENE(desktop, hw_mismatch, HwMismatch)
|
||||
ADD_SCENE(desktop, pinsetup, PinSetup)
|
||||
ADD_SCENE(desktop, levelup, LevelUp)
|
||||
|
@@ -59,4 +59,5 @@ bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) {
|
||||
void desktop_scene_debug_on_exit(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
desktop_debug_reset_screen_idx(desktop->debug_view);
|
||||
desktop_start_new_idle_animation(desktop->animation);
|
||||
}
|
||||
|
79
applications/desktop/scenes/desktop_scene_levelup.c
Normal file
79
applications/desktop/scenes/desktop_scene_levelup.c
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "../desktop_i.h"
|
||||
#include "../views/desktop_main.h"
|
||||
#include "applications.h"
|
||||
#include "assets_icons.h"
|
||||
#include "desktop/desktop.h"
|
||||
#include "desktop/helpers/desktop_animation.h"
|
||||
#include "dolphin/dolphin.h"
|
||||
#include "furi/pubsub.h"
|
||||
#include "furi/record.h"
|
||||
#include "storage/storage-glue.h"
|
||||
#include <loader/loader.h>
|
||||
#include <m-list.h>
|
||||
|
||||
#define LEVELUP_SCENE_PLAYING 0
|
||||
#define LEVELUP_SCENE_STOPPED 1
|
||||
|
||||
static void desktop_scene_levelup_callback(DesktopMainEvent event, void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void desktop_scene_levelup_animation_changed_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Desktop* desktop = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
desktop->view_dispatcher, DesktopMainEventUpdateOneShotAnimation);
|
||||
}
|
||||
|
||||
void desktop_scene_levelup_on_enter(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
DesktopMainView* main_view = desktop->main_view;
|
||||
|
||||
desktop_main_set_callback(main_view, desktop_scene_levelup_callback, desktop);
|
||||
desktop_animation_set_animation_changed_callback(
|
||||
desktop->animation, desktop_scene_levelup_animation_changed_callback, desktop);
|
||||
|
||||
desktop_animation_start_oneshot_levelup(desktop->animation);
|
||||
const Icon* icon = desktop_animation_get_oneshot_frame(desktop->animation);
|
||||
desktop_main_switch_dolphin_icon(desktop->main_view, icon);
|
||||
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewMain);
|
||||
scene_manager_set_scene_state(
|
||||
desktop->scene_manager, DesktopSceneLevelUp, LEVELUP_SCENE_PLAYING);
|
||||
}
|
||||
|
||||
bool desktop_scene_levelup_on_event(void* context, SceneManagerEvent event) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
bool consumed = false;
|
||||
DesktopMainEvent main_event = event.event;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(main_event == DesktopMainEventUpdateOneShotAnimation) {
|
||||
const Icon* icon = desktop_animation_get_oneshot_frame(desktop->animation);
|
||||
if(icon) {
|
||||
desktop_main_switch_dolphin_icon(desktop->main_view, icon);
|
||||
} else {
|
||||
scene_manager_set_scene_state(
|
||||
desktop->scene_manager, DesktopSceneLevelUp, LEVELUP_SCENE_STOPPED);
|
||||
}
|
||||
consumed = true;
|
||||
} else {
|
||||
if(scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneLevelUp) ==
|
||||
LEVELUP_SCENE_STOPPED) {
|
||||
scene_manager_previous_scene(desktop->scene_manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void desktop_scene_levelup_on_exit(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
|
||||
Dolphin* dolphin = furi_record_open("dolphin");
|
||||
dolphin_upgrade_level(dolphin);
|
||||
furi_record_close("dolphin");
|
||||
desktop_animation_set_animation_changed_callback(desktop->animation, NULL, NULL);
|
||||
desktop_start_new_idle_animation(desktop->animation);
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
#include "../desktop_i.h"
|
||||
#include "../views/desktop_locked.h"
|
||||
#include "desktop/helpers/desktop_animation.h"
|
||||
#include "desktop/views/desktop_main.h"
|
||||
#include <furi-hal-lock.h>
|
||||
|
||||
void desktop_scene_locked_callback(DesktopLockedEvent event, void* context) {
|
||||
@@ -7,6 +9,12 @@ void desktop_scene_locked_callback(DesktopLockedEvent event, void* context) {
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void desktop_scene_locked_animation_changed_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Desktop* desktop = context;
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventUpdateAnimation);
|
||||
}
|
||||
|
||||
void desktop_scene_locked_on_enter(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
DesktopLockedView* locked_view = desktop->locked_view;
|
||||
@@ -14,7 +22,11 @@ void desktop_scene_locked_on_enter(void* context) {
|
||||
desktop_locked_set_callback(locked_view, desktop_scene_locked_callback, desktop);
|
||||
desktop_locked_reset_door_pos(locked_view);
|
||||
desktop_locked_update_hint_timeout(locked_view);
|
||||
desktop_locked_set_dolphin_animation(locked_view);
|
||||
|
||||
desktop_animation_set_animation_changed_callback(
|
||||
desktop->animation, desktop_scene_locked_animation_changed_callback, desktop);
|
||||
const Icon* icon = desktop_animation_get_animation(desktop->animation);
|
||||
desktop_locked_set_dolphin_animation(locked_view, icon);
|
||||
|
||||
uint32_t state = scene_manager_get_scene_state(desktop->scene_manager, DesktopViewLocked);
|
||||
|
||||
@@ -68,6 +80,12 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
|
||||
case DesktopLockedEventInputReset:
|
||||
desktop->pincode_buffer.length = 0;
|
||||
break;
|
||||
case DesktopMainEventUpdateAnimation: {
|
||||
const Icon* icon = desktop_animation_get_animation(desktop->animation);
|
||||
desktop_locked_set_dolphin_animation(desktop->locked_view, icon);
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if(desktop_scene_locked_check_pin(desktop, event.event)) {
|
||||
scene_manager_set_scene_state(
|
||||
@@ -84,6 +102,7 @@ bool desktop_scene_locked_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void desktop_scene_locked_on_exit(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
desktop_animation_set_animation_changed_callback(desktop->animation, NULL, NULL);
|
||||
desktop_locked_reset_counter(desktop->locked_view);
|
||||
osTimerStop(desktop->locked_view->timer);
|
||||
}
|
||||
|
@@ -1,7 +1,13 @@
|
||||
#include "../desktop_i.h"
|
||||
#include "../views/desktop_main.h"
|
||||
#include "applications.h"
|
||||
#include "assets_icons.h"
|
||||
#include "dolphin/dolphin.h"
|
||||
#include "furi/pubsub.h"
|
||||
#include "furi/record.h"
|
||||
#include "storage/storage-glue.h"
|
||||
#include <loader/loader.h>
|
||||
#include <m-list.h>
|
||||
#define MAIN_VIEW_DEFAULT (0UL)
|
||||
|
||||
static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* flipper_app) {
|
||||
@@ -27,6 +33,12 @@ void desktop_scene_main_callback(DesktopMainEvent event, void* context) {
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
|
||||
}
|
||||
|
||||
static void desktop_scene_main_animation_changed_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Desktop* desktop = context;
|
||||
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopMainEventUpdateAnimation);
|
||||
}
|
||||
|
||||
void desktop_scene_main_on_enter(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
DesktopMainView* main_view = desktop->main_view;
|
||||
@@ -39,7 +51,11 @@ void desktop_scene_main_on_enter(void* context) {
|
||||
desktop_main_unlocked(desktop->main_view);
|
||||
}
|
||||
|
||||
desktop_main_switch_dolphin_animation(desktop->main_view);
|
||||
desktop_animation_activate(desktop->animation);
|
||||
desktop_animation_set_animation_changed_callback(
|
||||
desktop->animation, desktop_scene_main_animation_changed_callback, desktop);
|
||||
const Icon* icon = desktop_animation_get_animation(desktop->animation);
|
||||
desktop_main_switch_dolphin_animation(desktop->main_view, icon);
|
||||
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewMain);
|
||||
}
|
||||
|
||||
@@ -75,9 +91,30 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case DesktopMainEventUpdateAnimation: {
|
||||
const Icon* icon = desktop_animation_get_animation(desktop->animation);
|
||||
desktop_main_switch_dolphin_animation(desktop->main_view, icon);
|
||||
consumed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case DesktopMainEventRightShort: {
|
||||
DesktopAnimationState state = desktop_animation_handle_right(desktop->animation);
|
||||
if(state == DesktopAnimationStateLevelUpIsPending) {
|
||||
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLevelUp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(event.event != DesktopMainEventUpdateAnimation) {
|
||||
desktop_animation_activate(desktop->animation);
|
||||
}
|
||||
} else if(event.type != SceneManagerEventTypeTick) {
|
||||
desktop_animation_activate(desktop->animation);
|
||||
}
|
||||
|
||||
return consumed;
|
||||
@@ -85,6 +122,8 @@ bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void desktop_scene_main_on_exit(void* context) {
|
||||
Desktop* desktop = (Desktop*)context;
|
||||
|
||||
desktop_animation_set_animation_changed_callback(desktop->animation, NULL, NULL);
|
||||
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneMain, MAIN_VIEW_DEFAULT);
|
||||
desktop_main_reset_hint(desktop->main_view);
|
||||
}
|
||||
|
Reference in New Issue
Block a user