void mechlab_input_tick(scene *scene) { mechlab_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); // Poll the controller ctrl_event *p1 = NULL, *i; controller_poll(player1->ctrl, &p1); i = p1; if(i) { do { if(i->type == EVENT_TYPE_ACTION) { // If view is new dashboard view, pass all input to it if(local->dashtype == DASHBOARD_NEW) { // If inputting text for new player name is done, switch to next view. // If ESC, exit view. // Otherwise handle text input if(i->event_data.action == ACT_ESC) { trnmenu_finish(guiframe_get_root(local->frame)); } else if(i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { mechlab_select_dashboard(scene, local, DASHBOARD_SELECT_NEW_PIC); trnmenu_finish(guiframe_get_root(local->frame)); // This will trigger exception case in mechlab_tick } else { guiframe_action(local->dashboard, i->event_data.action); } // If view is any other, just pass input to the bottom menu } else { guiframe_action(local->frame, i->event_data.action); } } } while((i = i->next)); } controller_free_chain(p1); }
void vs_input_tick(scene *scene) { vs_local *local = scene->userdata; ctrl_event *p1=NULL, *i; game_player *player1 = game_state_get_player(scene->gs, 0); controller_poll(player1->ctrl, &p1); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if (i->event_data.action == ACT_ESC) { if(dialog_is_visible(&local->too_pathetic_dialog)) { dialog_event(&local->too_pathetic_dialog, i->event_data.action); } else if(dialog_is_visible(&local->quit_dialog)) { dialog_event(&local->quit_dialog, i->event_data.action); } else if(vs_is_singleplayer(scene) && player1->sp_wins != 0) { // there's an active singleplayer campaign, confirm quitting dialog_show(&local->quit_dialog, 1); } else { game_state_set_next(scene->gs, SCENE_MELEE); } } else { vs_handle_action(scene, i->event_data.action); } } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p1); }
int cutscene_event(scene *scene, SDL_Event *event) { cutscene_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1=NULL, *i; controller_event(player1->ctrl, event, &p1); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if ( i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { if (strlen(local->current) + local->pos < local->len) { local->pos += strlen(local->current)+1; local->current += strlen(local->current)+1; char * p; if ((p = strchr(local->current, '\n'))) { // null out the byte *p = '\0'; } } else { game_state_set_next(scene->gs, cutscene_next_scene(scene)); } return 1; } } } while((i = i->next)); } controller_free_chain(p1); return 1; }
void melee_input_tick(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); ctrl_event *p1=NULL, *p2 = NULL, *i; controller_poll(player1->ctrl, &p1); controller_poll(player2->ctrl, &p2); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if (i->event_data.action == ACT_ESC) { sound_play(20, 0.5f, 0.0f, 2.0f); if (local->selection == 1) { // restore the player selection local->column_a = local->pilot_id_a % 5; local->row_a = local->pilot_id_a / 5; local->column_b = local->pilot_id_b % 5; local->row_b = local->pilot_id_b / 5; local->selection = 0; local->done_a = 0; local->done_b = 0; } else { game_state_set_next(scene->gs, SCENE_MENU); } } else { handle_action(scene, 1, i->event_data.action); } } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p1); i = p2; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 2, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p2); }
void scoreboard_input_tick(scene*scene) { scoreboard_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1 = NULL, *i; controller_poll(player1->ctrl, &p1); i = p1; if(i) { do { if(i->type == EVENT_TYPE_ACTION) { // If there is pending data, and name has been given, save if(local->has_pending_data && strlen(local->pending_data.name) > 0 && (i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH)) { handle_scoreboard_save(local); local->has_pending_data = 0; // If there is no data, and confirm is clicked, don't save } else if (local->has_pending_data == 1 && strlen(local->pending_data.name) == 0 && (i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH)) { local->has_pending_data = 0; // Normal exit routine // Only allow if there is no pending data. } else if(!local->has_pending_data && (i->event_data.action == ACT_ESC || i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH)) { game_state_set_next(scene->gs, scene->gs->next_next_id); // If left or right button is pressed, change page // but only if we are not in input mode. } else if(!local->has_pending_data && i->event_data.action == ACT_LEFT) { local->page = (local->page > 0) ? local->page-1 : 0; } else if(!local->has_pending_data && i->event_data.action == ACT_RIGHT) { local->page = (local->page < MAX_PAGES) ? local->page+1 : MAX_PAGES; } } } while((i = i->next)); } controller_free_chain(p1); }
int intro_event(scene *scene, SDL_Event *event) { game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1=NULL, *i; controller_event(player1->ctrl, event, &p1); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if(i->event_data.action == ACT_ESC || i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { game_state_set_next(scene->gs, SCENE_MENU); } } } while((i = i->next)); } controller_free_chain(p1); return 1; }
void newsroom_input_tick(scene *scene) { newsroom_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1=NULL, *i; controller_poll(player1->ctrl, &p1); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if(dialog_is_visible(&local->continue_dialog)) { dialog_event(&local->continue_dialog, i->event_data.action); } else if ( i->event_data.action == ACT_ESC || i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { local->screen++; newsroom_fixup_str(local); if(local->screen >= 2) { if (local->won) { // pick a new player game_player *p1 = game_state_get_player(scene->gs, 0); game_player *p2 = game_state_get_player(scene->gs, 1); DEBUG("wins are %d", p1->sp_wins); if (p1->sp_wins == (4094 ^ (2 << p1->pilot_id))) { // won the game game_state_set_next(scene->gs, SCENE_END); } else { if (p1->sp_wins == (2046 ^ (2 << p1->pilot_id))) { // everyone but kriessack p2->pilot_id = 10; p2->har_id = HAR_NOVA; } else { // pick an opponent we have not yet beaten while(1) { int i = rand_int(10); if ((2 << i) & p1->sp_wins || i == p1->pilot_id) { continue; } p2->pilot_id = i; p2->har_id = rand_int(10); break; } } pilot p; pilot_get_info(&p, p2->pilot_id); p2->colors[0] = p.colors[0]; p2->colors[1] = p.colors[1]; p2->colors[2] = p.colors[2]; // make a new AI controller controller *ctrl = malloc(sizeof(controller)); controller_init(ctrl); ai_controller_create(ctrl, settings_get()->gameplay.difficulty); game_player_set_ctrl(p2, ctrl); game_state_set_next(scene->gs, SCENE_VS); } } else { dialog_show(&local->continue_dialog, 1); } } } } } while((i = i->next)); } controller_free_chain(p1); }