#include <curses.h>
#include <stdio.h>
+#include <string.h>
#include "debug.h"
#include "function.h"
#include "display.h"
+#define LIBWIDTH 11
+
typedef enum {
white = 1,
red,
}
}
+void _dobound (int xsize, int ysize, int xoffset, int yoffset)
+{
+ int i, j;
+
+ for (i = 0; i < xsize; i++) {
+ mvaddch (yoffset - 1, xoffset + i, ACS_HLINE);
+ mvaddch (yoffset + ysize, xoffset + i, ACS_HLINE);
+ }
+ for (j = 0; j < ysize; j++) {
+ mvaddch (yoffset + j, xoffset - 1, ACS_VLINE);
+ mvaddch (yoffset + j, xoffset + xsize, ACS_VLINE);
+ }
+ mvaddch (yoffset - 1, xoffset - 1, ACS_ULCORNER);
+ mvaddch (yoffset + ysize, xoffset - 1, ACS_LLCORNER);
+ mvaddch (yoffset - 1, xoffset + xsize, ACS_URCORNER);
+ mvaddch (yoffset + ysize, xoffset + xsize, ACS_LRCORNER);
+}
+
int helpwindow (char *msg, int xoffset, int yoffset)
{
_displaytitle ("Help message", xoffset, yoffset);
int j = 2;
j += _helpwindow (msg, xoffset, yoffset + j, length);
- return length;
+ return j;
+}
+
+void librarywindow (char *msg, int xoffset, int yoffset)
+{
+ _dobound (LIBWIDTH, 2, xoffset, yoffset);
+ mvaddstr (yoffset, xoffset + (LIBWIDTH - 7) / 2, "Library");
+ set_color (black);
+
+ int i;
+ for (i = 0; i < LIBWIDTH; i++) {
+ mvaddch (yoffset + 1, xoffset + i, ' ');
+ }
+
+ char str[LIBWIDTH + 1] = {0};
+ strncpy (str, msg, LIBWIDTH);
+ mvaddstr (yoffset + 1, xoffset + (LIBWIDTH - (int)strlen (str)) / 2, str);
+ set_color (white);
}
void boardwindow (board_t *board, int xoffset, int yoffset, int bound)
int i, j;
if (bound) {
- for (i = 0; i < board->xsize; i++) {
- mvaddch (yoffset - 1, xoffset + i, ACS_HLINE);
- mvaddch (yoffset + board->ysize, xoffset + i, ACS_HLINE);
- }
- for (j = 0; j < board->ysize; j++) {
- mvaddch (yoffset + j, xoffset - 1, ACS_VLINE);
- mvaddch (yoffset + j, xoffset + board->xsize, ACS_VLINE);
- }
- mvaddch (yoffset - 1, xoffset - 1, ACS_ULCORNER);
- mvaddch (yoffset + board->ysize, xoffset - 1, ACS_LLCORNER);
- mvaddch (yoffset - 1, xoffset + board->xsize, ACS_URCORNER);
- mvaddch (yoffset + board->ysize, xoffset + board->xsize, ACS_LRCORNER);
+ _dobound (board->xsize, board->ysize, xoffset, yoffset);
}
for (i = 0; i < board->xsize; i++) {
"<j> Move left cells\n"
"<k> Move down cells\n"
"<l> Move right cells\n"
+ "<o> Turn on library\n"
"<q> Quit\n"
"<r> Rotate clockwise\n"
"<s> Save file\n"
+ "<u> Reward library\n"
"<x> Erase cells\n"
;
int yelement = (ysize - element->ysize) / 2;
/* init windows */
- helpwindow (help, xhelp, yhelp);
+ int l = helpwindow (help, xhelp, yhelp);
+
+ /* window positions */
+ int xlibrary = xhelp + 1;
+ int ylibrary = yhelp + 1 + l + yoffset;
/* event loop */
int rotate = 0;
char *ptr = NULL;
boardwindow (board, xboard, yboard, 1);
+ librarywindow ((lib + n)->name, xlibrary, ylibrary);
switch (mode) {
case 'e':
halfdelay (0);