// do any key processing here // exit: -1 => nothing was done // >=0 => a choice was selected int popupdead_process_keys(int k) { int masked_k; if ( k <= 0 ) { return -1; } switch(k) { case KEY_ENTER: return Popupdead_default_choice; // select the current default choice break; case KEY_ESC: if (Popupdead_skip_active) { return 0; // 0 mimics a "do not skip" } else { return 1; // do nothing here for now - 1 mimics a "return to flight deck" } break; case KEY_DOWN: case KEY_PAD2: case KEY_TAB: popupdead_play_default_change_sound(); Popupdead_default_choice++; if ( Popupdead_default_choice >= Popupdead_num_choices ) { Popupdead_default_choice=0; } break; case KEY_UP: case KEY_PAD8: case KEY_SHIFTED+KEY_TAB: popupdead_play_default_change_sound(); Popupdead_default_choice--; if ( Popupdead_default_choice < 0 ) { Popupdead_default_choice=Popupdead_num_choices-1; } break; case KEY_PAUSE: game_process_pause_key(); break; default: break; } // end switch // read the dead key set masked_k = k & ~KEY_CTRLED; // take out CTRL modifier only process_set_of_keys(masked_k, Dead_key_set_size, Dead_key_set); button_info_do(&Player->bi); // call functions based on status of button_info bit vectors return -1; }
// do any key processing here // input: pi => data about the popup // k => key that was pressed // // exit: 0 .. nchoices-1 => choice selected through keypress // POPUP_ABORT => abort the popup // POPUP_NOCHANGE => nothing happenned int popup_process_keys(popup_info *pi, int k, int flags) { int i, masked_k; if ( k <= 0 ) { return POPUP_NOCHANGE; } for ( i = 0; i < pi->nchoices; i++ ) { if ( pi->keypress[i] == key_to_ascii(k) ) { Popup_default_choice=i; Popup_buttons[i].press_button(); return i; } } switch(k) { case KEY_ENTER: // select the current default choice return Popup_default_choice; break; case KEY_ESC: // only process the escape key if this flag is not set if(!(flags & PF_IGNORE_ESC)){ return POPUP_ABORT; } break; case KEY_DOWN: case KEY_PAD2: case KEY_TAB: popup_play_default_change_sound(pi); Popup_default_choice++; if ( Popup_default_choice >= pi->nchoices ) { Popup_default_choice=0; } break; case KEY_UP: case KEY_PAD8: case KEY_SHIFTED+KEY_TAB: popup_play_default_change_sound(pi); Popup_default_choice--; if ( Popup_default_choice < 0 ) { Popup_default_choice=pi->nchoices-1; } break; default: break; } // end switch masked_k = k & ~KEY_CTRLED; // take out CTRL modifier only if ( (Game_mode & GM_IN_MISSION) ) { process_set_of_keys(masked_k, Dead_key_set_size, Dead_key_set); button_info_do(&Player->bi); // call functions based on status of button_info bit vectors } return POPUP_NOCHANGE; }