From: Christian Heller Date: Wed, 28 Aug 2013 01:11:05 +0000 (+0200) Subject: Simplified meta_keys() interface by managing all windows stuff below World struct. X-Git-Tag: tce~1017 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/template?a=commitdiff_plain;h=caf7e50574dc4fb3756a386257863e5b8b42ad98;p=plomrogue Simplified meta_keys() interface by managing all windows stuff below World struct. --- diff --git a/src/main.c b/src/main.c index 1f9d7f7..8f13e08 100644 --- a/src/main.c +++ b/src/main.c @@ -189,24 +189,30 @@ int main(int argc, char *argv[]) init_keybindings(&world); set_cleanup_flag(CLEANUP_KEYBINDINGS); struct WinMeta win_meta; - char * err_winmem = "Trouble with init_win() or draw_all_wins() in main()."; + char * err_winmem = "Trouble with init_win:meta() or draw_all_wins() in " + "main()."; exit_err(init_win_meta(screen, &win_meta), &world, err_winmem); + world.wins.meta = &win_meta; struct Win win_keys = init_win(&win_meta, "Keys", - 0, 29, &world, draw_keys_win); + 0, 29, &world, draw_keys_win); + world.wins.keys = &win_keys; struct Win win_info = init_win(&win_meta, "Info", 3, 20, &world, draw_info_win); + world.wins.info = &win_info; uint16_t height_logwin = win_meta.padframe.size.y - (2 + win_info.frame.size.y); struct Win win_log = init_win(&win_meta, "Log", height_logwin, 20, &world, draw_log_win); + world.wins.log = &win_log; uint16_t width_mapwin = win_meta.padframe.size.x - win_keys.frame.size.x - - win_log.frame.size.x - 2; + - win_log.frame.size.x - 2; struct Win win_map = init_win(&win_meta, "Map", 0, width_mapwin, &world, draw_map_win); - toggle_window(&win_meta, &win_keys); - toggle_window(&win_meta, &win_map); - toggle_window(&win_meta, &win_info); - toggle_window(&win_meta, &win_log); + world.wins.map = &win_map; + toggle_window(&win_meta, world.wins.keys); + toggle_window(&win_meta, world.wins.map); + toggle_window(&win_meta, world.wins.info); + toggle_window(&win_meta, world.wins.log); /* Replay mode. */ int key; @@ -260,8 +266,7 @@ int main(int argc, char *argv[]) } else { - quit_called = meta_keys(key, &world, &win_meta, &win_keys, - &win_map, &win_info, &win_log); + quit_called = meta_keys(key, &world); if (1 == quit_called) { err_c = "Trouble closing 'record' file (fclose() in " @@ -322,8 +327,7 @@ int main(int argc, char *argv[]) } else { - quit_called = meta_keys(key, &world, &win_meta, &win_keys, - &win_map, &win_info, &win_log); + quit_called = meta_keys(key, &world); if (1 == quit_called) { exit_game(&world); diff --git a/src/main.h b/src/main.h index 5eec390..2ae8133 100644 --- a/src/main.h +++ b/src/main.h @@ -19,6 +19,17 @@ struct MonsterDef; +struct Wins +{ + struct WinMeta * meta; + struct Win * keys; + struct Win * info; + struct Win * log; + struct Win * map; +}; + + + struct World { char interactive; /* 1: playing; 0: record playback. */ @@ -34,6 +45,7 @@ struct World struct MonsterDef * monster_def; /* Pointer to the monster definitions. */ struct Monster * monster; /* Pointer to the monsters' data. */ struct Player * player; /* Pointer to the player data. */ + struct Wins wins; /* Pointers to WinMeta, individual Wins.*/ }; diff --git a/src/misc.c b/src/misc.c index 88d8316..a4781c9 100644 --- a/src/misc.c +++ b/src/misc.c @@ -264,11 +264,13 @@ extern struct yx_uint16 find_passable_pos(struct Map * map) -extern uint8_t meta_keys(int key, struct World * world, - struct WinMeta * win_meta, struct Win * win_keys, - struct Win * win_map, struct Win * win_info, - struct Win * win_log) +extern uint8_t meta_keys(int key, struct World * world) { + struct WinMeta * win_meta = world->wins.meta; + struct Win * win_keys = world->wins.keys; + struct Win * win_map = world->wins.map; + struct Win * win_info = world->wins.info; + struct Win * win_log = world->wins.log; char * err_toggle = "Trouble with toggle_window() in meta_keys()."; char * err_shift = "Trouble with shift_active_win() in meta_keys()."; char * err_resize = "Trouble with growshrink_active_window() in " diff --git a/src/misc.h b/src/misc.h index 259a511..417ca8e 100644 --- a/src/misc.h +++ b/src/misc.h @@ -90,10 +90,7 @@ extern struct yx_uint16 find_passable_pos(struct Map * map); /* Call some meta game / window management actions dependent on key. If the * "quit" action is called, return 1 only instead of doing anything directly. */ -extern uint8_t meta_keys(int key, struct World * world, - struct WinMeta * win_meta, struct Win * win_keys, - struct Win * win_map, struct Win * win_info, - struct Win * win_log); +extern uint8_t meta_keys(int key, struct World * world);