From: Christian Heller Date: Fri, 17 May 2013 00:33:18 +0000 (+0200) Subject: Scrolling pad now also has its own function with its own sanity checks. X-Git-Tag: tce~1290 X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/day?a=commitdiff_plain;h=ed160c85898e726c7daf6b329f5e807e760ba3ed;p=plomrogue Scrolling pad now also has its own function with its own sanity checks. --- diff --git a/roguelike.c b/roguelike.c index 362826c..e7ece3a 100644 --- a/roguelike.c +++ b/roguelike.c @@ -475,9 +475,9 @@ int main () { if (key == get_action_key(world.keybindings, "quit")) break; else if (key == get_action_key(world.keybindings, "scroll pad right")) - win_meta.pad_offset++; - else if (key == get_action_key(world.keybindings, "scroll pad left") && win_meta.pad_offset > 0) - win_meta.pad_offset--; + scroll_pad (&win_meta, '+'); + else if (key == get_action_key(world.keybindings, "scroll pad left")) + scroll_pad (&win_meta, '-'); else if (key == get_action_key(world.keybindings, "toggle keys window")) toggle_window(&win_meta, &win_keys); else if (key == get_action_key(world.keybindings, "toggle map window")) diff --git a/windows.c b/windows.c index 121c9fa..cc9f0f2 100644 --- a/windows.c +++ b/windows.c @@ -15,6 +15,13 @@ struct WinMeta init_win_meta (WINDOW * screen) { win_meta.pad = newpad(win_meta.height, 1); return win_meta; } +void scroll_pad (struct WinMeta * win_meta, char dir) { +// Scroll pad left (if possible) or right. + if ('+' == dir) + win_meta->pad_offset++; + else if ('-' == dir && win_meta->pad_offset > 0) + win_meta->pad_offset--; } + struct Win init_window (struct WinMeta * win_meta, char * title) { // Create and populate Win struct with sane default values. struct Win win; diff --git a/windows.h b/windows.h index 779a672..23fbdc1 100644 --- a/windows.h +++ b/windows.h @@ -29,6 +29,7 @@ struct Corners { struct yx br; }; struct WinMeta init_win_meta (WINDOW *); +void scroll_pad (struct WinMeta *, char); struct Win init_window (struct WinMeta *, char *); void append_window (struct WinMeta *, struct Win *); void suspend_window (struct WinMeta *, struct Win *);