[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <furi.h>
|
|
|
|
#include <furi_hal.h>
|
|
|
|
#include <applications.h>
|
|
|
|
#include <assets_icons.h>
|
2021-09-28 16:10:13 +03:00
|
|
|
#include <loader/loader.h>
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
#include "../desktop_i.h"
|
|
|
|
#include "../views/desktop_events.h"
|
|
|
|
#include "../views/desktop_view_main.h"
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include "desktop_scene.h"
|
|
|
|
#include "desktop_scene_i.h"
|
|
|
|
|
2022-02-10 14:20:50 +03:00
|
|
|
#define TAG "DesktopSrv"
|
|
|
|
|
2023-05-26 13:13:46 +03:00
|
|
|
#define FAP_LOADER_APP_NAME "Applications"
|
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
static void desktop_scene_main_new_idle_animation_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = context;
|
2022-02-10 21:17:41 +03:00
|
|
|
view_dispatcher_send_custom_event(
|
|
|
|
desktop->view_dispatcher, DesktopAnimationEventNewIdleAnimation);
|
2022-01-03 00:39:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_scene_main_check_animation_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = context;
|
2022-02-10 21:17:41 +03:00
|
|
|
view_dispatcher_send_custom_event(
|
|
|
|
desktop->view_dispatcher, DesktopAnimationEventCheckAnimation);
|
2022-01-03 00:39:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_scene_main_interact_animation_callback(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
Desktop* desktop = context;
|
2022-02-10 21:17:41 +03:00
|
|
|
view_dispatcher_send_custom_event(
|
|
|
|
desktop->view_dispatcher, DesktopAnimationEventInteractAnimation);
|
2022-01-03 00:39:56 +03:00
|
|
|
}
|
|
|
|
|
2022-03-23 16:45:37 +03:00
|
|
|
#ifdef APP_ARCHIVE
|
2021-09-28 12:40:39 +03:00
|
|
|
static void desktop_switch_to_app(Desktop* desktop, const FlipperApplication* flipper_app) {
|
|
|
|
furi_assert(desktop);
|
|
|
|
furi_assert(flipper_app);
|
|
|
|
furi_assert(flipper_app->app);
|
|
|
|
furi_assert(flipper_app->name);
|
|
|
|
|
|
|
|
if(furi_thread_get_state(desktop->scene_thread) != FuriThreadStateStopped) {
|
|
|
|
FURI_LOG_E("Desktop", "Thread is already running");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-12 11:46:04 +03:00
|
|
|
FuriHalRtcHeapTrackMode mode = furi_hal_rtc_get_heap_track_mode();
|
|
|
|
if(mode > FuriHalRtcHeapTrackModeNone) {
|
|
|
|
furi_thread_enable_heap_trace(desktop->scene_thread);
|
|
|
|
} else {
|
|
|
|
furi_thread_disable_heap_trace(desktop->scene_thread);
|
|
|
|
}
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
furi_thread_set_name(desktop->scene_thread, flipper_app->name);
|
|
|
|
furi_thread_set_stack_size(desktop->scene_thread, flipper_app->stack_size);
|
|
|
|
furi_thread_set_callback(desktop->scene_thread, flipper_app->app);
|
|
|
|
|
|
|
|
furi_thread_start(desktop->scene_thread);
|
|
|
|
}
|
2022-03-23 16:45:37 +03:00
|
|
|
#endif
|
2021-09-28 12:40:39 +03:00
|
|
|
|
2023-05-26 13:13:46 +03:00
|
|
|
static void desktop_scene_main_open_app_or_profile(Desktop* desktop, const char* path) {
|
|
|
|
do {
|
|
|
|
LoaderStatus status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, path);
|
|
|
|
if(status == LoaderStatusOk) break;
|
|
|
|
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
|
|
|
|
|
|
|
status = loader_start(desktop->loader, "Passport", NULL);
|
|
|
|
if(status != LoaderStatusOk) {
|
|
|
|
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
|
|
|
}
|
|
|
|
} while(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_scene_main_start_favorite(Desktop* desktop, FavoriteApp* application) {
|
|
|
|
LoaderStatus status = LoaderStatusErrorInternal;
|
|
|
|
if(application->is_external) {
|
|
|
|
status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, application->name_or_path);
|
|
|
|
} else if(strlen(application->name_or_path) > 0) {
|
|
|
|
status = loader_start(desktop->loader, application->name_or_path, NULL);
|
|
|
|
} else {
|
|
|
|
status = loader_start(desktop->loader, FAP_LOADER_APP_NAME, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(status != LoaderStatusOk) {
|
|
|
|
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
void desktop_scene_main_callback(DesktopEvent event, void* context) {
|
2021-09-28 12:40:39 +03:00
|
|
|
Desktop* desktop = (Desktop*)context;
|
2023-03-09 11:24:47 +03:00
|
|
|
if(desktop->in_transition) return;
|
2021-09-28 12:40:39 +03:00
|
|
|
view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
|
|
|
|
}
|
|
|
|
|
2021-09-28 17:42:52 +03:00
|
|
|
void desktop_scene_main_on_enter(void* context) {
|
2021-09-28 12:40:39 +03:00
|
|
|
Desktop* desktop = (Desktop*)context;
|
|
|
|
DesktopMainView* main_view = desktop->main_view;
|
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
animation_manager_set_context(desktop->animation_manager, desktop);
|
|
|
|
animation_manager_set_new_idle_callback(
|
|
|
|
desktop->animation_manager, desktop_scene_main_new_idle_animation_callback);
|
|
|
|
animation_manager_set_check_callback(
|
|
|
|
desktop->animation_manager, desktop_scene_main_check_animation_callback);
|
|
|
|
animation_manager_set_interact_callback(
|
|
|
|
desktop->animation_manager, desktop_scene_main_interact_animation_callback);
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
desktop_main_set_callback(main_view, desktop_scene_main_callback, desktop);
|
|
|
|
|
2022-02-10 21:17:41 +03:00
|
|
|
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdMain);
|
2021-09-28 12:40:39 +03:00
|
|
|
}
|
|
|
|
|
2021-09-28 17:42:52 +03:00
|
|
|
bool desktop_scene_main_on_event(void* context, SceneManagerEvent event) {
|
2021-09-28 12:40:39 +03:00
|
|
|
Desktop* desktop = (Desktop*)context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
switch(event.event) {
|
2023-05-04 06:48:13 +03:00
|
|
|
case DesktopMainEventOpenMenu: {
|
|
|
|
Loader* loader = furi_record_open(RECORD_LOADER);
|
|
|
|
loader_show_menu(loader);
|
|
|
|
furi_record_close(RECORD_LOADER);
|
2021-09-28 12:40:39 +03:00
|
|
|
consumed = true;
|
2023-05-04 06:48:13 +03:00
|
|
|
} break;
|
2021-09-28 12:40:39 +03:00
|
|
|
|
|
|
|
case DesktopMainEventOpenLockMenu:
|
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLockMenu);
|
|
|
|
consumed = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DesktopMainEventOpenDebug:
|
2021-10-04 12:33:31 +03:00
|
|
|
scene_manager_next_scene(desktop->scene_manager, DesktopSceneDebug);
|
2021-09-28 12:40:39 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
|
|
|
|
2022-10-13 16:54:13 +03:00
|
|
|
case DesktopMainEventLock:
|
2023-05-11 17:47:14 +03:00
|
|
|
scene_manager_set_scene_state(desktop->scene_manager, DesktopSceneLockMenu, 0);
|
|
|
|
desktop_lock(desktop);
|
2022-10-13 16:54:13 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
case DesktopMainEventOpenArchive:
|
2021-12-24 21:47:48 +03:00
|
|
|
#ifdef APP_ARCHIVE
|
2021-09-28 12:40:39 +03:00
|
|
|
desktop_switch_to_app(desktop, &FLIPPER_ARCHIVE);
|
2021-12-24 21:47:48 +03:00
|
|
|
#endif
|
2021-09-28 12:40:39 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
2021-10-02 20:00:56 +03:00
|
|
|
|
2022-06-10 16:29:25 +03:00
|
|
|
case DesktopMainEventOpenPowerOff: {
|
|
|
|
LoaderStatus status = loader_start(desktop->loader, "Power", "off");
|
|
|
|
if(status != LoaderStatusOk) {
|
|
|
|
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
|
|
|
}
|
|
|
|
consumed = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-06-10 15:38:16 +03:00
|
|
|
case DesktopMainEventOpenFavoritePrimary:
|
2022-09-17 00:43:21 +03:00
|
|
|
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_primary);
|
2022-06-10 15:38:16 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
|
|
|
case DesktopMainEventOpenFavoriteSecondary:
|
2022-09-17 00:43:21 +03:00
|
|
|
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_secondary);
|
2021-09-28 12:40:39 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
2023-03-18 01:16:34 +03:00
|
|
|
case DesktopMainEventOpenFavoriteTertiary:
|
|
|
|
DESKTOP_SETTINGS_LOAD(&desktop->settings);
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_start_favorite(desktop, &desktop->settings.favorite_tertiary);
|
2023-03-18 01:16:34 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
2022-02-10 21:17:41 +03:00
|
|
|
case DesktopAnimationEventCheckAnimation:
|
2022-01-03 00:39:56 +03:00
|
|
|
animation_manager_check_blocking_process(desktop->animation_manager);
|
2021-11-24 19:21:12 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
2022-02-10 21:17:41 +03:00
|
|
|
case DesktopAnimationEventNewIdleAnimation:
|
2022-01-03 00:39:56 +03:00
|
|
|
animation_manager_new_idle_process(desktop->animation_manager);
|
|
|
|
consumed = true;
|
|
|
|
break;
|
2022-02-10 21:17:41 +03:00
|
|
|
case DesktopAnimationEventInteractAnimation:
|
2022-04-18 15:34:18 +03:00
|
|
|
if(!animation_manager_interact_process(desktop->animation_manager)) {
|
|
|
|
LoaderStatus status = loader_start(desktop->loader, "Passport", NULL);
|
|
|
|
if(status != LoaderStatusOk) {
|
|
|
|
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
|
|
|
}
|
|
|
|
}
|
2022-01-03 00:39:56 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
2022-09-17 00:43:21 +03:00
|
|
|
case DesktopMainEventOpenPassport: {
|
|
|
|
LoaderStatus status = loader_start(desktop->loader, "Passport", NULL);
|
|
|
|
if(status != LoaderStatusOk) {
|
|
|
|
FURI_LOG_E(TAG, "loader_start failed: %d", status);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DesktopMainEventOpenGameMenu: {
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Snake.fap"));
|
2022-09-17 00:43:21 +03:00
|
|
|
break;
|
|
|
|
}
|
2022-10-27 02:19:14 +03:00
|
|
|
case DesktopMainEventOpenTetris: {
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Tetris.fap"));
|
2022-10-27 02:19:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DesktopMainEventOpenArkanoid: {
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Arkanoid.fap"));
|
2022-10-27 02:19:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DesktopMainEventOpenDOOM: {
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/DOOM.fap"));
|
2022-10-27 02:19:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DesktopMainEventOpenZombiez: {
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_open_app_or_profile(desktop, EXT_PATH("/apps/Games/Zombiez.fap"));
|
2022-10-27 02:19:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DesktopMainEventOpenHeap: {
|
2023-05-26 13:13:46 +03:00
|
|
|
desktop_scene_main_open_app_or_profile(
|
|
|
|
desktop, EXT_PATH("/apps/Games/heap_defence.fap"));
|
2022-10-27 02:19:14 +03:00
|
|
|
break;
|
|
|
|
}
|
2022-02-10 21:17:41 +03:00
|
|
|
case DesktopLockedEventUpdate:
|
|
|
|
desktop_view_locked_update(desktop->locked_view);
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
consumed = true;
|
|
|
|
break;
|
2021-11-24 19:21:12 +03:00
|
|
|
|
2021-09-28 12:40:39 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
2021-09-28 17:42:52 +03:00
|
|
|
void desktop_scene_main_on_exit(void* context) {
|
2021-09-28 12:40:39 +03:00
|
|
|
Desktop* desktop = (Desktop*)context;
|
2021-11-24 19:21:12 +03:00
|
|
|
|
2022-01-03 00:39:56 +03:00
|
|
|
animation_manager_set_new_idle_callback(desktop->animation_manager, NULL);
|
|
|
|
animation_manager_set_check_callback(desktop->animation_manager, NULL);
|
|
|
|
animation_manager_set_interact_callback(desktop->animation_manager, NULL);
|
|
|
|
animation_manager_set_context(desktop->animation_manager, desktop);
|
2021-09-28 12:40:39 +03:00
|
|
|
}
|