From: Christian Heller Date: Fri, 13 Mar 2015 15:04:27 +0000 (+0100) Subject: 7DRL: Make "Things here" window scrollable. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/foo.html?a=commitdiff_plain;h=1acf96881e079649fae9504f7fe209c6c71005ca;p=plomrogue 7DRL: Make "Things here" window scrollable. --- diff --git a/README b/README index b31abfe..f2c4548 100644 --- a/README +++ b/README @@ -56,8 +56,11 @@ p - pick up item D - drop item selected in inventory u - use item selected in inventory -UP - navigate upwards in Inventory -DOWN - navigate downwards in inventory +Up - navigate upwards in inventory +Down - navigate downwards in inventory + +PgUp - scroll upwards in "Things here" window +PgDn - scroll downwards in "Things here" window Save files, replay game recording, starting over ------------------------------------------------ diff --git a/confclient/commands b/confclient/commands index 865cc3e..b93e683 100644 --- a/confclient/commands +++ b/confclient/commands @@ -113,6 +113,12 @@ DESCRIPTION 'nav down object' COMMAND inv_u DESCRIPTION 'nav up object' +COMMAND stack_d +DESCRIPTION 'nav down stack' + +COMMAND stack_u +DESCRIPTION 'nav up stack' + COMMAND keyb_dw DESCRIPTION 'nav down window keys' diff --git a/confclient/interface_conf b/confclient/interface_conf index 0db1cf4..e9fc7f4 100644 --- a/confclient/interface_conf +++ b/confclient/interface_conf @@ -30,6 +30,8 @@ KEY 68 drop KEY 117 use KEY 259 inv_u KEY 258 inv_d +KEY 339 stack_u +KEY 338 stack_d KEYBINDINGS 'wingeom' KEY 50 shift_f diff --git a/roguelike-server b/roguelike-server index cbb7a44..959d769 100755 --- a/roguelike-server +++ b/roguelike-server @@ -614,12 +614,13 @@ def log_help(): strong_write(io_db["file_out"], "LOG " + "Some objects can be used (such as: eaten) by 'u' if " + "they are in your inventory. " - + "Use 'UP'/'DOWN' to navigate the inventory.\n") + + "Use 'Up'/'Down' to navigate the inventory.\n") strong_write(io_db["file_out"], "LOG " + "Use 'l' to toggle 'look' mode (move an exploration cursor " + "instead of the player over the map).\n") + strong_write(io_db["file_out"], "LOG " + + "Use 'PgUp'/PgDn' to scroll the 'Things here' window.\n") strong_write(io_db["file_out"], "LOG See README file for more details.\n") - strong_write(io_db["file_out"], "LOG \n") def decrement_lifepoints(t): diff --git a/src/client/control.c b/src/client/control.c index 55dbd9e..93220bc 100644 --- a/src/client/control.c +++ b/src/client/control.c @@ -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)) @@ -136,6 +166,8 @@ static uint8_t try_client_commands(struct Command * command) { 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, '+') diff --git a/src/client/draw_wins.c b/src/client/draw_wins.c index 3172ef4..c8d87fc 100644 --- a/src/client/draw_wins.c +++ b/src/client/draw_wins.c @@ -546,6 +546,7 @@ extern void draw_win_terrain_stack(struct Win * win) char * wait_response = "(polling)"; char * text = world.things_here ? world.things_here : wait_response; add_text_with_linebreaks(win, text); + win->center.y = world.things_here_scroll + (win->frame_size.y / 2); // } diff --git a/src/client/io.c b/src/client/io.c index bdebef2..d9f888d 100644 --- a/src/client/io.c +++ b/src/client/io.c @@ -278,6 +278,7 @@ static uint8_t read_queue() { nl_append_string("(none known)", &world.things_here); } + world.things_here_scroll = 0; // } else if (things_here_parsing) { diff --git a/src/client/world.h b/src/client/world.h index 99ad75a..3eba28b 100644 --- a/src/client/world.h +++ b/src/client/world.h @@ -42,6 +42,7 @@ struct World struct yx_uint8 player_pos; /* coordinates of player on map */ struct yx_uint8 look_pos; /* coordinates of look cursor */ uint16_t turn; /* world/game turn */ + uint16_t things_here_scroll; /* scroll position things here win */ // 7DRL int16_t player_satiation; /* player's belly fullness */ int16_t godsmood; /* island god's mood */ // 7DRL int16_t godsfavor; /* island god's favor to player */ // 7DRL