[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;
|
2023-11-01 07:24:11 +00:00
|
|
|
FuriTimer* poweroff_timer;
|
2022-09-16 21:43:21 +00:00
|
|
|
bool dummy_mode;
|
[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
|
|
|
|
2023-02-24 00:04:36 +00:00
|
|
|
#define DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT 1300
|
2022-06-13 02:40:57 +00:00
|
|
|
|
2023-11-01 07:24:11 +00:00
|
|
|
static void desktop_main_poweroff_timer_callback(void* context) {
|
|
|
|
DesktopMainView* main_view = context;
|
2022-06-13 02:40:57 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-09-16 21:43:21 +00:00
|
|
|
void desktop_main_set_dummy_mode_state(DesktopMainView* main_view, bool dummy_mode) {
|
|
|
|
furi_assert(main_view);
|
|
|
|
main_view->dummy_mode = dummy_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool desktop_main_input_callback(InputEvent* event, void* context) {
|
2021-09-28 09:40:39 +00:00
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
DesktopMainView* main_view = context;
|
|
|
|
|
2022-09-16 21:43:21 +00:00
|
|
|
if(main_view->dummy_mode == false) {
|
|
|
|
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) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteLeftShort, main_view->context);
|
2022-09-16 21:43:21 +00:00
|
|
|
}
|
2023-08-17 10:04:40 +00:00
|
|
|
// Right key short is handled by animation manager
|
2022-09-16 21:43:21 +00:00
|
|
|
} else if(event->type == InputTypeLong) {
|
2023-08-17 10:04:40 +00:00
|
|
|
if(event->key == InputKeyUp) {
|
|
|
|
main_view->callback(DesktopMainEventLock, main_view->context);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
2022-09-16 21:43:21 +00:00
|
|
|
main_view->callback(DesktopMainEventOpenDebug, main_view->context);
|
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteLeftLong, main_view->context);
|
2023-03-17 22:16:34 +00:00
|
|
|
} else if(event->key == InputKeyRight) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopMainEventOpenFavoriteRightLong, main_view->context);
|
2022-10-28 14:30:53 +00:00
|
|
|
} else if(event->key == InputKeyOk) {
|
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context);
|
|
|
|
}
|
2022-09-16 21:43:21 +00:00
|
|
|
}
|
2022-01-30 16:45:08 +00:00
|
|
|
}
|
2022-09-16 21:43:21 +00:00
|
|
|
} else {
|
|
|
|
if(event->type == InputTypeShort) {
|
|
|
|
if(event->key == InputKeyOk) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopDummyEventOpenOk, main_view->context);
|
2022-09-16 21:43:21 +00:00
|
|
|
} else if(event->key == InputKeyUp) {
|
|
|
|
main_view->callback(DesktopMainEventOpenLockMenu, main_view->context);
|
|
|
|
} else if(event->key == InputKeyDown) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopDummyEventOpenDown, main_view->context);
|
2022-09-16 21:43:21 +00:00
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopDummyEventOpenLeft, main_view->context);
|
2022-09-16 21:43:21 +00:00
|
|
|
}
|
2023-08-17 10:04:40 +00:00
|
|
|
// Right key short is handled by animation manager
|
2022-10-26 23:19:14 +00:00
|
|
|
} else if(event->type == InputTypeLong) {
|
|
|
|
if(event->key == InputKeyOk) {
|
2023-08-17 10:40:55 +00:00
|
|
|
// Not working in DummyMode
|
|
|
|
// if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
// main_view->callback(DesktopAnimationEventNewIdleAnimation, main_view->context);
|
|
|
|
// }
|
|
|
|
main_view->callback(DesktopDummyEventOpenOkLong, main_view->context);
|
2022-10-26 23:19:14 +00:00
|
|
|
} else if(event->key == InputKeyUp) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopDummyEventOpenUpLong, main_view->context);
|
2022-10-26 23:19:14 +00:00
|
|
|
} else if(event->key == InputKeyDown) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopDummyEventOpenDownLong, main_view->context);
|
2022-10-26 23:19:14 +00:00
|
|
|
} else if(event->key == InputKeyLeft) {
|
2023-08-17 10:04:40 +00:00
|
|
|
main_view->callback(DesktopDummyEventOpenLeftLong, main_view->context);
|
2023-08-17 10:40:55 +00:00
|
|
|
} else if(event->key == InputKeyRight) {
|
|
|
|
main_view->callback(DesktopDummyEventOpenRightLong, main_view->context);
|
2022-10-26 23:19:14 +00:00
|
|
|
}
|
2022-06-13 02:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyBack) {
|
|
|
|
if(event->type == InputTypePress) {
|
2023-11-01 07:24:11 +00:00
|
|
|
furi_timer_start(main_view->poweroff_timer, DESKTOP_MAIN_VIEW_POWEROFF_TIMEOUT);
|
2022-06-13 02:40:57 +00:00
|
|
|
} else if(event->type == InputTypeRelease) {
|
2023-11-01 07:24:11 +00:00
|
|
|
furi_timer_stop(main_view->poweroff_timer);
|
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();
|
|
|
|
view_set_context(main_view->view, main_view);
|
2022-09-16 21:43:21 +00:00
|
|
|
view_set_input_callback(main_view->view, desktop_main_input_callback);
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2023-11-01 07:24:11 +00:00
|
|
|
main_view->poweroff_timer =
|
|
|
|
furi_timer_alloc(desktop_main_poweroff_timer_callback, FuriTimerTypeOnce, main_view);
|
2022-06-13 02:40:57 +00:00
|
|
|
|
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);
|
|
|
|
}
|