projects
/
hackover2013-badge-firmware.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Level eingeordnet.
[hackover2013-badge-firmware.git]
/
badge
/
jumpnrun
/
starter.c
diff --git
a/badge/jumpnrun/starter.c
b/badge/jumpnrun/starter.c
index
4deb635
..
93e769c
100644
(file)
--- a/
badge/jumpnrun/starter.c
+++ b/
badge/jumpnrun/starter.c
@@
-48,9
+48,9
@@
static uint8_t jumpnrun_pick_level_from_fd(char *buf, size_t *first_visible, siz
return JUMPNRUN_ERROR;
}
return JUMPNRUN_ERROR;
}
- char menu_buf[levelcount][MENU_BUFLEN];
- char const *menu_index[levelcount];
- char const *fnames[levelcount];
+ char menu_buf[levelcount
+ 1
][MENU_BUFLEN];
+ char const *menu_index[levelcount
+ 1
];
+ char const *fnames[levelcount
+ 1
];
unsigned i;
for(i = 0; i < levelcount && f_gets(menu_buf[i], MENU_BUFLEN, fd); ++i) {
unsigned i;
for(i = 0; i < levelcount && f_gets(menu_buf[i], MENU_BUFLEN, fd); ++i) {
@@
-64,8
+64,15
@@
static uint8_t jumpnrun_pick_level_from_fd(char *buf, size_t *first_visible, siz
fnames[i] = p;
}
fnames[i] = p;
}
- *selected = badge_menu(menu_index, i, first_visible, *selected);
+ strcpy(menu_buf[i], "exit");
+ menu_index[i] = menu_buf[i];
+ size_t choice = badge_menu(menu_index, i + 1, first_visible, *selected);
+ if(choice == levelcount) {
+ return 1; // exit
+ }
+
+ *selected = choice;
strcpy(buf, fnames[*selected]);
return 0;
}
strcpy(buf, fnames[*selected]);
return 0;
}
@@
-92,7
+99,7
@@
void jumpnrun_play(void) {
while(0 == jumpnrun_pick_level(buf, &first_visible, &selected, progress)) {
if(JUMPNRUN_WON == jumpnrun_play_level(buf) && selected == progress) {
while(0 == jumpnrun_pick_level(buf, &first_visible, &selected, progress)) {
if(JUMPNRUN_WON == jumpnrun_play_level(buf) && selected == progress) {
- ++progress;
+
selected =
++progress;
jumpnrun_save_progress(progress);
}
}
jumpnrun_save_progress(progress);
}
}
This page took
0.021206 seconds
and
4
git commands to generate.