Use vertical doors for animations; change UI color depending on correctness

This commit is contained in:
RandyTheSilly committed 2026-11-13 02:13:25 -05:00
1 parent 74f3660698
commit 2c6f189ebe
2 files changed
+30 -33

No files matched your search

+29 -32
View File
@@ -42,8 +42,8 @@ static TextLayer *s_progress_txt_layer;
static TextLayer *s_side_a_txt_layer; static TextLayer *s_side_a_txt_layer;
static TextLayer *s_side_b_txt_layer; static TextLayer *s_side_b_txt_layer;
static TextLayer *s_side_c_txt_layer; static TextLayer *s_side_c_txt_layer;
static Layer *s_left_door_layer; static Layer *s_top_door_layer;
static Layer *s_right_door_layer; static Layer *s_bottom_door_layer;
// fonts // fonts
GFont s_font_lecoish_small; GFont s_font_lecoish_small;
@@ -60,7 +60,6 @@ static GBitmap *s_check_bmp;
// global vars // global vars
static WakeupReason s_alarm_reason; static WakeupReason s_alarm_reason;
static GColor s_setter_highlight_color;
static uint8_t s_highlight_pos = 0; static uint8_t s_highlight_pos = 0;
static bool s_skip_current_day = false; static bool s_skip_current_day = false;
static bool s_skip_current_day_from_confirmation = false; static bool s_skip_current_day_from_confirmation = false;
@@ -78,11 +77,14 @@ static char s_countdown_buf[4];
static char s_progress_buf[8]; static char s_progress_buf[8];
// constants // constants
//// colors
#define COLOR_PRIMARY GColorJaegerGreen
#define COLOR_FAIL GColorRed
#define COLOR_SETTER_HIGHLIGHT GColorMediumAquamarine
//// shared (setter+alarm) //// shared (setter+alarm)
static const uint8_t s_edge_bar_height = ((PBL_DISPLAY_HEIGHT / 7) * 2); static const uint8_t s_edge_bar_height = ((PBL_DISPLAY_HEIGHT / 7) * 2);
static const GRect s_top_bar_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, s_edge_bar_height); static const GRect s_top_bar_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, s_edge_bar_height);
static const GRect s_bottom_bar_grect = GRect(0, PBL_DISPLAY_HEIGHT - s_edge_bar_height, PBL_DISPLAY_WIDTH, s_edge_bar_height); static const GRect s_bottom_bar_grect = GRect(0, PBL_DISPLAY_HEIGHT - s_edge_bar_height, PBL_DISPLAY_WIDTH, s_edge_bar_height);
static const GColor s_primary_color = GColorJaegerGreen;
//// status //// status
#define STATUS_TEXT_INSET 4 #define STATUS_TEXT_INSET 4
//// alarm //// alarm
@@ -108,9 +110,11 @@ static const VibePattern s_first_triangle_vibe_pattern = {
// animation stuff // animation stuff
#define ANIMATION_DURATION 350 #define ANIMATION_DURATION 350
static GRect s_left_door_starting_grect = GRect(-(PBL_DISPLAY_WIDTH / 2), s_small_top_bar_height, PBL_DISPLAY_WIDTH / 2, PBL_DISPLAY_HEIGHT - s_small_top_bar_height - s_bottom_bar_grect.size.h); static GRect s_top_door_starting_grect = GRect(0, -(PBL_DISPLAY_HEIGHT / 2), PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT / 2);
static GRect s_right_door_starting_grect = GRect(PBL_DISPLAY_WIDTH, s_small_top_bar_height, PBL_DISPLAY_WIDTH / 2, PBL_DISPLAY_HEIGHT - s_small_top_bar_height - s_bottom_bar_grect.size.h); static GRect s_top_door_target_grect = GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT / 2);
static bool s_door_correct; static GRect s_bottom_door_starting_grect = GRect(0, PBL_DISPLAY_HEIGHT * (3 / 2), PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT / 2);
static GRect s_bottom_door_target_grect = GRect(0, PBL_DISPLAY_HEIGHT / 2, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT / 2);
static bool s_door_correct = true;
static Animation *s_door_anim; static Animation *s_door_anim;
// alarm drop menu options // alarm drop menu options
@@ -283,12 +287,12 @@ static bool schedule_alarm(WakeupReason schedule_reason) {
} }
static void top_bar_layer_update_proc(Layer *layer, GContext *ctx) { static void top_bar_layer_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, s_primary_color); graphics_context_set_fill_color(ctx, s_top_door_layer == NULL ? COLOR_PRIMARY : (s_door_correct ? COLOR_PRIMARY : COLOR_FAIL));
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone); graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
} }
static void bottom_bar_layer_update_proc(Layer *layer, GContext *ctx) { static void bottom_bar_layer_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, (s_highlight_pos == 2 ? s_setter_highlight_color : s_primary_color)); graphics_context_set_fill_color(ctx, (s_top_door_layer == NULL ? (s_highlight_pos == 2 ? COLOR_SETTER_HIGHLIGHT : COLOR_PRIMARY) : (s_door_correct ? COLOR_PRIMARY : COLOR_FAIL)));
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone); graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
} }
@@ -508,13 +512,8 @@ static void update_for_new_triangle() {
text_layer_set_text(s_progress_txt_layer, s_progress_buf); text_layer_set_text(s_progress_txt_layer, s_progress_buf);
} }
static void door_layer_red_update_proc(Layer *layer, GContext *ctx) { static void door_layer_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorSunsetOrange); graphics_context_set_fill_color(ctx, s_door_correct ? COLOR_PRIMARY : COLOR_FAIL);
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
}
static void door_layer_green_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_fill_color(ctx, GColorMediumAquamarine);
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone); graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
} }
@@ -541,12 +540,12 @@ static void play_door_animation(bool correct) {
// ensure door layers are correct color // ensure door layers are correct color
s_door_correct = correct; s_door_correct = correct;
layer_set_update_proc(s_left_door_layer, correct ? door_layer_green_update_proc : door_layer_red_update_proc); layer_set_update_proc(s_top_door_layer, door_layer_update_proc);
layer_set_update_proc(s_right_door_layer, correct ? door_layer_green_update_proc : door_layer_red_update_proc); layer_set_update_proc(s_bottom_door_layer, door_layer_update_proc);
// create base close animations // create base close animations
PropertyAnimation *l = property_animation_create_layer_frame(s_left_door_layer, &s_left_door_starting_grect, &GRect(0, s_left_door_starting_grect.origin.y, s_left_door_starting_grect.size.w, s_left_door_starting_grect.size.h)); PropertyAnimation *l = property_animation_create_layer_frame(s_top_door_layer, &s_top_door_starting_grect, &s_top_door_target_grect);
PropertyAnimation *r = property_animation_create_layer_frame(s_right_door_layer, &s_right_door_starting_grect, &GRect(PBL_DISPLAY_WIDTH / 2, s_left_door_starting_grect.origin.y, s_left_door_starting_grect.size.w, s_left_door_starting_grect.size.h)); PropertyAnimation *r = property_animation_create_layer_frame(s_bottom_door_layer, &s_bottom_door_starting_grect, &s_bottom_door_target_grect);
Animation *lc = property_animation_get_animation(l), *rc = property_animation_get_animation(r); Animation *lc = property_animation_get_animation(l), *rc = property_animation_get_animation(r);
animation_set_duration(lc, ANIMATION_DURATION); animation_set_duration(lc, ANIMATION_DURATION);
animation_set_duration(rc, ANIMATION_DURATION); animation_set_duration(rc, ANIMATION_DURATION);
@@ -644,7 +643,7 @@ static void division_layer_update_proc(Layer *layer, GContext *ctx) {
} }
static void alarm_highlight_layer_update_proc(Layer *layer, GContext *ctx) { static void alarm_highlight_layer_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_stroke_color(ctx, GColorRed); graphics_context_set_stroke_color(ctx, GColorBlue);
graphics_context_set_stroke_width(ctx, 3); graphics_context_set_stroke_width(ctx, 3);
graphics_draw_rect(ctx, layer_get_bounds(layer)); graphics_draw_rect(ctx, layer_get_bounds(layer));
} }
@@ -776,9 +775,6 @@ static void alarm_window_load() {
Layer *window_layer = window_get_root_layer(s_window); Layer *window_layer = window_get_root_layer(s_window);
// change highlight color to avoid changing color of bottom bar
s_setter_highlight_color = s_primary_color;
// graph paper bg // graph paper bg
s_graph_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT)); s_graph_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
layer_set_update_proc(s_graph_layer, graph_layer_update_proc); layer_set_update_proc(s_graph_layer, graph_layer_update_proc);
@@ -913,10 +909,10 @@ static void alarm_window_load() {
layer_add_child(window_layer, text_layer_get_layer(s_progress_txt_layer)); layer_add_child(window_layer, text_layer_get_layer(s_progress_txt_layer));
// door layers // door layers
s_left_door_layer = layer_create(s_left_door_starting_grect); s_top_door_layer = layer_create(s_top_door_starting_grect);
s_right_door_layer = layer_create(s_right_door_starting_grect); s_bottom_door_layer = layer_create(s_bottom_door_starting_grect);
layer_add_child(window_layer, s_left_door_layer); layer_add_child(window_layer, s_top_door_layer);
layer_add_child(window_layer, s_right_door_layer); layer_add_child(window_layer, s_bottom_door_layer);
// configure UI around current triangle in s_triangle_layer // configure UI around current triangle in s_triangle_layer
s_current_triangle_num = 1; s_current_triangle_num = 1;
@@ -940,8 +936,10 @@ static void alarm_window_unload() {
animation_destroy(s_door_anim); animation_destroy(s_door_anim);
s_door_anim = NULL; s_door_anim = NULL;
} }
layer_destroy(s_right_door_layer); layer_destroy(s_bottom_door_layer);
layer_destroy(s_left_door_layer); layer_destroy(s_top_door_layer);
s_bottom_door_layer = NULL; // checked to determine if in alarm or setter
s_top_door_layer = NULL;
text_layer_destroy(s_progress_txt_layer); text_layer_destroy(s_progress_txt_layer);
text_layer_destroy(s_countdown_txt_layer); text_layer_destroy(s_countdown_txt_layer);
window_destroy(s_drop_window); window_destroy(s_drop_window);
@@ -1024,7 +1022,7 @@ static void setter_highlight_layer_update_proc(Layer *layer, GContext *ctx) {
fill_area.origin.x = fill_area.size.w; fill_area.origin.x = fill_area.size.w;
break; break;
} }
graphics_context_set_fill_color(ctx, s_setter_highlight_color); graphics_context_set_fill_color(ctx, COLOR_SETTER_HIGHLIGHT);
graphics_fill_rect(ctx, fill_area, 0, GCornerNone); graphics_fill_rect(ctx, fill_area, 0, GCornerNone);
} }
@@ -1135,7 +1133,6 @@ static void live_wakeup_handler_for_setter(WakeupId id, int32_t reason) {
static void setter_window_load() { static void setter_window_load() {
wakeup_service_subscribe(live_wakeup_handler_for_setter); wakeup_service_subscribe(live_wakeup_handler_for_setter);
s_setter_highlight_color = GColorMediumAquamarine;
Layer *window_layer = window_get_root_layer(s_window); Layer *window_layer = window_get_root_layer(s_window);
// top&bottom bars // top&bottom bars
+1 -1
View File
@@ -32,7 +32,7 @@ static void right_triangle_layer_update_proc(Layer *layer, GContext *ctx) {
graphics_draw_line(ctx, GPoint(end_x, base_y), GPoint(apex_x, apex_y)); graphics_draw_line(ctx, GPoint(end_x, base_y), GPoint(apex_x, apex_y));
// circle theta angle // circle theta angle
graphics_context_set_stroke_color(ctx, GColorRed); graphics_context_set_stroke_color(ctx, GColorBlue);
graphics_context_set_stroke_width(ctx, 2); graphics_context_set_stroke_width(ctx, 2);
graphics_draw_circle(ctx, GPoint(tri->theta_angle_is_left ? start_x : end_x, base_y), 5); graphics_draw_circle(ctx, GPoint(tri->theta_angle_is_left ? start_x : end_x, base_y), 5);
} }