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 <gui/elements.h>
|
2022-10-28 14:08:50 +00:00
|
|
|
#include <assets_icons.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
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
#include "../desktop_i.h"
|
2022-02-10 18:17:41 +00:00
|
|
|
#include "desktop_view_lock_menu.h"
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
typedef enum {
|
|
|
|
DesktopLockMenuIndexLock,
|
2023-04-19 09:33:23 +00:00
|
|
|
DesktopLockMenuIndexStealth,
|
2022-09-19 13:03:42 +00:00
|
|
|
DesktopLockMenuIndexDummy,
|
|
|
|
|
|
|
|
DesktopLockMenuIndexTotalCount
|
|
|
|
} DesktopLockMenuIndex;
|
2022-01-29 09:39:10 +00:00
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
void desktop_lock_menu_set_callback(
|
|
|
|
DesktopLockMenuView* lock_menu,
|
|
|
|
DesktopLockMenuViewCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(lock_menu);
|
|
|
|
furi_assert(callback);
|
|
|
|
lock_menu->callback = callback;
|
|
|
|
lock_menu->context = context;
|
|
|
|
}
|
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
void desktop_lock_menu_set_pin_state(DesktopLockMenuView* lock_menu, bool pin_is_set) {
|
2021-10-26 18:34:31 +00:00
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
lock_menu->view,
|
|
|
|
DesktopLockMenuViewModel * model,
|
|
|
|
{ model->pin_is_set = pin_is_set; },
|
|
|
|
true);
|
2021-10-26 18:34:31 +00:00
|
|
|
}
|
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool dummy_mode) {
|
2021-09-28 09:40:39 +00:00
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
lock_menu->view,
|
|
|
|
DesktopLockMenuViewModel * model,
|
|
|
|
{ model->dummy_mode = dummy_mode; },
|
|
|
|
true);
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 09:33:23 +00:00
|
|
|
void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bool stealth_mode) {
|
|
|
|
with_view_model(
|
|
|
|
lock_menu->view,
|
|
|
|
DesktopLockMenuViewModel * model,
|
|
|
|
{ model->stealth_mode = stealth_mode; },
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx) {
|
|
|
|
furi_assert(idx < DesktopLockMenuIndexTotalCount);
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
lock_menu->view, DesktopLockMenuViewModel * model, { model->idx = idx; }, true);
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
|
2021-09-28 09:40:39 +00:00
|
|
|
DesktopLockMenuViewModel* m = model;
|
2022-09-19 13:03:42 +00:00
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
canvas_set_color(canvas, ColorBlack);
|
2021-11-26 12:19:30 +00:00
|
|
|
canvas_draw_icon(canvas, -57, 0 + STATUS_BAR_Y_SHIFT, &I_DoorLeft_70x55);
|
|
|
|
canvas_draw_icon(canvas, 116, 0 + STATUS_BAR_Y_SHIFT, &I_DoorRight_70x55);
|
2021-09-28 09:40:39 +00:00
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
2022-12-26 12:13:30 +00:00
|
|
|
for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) {
|
2022-09-19 13:03:42 +00:00
|
|
|
const char* str = NULL;
|
2021-10-26 18:34:31 +00:00
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
if(i == DesktopLockMenuIndexLock) {
|
|
|
|
str = "Lock";
|
2023-04-19 09:33:23 +00:00
|
|
|
} else if(i == DesktopLockMenuIndexStealth) {
|
|
|
|
if(m->stealth_mode) {
|
|
|
|
str = "Sound Mode";
|
2022-09-19 13:03:42 +00:00
|
|
|
} else {
|
2023-04-19 09:33:23 +00:00
|
|
|
str = "Stealth Mode";
|
2022-09-19 13:03:42 +00:00
|
|
|
}
|
2022-12-26 12:13:30 +00:00
|
|
|
} else if(i == DesktopLockMenuIndexDummy) { //-V547
|
2022-09-19 13:03:42 +00:00
|
|
|
if(m->dummy_mode) {
|
|
|
|
str = "Brainiac Mode";
|
|
|
|
} else {
|
|
|
|
str = "Dummy Mode";
|
|
|
|
}
|
|
|
|
}
|
2021-10-26 18:34:31 +00:00
|
|
|
|
2022-12-26 12:13:30 +00:00
|
|
|
if(str) //-V547
|
2022-01-29 09:39:10 +00:00
|
|
|
canvas_draw_str_aligned(
|
|
|
|
canvas, 64, 9 + (i * 17) + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter, str);
|
2021-10-26 18:34:31 +00:00
|
|
|
|
2021-11-26 12:19:30 +00:00
|
|
|
if(m->idx == i) elements_frame(canvas, 15, 1 + (i * 17) + STATUS_BAR_Y_SHIFT, 98, 15);
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu) {
|
|
|
|
furi_assert(lock_menu);
|
|
|
|
return lock_menu->view;
|
|
|
|
}
|
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
bool desktop_lock_menu_input_callback(InputEvent* event, void* context) {
|
2021-09-28 09:40:39 +00:00
|
|
|
furi_assert(event);
|
|
|
|
furi_assert(context);
|
|
|
|
|
|
|
|
DesktopLockMenuView* lock_menu = context;
|
2022-09-19 13:03:42 +00:00
|
|
|
uint8_t idx = 0;
|
|
|
|
bool consumed = false;
|
|
|
|
bool dummy_mode = false;
|
2023-04-19 09:33:23 +00:00
|
|
|
bool stealth_mode = false;
|
|
|
|
bool pin_is_set = false;
|
2022-10-08 17:38:29 +00:00
|
|
|
bool update = false;
|
2021-09-28 09:40:39 +00:00
|
|
|
|
|
|
|
with_view_model(
|
2022-10-08 17:38:29 +00:00
|
|
|
lock_menu->view,
|
|
|
|
DesktopLockMenuViewModel * model,
|
|
|
|
{
|
2022-09-19 13:03:42 +00:00
|
|
|
if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
|
|
|
|
if(event->key == InputKeyUp) {
|
|
|
|
if(model->idx == 0) {
|
|
|
|
model->idx = DesktopLockMenuIndexTotalCount - 1;
|
|
|
|
} else {
|
|
|
|
model->idx = CLAMP(model->idx - 1, DesktopLockMenuIndexTotalCount - 1, 0);
|
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
update = true;
|
2022-09-19 13:03:42 +00:00
|
|
|
consumed = true;
|
|
|
|
} else if(event->key == InputKeyDown) {
|
|
|
|
if(model->idx == DesktopLockMenuIndexTotalCount - 1) {
|
|
|
|
model->idx = 0;
|
|
|
|
} else {
|
|
|
|
model->idx = CLAMP(model->idx + 1, DesktopLockMenuIndexTotalCount - 1, 0);
|
|
|
|
}
|
2022-10-08 17:38:29 +00:00
|
|
|
update = true;
|
2022-09-19 13:03:42 +00:00
|
|
|
consumed = true;
|
|
|
|
}
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
idx = model->idx;
|
2022-09-19 13:03:42 +00:00
|
|
|
dummy_mode = model->dummy_mode;
|
2023-04-19 09:33:23 +00:00
|
|
|
stealth_mode = model->stealth_mode;
|
|
|
|
pin_is_set = model->pin_is_set;
|
2022-10-08 17:38:29 +00:00
|
|
|
},
|
|
|
|
update);
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
if(event->key == InputKeyOk) {
|
2023-04-19 09:33:23 +00:00
|
|
|
if((idx == DesktopLockMenuIndexLock)) {
|
2023-04-24 23:09:29 +00:00
|
|
|
if((pin_is_set) && (event->type == InputTypeLong)) {
|
2023-04-19 09:33:23 +00:00
|
|
|
lock_menu->callback(DesktopLockMenuEventPinLock, lock_menu->context);
|
2023-04-24 23:09:29 +00:00
|
|
|
} else if(event->type == InputTypeShort) {
|
2023-04-19 09:33:23 +00:00
|
|
|
lock_menu->callback(DesktopLockMenuEventLock, lock_menu->context);
|
|
|
|
}
|
|
|
|
} else if(idx == DesktopLockMenuIndexStealth) {
|
|
|
|
if((stealth_mode == false) && (event->type == InputTypeShort)) {
|
|
|
|
lock_menu->callback(DesktopLockMenuEventStealthModeOn, lock_menu->context);
|
|
|
|
} else if((stealth_mode == true) && (event->type == InputTypeShort)) {
|
|
|
|
lock_menu->callback(DesktopLockMenuEventStealthModeOff, lock_menu->context);
|
|
|
|
}
|
2022-09-19 13:03:42 +00:00
|
|
|
} else if(idx == DesktopLockMenuIndexDummy) {
|
|
|
|
if((dummy_mode == false) && (event->type == InputTypeShort)) {
|
|
|
|
lock_menu->callback(DesktopLockMenuEventDummyModeOn, lock_menu->context);
|
|
|
|
} else if((dummy_mode == true) && (event->type == InputTypeShort)) {
|
|
|
|
lock_menu->callback(DesktopLockMenuEventDummyModeOff, lock_menu->context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
consumed = true;
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
2022-09-19 13:03:42 +00:00
|
|
|
return consumed;
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DesktopLockMenuView* desktop_lock_menu_alloc() {
|
2022-02-18 19:53:46 +00:00
|
|
|
DesktopLockMenuView* lock_menu = malloc(sizeof(DesktopLockMenuView));
|
2021-09-28 09:40:39 +00:00
|
|
|
lock_menu->view = view_alloc();
|
|
|
|
view_allocate_model(lock_menu->view, ViewModelTypeLocking, sizeof(DesktopLockMenuViewModel));
|
|
|
|
view_set_context(lock_menu->view, lock_menu);
|
2022-09-19 13:03:42 +00:00
|
|
|
view_set_draw_callback(lock_menu->view, (ViewDrawCallback)desktop_lock_menu_draw_callback);
|
|
|
|
view_set_input_callback(lock_menu->view, desktop_lock_menu_input_callback);
|
2021-09-28 09:40:39 +00:00
|
|
|
|
|
|
|
return lock_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_lock_menu_free(DesktopLockMenuView* lock_menu_view) {
|
|
|
|
furi_assert(lock_menu_view);
|
|
|
|
|
|
|
|
view_free(lock_menu_view->view);
|
|
|
|
free(lock_menu_view);
|
|
|
|
}
|