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 "misc.h" /* for scroll_pad(), toggle_window(),
15 * growshrink_active_window()
17 #include "map_object_actions.h" /* for player_wait(), move_player() */
21 extern void record_control(int action, struct World * world)
27 else if (NORTH == action)
29 move_player(world, NORTH);
31 else if (EAST == action)
33 move_player(world, EAST);
35 else if (SOUTH == action)
37 move_player(world, SOUTH);
39 else if (WEST == action)
41 move_player(world, WEST);
47 extern uint8_t player_control(int key, struct World * world)
49 if (key == get_action_key(world->keybindings, "player up"))
51 move_player(world, NORTH);
53 else if (key == get_action_key(world->keybindings, "player right"))
55 move_player(world, EAST);
57 else if (key == get_action_key(world->keybindings, "player down"))
59 move_player(world, SOUTH);
61 else if (key == get_action_key(world->keybindings, "player left"))
63 move_player(world, WEST);
65 else if (key == get_action_key(world->keybindings, "wait / next turn"))
78 extern uint8_t meta_control(int key, struct World * world)
80 struct WinMeta * win_meta = world->wins.meta;
81 struct Win * win_keys = world->wins.keys;
82 struct Win * win_map = world->wins.map;
83 struct Win * win_info = world->wins.info;
84 struct Win * win_log = world->wins.log;
85 char * err_toggle = "Trouble with toggle_window() in meta_keys().";
86 char * err_shift = "Trouble with shift_active_win() in meta_keys().";
87 char * err_resize = "Trouble with growshrink_active_window() in "
89 if (key == get_action_key(world->keybindings, "quit"))
93 else if (key == get_action_key(world->keybindings, "scroll pad right"))
95 scroll_pad(win_meta, '+');
97 else if (key == get_action_key(world->keybindings, "scroll pad left"))
99 scroll_pad(win_meta, '-');
101 else if (key == get_action_key(world->keybindings, "toggle keys window"))
103 exit_err(toggle_window(win_meta, win_keys), world, err_toggle);
105 else if (key == get_action_key(world->keybindings, "toggle map window"))
107 exit_err(toggle_window(win_meta, win_map), world, err_toggle);
109 else if (key == get_action_key(world->keybindings, "toggle info window"))
111 exit_err(toggle_window(win_meta, win_info), world, err_toggle);
113 else if (key == get_action_key(world->keybindings, "toggle log window"))
115 exit_err(toggle_window(win_meta, win_log), world, err_toggle);
117 else if (key == get_action_key(world->keybindings, "cycle forwards"))
119 cycle_active_win(win_meta, 'f');
121 else if (key == get_action_key(world->keybindings, "cycle backwards"))
123 cycle_active_win(win_meta, 'b');
125 else if (key == get_action_key(world->keybindings, "shift forwards"))
127 exit_err(shift_active_win(win_meta, 'f'), world, err_shift);
129 else if (key == get_action_key(world->keybindings, "shift backwards"))
131 exit_err(shift_active_win(win_meta, 'b'), world, err_shift);
133 else if (key == get_action_key(world->keybindings, "grow horizontally"))
135 exit_err(growshrink_active_window(win_meta, '*'), world, err_resize);
137 else if (key == get_action_key(world->keybindings, "shrink horizontally"))
139 exit_err(growshrink_active_window(win_meta, '_'), world, err_resize);
141 else if (key == get_action_key(world->keybindings, "grow vertically"))
143 exit_err(growshrink_active_window(win_meta, '+'), world, err_resize);
145 else if (key == get_action_key(world->keybindings, "shrink vertically"))
147 exit_err(growshrink_active_window(win_meta, '-'), world, err_resize);
149 else if (key == get_action_key(world->keybindings, "save keys"))
151 save_keybindings(world);
153 else if (key == get_action_key(world->keybindings, "keys nav up"))
155 keyswin_move_selection (world, 'u');
157 else if (key == get_action_key(world->keybindings, "keys nav down"))
159 keyswin_move_selection (world, 'd');
161 else if (key == get_action_key(world->keybindings, "keys mod"))
163 keyswin_mod_key (world, win_meta);
165 else if (key == get_action_key(world->keybindings, "map up"))
167 map_scroll(world->map, NORTH, win_map->frame.size);
169 else if (key == get_action_key(world->keybindings, "map down"))
171 map_scroll(world->map, SOUTH, win_map->frame.size);
173 else if (key == get_action_key(world->keybindings, "map right"))
175 map_scroll(world->map, EAST, win_map->frame.size);
177 else if (key == get_action_key(world->keybindings, "map left"))
179 map_scroll(world->map, WEST, win_map->frame.size);
181 else if (key == get_action_key(world->keybindings, "map center player"))
183 map_center_player (world->map, world->player, win_map->frame.size);