+ setString(&ti->identifier, identifier);
+ setString(&ti->name, name);
+ setString(&ti->name_sorting, name);
+ setString(&ti->infotext, STR_SETUP_CHOOSE_DROP_DISTANCE);
+
+ pushTreeInfo(&drop_distances, ti);
+ }
+
+ // sort distance values to start with lowest distance value
+ sortTreeInfo(&drop_distances);
+
+ // set current distance value to configured distance value
+ drop_distance_current =
+ getTreeInfoFromIdentifier(drop_distances,
+ i_to_a(setup.touch.drop_distance));
+
+ // if that fails, set current distance to reliable default value
+ if (drop_distance_current == NULL)
+ drop_distance_current =
+ getTreeInfoFromIdentifier(drop_distances,
+ i_to_a(TOUCH_DROP_DISTANCE_DEFAULT));
+
+ // if that also fails, set current distance to first available value
+ if (drop_distance_current == NULL)
+ drop_distance_current = drop_distances;
+ }
+
+ if (transparencies == NULL)
+ {
+ for (i = 0; transparencies_list[i].value != -1; i++)
+ {
+ TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+ char identifier[32], name[32];
+ int value = transparencies_list[i].value;
+ char *text = transparencies_list[i].text;
+
+ ti->node_top = &transparencies;
+ ti->sort_priority = value;
+
+ sprintf(identifier, "%d", value);
+ sprintf(name, "%s", text);
+
+ setString(&ti->identifier, identifier);
+ setString(&ti->name, name);
+ setString(&ti->name_sorting, name);
+ setString(&ti->infotext, STR_SETUP_CHOOSE_TRANSPARENCY);
+
+ pushTreeInfo(&transparencies, ti);
+ }
+
+ // sort transparency values to start with lowest transparency value
+ sortTreeInfo(&transparencies);
+
+ // set current transparency value to configured transparency value
+ transparency_current =
+ getTreeInfoFromIdentifier(transparencies,
+ i_to_a(setup.touch.transparency));
+
+ // if that fails, set current transparency to reliable default value
+ if (transparency_current == NULL)
+ transparency_current =
+ getTreeInfoFromIdentifier(transparencies,
+ i_to_a(TOUCH_TRANSPARENCY_DEFAULT));
+
+ // if that also fails, set current transparency to first available value
+ if (transparency_current == NULL)
+ transparency_current = transparencies;
+ }
+
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ if (grid_sizes[i][j] == NULL)
+ {
+ for (k = 0; grid_sizes_list[k].value != -1; k++)
+ {
+ TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+ char identifier[32], name[32];
+ int value = grid_sizes_list[k].value;
+ char *text = grid_sizes_list[k].text;
+
+ ti->node_top = &grid_sizes[i][j];
+ ti->sort_priority = value;
+
+ sprintf(identifier, "%d", value);
+ sprintf(name, "%s", text);
+
+ setString(&ti->identifier, identifier);
+ setString(&ti->name, name);
+ setString(&ti->name_sorting, name);
+ setString(&ti->infotext,
+ (i == 0 ?
+ (j == 0 ?
+ STR_SETUP_CHOOSE_GRID_XSIZE_0 :
+ STR_SETUP_CHOOSE_GRID_YSIZE_0) :
+ (j == 0 ?
+ STR_SETUP_CHOOSE_GRID_XSIZE_1 :
+ STR_SETUP_CHOOSE_GRID_YSIZE_1)));
+
+ pushTreeInfo(&grid_sizes[i][j], ti);
+ }
+
+ // sort grid size values to start with lowest grid size value
+ sortTreeInfo(&grid_sizes[i][j]);
+
+ // set current grid size value to configured grid size value
+ grid_size_current[i][j] =
+ getTreeInfoFromIdentifier(grid_sizes[i][j],
+ i_to_a(j == 0 ?
+ setup.touch.grid_xsize[i] :
+ setup.touch.grid_ysize[i]));
+
+ // if that fails, set current grid size to reliable default value
+ if (grid_size_current[i][j] == NULL)
+ grid_size_current[i][j] =
+ getTreeInfoFromIdentifier(grid_sizes[i][j],
+ i_to_a(j == 0 ?
+ DEFAULT_GRID_XSIZE(i) :
+ DEFAULT_GRID_YSIZE(i)));
+
+ // if that also fails, set current grid size to first available value
+ if (grid_size_current[i][j] == NULL)
+ grid_size_current[i][j] = grid_sizes[i][j];
+ }
+ }
+ }
+
+ setup.touch.control_type = touch_control_current->identifier;
+ setup.touch.move_distance = atoi(move_distance_current->identifier);
+ setup.touch.drop_distance = atoi(drop_distance_current->identifier);
+ setup.touch.transparency = atoi(transparency_current->identifier);
+
+ for (i = 0; i < 2; i++)
+ {
+ setup.touch.grid_xsize[i] = atoi(grid_size_current[i][0]->identifier);
+ setup.touch.grid_ysize[i] = atoi(grid_size_current[i][1]->identifier);
+
+ if (i == GRID_ACTIVE_NR())
+ {
+ overlay.grid_xsize = setup.touch.grid_xsize[i];
+ overlay.grid_ysize = setup.touch.grid_ysize[i];
+ }
+ }
+
+ // needed for displaying value text instead of identifier
+ touch_controls_text = touch_control_current->name;
+ move_distance_text = move_distance_current->name;
+ drop_distance_text = drop_distance_current->name;
+ transparency_text = transparency_current->name;
+
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < 2; j++)
+ grid_size_text[i][j] = grid_size_current[i][j]->name;
+
+ setup_mode = SETUP_MODE_TOUCH;
+
+ DrawSetupScreen();
+}
+
+static void execSetupArtwork(void)
+{
+ static ArtworkDirTree *gfx_last_valid = NULL;
+ static ArtworkDirTree *snd_last_valid = NULL;
+ static ArtworkDirTree *mus_last_valid = NULL;
+
+ // current artwork directory may be invalid (level group, parent link)
+ if (!validLevelSeries(artwork.gfx_current))
+ artwork.gfx_current = getFirstValidTreeInfoEntry(gfx_last_valid);
+ if (!validLevelSeries(artwork.snd_current))
+ artwork.snd_current = getFirstValidTreeInfoEntry(snd_last_valid);
+ if (!validLevelSeries(artwork.mus_current))
+ artwork.mus_current = getFirstValidTreeInfoEntry(mus_last_valid);
+
+ // store valid artwork directory information
+ gfx_last_valid = artwork.gfx_current;
+ snd_last_valid = artwork.snd_current;
+ mus_last_valid = artwork.mus_current;
+
+#if 0
+ Debug("screens:execSetupArtwork", "'%s', '%s', '%s'",
+ artwork.gfx_current->subdir,
+ artwork.gfx_current->fullpath,
+ artwork.gfx_current->basepath);
+#endif
+
+ setup.graphics_set = artwork.gfx_current->identifier;
+ setup.sounds_set = artwork.snd_current->identifier;
+ setup.music_set = artwork.mus_current->identifier;
+
+ // needed if last screen (setup choice) changed graphics, sounds or music
+ ReloadCustomArtwork(0);
+
+ // needed for displaying artwork name instead of artwork identifier
+ graphics_set_name = artwork.gfx_current->name;
+ sounds_set_name = artwork.snd_current->name;
+ music_set_name = artwork.mus_current->name;
+
+ setup_mode = SETUP_MODE_ARTWORK;
+
+ DrawSetupScreen();
+}
+
+static void execSetupChooseGraphics(void)
+{
+ setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
+
+ DrawSetupScreen();
+}
+
+static void execSetupChooseSounds(void)
+{
+ setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
+
+ DrawSetupScreen();
+}
+
+static void execSetupChooseMusic(void)
+{
+ setup_mode = SETUP_MODE_CHOOSE_MUSIC;
+
+ DrawSetupScreen();
+}
+
+static void execSetupInput(void)
+{
+ setup_mode = SETUP_MODE_INPUT;
+
+ DrawSetupScreen();
+}
+
+static void execSetupShortcuts(void)
+{
+ setup_mode = SETUP_MODE_SHORTCUTS;
+
+ DrawSetupScreen();
+}
+
+static void execSetupShortcuts1(void)
+{
+ setup_mode = SETUP_MODE_SHORTCUTS_1;
+
+ DrawSetupScreen();
+}
+
+static void execSetupShortcuts2(void)
+{
+ setup_mode = SETUP_MODE_SHORTCUTS_2;
+
+ DrawSetupScreen();
+}
+
+static void execSetupShortcuts3(void)
+{
+ setup_mode = SETUP_MODE_SHORTCUTS_3;
+
+ DrawSetupScreen();
+}
+
+static void execSetupShortcuts4(void)
+{
+ setup_mode = SETUP_MODE_SHORTCUTS_4;
+
+ DrawSetupScreen();
+}
+
+static void execSetupShortcuts5(void)
+{
+ setup_mode = SETUP_MODE_SHORTCUTS_5;
+
+ DrawSetupScreen();
+}
+
+static void execExitSetup(void)
+{
+ SetGameStatus(GAME_MODE_MAIN);
+
+ DrawMainMenu();
+}
+
+static void execSaveAndExitSetup(void)
+{
+ SaveSetup();
+ execExitSetup();
+}
+
+static void execGadgetNetworkServer(void)
+{
+ int gadget_id = SCREEN_CTRL_ID_NETWORK_SERVER;
+ struct GadgetInfo *gi = screen_gadget[gadget_id];
+
+ if (strEqual(setup.network_server_hostname, STR_NETWORK_AUTO_DETECT))
+ network_server_hostname[0] = '\0';
+
+ ModifyGadget(gi, GDI_TEXT_VALUE, network_server_hostname, GDI_END);
+
+ MapGadget(gi);
+
+ ClickOnGadget(gi, MB_LEFTBUTTON);
+}
+
+static void execOfferUploadTapes(void)
+{
+ OfferUploadTapes();
+}
+
+static void ToggleNetworkModeIfNeeded(void)
+{
+ int font_title = FONT_TITLE_1;
+ int font_foot = FC_BLUE;
+ int ystart = mSY - SY + 16;
+ int ybottom = mSY - SY + SYSIZE - 20;
+ char *text = (setup.network_mode ? "Start Network" : "Stop Network");
+
+ if (setup.network_mode == network.enabled)
+ return;
+
+ network.enabled = setup.network_mode;
+
+ FadeOut(REDRAW_ALL);
+
+ ClearField();
+
+ DrawTextSCentered(ystart, font_title, text);
+
+ FadeIn(REDRAW_ALL);
+
+ if (network.enabled)
+ InitNetworkServer();
+ else
+ DisconnectFromNetworkServer();
+
+ DrawTextSCentered(ybottom, font_foot,
+ "Press any key or button for setup menu");
+
+ WaitForEventToContinue();
+
+ DrawSetupScreen();
+}
+
+static void ToggleGameSpeedsListIfNeeded(void)
+{
+ boolean using_game_speeds_extended = (game_speeds == game_speeds_extended);
+
+ if (setup.game_speed_extended == using_game_speeds_extended)
+ return;
+
+ // try to match similar values when changing game speeds list
+ if (setup.game_speed_extended)
+ setup.game_frame_delay = (setup.game_frame_delay == 15 ? 16 :
+ setup.game_frame_delay == 30 ? 29 :
+ setup.game_frame_delay);
+ else
+ setup.game_frame_delay = (setup.game_frame_delay == 14 ? 15 :
+ setup.game_frame_delay == 16 ? 15 :
+ setup.game_frame_delay >= 29 ? 30 :
+ setup.game_frame_delay <= 10 ? 10 :
+ setup.game_frame_delay);
+
+ execSetupGame_setGameSpeeds(TRUE);
+
+ DrawSetupScreen();
+}
+
+static void ToggleUseApiServerIfNeeded(void)
+{
+ if (runtime.use_api_server == setup.use_api_server)
+ return;
+
+ runtime.use_api_server = setup.use_api_server;
+
+ if (runtime.use_api_server)
+ {
+ if (setup.has_remaining_tapes)
+ setup.ask_for_uploading_tapes = TRUE;
+
+ CheckApiServerTasks();
+ }
+}
+
+static void ModifyGameSpeedIfNeeded(void)
+{
+ if (strEqual(setup.vsync_mode, STR_VSYNC_MODE_OFF) ||
+ setup.game_frame_delay <= MAX_VSYNC_FRAME_DELAY)
+ return;
+
+ char message[100];
+ char *game_speed_text = "Fast";
+ int game_speed_value = 15;
+
+ if (setup.game_speed_extended)
+ {
+ game_speed_text = "60 fps";
+ game_speed_value = 16;
+ }
+
+ sprintf(message, "Game speed set to %s for VSync to work!", game_speed_text);
+
+ // set game speed to existing list value that is fast enough for vsync
+ setup.game_frame_delay = game_speed_value;
+
+ execSetupGame_setGameSpeeds(TRUE);
+
+ Request(message, REQ_CONFIRM);
+}
+
+static void DisableVsyncIfNeeded(void)
+{
+ if (strEqual(setup.vsync_mode, STR_VSYNC_MODE_OFF) ||
+ (setup.game_frame_delay >= MIN_VSYNC_FRAME_DELAY &&
+ setup.game_frame_delay <= MAX_VSYNC_FRAME_DELAY))
+ return;
+
+ // disable vsync for the selected game speed to work
+ setup.vsync_mode = STR_VSYNC_MODE_OFF;
+
+ execSetupGraphics_setVsyncModes(TRUE);
+
+ Request("VSync disabled for this game speed to work!", REQ_CONFIRM);
+}
+
+static struct
+{
+ void *value;
+ void *related_value;
+} hide_related_entry_list[] =
+{
+ { &setup.network_server_hostname, execGadgetNetworkServer },
+ { &setup.network_server_hostname, &network_server_text },
+
+ { &setup.scores_in_highscore_list, execSetupChooseScoresType },
+ { &setup.scores_in_highscore_list, &scores_type_text },
+
+ { &setup.game_frame_delay, execSetupChooseGameSpeed },
+ { &setup.game_frame_delay, &game_speed_text },
+
+ { &setup.scroll_delay_value, execSetupChooseScrollDelay },
+ { &setup.scroll_delay_value, &scroll_delay_text },
+
+ { &setup.engine_snapshot_mode, execSetupChooseSnapshotMode },
+ { &setup.engine_snapshot_mode, &snapshot_mode_text },
+
+ { &setup.window_scaling_percent, execSetupChooseWindowSize },
+ { &setup.window_scaling_percent, &window_size_text },
+
+ { &setup.window_scaling_quality, execSetupChooseScalingType },
+ { &setup.window_scaling_quality, &scaling_type_text },
+
+ { &setup.screen_rendering_mode, execSetupChooseRenderingMode },
+ { &setup.screen_rendering_mode, &rendering_mode_text },
+
+ { &setup.vsync_mode, execSetupChooseVsyncMode },
+ { &setup.vsync_mode, &vsync_mode_text },
+
+ { &setup.graphics_set, execSetupChooseGraphics },
+ { &setup.graphics_set, &graphics_set_name },
+
+ { &setup.sounds_set, execSetupChooseSounds },
+ { &setup.sounds_set, &sounds_set_name },
+
+ { &setup.music_set, execSetupChooseMusic },
+ { &setup.music_set, &music_set_name },
+
+ { &setup.volume_simple, execSetupChooseVolumeSimple },
+ { &setup.volume_simple, &volume_simple_text },
+
+ { &setup.volume_loops, execSetupChooseVolumeLoops },
+ { &setup.volume_loops, &volume_loops_text },
+
+ { &setup.volume_music, execSetupChooseVolumeMusic },
+ { &setup.volume_music, &volume_music_text },
+
+ { &setup.touch.control_type, execSetupChooseTouchControls },
+ { &setup.touch.control_type, &touch_controls_text },
+
+ { &setup.touch.move_distance, execSetupChooseMoveDistance },
+ { &setup.touch.move_distance, &move_distance_text },
+
+ { &setup.touch.drop_distance, execSetupChooseDropDistance },
+ { &setup.touch.drop_distance, &drop_distance_text },
+
+ { &setup.touch.transparency, execSetupChooseTransparency },
+ { &setup.touch.transparency, &transparency_text },
+
+ { &setup.touch.grid_xsize[0], execSetupChooseGridXSize_0 },
+ { &setup.touch.grid_xsize[0], &grid_size_text[0][0] },
+
+ { &setup.touch.grid_ysize[0], execSetupChooseGridYSize_0 },
+ { &setup.touch.grid_ysize[0], &grid_size_text[0][1] },
+
+ { &setup.touch.grid_xsize[1], execSetupChooseGridXSize_1 },
+ { &setup.touch.grid_xsize[1], &grid_size_text[1][0] },
+
+ { &setup.touch.grid_ysize[1], execSetupChooseGridYSize_1 },
+ { &setup.touch.grid_ysize[1], &grid_size_text[1][1] },
+
+ { &setup.internal.menu_game, execSetupGame },
+ { &setup.internal.menu_engines, execSetupEngines },
+ { &setup.internal.menu_editor, execSetupEditor },
+ { &setup.internal.menu_graphics, execSetupGraphics },
+ { &setup.internal.menu_sound, execSetupSound },
+ { &setup.internal.menu_artwork, execSetupArtwork },
+ { &setup.internal.menu_input, execSetupInput },
+ { &setup.internal.menu_touch, execSetupTouch },
+ { &setup.internal.menu_shortcuts, execSetupShortcuts },
+ { &setup.internal.menu_exit, execExitSetup },
+ { &setup.internal.menu_save_and_exit, execSaveAndExitSetup },
+
+ { &setup.internal.menu_shortcuts_various, execSetupShortcuts1 },
+ { &setup.internal.menu_shortcuts_focus, execSetupShortcuts2 },
+ { &setup.internal.menu_shortcuts_tape, execSetupShortcuts3 },
+ { &setup.internal.menu_shortcuts_sound, execSetupShortcuts4 },
+ { &setup.internal.menu_shortcuts_snap, execSetupShortcuts5 },
+
+ { &setup.internal.info_title, execInfoTitleScreen },
+ { &setup.internal.info_elements, execInfoElements },
+ { &setup.internal.info_music, execInfoMusic },
+ { &setup.internal.info_credits, execInfoCredits },
+ { &setup.internal.info_program, execInfoProgram },
+ { &setup.internal.info_version, execInfoVersion },
+ { &setup.internal.info_levelset, execInfoLevelSet },
+ { &setup.internal.info_exit, execExitInfo },
+
+ { NULL, NULL }
+};
+
+void setHideRelatedSetupEntries(void)
+{
+ int i;
+
+ for (i = 0; hide_related_entry_list[i].value != NULL; i++)
+ if (hideSetupEntry(hide_related_entry_list[i].value))
+ setHideSetupEntry(hide_related_entry_list[i].related_value);
+}
+
+static struct TokenInfo setup_info_main[] =
+{
+ { TYPE_ENTER_MENU, execSetupGame, STR_SETUP_GAME },
+ { TYPE_ENTER_MENU, execSetupEngines, STR_SETUP_ENGINES },
+ { TYPE_ENTER_MENU, execSetupEditor, STR_SETUP_EDITOR },
+ { TYPE_ENTER_MENU, execSetupGraphics, STR_SETUP_GRAPHICS },
+ { TYPE_ENTER_MENU, execSetupSound, STR_SETUP_SOUND },
+ { TYPE_ENTER_MENU, execSetupArtwork, STR_SETUP_ARTWORK },
+ { TYPE_ENTER_MENU, execSetupInput, STR_SETUP_INPUT },
+ { TYPE_ENTER_MENU, execSetupTouch, STR_SETUP_TOUCH },
+ { TYPE_ENTER_MENU, execSetupShortcuts, STR_SETUP_SHORTCUTS },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execExitSetup, STR_SETUP_EXIT },
+ { TYPE_LEAVE_MENU, execSaveAndExitSetup, STR_SETUP_SAVE_AND_EXIT },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_game[] =
+{
+ { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" },
+ { TYPE_SWITCH, &setup.network_mode, "Network Multi-Player Mode:" },
+ { TYPE_PLAYER, &setup.network_player_nr, "Preferred Network Player:" },
+ { TYPE_TEXT_INPUT, execGadgetNetworkServer, "Network Server Hostname:" },
+ { TYPE_STRING, &network_server_text, "" },
+ { TYPE_SWITCH, &setup.use_api_server, "Use Highscore Server:" },
+ { TYPE_ENTER_LIST, execSetupChooseScoresType, "Scores in Highscore List:" },
+ { TYPE_STRING, &scores_type_text, "" },
+ { TYPE_ENTER_LIST, execOfferUploadTapes, "Upload 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:" },
+ { TYPE_SWITCH, &setup.handicap, "Force Solving Levels:" },
+ { TYPE_SWITCH, &setup.skip_levels, "Allow Skipping Levels:" },
+ { TYPE_SWITCH, &setup.increment_levels, "Increment Solved Levels:" },
+ { TYPE_SWITCH, &setup.auto_play_next_level, "Auto-play Next Level:" },
+ { TYPE_SWITCH, &setup.count_score_after_game, "Count Score After Game:" },
+ { TYPE_SWITCH, &setup.show_scores_after_game, "Show Scores After Game:" },
+ { TYPE_YES_NO, &setup.ask_on_game_over, "Ask on Game Over:" },
+ { TYPE_YES_NO, &setup.ask_on_quit_game, "Ask on Quit Game:" },
+ { TYPE_YES_NO, &setup.ask_on_quit_program, "Ask on Quit Program:" },
+ { TYPE_SWITCH, &setup.autorecord, "Auto-Record When Playing:" },
+ { TYPE_SWITCH, &setup.autorecord_after_replay, "Auto-Record After Replay:" },
+ { TYPE_SWITCH, &setup.auto_pause_on_start, "Start Game in Pause Mode:" },
+ { TYPE_ENTER_LIST, execSetupChooseGameSpeed, "Game Speed:" },
+ { TYPE_STRING, &game_speed_text, "" },
+ { TYPE_SWITCH, &setup.game_speed_extended, "Game Speed Extended List:" },
+#if 1
+ { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
+ { TYPE_STRING, &scroll_delay_text, "" },
+#endif
+ { TYPE_ENTER_LIST, execSetupChooseSnapshotMode, "Game Engine Snapshot Mode:" },
+ { TYPE_STRING, &snapshot_mode_text, "" },
+ { TYPE_SWITCH, &setup.show_load_save_buttons, "Show Load/Save Buttons:" },
+ { TYPE_SWITCH, &setup.show_undo_redo_buttons, "Show Undo/Redo Buttons:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_engines[] =
+{
+ { TYPE_HEADLINE, NULL, "Boulder Dash" },
+ { TYPE_SWITCH, &setup.bd_skip_uncovering, "Skip (un)covering screen:" },
+ { TYPE_SWITCH, &setup.bd_skip_hatching, "Skip hatching player:" },
+ { TYPE_SWITCH, &setup.bd_scroll_delay, "Scroll Delay:" },
+ { TYPE_YES_NO_AUTO, &setup.bd_smooth_movements, "Smooth Element Movement:" },
+ { TYPE_ENTER_LIST, &execSetupChoosePaletteC64, "Color Palette (C64):" },
+ { TYPE_STRING, &bd_palette_c64_text, "" },
+ { TYPE_ENTER_LIST, &execSetupChoosePaletteC64DTV, "Color Palette (C64DTV):" },
+ { TYPE_STRING, &bd_palette_c64dtv_text, "" },
+ { TYPE_ENTER_LIST, &execSetupChoosePaletteAtari, "Color Palette (Atari):" },
+ { TYPE_STRING, &bd_palette_atari_text, "" },
+ { TYPE_ENTER_LIST, &execSetupChooseColorType, "Preferred Color Type:" },
+ { TYPE_STRING, &bd_color_type_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_HEADLINE, NULL, "Emerald Mine" },
+ { TYPE_SWITCH, &setup.forced_scroll_delay, "Scroll Delay:" },
+ { TYPE_ECS_AGA, &setup.prefer_aga_graphics, "Amiga Graphics Chipset:" },
+ { TYPE_SWITCH, &setup.prefer_lowpass_sounds, "Low-Pass Filter Sounds:" },
+ { TYPE_SWITCH, &setup.prefer_extra_panel_items,"Show Dynamite and Keys:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_HEADLINE, NULL, "Supaplex" },
+ { TYPE_SWITCH, &setup.sp_show_border_elements, "Border Elements:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_editor[] =
+{
+#if 0
+ { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" },
+ { TYPE_SWITCH, &setup.editor.el_boulderdash_native, "Boulder Dash Native:" },
+ { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" },
+ { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" },
+ { TYPE_SWITCH, &setup.editor.el_more, "Rocks'n'Diamonds:" },
+ { TYPE_SWITCH, &setup.editor.el_sokoban, "Sokoban:" },
+ { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" },
+ { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" },
+ { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" },
+ { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" },
+ { TYPE_SWITCH, &setup.editor.el_steel_chars, "Text Characters (Steel):" },
+#endif
+ { TYPE_SWITCH, &setup.editor.el_classic, "Classic Elements:" },
+ { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" },
+#if 0
+ { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" },
+#endif
+ { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" },
+ { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" },
+ { TYPE_EMPTY, NULL, "" },
+#if 0
+ { TYPE_SWITCH, &setup.editor.el_by_game, "Show elements by game:" },
+ { TYPE_SWITCH, &setup.editor.el_by_type, "Show elements by type:" },
+ { TYPE_EMPTY, NULL, "" },
+#endif
+ { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_SWITCH, &setup.editor.show_read_only_warning, "Show read-only warning:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_graphics[] =
+{
+#if !defined(PLATFORM_ANDROID) && !defined(PLATFORM_EMSCRIPTEN)
+ { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
+ { TYPE_ENTER_LIST, execSetupChooseWindowSize, "Window Scaling:" },
+ { TYPE_STRING, &window_size_text, "" },
+ { TYPE_ENTER_LIST, execSetupChooseScalingType, "Anti-Aliasing:" },
+ { TYPE_STRING, &scaling_type_text, "" },
+ { TYPE_ENTER_LIST, execSetupChooseRenderingMode, "Special Rendering:" },
+ { TYPE_STRING, &rendering_mode_text, "" },
+#endif
+#if 0
+ { TYPE_ENTER_LIST, execSetupChooseScrollDelay, "Scroll Delay:" },
+ { TYPE_STRING, &scroll_delay_text, "" },
+#endif
+#if !defined(PLATFORM_EMSCRIPTEN)
+ { TYPE_ENTER_LIST, execSetupChooseVsyncMode, "Vertical Sync (VSync):" },
+ { TYPE_STRING, &vsync_mode_text, "" },
+#endif
+ { TYPE_SWITCH, &setup.fade_screens, "Fade Screens:" },
+ { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" },
+ { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" },
+ { TYPE_SWITCH, &setup.show_titlescreen, "Show Title Screens:" },
+ { TYPE_SWITCH, &setup.toons, "Show Toons:" },
+ { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" },
+ { TYPE_YES_NO_AUTO, &setup.debug.xsn_mode, debug_xsn_mode },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_sound[] =
+{
+ { TYPE_SWITCH, &setup.sound_simple, "Sound Effects (Normal):" },
+ { TYPE_SWITCH, &setup.sound_loops, "Sound Effects (Looping):" },
+ { TYPE_SWITCH, &setup.sound_music, "Music:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupChooseVolumeSimple, "Sound Volume (Normal):" },
+ { TYPE_STRING, &volume_simple_text, "" },
+ { TYPE_ENTER_LIST, execSetupChooseVolumeLoops, "Sound Volume (Looping):" },
+ { TYPE_STRING, &volume_loops_text, "" },
+ { TYPE_ENTER_LIST, execSetupChooseVolumeMusic, "Music Volume:" },
+ { TYPE_STRING, &volume_music_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_artwork[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseGraphics, "Custom Graphics:" },
+ { TYPE_STRING, &graphics_set_name, "" },
+ { TYPE_ENTER_LIST, execSetupChooseSounds, "Custom Sounds:" },
+ { TYPE_STRING, &sounds_set_name, "" },
+ { TYPE_ENTER_LIST, execSetupChooseMusic, "Custom Music:" },
+ { TYPE_STRING, &music_set_name, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_YES_NO_AUTO, &setup.override_level_graphics,"Override Level Graphics:" },
+ { TYPE_YES_NO_AUTO, &setup.override_level_sounds, "Override Level Sounds:" },
+ { TYPE_YES_NO_AUTO, &setup.override_level_music, "Override Level Music:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_input[] =
+{
+ { TYPE_SWITCH, NULL, "Player:" },
+ { TYPE_SWITCH, NULL, "Device:" },
+ { TYPE_SWITCH, NULL, "" },
+ { TYPE_SKIPPABLE, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_SKIPPABLE, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_touch[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
+ { TYPE_STRING, &touch_controls_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_touch_virtual_buttons_0[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
+ { TYPE_STRING, &touch_controls_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupChooseGridXSize_0, "Horizontal Buttons (Landscape):" },
+ { TYPE_STRING, &grid_size_text[0][0], "" },
+ { TYPE_ENTER_LIST, execSetupChooseGridYSize_0, "Vertical Buttons (Landscape):" },
+ { TYPE_STRING, &grid_size_text[0][1], "" },
+ { TYPE_ENTER_LIST, execSetupChooseTransparency, "Button Transparency:" },
+ { TYPE_STRING, &transparency_text, "" },
+ { TYPE_SWITCH, &setup.touch.draw_outlined, "Draw Buttons Outlined:" },
+ { TYPE_SWITCH, &setup.touch.draw_pressed, "Highlight Pressed Buttons:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_touch_virtual_buttons_1[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
+ { TYPE_STRING, &touch_controls_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupChooseGridXSize_1, "Horizontal Buttons (Portrait):" },
+ { TYPE_STRING, &grid_size_text[1][0], "" },
+ { TYPE_ENTER_LIST, execSetupChooseGridYSize_1, "Vertical Buttons (Portrait):" },
+ { TYPE_STRING, &grid_size_text[1][1], "" },
+ { TYPE_ENTER_LIST, execSetupChooseTransparency, "Button Transparency:" },
+ { TYPE_STRING, &transparency_text, "" },
+ { TYPE_SWITCH, &setup.touch.draw_outlined, "Draw Buttons Outlined:" },
+ { TYPE_SWITCH, &setup.touch.draw_pressed, "Highlight Pressed Buttons:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo *setup_info_touch_virtual_buttons[] =
+{
+ setup_info_touch_virtual_buttons_0,
+ setup_info_touch_virtual_buttons_1
+};
+
+static struct TokenInfo setup_info_touch_wipe_gestures[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
+ { TYPE_STRING, &touch_controls_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_LIST, execSetupChooseMoveDistance, "Move Trigger Distance:" },
+ { TYPE_STRING, &move_distance_text, "" },
+ { TYPE_ENTER_LIST, execSetupChooseDropDistance, "Drop Trigger Distance:" },
+ { TYPE_STRING, &drop_distance_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcuts[] =
+{
+ { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" },
+ { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" },
+ { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" },
+ { TYPE_ENTER_MENU, execSetupShortcuts4, "Sound & Music" },
+ { TYPE_ENTER_MENU, execSetupShortcuts5, "TAS Snap Keys" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcuts_1[] =
+{
+ { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:" },
+ { TYPE_KEY, &setup.shortcut.save_game, "" },
+ { TYPE_KEYTEXT, NULL, "Quick Load Game from Tape:" },
+ { TYPE_KEY, &setup.shortcut.load_game, "" },
+ { TYPE_KEYTEXT, NULL, "Restart Game:" },
+ { TYPE_KEY, &setup.shortcut.restart_game, "" },
+ { TYPE_KEYTEXT, NULL, "Replay & Pause Before End:" },
+ { TYPE_KEY, &setup.shortcut.pause_before_end, "" },
+ { TYPE_KEYTEXT, NULL, "Start Game & Toggle Pause:" },
+ { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" },
+ { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcuts_2[] =
+{
+ { TYPE_KEYTEXT, NULL, "Set Focus to Player 1:" },
+ { TYPE_KEY, &setup.shortcut.focus_player[0], "" },
+ { TYPE_KEYTEXT, NULL, "Set Focus to Player 2:" },
+ { TYPE_KEY, &setup.shortcut.focus_player[1], "" },
+ { TYPE_KEYTEXT, NULL, "Set Focus to Player 3:" },
+ { TYPE_KEY, &setup.shortcut.focus_player[2], "" },
+ { TYPE_KEYTEXT, NULL, "Set Focus to Player 4:" },
+ { TYPE_KEY, &setup.shortcut.focus_player[3], "" },
+ { TYPE_KEYTEXT, NULL, "Set Focus to All Players:" },
+ { TYPE_KEY, &setup.shortcut.focus_player_all, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcuts_3[] =
+{
+ { TYPE_KEYTEXT, NULL, "Eject Tape:" },
+ { TYPE_KEY, &setup.shortcut.tape_eject, "" },
+ { TYPE_KEYTEXT, NULL, "Warp / Single Step:" },
+ { TYPE_KEY, &setup.shortcut.tape_extra, "" },
+ { TYPE_KEYTEXT, NULL, "Stop Tape:" },
+ { TYPE_KEY, &setup.shortcut.tape_stop, "" },
+ { TYPE_KEYTEXT, NULL, "Pause / Unpause Tape:" },
+ { TYPE_KEY, &setup.shortcut.tape_pause, "" },
+ { TYPE_KEYTEXT, NULL, "Record Tape:" },
+ { TYPE_KEY, &setup.shortcut.tape_record, "" },
+ { TYPE_KEYTEXT, NULL, "Play Tape:" },
+ { TYPE_KEY, &setup.shortcut.tape_play, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcuts_4[] =
+{
+ { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Normal):" },
+ { TYPE_KEY, &setup.shortcut.sound_simple, "" },
+ { TYPE_KEYTEXT, NULL, "Toggle Sound Effects (Looping):" },
+ { TYPE_KEY, &setup.shortcut.sound_loops, "" },
+ { TYPE_KEYTEXT, NULL, "Toggle Music:" },
+ { TYPE_KEY, &setup.shortcut.sound_music, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcuts_5[] =
+{
+ { TYPE_KEYTEXT, NULL, "Snap Left:" },
+ { TYPE_KEY, &setup.shortcut.snap_left, "" },
+ { TYPE_KEYTEXT, NULL, "Snap Right:" },
+ { TYPE_KEY, &setup.shortcut.snap_right, "" },
+ { TYPE_KEYTEXT, NULL, "Snap Up:" },
+ { TYPE_KEY, &setup.shortcut.snap_up, "" },
+ { TYPE_KEYTEXT, NULL, "Snap Down:" },
+ { TYPE_KEY, &setup.shortcut.snap_down, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static Key getSetupKey(void)
+{
+ Key key = KSYM_UNDEFINED;
+ boolean got_key_event = FALSE;
+
+ while (!got_key_event)
+ {
+ Event event;
+
+ if (NextValidEvent(&event))
+ {
+ switch (event.type)
+ {
+ case EVENT_KEYPRESS:
+ {
+ key = GetEventKey((KeyEvent *)&event);
+
+ // press 'Escape' or 'Enter' to keep the existing key binding
+ if (key == KSYM_Escape || key == KSYM_Return)
+ key = KSYM_UNDEFINED; // keep old value
+
+ got_key_event = TRUE;
+ }
+ break;
+
+ case EVENT_KEYRELEASE:
+ key_joystick_mapping = 0;
+ break;
+
+ default:
+ HandleOtherEvents(&event);
+ break;
+ }
+ }
+
+ BackToFront();
+ }
+
+ return key;
+}
+
+static int getSetupValueFont(int type, void *value)
+{
+ if (type & TYPE_GHOSTED)
+ return FONT_OPTION_OFF;
+ else if (type & TYPE_KEY)
+ return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1);
+ else if (type & TYPE_STRING)
+ return FONT_VALUE_2;
+ else if (type & TYPE_ECS_AGA)
+ return FONT_VALUE_1;
+ else if (type & TYPE_BOOLEAN_STYLE)
+ return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF);
+ else if (type & TYPE_YES_NO_AUTO)
+ return (*(int *)value == AUTO ? FONT_OPTION_ON :
+ *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON);
+ else if (type & TYPE_PLAYER)
+ return FONT_VALUE_1;
+ else
+ return FONT_VALUE_1;
+}
+
+static int getSetupValueFontNarrow(int type, int font_nr)
+{
+ return (font_nr == FONT_VALUE_1 ? FONT_VALUE_NARROW :
+ font_nr == FONT_OPTION_ON ? FONT_OPTION_ON_NARROW :
+ font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW :
+ font_nr);
+}
+
+static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
+{
+ int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
+ struct TokenInfo *si = &setup_info[si_pos];
+ boolean font_draw_xoffset_modified = FALSE;
+ boolean scrollbar_needed = (num_setup_info < max_setup_info);
+ int mx_scrollbar = screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x;
+ int mx_right_border = (scrollbar_needed ? mx_scrollbar : SX + SXSIZE);
+ int font_draw_xoffset_old = -1;
+ int xoffset = (scrollbar_needed ? 0 : 1);
+ int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
+ int xpos = menu_screen_value_xpos;
+ int ypos = MENU_SCREEN_START_YPOS + screen_pos;
+ int startx = mSX + xpos * 32;
+ int starty = mSY + ypos * 32;
+ int type = si->type;
+ void *value = si->value;
+ char *value_string = getSetupValue(type, value);
+ int font_nr_default = getSetupValueFont(type, value);
+ int font_width_default = getFontWidth(font_nr_default);
+ int font_nr = font_nr_default;
+
+ if (value_string == NULL)
+ return;
+
+ if (type & TYPE_KEY)
+ {
+ xpos = MENU_SCREEN_START_XPOS;
+
+ if (type & TYPE_QUERY)
+ value_string = "<press key>";
+ }
+ else if (type & TYPE_STRING)
+ {
+ int max_value_len = (SXSIZE - 2 * TILEX) / font_width_default;
+
+ xpos = MENU_SCREEN_START_XPOS;
+
+ if (strlen(value_string) > max_value_len)
+ value_string[max_value_len] = '\0';
+ }
+ else if (type & TYPE_PLAYER)
+ {
+ int displayed_player_nr = *(int *)value + 1;
+
+ value_string = getSetupValue(TYPE_INTEGER, (void *)&displayed_player_nr);
+ }
+
+ startx = mSX + xpos * 32;
+ starty = mSY + ypos * 32;
+
+ // always use narrow font for setup values on right screen side
+ if (xpos > MENU_SCREEN_START_XPOS)
+ font_nr = getSetupValueFontNarrow(type, font_nr);
+
+ // downward compatibility correction for Juergen Bonhagen's menu settings
+ if (setup_mode != SETUP_MODE_INPUT)
+ {
+ int max_menu_text_length_big = (menu_screen_value_xpos -
+ MENU_SCREEN_START_XPOS);
+ int max_menu_text_length_medium = max_menu_text_length_big * 2;
+ int check_font_nr = FONT_OPTION_ON; // known font that needs correction
+ int font1_xoffset = getFontDrawOffsetX(font_nr);
+ int font2_xoffset = getFontDrawOffsetX(check_font_nr);
+ int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
+ int text_font_nr = getMenuTextFont(FONT_MENU_2);
+ int text_font_xoffset = getFontDrawOffsetX(text_font_nr);
+ int text_width = max_menu_text_length_medium * getFontWidth(text_font_nr);
+ boolean correct_font_draw_xoffset = FALSE;
+
+ if (xpos == MENU_SCREEN_START_XPOS &&
+ startx + font1_xoffset < text_startx + text_font_xoffset)
+ correct_font_draw_xoffset = TRUE;
+
+ if (xpos == menu_screen_value_xpos &&
+ startx + font2_xoffset < text_startx + text_width + text_font_xoffset)
+ correct_font_draw_xoffset = TRUE;
+
+ // check if setup value would overlap with setup text when printed
+ // (this can happen for extreme/wrong values for font draw offset)
+ if (correct_font_draw_xoffset)
+ {
+ font_draw_xoffset_old = getFontDrawOffsetX(font_nr);
+ font_draw_xoffset_modified = TRUE;
+
+ if (type & TYPE_KEY)
+ getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr);
+ else if (!(type & TYPE_STRING))
+ getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 -
+ max_menu_text_length_medium * (16 - getFontWidth(text_font_nr));
+ }
+ }
+
+ DrawBackground(startx, starty, mx_right_border - startx, getFontHeight(font_nr));
+ DrawText(startx, starty, value_string, font_nr);
+
+ if (type & TYPE_PLAYER)
+ {
+ struct FontBitmapInfo *font = getFontBitmapInfo(font_nr);
+ int player_nr = *(int *)value;
+ int xoff = font->draw_xoffset + getFontWidth(font_nr);
+ int yoff = font->draw_yoffset + (getFontHeight(font_nr) - TILEY) / 2;
+ int startx2 = startx + xoff;
+ int starty2 = starty + yoff;
+
+ if (DrawingOnBackground(startx2, starty2))
+ ClearRectangleOnBackground(drawto, startx2, starty2, TILEX, TILEY);
+
+ DrawFixedGraphicThruMaskExt(drawto, startx2, starty2,
+ PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
+ }
+
+ if (font_draw_xoffset_modified)
+ getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old;
+}
+
+static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx)
+{
+ int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
+ struct TokenInfo *si = &setup_info[si_pos];
+
+ if (si->type & TYPE_BOOLEAN_STYLE)
+ {
+ *(boolean *)si->value ^= TRUE;
+ }
+ else if (si->type & TYPE_YES_NO_AUTO)
+ {
+ *(int *)si->value =
+ (dx == -1 ?
+ (*(int *)si->value == AUTO ? TRUE :
+ *(int *)si->value == TRUE ? FALSE : AUTO) :
+ (*(int *)si->value == TRUE ? AUTO :
+ *(int *)si->value == AUTO ? FALSE : TRUE));
+ }
+ else if (si->type & TYPE_KEY)
+ {
+ Key key;
+
+ si->type |= TYPE_QUERY;
+ drawSetupValue(screen_pos, setup_info_pos_raw);
+ si->type &= ~TYPE_QUERY;
+
+ key = getSetupKey();
+ if (key != KSYM_UNDEFINED)
+ *(Key *)si->value = key;
+ }
+ else if (si->type & TYPE_PLAYER)
+ {
+ int player_nr = *(int *)si->value;
+
+ if (dx)
+ player_nr += dx;
+ else
+ player_nr = Request("Choose player", REQ_PLAYER) - 1;
+
+ *(int *)si->value = MIN(MAX(0, player_nr), MAX_PLAYERS - 1);
+ }
+
+ drawSetupValue(screen_pos, setup_info_pos_raw);
+
+ // fullscreen state may have changed at this point
+ if (si->value == &setup.fullscreen)
+ ToggleFullscreenIfNeeded();
+
+ // network mode may have changed at this point
+ if (si->value == &setup.network_mode)
+ ToggleNetworkModeIfNeeded();
+
+ // API server mode may have changed at this point
+ if (si->value == &setup.use_api_server)
+ ToggleUseApiServerIfNeeded();
+
+ // game speed list may have changed at this point
+ if (si->value == &setup.game_speed_extended)
+ ToggleGameSpeedsListIfNeeded();
+}
+
+static struct TokenInfo *getSetupInfoFinal(struct TokenInfo *setup_info_orig)
+{
+ static struct TokenInfo *setup_info_final = NULL;
+ int list_size = 0;
+ int list_pos = 0;
+ int i;
+
+ // determine maximum list size of target list
+ while (setup_info_orig[list_size++].type != 0);
+
+ // free, allocate and clear memory for target list
+ checked_free(setup_info_final);
+ setup_info_final = checked_calloc(list_size * sizeof(struct TokenInfo));
+
+ // copy setup info list without setup entries marked as hidden
+ for (i = 0; setup_info_orig[i].type != 0; i++)
+ {
+ // skip setup entries configured to be hidden
+ if (hideSetupEntry(setup_info_orig[i].value))
+ continue;
+
+ // skip skippable setup entries if screen is lower than usual
+ if (SCR_FIELDY < SCR_FIELDY_DEFAULT &&
+ setup_info_orig[i].type == TYPE_SKIPPABLE)
+ continue;
+
+ setup_info_final[list_pos++] = setup_info_orig[i];
+ }
+
+ return setup_info_final;
+}
+
+static void DrawSetupScreen_Generic(void)
+{
+ int fade_mask = REDRAW_FIELD;
+ boolean redraw_all = FALSE;
+ char *title_string = NULL;
+ int i;
+
+ if (CheckFadeAll())
+ fade_mask = REDRAW_ALL;
+
+ UnmapAllGadgets();
+ FadeMenuSoundsAndMusic();
+
+ FreeScreenGadgets();
+ CreateScreenGadgets();
+
+ if (redraw_mask & REDRAW_ALL)
+ redraw_all = TRUE;
+
+ FadeOut(fade_mask);
+
+ // needed if different viewport properties defined for setup screen
+ ChangeViewportPropertiesIfNeeded();
+
+ SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
+
+ ClearField();
+
+ OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+
+ if (setup_mode == SETUP_MODE_MAIN)
+ {
+ setup_info = setup_info_main;
+ title_string = STR_SETUP_MAIN;
+ }
+ else if (setup_mode == SETUP_MODE_GAME)
+ {
+ setup_info = setup_info_game;
+ title_string = STR_SETUP_GAME;
+ }
+ else if (setup_mode == SETUP_MODE_ENGINES)
+ {
+ setup_info = setup_info_engines;
+ title_string = STR_SETUP_ENGINES;
+ }
+ else if (setup_mode == SETUP_MODE_EDITOR)
+ {
+ setup_info = setup_info_editor;
+ title_string = STR_SETUP_EDITOR;
+ }
+ else if (setup_mode == SETUP_MODE_GRAPHICS)
+ {
+ setup_info = setup_info_graphics;
+ title_string = STR_SETUP_GRAPHICS;
+ }
+ else if (setup_mode == SETUP_MODE_SOUND)
+ {
+ setup_info = setup_info_sound;
+ title_string = STR_SETUP_SOUND;
+ }
+ else if (setup_mode == SETUP_MODE_ARTWORK)
+ {
+ setup_info = setup_info_artwork;
+ title_string = STR_SETUP_ARTWORK;
+ }
+ else if (setup_mode == SETUP_MODE_TOUCH)
+ {
+ setup_info = setup_info_touch;
+ title_string = STR_SETUP_TOUCH;
+
+ if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
+ setup_info = setup_info_touch_virtual_buttons[GRID_ACTIVE_NR()];
+ else if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
+ setup_info = setup_info_touch_wipe_gestures;
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUTS)
+ {
+ setup_info = setup_info_shortcuts;
+ title_string = STR_SETUP_SHORTCUTS;
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUTS_1)
+ {
+ setup_info = setup_info_shortcuts_1;
+ title_string = STR_SETUP_SHORTCUTS;
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUTS_2)
+ {
+ setup_info = setup_info_shortcuts_2;
+ title_string = STR_SETUP_SHORTCUTS;
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUTS_3)
+ {
+ setup_info = setup_info_shortcuts_3;
+ title_string = STR_SETUP_SHORTCUTS;
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUTS_4)
+ {
+ setup_info = setup_info_shortcuts_4;
+ title_string = STR_SETUP_SHORTCUTS;
+ }
+ else if (setup_mode == SETUP_MODE_SHORTCUTS_5)
+ {
+ setup_info = setup_info_shortcuts_5;
+ title_string = STR_SETUP_SHORTCUTS;
+ }
+
+ // use modified setup info without setup entries marked as hidden
+ setup_info = getSetupInfoFinal(setup_info);
+
+ DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string);
+
+ // determine maximal number of setup entries that can be displayed on screen
+ num_setup_info = 0;
+ for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
+ num_setup_info++;
+
+ // determine maximal number of setup entries available for this setup screen
+ max_setup_info = 0;
+ for (i = 0; setup_info[i].type != 0; i++)
+ max_setup_info++;
+
+ HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE);
+
+ MapScreenGadgets(max_setup_info);
+
+ if (redraw_all)
+ redraw_mask = fade_mask = REDRAW_ALL;
+
+ DrawMaskedBorder(fade_mask);
+
+ FadeIn(fade_mask);
+}
+
+void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
+{
+ menu_info = setup_info;
+
+ HandleMenuScreen(mx, my, dx, dy, button,
+ setup_mode, num_setup_info, max_setup_info);
+}
+
+static void DrawSetupScreen_Input(void)
+{
+ int i;
+
+ FadeOut(REDRAW_FIELD);
+
+ ClearField();
+
+ setup_info = getSetupInfoFinal(setup_info_input);
+
+ DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, STR_SETUP_INPUT);
+
+ for (i = 0; setup_info[i].type != 0; i++)
+ {
+ if (setup_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
+ initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
+ else if (setup_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
+ initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
+ else if (setup_info[i].type & ~TYPE_SKIP_ENTRY)
+ initCursor(i, IMG_MENU_BUTTON);
+
+ DrawCursorAndText_Setup(i, -1, FALSE);
+ }
+
+ // create gadgets for setup input menu screen
+ FreeScreenGadgets();
+ CreateScreenGadgets();
+
+ // map gadgets for setup input menu screen
+ MapScreenMenuGadgets(SCREEN_MASK_INPUT);
+
+ HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
+
+ FadeIn(REDRAW_FIELD);
+}
+
+static void setJoystickDeviceToNr(char *device_name, int device_nr)
+{
+ if (device_name == NULL)
+ return;