X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=369124a77f917106b90e39b64d3d69e5902298d7;hb=f2b5c31430a9feeb0d7bb1aa9e21c2f8a230f548;hp=5c78347a48605fd0477c76623faa0718e087d687;hpb=0321cbef506f76d246fda98882aa8ad21a48be27;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 5c78347a..369124a7 100644 --- a/src/screens.c +++ b/src/screens.c @@ -282,6 +282,9 @@ static void MapScreenTreeGadgets(TreeInfo *); static void UpdateScreenMenuGadgets(int, boolean); +static boolean OfferUploadTapes(void); +static void execOfferUploadTapes(void); + static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; static int info_mode = INFO_MODE_MAIN; @@ -4055,10 +4058,14 @@ static void RenamePlayerOnServerExt(struct HttpRequest *request, snprintf(request->body, MAX_HTTP_BODY_SIZE, "{\n" "%s" + " \"game_version\": \"%s\",\n" + " \"game_platform\": \"%s\",\n" " \"name\": \"%s\",\n" " \"uuid\": \"%s\"\n" "}\n", getPasswordJSON(setup.api_server_password), + getProgramRealVersionString(), + getProgramPlatformString(), player_name, player_uuid); @@ -5564,6 +5571,9 @@ static void execSetupGame(void) execSetupGame_setNetworkServerText(); + if (!setup.provide_uploading_tapes) + setHideSetupEntry(execOfferUploadTapes); + setup_mode = SETUP_MODE_GAME; DrawSetupScreen(); @@ -6649,6 +6659,11 @@ static void execGadgetNetworkServer(void) ClickOnGadget(gi, MB_LEFTBUTTON); } +static void execOfferUploadTapes(void) +{ + OfferUploadTapes(); +} + static void ToggleNetworkModeIfNeeded(void) { int font_title = FONT_TITLE_1; @@ -6866,8 +6881,9 @@ static struct TokenInfo setup_info_game[] = { TYPE_PLAYER, &setup.network_player_nr,"Preferred Network Player:" }, { TYPE_TEXT_INPUT, execGadgetNetworkServer, "Network Server Hostname:" }, { TYPE_STRING, &network_server_text, "" }, - { TYPE_SWITCH, &setup.api_server, "Use Highscore Server:" }, + { TYPE_SWITCH, &setup.use_api_server, "Use Highscore Server:" }, { TYPE_SWITCH, &setup.only_show_local_scores, "Only Show Local Scores:" }, + { TYPE_ENTER_LIST, execOfferUploadTapes, "Upload All Tapes to Server" }, { TYPE_SWITCH, &setup.multiple_users, "Multiple Users/Teams:" }, { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" }, { TYPE_SWITCH, &setup.time_limit, "Time Limit:" }, @@ -7471,8 +7487,8 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) ToggleNetworkModeIfNeeded(); // API server mode may have changed at this point - if (si->value == &setup.api_server) - runtime.api_server = setup.api_server; + if (si->value == &setup.use_api_server) + runtime.use_api_server = setup.use_api_server; // game speed list may have changed at this point if (si->value == &setup.game_speed_extended) @@ -9032,10 +9048,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 +9842,78 @@ 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; +} + +static boolean OfferUploadTapes(void) +{ + if (!Request("Upload all your tapes to the high score server now?", REQ_ASK)) + return FALSE; + + int num_tapes_uploaded = UploadTapes(); + char message[100]; + + sprintf(message, "%d tapes uploaded!", num_tapes_uploaded); + + Request(message, REQ_CONFIRM); + + // after all tapes have been uploaded, remove entry from setup menu + setup.provide_uploading_tapes = FALSE; + + SaveSetup(); + + return (num_tapes_uploaded > 0); +} + +void CheckUploadTapes(void) +{ + if (!setup.ask_for_uploading_tapes) + return; + + if (directoryExists(getTapeDir(NULL))) + { + boolean tapes_uploaded = OfferUploadTapes(); + + if (!tapes_uploaded) + Request("You can upload your tapes from the setup menu later!", + REQ_CONFIRM); + } + else + { + // if tapes directory does not exist yet, never offer uploading all tapes + setup.provide_uploading_tapes = FALSE; + } + + // after asking for uploading all tapes once, do not ask again + setup.ask_for_uploading_tapes = FALSE; + + SaveSetup(); +}