added asking for and uploading tapes to score server (only once)
authorHolger Schemel <info@artsoft.org>
Sun, 5 Sep 2021 22:16:46 +0000 (00:16 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 5 Sep 2021 22:16:46 +0000 (00:16 +0200)
src/init.c
src/screens.c
src/screens.h
src/tape.c

index ae0e16c8b9c0cc41e23d2b793e7f2777fb5ed116..6adf67db99c57c5a005bbe4185c52b1bfe68714c 100644 (file)
@@ -6333,6 +6333,8 @@ void OpenAll(void)
 
   DrawMainMenu();
 
+  CheckUploadTapes();
+
 #if 0
   Debug("internal:path", "SDL_GetBasePath() == '%s'",
        SDL_GetBasePath());
index cfab48e7250f1c5888648fbe8d267c65fa748269..e3294c1bd8691edd0fb4c6df8992e030b485c860 100644 (file)
@@ -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();
+}
index 7bcf88b2154774c980d5384034725139a2a06851..3d5a1316b1ed78c4580b6272571c2b8f034f274a 100644 (file)
@@ -47,4 +47,6 @@ void setHideRelatedSetupEntries(void);
 void DumpScreenIdentifiers(void);
 boolean DoScreenAction(int);
 
+void CheckUploadTapes(void);
+
 #endif // SCREENS_H
index c14b21694940eea6c63844c1bd0e2f25285d4623..62cb3e0d102785f5d5dec5c879c9ce55bddecd65 100644 (file)
@@ -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)