[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>
This commit is contained in:
17
applications/gui/canvas.c
Executable file → Normal file
17
applications/gui/canvas.c
Executable file → Normal file
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <stdint.h>
|
||||
#include <u8g2_glue.h>
|
||||
|
||||
const CanvasFontParameters canvas_font_params[FontTotalNumber] = {
|
||||
@@ -202,6 +203,22 @@ uint8_t canvas_glyph_width(Canvas* canvas, char symbol) {
|
||||
return u8g2_GetGlyphWidth(&canvas->fb, symbol);
|
||||
}
|
||||
|
||||
void canvas_draw_bitmap(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
const uint8_t* compressed_bitmap_data) {
|
||||
furi_assert(canvas);
|
||||
|
||||
x += canvas->offset_x;
|
||||
y += canvas->offset_y;
|
||||
uint8_t* bitmap_data = NULL;
|
||||
furi_hal_compress_icon_decode(compressed_bitmap_data, &bitmap_data);
|
||||
u8g2_DrawXBM(&canvas->fb, x, y, width, height, bitmap_data);
|
||||
}
|
||||
|
||||
void canvas_draw_icon_animation(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
|
@@ -178,6 +178,23 @@ uint16_t canvas_string_width(Canvas* canvas, const char* str);
|
||||
*/
|
||||
uint8_t canvas_glyph_width(Canvas* canvas, char symbol);
|
||||
|
||||
/** Draw bitmap picture at position defined by x,y.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width width of bitmap
|
||||
* @param height height of bitmap
|
||||
* @param compressed_bitmap_data compressed bitmap data
|
||||
*/
|
||||
void canvas_draw_bitmap(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
const uint8_t* compressed_bitmap_data);
|
||||
|
||||
/** Draw animation at position defined by x,y.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
|
@@ -3,6 +3,7 @@
|
||||
* GUI: internal Icon API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "icon.h"
|
||||
|
||||
struct Icon {
|
||||
|
@@ -1,166 +0,0 @@
|
||||
#include "gui/view.h"
|
||||
#include "furi/memmgr.h"
|
||||
#include "view_composed.h"
|
||||
#include "view_i.h"
|
||||
|
||||
typedef struct {
|
||||
View* bottom;
|
||||
View* top;
|
||||
bool top_enabled;
|
||||
} ViewComposedModel;
|
||||
|
||||
struct ViewComposed {
|
||||
View* view;
|
||||
};
|
||||
|
||||
static void view_composed_draw(Canvas* canvas, void* model);
|
||||
static bool view_composed_input(InputEvent* event, void* context);
|
||||
|
||||
static void view_composed_update_callback(View* view_top_or_bottom, void* context) {
|
||||
furi_assert(view_top_or_bottom);
|
||||
furi_assert(context);
|
||||
|
||||
View* view_composed_view = context;
|
||||
view_composed_view->update_callback(
|
||||
view_composed_view, view_composed_view->update_callback_context);
|
||||
}
|
||||
|
||||
static void view_composed_enter(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
ViewComposed* view_composed = context;
|
||||
ViewComposedModel* model = view_get_model(view_composed->view);
|
||||
|
||||
/* if more than 1 composed views hold same view it has to reassign update_callback_context */
|
||||
if(model->bottom) {
|
||||
view_set_update_callback_context(model->bottom, view_composed->view);
|
||||
if(model->bottom->enter_callback) {
|
||||
model->bottom->enter_callback(model->bottom->context);
|
||||
}
|
||||
}
|
||||
if(model->top) {
|
||||
view_set_update_callback_context(model->top, view_composed->view);
|
||||
if(model->top->enter_callback) {
|
||||
model->top->enter_callback(model->top->context);
|
||||
}
|
||||
}
|
||||
|
||||
view_commit_model(view_composed->view, false);
|
||||
}
|
||||
|
||||
static void view_composed_exit(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
ViewComposed* view_composed = context;
|
||||
ViewComposedModel* model = view_get_model(view_composed->view);
|
||||
|
||||
if(model->bottom) {
|
||||
if(model->bottom->exit_callback) {
|
||||
model->bottom->exit_callback(model->bottom->context);
|
||||
}
|
||||
}
|
||||
if(model->top) {
|
||||
if(model->top->exit_callback) {
|
||||
model->top->exit_callback(model->top->context);
|
||||
}
|
||||
}
|
||||
|
||||
view_commit_model(view_composed->view, false);
|
||||
}
|
||||
|
||||
ViewComposed* view_composed_alloc(void) {
|
||||
ViewComposed* view_composed = furi_alloc(sizeof(ViewComposed));
|
||||
view_composed->view = view_alloc();
|
||||
|
||||
view_allocate_model(view_composed->view, ViewModelTypeLocking, sizeof(ViewComposedModel));
|
||||
view_set_draw_callback(view_composed->view, view_composed_draw);
|
||||
view_set_input_callback(view_composed->view, view_composed_input);
|
||||
view_set_context(view_composed->view, view_composed);
|
||||
view_set_enter_callback(view_composed->view, view_composed_enter);
|
||||
view_set_exit_callback(view_composed->view, view_composed_exit);
|
||||
return view_composed;
|
||||
}
|
||||
|
||||
void view_composed_free(ViewComposed* view_composed) {
|
||||
furi_assert(view_composed);
|
||||
|
||||
ViewComposedModel* view_composed_model = view_get_model(view_composed->view);
|
||||
view_set_update_callback(view_composed_model->bottom, NULL);
|
||||
view_set_update_callback_context(view_composed_model->bottom, NULL);
|
||||
view_set_update_callback(view_composed_model->top, NULL);
|
||||
view_set_update_callback_context(view_composed_model->top, NULL);
|
||||
view_commit_model(view_composed->view, true);
|
||||
|
||||
view_free(view_composed->view);
|
||||
free(view_composed);
|
||||
}
|
||||
|
||||
static void view_composed_draw(Canvas* canvas, void* model) {
|
||||
furi_assert(model);
|
||||
|
||||
ViewComposedModel* view_composed_model = model;
|
||||
|
||||
view_draw(view_composed_model->bottom, canvas);
|
||||
if(view_composed_model->top_enabled && view_composed_model->top) {
|
||||
view_draw(view_composed_model->top, canvas);
|
||||
}
|
||||
}
|
||||
|
||||
static bool view_composed_input(InputEvent* event, void* context) {
|
||||
furi_assert(event);
|
||||
furi_assert(context);
|
||||
|
||||
ViewComposed* view_composed = context;
|
||||
ViewComposedModel* view_composed_model = view_get_model(view_composed->view);
|
||||
bool consumed = false;
|
||||
|
||||
if(view_composed_model->top_enabled && view_composed_model->top) {
|
||||
consumed = view_input(view_composed_model->top, event);
|
||||
}
|
||||
if(!consumed) {
|
||||
consumed = view_input(view_composed_model->bottom, event);
|
||||
}
|
||||
|
||||
view_commit_model(view_composed->view, false);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void view_composed_top_enable(ViewComposed* view_composed, bool enable) {
|
||||
furi_assert(view_composed);
|
||||
|
||||
ViewComposedModel* view_composed_model = view_get_model(view_composed->view);
|
||||
bool update = (view_composed_model->top_enabled != enable);
|
||||
view_composed_model->top_enabled = enable;
|
||||
view_commit_model(view_composed->view, update);
|
||||
}
|
||||
|
||||
void view_composed_tie_views(ViewComposed* view_composed, View* view_bottom, View* view_top) {
|
||||
furi_assert(view_composed);
|
||||
furi_assert(view_bottom);
|
||||
|
||||
ViewComposedModel* view_composed_model = view_get_model(view_composed->view);
|
||||
|
||||
if(view_composed_model->bottom) {
|
||||
view_set_update_callback(view_composed_model->bottom, NULL);
|
||||
view_set_update_callback_context(view_composed_model->bottom, NULL);
|
||||
}
|
||||
if(view_composed_model->top) {
|
||||
view_set_update_callback(view_composed_model->top, NULL);
|
||||
view_set_update_callback_context(view_composed_model->top, NULL);
|
||||
}
|
||||
|
||||
view_composed_model->bottom = view_bottom;
|
||||
view_set_update_callback(view_bottom, view_composed_update_callback);
|
||||
view_set_update_callback_context(view_bottom, view_composed->view);
|
||||
view_composed_model->top = view_top;
|
||||
view_set_update_callback(view_top, view_composed_update_callback);
|
||||
view_set_update_callback_context(view_top, view_composed->view);
|
||||
|
||||
view_commit_model(view_composed->view, true);
|
||||
}
|
||||
|
||||
View* view_composed_get_view(ViewComposed* view_composed) {
|
||||
furi_assert(view_composed);
|
||||
return view_composed->view;
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "view.h"
|
||||
|
||||
typedef struct ViewComposed ViewComposed;
|
||||
|
||||
ViewComposed* view_composed_alloc(void);
|
||||
void view_composed_free(ViewComposed* view_composed);
|
||||
void view_composed_top_enable(ViewComposed* view_composed, bool enable);
|
||||
void view_composed_tie_views(ViewComposed* view_composed, View* view_bottom, View* view_top);
|
||||
View* view_composed_get_view(ViewComposed* view_composed);
|
165
applications/gui/view_stack.c
Normal file
165
applications/gui/view_stack.c
Normal file
@@ -0,0 +1,165 @@
|
||||
#include "gui/view.h"
|
||||
#include "furi/memmgr.h"
|
||||
#include "view_stack.h"
|
||||
#include "view_i.h"
|
||||
|
||||
#define MAX_VIEWS 3
|
||||
|
||||
typedef struct {
|
||||
View* views[MAX_VIEWS];
|
||||
} ViewStackModel;
|
||||
|
||||
struct ViewStack {
|
||||
View* view;
|
||||
};
|
||||
|
||||
static void view_stack_draw(Canvas* canvas, void* model);
|
||||
static bool view_stack_input(InputEvent* event, void* context);
|
||||
|
||||
static void view_stack_update_callback(View* view_top_or_bottom, void* context) {
|
||||
furi_assert(view_top_or_bottom);
|
||||
furi_assert(context);
|
||||
|
||||
View* view_stack_view = context;
|
||||
if(view_stack_view->update_callback) {
|
||||
view_stack_view->update_callback(
|
||||
view_stack_view, view_stack_view->update_callback_context);
|
||||
}
|
||||
}
|
||||
|
||||
static void view_stack_enter(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
ViewStack* view_stack = context;
|
||||
ViewStackModel* model = view_get_model(view_stack->view);
|
||||
|
||||
/* if more than 1 composite views hold same view they have to reassign update_callback_context */
|
||||
for(int i = 0; i < MAX_VIEWS; ++i) {
|
||||
if(model->views[i]) {
|
||||
view_set_update_callback_context(model->views[i], view_stack->view);
|
||||
if(model->views[i]->enter_callback) {
|
||||
model->views[i]->enter_callback(model->views[i]->context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
view_commit_model(view_stack->view, false);
|
||||
}
|
||||
|
||||
static void view_stack_exit(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
ViewStack* view_stack = context;
|
||||
ViewStackModel* model = view_get_model(view_stack->view);
|
||||
|
||||
for(int i = 0; i < MAX_VIEWS; ++i) {
|
||||
if(model->views[i] && model->views[i]->exit_callback) {
|
||||
model->views[i]->exit_callback(model->views[i]->context);
|
||||
}
|
||||
}
|
||||
|
||||
view_commit_model(view_stack->view, false);
|
||||
}
|
||||
|
||||
ViewStack* view_stack_alloc(void) {
|
||||
ViewStack* view_stack = furi_alloc(sizeof(ViewStack));
|
||||
view_stack->view = view_alloc();
|
||||
|
||||
view_allocate_model(view_stack->view, ViewModelTypeLocking, sizeof(ViewStackModel));
|
||||
view_set_draw_callback(view_stack->view, view_stack_draw);
|
||||
view_set_input_callback(view_stack->view, view_stack_input);
|
||||
view_set_context(view_stack->view, view_stack);
|
||||
view_set_enter_callback(view_stack->view, view_stack_enter);
|
||||
view_set_exit_callback(view_stack->view, view_stack_exit);
|
||||
return view_stack;
|
||||
}
|
||||
|
||||
void view_stack_free(ViewStack* view_stack) {
|
||||
furi_assert(view_stack);
|
||||
|
||||
ViewStackModel* model = view_get_model(view_stack->view);
|
||||
for(int i = 0; i < MAX_VIEWS; ++i) {
|
||||
if(model->views[i]) {
|
||||
view_set_update_callback(model->views[i], NULL);
|
||||
view_set_update_callback_context(model->views[i], NULL);
|
||||
}
|
||||
}
|
||||
view_commit_model(view_stack->view, false);
|
||||
|
||||
view_free(view_stack->view);
|
||||
free(view_stack);
|
||||
}
|
||||
|
||||
static void view_stack_draw(Canvas* canvas, void* _model) {
|
||||
furi_assert(_model);
|
||||
|
||||
ViewStackModel* model = _model;
|
||||
for(int i = 0; i < MAX_VIEWS; ++i) {
|
||||
if(model->views[i]) {
|
||||
view_draw(model->views[i], canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool view_stack_input(InputEvent* event, void* context) {
|
||||
furi_assert(event);
|
||||
furi_assert(context);
|
||||
|
||||
bool consumed = false;
|
||||
ViewStack* view_stack = context;
|
||||
|
||||
ViewStackModel* model = view_get_model(view_stack->view);
|
||||
for(int i = MAX_VIEWS - 1; !consumed && (i >= 0); --i) {
|
||||
if(model->views[i]) {
|
||||
consumed = view_input(model->views[i], event);
|
||||
}
|
||||
}
|
||||
view_commit_model(view_stack->view, false);
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void view_stack_add_view(ViewStack* view_stack, View* view) {
|
||||
furi_assert(view_stack);
|
||||
furi_assert(view);
|
||||
|
||||
bool result = false;
|
||||
ViewStackModel* model = view_get_model(view_stack->view);
|
||||
for(int i = 0; i < MAX_VIEWS; ++i) {
|
||||
if(!model->views[i]) {
|
||||
model->views[i] = view;
|
||||
view_set_update_callback(model->views[i], view_stack_update_callback);
|
||||
view_set_update_callback_context(model->views[i], view_stack->view);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
view_commit_model(view_stack->view, result);
|
||||
furi_assert(result);
|
||||
}
|
||||
|
||||
void view_stack_remove_view(ViewStack* view_stack, View* view) {
|
||||
furi_assert(view_stack);
|
||||
furi_assert(view);
|
||||
|
||||
/* Removing view on-the-go is dangerous, but it is protected with
|
||||
* Locking model, so system is consistent at any time. */
|
||||
bool result = false;
|
||||
ViewStackModel* model = view_get_model(view_stack->view);
|
||||
for(int i = 0; i < MAX_VIEWS; ++i) {
|
||||
if(model->views[i] == view) {
|
||||
view_set_update_callback(model->views[i], NULL);
|
||||
view_set_update_callback_context(model->views[i], NULL);
|
||||
model->views[i] = NULL;
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
view_commit_model(view_stack->view, result);
|
||||
furi_assert(result);
|
||||
}
|
||||
|
||||
View* view_stack_get_view(ViewStack* view_stack) {
|
||||
furi_assert(view_stack);
|
||||
return view_stack->view;
|
||||
}
|
53
applications/gui/view_stack.h
Normal file
53
applications/gui/view_stack.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file view_stack.h
|
||||
* GUI: ViewStack API
|
||||
*
|
||||
* ViewStack accumulates several Views in one stack.
|
||||
* Draw callbacks are called sequenctially starting from
|
||||
* first added. Input callbacks are called in reverse order.
|
||||
* Consumed input is not passed on underlying layers.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "view.h"
|
||||
|
||||
/** ViewStack, anonymous type. */
|
||||
typedef struct ViewStack ViewStack;
|
||||
|
||||
/** Allocate and init ViewStack
|
||||
*
|
||||
* @return ViewStack instance
|
||||
*/
|
||||
ViewStack* view_stack_alloc(void);
|
||||
|
||||
/** Free ViewStack instance
|
||||
*
|
||||
* @param view_stack instance
|
||||
*/
|
||||
void view_stack_free(ViewStack* view_stack);
|
||||
|
||||
/** Get View of ViewStack.
|
||||
* Should this View to any view manager such as
|
||||
* ViewDispatcher or ViewHolder.
|
||||
*
|
||||
* @param view_stack instance
|
||||
*/
|
||||
View* view_stack_get_view(ViewStack* view_stack);
|
||||
|
||||
/** Add View to ViewStack.
|
||||
* Adds View on top of ViewStack.
|
||||
*
|
||||
* @param view_stack instance
|
||||
* @view view view to add
|
||||
*/
|
||||
void view_stack_add_view(ViewStack* view_stack, View* view);
|
||||
|
||||
/** Remove any View in ViewStack.
|
||||
* If no View to remove found - ignore.
|
||||
*
|
||||
* @param view_stack instance
|
||||
* @view view view to remove
|
||||
*/
|
||||
void view_stack_remove_view(ViewStack* view_stack, View* view);
|
Reference in New Issue
Block a user