From: Pasi Kallinen Date: Fri, 3 Jun 2016 18:08:43 +0000 (+0300) Subject: Split direction key showing into separate function X-Git-Tag: NetHack-3.6.1_RC01~706 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d594f77c29cc01ce633177b0d67d9ef11add521;p=nethack Split direction key showing into separate function --- diff --git a/src/cmd.c b/src/cmd.c index ae2b2bb84..475010512 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -183,6 +183,7 @@ static const char *readchar_queue = ""; static coord clicklook_cc; STATIC_DCL char *NDECL(parse); +STATIC_DCL void FDECL(show_direction_keys, (winid, boolean)); STATIC_DCL boolean FDECL(help_dir, (CHAR_P, const char *)); STATIC_PTR int @@ -3790,6 +3791,37 @@ retry: return 1; } +STATIC_OVL void +show_direction_keys(win, nodiag) +winid win; +boolean nodiag; +{ + char buf[BUFSZ]; + + if (nodiag) { + Sprintf(buf, " %c ", Cmd.move_N); + putstr(win, 0, buf); + putstr(win, 0, " | "); + Sprintf(buf, " %c- . -%c", Cmd.move_W, Cmd.move_E); + putstr(win, 0, buf); + putstr(win, 0, " | "); + Sprintf(buf, " %c ", Cmd.move_S); + putstr(win, 0, buf); + } else { + Sprintf(buf, " %c %c %c", Cmd.move_NW, Cmd.move_N, + Cmd.move_NE); + putstr(win, 0, buf); + putstr(win, 0, " \\ | / "); + Sprintf(buf, " %c- . -%c", Cmd.move_W, Cmd.move_E); + putstr(win, 0, buf); + putstr(win, 0, " / | \\ "); + Sprintf(buf, " %c %c %c", Cmd.move_SW, Cmd.move_S, + Cmd.move_SE); + putstr(win, 0, buf); + }; +} + + STATIC_OVL boolean help_dir(sym, msg) char sym; @@ -3828,29 +3860,12 @@ const char *msg; putstr(win, 0, ""); } } - if (NODIAG(u.umonnum)) { - putstr(win, 0, "Valid direction keys in your current form are:"); - Sprintf(buf, " %c ", Cmd.move_N); - putstr(win, 0, buf); - putstr(win, 0, " | "); - Sprintf(buf, " %c- . -%c", Cmd.move_W, Cmd.move_E); - putstr(win, 0, buf); - putstr(win, 0, " | "); - Sprintf(buf, " %c ", Cmd.move_S); - putstr(win, 0, buf); - } else { - putstr(win, 0, "Valid direction keys are:"); - Sprintf(buf, " %c %c %c", Cmd.move_NW, Cmd.move_N, - Cmd.move_NE); - putstr(win, 0, buf); - putstr(win, 0, " \\ | / "); - Sprintf(buf, " %c- . -%c", Cmd.move_W, Cmd.move_E); - putstr(win, 0, buf); - putstr(win, 0, " / | \\ "); - Sprintf(buf, " %c %c %c", Cmd.move_SW, Cmd.move_S, - Cmd.move_SE); - putstr(win, 0, buf); - }; + + Sprintf(buf, "Valid direction keys %sare:", + NODIAG(u.umonnum) ? "in your current form " : ""); + putstr(win, 0, buf); + show_direction_keys(win, NODIAG(u.umonnum)); + putstr(win, 0, ""); putstr(win, 0, " < up"); putstr(win, 0, " > down");