Changeset a35b458 in mainline for uspace/app/tetris/scores.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tetris/scores.c
r3061bc1 ra35b458 98 98 { 99 99 int i; 100 100 101 101 clear_screen(); 102 102 moveto(10, 0); 103 103 printf("\tRank \tLevel \tName\t points\n"); 104 104 printf("\t========================================================\n"); 105 105 106 106 for (i = 0; i < NUMSPOTS - 1; i++) 107 107 printf("\t%6d %6d %-16s %20d\n", 108 108 i + 1, scores[i].hs_level, scores[i].hs_name, scores[i].hs_score); 109 109 110 110 if (!firstgame) { 111 111 printf("\t========================================================\n"); … … 113 113 scores[NUMSPOTS - 1].hs_level, scores[NUMSPOTS - 1].hs_name, scores[NUMSPOTS - 1].hs_score); 114 114 } 115 115 116 116 printf("\n\n\n\n\tPress any key to return to main menu."); 117 117 getchar(); … … 125 125 cons_event_t ev; 126 126 kbd_event_t *kev; 127 127 128 128 clear_screen(); 129 129 moveto(10, 10); … … 133 133 i = 6; 134 134 off = 6; 135 135 136 136 moveto(10 , 28); 137 137 printf("%s%.*s", scores[NUMSPOTS - 1].hs_name, MAXLOGNAME-i, 138 138 "........................................"); 139 139 140 140 while (1) { 141 141 console_flush(console); 142 142 if (!console_get_event(console, &ev)) 143 143 exit(1); 144 144 145 145 if (ev.type != CEV_KEY || ev.ev.key.type == KEY_RELEASE) 146 146 continue; 147 147 148 148 kev = &ev.ev.key; 149 149 150 150 if (kev->key == KC_ENTER || kev->key == KC_NENTER) 151 151 break; 152 152 153 153 if (kev->key == KC_BACKSPACE) { 154 154 if (i > 0) { 155 155 wchar_t uc; 156 156 157 157 --i; 158 158 while (off > 0) { … … 164 164 break; 165 165 } 166 166 167 167 scores[NUMSPOTS - 1].hs_name[off] = '\0'; 168 168 } … … 176 176 } 177 177 } 178 178 179 179 moveto(10, 28); 180 180 printf("%s%.*s", scores[NUMSPOTS - 1].hs_name, MAXLOGNAME - i, 181 181 "........................................"); 182 182 } 183 183 184 184 scores[NUMSPOTS - 1].hs_score = score; 185 185 scores[NUMSPOTS - 1].hs_level = level; 186 186 187 187 i = NUMSPOTS - 1; 188 188 while ((i > 0) && (scores[i - 1].hs_score < score)) 189 189 i--; 190 190 191 191 for (j = NUMSPOTS - 2; j > i; j--) 192 192 copyhiscore(j, j-1); 193 193 194 194 copyhiscore(i, NUMSPOTS - 1); 195 195 } … … 235 235 return; 236 236 } 237 237 238 238 cnt = fwrite(scores, sizeof(struct highscore), NUMSPOTS, f); 239 239 rc = fclose(f);
Note:
See TracChangeset
for help on using the changeset viewer.