#include "keybindings.h" /* for get_keycode_to_action(), mod_selected_keyb(),
* move_keyb_mod_selection()
*/
-#include "map.h" /* for map_scroll(), map_center_object() */
-#include "main.h" /* for World struct */
+#include "map.h" /* for map_scroll() */
+#include "main.h" /* for world global */
#include "rexit.h" /* for exit_err() */
#include "wincontrol.h" /* for scroll_pad(), toggle_window(),
* growshrink_active_window(), toggle_winconfig(),
* toggle_win_height_type(), toggle_win_width_type()
*/
-#include "map_object_actions.h" /* for player_wait(), move_player() */
+#include "map_object_actions.h" /* for player_wait(), move_player(),
+ * player_drop(), player_pick()
+ */
#include "command_db.h" /* for is_command_id_shortdsc() */
#include "misc.h" /* for load_interface_conf(), unload_interface_conf(),
- * save_interface_conf()
+ * save_interface_conf(), nav_inventory()
*/
#include "yx_uint16.h" /* for dir enum */
#include "map_objects.h" /* for get_player() */
-extern uint16_t get_available_keycode_to_action(struct World * world,
- char * name)
+extern uint16_t get_available_keycode_to_action(char * name)
{
- uint16_t keycode = get_keycode_to_action(world->kb_global.kbs, name);
- if (0 != keycode || 0 == world->wmeta->active)
+ uint16_t keycode = get_keycode_to_action(world.kb_global.kbs, name);
+ if (0 != keycode || 0 == world.wmeta->active)
{
return keycode;
}
- struct WinConf * wc = get_winconf_by_win(world, world->wmeta->active);
+ struct WinConf * wc = get_winconf_by_win(world.wmeta->active);
if (0 == wc->view)
{
keycode = get_keycode_to_action(wc->kb.kbs, name);
}
else if (1 == wc->view)
{
- keycode = get_keycode_to_action(world->kb_wingeom.kbs, name);
+ keycode = get_keycode_to_action(world.kb_wingeom.kbs, name);
}
else if (2 == wc->view)
{
- keycode = get_keycode_to_action(world->kb_winkeys.kbs, name);
+ keycode = get_keycode_to_action(world.kb_winkeys.kbs, name);
}
return keycode;
}
-extern void record_control(int action, struct World * world)
+extern void record_control(int action)
{
- if (is_command_id_shortdsc(world, action, "wait"))
+ if (is_command_id_shortdsc(action, "wait"))
{
- player_wait(world);
+ player_wait();
}
- else if (is_command_id_shortdsc(world, action, "player_u"))
+ else if (is_command_id_shortdsc(action, "player_u"))
{
- move_player(world, NORTH);
+ move_player(NORTH);
}
- else if (is_command_id_shortdsc(world, action, "player_r"))
+ else if (is_command_id_shortdsc(action, "player_r"))
{
- move_player(world, EAST);
+ move_player(EAST);
}
- else if (is_command_id_shortdsc(world, action, "player_d"))
+ else if (is_command_id_shortdsc(action, "player_d"))
{
- move_player(world, SOUTH);
+ move_player(SOUTH);
}
- else if (is_command_id_shortdsc(world, action, "player_l"))
+ else if (is_command_id_shortdsc(action, "player_l"))
{
- move_player(world, WEST);
+ move_player(WEST);
+ }
+ else if (is_command_id_shortdsc(action, "drop"))
+ {
+ player_drop();
+ }
+ else if (is_command_id_shortdsc(action, "pick"))
+ {
+ player_pick();
}
}
-extern uint8_t player_control(int key, struct World * world)
+extern uint8_t player_control(int key)
{
- if (key == get_available_keycode_to_action(world, "player_u"))
+ if (key == get_available_keycode_to_action("wait"))
{
- move_player(world, NORTH);
+ player_wait();
}
- else if (key == get_available_keycode_to_action(world, "player_r"))
+ else if (key == get_available_keycode_to_action("player_u"))
{
- move_player(world, EAST);
+ move_player(NORTH);
}
- else if (key == get_available_keycode_to_action(world, "player_d"))
+ else if (key == get_available_keycode_to_action("player_r"))
{
- move_player(world, SOUTH);
+ move_player(EAST);
}
- else if (key == get_available_keycode_to_action(world, "player_l"))
+ else if (key == get_available_keycode_to_action("player_d"))
{
- move_player(world, WEST);
+ move_player(SOUTH);
}
- else if (key == get_available_keycode_to_action(world, "wait"))
+ else if (key == get_available_keycode_to_action("player_l"))
{
- player_wait(world);
+ move_player(WEST);
+ }
+ else if (key == get_available_keycode_to_action("drop"))
+ {
+ player_drop();
+ }
+ else if (key == get_available_keycode_to_action("pick"))
+ {
+ player_pick();
}
else
{
-extern uint8_t wingeom_control(int key, struct World * world)
+extern uint8_t wingeom_control(int key)
{
char * err_shift = "Trouble with shift_active_win() in wingeom_control().";
char * err_resize = "Trouble with growshrink_active_window() in "
"wingeom_control().";
- if (key == get_available_keycode_to_action(world, "to_height_t"))
+ if (key == get_available_keycode_to_action("to_height_t"))
{
- toggle_win_height_type(world, world->wmeta->active);
+ toggle_win_height_type(world.wmeta->active);
}
- else if (key == get_available_keycode_to_action(world, "to_width_t"))
+ else if (key == get_available_keycode_to_action("to_width_t"))
{
- toggle_win_width_type(world, world->wmeta->active);
+ toggle_win_width_type(world.wmeta->active);
}
- else if (key == get_available_keycode_to_action(world, "grow_h"))
+ else if (key == get_available_keycode_to_action("grow_h"))
{
- exit_err(growshrink_active_window(world, '*'), world, err_resize);
+ exit_err(growshrink_active_window('*'), err_resize);
}
- else if (key == get_available_keycode_to_action(world, "shri_h"))
+ else if (key == get_available_keycode_to_action("shri_h"))
{
- exit_err(growshrink_active_window(world, '_'), world, err_resize);
+ exit_err(growshrink_active_window('_'), err_resize);
}
- else if (key == get_available_keycode_to_action(world, "grow_v"))
+ else if (key == get_available_keycode_to_action("grow_v"))
{
- exit_err(growshrink_active_window(world, '+'), world, err_resize);
+ exit_err(growshrink_active_window('+'), err_resize);
}
- else if (key == get_available_keycode_to_action(world, "shri_v"))
+ else if (key == get_available_keycode_to_action("shri_v"))
{
- exit_err(growshrink_active_window(world, '-'), world, err_resize);
+ exit_err(growshrink_active_window('-'), err_resize);
}
- else if (key == get_available_keycode_to_action(world, "shift_f"))
+ else if (key == get_available_keycode_to_action("shift_f"))
{
- exit_err(shift_active_win(world->wmeta, 'f'), world, err_shift);
+ exit_err(shift_active_win(world.wmeta, 'f'), err_shift);
}
- else if (key == get_available_keycode_to_action(world, "shift_b"))
+ else if (key == get_available_keycode_to_action("shift_b"))
{
- exit_err(shift_active_win(world->wmeta, 'b'), world, err_shift);
+ exit_err(shift_active_win(world.wmeta, 'b'), err_shift);
}
else
{
-extern uint8_t winkeyb_control(int key, struct World * world)
+extern uint8_t winkeyb_control(int key)
{
- struct WinConf * wc = get_winconf_by_win(world, world->wmeta->active);
- if (key == get_available_keycode_to_action(world, "w_keys_u"))
+ struct WinConf * wc = get_winconf_by_win(world.wmeta->active);
+ if (key == get_available_keycode_to_action("w_keys_u"))
{
move_keyb_mod_selection(&wc->kb, 'u');
}
- else if (key == get_available_keycode_to_action(world, "w_keys_d"))
+ else if (key == get_available_keycode_to_action("w_keys_d"))
{
move_keyb_mod_selection(&wc->kb, 'd');
}
- else if (key == get_available_keycode_to_action(world, "w_keys_m"))
+ else if (key == get_available_keycode_to_action("w_keys_m"))
{
- mod_selected_keyb(world, &wc->kb);
+ mod_selected_keyb(&wc->kb);
}
else
{
-extern uint8_t meta_control(int key, struct World * world)
+extern uint8_t meta_control(int key)
{
- struct WinMeta * win_meta = world->wmeta;
- struct Win * win_map = get_win_by_id(world, 'm');
+ struct WinMeta * win_meta = world.wmeta;
+ struct Win * win_map = get_win_by_id('m');
char * err_toggle = "Trouble with toggle_window() in meta_control().";
- if (key == get_available_keycode_to_action(world, "quit"))
+ if (key == get_available_keycode_to_action("quit"))
{
return 1;
}
- else if (key == get_available_keycode_to_action(world, "winconf"))
+ else if (key == get_available_keycode_to_action("winconf"))
{
- toggle_winconfig(world, world->wmeta->active);
+ toggle_winconfig(world.wmeta->active);
}
- else if (key == get_available_keycode_to_action(world, "cyc_win_f"))
+ else if (key == get_available_keycode_to_action("cyc_win_f"))
{
- cycle_active_win(world->wmeta, 'f');
+ cycle_active_win(world.wmeta, 'f');
}
- else if (key == get_available_keycode_to_action(world, "cyc_win_b"))
+ else if (key == get_available_keycode_to_action("cyc_win_b"))
{
- cycle_active_win(world->wmeta, 'b');
+ cycle_active_win(world.wmeta, 'b');
}
- else if (key == get_available_keycode_to_action(world, "scrl_r"))
+ else if (key == get_available_keycode_to_action("scrl_r"))
{
scroll_pad(win_meta, '+');
}
- else if (key == get_available_keycode_to_action(world, "scrl_l"))
+ else if (key == get_available_keycode_to_action("scrl_l"))
{
scroll_pad(win_meta, '-');
}
- else if (key == get_available_keycode_to_action(world, "to_a_keywin"))
+ else if (key == get_available_keycode_to_action("to_a_keywin"))
+ {
+ exit_err(toggle_window(win_meta, get_win_by_id('k')), err_toggle);
+ }
+ else if (key == get_available_keycode_to_action("to_g_keywin"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, 'k'));
- exit_err(test, world, err_toggle);
+ exit_err(toggle_window(win_meta, get_win_by_id('0')), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_g_keywin"))
+ else if (key == get_available_keycode_to_action("to_wg_keywin"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, '0'));
- exit_err(test, world, err_toggle);
+ exit_err(toggle_window(win_meta, get_win_by_id('1')), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_wg_keywin"))
+ else if (key == get_available_keycode_to_action("to_wk_keywin"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, '1'));
- exit_err(test, world, err_toggle);
+ exit_err(toggle_window(win_meta, get_win_by_id('2')), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_wk_keywin"))
+ else if (key == get_available_keycode_to_action("to_mapwin"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, '2'));
- exit_err(test, world, err_toggle);
+ exit_err(toggle_window(win_meta, win_map), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_mapwin"))
+ else if (key == get_available_keycode_to_action("to_infowin"))
{
- exit_err(toggle_window(win_meta, win_map), world, err_toggle);
+ exit_err(toggle_window(win_meta, get_win_by_id('i')), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_infowin"))
+ else if (key == get_available_keycode_to_action("to_inv"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, 'i'));
- exit_err(test, world, err_toggle);
+ exit_err(toggle_window(win_meta, get_win_by_id('c')), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_inv"))
+ else if (key == get_available_keycode_to_action("to_logwin"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, 'c'));
- exit_err(test, world, err_toggle);
+ exit_err(toggle_window(win_meta, get_win_by_id('l')), err_toggle);
}
- else if (key == get_available_keycode_to_action(world, "to_logwin"))
+ else if (key == get_available_keycode_to_action("save_conf"))
{
- uint8_t test = toggle_window(win_meta, get_win_by_id(world, 'l'));
- exit_err(test, world, err_toggle);
+ save_interface_conf();
}
- else if (key == get_available_keycode_to_action(world, "save_conf"))
+ else if (key == get_available_keycode_to_action("g_keys_u"))
{
- save_interface_conf(world);
+ move_keyb_mod_selection(&world.kb_global, 'u');
}
- else if (key == get_available_keycode_to_action(world, "g_keys_u"))
+ else if (key == get_available_keycode_to_action("g_keys_d"))
{
- move_keyb_mod_selection(&world->kb_global, 'u');
+ move_keyb_mod_selection(&world.kb_global, 'd');
}
- else if (key == get_available_keycode_to_action(world, "g_keys_d"))
+ else if (key == get_available_keycode_to_action("g_keys_m"))
{
- move_keyb_mod_selection(&world->kb_global, 'd');
+ mod_selected_keyb(&world.kb_global);
}
- else if (key == get_available_keycode_to_action(world, "g_keys_m"))
+ else if (key == get_available_keycode_to_action("wg_keys_u"))
{
- mod_selected_keyb(world, &world->kb_global);
+ move_keyb_mod_selection(&world.kb_wingeom, 'u');
}
- else if (key == get_available_keycode_to_action(world, "wg_keys_u"))
+ else if (key == get_available_keycode_to_action("wg_keys_d"))
{
- move_keyb_mod_selection(&world->kb_wingeom, 'u');
+ move_keyb_mod_selection(&world.kb_wingeom, 'd');
}
- else if (key == get_available_keycode_to_action(world, "wg_keys_d"))
+ else if (key == get_available_keycode_to_action("wg_keys_m"))
{
- move_keyb_mod_selection(&world->kb_wingeom, 'd');
+ mod_selected_keyb(&world.kb_wingeom);
}
- else if (key == get_available_keycode_to_action(world, "wg_keys_m"))
+ else if (key == get_available_keycode_to_action("wk_keys_u"))
{
- mod_selected_keyb(world, &world->kb_wingeom);
+ move_keyb_mod_selection(&world.kb_winkeys, 'u');
}
- else if (key == get_available_keycode_to_action(world, "wk_keys_u"))
+ else if (key == get_available_keycode_to_action("wk_keys_d"))
{
- move_keyb_mod_selection(&world->kb_winkeys, 'u');
+ move_keyb_mod_selection(&world.kb_winkeys, 'd');
}
- else if (key == get_available_keycode_to_action(world, "wk_keys_d"))
+ else if (key == get_available_keycode_to_action("wk_keys_m"))
{
- move_keyb_mod_selection(&world->kb_winkeys, 'd');
+ mod_selected_keyb(&world.kb_winkeys);
}
- else if (key == get_available_keycode_to_action(world, "wk_keys_m"))
+ else if (key == get_available_keycode_to_action("map_u"))
{
- mod_selected_keyb(world, &world->kb_winkeys);
+ map_scroll(win_map, world.map->size, NORTH);
}
- else if (key == get_available_keycode_to_action(world, "map_u"))
+ else if (key == get_available_keycode_to_action("map_d"))
{
- map_scroll(world->map, NORTH, win_map->frame.size);
- }
- else if (key == get_available_keycode_to_action(world, "map_d"))
+ map_scroll(win_map, world.map->size, SOUTH);
+ }
+ else if (key == get_available_keycode_to_action("map_r"))
+ {
+ map_scroll(win_map, world.map->size, EAST);
+ }
+ else if (key == get_available_keycode_to_action("map_l"))
{
- map_scroll(world->map, SOUTH, win_map->frame.size);
+ map_scroll(win_map, world.map->size, WEST);
}
- else if (key == get_available_keycode_to_action(world, "map_r"))
+ else if (key == get_available_keycode_to_action("map_c"))
{
- map_scroll(world->map, EAST, win_map->frame.size);
+ struct MapObj * player = get_player();
+ win_map->center = player->pos;
}
- else if (key == get_available_keycode_to_action(world, "map_l"))
+ else if (key == get_available_keycode_to_action("inv_u"))
{
- map_scroll(world->map, WEST, win_map->frame.size);
+ nav_inventory('u');
}
- else if (key == get_available_keycode_to_action(world, "map_c"))
+ else if (key == get_available_keycode_to_action("inv_d"))
{
- map_center_object(world->map, get_player(world), win_map->frame.size);
+ nav_inventory('d');
}
- else if (key == get_available_keycode_to_action(world, "reload_conf"))
+ else if (key == get_available_keycode_to_action("reload_conf"))
{
- unload_interface_conf(world);
- load_interface_conf(world);
+ unload_interface_conf();
+ load_interface_conf();
}
- else if (key == get_available_keycode_to_action(world, "winconf"))
+ else if (key == get_available_keycode_to_action("winconf"))
{
- toggle_winconfig(world, world->wmeta->active);
+ toggle_winconfig(world.wmeta->active);
}
return 0;
}