diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-03-04 21:56:56 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-03-29 21:22:23 +0200 |
commit | babe53830c1bf0904d4661e5b2ce7c3b337dba9c (patch) | |
tree | 105194ddc08a7e4fc60c4b208a9cf78081982a09 /src/lua_bind.c | |
parent | 2d82b906749e7249b98b32a81c66a92e46c1cf10 (diff) |
Refactor: Move intro terminal code from Lua to C
Diffstat (limited to 'src/lua_bind.c')
-rw-r--r-- | src/lua_bind.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/lua_bind.c b/src/lua_bind.c index 7894b7d4..c8e861a9 100644 --- a/src/lua_bind.c +++ b/src/lua_bind.c @@ -630,3 +630,73 @@ cptr approximate_distance(int y, int x, int y2, int x2) return "not very far"; } } + +bool_ drop_text_left(byte c, cptr str, int y, int o) +{ + int i = strlen(str); + int x = 39 - (strlen(str) / 2) + o; + while (i > 0) + { + int a = 0; + int time = 0; + + if (str[i-1] != ' ') + { + while (a < x + i - 1) + { + Term_putch(a - 1, y, c, 32); + Term_putch(a, y, c, str[i-1]); + time = time + 1; + if (time >= 4) + { + Term_xtra(TERM_XTRA_DELAY, 1); + time = 0; + } + Term_redraw_section(a - 1, y, a, y); + a = a + 1; + + inkey_scan = TRUE; + if (inkey()) { + return TRUE; + } + } + } + + i = i - 1; + } + return FALSE; +} + +bool_ drop_text_right(byte c, cptr str, int y, int o) +{ + int x = 39 - (strlen(str) / 2) + o; + int i = 1; + while (i <= strlen(str)) + { + int a = 79; + int time = 0; + + if (str[i-1] != ' ') { + while (a >= x + i - 1) + { + Term_putch(a + 1, y, c, 32); + Term_putch(a, y, c, str[i-1]); + time = time + 1; + if (time >= 4) { + Term_xtra(TERM_XTRA_DELAY, 1); + time = 0; + } + Term_redraw_section(a, y, a + 1, y); + a = a - 1; + + inkey_scan = TRUE; + if (inkey()) { + return TRUE; + } + } + } + + i = i + 1; + } + return FALSE; +} |