X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fcontrol.c;h=273fddc29481c1a88176ea5433ab510a00cd859e;hb=d4693165cda2814c544e05b219c2cf3798e31857;hp=e10a93cbbc78ab149ec0daad7c94f1691c4e967e;hpb=fcf58a650b9c0a9c3aa08c2c25ea14d70e08f8c7;p=plomrogue diff --git a/src/control.c b/src/control.c index e10a93c..273fddc 100644 --- a/src/control.c +++ b/src/control.c @@ -11,19 +11,80 @@ #include "map.h" /* for map_scroll(), map_center_player(), dir enum */ #include "main.h" /* for World struct */ #include "rexit.h" /* for exit_err() */ -#include "misc.h" /* for scroll_pad(), toggle_window(), - * growshrink_active_window() - */ +#include "wincontrol.h" /* for scroll_pad(), toggle_window(), + * growshrink_active_window(), reload_win_config() + * toggle_winconfig(), save_win_configs(), + * toggle_win_height_type(), toggle_win_width_type() + */ +#include "map_object_actions.h" /* for player_wait(), move_player() */ +#include "command_db.h" /* for is_command_id_shortdsc() */ -extern uint8_t meta_keys(int key, struct World * world) +extern void record_control(int action, struct World * world) { - struct WinMeta * win_meta = world->wins.meta; - struct Win * win_keys = world->wins.keys; - struct Win * win_map = world->wins.map; - struct Win * win_info = world->wins.info; - struct Win * win_log = world->wins.log; + if (is_command_id_shortdsc(world, action, "wait")) + { + player_wait(world); + } + else if (is_command_id_shortdsc(world, action, "player_u")) + { + move_player(world, NORTH); + } + else if (is_command_id_shortdsc(world, action, "player_r")) + { + move_player(world, EAST); + } + else if (is_command_id_shortdsc(world, action, "player_d")) + { + move_player(world, SOUTH); + } + else if (is_command_id_shortdsc(world, action, "player_l")) + { + move_player(world, WEST); + } +} + + + +extern uint8_t player_control(int key, struct World * world) +{ + if (key == get_action_key(world->keybindings, "player_u")) + { + move_player(world, NORTH); + } + else if (key == get_action_key(world->keybindings, "player_r")) + { + move_player(world, EAST); + } + else if (key == get_action_key(world->keybindings, "player_d")) + { + move_player(world, SOUTH); + } + else if (key == get_action_key(world->keybindings, "player_l")) + { + move_player(world, WEST); + } + else if (key == get_action_key(world->keybindings, "wait")) + { + player_wait(world); + } + else + { + return 1; + } + return 0; +} + + + +extern uint8_t meta_control(int key, struct World * world) +{ + struct WinMeta * win_meta = world->wmeta; + struct Win * win_keys = get_win_by_id(world, 'k'); + struct Win * win_map = get_win_by_id(world, 'm'); + struct Win * win_info = get_win_by_id(world, 'i'); + struct Win * win_log = get_win_by_id(world, 'l'); char * err_toggle = "Trouble with toggle_window() in meta_keys()."; char * err_shift = "Trouble with shift_active_win() in meta_keys()."; char * err_resize = "Trouble with growshrink_active_window() in " @@ -32,97 +93,117 @@ extern uint8_t meta_keys(int key, struct World * world) { return 1; } - else if (key == get_action_key(world->keybindings, "scroll pad right")) + else if (key == get_action_key(world->keybindings, "scrl_r")) { scroll_pad(win_meta, '+'); } - else if (key == get_action_key(world->keybindings, "scroll pad left")) + else if (key == get_action_key(world->keybindings, "scrl_l")) { scroll_pad(win_meta, '-'); } - else if (key == get_action_key(world->keybindings, "toggle keys window")) + else if (key == get_action_key(world->keybindings, "to_keywin")) { exit_err(toggle_window(win_meta, win_keys), world, err_toggle); } - else if (key == get_action_key(world->keybindings, "toggle map window")) + else if (key == get_action_key(world->keybindings, "to_mapwin")) { exit_err(toggle_window(win_meta, win_map), world, err_toggle); } - else if (key == get_action_key(world->keybindings, "toggle info window")) + else if (key == get_action_key(world->keybindings, "to_infowin")) { exit_err(toggle_window(win_meta, win_info), world, err_toggle); } - else if (key == get_action_key(world->keybindings, "toggle log window")) + else if (key == get_action_key(world->keybindings, "to_logwin")) { exit_err(toggle_window(win_meta, win_log), world, err_toggle); } - else if (key == get_action_key(world->keybindings, "cycle forwards")) + else if (key == get_action_key(world->keybindings, "cyc_win_f")) { cycle_active_win(win_meta, 'f'); } - else if (key == get_action_key(world->keybindings, "cycle backwards")) + else if (key == get_action_key(world->keybindings, "cyc_win_b")) { cycle_active_win(win_meta, 'b'); } - else if (key == get_action_key(world->keybindings, "shift forwards")) + else if (key == get_action_key(world->keybindings, "shift_f")) { exit_err(shift_active_win(win_meta, 'f'), world, err_shift); } - else if (key == get_action_key(world->keybindings, "shift backwards")) + else if (key == get_action_key(world->keybindings, "shift_b")) { exit_err(shift_active_win(win_meta, 'b'), world, err_shift); } - else if (key == get_action_key(world->keybindings, "grow horizontally")) + else if (key == get_action_key(world->keybindings, "grow_h")) { - exit_err(growshrink_active_window(win_meta, '*'), world, err_resize); + exit_err(growshrink_active_window(world, '*'), world, err_resize); } - else if (key == get_action_key(world->keybindings, "shrink horizontally")) + else if (key == get_action_key(world->keybindings, "shri_h")) { - exit_err(growshrink_active_window(win_meta, '_'), world, err_resize); + exit_err(growshrink_active_window(world, '_'), world, err_resize); } - else if (key == get_action_key(world->keybindings, "grow vertically")) + else if (key == get_action_key(world->keybindings, "grow_v")) { - exit_err(growshrink_active_window(win_meta, '+'), world, err_resize); + exit_err(growshrink_active_window(world, '+'), world, err_resize); } - else if (key == get_action_key(world->keybindings, "shrink vertically")) + else if (key == get_action_key(world->keybindings, "shri_v")) { - exit_err(growshrink_active_window(win_meta, '-'), world, err_resize); + exit_err(growshrink_active_window(world, '-'), world, err_resize); } - else if (key == get_action_key(world->keybindings, "save keys")) + else if (key == get_action_key(world->keybindings, "save_keys")) { save_keybindings(world); } - else if (key == get_action_key(world->keybindings, "keys nav up")) + else if (key == get_action_key(world->keybindings, "keys_u")) { - keyswin_move_selection (world, 'u'); + keyswin_move_selection(world, 'u'); } - else if (key == get_action_key(world->keybindings, "keys nav down")) + else if (key == get_action_key(world->keybindings, "keys_d")) { - keyswin_move_selection (world, 'd'); + keyswin_move_selection(world, 'd'); } - else if (key == get_action_key(world->keybindings, "keys mod")) + else if (key == get_action_key(world->keybindings, "keys_m")) { - keyswin_mod_key (world, win_meta); + keyswin_mod_key(world, win_meta); } - else if (key == get_action_key(world->keybindings, "map up")) + else if (key == get_action_key(world->keybindings, "map_u")) { map_scroll(world->map, NORTH, win_map->frame.size); } - else if (key == get_action_key(world->keybindings, "map down")) + else if (key == get_action_key(world->keybindings, "map_d")) { map_scroll(world->map, SOUTH, win_map->frame.size); } - else if (key == get_action_key(world->keybindings, "map right")) + else if (key == get_action_key(world->keybindings, "map_r")) { map_scroll(world->map, EAST, win_map->frame.size); } - else if (key == get_action_key(world->keybindings, "map left")) + else if (key == get_action_key(world->keybindings, "map_l")) { map_scroll(world->map, WEST, win_map->frame.size); } - else if (key == get_action_key(world->keybindings, "map center player")) + else if (key == get_action_key(world->keybindings, "map_c")) + { + map_center_player(world->map, world->player, win_map->frame.size); + } + else if (key == get_action_key(world->keybindings, "reload_wins")) + { + reload_win_config(world); + } + else if (key == get_action_key(world->keybindings, "winconf")) + { + toggle_winconfig(world, world->wmeta->active); + } + else if (key == get_action_key(world->keybindings, "to_height_t")) + { + toggle_win_height_type(world, world->wmeta->active); + } + else if (key == get_action_key(world->keybindings, "to_width_t")) + { + toggle_win_width_type(world, world->wmeta->active); + } + else if (key == get_action_key(world->keybindings, "save_winconf")) { - map_center_player (world->map, world->player, win_map->frame.size); + save_win_configs(world); } return 0; }