[FL-1181] Archive app (#458)

* fix stack size, file listing works
* fix scrollbar, update docs
* cut long filenames
* Dolphin: overhaul unlocking logic, unlocked message added
* furi - added common_defines.h, minor macro cleanup; fix scrollbar type conversion
* remove door opening animation
* adaptive long file name shortening, item icons, invert selection
* archive: browser tab, file types (beta);  scenes: fix sleep emote
* dont trim unknown extensions
* fix string_size usage
* array container for file list, fixes
* better path handling
* archive: renaming, adding to favorites worksl scrollbar fix: limit min bar height to 1px to prevent disappearance on large lists

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
its your bedtime
2021-05-18 21:54:56 +03:00
committed by GitHub
parent 725981f431
commit c97d766e5b
30 changed files with 1043 additions and 97 deletions

View File

@@ -60,31 +60,41 @@ bool dolphin_view_first_start_input(InputEvent* event, void* context) {
void dolphin_lock_handler(InputEvent* event, Dolphin* dolphin) {
furi_assert(event);
furi_assert(dolphin);
if(event->key == InputKeyBack) {
with_view_model(
dolphin->idle_view_main, (DolphinViewMainModel * model) {
model->hint_timeout = HINT_TIMEOUT_L;
return true;
});
if(event->key == InputKeyBack && event->type == InputTypeShort) {
uint32_t press_time = HAL_GetTick();
// check if pressed sequentially
if(press_time - dolphin->lock_lastpress < 200) {
dolphin->lock_lastpress = press_time;
dolphin->lock_count++;
} else if(press_time - dolphin->lock_lastpress > 200) {
if(press_time - dolphin->lock_lastpress > UNLOCK_RST_TIMEOUT) {
dolphin->lock_lastpress = press_time;
dolphin->lock_count = 0;
} else if(press_time - dolphin->lock_lastpress < UNLOCK_RST_TIMEOUT) {
dolphin->lock_lastpress = press_time;
dolphin->lock_count++;
}
if(dolphin->lock_count == 3) {
if(dolphin->lock_count == 2) {
dolphin->locked = false;
dolphin->lock_count = 0;
with_view_model(
dolphin->view_lockmenu, (DolphinViewLockMenuModel * model) {
model->locked = false;
model->door_left_x = -57; // move doors to default pos
model->door_right_x = 115;
return true;
});
with_view_model(
dolphin->idle_view_main, (DolphinViewMainModel * model) {
model->hint_timeout = 0;
model->hint_timeout = HINT_TIMEOUT_L; // "unlocked" hint timeout
model->locked = false;
return true;
});
@@ -112,9 +122,7 @@ bool dolphin_view_idle_main_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
dolphin_switch_to_app(dolphin, &FLIPPER_SCENE);
} else if(event->key == InputKeyDown && event->type == InputTypeShort) {
#if 0
dolphin_switch_to_app(dolphin, &ARCHIVE_APP);
#endif
dolphin_switch_to_app(dolphin, &FLIPPER_ARCHIVE);
} else if(event->key == InputKeyDown && event->type == InputTypeLong) {
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewStats);
} else if(event->key == InputKeyBack && event->type == InputTypeShort) {
@@ -123,12 +131,6 @@ bool dolphin_view_idle_main_input(InputEvent* event, void* context) {
} else {
// locked
with_view_model(
dolphin->idle_view_main, (DolphinViewMainModel * model) {
model->hint_timeout = 3;
return true;
});
dolphin_lock_handler(event, dolphin);
dolphin_scene_handler_switch_scene(dolphin);
}
@@ -151,14 +153,19 @@ static void lock_menu_callback(void* context, uint8_t index) {
// lock
case 0:
dolphin->locked = true;
DolphinViewLockMenuModel* model = view_get_model(dolphin->view_lockmenu);
model->locked = true;
model->exit_timeout = 20;
view_port_enabled_set(dolphin->lock_viewport, dolphin->locked);
view_commit_model(dolphin->view_lockmenu, true);
with_view_model(
dolphin->view_lockmenu, (DolphinViewLockMenuModel * model) {
model->locked = true;
model->exit_timeout = HINT_TIMEOUT_H;
return true;
});
with_view_model(
dolphin->idle_view_main, (DolphinViewMainModel * model) {
model->locked = true;
return true;
});
break;
default:

View File

@@ -14,6 +14,10 @@
#include <assets_icons.h>
#include <stdint.h>
#define UNLOCK_RST_TIMEOUT 500 // keypress counter reset timeout (ms)
#define HINT_TIMEOUT_L 3 // low refresh rate timeout (app ticks)
#define HINT_TIMEOUT_H 40 // high refresh rate timeout (app ticks)
typedef enum {
DolphinEventTypeDeed,
DolphinEventTypeSave,

View File

@@ -65,8 +65,13 @@ void dolphin_view_idle_main_draw(Canvas* canvas, void* model) {
if(m->hint_timeout > 0) {
m->hint_timeout--;
canvas_draw_icon_name(canvas, 13, 5, I_LockPopup_100x49);
elements_multiline_text(canvas, 65, 20, "To unlock\npress:");
if(m->locked) {
canvas_draw_icon_name(canvas, 13, 5, I_LockPopup_100x49);
elements_multiline_text(canvas, 65, 20, "To unlock\npress:");
} else {
canvas_set_font(canvas, FontPrimary);
elements_multiline_text_framed(canvas, 42, 30, "Unlocked");
}
}
}
@@ -81,8 +86,8 @@ void dolphin_view_lockmenu_draw(Canvas* canvas, void* model) {
if(m->locked) {
m->exit_timeout--;
m->door_left_x = CLAMP(m->door_left_x + 10, 0, -57);
m->door_right_x = CLAMP(m->door_right_x - 10, 115, 60);
m->door_left_x = CLAMP(m->door_left_x + 5, 0, -57);
m->door_right_x = CLAMP(m->door_right_x - 5, 115, 60);
if(m->door_left_x > -10) {
canvas_set_font(canvas, FontPrimary);
@@ -90,9 +95,6 @@ void dolphin_view_lockmenu_draw(Canvas* canvas, void* model) {
}
} else {
m->door_left_x = CLAMP(m->door_left_x - 10, 0, -57);
m->door_right_x = CLAMP(m->door_right_x + 10, 115, 60);
if(m->door_left_x == -57) {
for(uint8_t i = 0; i < 3; ++i) {
canvas_draw_str_aligned(

View File

@@ -6,18 +6,6 @@
#include <input/input.h>
#include <furi.h>
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef CLAMP
#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
#endif
// Idle screen
typedef enum {
DolphinViewIdleMain,
@@ -60,6 +48,7 @@ typedef struct {
Icon* animation;
uint8_t scene_num;
uint8_t hint_timeout;
bool locked;
} DolphinViewMainModel;
void dolphin_view_idle_main_draw(Canvas* canvas, void* model);

View File

@@ -4,22 +4,6 @@
#include <gui/gui_i.h>
#include <u8g2/u8g2.h>
#ifndef ARRSIZE
#define ARRSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#endif
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef CLAMP
#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
#endif
// global
#define SCALE 32
// screen

View File

@@ -66,7 +66,7 @@ void dolphin_scene_update_state(SceneState* state, uint32_t t, uint32_t dt) {
state->player_flipped = false;
if(state->action_timeout == 0) {
scene_proceed_action(state);
state->emote_id = roll_new(state->previous_emote, ARRSIZE(emotes_list));
state->emote_id = roll_new(state->previous_emote, SIZEOF_ARRAY(emotes_list));
break;
}
case INTERACT:

View File

@@ -37,17 +37,14 @@ static void scene_draw_sleep_emote(SceneState* state, Canvas* canvas) {
furi_assert(state);
furi_assert(canvas);
char dialog_str[] = "zZzZ...";
char buf[64];
char dialog_str[] = "zZzZ..";
// 2do - sofa x pos getter
if(state->player_global.x == 154 && state->action_timeout % 100 < 30) {
if(state->player_global.x == 154 && state->action_timeout % 100 < 50) {
if(state->dialog_progress < strlen(dialog_str)) {
if(state->action_timeout % 5 == 0) state->dialog_progress++;
dialog_str[state->dialog_progress] = '\0';
snprintf(buf, state->dialog_progress, dialog_str);
// bubble vs just text?
//elements_multiline_text_framed(canvas, 80, 20, buf);
canvas_draw_str(canvas, 80, 20, buf);
if(state->action_timeout % 10 == 0) state->dialog_progress++;
dialog_str[state->dialog_progress + 1] = '\0';
canvas_draw_str(canvas, 80, 20, dialog_str);
}
} else {
@@ -83,6 +80,25 @@ static void draw_idle_emote(SceneState* state, Canvas* canvas){
}
*/
static void draw_idle_emote(SceneState* state, Canvas* canvas) {
furi_assert(state);
furi_assert(canvas);
char dialog_str[] = "...";
if(state->action_timeout % 100 < 50) {
if(state->dialog_progress < strlen(dialog_str)) {
if(state->action_timeout % 10 == 0) state->dialog_progress++;
dialog_str[state->dialog_progress + 1] = '\0';
canvas_draw_str(canvas, 70, 15, dialog_str);
}
} else {
state->dialog_progress = 0;
}
}
void dolphin_scene_render_dolphin(SceneState* state, Canvas* canvas) {
furi_assert(state);
furi_assert(canvas);
@@ -190,8 +206,6 @@ void dolphin_scene_render_state(SceneState* state, Canvas* canvas) {
scene_activate_item_callback(state, canvas);
else if(state->action == SLEEP)
scene_draw_sleep_emote(state, canvas);
/*
else if(state->action == IDLE)
draw_idle_emote(state, canvas);
*/
}