[FL-1149] Dolphin: stage 3 (#422)
* dolphin scenes refactoring & restructuring phase 1 * Passport app: mood and level display, opens from main menu and dolphin scenes. Dolphin scenes: minor refactoring (WIP) * dolphin scene app restruct * use gui defines for screen size * mv passport to dolphin dir Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
dbb8a92653
commit
51d726c2d7
@ -103,7 +103,11 @@ int32_t app_loader(void* p) {
|
|||||||
menu, menu_item_alloc_function("Games", assets_icons_get(A_Games_14), NULL, NULL));
|
menu, menu_item_alloc_function("Games", assets_icons_get(A_Games_14), NULL, NULL));
|
||||||
menu_item_add(
|
menu_item_add(
|
||||||
menu,
|
menu,
|
||||||
menu_item_alloc_function("Passport", assets_icons_get(A_Passport_14), NULL, NULL));
|
menu_item_alloc_function(
|
||||||
|
"Passport",
|
||||||
|
assets_icons_get(A_Passport_14),
|
||||||
|
app_loader_menu_callback,
|
||||||
|
(void*)&FLIPPER_SCENE_APPS[0]));
|
||||||
menu_item_add(
|
menu_item_add(
|
||||||
menu,
|
menu,
|
||||||
menu_item_alloc_function("Settings", assets_icons_get(A_Settings_14), NULL, NULL));
|
menu_item_alloc_function("Settings", assets_icons_get(A_Settings_14), NULL, NULL));
|
||||||
|
@ -33,7 +33,7 @@ int32_t sd_filesystem(void* p);
|
|||||||
int32_t subghz_app(void* p);
|
int32_t subghz_app(void* p);
|
||||||
int32_t gui_test(void* p);
|
int32_t gui_test(void* p);
|
||||||
int32_t keypad_test(void* p);
|
int32_t keypad_test(void* p);
|
||||||
int32_t dolphin_scene(void* p);
|
int32_t scene_app(void* p);
|
||||||
int32_t passport(void* p);
|
int32_t passport(void* p);
|
||||||
|
|
||||||
const FlipperApplication FLIPPER_SERVICES[] = {
|
const FlipperApplication FLIPPER_SERVICES[] = {
|
||||||
@ -149,10 +149,6 @@ const FlipperApplication FLIPPER_SERVICES[] = {
|
|||||||
{.app = keypad_test, .name = "keypad_test", .icon = A_Plugins_14},
|
{.app = keypad_test, .name = "keypad_test", .icon = A_Plugins_14},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef APP_DOLPHIN_SCENE
|
|
||||||
{.app = dolphin_scene, .name = "Dolphin [beta]", .stack_size = 1024, .icon = A_Games_14},
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(FlipperApplication);
|
const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(FlipperApplication);
|
||||||
@ -231,9 +227,8 @@ const FlipperApplication FLIPPER_PLUGINS[] = {
|
|||||||
|
|
||||||
const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApplication);
|
const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApplication);
|
||||||
|
|
||||||
#ifdef BUILD_DOLPHIN_SCENE
|
const FlipperApplication FLIPPER_SCENE =
|
||||||
const FlipperApplication FLIPPER_SCENES =
|
{.app = scene_app, .name = "Scenes", .stack_size = 1024, .icon = A_Games_14};
|
||||||
{.app = dolphin_scene, .name = "Dolphin [beta]", .stack_size = 1024, .icon = A_Games_14};
|
|
||||||
|
|
||||||
const FlipperApplication FLIPPER_SCENE_APPS[] = {
|
const FlipperApplication FLIPPER_SCENE_APPS[] = {
|
||||||
{.app = passport, .name = "Passport", .stack_size = 1024, .icon = A_Games_14},
|
{.app = passport, .name = "Passport", .stack_size = 1024, .icon = A_Games_14},
|
||||||
@ -242,5 +237,3 @@ const FlipperApplication FLIPPER_SCENE_APPS[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(FlipperApplication);
|
const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(FlipperApplication);
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -31,6 +31,6 @@ extern const size_t FLIPPER_PLUGINS_COUNT;
|
|||||||
/* Seperate scene app holder
|
/* Seperate scene app holder
|
||||||
* Spawned by app-loader
|
* Spawned by app-loader
|
||||||
*/
|
*/
|
||||||
extern const FlipperApplication FLIPPER_SCENES;
|
extern const FlipperApplication FLIPPER_SCENE;
|
||||||
extern const FlipperApplication FLIPPER_SCENE_APPS[];
|
extern const FlipperApplication FLIPPER_SCENE_APPS[];
|
||||||
extern const size_t FLIPPER_SCENE_APPS_COUNT;
|
extern const size_t FLIPPER_SCENE_APPS_COUNT;
|
||||||
|
@ -16,7 +16,6 @@ APP_BT = 1
|
|||||||
APP_CLI = 1
|
APP_CLI = 1
|
||||||
APP_SD_FILESYSTEM = 1
|
APP_SD_FILESYSTEM = 1
|
||||||
BUILD_IRDA = 1
|
BUILD_IRDA = 1
|
||||||
BUILD_DOLPHIN_SCENE = 1
|
|
||||||
APP_DOLPHIN = 1
|
APP_DOLPHIN = 1
|
||||||
BUILD_EXAMPLE_BLINK = 1
|
BUILD_EXAMPLE_BLINK = 1
|
||||||
BUILD_EXAMPLE_UART_WRITE = 1
|
BUILD_EXAMPLE_UART_WRITE = 1
|
||||||
@ -46,6 +45,9 @@ ifeq ($(APP_DOLPHIN), 1)
|
|||||||
APP_MENU = 1
|
APP_MENU = 1
|
||||||
CFLAGS += -DAPP_DOLPHIN
|
CFLAGS += -DAPP_DOLPHIN
|
||||||
C_SOURCES += $(wildcard $(APP_DIR)/dolphin/*.c)
|
C_SOURCES += $(wildcard $(APP_DIR)/dolphin/*.c)
|
||||||
|
C_SOURCES += $(wildcard $(APP_DIR)/dolphin/scenes/*.c)
|
||||||
|
C_SOURCES += $(wildcard $(APP_DIR)/dolphin/scenes/assets/*.c)
|
||||||
|
C_SOURCES += $(wildcard $(APP_DIR)/dolphin/passport/*.c)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
APP_POWER ?= 0
|
APP_POWER ?= 0
|
||||||
@ -261,18 +263,6 @@ CFLAGS += -DBUILD_FLOOPPER_BLOOPPER
|
|||||||
C_SOURCES += $(wildcard $(APP_DIR)/floopper-bloopper/*.c)
|
C_SOURCES += $(wildcard $(APP_DIR)/floopper-bloopper/*.c)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
APP_DOLPHIN_SCENE ?= 0
|
|
||||||
ifeq ($(APP_DOLPHIN_SCENE), 1)
|
|
||||||
CFLAGS += -DAPP_DOLPHIN_SCENE
|
|
||||||
BUILD_DOLPHIN_SCENE = 1
|
|
||||||
endif
|
|
||||||
BUILD_DOLPHIN_SCENE ?= 0
|
|
||||||
ifeq ($(BUILD_DOLPHIN_SCENE), 1)
|
|
||||||
CFLAGS += -DBUILD_DOLPHIN_SCENE
|
|
||||||
C_SOURCES += $(wildcard $(APP_DIR)/dolphin_scene/*.c)
|
|
||||||
C_SOURCES += $(wildcard $(APP_DIR)/passport/*.c)
|
|
||||||
endif
|
|
||||||
|
|
||||||
APP_IBUTTON ?= 0
|
APP_IBUTTON ?= 0
|
||||||
ifeq ($(APP_IBUTTON), 1)
|
ifeq ($(APP_IBUTTON), 1)
|
||||||
CFLAGS += -DAPP_IBUTTON
|
CFLAGS += -DAPP_IBUTTON
|
||||||
|
@ -80,7 +80,7 @@ bool dolphin_view_idle_main_input(InputEvent* event, void* context) {
|
|||||||
} else if(event->key == InputKeyLeft) {
|
} else if(event->key == InputKeyLeft) {
|
||||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleUp);
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleUp);
|
||||||
} else if(event->key == InputKeyRight) {
|
} else if(event->key == InputKeyRight) {
|
||||||
dolphin_switch_to_interactive_scene(dolphin, &FLIPPER_SCENES);
|
dolphin_switch_to_interactive_scene(dolphin, &FLIPPER_SCENE);
|
||||||
} else if(event->key == InputKeyDown) {
|
} else if(event->key == InputKeyDown) {
|
||||||
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleDown);
|
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleDown);
|
||||||
}
|
}
|
||||||
|
@ -3,38 +3,6 @@
|
|||||||
#include <api-hal.h>
|
#include <api-hal.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t magic;
|
|
||||||
uint8_t version;
|
|
||||||
uint8_t checksum;
|
|
||||||
uint8_t flags;
|
|
||||||
uint32_t timestamp;
|
|
||||||
} DolphinDataHeader;
|
|
||||||
|
|
||||||
#define DOLPHIN_DATA_PAGE 0xC0
|
|
||||||
#define DOLPHIN_DATA_HEADER_ADDRESS 0x080C0000U
|
|
||||||
#define DOLPHIN_DATA_DATA_ADDRESS (DOLPHIN_DATA_HEADER_ADDRESS + sizeof(DolphinDataHeader))
|
|
||||||
|
|
||||||
#define DOLPHIN_DATA_HEADER_MAGIC 0xD0
|
|
||||||
#define DOLPHIN_DATA_HEADER_VERSION 0x01
|
|
||||||
|
|
||||||
#define DOLPHIN_LVL_THRESHOLD 20.0f
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t limit_ibutton;
|
|
||||||
uint32_t limit_nfc;
|
|
||||||
uint32_t limit_ir;
|
|
||||||
uint32_t limit_rfid;
|
|
||||||
|
|
||||||
uint32_t flags;
|
|
||||||
uint32_t icounter;
|
|
||||||
uint32_t butthurt;
|
|
||||||
} DolphinData;
|
|
||||||
|
|
||||||
struct DolphinState {
|
|
||||||
DolphinData data;
|
|
||||||
};
|
|
||||||
|
|
||||||
DolphinState* dolphin_state_alloc() {
|
DolphinState* dolphin_state_alloc() {
|
||||||
DolphinState* dolphin_state = furi_alloc(sizeof(DolphinState));
|
DolphinState* dolphin_state = furi_alloc(sizeof(DolphinState));
|
||||||
return dolphin_state;
|
return dolphin_state;
|
||||||
|
@ -4,6 +4,38 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define DOLPHIN_DATA_PAGE 0xC0
|
||||||
|
#define DOLPHIN_DATA_HEADER_ADDRESS 0x080C0000U
|
||||||
|
#define DOLPHIN_DATA_DATA_ADDRESS (DOLPHIN_DATA_HEADER_ADDRESS + sizeof(DolphinDataHeader))
|
||||||
|
|
||||||
|
#define DOLPHIN_DATA_HEADER_MAGIC 0xD0
|
||||||
|
#define DOLPHIN_DATA_HEADER_VERSION 0x01
|
||||||
|
|
||||||
|
#define DOLPHIN_LVL_THRESHOLD 20.0f
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t magic;
|
||||||
|
uint8_t version;
|
||||||
|
uint8_t checksum;
|
||||||
|
uint8_t flags;
|
||||||
|
uint32_t timestamp;
|
||||||
|
} DolphinDataHeader;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t limit_ibutton;
|
||||||
|
uint32_t limit_nfc;
|
||||||
|
uint32_t limit_ir;
|
||||||
|
uint32_t limit_rfid;
|
||||||
|
|
||||||
|
uint32_t flags;
|
||||||
|
uint32_t icounter;
|
||||||
|
uint32_t butthurt;
|
||||||
|
} DolphinData;
|
||||||
|
|
||||||
|
struct DolphinState {
|
||||||
|
DolphinData data;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct DolphinState DolphinState;
|
typedef struct DolphinState DolphinState;
|
||||||
|
|
||||||
DolphinState* dolphin_state_alloc();
|
DolphinState* dolphin_state_alloc();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <gui/gui.h>
|
#include <gui/gui.h>
|
||||||
#include <api-hal-version.h>
|
#include <api-hal-version.h>
|
||||||
|
#include "dolphin/dolphin.h"
|
||||||
|
#include "dolphin/dolphin_state.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EventTypeTick,
|
EventTypeTick,
|
||||||
@ -14,8 +16,8 @@ typedef struct {
|
|||||||
EventType type;
|
EventType type;
|
||||||
} AppEvent;
|
} AppEvent;
|
||||||
|
|
||||||
typedef struct {
|
// Moods, corresponding to butthurt level. (temp, unclear about max level)
|
||||||
} State;
|
static const char* mood_strings[5] = {[0] = "Normal", [1] = "Ok", [2] = "Sad", [3] = "Angry"};
|
||||||
|
|
||||||
static void input_callback(InputEvent* input_event, void* ctx) {
|
static void input_callback(InputEvent* input_event, void* ctx) {
|
||||||
osMessageQueueId_t event_queue = ctx;
|
osMessageQueueId_t event_queue = ctx;
|
||||||
@ -26,16 +28,17 @@ static void input_callback(InputEvent* input_event, void* ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void render_callback(Canvas* canvas, void* ctx) {
|
static void render_callback(Canvas* canvas, void* ctx) {
|
||||||
State* state = (State*)acquire_mutex((ValueMutex*)ctx, 25);
|
DolphinState* state = (DolphinState*)acquire_mutex((ValueMutex*)ctx, 25);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
char level[20];
|
char level[20];
|
||||||
uint32_t current_level = dolphin_state_get_level(dolphin->state);
|
char mood[32];
|
||||||
uint32_t prev_cap = dolphin_state_xp_to_levelup(dolphin->state, current_level - 1, false);
|
|
||||||
uint32_t exp = (dolphin_state_xp_to_levelup(dolphin->state, current_level, true) * 63) /
|
uint32_t butthurt = dolphin_state_get_butthurt(state);
|
||||||
(dolphin_state_xp_to_levelup(dolphin->state, current_level, false) - prev_cap);
|
uint32_t current_level = dolphin_state_get_level(state);
|
||||||
*/
|
uint32_t prev_cap = dolphin_state_xp_to_levelup(state, current_level - 1, false);
|
||||||
|
uint32_t exp = (dolphin_state_xp_to_levelup(state, current_level, true) * 63) /
|
||||||
|
(dolphin_state_xp_to_levelup(state, current_level, false) - prev_cap);
|
||||||
|
|
||||||
canvas_clear(canvas);
|
canvas_clear(canvas);
|
||||||
|
|
||||||
// multipass
|
// multipass
|
||||||
@ -59,29 +62,31 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
|||||||
canvas_draw_line(canvas, 59, 44, 124, 44);
|
canvas_draw_line(canvas, 59, 44, 124, 44);
|
||||||
|
|
||||||
canvas_draw_str(canvas, 59, 15, api_hal_version_get_name_ptr());
|
canvas_draw_str(canvas, 59, 15, api_hal_version_get_name_ptr());
|
||||||
canvas_draw_str(canvas, 59, 28, "Mood: OK");
|
|
||||||
/*
|
|
||||||
snprintf(level, 20, "Level: %ld", current_level);
|
snprintf(level, 20, "Level: %ld", current_level);
|
||||||
|
snprintf(mood, 20, "Mood: %s", mood_strings[butthurt]);
|
||||||
|
|
||||||
|
canvas_draw_str(canvas, 59, 28, mood);
|
||||||
|
|
||||||
canvas_draw_str(canvas, 59, 41, level);
|
canvas_draw_str(canvas, 59, 41, level);
|
||||||
canvas_set_color(canvas, ColorWhite);
|
canvas_set_color(canvas, ColorWhite);
|
||||||
canvas_draw_box(canvas, 123 - exp, 48, exp + 1, 6);
|
canvas_draw_box(canvas, 123 - exp, 48, exp + 1, 6);
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
canvas_draw_line(canvas, 123 - exp, 48, 123 - exp, 54);
|
canvas_draw_line(canvas, 123 - exp, 48, 123 - exp, 54);
|
||||||
*/
|
|
||||||
|
|
||||||
release_mutex((ValueMutex*)ctx, state);
|
release_mutex((ValueMutex*)ctx, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t passport(void* p) {
|
int32_t passport(void* p) {
|
||||||
State _state;
|
DolphinState _state;
|
||||||
ValueMutex state_mutex;
|
ValueMutex state_mutex;
|
||||||
|
dolphin_state_load(&_state);
|
||||||
|
|
||||||
osMessageQueueId_t event_queue = osMessageQueueNew(1, sizeof(AppEvent), NULL);
|
osMessageQueueId_t event_queue = osMessageQueueNew(2, sizeof(AppEvent), NULL);
|
||||||
furi_check(event_queue);
|
furi_check(event_queue);
|
||||||
|
|
||||||
if(!init_mutex(&state_mutex, &_state, sizeof(State))) {
|
if(!init_mutex(&state_mutex, &_state, sizeof(DolphinState))) {
|
||||||
printf("cannot create mutex\r\n");
|
printf("[Passport] cannot create mutex\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,17 +100,15 @@ int32_t passport(void* p) {
|
|||||||
|
|
||||||
AppEvent event;
|
AppEvent event;
|
||||||
while(1) {
|
while(1) {
|
||||||
State* state = (State*)acquire_mutex_block(&state_mutex);
|
|
||||||
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 25);
|
osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, 25);
|
||||||
if(event_status == osOK) {
|
if(event_status == osOK) {
|
||||||
if(event.type == EventTypeKey && event.value.input.type == InputTypeShort) {
|
if(event.type == EventTypeKey && event.value.input.type == InputTypeShort &&
|
||||||
release_mutex(&state_mutex, state);
|
event.value.input.key == InputKeyBack) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view_port_update(view_port);
|
view_port_update(view_port);
|
||||||
release_mutex(&state_mutex, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gui_remove_view_port(gui, view_port);
|
gui_remove_view_port(gui, view_port);
|
@ -1,6 +1,6 @@
|
|||||||
#include "dolphin_scene/items_i.h"
|
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
#include "applications.h"
|
#include "applications.h"
|
||||||
|
#include "items_i.h"
|
||||||
|
|
||||||
const Item TV = {
|
const Item TV = {
|
||||||
.layer = 7,
|
.layer = 7,
|
||||||
@ -64,6 +64,20 @@ static void dolphin_scene_start_app(SceneState* state, const FlipperApplication*
|
|||||||
furi_thread_start(state->scene_app_thread);
|
furi_thread_start(state->scene_app_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const void scene_activate_item_callback(SceneState* state, Canvas* canvas) {
|
||||||
|
furi_assert(state);
|
||||||
|
furi_assert(canvas);
|
||||||
|
|
||||||
|
const Item* near = is_nearby(state);
|
||||||
|
if(near && state->use_pending == true) {
|
||||||
|
state->action_timeout = near->timeout;
|
||||||
|
near->callback(canvas, state);
|
||||||
|
state->use_pending = false;
|
||||||
|
} else if(near) {
|
||||||
|
near->callback(canvas, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Item* is_nearby(SceneState* state) {
|
const Item* is_nearby(SceneState* state) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
uint8_t item = 0;
|
uint8_t item = 0;
|
||||||
@ -128,4 +142,4 @@ void pc_callback(Canvas* canvas, void* state) {
|
|||||||
if(s->use_pending) {
|
if(s->use_pending) {
|
||||||
dolphin_scene_start_app(s, &FLIPPER_SCENE_APPS[1]);
|
dolphin_scene_start_app(s, &FLIPPER_SCENE_APPS[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
8
applications/dolphin/scenes/assets/items.h
Normal file
8
applications/dolphin/scenes/assets/items.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "dolphin/scenes/scene.h"
|
||||||
|
|
||||||
|
#define ITEMS_NUM 4
|
||||||
|
|
||||||
|
const Item* is_nearby(SceneState* state);
|
||||||
|
const Item** get_scene(SceneState* state);
|
||||||
|
const void scene_activate_item_callback(SceneState* state, Canvas* canvas);
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "dolphin_scene/items.h"
|
#include "items.h"
|
||||||
|
|
||||||
void smash_tv(Canvas* canvas, void* state);
|
void smash_tv(Canvas* canvas, void* state);
|
||||||
void draw_tv(Canvas* canvas, void* state);
|
void draw_tv(Canvas* canvas, void* state);
|
@ -1,18 +1,43 @@
|
|||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <api-hal.h>
|
#include <api-hal.h>
|
||||||
#include "dolphin_scene/dolphin_scene.h"
|
#include "scene.h"
|
||||||
|
|
||||||
static SceneAppGui* scene_app_gui = NULL;
|
static SceneAppGui* scene_app_gui = NULL;
|
||||||
static ValueMutex* scene_state_mutex = NULL;
|
static ValueMutex* scene_state_mutex = NULL;
|
||||||
|
|
||||||
static void dolphin_engine_tick_callback(void* p) {
|
void dolphin_scene_redraw(Canvas* canvas, void* ctx) {
|
||||||
|
furi_assert(canvas);
|
||||||
|
furi_assert(ctx);
|
||||||
|
|
||||||
|
SceneState* state = (SceneState*)acquire_mutex((ValueMutex*)ctx, 25);
|
||||||
|
if(state == NULL) return; // redraw fail
|
||||||
|
uint32_t t = xTaskGetTickCount();
|
||||||
|
|
||||||
|
canvas_clear(canvas);
|
||||||
|
dolphin_scene_render(state, canvas, t);
|
||||||
|
dolphin_scene_render_state(state, canvas);
|
||||||
|
release_mutex((ValueMutex*)ctx, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dolphin_scene_handle_input(SceneState* state, InputEvent* input) {
|
||||||
|
// printf("[kb] event: %02x %s\n", input->key, input->state ? "pressed" : "released");
|
||||||
|
dolphin_scene_handle_user_input(state, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dolphin_scene_tick_handler(SceneState* state, uint32_t t, uint32_t dt) {
|
||||||
|
// printf("t: %d, dt: %d\n", t, dt);
|
||||||
|
dolphin_scene_coordinates(state, dt);
|
||||||
|
dolphin_scene_update_state(state, t, dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void scene_engine_tick_callback(void* p) {
|
||||||
osMessageQueueId_t event_queue = p;
|
osMessageQueueId_t event_queue = p;
|
||||||
AppEvent event;
|
AppEvent event;
|
||||||
event.type = EventTypeTick;
|
event.type = EventTypeTick;
|
||||||
osMessageQueuePut(event_queue, (void*)&event, 0, 0);
|
osMessageQueuePut(event_queue, (void*)&event, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dolphin_engine_input_callback(InputEvent* input_event, void* ctx) {
|
static void scene_engine_input_callback(InputEvent* input_event, void* ctx) {
|
||||||
osMessageQueueId_t event_queue = ctx;
|
osMessageQueueId_t event_queue = ctx;
|
||||||
AppEvent event;
|
AppEvent event;
|
||||||
event.type = EventTypeKey;
|
event.type = EventTypeKey;
|
||||||
@ -31,7 +56,7 @@ void scene_alloc() {
|
|||||||
scene_app_gui->gui = furi_record_open("gui");
|
scene_app_gui->gui = furi_record_open("gui");
|
||||||
scene_app_gui->view_port = view_port_alloc();
|
scene_app_gui->view_port = view_port_alloc();
|
||||||
scene_app_gui->timer =
|
scene_app_gui->timer =
|
||||||
osTimerNew(dolphin_engine_tick_callback, osTimerPeriodic, scene_app_gui->mqueue, NULL);
|
osTimerNew(scene_engine_tick_callback, osTimerPeriodic, scene_app_gui->mqueue, NULL);
|
||||||
printf("scene_alloc: timer %p\r\n", scene_app_gui->timer);
|
printf("scene_alloc: timer %p\r\n", scene_app_gui->timer);
|
||||||
// Scene State
|
// Scene State
|
||||||
SceneState* scene_state = furi_alloc(sizeof(SceneState));
|
SceneState* scene_state = furi_alloc(sizeof(SceneState));
|
||||||
@ -47,7 +72,7 @@ void scene_alloc() {
|
|||||||
// Open GUI and register fullscreen view_port
|
// Open GUI and register fullscreen view_port
|
||||||
view_port_draw_callback_set(scene_app_gui->view_port, dolphin_scene_redraw, scene_state_mutex);
|
view_port_draw_callback_set(scene_app_gui->view_port, dolphin_scene_redraw, scene_state_mutex);
|
||||||
view_port_input_callback_set(
|
view_port_input_callback_set(
|
||||||
scene_app_gui->view_port, dolphin_engine_input_callback, scene_app_gui->mqueue);
|
scene_app_gui->view_port, scene_engine_input_callback, scene_app_gui->mqueue);
|
||||||
gui_add_view_port(scene_app_gui->gui, scene_app_gui->view_port, GuiLayerMain);
|
gui_add_view_port(scene_app_gui->gui, scene_app_gui->view_port, GuiLayerMain);
|
||||||
view_port_enabled_set(scene_app_gui->view_port, true);
|
view_port_enabled_set(scene_app_gui->view_port, true);
|
||||||
printf("scene_alloc: complete\r\n");
|
printf("scene_alloc: complete\r\n");
|
||||||
@ -75,7 +100,7 @@ void scene_free() {
|
|||||||
printf("scene_free: complete\r\n");
|
printf("scene_free: complete\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dolphin_scene(void* p) {
|
int32_t scene_app(void* p) {
|
||||||
api_hal_power_insomnia_enter();
|
api_hal_power_insomnia_enter();
|
||||||
scene_alloc();
|
scene_alloc();
|
||||||
|
|
||||||
@ -111,4 +136,4 @@ int32_t dolphin_scene(void* p) {
|
|||||||
scene_free();
|
scene_free();
|
||||||
api_hal_power_insomnia_exit();
|
api_hal_power_insomnia_exit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <gui/gui.h>
|
#include <gui/gui_i.h>
|
||||||
#include <u8g2/u8g2.h>
|
#include <u8g2/u8g2.h>
|
||||||
|
|
||||||
#ifndef ARRSIZE
|
#ifndef ARRSIZE
|
||||||
@ -23,8 +23,9 @@
|
|||||||
// global
|
// global
|
||||||
#define SCALE 32
|
#define SCALE 32
|
||||||
// screen
|
// screen
|
||||||
#define SCREEN_WIDTH 128
|
|
||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_WIDTH GUI_DISPLAY_WIDTH
|
||||||
|
#define SCREEN_HEIGHT GUI_DISPLAY_HEIGHT
|
||||||
#define BONDARIES_X_LEFT 40
|
#define BONDARIES_X_LEFT 40
|
||||||
#define BONDARIES_X_RIGHT 88
|
#define BONDARIES_X_RIGHT 88
|
||||||
|
|
||||||
@ -44,7 +45,6 @@
|
|||||||
#define DOLPHIN_LAYER 6
|
#define DOLPHIN_LAYER 6
|
||||||
#define PARALLAX_MOD 7
|
#define PARALLAX_MOD 7
|
||||||
#define PARALLAX(layer) layer / PARALLAX_MOD - layer
|
#define PARALLAX(layer) layer / PARALLAX_MOD - layer
|
||||||
#define ITEMS_NUM 4
|
|
||||||
|
|
||||||
#define DIALOG_PROGRESS 250
|
#define DIALOG_PROGRESS 250
|
||||||
|
|
||||||
@ -131,8 +131,8 @@ void dolphin_scene_render_dolphin(SceneState* state, Canvas* canvas);
|
|||||||
void dolphin_scene_handle_user_input(SceneState* state, InputEvent* input);
|
void dolphin_scene_handle_user_input(SceneState* state, InputEvent* input);
|
||||||
void dolphin_scene_coordinates(SceneState* state, uint32_t dt);
|
void dolphin_scene_coordinates(SceneState* state, uint32_t dt);
|
||||||
|
|
||||||
void dolphin_scene_render_dolphin_state(SceneState* state, Canvas* canvas);
|
void dolphin_scene_render_state(SceneState* state, Canvas* canvas);
|
||||||
void dolphin_scene_update_dolphin_state(SceneState* state, uint32_t t, uint32_t dt);
|
void dolphin_scene_update_state(SceneState* state, uint32_t t, uint32_t dt);
|
||||||
|
|
||||||
void dolphin_scene_redraw(Canvas* canvas, void* ctx);
|
void dolphin_scene_redraw(Canvas* canvas, void* ctx);
|
||||||
void dolphin_scene_tick_handler(SceneState* state, uint32_t t, uint32_t dt);
|
void dolphin_scene_tick_handler(SceneState* state, uint32_t t, uint32_t dt);
|
@ -1,46 +1,6 @@
|
|||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
#include "dolphin_scene/dolphin_scene.h"
|
#include "scene.h"
|
||||||
|
|
||||||
void dolphin_scene_render_dolphin(SceneState* state, Canvas* canvas) {
|
|
||||||
furi_assert(state);
|
|
||||||
furi_assert(canvas);
|
|
||||||
|
|
||||||
if(state->scene_zoom == SCENE_ZOOM) {
|
|
||||||
state->dolphin_gfx = I_DolphinExcited_64x63;
|
|
||||||
} else if(state->action == SLEEP && state->player_global.x == 154) {
|
|
||||||
state->dolphin_gfx = A_FX_Sitting_40x27;
|
|
||||||
state->dolphin_gfx_b = I_FX_SittingB_40x27;
|
|
||||||
} else if(state->action != INTERACT) {
|
|
||||||
if(state->player_v.x < 0 || state->player_flipped) {
|
|
||||||
if(state->player_anim == 0) {
|
|
||||||
state->dolphin_gfx = I_WalkL1_32x32;
|
|
||||||
state->dolphin_gfx_b = I_WalkLB1_32x32;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
state->dolphin_gfx = I_WalkL2_32x32;
|
|
||||||
state->dolphin_gfx_b = I_WalkLB2_32x32;
|
|
||||||
}
|
|
||||||
} else if(state->player_v.x > 0 || !state->player_flipped) {
|
|
||||||
if(state->player_anim == 0) {
|
|
||||||
state->dolphin_gfx = I_WalkR1_32x32;
|
|
||||||
state->dolphin_gfx_b = I_WalkRB1_32x32;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
state->dolphin_gfx = I_WalkR2_32x32;
|
|
||||||
state->dolphin_gfx_b = I_WalkRB2_32x32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// zoom handlers
|
|
||||||
canvas_set_bitmap_mode(canvas, true);
|
|
||||||
canvas_set_color(canvas, ColorWhite);
|
|
||||||
canvas_draw_icon_name(canvas, state->player.x, state->player.y, state->dolphin_gfx_b);
|
|
||||||
canvas_set_color(canvas, ColorBlack);
|
|
||||||
canvas_draw_icon_name(canvas, state->player.x, state->player.y, state->dolphin_gfx);
|
|
||||||
canvas_set_bitmap_mode(canvas, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dolphin_scene_handle_user_input(SceneState* state, InputEvent* input) {
|
void dolphin_scene_handle_user_input(SceneState* state, InputEvent* input) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
@ -1,6 +1,6 @@
|
|||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include "dolphin_scene/dolphin_scene.h"
|
#include "scene.h"
|
||||||
#include "dolphin_scene/dolphin_emotes.h"
|
#include "assets/emotes.h"
|
||||||
|
|
||||||
static uint16_t roll_new(uint16_t prev, uint16_t max) {
|
static uint16_t roll_new(uint16_t prev, uint16_t max) {
|
||||||
uint16_t val = 999;
|
uint16_t val = 999;
|
||||||
@ -11,7 +11,7 @@ static uint16_t roll_new(uint16_t prev, uint16_t max) {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dolphin_actions_proceed(SceneState* state) {
|
static void scene_proceed_action(SceneState* state) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
|
|
||||||
state->prev_action = state->action;
|
state->prev_action = state->action;
|
||||||
@ -21,7 +21,7 @@ static void dolphin_actions_proceed(SceneState* state) {
|
|||||||
state->action_timeout = default_timeout[state->action];
|
state->action_timeout = default_timeout[state->action];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dolphin_go_to_poi(SceneState* state) {
|
static void scene_dolphin_go_to_poi(SceneState* state) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
if(state->player_global.x < state->poi) {
|
if(state->player_global.x < state->poi) {
|
||||||
state->player_flipped = false;
|
state->player_flipped = false;
|
||||||
@ -32,7 +32,7 @@ static void dolphin_go_to_poi(SceneState* state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_handler(SceneState* state) {
|
static void scene_action_handler(SceneState* state) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
if(state->action == MINDCONTROL && state->player_v.x != 0) {
|
if(state->action == MINDCONTROL && state->player_v.x != 0) {
|
||||||
state->action_timeout = default_timeout[state->action];
|
state->action_timeout = default_timeout[state->action];
|
||||||
@ -48,23 +48,24 @@ static void action_handler(SceneState* state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dolphin_scene_update_dolphin_state(SceneState* state, uint32_t t, uint32_t dt) {
|
void dolphin_scene_update_state(SceneState* state, uint32_t t, uint32_t dt) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
action_handler(state);
|
scene_action_handler(state);
|
||||||
|
UNUSED(dialogues_list);
|
||||||
|
|
||||||
switch(state->action) {
|
switch(state->action) {
|
||||||
case WALK:
|
case WALK:
|
||||||
if(state->player_global.x == state->poi) {
|
if(state->player_global.x == state->poi) {
|
||||||
state->player_v.x = 0;
|
state->player_v.x = 0;
|
||||||
dolphin_actions_proceed(state);
|
scene_proceed_action(state);
|
||||||
} else {
|
} else {
|
||||||
dolphin_go_to_poi(state);
|
scene_dolphin_go_to_poi(state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EMOTE:
|
case EMOTE:
|
||||||
state->player_flipped = false;
|
state->player_flipped = false;
|
||||||
if(state->action_timeout == 0) {
|
if(state->action_timeout == 0) {
|
||||||
dolphin_actions_proceed(state);
|
scene_proceed_action(state);
|
||||||
state->emote_id = roll_new(state->previous_emote, ARRSIZE(emotes_list));
|
state->emote_id = roll_new(state->previous_emote, ARRSIZE(emotes_list));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -73,7 +74,7 @@ void dolphin_scene_update_dolphin_state(SceneState* state, uint32_t t, uint32_t
|
|||||||
if(state->prev_action == MINDCONTROL) {
|
if(state->prev_action == MINDCONTROL) {
|
||||||
state->action = MINDCONTROL;
|
state->action = MINDCONTROL;
|
||||||
} else {
|
} else {
|
||||||
dolphin_actions_proceed(state);
|
scene_proceed_action(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -81,21 +82,19 @@ void dolphin_scene_update_dolphin_state(SceneState* state, uint32_t t, uint32_t
|
|||||||
if(state->poi != 154) { // temp
|
if(state->poi != 154) { // temp
|
||||||
state->poi = 154;
|
state->poi = 154;
|
||||||
} else if(state->player_global.x != state->poi) {
|
} else if(state->player_global.x != state->poi) {
|
||||||
dolphin_go_to_poi(state);
|
scene_dolphin_go_to_poi(state);
|
||||||
} else {
|
} else {
|
||||||
state->player_v.x = 0;
|
state->player_v.x = 0;
|
||||||
if(state->action_timeout == 0) {
|
if(state->action_timeout == 0) {
|
||||||
state->poi = roll_new(state->player_global.x, WORLD_WIDTH / 4);
|
state->poi = roll_new(state->player_global.x, WORLD_WIDTH / 4);
|
||||||
dolphin_actions_proceed(state);
|
scene_proceed_action(state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if(state->action_timeout == 0) {
|
if(state->action_timeout == 0) {
|
||||||
dolphin_actions_proceed(state);
|
scene_proceed_action(state);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNUSED(dialogues_list);
|
|
||||||
}
|
}
|
@ -1,16 +1,12 @@
|
|||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include "dolphin_scene/dolphin_scene.h"
|
#include "scene.h"
|
||||||
#include "dolphin_scene/dolphin_emotes.h"
|
#include "assets/emotes.h"
|
||||||
#include "dolphin_scene/items.h"
|
#include "assets/items.h"
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
|
|
||||||
const char* action_str[] = {"Sleep", "Idle", "Walk", "Emote", "Use", "MC"};
|
const char* action_str[] = {"Sleep", "Idle", "Walk", "Emote", "Use", "MC"};
|
||||||
|
|
||||||
static bool item_screen_bounds(int32_t pos) {
|
static void scene_draw_hint(SceneState* state, Canvas* canvas, bool glitching) {
|
||||||
return pos > -SCREEN_WIDTH && pos < (SCREEN_WIDTH * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void draw_hint(SceneState* state, Canvas* canvas, bool glitching) {
|
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
furi_assert(canvas);
|
furi_assert(canvas);
|
||||||
char buf[32];
|
char buf[32];
|
||||||
@ -31,19 +27,19 @@ static void draw_hint(SceneState* state, Canvas* canvas, bool glitching) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_current_emote(SceneState* state, Canvas* canvas) {
|
static void scene_draw_current_emote(SceneState* state, Canvas* canvas) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
furi_assert(canvas);
|
furi_assert(canvas);
|
||||||
elements_multiline_text_framed(canvas, 80, 20, (char*)emotes_list[state->emote_id]);
|
elements_multiline_text_framed(canvas, 80, 20, (char*)emotes_list[state->emote_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_sleep_emote(SceneState* state, Canvas* canvas) {
|
static void scene_draw_sleep_emote(SceneState* state, Canvas* canvas) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
furi_assert(canvas);
|
furi_assert(canvas);
|
||||||
|
|
||||||
char dialog_str[] = "zZzZ...";
|
char dialog_str[] = "zZzZ...";
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
// 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 < 30) {
|
||||||
if(state->dialog_progress < strlen(dialog_str)) {
|
if(state->dialog_progress < strlen(dialog_str)) {
|
||||||
if(state->action_timeout % 5 == 0) state->dialog_progress++;
|
if(state->action_timeout % 5 == 0) state->dialog_progress++;
|
||||||
@ -59,7 +55,7 @@ static void draw_sleep_emote(SceneState* state, Canvas* canvas) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_dialog(SceneState* state, Canvas* canvas) {
|
static void scene_draw_dialog(SceneState* state, Canvas* canvas) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
furi_assert(canvas);
|
furi_assert(canvas);
|
||||||
|
|
||||||
@ -87,18 +83,47 @@ static void draw_idle_emote(SceneState* state, Canvas* canvas){
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void activate_item_callback(SceneState* state, Canvas* canvas) {
|
void dolphin_scene_render_dolphin(SceneState* state, Canvas* canvas) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
furi_assert(canvas);
|
furi_assert(canvas);
|
||||||
|
|
||||||
const Item* near = is_nearby(state);
|
if(state->scene_zoom == SCENE_ZOOM) {
|
||||||
if(near && state->use_pending == true) {
|
state->dolphin_gfx = I_DolphinExcited_64x63;
|
||||||
state->action_timeout = near->timeout;
|
} else if(state->action == SLEEP && state->player_global.x == 154) { // 2do - sofa x pos getter
|
||||||
near->callback(canvas, state);
|
state->dolphin_gfx = A_FX_Sitting_40x27;
|
||||||
state->use_pending = false;
|
state->dolphin_gfx_b = I_FX_SittingB_40x27;
|
||||||
} else if(near) {
|
} else if(state->action != INTERACT) {
|
||||||
near->callback(canvas, state);
|
if(state->player_v.x < 0 || state->player_flipped) {
|
||||||
|
if(state->player_anim == 0) {
|
||||||
|
state->dolphin_gfx = I_WalkL1_32x32;
|
||||||
|
state->dolphin_gfx_b = I_WalkLB1_32x32;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
state->dolphin_gfx = I_WalkL2_32x32;
|
||||||
|
state->dolphin_gfx_b = I_WalkLB2_32x32;
|
||||||
|
}
|
||||||
|
} else if(state->player_v.x > 0 || !state->player_flipped) {
|
||||||
|
if(state->player_anim == 0) {
|
||||||
|
state->dolphin_gfx = I_WalkR1_32x32;
|
||||||
|
state->dolphin_gfx_b = I_WalkRB1_32x32;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
state->dolphin_gfx = I_WalkR2_32x32;
|
||||||
|
state->dolphin_gfx_b = I_WalkRB2_32x32;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canvas_set_bitmap_mode(canvas, true);
|
||||||
|
canvas_set_color(canvas, ColorWhite);
|
||||||
|
canvas_draw_icon_name(canvas, state->player.x, state->player.y, state->dolphin_gfx_b);
|
||||||
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
canvas_draw_icon_name(canvas, state->player.x, state->player.y, state->dolphin_gfx);
|
||||||
|
canvas_set_bitmap_mode(canvas, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool item_screen_bounds(int32_t pos) {
|
||||||
|
return pos > -SCREEN_WIDTH && pos < (SCREEN_WIDTH * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dolphin_scene_render(SceneState* state, Canvas* canvas, uint32_t t) {
|
void dolphin_scene_render(SceneState* state, Canvas* canvas, uint32_t t) {
|
||||||
@ -134,7 +159,7 @@ void dolphin_scene_render(SceneState* state, Canvas* canvas, uint32_t t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dolphin_scene_render_dolphin_state(SceneState* state, Canvas* canvas) {
|
void dolphin_scene_render_state(SceneState* state, Canvas* canvas) {
|
||||||
furi_assert(state);
|
furi_assert(state);
|
||||||
furi_assert(canvas);
|
furi_assert(canvas);
|
||||||
|
|
||||||
@ -156,15 +181,15 @@ void dolphin_scene_render_dolphin_state(SceneState* state, Canvas* canvas) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(state->scene_zoom == SCENE_ZOOM)
|
if(state->scene_zoom == SCENE_ZOOM)
|
||||||
draw_dialog(state, canvas);
|
scene_draw_dialog(state, canvas);
|
||||||
else if(state->action == EMOTE)
|
else if(state->action == EMOTE)
|
||||||
draw_current_emote(state, canvas);
|
scene_draw_current_emote(state, canvas);
|
||||||
else if(state->action == MINDCONTROL)
|
else if(state->action == MINDCONTROL)
|
||||||
draw_hint(state, canvas, state->action_timeout > 45);
|
scene_draw_hint(state, canvas, state->action_timeout > 45);
|
||||||
else if(state->action == INTERACT)
|
else if(state->action == INTERACT)
|
||||||
activate_item_callback(state, canvas);
|
scene_activate_item_callback(state, canvas);
|
||||||
else if(state->action == SLEEP)
|
else if(state->action == SLEEP)
|
||||||
draw_sleep_emote(state, canvas);
|
scene_draw_sleep_emote(state, canvas);
|
||||||
/*
|
/*
|
||||||
else if(state->action == IDLE)
|
else if(state->action == IDLE)
|
||||||
draw_idle_emote(state, canvas);
|
draw_idle_emote(state, canvas);
|
@ -1,31 +0,0 @@
|
|||||||
#include <furi.h>
|
|
||||||
#include "dolphin_scene/dolphin_scene.h"
|
|
||||||
|
|
||||||
void dolphin_scene_redraw(Canvas* canvas, void* ctx) {
|
|
||||||
furi_assert(canvas);
|
|
||||||
furi_assert(ctx);
|
|
||||||
|
|
||||||
SceneState* state = (SceneState*)acquire_mutex((ValueMutex*)ctx, 25);
|
|
||||||
if(state == NULL) return; // redraw fail
|
|
||||||
uint32_t t = xTaskGetTickCount();
|
|
||||||
|
|
||||||
canvas_clear(canvas);
|
|
||||||
|
|
||||||
dolphin_scene_render(state, canvas, t);
|
|
||||||
|
|
||||||
dolphin_scene_render_dolphin_state(state, canvas);
|
|
||||||
|
|
||||||
release_mutex((ValueMutex*)ctx, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dolphin_scene_handle_input(SceneState* state, InputEvent* input) {
|
|
||||||
// printf("[kb] event: %02x %s\n", input->key, input->state ? "pressed" : "released");
|
|
||||||
dolphin_scene_handle_user_input(state, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dolphin_scene_tick_handler(SceneState* state, uint32_t t, uint32_t dt) {
|
|
||||||
// printf("t: %d, dt: %d\n", t, dt);
|
|
||||||
|
|
||||||
dolphin_scene_coordinates(state, dt);
|
|
||||||
dolphin_scene_update_dolphin_state(state, t, dt);
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "dolphin_scene/dolphin_scene.h"
|
|
||||||
|
|
||||||
const Item* is_nearby(SceneState* state);
|
|
||||||
const Item** get_scene(SceneState* state);
|
|
Loading…
Reference in New Issue
Block a user