[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:
@@ -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