Move to next box after selection
This commit is contained in:
+76
-75
@@ -382,6 +382,81 @@ static void alarm_highlight_layer_update_proc(Layer *layer, GContext *ctx) {
|
||||
graphics_draw_rect(ctx, layer_get_bounds(layer));
|
||||
}
|
||||
|
||||
static void set_alarm_highlighter_frame() {
|
||||
switch (s_highlight_pos) {
|
||||
case 0:
|
||||
layer_set_frame(s_alarm_highlight_layer, s_drop_function_grect);
|
||||
break;
|
||||
case 1:
|
||||
layer_set_frame(s_alarm_highlight_layer, s_drop_over_grect);
|
||||
break;
|
||||
case 2:
|
||||
layer_set_frame(s_alarm_highlight_layer, s_drop_under_grect);
|
||||
}
|
||||
}
|
||||
|
||||
static void alarm_up_click_handler(void *recognizer, void *ctx) {
|
||||
if (s_highlight_pos == 0) {
|
||||
s_highlight_pos = 2;
|
||||
} else {
|
||||
s_highlight_pos--;
|
||||
}
|
||||
set_alarm_highlighter_frame();
|
||||
}
|
||||
|
||||
static void alarm_down_click_handler(void *recognizer, void *ctx) {
|
||||
if (s_highlight_pos == 2) {
|
||||
s_highlight_pos = 0;
|
||||
} else {
|
||||
s_highlight_pos++;
|
||||
}
|
||||
set_alarm_highlighter_frame();
|
||||
}
|
||||
|
||||
static void alarm_select_click_handler(void *recognizer, void *ctx) {
|
||||
window_stack_push(s_drop_window, true);
|
||||
}
|
||||
|
||||
static void alarm_select_hold_handler(void *recognizer, void *ctx) {
|
||||
// check solution
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (s_selected_indices[i] != s_solution_indices[i]) {
|
||||
push_status_window(STATUS_MATH_FAILURE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// solution is correct, meaning a non-recovery alarm needs scheduled;
|
||||
// set dummy handler to avoid overwriting an important alarm with a
|
||||
// no-longer-important recovery alarm
|
||||
wakeup_service_subscribe(NULL);
|
||||
|
||||
if (s_awareness_countdown_int > 0) {
|
||||
// set main alarm if the awareness alarm was solved within time limit
|
||||
tick_timer_service_unsubscribe(); // alarm is fully disarmed - prevent stimulus in confirmation window
|
||||
if (schedule_alarm(WAKE_MAIN_ALARM)) {
|
||||
push_status_window(STATUS_CONFIRMATION);
|
||||
}
|
||||
} else {
|
||||
// otherwise, set awareness alarm and exit
|
||||
if (schedule_alarm(WAKE_AWARENESS_ALARM)) {
|
||||
if (settings.TutorialEnabled && (s_alarm_reason == WAKE_MAIN_ALARM || s_alarm_reason == WAKE_RECOVERY_MAIN_ALARM)) {
|
||||
push_status_window(STATUS_MAIN_TUTORIAL);
|
||||
} else {
|
||||
window_stack_pop_all(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void alarm_click_config_provider(void *ctx) {
|
||||
window_single_click_subscribe(BUTTON_ID_BACK, NULL);
|
||||
window_single_click_subscribe(BUTTON_ID_UP, alarm_up_click_handler);
|
||||
window_single_click_subscribe(BUTTON_ID_DOWN, alarm_down_click_handler);
|
||||
window_single_click_subscribe(BUTTON_ID_SELECT, alarm_select_click_handler);
|
||||
window_long_click_subscribe(BUTTON_ID_SELECT, 2500, alarm_select_hold_handler, NULL);
|
||||
}
|
||||
|
||||
static uint16_t menu_get_num_rows(MenuLayer *menu_layer, uint16_t section_index, void *context) {
|
||||
if (s_highlight_pos == 0) {
|
||||
return 3;
|
||||
@@ -415,6 +490,7 @@ static void menu_select(MenuLayer *menu_layer, MenuIndex *cell_index, void *cont
|
||||
text_layer_set_text(s_drop_txt_under_layer, s_options_under[cell_index->row]);
|
||||
}
|
||||
s_selected_indices[s_highlight_pos] = cell_index->row;
|
||||
alarm_down_click_handler(NULL, NULL); // move to next box
|
||||
window_stack_remove(s_drop_window, true);
|
||||
}
|
||||
|
||||
@@ -724,81 +800,6 @@ static void alarm_window_unload() {
|
||||
fonts_unload_custom_font(s_font_mansalva_small);
|
||||
}
|
||||
|
||||
static void set_alarm_highlighter_frame() {
|
||||
switch (s_highlight_pos) {
|
||||
case 0:
|
||||
layer_set_frame(s_alarm_highlight_layer, s_drop_function_grect);
|
||||
break;
|
||||
case 1:
|
||||
layer_set_frame(s_alarm_highlight_layer, s_drop_over_grect);
|
||||
break;
|
||||
case 2:
|
||||
layer_set_frame(s_alarm_highlight_layer, s_drop_under_grect);
|
||||
}
|
||||
}
|
||||
|
||||
static void alarm_up_click_handler(void *recognizer, void *ctx) {
|
||||
if (s_highlight_pos == 0) {
|
||||
s_highlight_pos = 2;
|
||||
} else {
|
||||
s_highlight_pos--;
|
||||
}
|
||||
set_alarm_highlighter_frame();
|
||||
}
|
||||
|
||||
static void alarm_down_click_handler(void *recognizer, void *ctx) {
|
||||
if (s_highlight_pos == 2) {
|
||||
s_highlight_pos = 0;
|
||||
} else {
|
||||
s_highlight_pos++;
|
||||
}
|
||||
set_alarm_highlighter_frame();
|
||||
}
|
||||
|
||||
static void alarm_select_click_handler(void *recognizer, void *ctx) {
|
||||
window_stack_push(s_drop_window, true);
|
||||
}
|
||||
|
||||
static void alarm_select_hold_handler(void *recognizer, void *ctx) {
|
||||
// check solution
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (s_selected_indices[i] != s_solution_indices[i]) {
|
||||
push_status_window(STATUS_MATH_FAILURE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// solution is correct, meaning a non-recovery alarm needs scheduled;
|
||||
// set dummy handler to avoid overwriting an important alarm with a
|
||||
// no-longer-important recovery alarm
|
||||
wakeup_service_subscribe(NULL);
|
||||
|
||||
if (s_awareness_countdown_int > 0) {
|
||||
// set main alarm if the awareness alarm was solved within time limit
|
||||
tick_timer_service_unsubscribe(); // alarm is fully disarmed - prevent stimulus in confirmation window
|
||||
if (schedule_alarm(WAKE_MAIN_ALARM)) {
|
||||
push_status_window(STATUS_CONFIRMATION);
|
||||
}
|
||||
} else {
|
||||
// otherwise, set awareness alarm and exit
|
||||
if (schedule_alarm(WAKE_AWARENESS_ALARM)) {
|
||||
if (settings.TutorialEnabled && (s_alarm_reason == WAKE_MAIN_ALARM || s_alarm_reason == WAKE_RECOVERY_MAIN_ALARM)) {
|
||||
push_status_window(STATUS_MAIN_TUTORIAL);
|
||||
} else {
|
||||
window_stack_pop_all(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void alarm_click_config_provider(void *ctx) {
|
||||
window_single_click_subscribe(BUTTON_ID_BACK, NULL);
|
||||
window_single_click_subscribe(BUTTON_ID_UP, alarm_up_click_handler);
|
||||
window_single_click_subscribe(BUTTON_ID_DOWN, alarm_down_click_handler);
|
||||
window_single_click_subscribe(BUTTON_ID_SELECT, alarm_select_click_handler);
|
||||
window_long_click_subscribe(BUTTON_ID_SELECT, 2500, alarm_select_hold_handler, NULL);
|
||||
}
|
||||
|
||||
static void push_alarm_window() {
|
||||
s_alarm_reason = persist_read_int(STORAGE_KEY_ALARM_REASON);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user