X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=curses.c;h=cdbc9f53544d3a0870f6b83782a88362f1803fe2;hb=28e57b8c74635460d8380fcc533f161f37cb12d3;hp=14e9ce47e32b796ab3c61732d65e5b18a366974f;hpb=b49a491544fbd21beb14a44f6ccf5983b6a2f8dc;p=pkg%2Fnetris.git diff --git a/curses.c b/curses.c index 14e9ce4..cdbc9f5 100644 --- a/curses.c +++ b/curses.c @@ -22,6 +22,7 @@ #include "netris.h" #include #include +#include #include #include #include @@ -57,6 +58,7 @@ static EventGenRec keyGen = static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS]; static int statusYPos, statusXPos; static int haveColor; +static int screens_dirty = 0; static char *term_vi; /* String to make cursor invisible */ static char *term_ve; /* String to make cursor visible */ @@ -98,6 +100,7 @@ ExtFunc void InitScreens(void) #endif AtExit(CleanupScreens); + screens_dirty = 1; RestoreSignals(NULL, &oldMask); cbreak(); @@ -116,9 +119,12 @@ ExtFunc void InitScreens(void) ExtFunc void CleanupScreens(void) { - RemoveEventGen(&keyGen); - endwin(); - OutputTermStr(term_ve, 1); + if (screens_dirty) { + RemoveEventGen(&keyGen); + endwin(); + OutputTermStr(term_ve, 1); + screens_dirty = 0; + } } ExtFunc void GetTermcapInfo(void) @@ -201,6 +207,8 @@ ExtFunc void InitScreen(int scr) for (y = boardVisible[scr] - 1; y >= 0; --y) { move(boardYPos[scr] - y, boardXPos[scr] - 1); addch('|'); + for (x = boardWidth[scr] - 1; x >= 0; --x) + addstr(" "); move(boardYPos[scr] - y, boardXPos[scr] + 2 * boardWidth[scr]); addch('|'); } @@ -256,6 +264,23 @@ ExtFunc void PlotUnderline(int scr, int x, int flag) ExtFunc void ShowDisplayInfo(void) { + move(statusYPos - 3, statusXPos); + printw("Won: %3d", won); + move(statusYPos - 2, statusXPos); + printw("Lost: %3d", lost); + + move(statusYPos - 1, statusXPos); + switch(gameState) { + case STATE_WAIT_CONNECTION: + addstr("Waiting for opponent... "); + break; + case STATE_WAIT_KEYPRESS: + addstr("Press the key for a new game."); + break; + default: + addstr(" "); + } + move(statusYPos - 9, statusXPos); printw("Seed: %d", initSeed); clrtoeol();