2021-04-13 18:06:25 +00:00
|
|
|
#include <furi.h>
|
2021-04-26 12:19:14 +00:00
|
|
|
#include "scene.h"
|
|
|
|
#include "assets/emotes.h"
|
|
|
|
#include "assets/items.h"
|
2021-04-13 18:06:25 +00:00
|
|
|
#include <gui/elements.h>
|
|
|
|
|
|
|
|
const char* action_str[] = {"Sleep", "Idle", "Walk", "Emote", "Use", "MC"};
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
static void scene_draw_hint(SceneState* state, Canvas* canvas, bool glitching) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
const Item* near = is_nearby(state);
|
|
|
|
if(near) {
|
|
|
|
int32_t hint_pos_x = (near->x - state->player_global.x) * PARALLAX(near->layer) + 25;
|
|
|
|
int8_t hint_pos_y = near->y < 15 ? near->y + 4 : near->y - 16;
|
|
|
|
|
|
|
|
strcpy(buf, near->action_name);
|
|
|
|
if(glitching) {
|
|
|
|
for(size_t g = 0; g != state->action_timeout; g++) {
|
|
|
|
buf[(g * 23) % strlen(buf)] = ' ' + (random() % g * 17) % ('z' - ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas_draw_str(canvas, hint_pos_x, hint_pos_y, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
static void scene_draw_current_emote(SceneState* state, Canvas* canvas) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
elements_multiline_text_framed(canvas, 80, 20, (char*)emotes_list[state->emote_id]);
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
static void scene_draw_sleep_emote(SceneState* state, Canvas* canvas) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
char dialog_str[] = "zZzZ..";
|
2021-04-26 12:19:14 +00:00
|
|
|
// 2do - sofa x pos getter
|
2021-05-18 18:54:56 +00:00
|
|
|
if(state->player_global.x == 154 && state->action_timeout % 100 < 50) {
|
2021-04-13 18:06:25 +00:00
|
|
|
if(state->dialog_progress < strlen(dialog_str)) {
|
2021-05-18 18:54:56 +00:00
|
|
|
if(state->action_timeout % 10 == 0) state->dialog_progress++;
|
|
|
|
|
|
|
|
dialog_str[state->dialog_progress + 1] = '\0';
|
|
|
|
canvas_draw_str(canvas, 80, 20, dialog_str);
|
2021-04-13 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
state->dialog_progress = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
static void scene_draw_dialog(SceneState* state, Canvas* canvas) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
|
|
|
|
char dialog_str[64];
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
strcpy(dialog_str, (char*)dialogues_list[state->dialogue_id]);
|
|
|
|
|
|
|
|
if(state->dialog_progress <= strlen(dialog_str)) {
|
|
|
|
if(state->action_timeout % 2 == 0) state->dialog_progress++;
|
|
|
|
dialog_str[state->dialog_progress] = '\0';
|
|
|
|
snprintf(buf, state->dialog_progress, dialog_str);
|
|
|
|
} else {
|
|
|
|
snprintf(buf, 64, dialog_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
elements_multiline_text_framed(canvas, 68, 16, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
static void draw_idle_emote(SceneState* state, Canvas* canvas){
|
|
|
|
if(state->action_timeout % 50 < 40 && state->prev_action == MINDCONTROL){
|
|
|
|
elements_multiline_text_framed(canvas, 68, 16, "WUT?!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2021-05-18 18:54:56 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
void dolphin_scene_render_dolphin(SceneState* state, Canvas* canvas) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
if(state->scene_zoom == SCENE_ZOOM) {
|
|
|
|
state->dolphin_gfx = I_DolphinExcited_64x63;
|
|
|
|
} else if(state->action == SLEEP && state->player_global.x == 154) { // 2do - sofa x pos getter
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 18:06:25 +00:00
|
|
|
}
|
2021-04-26 12:19:14 +00:00
|
|
|
|
|
|
|
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);
|
2021-04-13 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void dolphin_scene_render(SceneState* state, Canvas* canvas, uint32_t t) {
|
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
const Item** current_scene = get_scene(state);
|
|
|
|
|
|
|
|
for(uint8_t l = 0; l < LAYERS; l++) {
|
|
|
|
if(state->scene_zoom < SCENE_ZOOM) {
|
|
|
|
for(uint8_t i = 0; i < ITEMS_NUM; i++) {
|
|
|
|
int32_t item_pos = (current_scene[i]->x - state->player_global.x);
|
|
|
|
if(item_screen_bounds(item_pos)) {
|
|
|
|
if(current_scene[i]->draw) current_scene[i]->draw(canvas, state);
|
|
|
|
|
|
|
|
if(l == current_scene[i]->layer) {
|
|
|
|
canvas_draw_icon_name(
|
|
|
|
canvas,
|
|
|
|
item_pos * PARALLAX(l),
|
|
|
|
current_scene[i]->y,
|
|
|
|
current_scene[i]->icon);
|
|
|
|
canvas_set_bitmap_mode(canvas, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(l == 0) canvas_draw_line(canvas, 0, 42, 128, 42);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(l == DOLPHIN_LAYER) dolphin_scene_render_dolphin(state, canvas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
void dolphin_scene_render_state(SceneState* state, Canvas* canvas) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
furi_assert(canvas);
|
|
|
|
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
|
|
|
// dolphin_scene_debug
|
|
|
|
if(state->debug) {
|
|
|
|
sprintf(
|
|
|
|
buf,
|
|
|
|
"x:%ld>%d %ld %s",
|
|
|
|
state->player_global.x,
|
|
|
|
state->poi,
|
|
|
|
state->action_timeout,
|
|
|
|
action_str[state->action]);
|
|
|
|
canvas_draw_str(canvas, 0, 13, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(state->scene_zoom == SCENE_ZOOM)
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_draw_dialog(state, canvas);
|
2021-04-13 18:06:25 +00:00
|
|
|
else if(state->action == EMOTE)
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_draw_current_emote(state, canvas);
|
2021-04-13 18:06:25 +00:00
|
|
|
else if(state->action == MINDCONTROL)
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_draw_hint(state, canvas, state->action_timeout > 45);
|
2021-04-13 18:06:25 +00:00
|
|
|
else if(state->action == INTERACT)
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_activate_item_callback(state, canvas);
|
2021-04-13 18:06:25 +00:00
|
|
|
else if(state->action == SLEEP)
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_draw_sleep_emote(state, canvas);
|
2021-04-13 18:06:25 +00:00
|
|
|
else if(state->action == IDLE)
|
|
|
|
draw_idle_emote(state, canvas);
|
|
|
|
}
|