src/game.c

changeset 127
7258a46bf5ae
parent 126
d58b2abdd330
child 128
ce38ee9bc3af
equal deleted inserted replaced
126:d58b2abdd330 127:7258a46bf5ae
178 printw("Unknown move parser error."); 178 printw("Unknown move parser error.");
179 } 179 }
180 } 180 }
181 181
182 static void save_pgn(GameState *gamestate, GameInfo *gameinfo) { 182 static void save_pgn(GameState *gamestate, GameInfo *gameinfo) {
183 int y = getcury(stdscr);
184
185 /* ask for player names */
186 {
187 char pname[PLAYER_NAME_BUFLEN];
188 printw("\rWhite's name (%s): ", pgn_player_name(gamestate, WHITE));
189 clrtoeol();
190 if (getnstr(pname, PLAYER_NAME_BUFLEN) == OK && pname[0] != '\0') {
191 strncpy(gamestate->wname, pname, PLAYER_NAME_BUFLEN);
192 }
193 move(y, 0);
194 printw("\rBlack's name (%s): ", pgn_player_name(gamestate, BLACK));
195 clrtoeol();
196 if (getnstr(pname, PLAYER_NAME_BUFLEN) == OK && pname[0] != '\0') {
197 strncpy(gamestate->bname, pname, PLAYER_NAME_BUFLEN);
198 }
199 move(y, 0);
200 }
201
183 bool export_comments = prompt_yesno("Export with comments"); 202 bool export_comments = prompt_yesno("Export with comments");
184 203
185 printw("\rFilename: "); 204 printw("\rFilename: ");
186 clrtoeol(); 205 clrtoeol();
187 206
188 char filename[64]; 207 char filename[64];
189 int y = getcury(stdscr);
190 if (getnstr(filename, 64) == OK && filename[0] != '\0') { 208 if (getnstr(filename, 64) == OK && filename[0] != '\0') {
191 move(y, 0); 209 move(y, 0);
192 FILE *file = fopen(filename, "w"); 210 FILE *file = fopen(filename, "w");
193 if (file) { 211 if (file) {
194 write_pgn(file, gamestate, gameinfo, export_comments); 212 write_pgn(file, gamestate, gameinfo, export_comments);

mercurial