From: Christian Heller Date: Thu, 23 May 2013 09:03:32 +0000 (+0200) Subject: init_window() now initializes Win.data and Win.draw, too X-Git-Tag: tce~1284 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/do_day?a=commitdiff_plain;h=e1ae0a05e12a8a0aec170d9d3b795ca0dc74e6ed;p=plomrogue init_window() now initializes Win.data and Win.draw, too --- diff --git a/roguelike.c b/roguelike.c index 89b6462..f530d45 100644 --- a/roguelike.c +++ b/roguelike.c @@ -471,18 +471,10 @@ int main () { raw(); struct WinMeta win_meta = init_win_meta(screen); - struct Win win_keys = init_window(&win_meta, "Keys"); - win_keys.draw = draw_keys_window; - win_keys.data = &world; - struct Win win_map = init_window(&win_meta, "Map"); - win_map.draw = draw_map; - win_map.data = &world; - struct Win win_info = init_window(&win_meta, "Info"); - win_info.draw = draw_info; - win_info.data = &world; - struct Win win_log = init_window(&win_meta, "Log"); - win_log.draw = draw_log; - win_log.data = &world; + struct Win win_keys = init_window(&win_meta, "Keys", &world, draw_keys_window); + struct Win win_map = init_window(&win_meta, "Map", &world, draw_map); + struct Win win_info = init_window(&win_meta, "Info", &world, draw_info); + struct Win win_log = init_window(&win_meta, "Log", &world, draw_log); int key; while (1) { diff --git a/windows.c b/windows.c index ba6401b..6a649a3 100644 --- a/windows.c +++ b/windows.c @@ -23,7 +23,7 @@ void scroll_pad (struct WinMeta * win_meta, char dir) { else if ('-' == dir && win_meta->pad_offset > 0) win_meta->pad_offset--; } -struct Win init_window (struct WinMeta * win_meta, char * title) { +struct Win init_window (struct WinMeta * win_meta, char * title, void * data, void * func) { // Create and populate Win struct with sane default values. struct Win win; win.prev = 0; @@ -32,6 +32,8 @@ struct Win init_window (struct WinMeta * win_meta, char * title) { win.title = title; win.width = 20; win.height = win_meta->height - 1; + win.data = data; + win.draw = func; return win; } void append_window (struct WinMeta * win_meta, struct Win * win) { diff --git a/windows.h b/windows.h index 8f06ffc..b5df498 100644 --- a/windows.h +++ b/windows.h @@ -30,7 +30,7 @@ struct Corners { struct WinMeta init_win_meta (WINDOW *); void scroll_pad (struct WinMeta *, char); -struct Win init_window (struct WinMeta *, char *); +struct Win init_window (struct WinMeta *, char *, void *, void *); void append_window (struct WinMeta *, struct Win *); void suspend_window (struct WinMeta *, struct Win *); struct yx place_window (struct WinMeta *, struct Win *);