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 <furi_hal.h>
|
|
|
|
#include <gui/elements.h>
|
2021-09-28 09:40:39 +00:00
|
|
|
#include "../desktop_i.h"
|
|
|
|
#include "desktop_first_start.h"
|
|
|
|
|
2021-11-16 00:12:30 +00:00
|
|
|
#define DESKTOP_FIRST_START_POWEROFF_SHORT 5000
|
|
|
|
#define DESKTOP_FIRST_START_POWEROFF_LONG (60 * 60 * 1000)
|
|
|
|
|
|
|
|
struct DesktopFirstStartView {
|
|
|
|
View* view;
|
|
|
|
DesktopFirstStartViewCallback callback;
|
|
|
|
void* context;
|
|
|
|
osTimerId_t timer;
|
|
|
|
};
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2021-11-16 00:12:30 +00:00
|
|
|
typedef struct {
|
|
|
|
uint8_t page;
|
|
|
|
} DesktopFirstStartViewModel;
|
|
|
|
|
|
|
|
static void desktop_first_start_draw(Canvas* canvas, void* model) {
|
2021-09-28 09:40:39 +00:00
|
|
|
DesktopFirstStartViewModel* m = model;
|
|
|
|
|
|
|
|
canvas_clear(canvas);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
uint8_t width = canvas_width(canvas);
|
|
|
|
uint8_t height = canvas_height(canvas);
|
|
|
|
const char* my_name = furi_hal_version_get_name_ptr();
|
|
|
|
if(m->page == 0) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, 0, height - 51, &I_DolphinFirstStart0_70x53);
|
2021-11-26 12:19:30 +00:00
|
|
|
elements_multiline_text_framed(
|
|
|
|
canvas, 75, 16 + STATUS_BAR_Y_SHIFT, "Hey m8,\npress > to\ncontinue");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 1) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, 0, height - 51, &I_DolphinFirstStart1_59x53);
|
2021-11-26 12:19:30 +00:00
|
|
|
elements_multiline_text_framed(
|
|
|
|
canvas, 64, 16 + STATUS_BAR_Y_SHIFT, "First Of All,\n... >");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 2) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, 0, height - 51, &I_DolphinFirstStart2_59x51);
|
2021-11-26 12:19:30 +00:00
|
|
|
elements_multiline_text_framed(
|
|
|
|
canvas, 64, 16 + STATUS_BAR_Y_SHIFT, "Thank you\nfor your\nsupport! >");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 3) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, width - 57, height - 45, &I_DolphinFirstStart3_57x48);
|
2021-11-26 12:19:30 +00:00
|
|
|
elements_multiline_text_framed(
|
|
|
|
canvas, 0, 16 + STATUS_BAR_Y_SHIFT, "Kickstarter\ncampaign\nwas INSANE! >");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 4) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, width - 67, height - 51, &I_DolphinFirstStart4_67x53);
|
2021-11-26 12:19:30 +00:00
|
|
|
elements_multiline_text_framed(
|
|
|
|
canvas, 0, 13 + STATUS_BAR_Y_SHIFT, "Now\nallow me\nto introduce\nmyself >");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 5) {
|
|
|
|
char buf[64];
|
|
|
|
snprintf(
|
|
|
|
buf,
|
|
|
|
64,
|
|
|
|
"%s %s%s",
|
|
|
|
"I am",
|
|
|
|
my_name ? my_name : "Unknown",
|
2021-10-21 12:24:34 +00:00
|
|
|
",\ncyberdolphin\nliving in your\npocket >");
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, 0, height - 49, &I_DolphinFirstStart5_54x49);
|
2021-11-26 12:19:30 +00:00
|
|
|
elements_multiline_text_framed(canvas, 60, 13 + STATUS_BAR_Y_SHIFT, buf);
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 6) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, 0, height - 51, &I_DolphinFirstStart6_58x54);
|
2021-09-28 09:40:39 +00:00
|
|
|
elements_multiline_text_framed(
|
2021-11-26 12:19:30 +00:00
|
|
|
canvas,
|
|
|
|
63,
|
|
|
|
13 + STATUS_BAR_Y_SHIFT,
|
|
|
|
"I can grow\nsmart'n'cool\nif you use me\noften >");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 7) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, width - 61, height - 51, &I_DolphinFirstStart7_61x51);
|
2021-09-28 09:40:39 +00:00
|
|
|
elements_multiline_text_framed(
|
2021-11-26 12:19:30 +00:00
|
|
|
canvas, 0, 13 + STATUS_BAR_Y_SHIFT, "As long as\nyou read, write\nand emulate >");
|
2021-09-28 09:40:39 +00:00
|
|
|
} else if(m->page == 8) {
|
2021-11-24 16:21:12 +00:00
|
|
|
canvas_draw_icon(canvas, width - 56, height - 51, &I_DolphinFirstStart8_56x51);
|
2021-09-28 09:40:39 +00:00
|
|
|
elements_multiline_text_framed(
|
2021-11-26 12:19:30 +00:00
|
|
|
canvas,
|
|
|
|
0,
|
|
|
|
13 + STATUS_BAR_Y_SHIFT,
|
|
|
|
"You can check\nmy level and\nmood in the\nPassport menu");
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-16 00:12:30 +00:00
|
|
|
static bool desktop_first_start_input(InputEvent* event, void* context) {
|
2021-09-28 09:40:39 +00:00
|
|
|
furi_assert(event);
|
2021-11-16 00:12:30 +00:00
|
|
|
DesktopFirstStartView* instance = context;
|
2021-09-28 09:40:39 +00:00
|
|
|
|
|
|
|
if(event->type == InputTypeShort) {
|
2021-11-16 00:12:30 +00:00
|
|
|
DesktopFirstStartViewModel* model = view_get_model(instance->view);
|
2021-09-28 09:40:39 +00:00
|
|
|
if(event->key == InputKeyLeft) {
|
|
|
|
if(model->page > 0) model->page--;
|
|
|
|
} else if(event->key == InputKeyRight) {
|
|
|
|
uint32_t page = ++model->page;
|
|
|
|
if(page > 8) {
|
2021-11-16 00:12:30 +00:00
|
|
|
instance->callback(DesktopFirstStartCompleted, instance->context);
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-16 00:12:30 +00:00
|
|
|
view_commit_model(instance->view, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event->key == InputKeyOk) {
|
|
|
|
if(event->type == InputTypePress) {
|
|
|
|
osTimerStart(instance->timer, DESKTOP_FIRST_START_POWEROFF_SHORT);
|
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
|
osTimerStop(instance->timer);
|
|
|
|
}
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-11-16 00:12:30 +00:00
|
|
|
static void desktop_first_start_timer_callback(void* context) {
|
|
|
|
DesktopFirstStartView* instance = context;
|
|
|
|
instance->callback(DesktopFirstStartPoweroff, instance->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_first_start_enter(void* context) {
|
|
|
|
DesktopFirstStartView* instance = context;
|
|
|
|
|
|
|
|
furi_assert(instance->timer == NULL);
|
|
|
|
instance->timer = osTimerNew(desktop_first_start_timer_callback, osTimerOnce, instance, NULL);
|
|
|
|
|
|
|
|
osTimerStart(instance->timer, DESKTOP_FIRST_START_POWEROFF_LONG);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void desktop_first_start_exit(void* context) {
|
|
|
|
DesktopFirstStartView* instance = context;
|
|
|
|
|
|
|
|
osTimerStop(instance->timer);
|
|
|
|
osTimerDelete(instance->timer);
|
|
|
|
instance->timer = NULL;
|
|
|
|
}
|
|
|
|
|
2021-09-28 09:40:39 +00:00
|
|
|
DesktopFirstStartView* desktop_first_start_alloc() {
|
2021-11-16 00:12:30 +00:00
|
|
|
DesktopFirstStartView* instance = furi_alloc(sizeof(DesktopFirstStartView));
|
|
|
|
instance->view = view_alloc();
|
|
|
|
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(DesktopFirstStartViewModel));
|
|
|
|
view_set_context(instance->view, instance);
|
|
|
|
view_set_draw_callback(instance->view, (ViewDrawCallback)desktop_first_start_draw);
|
|
|
|
view_set_input_callback(instance->view, desktop_first_start_input);
|
|
|
|
view_set_enter_callback(instance->view, desktop_first_start_enter);
|
|
|
|
view_set_exit_callback(instance->view, desktop_first_start_exit);
|
|
|
|
|
|
|
|
return instance;
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|
|
|
|
|
2021-11-16 00:12:30 +00:00
|
|
|
void desktop_first_start_free(DesktopFirstStartView* instance) {
|
|
|
|
furi_assert(instance);
|
2021-09-28 09:40:39 +00:00
|
|
|
|
2021-11-16 00:12:30 +00:00
|
|
|
view_free(instance->view);
|
|
|
|
free(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
View* desktop_first_start_get_view(DesktopFirstStartView* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
return instance->view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void desktop_first_start_set_callback(
|
|
|
|
DesktopFirstStartView* instance,
|
|
|
|
DesktopFirstStartViewCallback callback,
|
|
|
|
void* context) {
|
|
|
|
furi_assert(instance);
|
|
|
|
furi_assert(callback);
|
|
|
|
instance->callback = callback;
|
|
|
|
instance->context = context;
|
2021-09-28 09:40:39 +00:00
|
|
|
}
|