uni

University stuff
git clone git://git.christosmarg.xyz/uni-assignments.git
Log | Files | Refs | README | LICENSE

wins.c (1215B)


      1 #include "wins.h"
      2 
      3 void
      4 init_curses(void)
      5 {
      6     initscr();
      7     noecho();
      8     cbreak();
      9 }
     10 
     11 WINDOW *
     12 game_win(int rows, int cols)
     13 {
     14 	int wrows = rows+2;
     15 	int wcols = cols*3+2;
     16 	int wy = YMAX(stdscr)/2 - wrows/2;
     17 	int wx = XMAX(stdscr)/2 - wcols/2;
     18 	WINDOW *gw = newwin(wrows, wcols, wy, wx);
     19 	wattron(gw, A_BOLD);
     20 	box(gw, 0, 0);
     21 	wrefresh(gw);
     22 	wattroff(gw, A_BOLD);
     23 	return gw;
     24 }
     25 
     26 void
     27 options_menu(void)
     28 {
     29 	int w = 33, h = 15;
     30 	int wy = YMAX(stdscr)/2 - h/2;
     31 	int wx = XMAX(stdscr)/2 - w/2;
     32 	WINDOW *opts = newwin(h, w, wy, wx);
     33 	werase(opts);
     34 	box(opts, 0, 0);
     35 	fill_menu(opts);
     36 	wrefresh(opts);
     37 	wgetch(opts);
     38 	werase(opts);
     39 	wrefresh(opts);
     40 	delwin(opts);
     41 }
     42 
     43 void
     44 fill_menu(WINDOW *opts)
     45 {
     46 	mvwprintw(opts, 1, 1, "q	Quit");
     47 	mvwprintw(opts, 2, 1, "w/k	Move up");
     48 	mvwprintw(opts, 3, 1, "s/j	Move down");
     49 	mvwprintw(opts, 4, 1, "a/h	Move left");
     50 	mvwprintw(opts, 5, 1, "d/l	Move right");
     51 	mvwprintw(opts, 6, 1, "f	Flag cell");
     52 	mvwprintw(opts, 7, 1, "g	Defuse (if flagged only)");
     53 	mvwprintw(opts, 8, 1, "p	Pause music");
     54 	mvwprintw(opts, 9, 1, "+	Volume up");
     55 	mvwprintw(opts, 10, 1, "-	Volume down");
     56 	mvwprintw(opts, 11, 1, "[ENTER]/o Open cell");
     57 	mvwprintw(opts, 13, 1, "Press any key to quit the menu");
     58 }