X-Git-Url: http://git.shiar.net/netris.git/blobdiff_plain/968bf843bad5fc3d0c2d96a26fc39f3f01d94bfc..776faa936ea4b3f5ccaacda0f05a2ed1e945d304:/curses.c diff --git a/curses.c b/curses.c index 14e9ce4..9649d85 100644 --- a/curses.c +++ b/curses.c @@ -48,7 +48,7 @@ static struct }; #endif -static void PlotBlock1(int scr, int y, int x, BlockType type); +ExtFunc void PlotBlock1(int scr, int y, int x, BlockType type); static MyEventType KeyGenFunc(EventGenRec *gen, MyEvent *event); static EventGenRec keyGen = @@ -195,9 +195,12 @@ ExtFunc void InitScreen(int scr) else boardXPos[scr] = boardXPos[scr - 1] + 2 * boardWidth[scr - 1] + 3; + if (scr == 1) + boardXPos[scr] += 24; boardYPos[scr] = 22; - if (statusXPos < boardXPos[scr] + 2 * boardWidth[scr] + 3) - statusXPos = boardXPos[scr] + 2 * boardWidth[scr] + 3; + statusXPos = 2 * boardWidth[0] + 3; +// if (statusXPos < boardXPos[scr] + 2 * boardWidth[scr] + 3) +// statusXPos = boardXPos[scr] + 2 * boardWidth[scr] + 3; for (y = boardVisible[scr] - 1; y >= 0; --y) { move(boardYPos[scr] - y, boardXPos[scr] - 1); addch('|'); @@ -217,7 +220,7 @@ ExtFunc void CleanupScreen(int scr) { } -static void PlotBlock1(int scr, int y, int x, BlockType type) +ExtFunc void PlotBlock1(int scr, int y, int x, BlockType type) { int colorIndex = abs(type); @@ -237,7 +240,7 @@ static void PlotBlock1(int scr, int y, int x, BlockType type) standout(); } - addstr(type > 0 ? "[]" : "$$"); + addstr(type ? "[]" : "$$"); standend(); } } @@ -257,18 +260,16 @@ ExtFunc void PlotUnderline(int scr, int x, int flag) ExtFunc void ShowDisplayInfo(void) { move(statusYPos - 9, statusXPos); - printw("Seed: %d", initSeed); - clrtoeol(); + printw("Seed: %010d", initSeed); move(statusYPos - 8, statusXPos); - printw("Speed: %dms", speed / 1000); - clrtoeol(); + printw("Speed: %dms ", speed / 1000); if (robotEnable) { move(statusYPos - 6, statusXPos); if (fairRobot) addstr("Controlled by a fair robot"); else addstr("Controlled by a robot"); - clrtoeol(); +// clrtoeol(); } if (opponentFlags & SCF_usingRobot) { move(statusYPos - 5, statusXPos); @@ -276,10 +277,29 @@ ExtFunc void ShowDisplayInfo(void) addstr("The opponent is a fair robot"); else addstr("The opponent is a robot"); - clrtoeol(); +// clrtoeol(); } } +ExtFunc void ShowScore(int scr, int totalDrops, int totalLines, int totalAdds) +{ + float timer; + move(6, statusXPos); addstr("Next: "); + move(7, statusXPos + 6); addstr(" "); + ShapeIterate(nextShape[scr], scr, + ShapeToNetNum(nextShape[scr]) == 15 ? 15 : 16, statusXPos/2 + 4, + 1, GlanceFunc, NULL); + move(statusYPos - 20 + 1, statusXPos); + timer = CurTimeval() / 1e6; + printw("Lines: %05d", totalLines); + if (timer > 4) + printw(" (%.1f ppm)", totalDrops * 60 / timer); + move(statusYPos - 18, statusXPos); + printw("apm: %.1f", totalAdds * 60 / timer); + if (totalLines > 0) + printw(" (%d%% yield) ", 100 * totalAdds / totalLines); +} + ExtFunc void UpdateOpponentDisplay(void) { move(1, 0); @@ -293,34 +313,37 @@ ExtFunc void ShowPause(int pausedByMe, int pausedByThem) if (pausedByThem) addstr("Game paused by opponent"); else - clrtoeol(); + addstr(" "); move(statusYPos - 2, statusXPos); if (pausedByMe) addstr("Game paused by you"); else - clrtoeol(); + addstr(" "); } ExtFunc void Message(char *s) { static int line = 0; - move(statusYPos - 20 + line, statusXPos); +// move(statusYPos - 20 + line, statusXPos); + move(statusYPos + 2 + line, 1); addstr(s); /* XXX Should truncate long lines */ clrtoeol(); line = (line + 1) % 10; - move(statusYPos - 20 + line, statusXPos); +// move(statusYPos - 20 + line, statusXPos); + move(statusYPos + 2 + line, 1); clrtoeol(); } ExtFunc void RefreshScreen(void) { +/* static char timeStr[2][32]; time_t theTime; time(&theTime); strftime(timeStr[0], 30, "%I:%M %p", localtime(&theTime)); - /* Just in case the local curses library sucks */ + // Just in case the local curses library sucks if (strcmp(timeStr[0], timeStr[1])) { move(statusYPos, statusXPos); @@ -329,6 +352,11 @@ ExtFunc void RefreshScreen(void) } move(boardYPos[0] + 1, boardXPos[0] + 2 * boardWidth[0] + 1); refresh(); +*/ + move(statusYPos, statusXPos); + printw("Timer: %.0f ", CurTimeval() / 1e6); + move(boardYPos[0] + 1, boardXPos[0] + 2 * boardWidth[0] + 1); + refresh(); } ExtFunc void ScheduleFullRedraw(void)