From c25e1d6fd68f1f85af9e7f6dd0d35c725000014f Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Fri, 9 Jan 2015 22:06:21 +0100 Subject: allow to display a multiple selection Signed-off-by: Olivier Gayot --- jouer.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'jouer.c') diff --git a/jouer.c b/jouer.c index 1e4e5fa..68bfb8c 100644 --- a/jouer.c +++ b/jouer.c @@ -127,10 +127,11 @@ enum action_state_t select_target(struct action_params_t *params, void *data, struct character_t *new_selection; SDL_Event event; + /* TODO update to reflect the selection preferences */ target.is_chr = true; target.chr = params->src; - update_selected_target(surfaces, positions, target.chr); + update_selected_target(surfaces, positions, &target); SDL_Flip(surfaces->Pecran); for (;;) { @@ -147,36 +148,47 @@ enum action_state_t select_target(struct action_params_t *params, void *data, return ACTION_CANCELED; case SDLK_UP: case SDLK_k: + if (!target.is_chr) + continue; + new_selection = find_prev_team_member(target.chr); if (new_selection->idx == target.chr->idx) continue; target.chr = new_selection; - update_selected_target(surfaces, positions, target.chr); + update_selected_target(surfaces, positions, &target); SDL_Flip(surfaces->Pecran); break; case SDLK_DOWN: case SDLK_j: + if (!target.is_chr) + continue; + new_selection = find_next_team_member(target.chr); if (new_selection->idx == target.chr->idx) continue; target.chr = new_selection; - update_selected_target(surfaces, positions, target.chr); + update_selected_target(surfaces, positions, &target); SDL_Flip(surfaces->Pecran); break; case SDLK_LEFT: case SDLK_h: case SDLK_RIGHT: case SDLK_l: - new_selection = get_first_alive_character((target.chr->team == params->t1) ? params->t2 : params->t1); - if (new_selection == NULL) - continue; + if (target.is_chr) { + new_selection = get_first_alive_character((target.chr->team == params->t1) ? params->t2 : params->t1); + if (new_selection == NULL) + continue; + + target.chr = new_selection; + } else { + target.team = (target.team == params->t1) ? params->t2 : params->t1; + } - target.chr = new_selection; - update_selected_target(surfaces, positions, target.chr); + update_selected_target(surfaces, positions, &target); SDL_Flip(surfaces->Pecran); break; case SDLK_RETURN: -- cgit v1.2.3