From: Holger Schemel Date: Sun, 5 Sep 2021 22:16:46 +0000 (+0200) Subject: added asking for and uploading tapes to score server (only once) X-Git-Tag: 4.3.0.0~69 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ec32314a7ce9f3ac478d7fdecf85ed949816bdc1;p=rocksndiamonds.git added asking for and uploading tapes to score server (only once) --- diff --git a/src/init.c b/src/init.c index ae0e16c8..6adf67db 100644 --- a/src/init.c +++ b/src/init.c @@ -6333,6 +6333,8 @@ void OpenAll(void) DrawMainMenu(); + CheckUploadTapes(); + #if 0 Debug("internal:path", "SDL_GetBasePath() == '%s'", SDL_GetBasePath()); diff --git a/src/screens.c b/src/screens.c index cfab48e7..e3294c1b 100644 --- a/src/screens.c +++ b/src/screens.c @@ -9828,3 +9828,55 @@ void DrawScreenAfterAddingSet(char *tree_subdir_new, int tree_type) } } } + +static void UploadTapes(void) +{ + SetGameStatus(GAME_MODE_LOADING); + + FadeSetEnterScreen(); + FadeOut(REDRAW_ALL); + + ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); + + FadeIn(REDRAW_ALL); + + DrawInitTextHead("Uploading tapes"); + + global.autoplay_mode = AUTOPLAY_MODE_UPLOAD; + global.autoplay_leveldir = "ALL"; + global.autoplay_all = TRUE; + + AutoPlayTapes(); + + global.autoplay_mode = AUTOPLAY_MODE_NONE; + global.autoplay_leveldir = NULL; + global.autoplay_all = FALSE; + + SetGameStatus(GAME_MODE_MAIN); + + DrawMainMenu(); +} + +void CheckUploadTapes(void) +{ + if (!setup.ask_for_uploading_tapes) + return; + + if (directoryExists(getTapeDir(NULL))) + { + if (Request("Upload all your tapes to the high score server now?", REQ_ASK)) + { + UploadTapes(); + + Request("All tapes uploaded!", REQ_CONFIRM); + } + else + { + Request("You can upload your tapes from the setup menu later!", REQ_CONFIRM); + } + } + + setup.ask_for_uploading_tapes = FALSE; + + SaveSetup(); +} diff --git a/src/screens.h b/src/screens.h index 7bcf88b2..3d5a1316 100644 --- a/src/screens.h +++ b/src/screens.h @@ -47,4 +47,6 @@ void setHideRelatedSetupEntries(void); void DumpScreenIdentifiers(void); boolean DoScreenAction(int); +void CheckUploadTapes(void); + #endif // SCREENS_H diff --git a/src/tape.c b/src/tape.c index c14b2169..62cb3e0d 100644 --- a/src/tape.c +++ b/src/tape.c @@ -505,6 +505,8 @@ static void PrintTapeReplayHeader(struct AutoPlayInfo *autoplay) Print("Number of levels: %d\n", autoplay->leveldir->levels); PrintLine("=", 79); Print("\n"); + + DrawInitTextItem(autoplay->leveldir->name); } static void PrintTapeReplayProgress(boolean replay_finished) @@ -1357,6 +1359,26 @@ void FixTape_ForceSinglePlayer(void) // tape autoplay functions // ---------------------------------------------------------------------------- +static TreeInfo *getNextValidAutoPlayEntry(TreeInfo *node) +{ + node = getNextValidTreeInfoEntry(node); + + while (node && node->is_copy) + node = getNextValidTreeInfoEntry(node); + + return node; +} + +static TreeInfo *getFirstValidAutoPlayEntry(TreeInfo *node) +{ + node = getFirstValidTreeInfoEntry(node); + + if (node && node->is_copy) + return getNextValidAutoPlayEntry(node); + + return node; +} + static void AutoPlayTapes_SetScoreEntry(int score, int time) { // set unique basename for score tape (for uploading to score server) @@ -1396,6 +1418,8 @@ static void AutoPlayTapes_WaitForUpload(void) Fail("cannot upload score tape to score server"); } + UPDATE_BUSY_STATE(); + Delay(20); } @@ -1540,10 +1564,14 @@ static void AutoPlayTapesExt(boolean initialize) Fail("specify player name when uploading solution tapes"); } - DrawCompleteVideoDisplay(); + if (global.autoplay_mode != AUTOPLAY_MODE_UPLOAD) + DrawCompleteVideoDisplay(); - audio.sound_enabled = FALSE; - setup.engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_OFF); + if (program.headless) + { + audio.sound_enabled = FALSE; + setup.engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_OFF); + } if (strSuffix(global.autoplay_leveldir, ".tape")) { @@ -1570,7 +1598,7 @@ static void AutoPlayTapesExt(boolean initialize) if (autoplay.all_levelsets) { // start auto-playing first level set - autoplay.leveldir = getFirstValidTreeInfoEntry(leveldir_first); + autoplay.leveldir = getFirstValidAutoPlayEntry(leveldir_first); } else { @@ -1618,6 +1646,8 @@ static void AutoPlayTapesExt(boolean initialize) if (global.autoplay_mode != AUTOPLAY_MODE_FIX || patch_nr == 0) level_nr = autoplay.level_nr++; + UPDATE_BUSY_STATE(); + // check if all tapes for this level set have been processed if (level_nr > autoplay.leveldir->last_level) { @@ -1627,7 +1657,7 @@ static void AutoPlayTapesExt(boolean initialize) break; // continue with next level set - autoplay.leveldir = getNextValidTreeInfoEntry(autoplay.leveldir); + autoplay.leveldir = getNextValidAutoPlayEntry(autoplay.leveldir); // all level sets processed if (autoplay.leveldir == NULL) @@ -1788,7 +1818,8 @@ static void AutoPlayTapesExt(boolean initialize) return; } - CloseAllAndExit(0); + if (program.headless) + CloseAllAndExit(0); } void AutoPlayTapes(void)