changed interface for functions to auto-play tapes to return played tapes
[rocksndiamonds.git] / src / screens.c
index 5c78347a48605fd0477c76623faa0718e087d687..30bb2b20ee43b65fea9d8ed112b4aea9a694df89 100644 (file)
@@ -4055,10 +4055,12 @@ static void RenamePlayerOnServerExt(struct HttpRequest *request,
   snprintf(request->body, MAX_HTTP_BODY_SIZE,
           "{\n"
           "%s"
+          "  \"game_version\":         \"%s\",\n"
           "  \"name\":                 \"%s\",\n"
           "  \"uuid\":                 \"%s\"\n"
           "}\n",
           getPasswordJSON(setup.api_server_password),
+          getProgramRealVersionString(),
           player_name,
           player_uuid);
 
@@ -9032,10 +9034,10 @@ void HandleGameActions(void)
   if (game_status != GAME_MODE_PLAYING)
     return;
 
-  GameActions();       // main game loop
+  GameActions();               // main game loop
 
   if (tape.auto_play && !tape.playing)
-    AutoPlayTapes();   // continue automatically playing next tape
+    AutoPlayTapesContinue();   // continue automatically playing next tape
 }
 
 
@@ -9826,3 +9828,60 @@ void DrawScreenAfterAddingSet(char *tree_subdir_new, int tree_type)
     }
   }
 }
+
+static int 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;
+
+  int num_tapes_uploaded = AutoPlayTapes();
+
+  global.autoplay_mode = AUTOPLAY_MODE_NONE;
+  global.autoplay_leveldir = NULL;
+  global.autoplay_all = FALSE;
+
+  SetGameStatus(GAME_MODE_MAIN);
+
+  DrawMainMenu();
+
+  return num_tapes_uploaded;
+}
+
+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))
+    {
+      int num_tapes_uploaded = UploadTapes();
+      char message[100];
+
+      sprintf(message, "%d tapes uploaded!", num_tapes_uploaded);
+
+      Request(message, REQ_CONFIRM);
+    }
+    else
+    {
+      Request("You can upload your tapes from the setup menu later!", REQ_CONFIRM);
+    }
+  }
+
+  setup.ask_for_uploading_tapes = FALSE;
+
+  SaveSetup();
+}