settings.c (836B)
1 #include "settings.h" 2 3 int 4 set_cols(void) 5 { 6 int cols; 7 do 8 { 9 mvprintw(YMAX(stdscr)-4, 1, "Columns (Min = 5, Max = %d): ", 10 (XMAX(stdscr)-2)/3-2); 11 refresh(); 12 scanw("%d", &cols); 13 refresh(); 14 } while (cols < 5 || cols > (XMAX(stdscr)-2)/3-2); 15 return cols; 16 } 17 18 int 19 set_rows(void) 20 { 21 int rows; 22 do 23 { 24 mvprintw(YMAX(stdscr)-3, 1, "Rows (Min = 5, Max = %d): ", 25 YMAX(stdscr)-4); 26 refresh(); 27 scanw("%d", &rows); 28 refresh(); 29 } while (rows < 5 || rows > YMAX(stdscr)-4); 30 return rows; 31 } 32 33 int 34 set_nmines(int dimensions) 35 { 36 int nmines; 37 do 38 { 39 mvprintw(YMAX(stdscr)-2, 1, "Mines (Max = %d): ", dimensions-15); 40 refresh(); 41 scanw("%d", &nmines); 42 refresh(); 43 } while (nmines < 1 || nmines > dimensions-15); 44 return nmines; 45 }