- FadeMenuSoundsAndMusic();
-
- info_mode = INFO_MODE_MAIN;
- DrawInfoScreen();
- }
- else
- {
- PlayMenuSoundIfLoop();
- }
-}
-
-static void DrawInfoScreen_LevelSet(void)
-{
- struct TitleMessageInfo *tmi = &readme;
- char *filename = getLevelSetInfoFilename();
- char *title = "Level Set Information:";
- int font_foot = MENU_INFO_FONT_FOOT;
- int ystart = mSY - SY + MENU_SCREEN_INFO_YSTART1;
- int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
-
- if (filename == NULL)
- {
- DrawInfoScreen_NotAvailable(title, "No information for this level set.");
-
- return;
- }
-
- SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
-
- FadeOut(REDRAW_FIELD);
-
- ClearField();
- DrawHeadline();
-
- DrawTextSCentered(ystart, FONT_TEXT_1, title);
-
- // if x position set to "-1", automatically determine by playfield width
- if (tmi->x == -1)
- tmi->x = SXSIZE / 2;
-
- // if y position set to "-1", use static default value
- if (tmi->y == -1)
- tmi->y = 150;
-
- // if width set to "-1", automatically determine by playfield width
- if (tmi->width == -1)
- tmi->width = SXSIZE - 2 * TILEX;
-
- // if height set to "-1", automatically determine by playfield height
- if (tmi->height == -1)
- tmi->height = MENU_SCREEN_INFO_YBOTTOM - tmi->y - 10;
-
- // if chars set to "-1", automatically determine by text and font width
- if (tmi->chars == -1)
- tmi->chars = tmi->width / getFontWidth(tmi->font);
- else
- tmi->width = tmi->chars * getFontWidth(tmi->font);
-
- // if lines set to "-1", automatically determine by text and font height
- if (tmi->lines == -1)
- tmi->lines = tmi->height / getFontHeight(tmi->font);
- else
- tmi->height = tmi->lines * getFontHeight(tmi->font);
-
- DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
- filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
- tmi->autowrap, tmi->centered, tmi->parse_comments);
-
- DrawTextSCentered(ybottom, font_foot, TEXT_INFO_MENU);
-
- FadeIn(REDRAW_FIELD);
-}
-
-static void HandleInfoScreen_LevelSet(int button)
-{
- if (button == MB_MENU_LEAVE)
- {
- PlaySound(SND_MENU_ITEM_SELECTING);
-
- info_mode = INFO_MODE_MAIN;
- DrawInfoScreen();
-
- return;
- }
- else if (button == MB_MENU_CHOICE)
- {
- PlaySound(SND_MENU_ITEM_SELECTING);
-
- FadeMenuSoundsAndMusic();
-
- info_mode = INFO_MODE_MAIN;
- DrawInfoScreen();
- }
- else
- {
- PlayMenuSoundIfLoop();
- }
-}
-
-static void DrawInfoScreen(void)
-{
- if (info_mode == INFO_MODE_TITLE)
- DrawInfoScreen_TitleScreen();
- else if (info_mode == INFO_MODE_ELEMENTS)
- DrawInfoScreen_Elements();
- else if (info_mode == INFO_MODE_MUSIC)
- DrawInfoScreen_Music();
- else if (info_mode == INFO_MODE_CREDITS)
- DrawInfoScreen_Credits();
- else if (info_mode == INFO_MODE_PROGRAM)
- DrawInfoScreen_Program();
- else if (info_mode == INFO_MODE_VERSION)
- DrawInfoScreen_Version();
- else if (info_mode == INFO_MODE_LEVELSET)
- DrawInfoScreen_LevelSet();
- else
- DrawInfoScreen_Main();
-
- if (info_mode != INFO_MODE_MAIN &&
- info_mode != INFO_MODE_TITLE &&
- info_mode != INFO_MODE_MUSIC)
- PlayMenuSoundsAndMusic();
-}
-
-void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
-{
- if (info_mode == INFO_MODE_TITLE)
- HandleInfoScreen_TitleScreen(dx, dy, button);
- else if (info_mode == INFO_MODE_ELEMENTS)
- HandleInfoScreen_Elements(dx, dy, button);
- else if (info_mode == INFO_MODE_MUSIC)
- HandleInfoScreen_Music(dx, dy, button);
- else if (info_mode == INFO_MODE_CREDITS)
- HandleInfoScreen_Credits(dx, dy, button);
- else if (info_mode == INFO_MODE_PROGRAM)
- HandleInfoScreen_Program(dx, dy, button);
- else if (info_mode == INFO_MODE_VERSION)
- HandleInfoScreen_Version(button);
- else if (info_mode == INFO_MODE_LEVELSET)
- HandleInfoScreen_LevelSet(button);
- else
- HandleInfoScreen_Main(mx, my, dx, dy, button);
-}
-
-
-// ============================================================================
-// rename player API functions
-// ============================================================================
-
-struct ApiRenamePlayerThreadData
-{
- char *player_name;
- char *player_uuid;
-};
-
-static void *CreateThreadData_ApiRenamePlayer(void)
-{
- struct ApiRenamePlayerThreadData *data =
- checked_malloc(sizeof(struct ApiRenamePlayerThreadData));
-
- data->player_name = getStringCopy(setup.player_name);
- data->player_uuid = getStringCopy(setup.player_uuid);
-
- return data;
-}
-
-static void FreeThreadData_ApiRenamePlayer(void *data_raw)
-{
- struct ApiRenamePlayerThreadData *data = data_raw;
-
- checked_free(data->player_name);
- checked_free(data->player_uuid);
- checked_free(data);
-}
-
-static boolean SetRequest_ApiRenamePlayer(struct HttpRequest *request,
- void *data_raw)
-{
- struct ApiRenamePlayerThreadData *data = data_raw;
- char *player_name_raw = data->player_name;
- char *player_uuid_raw = data->player_uuid;
-
- request->hostname = setup.api_server_hostname;
- request->port = API_SERVER_PORT;
- request->method = API_SERVER_METHOD;
- request->uri = API_SERVER_URI_RENAME;
-
- char *player_name = getEscapedJSON(player_name_raw);
- char *player_uuid = getEscapedJSON(player_uuid_raw);
-
- 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);
-
- checked_free(player_name);
- checked_free(player_uuid);
-
- ConvertHttpRequestBodyToServerEncoding(request);
-
- return TRUE;
-}
-
-static void HandleResponse_ApiRenamePlayer(struct HttpResponse *response,
- void *data_raw)
-{
- // nothing to do here
-}
-
-#if defined(PLATFORM_EMSCRIPTEN)
-static void Emscripten_ApiRenamePlayer_Loaded(unsigned handle, void *data_raw,
- void *buffer, unsigned int size)
-{
- struct HttpResponse *response = GetHttpResponseFromBuffer(buffer, size);
-
- if (response != NULL)
- {
- HandleResponse_ApiRenamePlayer(response, data_raw);
-
- checked_free(response);
- }
- else
- {
- Error("server response too large to handle (%d bytes)", size);
- }
-
- FreeThreadData_ApiRenamePlayer(data_raw);
-}
-
-static void Emscripten_ApiRenamePlayer_Failed(unsigned handle, void *data_raw,
- int code, const char *status)
-{
- Error("server failed to handle request: %d %s", code, status);
-
- FreeThreadData_ApiRenamePlayer(data_raw);
-}
-
-static void Emscripten_ApiRenamePlayer_Progress(unsigned handle, void *data_raw,
- int bytes, int size)
-{
- // nothing to do here
-}
-
-static void Emscripten_ApiRenamePlayer_HttpRequest(struct HttpRequest *request,
- void *data_raw)
-{
- if (!SetRequest_ApiRenamePlayer(request, data_raw))
- {
- FreeThreadData_ApiRenamePlayer(data_raw);
-
- return;
- }
-
- emscripten_async_wget2_data(request->uri,
- request->method,
- request->body,
- data_raw,
- TRUE,
- Emscripten_ApiRenamePlayer_Loaded,
- Emscripten_ApiRenamePlayer_Failed,
- Emscripten_ApiRenamePlayer_Progress);
-}
-
-#else
-
-static void ApiRenamePlayer_HttpRequestExt(struct HttpRequest *request,
- struct HttpResponse *response,
- void *data_raw)
-{
- if (!SetRequest_ApiRenamePlayer(request, data_raw))
- return;
-
- if (!DoHttpRequest(request, response))
- {
- Error("HTTP request failed: %s", GetHttpError());