[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 09:20:41 +00:00
|
|
|
#include <gui/gui_i.h>
|
|
|
|
#include <gui/view.h>
|
|
|
|
#include <gui/elements.h>
|
|
|
|
#include <gui/canvas.h>
|
2021-09-28 09:40:39 +00:00
|
|
|
#include <furi.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 09:20:41 +00:00
|
|
|
#include <input/input.h>
|
|
|
|
#include <dolphin/dolphin.h>
|
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
#include "../desktop_i.h"
|
2022-02-10 18:17:41 +00:00
|
|
|
#include "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 09:20:41 +00:00
|
|
|
|
|
|
|
struct DesktopMainView {
|
|
|
|
View* view;
|
|
|
|
DesktopMainViewCallback callback;
|
|
|
|
void* context;
|
2022-06-13 02:40:57 +00:00
|
|
|
TimerHandle_t poweroff_timer;
|
[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 09:20:41 +00:00
|
|
|
};
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2022-08-05 15:45:18 +00:00
|
|
|
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 3000
|
2022-06-13 02:40:57 +00:00
|
|
|
|
|
|
|
static void desktop_main_poweroff_timer_callback(TimerHandle_t timer) {
|
|
|
|
DesktopMainView* main_view = pvTimerGetTimerID(timer);
|
|
|
|
main_view->callback(DesktopMainEventOpenPowerOff, main_view->context);
|
|
|
|
}
|
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
void desktop_main_set_callback(
|
|
|
|
DesktopMainView* main_view,
|
|
|
|
DesktopMainViewCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
furi_assert(callback);
|
|
|
|
main_view->callback = callback;
|
|
|
|
main_view->context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
View* desktop_main_get_view(DesktopMainView* main_view) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
return main_view->view;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool desktop_main_input(InputEvent* event, void* context) {
|
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
DesktopMainView* main_view = context;
|
|
|
|
|
2022-01-30 16:45:08 +00:00
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(event->key == InputKeyOk) {
|
|
|
|
main_view->callback(DesktopMainEventOpenMenu, main_view->context);
|
|
|
|
} else if(event->key == InputKeyUp) {
|
|
|
|
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
|
|
|
main_view->callback(DesktopMainEventOpenArchive, main_view->context);
|
|
|
|
} else if(event->key == InputKeyLeft) {
|
2022-06-10 12:38:16 +00:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoritePrimary, main_view->context);
|
2022-01-30 16:45:08 +00:00
|
|
|
} else if(event->key == InputKeyRight) {
|
2022-04-18 12:34:18 +00:00
|
|
|
main_view->callback(DesktopMainEventOpenPassport, main_view->context);
|
2022-01-30 16:45:08 +00:00
|
|
|
}
|
|
|
|
} else if(event->type == InputTypeLong) {
|
|
|
|
if(event->key == InputKeyDown) {
|
|
|
|
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
|
2022-06-10 12:38:16 +00:00
|
|
|
} else if(event->key == InputKeyLeft) {
|
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context);
|
2022-06-13 02:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack) {
|
|
|
|
if(event->type == InputTypePress) {
|
|
|
|
xTimerChangePeriod(
|
|
|
|
main_view->poweroff_timer,
|
|
|
|
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
|
|
|
|
portMAX_DELAY);
|
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
|
xTimerStop(main_view->poweroff_timer, portMAX_DELAY);
|
2022-01-30 16:45:08 +00:00
|
|
|
}
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
2021-10-26 18:34:31 +00:00
|
|
|
|
2022-01-30 16:45:08 +00:00
|
|
|
return true;
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DesktopMainView* desktop_main_alloc() {
|
2022-02-18 19:53:46 +00:00
|
|
|
DesktopMainView* main_view = malloc(sizeof(DesktopMainView));
|
2022-01-02 21:39:56 +00:00
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
main_view->view = view_alloc();
|
[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 09:20:41 +00:00
|
|
|
view_allocate_model(main_view->view, ViewModelTypeLockFree, 1);
|
2021-09-28 09:40:39 +00:00
|
|
|
view_set_context(main_view->view, main_view);
|
|
|
|
view_set_input_callback(main_view->view, desktop_main_input);
|
|
|
|
|
2022-06-13 02:40:57 +00:00
|
|
|
main_view->poweroff_timer = xTimerCreate(
|
|
|
|
NULL,
|
|
|
|
pdMS_TO_TICKS(DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT),
|
|
|
|
pdFALSE,
|
|
|
|
main_view,
|
|
|
|
desktop_main_poweroff_timer_callback);
|
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
return main_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_main_free(DesktopMainView* main_view) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
view_free(main_view->view);
|
2022-07-20 10:56:33 +00:00
|
|
|
furi_timer_free(main_view->poweroff_timer);
|
2021-09-28 09:40:39 +00:00
|
|
|
free(main_view);
|
|
|
|
}
|