4 #include <stdint.h> /* for uint8_t */
5 #include "windows.h" /* for cycle_active_win(), shift_active_win(), struct Win,
8 #include "keybindings.h" /* for get_action_key(), save_keybindings(),
9 * keyswin_move_selection(), keyswin_mod_key()
11 #include "map.h" /* for map_scroll(), map_center_player(), dir enum */
12 #include "main.h" /* for World struct */
13 #include "rexit.h" /* for exit_err() */
14 #include "wincontrol.h" /* for scroll_pad(), toggle_window(),
15 * growshrink_active_window()
17 #include "map_object_actions.h" /* for player_wait(), move_player() */
18 #include "command_db.h" /* for is_command_id_shortdsc() */
22 extern void record_control(int action, struct World * world)
24 if (is_command_id_shortdsc(world, action, "wait"))
28 else if (is_command_id_shortdsc(world, action, "player_u"))
30 move_player(world, NORTH);
32 else if (is_command_id_shortdsc(world, action, "player_r"))
34 move_player(world, EAST);
36 else if (is_command_id_shortdsc(world, action, "player_d"))
38 move_player(world, SOUTH);
40 else if (is_command_id_shortdsc(world, action, "player_l"))
42 move_player(world, WEST);
48 extern uint8_t player_control(int key, struct World * world)
50 if (key == get_action_key(world->keybindings, "player_u"))
52 move_player(world, NORTH);
54 else if (key == get_action_key(world->keybindings, "player_r"))
56 move_player(world, EAST);
58 else if (key == get_action_key(world->keybindings, "player_d"))
60 move_player(world, SOUTH);
62 else if (key == get_action_key(world->keybindings, "player_l"))
64 move_player(world, WEST);
66 else if (key == get_action_key(world->keybindings, "wait"))
79 extern uint8_t meta_control(int key, struct World * world)
81 struct WinMeta * win_meta = world->wins.meta;
82 struct Win * win_keys = world->wins.keys;
83 struct Win * win_map = world->wins.map;
84 struct Win * win_info = world->wins.info;
85 struct Win * win_log = world->wins.log;
86 char * err_toggle = "Trouble with toggle_window() in meta_keys().";
87 char * err_shift = "Trouble with shift_active_win() in meta_keys().";
88 char * err_resize = "Trouble with growshrink_active_window() in "
90 if (key == get_action_key(world->keybindings, "quit"))
94 else if (key == get_action_key(world->keybindings, "scrl_r"))
96 scroll_pad(win_meta, '+');
98 else if (key == get_action_key(world->keybindings, "scrl_l"))
100 scroll_pad(win_meta, '-');
102 else if (key == get_action_key(world->keybindings, "to_keywin"))
104 exit_err(toggle_window(win_meta, win_keys), world, err_toggle);
106 else if (key == get_action_key(world->keybindings, "to_mapwin"))
108 exit_err(toggle_window(win_meta, win_map), world, err_toggle);
110 else if (key == get_action_key(world->keybindings, "to_infowin"))
112 exit_err(toggle_window(win_meta, win_info), world, err_toggle);
114 else if (key == get_action_key(world->keybindings, "to_logwin"))
116 exit_err(toggle_window(win_meta, win_log), world, err_toggle);
118 else if (key == get_action_key(world->keybindings, "cyc_win_f"))
120 cycle_active_win(win_meta, 'f');
122 else if (key == get_action_key(world->keybindings, "cyc_win_b"))
124 cycle_active_win(win_meta, 'b');
126 else if (key == get_action_key(world->keybindings, "shift_f"))
128 exit_err(shift_active_win(win_meta, 'f'), world, err_shift);
130 else if (key == get_action_key(world->keybindings, "shift_b"))
132 exit_err(shift_active_win(win_meta, 'b'), world, err_shift);
134 else if (key == get_action_key(world->keybindings, "grow_h"))
136 exit_err(growshrink_active_window(win_meta, '*'), world, err_resize);
138 else if (key == get_action_key(world->keybindings, "shri_h"))
140 exit_err(growshrink_active_window(win_meta, '_'), world, err_resize);
142 else if (key == get_action_key(world->keybindings, "grow_v"))
144 exit_err(growshrink_active_window(win_meta, '+'), world, err_resize);
146 else if (key == get_action_key(world->keybindings, "shri_v"))
148 exit_err(growshrink_active_window(win_meta, '-'), world, err_resize);
150 else if (key == get_action_key(world->keybindings, "save_keys"))
152 save_keybindings(world);
154 else if (key == get_action_key(world->keybindings, "keys_u"))
156 keyswin_move_selection(world, 'u');
158 else if (key == get_action_key(world->keybindings, "keys_d"))
160 keyswin_move_selection(world, 'd');
162 else if (key == get_action_key(world->keybindings, "keys_m"))
164 keyswin_mod_key(world, win_meta);
166 else if (key == get_action_key(world->keybindings, "map_u"))
168 map_scroll(world->map, NORTH, win_map->frame.size);
170 else if (key == get_action_key(world->keybindings, "map_d"))
172 map_scroll(world->map, SOUTH, win_map->frame.size);
174 else if (key == get_action_key(world->keybindings, "map_r"))
176 map_scroll(world->map, EAST, win_map->frame.size);
178 else if (key == get_action_key(world->keybindings, "map_l"))
180 map_scroll(world->map, WEST, win_map->frame.size);
182 else if (key == get_action_key(world->keybindings, "map_c"))
184 map_center_player (world->map, world->player, win_map->frame.size);