From: Christian Heller Date: Sun, 28 Apr 2013 10:17:00 +0000 (+0200) Subject: Restructured order of draw_all_windows() calls, heavily reduced number of superfluous... X-Git-Tag: tce~1340 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/ledger2?a=commitdiff_plain;h=735254c661a213b2707863e98a1852f48bb7f853;p=plomrogue Restructured order of draw_all_windows() calls, heavily reduced number of superfluous calls of it. --- diff --git a/roguelike.c b/roguelike.c index e2c5474..8d4ec18 100644 --- a/roguelike.c +++ b/roguelike.c @@ -318,6 +318,7 @@ int main () { int key; while (1) { + draw_all_windows (&win_meta); key = getch(); if (key == get_action_key(world.keybindings, "quit")) break; @@ -350,53 +351,42 @@ int main () { else if (key == get_action_key(world.keybindings, "keys nav up") && world.keyswindata->select > 0) { world.keyswindata->select--; draw_all_windows (&win_meta); } - else if (key == get_action_key(world.keybindings, "keys nav down") && world.keyswindata->select < world.keyswindata->max) { + else if (key == get_action_key(world.keybindings, "keys nav down") && world.keyswindata->select < world.keyswindata->max) world.keyswindata->select++; - draw_all_windows (&win_meta); } else if (key == get_action_key(world.keybindings, "keys mod")) { world.keyswindata->edit = 1; draw_all_windows (&win_meta); key = getch(); if (key < 1000) // ensure maximum of three digits in key code field world.keybindings[world.keyswindata->select].key = key; - world.keyswindata->edit = 0; - draw_all_windows (&win_meta); } - else if (key == get_action_key(world.keybindings, "map up") && map.offset_y > 0) { + world.keyswindata->edit = 0; } + else if (key == get_action_key(world.keybindings, "map up") && map.offset_y > 0) map.offset_y--; - draw_all_windows (&win_meta); } - else if (key == get_action_key(world.keybindings, "map down")) { + else if (key == get_action_key(world.keybindings, "map down")) map.offset_y++; - draw_all_windows (&win_meta); } - else if (key == get_action_key(world.keybindings, "map right")) { + else if (key == get_action_key(world.keybindings, "map right")) map.offset_x++; - draw_all_windows (&win_meta); } - else if (key == get_action_key(world.keybindings, "map left") && map.offset_x > 0) { + else if (key == get_action_key(world.keybindings, "map left") && map.offset_x > 0) map.offset_x--; - draw_all_windows (&win_meta); } else if (key == get_action_key(world.keybindings, "player down") && map.player_y < map.height - 1) { update_info (&win_info); update_log (&win_log, "\nYou move south."); - map.player_y++; - draw_all_windows (&win_meta); } + map.player_y++; } else if (key == get_action_key(world.keybindings, "player up") && map.player_y > 0) { update_info (&win_info); update_log (&win_log, "\nYou move north."); - map.player_y--; - draw_all_windows (&win_meta); } + map.player_y--; } else if (key == get_action_key(world.keybindings, "player right") && map.player_x < map.width - 1) { update_info (&win_info); update_log (&win_log, "\nYou move east."); - map.player_x++; - draw_all_windows (&win_meta); } + map.player_x++; } else if (key == get_action_key(world.keybindings, "player left") && map.player_x > 0) { update_info (&win_info); update_log (&win_log, "\nYou move west."); - map.player_x--; - draw_all_windows (&win_meta); } + map.player_x--; } else if (key == get_action_key(world.keybindings, "wait") ) { update_info (&win_info); - update_log (&win_log, "\nYou wait."); - draw_all_windows(&win_meta); } } + update_log (&win_log, "\nYou wait."); } } endwin(); return 0; } diff --git a/windows.c b/windows.c index b71177f..2251c51 100644 --- a/windows.c +++ b/windows.c @@ -31,8 +31,7 @@ void append_window (struct WinMeta * win_meta, struct Win * win) { win_meta->active = win; win_meta->chain_start = win; } win_meta->chain_end = win; - update_windows(win_meta, win); - draw_all_windows(win_meta); } + update_windows(win_meta, win); } void suspend_window (struct WinMeta * win_meta, struct Win * win) { // Destroy win, suspend from window chain. Update geometry of following rows, as well as activity selection. @@ -51,9 +50,7 @@ void suspend_window (struct WinMeta * win_meta, struct Win * win) { if (win_meta->active == win) // ... or else to the previous element. win_meta->active = win->prev; } win->prev = 0; - win->next = 0; - if (0 != win_meta->chain_start) - draw_all_windows(win_meta); } + win->next = 0; } void place_window (struct WinMeta * win_meta, struct Win * win) { // Based on position and sizes of previous window, find fitting place for current window. @@ -171,8 +168,7 @@ void resize_window (struct WinMeta * win_meta, char change) { win_meta->active->width--; else if (change == '*') win_meta->active->width++; - update_windows(win_meta, win_meta->chain_start); - draw_all_windows(win_meta); } + update_windows(win_meta, win_meta->chain_start); } void cycle_active_window (struct WinMeta * win_meta, char dir) { // Cycle active window selection forwards (dir = 'n') or backwards. @@ -185,8 +181,7 @@ void cycle_active_window (struct WinMeta * win_meta, char dir) { if (win_meta->active->prev != 0) win_meta->active = win_meta->active->prev; else - win_meta->active = win_meta->chain_end; } - draw_all_windows(win_meta); } + win_meta->active = win_meta->chain_end; } } void shift_window (struct WinMeta * win_meta, char dir) { // Move active window forward/backward in window chain. If jumping beyond start/end, move to other chain end. @@ -223,5 +218,4 @@ void shift_window (struct WinMeta * win_meta, char dir) { else append_window(win_meta, wins[i]); free(wins); - win_meta->active = win_shift; - draw_all_windows(win_meta); } } + win_meta->active = win_shift; } }