diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 22:06:21 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 22:21:33 +0100 |
commit | c25e1d6fd68f1f85af9e7f6dd0d35c725000014f (patch) | |
tree | efb7cb8a1d1919877c3b218a1510140935d43ec3 /jouer.c | |
parent | 8c37dc0c5e6f4e588d37f5900764125716bc7f77 (diff) |
allow to display a multiple selection
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'jouer.c')
-rw-r--r-- | jouer.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -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: |