mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
brickmania, blackjack, jewels, bubbles: Remove save file only if player resumed the game loaded from the file.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22639 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c17037a802
commit
d41e698ea0
4 changed files with 34 additions and 25 deletions
|
@ -36,8 +36,8 @@ PLUGIN_HEADER
|
||||||
/* final game return status */
|
/* final game return status */
|
||||||
enum {
|
enum {
|
||||||
BJ_LOSE,
|
BJ_LOSE,
|
||||||
|
BJ_QUIT_WITHOUT_SAVING,
|
||||||
BJ_QUIT,
|
BJ_QUIT,
|
||||||
BJ_SAVE_AND_QUIT,
|
|
||||||
BJ_USB,
|
BJ_USB,
|
||||||
BJ_END,
|
BJ_END,
|
||||||
};
|
};
|
||||||
|
@ -514,7 +514,8 @@ typedef struct game_context {
|
||||||
bool asked_insurance;
|
bool asked_insurance;
|
||||||
} game_context;
|
} game_context;
|
||||||
|
|
||||||
static bool resume;
|
static bool resume = false;
|
||||||
|
static bool resume_file = false;
|
||||||
static struct highscore highest[NUM_SCORES];
|
static struct highscore highest[NUM_SCORES];
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -855,23 +856,19 @@ static bool blackjack_loadgame(struct game_context* bj) {
|
||||||
signed int fd;
|
signed int fd;
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
|
|
||||||
resume = false;
|
|
||||||
/* open game file */
|
/* open game file */
|
||||||
fd = rb->open(SAVE_FILE, O_RDONLY);
|
fd = rb->open(SAVE_FILE, O_RDONLY);
|
||||||
if(fd < 0) return loaded;
|
if(fd < 0) return false;
|
||||||
|
|
||||||
/* read in saved game */
|
/* read in saved game */
|
||||||
if(rb->read(fd, bj, sizeof(struct game_context))
|
if(rb->read(fd, bj, sizeof(struct game_context))
|
||||||
== (long)sizeof(struct game_context))
|
== (long)sizeof(struct game_context))
|
||||||
{
|
{
|
||||||
resume = true;
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
|
|
||||||
/* delete saved file */
|
|
||||||
rb->remove(SAVE_FILE);
|
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,7 +1201,8 @@ static unsigned int blackjack_menu(struct game_context* bj) {
|
||||||
MENUITEM_STRINGLIST(menu, "BlackJack Menu", NULL,
|
MENUITEM_STRINGLIST(menu, "BlackJack Menu", NULL,
|
||||||
"Resume Game", "Start New Game",
|
"Resume Game", "Start New Game",
|
||||||
"High Scores", "Help",
|
"High Scores", "Help",
|
||||||
"Playback Control", "Quit", "Save and Quit");
|
"Playback Control",
|
||||||
|
"Quit without Saving", "Quit");
|
||||||
|
|
||||||
while(!breakout) {
|
while(!breakout) {
|
||||||
switch(rb->do_menu(&menu, &selection, NULL, false)) {
|
switch(rb->do_menu(&menu, &selection, NULL, false)) {
|
||||||
|
@ -1213,6 +1211,8 @@ static unsigned int blackjack_menu(struct game_context* bj) {
|
||||||
rb->splash(HZ*2, "Nothing to resume");
|
rb->splash(HZ*2, "Nothing to resume");
|
||||||
} else {
|
} else {
|
||||||
breakout = true;
|
breakout = true;
|
||||||
|
if(resume_file)
|
||||||
|
rb->remove(SAVE_FILE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1231,9 +1231,9 @@ static unsigned int blackjack_menu(struct game_context* bj) {
|
||||||
return BJ_USB;
|
return BJ_USB;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
return BJ_QUIT;
|
return BJ_QUIT_WITHOUT_SAVING;
|
||||||
case 6:
|
case 6:
|
||||||
return BJ_SAVE_AND_QUIT;
|
return BJ_QUIT;
|
||||||
|
|
||||||
case MENU_ATTACHED_USB:
|
case MENU_ATTACHED_USB:
|
||||||
return BJ_USB;
|
return BJ_USB;
|
||||||
|
@ -1278,6 +1278,7 @@ static int blackjack(struct game_context* bj) {
|
||||||
* play *
|
* play *
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
|
resume_file = false;
|
||||||
/* check for resumed game */
|
/* check for resumed game */
|
||||||
if(resume) {
|
if(resume) {
|
||||||
resume = false;
|
resume = false;
|
||||||
|
@ -1508,7 +1509,8 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
|
|
||||||
/* load high scores */
|
/* load high scores */
|
||||||
highscore_load(HIGH_SCORE,highest,NUM_SCORES);
|
highscore_load(HIGH_SCORE,highest,NUM_SCORES);
|
||||||
blackjack_loadgame(&bj);
|
resume = blackjack_loadgame(&bj);
|
||||||
|
resume_file = resume;
|
||||||
|
|
||||||
rb->lcd_setfont(FONT_SYSFIXED);
|
rb->lcd_setfont(FONT_SYSFIXED);
|
||||||
|
|
||||||
|
@ -1537,15 +1539,13 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
highscore_save(HIGH_SCORE,highest,NUM_SCORES);
|
highscore_save(HIGH_SCORE,highest,NUM_SCORES);
|
||||||
return PLUGIN_USB_CONNECTED;
|
return PLUGIN_USB_CONNECTED;
|
||||||
|
|
||||||
case BJ_SAVE_AND_QUIT:
|
case BJ_QUIT:
|
||||||
if (resume) {
|
rb->splash(HZ/5, "Saving Game and Scores...");
|
||||||
rb->splash(HZ, "Saving game...");
|
blackjack_savegame(&bj);
|
||||||
blackjack_savegame(&bj);
|
highscore_save(HIGH_SCORE,highest,NUM_SCORES);
|
||||||
}
|
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
case BJ_QUIT:
|
case BJ_QUIT_WITHOUT_SAVING:
|
||||||
highscore_save(HIGH_SCORE,highest,NUM_SCORES);
|
|
||||||
exit = true;
|
exit = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -619,6 +619,7 @@ int difficulty = NORMAL;
|
||||||
int pad_width;
|
int pad_width;
|
||||||
int num_count;
|
int num_count;
|
||||||
bool resume = false;
|
bool resume = false;
|
||||||
|
bool resume_file = false;
|
||||||
|
|
||||||
typedef struct cube {
|
typedef struct cube {
|
||||||
int powertop;
|
int powertop;
|
||||||
|
@ -751,8 +752,6 @@ static void brickmania_loadgame(void)
|
||||||
|
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
|
|
||||||
/* delete saved file */
|
|
||||||
rb->remove(SAVE_FILE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,6 +921,8 @@ static int brickmania_menu(void)
|
||||||
case 0:
|
case 0:
|
||||||
if(game_state!=ST_READY)
|
if(game_state!=ST_READY)
|
||||||
game_state = ST_PAUSE;
|
game_state = ST_PAUSE;
|
||||||
|
if(resume_file)
|
||||||
|
rb->remove(SAVE_FILE);
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
score=0;
|
score=0;
|
||||||
|
@ -982,6 +983,7 @@ static int brickmania_game_loop(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
resume = false;
|
resume = false;
|
||||||
|
resume_file = false;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
/* Convert CYCLETIME (in ms) to HZ */
|
/* Convert CYCLETIME (in ms) to HZ */
|
||||||
|
@ -1778,6 +1780,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
/* now go ahead and have fun! */
|
/* now go ahead and have fun! */
|
||||||
rb->srand( *rb->current_tick );
|
rb->srand( *rb->current_tick );
|
||||||
brickmania_loadgame();
|
brickmania_loadgame();
|
||||||
|
resume_file = resume;
|
||||||
while(brickmania_game_loop() == 0) {
|
while(brickmania_game_loop() == 0) {
|
||||||
if(!resume) {
|
if(!resume) {
|
||||||
int position = highscore_update(score, level+1, "", highest, NUM_SCORES);
|
int position = highscore_update(score, level+1, "", highest, NUM_SCORES);
|
||||||
|
|
|
@ -1274,6 +1274,7 @@ struct highscore highscores[NUM_SCORES];
|
||||||
|
|
||||||
/* used to denote available resume info */
|
/* used to denote available resume info */
|
||||||
static bool resume = false;
|
static bool resume = false;
|
||||||
|
static bool resume_file = false;
|
||||||
static unsigned int highlevel = 0; /* the highest level beaten */
|
static unsigned int highlevel = 0; /* the highest level beaten */
|
||||||
static unsigned int last_highlevel = 0;
|
static unsigned int last_highlevel = 0;
|
||||||
|
|
||||||
|
@ -2393,14 +2394,15 @@ static int bubbles_menu(struct game_context* bb) {
|
||||||
rb->splash(HZ/2, "Nothing to resume");
|
rb->splash(HZ/2, "Nothing to resume");
|
||||||
else
|
else
|
||||||
startgame = true;
|
startgame = true;
|
||||||
|
if(resume_file)
|
||||||
if(rb->file_exists(SAVE_FILE))
|
|
||||||
rb->remove(SAVE_FILE);
|
rb->remove(SAVE_FILE);
|
||||||
|
resume_file = false;
|
||||||
break;
|
break;
|
||||||
case 1: /* new game */
|
case 1: /* new game */
|
||||||
bb->level = startlevel;
|
bb->level = startlevel;
|
||||||
startgame = true;
|
startgame = true;
|
||||||
resume = false;
|
resume = false;
|
||||||
|
resume_file = false;
|
||||||
break;
|
break;
|
||||||
case 2: /* choose level */
|
case 2: /* choose level */
|
||||||
startlevel++;
|
startlevel++;
|
||||||
|
@ -2497,6 +2499,7 @@ enum plugin_status plugin_start(const void* parameter) {
|
||||||
|
|
||||||
/* load files */
|
/* load files */
|
||||||
resume = bubbles_loadgame(&bb);
|
resume = bubbles_loadgame(&bb);
|
||||||
|
resume_file = resume;
|
||||||
bubbles_loaddata();
|
bubbles_loaddata();
|
||||||
highscore_load(SCORE_FILE, highscores, NUM_SCORES);
|
highscore_load(SCORE_FILE, highscores, NUM_SCORES);
|
||||||
rb->lcd_clear_display();
|
rb->lcd_clear_display();
|
||||||
|
|
|
@ -420,6 +420,7 @@ struct puzzle_level puzzle_levels[NUM_PUZZLE_LEVELS] = {
|
||||||
#define HIGH_SCORE PLUGIN_GAMES_DIR "/jewels.score"
|
#define HIGH_SCORE PLUGIN_GAMES_DIR "/jewels.score"
|
||||||
struct highscore highest[NUM_SCORES];
|
struct highscore highest[NUM_SCORES];
|
||||||
|
|
||||||
|
static bool resume_file = false;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* jewels_setcolors() set the foreground and background colors.
|
* jewels_setcolors() set the foreground and background colors.
|
||||||
|
@ -458,8 +459,6 @@ static bool jewels_loadgame(struct game_context* bj)
|
||||||
|
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
|
|
||||||
/* delete saved file */
|
|
||||||
rb->remove(SAVE_FILE);
|
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1361,6 +1360,8 @@ static int jewels_game_menu(struct game_context* bj, bool ingame)
|
||||||
switch (rb->do_menu(&main_menu, &choice, NULL, false)) {
|
switch (rb->do_menu(&main_menu, &choice, NULL, false)) {
|
||||||
case 0:
|
case 0:
|
||||||
jewels_setcolors();
|
jewels_setcolors();
|
||||||
|
if(resume_file)
|
||||||
|
rb->remove(SAVE_FILE);
|
||||||
return 0;
|
return 0;
|
||||||
case 1:
|
case 1:
|
||||||
jewels_init(bj);
|
jewels_init(bj);
|
||||||
|
@ -1402,9 +1403,11 @@ static int jewels_main(struct game_context* bj) {
|
||||||
int x=0, y=0;
|
int x=0, y=0;
|
||||||
|
|
||||||
bool loaded = jewels_loadgame(bj);
|
bool loaded = jewels_loadgame(bj);
|
||||||
|
resume_file = loaded;
|
||||||
if (jewels_game_menu(bj, loaded)!=0)
|
if (jewels_game_menu(bj, loaded)!=0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
resume_file = false;
|
||||||
while(true) {
|
while(true) {
|
||||||
no_movesavail = false;
|
no_movesavail = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue