ask user if they want a tutorial, except if tutorial boolean option has been set in config - either on or off - in which case just obey that setting without asking */
| 427 | been set in config - either on or off - in which case just obey that |
| 428 | setting without asking */ |
| 429 | boolean |
| 430 | ask_do_tutorial(void) |
| 431 | { |
| 432 | boolean dotut = flags.tutorial; |
| 433 | |
| 434 | if (!opt_set_in_config[opt_tutorial]) { |
| 435 | winid win; |
| 436 | menu_item *sel; |
| 437 | anything any; |
| 438 | char buf[BUFSZ]; |
| 439 | const char *rc; |
| 440 | boolean norc; |
| 441 | int n, pass = 0; |
| 442 | |
| 443 | rc = nh_basename(get_configfile(), TRUE); |
| 444 | norc = !strcmp(get_configfile(), "/dev/null"); |
| 445 | Snprintf(buf, sizeof buf, |
| 446 | "Put \"OPTIONS=!tutorial\" in %s to skip this query.", |
| 447 | (rc && *rc && !norc) ? rc : "your configuration file"); |
| 448 | do { |
| 449 | win = create_nhwindow(NHW_MENU); |
| 450 | start_menu(win, MENU_BEHAVE_STANDARD); |
| 451 | any = cg.zeroany; |
| 452 | any.a_char = 'y'; |
| 453 | add_menu(win, &nul_glyphinfo, &any, any.a_char, 0, |
| 454 | ATR_NONE, NO_COLOR, |
| 455 | "Yes, do a tutorial", MENU_ITEMFLAGS_NONE); |
| 456 | any.a_char = 'n'; |
| 457 | add_menu(win, &nul_glyphinfo, &any, any.a_char, 0, |
| 458 | ATR_NONE, NO_COLOR, |
| 459 | "No, just start play", MENU_ITEMFLAGS_NONE); |
| 460 | |
| 461 | add_menu_str(win, ""); |
| 462 | add_menu_str(win, buf); |
| 463 | if (pass++) /* we'll get here after <space> or <return> */ |
| 464 | add_menu_str(win, "(Please choose 'y' or 'n'.)"); |
| 465 | |
| 466 | end_menu(win, "Do you want a tutorial?"); |
| 467 | |
| 468 | n = select_menu(win, PICK_ONE, &sel); |
| 469 | destroy_nhwindow(win); |
| 470 | } while (!n); |
| 471 | if (n > 0) { |
| 472 | dotut = (sel[0].item.a_char == 'y'); |
| 473 | free((genericptr_t) sel); |
| 474 | } else { /* ESC */ |
| 475 | dotut = FALSE; |
| 476 | } |
| 477 | } |
| 478 | return dotut; |
| 479 | } |
| 480 | |
| 481 | /* |
| 482 | ********************************** |
no test coverage detected