2 * "THE BEER-WARE LICENSE" (Revision 42):
3 * <tobias.rehbein@web.de> wrote this file. As long as you retain this notice
4 * you can do whatever you want with this stuff. If we meet some day, and you
5 * think this stuff is worth it, you can buy me a beer in return.
17 static void print_oggfile(oggfile_t
* oggfile
);
19 extern options_t options
;
26 if ((tty
= open("/dev/tty", O_RDONLY
)) == -1)
27 err(1, "could not open /dev/tty");
31 ui_display_quiz(ui_model_t
* model
)
35 puts("+-----------+-------------------+-------------------+");
36 printf("| Next turn | current turn: %3d | current player: %d |\n",
37 model
->turn
, model
->current_player
+ 1);
38 puts("+-----------+-------------------+-------------------+\n");
40 for (i
= 0; i
< options
.choices
; i
++) {
41 printf("%d. %s\n", i
+ 1, model
->oggfiles
[i
].artist
);
42 printf(" %s\n", model
->oggfiles
[i
].album
);
43 printf(" %s\n\n", model
->oggfiles
[i
].title
);
48 ui_display_result(ui_model_t
* model
)
53 if (model
->correct
== model
->guess
)
54 printf("\nYou are right!\n");
56 printf("\nSorry, you are wrong!\n");
57 printf("\nYour guess:\n");
58 print_oggfile(model
->guess
);
61 printf("\nYou are listening to:\n");
62 print_oggfile(model
->correct
);
63 puts("\nScoreboard:\n");
64 for (i
= 0; i
< options
.players
; i
++) {
65 if (i
== model
->current_player
)
69 printf("%c Player %d: %5d %c\n", mark
, i
+ 1, model
->scores
[i
], mark
);
80 printf("What are you listening to? (1-%d, 'q' to quit)\n", options
.choices
);
82 if (read(tty
, &answer
, 2) == -1)
83 err(1, "could not read from /dev/tty");
84 canswer
= (char)answer
;
85 if (canswer
== 'q' || (canswer
>= '1' && canswer
<= '0' + options
.choices
))
96 printf("press return to continue...\n");
98 if (read(tty
, &in
, 1) == -1)
99 err(1, "could not read from /dev/tty");
109 if (close(tty
) == -1)
110 err(1, "could not close fd for /dev/tty");
116 print_oggfile(oggfile_t
* oggfile
)
118 printf(" %s\n", oggfile
->artist
);
119 printf(" %s\n", oggfile
->album
);
120 printf(" %s\n", oggfile
->title
);