예제 #1
0
int print_travel(int scope, struct Information* InputText, struct Information* copy, int* index){ // 여행지 선택 후 해당 여행지의 정보 보여주는 함수i
	int start = (scope-1)*5; // 시작 인덱스 지정
	int end = scope*5; // 마지막 인덱스 지정
	int choice; // 함수 실행 판별 변수
	int i;
	int j;
	*index = start; // 어느 지역의 인기도를 증가시킬지 체크하기 위한 index
	if(scope == 6){ // 제주도일 경우
		end = end - 1; // 4곳만 출력하기 위해 end를 감소
	}
	for(i=0, j = start; j < end; j++, i++){
		printf("%d. %s\n", i+1, InputText[j].name);
		copy[i] = InputText[j];
	}
	while(1){
		printf("\n\n"); 
		print_menu2(); // 추가 메뉴 출력
		scanf("%d", &choice);
		fflush(stdin);
		if(choice < 0 || choice > 6){
		RED;	printf("\t\t\t\t\t<<  잘못 입력하셨습니다. 다시 입력해주세요.....>>\n");
			continue;
		}
		else{
			break;
		}
	}
	return choice;
}
예제 #2
0
/*Description - Prints the menu tht appears after login in a new window using ncurses library*/
void login_menu() {
	system("clear");
	WINDOW *menu_win;
	int highlight = 1;
	int choice = 0;
	int c;
	initscr();
	clear();
	noecho();
	cbreak();	/* Line buffering disabled. pass on everything */
	startx = (80 - WIDTH) / 2;
	starty = (24 - HEIGHT) / 2;
	menu_win = newwin(HEIGHT, WIDTH, starty, startx);
	keypad(menu_win, TRUE);
	mvprintw(0, 20, "***************WELCOME****************");
	mvprintw(2, 7, "Use arrow keys to go up and down, Press enter to select a choice");
	refresh();
	print_menu2(menu_win, highlight);
	while(1)
	{	c = wgetch(menu_win);
		switch(c)
		{	case KEY_UP:
				if(highlight == 1)
					highlight = n_choices2;
				else
					--highlight;
				break;
			case KEY_DOWN:
				if(highlight == n_choices2)
					highlight = 1;
				else 
					++highlight;
				break;
			case 10:
				choice = highlight;
				break;
			default:
				mvprintw(24, 0, "Charcter pressed is = %3d Hopefully it can be printed as '%c'", c, c);
				refresh();
				break;
		}
		print_menu2(menu_win, highlight);
		if(choice != 0)	/* User did a choice come out of the infinite loop */
			break;
	}
	clrtoeol();
	endwin();
	switch(choice) {
		case 1: /*Guide*/
			guide();
			login_menu();
			break;
		case 2: /*Play Game*/
			play_game();
			break;
		case 3: /*Buy*/
			buy_chips();
			login_menu();
			break;
		case 4: /*Sell*/
			sell_chips();
			login_menu();
			break;
		case 5: /*Check bal*/
			disp_bal();
			login_menu();
			break;
		case 6: /*Change_info*/
			change_info();
			login_menu();
			break;
		case 7: /*Log out*/
			logout();
			menu();
			break;
		default:
			login_menu();
			break;
	}
}