Exemplo n.º 1
0
//input handlers
static void button_click(ClickRecognizerRef recognizer, void *context) {
  ButtonId button = click_recognizer_get_button_id(recognizer);
  int answerNum = 0;
  if(button == BUTTON_ID_SELECT) answerNum = 1;
  if(button == BUTTON_ID_DOWN)   answerNum = 2;

  if(currentQuestion.correct_answer_num == answerNum) {
    if(!already_failed_question) 
      correct_anserted_questions++;

    total_question_num++;
    update_stats_disp();

    load_new_question();
  } else {    
    already_failed_question = true;

    if(currentQuestion.enabled[answerNum]) {      
      if(kana_app_settings_get_setting(SETTING_VIBRATIONS) == SETTING_VIBRATIONS_YES) 
        vibes_short_pulse();

      currentQuestion.enabled[answerNum] = false;

      if(kana_app_settings_get_setting(SETTING_ROMAJI_MODE) == ROMAJI_AS_QUESTION) {        
        clean_bitmap_answer(answerNum);
        load_bitmap_answer(answerNum, true);
      } else {
        #ifdef PBL_COLOR
          text_layer_set_text_color(ui.romajiAnswer[answerNum], WRONG_ANSWER_COLOR);
        #else
          text_layer_set_text(ui.romajiAnswer[answerNum], "");
        #endif
      }
    }
  }
}
Exemplo n.º 2
0
static char* menu_get_option(int position) {
    return setting_cell_subtitles[position][kana_app_settings_get_setting(position)];
}
Exemplo n.º 3
0
static void menu_rotate_option(int position) {    
    int prevValue = kana_app_settings_get_setting(position);

    persist_write_int( SETTINGS_STORAGE + position, (prevValue + 1) % setting_subtitles_len[position]);
}
Exemplo n.º 4
0
static void load_new_question() {  
  clean();

  int displayRomaji = kana_app_settings_get_setting(SETTING_ROMAJI_MODE);

  currentQuestion.correct_answer_num = rand() % 3;
  choosen_question_mode = kana_app_settings_get_setting(SETTING_QUIZ_MODE);
  choosen_question_mode = 
    (choosen_question_mode == QUESTION_MODE_RANDOM) ? 
      rand() % QUESTION_MODE_RANDOM : choosen_question_mode;
  
  for(int i=0; i < 3; i++) {
    currentQuestion.enabled[i] = true;

    bool duplicate = false;
    do {
      duplicate = false;
      currentQuestion.answer[i] = rand() % GLYPHS_NUM;

      for(int j=0; j<i; j++)
        if(currentQuestion.answer[j] == currentQuestion.answer[i]) 
          duplicate = true;

      if(previous_question == currentQuestion.answer[i]) 
        duplicate = true; 

    } while (duplicate);
  }

  previous_question = currentQuestion.answer[currentQuestion.correct_answer_num];

  int act_char_id = currentQuestion.answer[currentQuestion.correct_answer_num];
  if(displayRomaji == ROMAJI_AS_QUESTION) {
    GRect bounds = GRect(5, 56, 100, 60);           
    ui.romajiQuestion = text_layer_create(bounds);  
    text_layer_set_font(ui.romajiQuestion, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));  
    text_layer_set_text(ui.romajiQuestion, "");
    text_layer_set_text_alignment(ui.romajiQuestion, GTextAlignmentCenter);
    #ifdef PBL_COLOR
      text_layer_set_background_color(ui.romajiQuestion, GColorClear);  
      text_layer_set_text_color(ui.romajiQuestion, SEC_FG_COLOR);
    #endif

    layer_add_child(
      window_get_root_layer(ui.window), 
      text_layer_get_layer(ui.romajiQuestion));
    text_layer_set_text(
      ui.romajiQuestion, 
      kana_app_getRomaji(act_char_id));

    for(int i=0; i<3; i++) 
      load_bitmap_answer(i, false);

  } else if (displayRomaji == ROMAJI_AS_ANSWERS) {

    if(choosen_question_mode == QUESTION_MODE_KATAKANA) {
      ui.glyph_paths_num = kana_app_katakana_glyphs[act_char_id].size;
      
      for(int i = 0; i < ui.glyph_paths_num; i++) 
        ui.glyph_path[i] = gpath_create(kana_app_katakana_glyphs[act_char_id].glyph_path[i]);    

      for(int i = 0; i < 3; i++) 
        text_layer_set_text(ui.romajiAnswer[i], kana_app_getRomaji(currentQuestion.answer[i]));

    } else if(choosen_question_mode == QUESTION_MODE_HIRAGANA) {
      ui.glyph_paths_num = kana_app_hiragana_glyphs[act_char_id].size;
      
      for(int i = 0; i < ui.glyph_paths_num; i++) 
        ui.glyph_path[i] = gpath_create(kana_app_hiragana_glyphs[act_char_id].glyph_path[i]);

      for(int i = 0; i < 3; i++) 
        text_layer_set_text(ui.romajiAnswer[i], kana_app_getRomaji(currentQuestion.answer[i]));
    }
  }

  layer_mark_dirty(window_get_root_layer(ui.window));
}