X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fclient%2Fcontrol.c;h=93220bc2c2881e54bd6ec39e32a8aea5b2c1d94d;hb=5987599c7531fb17ad174824335d99339200f306;hp=d525d56fc5b228da59edb082f0e65a8f8368a698;hpb=66f67a2d7e34283a2261b90e5c3c6cdf87fdae7f;p=plomrogue diff --git a/src/client/control.c b/src/client/control.c index d525d56..93220bc 100644 --- a/src/client/control.c +++ b/src/client/control.c @@ -17,7 +17,7 @@ #include "keybindings.h" /* get_command_to_keycode(), get_keycode_to_command(), * mod_selected_keyb(), move_keyb_selection() */ -#include "map.h" /* map_scroll(), map_center(), toggle_autofocus() */ +#include "map.h" /* toggle_lookmode(), lookmode_nav()*/ #include "wincontrol.h" /* shift_active_win(), resize_active_win(), * toggle_win_size_type(), toggle_window(), * cycle_active_win(), scroll_v_screen(), @@ -87,6 +87,36 @@ static void nav_inventory(char dir) +static void nav_stack(char dir) // +{ + FILE * file = fopen("test", "a"); + fprintf(file, "called %d\n", world.things_here_scroll); + if ('u' == dir && world.things_here_scroll > 0) + { + world.things_here_scroll--; + fprintf(file, "u\n"); + } + else if ('d' == dir && world.things_here) + { + uint32_t i; + uint32_t n_lines = 1; + for (i = 0; '\0' != world.things_here[i]; i++) + { + n_lines = n_lines + (world.things_here[i] == '\n'); + } + uint16_t f_h = get_win_by_id('s')->frame_size.y; + fprintf(file, "%d %d\n", n_lines, f_h); + if (n_lines > f_h && world.things_here_scroll < n_lines - f_h) + { + world.things_here_scroll++; + } + fprintf(file, "d %d\n", world.things_here_scroll); + } + fclose(file); +} + + + static uint8_t try_0args(struct Command * command, char * match, void (* f) ()) { if (!strcmp(command->dsc_short, match)) @@ -134,19 +164,14 @@ static uint8_t try_kb_manip(char * command) static uint8_t try_client_commands(struct Command * command) { - return ( try_0args(command, "map_c", map_center) - || try_0args(command, "to_autofocus", toggle_autofocus) - || try_1args(command, "map_u", map_scroll, '8') - || try_1args(command, "map_d", map_scroll, '2') - || try_1args(command, "map_r", map_scroll, '6') - || try_1args(command, "map_l", map_scroll, '4') - || try_1args(command, "inv_u", nav_inventory, 'u') + return ( try_1args(command, "inv_u", nav_inventory, 'u') || try_1args(command, "inv_d", nav_inventory, 'd') + || try_1args(command, "stack_u", nav_stack, 'u') // + || try_1args(command, "stack_d", nav_stack, 'd') // || try_1args(command, "cyc_win_f", cycle_active_win, 'f') || try_1args(command, "cyc_win_b", cycle_active_win, 'b') || try_1args(command, "scrl_r", scroll_v_screen, '+') || try_1args(command, "scrl_l", scroll_v_screen, '-') - || try_1args(command, "to_a_keywin", toggle_window, 'a') || try_1args(command, "to_g_keywin", toggle_window, '0') || try_1args(command, "to_wg_keywin", toggle_window, '1') || try_1args(command, "to_wk_keywin", toggle_window, '2') @@ -154,6 +179,7 @@ static uint8_t try_client_commands(struct Command * command) || try_1args(command, "to_infowin", toggle_window, 'i') || try_1args(command, "to_inv", toggle_window, 'c') || try_1args(command, "to_logwin", toggle_window, 'l') + || try_1args(command, "to_terrain", toggle_window, 's') || try_0args(command, "winconf", toggle_winconfig) || try_1args(command, "grow_h", resize_active_win, '*') || try_1args(command, "shri_h", resize_active_win, '_') @@ -166,6 +192,7 @@ static uint8_t try_client_commands(struct Command * command) || try_1args(command, "shift_b", shift_active_win, 'b') || try_0args(command, "reload_conf", reload_interface_conf) || try_0args(command, "save_conf", save_interface_conf) + || try_0args(command, "to_look", toggle_lookmode) || try_kb_manip(command->dsc_short)); } @@ -263,7 +290,7 @@ extern uint8_t try_key(uint16_t key) } if (command) { - if (try_server_commands(command)) + if (world.look && lookmode_nav(command->dsc_short)) { return 1; } @@ -271,6 +298,10 @@ extern uint8_t try_key(uint16_t key) { return 1; } + else if (try_server_commands(command)) + { + return 1; + } else if (!strcmp("quit", command->dsc_short)) { return 2;