WINDOW *Napravi_plocu() {
	WINDOW *ploca;
	int i, height, width, v_border=8, h_border=9, board_width=7, board_height=6;

	height = v_border+board_height-1;
	width = h_border+board_width+board_width-1;
	ploca = newwin(height, width, 3, COLS/2-width/2);
	box(ploca, 0, 0);
	for (i=1; i<board_height; i++) {
		mvwhline(ploca, height/board_height*i, 1, ACS_HLINE, width-2);
	}
	for (i=1; i<board_width; i++) {
		mvwvline(ploca, 1, width/board_width*i, ACS_VLINE, height-2);
	}
	Wrefresh(ploca);
	return ploca;
}
WINDOW *Napravi_menu(int *n_choices, ITEM **items, MENU *menu) {
	int i, height, width;
	WINDOW *menu_window;
	
	*n_choices = ARRAY_SIZE(choices);
	items = (ITEM **) calloc(*n_choices, sizeof(ITEM *));
	for(i = 0; i < *n_choices; ++i)
        items[i] = new_item(choices[i], "");
	menu = new_menu((ITEM **) items);
	height = 3;
	width = 9+7+6;
	menu_window = newwin(height, width, 16, COLS/2-width/2);
	//Validiraj_ncurses(keypad(menu_window, TRUE));
	set_menu_win(menu, menu_window);
	set_menu_sub(menu, derwin(menu_window, height-1, width-1, 1, 1));
	set_menu_mark(menu, ">");
	set_menu_format(menu, 1, 7);
	menu_opts_off(menu, O_SHOWDESC);
	box(menu_window, 0, 0);
	post_menu(menu);
	Wrefresh(menu_window);
	return menu_window;
}
Exemple #3
0
Fichier : vga.c Projet : kkaneda/vm
static void
print_char ( WINDOW *w, bit32u_t paddr, int base_y )
{
	static int nscr = 0;
	struct point_t pt;
	char c;
	
	pt = paddr_to_pt ( paddr );
	pt.y += base_y;

	c = ( char ) Monitor_read_byte_with_paddr ( paddr );
	if ( ! isprint ( c ) )
		return;
	
	if ( pt.y - nscr >= SUB_WINDOW_HEIGHT ) {
		nscr++; 
		Scrollok ( w, TRUE );
		Scroll ( w );
		Scrollok ( w, FALSE );
	}
	
	mvwaddch ( w, pt.y - nscr, pt.x, c );
	Wrefresh ( w );
}
int main(int argc, char **argv) {
    int i, j, mpi_rank, mpi_size, key, igra_traje=1, potez, n_choices;
    char processor_name[MPI_MAX_PROCESSOR_NAME], string[1000];
    WINDOW *ploca, *menu_window;
	ITEM **items;
	MENU *menu;

    Inicijaliziraj_MPI(&argc, &argv, &mpi_rank, &mpi_size, processor_name);
	if (mpi_rank == 0) {
		Inicijaliziraj_sucelje();
		Refresh();
		ploca = Napravi_plocu(); 
		menu_window = Napravi_menu(&n_choices, items, menu);

		/*
		wattron(ploca, COLOR_PAIR(3));
		//mvwaddch(ploca, 1, 1, ACS_BLOCK);
		mvwprintw(ploca, 1, 2, " ");
		wattroff(ploca, COLOR_PAIR(3));
		Wrefresh(ploca);
		
		wattron(ploca, COLOR_PAIR(4));
		//mvwaddch(ploca, 5, 5, ACS_DIAMOND);
		mvwprintw(ploca, 3, 5, " ");
		wattroff(ploca, COLOR_PAIR(4));
		Wrefresh(ploca);
		*/
		Refresh();
		potez=POTEZ_HUMAN;
		while (igra_traje) {
			igra_traje=0;
			switch (potez) {
				case POTEZ_CPU:
					//printw("CPU na potezu\n");
					//TODO: DODATI LOGIKU OVDJE
					potez = POTEZ_HUMAN;
					break;
				case POTEZ_HUMAN:
					//printw("Igracev potez!\nKoristi strelice za odabir stupca");
					//Refresh();
					//TODO: DODATI LOGIKU OVDJE
					while (getnstr(string, 1000)) {
						//move(0,0);
						//clear();
						//Refresh();
						mvprintw(0,0,"			pritisnut %s", string);
						/*
						switch (key) {
							case KEY_LEFT:
								menu_driver(menu, REQ_LEFT_ITEM);
								break;
							case KEY_RIGHT:
								menu_driver(menu, REQ_RIGHT_ITEM);
								break;
							case 10: //enter
							{
								ITEM *cur;
								cur=current_item(menu);
							}

							default:
								Refresh();
								continue;
						}
						*/
						Wrefresh(menu_window);
					}
					potez = POTEZ_CPU;
					break;
				default:
					printw("Došlo je do pogreške!");
					Refresh();
			}
			
		}
		
		printw("Igra je završena!\nPritisnite neku tipku za izlazak...");
		refresh();
		Zavrsi(menu, items, n_choices);
	}
	Validiraj_MPI(MPI_Finalize());
    return 0;
}