Flash an X instead of a status window when the user inputs the wrong answer

This commit is contained in:
RandyTheSilly committed 2026-10-31 00:40:04 -04:00
1 parent 8820df1a85
commit f6a10475ca
6 files changed
+83 -11

No files matched your search

+7
View File
@@ -58,6 +58,13 @@
"spaceOptimization": "storage", "spaceOptimization": "storage",
"type": "bitmap" "type": "bitmap"
}, },
{
"file": "x.png",
"memoryFormat": "Smallest",
"name": "X",
"spaceOptimization": "storage",
"type": "bitmap"
},
{ {
"file": "check.png", "file": "check.png",
"memoryFormat": "Smallest", "memoryFormat": "Smallest",
+3
View File
@@ -1,3 +1,6 @@
# X Icon
Modified version of [x mark by Lewen Design](https://thenounproject.com/icon/x-mark-7924184/) (CC BY 3.0)
# Check Icon # Check Icon
Modified version of [checkmark by Asmuh](https://thenounproject.com/icon/checkmark-2193586/) (CC BY 3.0) Modified version of [checkmark by Asmuh](https://thenounproject.com/icon/checkmark-2193586/) (CC BY 3.0)
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
viewBox="-5.0 -10.0 110.0 135.0"
id="svg2"
sodipodi:docname="x.svg"
inkscape:version="1.4.4 (dcaf3e7d9e, 2026-05-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<sodipodi:namedview
id="namedview2"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="7.8444444"
inkscape:cx="54.943343"
inkscape:cy="67.436261"
inkscape:window-width="3056"
inkscape:window-height="1631"
inkscape:window-x="20"
inkscape:window-y="20"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<path
d="m85.66 83.832c-0.16797 0.15234-0.66406-0.67188-0.69922-0.82812-0.011719-0.050781-0.078126-0.12891 0.039062-0.15234 0.20312-0.039062 0.44141 0.59375 0.51172 0.72656 0.023437 0.046875 0.19922 0.10938 0.15234 0.25zm-56.695-25.797c-0.10156-0.14062-0.21484-0.21484-0.39062-0.16406-0.31641 0.09375 0.054687 0.55859 0.27344 0.5625l0.12109-0.39844zm30.805-10.719-0.023437 0.23438c0.29688-0.019531 0.28906-0.14844 0.40234-0.31641 0.16406-0.25 0.11719-0.32812 0.14453-0.37891 0.035156-0.0625 0.17969-0.074219 0.24219-0.12891 0.027344-0.023437 0.22266-0.25 0.13281-0.30078-0.12109-0.0625-0.23438 0.17969-0.40234 0.027344 0.125 0.48047 0.011719 0.25781-0.14453 0.40234-0.12891 0.11719-0.011719 0.29688-0.050782 0.34766l-0.29687 0.10938zm-8.7773-15.43c-0.089844-0.070313-0.70313 0.37109-0.57422 0.57422 0.058593 0.070312 0.59766-0.42969 0.57422-0.57422zm-9.1641 36.535c-0.18359 0.050781-0.20312 0.26172-0.28516 0.39844-0.027344 0.046876-0.10938 0.039063-0.11328 0.042969-0.039063 0.0625 0.035156 0.12891 0.082031 0.16797 0.078125-0.089844 0.76562-0.73438 0.3125-0.60938zm43.602 17.367-0.17578-0.39844c-0.625-0.066406-0.035156 0.62891 0.17578 0.39844zm-21.242-2.3945c-0.125-0.12109-0.20703-0.35938-0.41016-0.36719-0.070313 0.070312 0.42969 0.62891 0.54688 0.63281 0.089843 0 0.074219-0.16797 0.011719-0.21484-0.035157-0.027343-0.11719-0.019531-0.14844-0.046874zm8.5156-17.934c0.042969 0.25391 0.03125 0.42187 0.34375 0.40234 0.035156-0.26562-0.054687-0.4375-0.34375-0.40234zm-13.594-40.719c-0.23047-0.046876-0.25 0.21484-0.40234 0.31641l0.11719 0.14453c0.17188-0.082031 0.26953-0.27344 0.28516-0.46094zm-18.773 45.414c0.074218 0.09375 0.15234 0.17188 0.28516 0.14062l0.10156-0.25781-0.12891-0.14062zm20.488-24.32c-0.035157 0.066406-0.050781 0.14062-0.042969 0.21484 0.14453 0.046875 0.10156-0.0625 0.13672-0.09375 0.55078-0.42188 0.070312-0.42969-0.09375-0.125zm10.957 18.359c-0.0625 0.22266 0.125 0.57813 0.37109 0.51563 0.26172-0.066407-0.18359-0.57031-0.37109-0.51563zm1.3828 2.9961c-0.12109 0.17578 0.42188 0.46094 0.46094 0.25781l-0.17188-0.28906c-0.050781-0.046875-0.27734 0.019532-0.28516 0.03125zm8.4062 10.465c0.32031 0.5625 0.72266 1.4258 1.1523 1.8867 0.20703 0.22266 0.20312 0.050781 0.41016 0.44141 0.3125 0.59375 0.55859 1.1055 0.98047 1.7383 0.16016 0.24219 0.29688 0.49219 0.46094 0.74609 0.03125 0.050781 0.20312 0.34375 0.27734 0.26953-0.011718-0.10156 0.070313-0.21875 0.0625-0.30859-0.003906-0.039063-0.09375-0.039063-0.11719-0.078126-0.085937-0.14453-0.18359-0.37109-0.28516-0.49609-0.046875-0.054688-0.14453-0.015625-0.17578-0.074219-0.070313-0.13281-0.19922-0.46484-0.27734-0.64062-0.26953-0.60547-0.66797-0.98438-1.0352-1.5508-0.21875-0.33594-0.37891-0.74609-0.55859-1.0547-0.039063-0.066406-0.19922-0.11328-0.28125-0.23828-0.23438-0.35156-0.10156-0.43359-0.51953-0.83594-0.089843-0.085938-0.17187-0.17188-0.26172-0.25391-0.125 0.3125 0.09375 0.3125 0.17188 0.44922zm-62.121-6.7852c-0.066407 0.097656-0.41406 0.64062-0.16016 0.69141 0.21094 0.046875 0.19141-0.35938 0.22656-0.46094 0.28516-0.77734 0.73828-1.6484 1.0625-2.4062 0.1875-0.44141 0.41797-0.85547 0.58594-1.3047 0.042969-0.11328 0.27734-0.76172 0.28125-0.80859 0.015626-0.20703-0.3125-0.19922-0.10937-0.48828l-0.43359 0.6875c-0.22656 0.97266-0.80859 1.9492-1.0508 2.9258-0.039062 0.16016 0.054688 0.39844 0.042969 0.41406-0.085937 0.10938-0.51953 0.046875-0.23047 0.54688-0.26562 0.089843-0.17187 0.14453-0.21094 0.19922zm56.191 1.9609c0.23438-0.058593 0.29297 0.23828 0.35938 0.28125 0.035156 0.023438 0.14453-0.050781 0.23438 0.003907 0.22266 0.13281 0.28906 0.65625 0.78906 0.40625-0.17578-0.24609-0.10938-0.29297 0.03125-0.51563-0.074219-0.0625-0.12891-0.22656-0.20703-0.26562-0.14453-0.074219-0.46875 0.17578-0.39844-0.36719l0.16016-0.007812 0.007813-0.22656h-0.17188l0.058594 0.17188c-0.12891-0.19922-0.47266-0.10156-0.50781-0.12109-0.03125-0.015625-0.33594-0.48828-0.41797-0.56641-0.085937-0.0625-0.32812 0.21094-0.28516 0.30859 0.09375 0.039062 0.52344 0.65234 0.51953 0.69531-0.003906 0.070313-0.24219 0.050782-0.17188 0.19922zm-6.9648 4.8164c0.050781 0.074218 0.03125 0.22656 0.10938 0.33984 0.015625 0.023438 0.38281 0.33203 0.40625 0.33984 0.25781 0.10938 0.14062-0.20703 0.40234-0.14062l-0.011719 0.16406c-0.17578 0.070313-0.5 0.10547-0.44922 0.35547 0.125-0.042969 0.33594 0.0625 0.42578 0.042969 0.085937-0.015625 0.12891-0.18359 0.28906-0.16016 0.27734 0.1875 0.35156 0.59766 0.69531 0.75 0.25391-0.36328-0.16797-0.4375-0.36328-0.66016l0.10156-0.23438c-0.070312-0.13672-0.26562-0.050781-0.33594-0.09375-0.042968-0.027343-0.11719-0.43359-0.17969-0.52734-0.074219-0.11328-0.26562-0.11719-0.33203-0.17188-0.074219-0.066406-0.082032-0.26172-0.14844-0.3125-0.019531-0.015625-0.375-0.14453-0.38672-0.12891-0.125 0.42187 0.31641 0.34375 0.23047 0.75-0.35547 0.050781-0.27734-0.30078-0.29688-0.33203-0.011719-0.019531-0.37109-0.26953-0.39453-0.24219-0.14062 0.15234 0.21484 0.23828 0.23438 0.26562zm-37.066-23.594c-0.074219 0.078124-0.078125 0.17969-0.14453 0.25781-0.10938 0.12109-0.38672 0.1875-0.33984 0.43359Line truncated
id="path1"
style="fill:#ff0000"
inkscape:export-filename="../resources/x.png"
inkscape:export-xdpi="215.34914"
inkscape:export-ydpi="215.34914" />
</svg>

After

Width:  |  Height:  |  Size: 89 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

+33 -9
View File
@@ -25,6 +25,8 @@ static BitmapLayer *s_check_bmp_layer;
static TextLayer *s_setter_txt_layer; static TextLayer *s_setter_txt_layer;
static Layer *s_setter_highlight_layer; static Layer *s_setter_highlight_layer;
//// alarm //// alarm
static BitmapLayer *s_x_bmp_layer;
static Animation *s_x_anim_master;
static Layer *s_graph_layer; static Layer *s_graph_layer;
static TextLayer *s_theta_txt_layer; static TextLayer *s_theta_txt_layer;
static TextLayer *s_parenthesis_txt_layer; static TextLayer *s_parenthesis_txt_layer;
@@ -54,6 +56,8 @@ GFont s_font_mansalva_small;
//// setter //// setter
static GBitmap *s_clock_bmp; static GBitmap *s_clock_bmp;
static GBitmap *s_check_bmp; static GBitmap *s_check_bmp;
//// alarm
static GBitmap *s_x_bmp;
// global vars // global vars
static WakeupReason s_alarm_reason; static WakeupReason s_alarm_reason;
@@ -129,10 +133,6 @@ static void status_set_failure_click_config_provider(void *ctx) {
window_single_click_subscribe(BUTTON_ID_DOWN, click_handler_push_setter); window_single_click_subscribe(BUTTON_ID_DOWN, click_handler_push_setter);
} }
static void status_math_failure_click_config_provider(void *ctx) {
window_single_click_subscribe(BUTTON_ID_SELECT, click_handler_retry);
}
static void status_window_load(StatusWindowPurpose purpose) { static void status_window_load(StatusWindowPurpose purpose) {
Layer *window_layer = window_get_root_layer(s_status_window); Layer *window_layer = window_get_root_layer(s_status_window);
s_status_txt_layer = text_layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT)); s_status_txt_layer = text_layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
@@ -149,10 +149,6 @@ static void status_window_load(StatusWindowPurpose purpose) {
case STATUS_SET_FAILURE: case STATUS_SET_FAILURE:
text_layer_set_text(s_status_txt_layer, "Failed to set an alarm.\nPress any button to return to alarm setter."); text_layer_set_text(s_status_txt_layer, "Failed to set an alarm.\nPress any button to return to alarm setter.");
window_set_click_config_provider(s_status_window, status_set_failure_click_config_provider); window_set_click_config_provider(s_status_window, status_set_failure_click_config_provider);
break;
case STATUS_MATH_FAILURE:
text_layer_set_text(s_status_txt_layer, "Incorrect equation.\nTry again!");
window_set_click_config_provider(s_status_window, status_math_failure_click_config_provider);
} }
text_layer_set_background_color(s_status_txt_layer, GColorClear); text_layer_set_background_color(s_status_txt_layer, GColorClear);
layer_set_frame(text_layer_get_layer(s_status_txt_layer), GRect(0, (PBL_DISPLAY_HEIGHT / 2) - (text_layer_get_content_size(s_status_txt_layer).h / 2), PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT)); layer_set_frame(text_layer_get_layer(s_status_txt_layer), GRect(0, (PBL_DISPLAY_HEIGHT / 2) - (text_layer_get_content_size(s_status_txt_layer).h / 2), PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
@@ -542,7 +538,7 @@ static void accel_tap_handler(AccelAxisType axis, int32_t direction) {
// check solution // check solution
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
if (s_selected_indices[i] != s_solution_indices[i]) { if (s_selected_indices[i] != s_solution_indices[i]) {
push_status_window(STATUS_MATH_FAILURE); animation_schedule(animation_clone(s_x_anim_master));
return; return;
} }
} }
@@ -634,6 +630,16 @@ static void live_wakeup_handler_for_alarm(WakeupId id, int32_t wakeup_reason) {
} }
} }
static void anim_handler_flash_x_start(Animation *animation, void *context) {
layer_set_hidden(bitmap_layer_get_layer(s_x_bmp_layer), false);
}
static void anim_handler_flash_x_end(Animation *animation, bool finished, void *context) {
layer_set_hidden(bitmap_layer_get_layer(s_x_bmp_layer), true);
animation_destroy(animation);
}
static void anim_update_flash_x(Animation *animation, const AnimationProgress progress) {} // dummy
static const AnimationImplementation s_x_anim_impl = {.update = anim_update_flash_x};
static void alarm_window_load() { static void alarm_window_load() {
wakeup_service_subscribe(live_wakeup_handler_for_alarm); wakeup_service_subscribe(live_wakeup_handler_for_alarm);
@@ -761,6 +767,20 @@ static void alarm_window_load() {
text_layer_set_font(s_progress_txt_layer, s_font_lecoish_small); text_layer_set_font(s_progress_txt_layer, s_font_lecoish_small);
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));
// x (incorrect equation icon)
s_x_bmp = gbitmap_create_with_resource(RESOURCE_ID_X);
s_x_bmp_layer = bitmap_layer_create(GRect(20, 24, 160, 179));
bitmap_layer_set_bitmap(s_x_bmp_layer, s_x_bmp);
bitmap_layer_set_compositing_mode(s_x_bmp_layer, GCompOpSet);
layer_set_hidden(bitmap_layer_get_layer(s_x_bmp_layer), true); // hide until needed
layer_add_child(window_layer, bitmap_layer_get_layer(s_x_bmp_layer));
// x flash animation init
s_x_anim_master = animation_create();
animation_set_implementation(s_x_anim_master, &s_x_anim_impl);
animation_set_duration(s_x_anim_master, 1500);
animation_set_handlers(s_x_anim_master, (AnimationHandlers){.started = anim_handler_flash_x_start, .stopped = anim_handler_flash_x_end}, NULL);
// 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;
s_secs_since_last_input = MAX_SECS_WITHOUT_INPUT; s_secs_since_last_input = MAX_SECS_WITHOUT_INPUT;
@@ -775,6 +795,10 @@ static void alarm_window_load() {
static void alarm_window_unload() { static void alarm_window_unload() {
tick_timer_service_unsubscribe(); tick_timer_service_unsubscribe();
accel_tap_service_unsubscribe(); accel_tap_service_unsubscribe();
animation_destroy(s_x_anim_master);
gbitmap_destroy(s_x_bmp);
bitmap_layer_destroy(s_x_bmp_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);
text_layer_destroy(s_side_a_txt_layer); text_layer_destroy(s_side_a_txt_layer);
+1 -2
View File
@@ -3,8 +3,7 @@
typedef enum typedef enum
{ {
STATUS_CONFIRMATION = 1, STATUS_CONFIRMATION = 1,
STATUS_SET_FAILURE = 2, STATUS_SET_FAILURE = 2
STATUS_MATH_FAILURE = 3
} StatusWindowPurpose; } StatusWindowPurpose;
static void push_setter_window(); static void push_setter_window();