+static void setSetupInfoToDefaults(struct SetupInfo *si)
+{
+ int i;
+
+ si->player_name = getStringCopy(getDefaultUserName(user.nr));
+
+ si->multiple_users = TRUE;
+
+ si->sound = TRUE;
+ si->sound_loops = TRUE;
+ si->sound_music = TRUE;
+ si->sound_simple = TRUE;
+ si->toons = TRUE;
+ si->global_animations = TRUE;
+ si->scroll_delay = TRUE;
+ si->forced_scroll_delay = FALSE;
+ si->scroll_delay_value = STD_SCROLL_DELAY;
+ si->engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_DEFAULT);
+ si->engine_snapshot_memory = SNAPSHOT_MEMORY_DEFAULT;
+ si->fade_screens = TRUE;
+ si->autorecord = TRUE;
+ si->autorecord_after_replay = TRUE;
+ si->auto_pause_on_start = FALSE;
+ si->show_titlescreen = TRUE;
+ si->quick_doors = FALSE;
+ si->team_mode = FALSE;
+ si->handicap = TRUE;
+ si->skip_levels = TRUE;
+ si->increment_levels = TRUE;
+ si->auto_play_next_level = TRUE;
+ si->count_score_after_game = TRUE;
+ si->show_scores_after_game = TRUE;
+ si->time_limit = TRUE;
+ si->fullscreen = FALSE;
+ si->window_scaling_percent = STD_WINDOW_SCALING_PERCENT;
+ si->window_scaling_quality = getStringCopy(SCALING_QUALITY_DEFAULT);
+ si->screen_rendering_mode = getStringCopy(STR_SPECIAL_RENDERING_DEFAULT);
+ si->vsync_mode = getStringCopy(STR_VSYNC_MODE_DEFAULT);
+ si->ask_on_escape = TRUE;
+ si->ask_on_escape_editor = TRUE;
+ si->ask_on_game_over = TRUE;
+ si->ask_on_quit_game = TRUE;
+ si->ask_on_quit_program = TRUE;
+ si->quick_switch = FALSE;
+ si->input_on_focus = FALSE;
+ si->prefer_aga_graphics = TRUE;
+ si->prefer_lowpass_sounds = FALSE;
+ si->prefer_extra_panel_items = TRUE;
+ si->game_speed_extended = FALSE;
+ si->game_frame_delay = GAME_FRAME_DELAY;
+ si->bd_skip_uncovering = FALSE;
+ si->bd_skip_hatching = FALSE;
+ si->sp_show_border_elements = FALSE;
+ si->small_game_graphics = FALSE;
+ si->show_load_save_buttons = FALSE;
+ si->show_undo_redo_buttons = FALSE;
+ si->scores_in_highscore_list = getStringCopy(STR_SCORES_TYPE_DEFAULT);
+
+ si->graphics_set = getStringCopy(GFX_CLASSIC_SUBDIR);
+ si->sounds_set = getStringCopy(SND_CLASSIC_SUBDIR);
+ si->music_set = getStringCopy(MUS_CLASSIC_SUBDIR);
+
+ si->override_level_graphics = FALSE;
+ si->override_level_sounds = FALSE;
+ si->override_level_music = FALSE;
+
+ si->volume_simple = 100; // percent
+ si->volume_loops = 100; // percent
+ si->volume_music = 100; // percent
+
+ si->network_mode = FALSE;
+ si->network_player_nr = 0; // first player
+ si->network_server_hostname = getStringCopy(STR_NETWORK_AUTO_DETECT);
+
+ si->touch.control_type = getStringCopy(TOUCH_CONTROL_DEFAULT);
+ si->touch.move_distance = TOUCH_MOVE_DISTANCE_DEFAULT; // percent
+ si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT; // percent
+ si->touch.transparency = TOUCH_TRANSPARENCY_DEFAULT; // percent
+ si->touch.draw_outlined = TRUE;
+ si->touch.draw_pressed = TRUE;
+
+ for (i = 0; i < 2; i++)
+ {
+ char *default_grid_button[6][2] =
+ {
+ { " ", " ^^ " },
+ { " ", " ^^ " },
+ { " ", "<< >>" },
+ { " ", "<< >>" },
+ { "111222", " vv " },
+ { "111222", " vv " }
+ };
+ int grid_xsize = DEFAULT_GRID_XSIZE(i);
+ int grid_ysize = DEFAULT_GRID_YSIZE(i);
+ int min_xsize = MIN(6, grid_xsize);
+ int min_ysize = MIN(6, grid_ysize);
+ int startx = grid_xsize - min_xsize;
+ int starty = grid_ysize - min_ysize;
+ int x, y;
+
+ // virtual buttons grid can only be set to defaults if video is initialized
+ // (this will be repeated if virtual buttons are not loaded from setup file)
+ if (video.initialized)
+ {
+ si->touch.grid_xsize[i] = grid_xsize;
+ si->touch.grid_ysize[i] = grid_ysize;
+ }
+ else
+ {
+ si->touch.grid_xsize[i] = -1;
+ si->touch.grid_ysize[i] = -1;
+ }
+
+ for (x = 0; x < MAX_GRID_XSIZE; x++)
+ for (y = 0; y < MAX_GRID_YSIZE; y++)
+ si->touch.grid_button[i][x][y] = CHAR_GRID_BUTTON_NONE;
+
+ for (x = 0; x < min_xsize; x++)
+ for (y = 0; y < min_ysize; y++)
+ si->touch.grid_button[i][x][starty + y] =
+ default_grid_button[y][0][x];
+
+ for (x = 0; x < min_xsize; x++)
+ for (y = 0; y < min_ysize; y++)
+ si->touch.grid_button[i][startx + x][starty + y] =
+ default_grid_button[y][1][x];
+ }
+
+ si->touch.grid_initialized = video.initialized;
+
+ si->touch.overlay_buttons = FALSE;
+
+ si->editor.el_boulderdash = TRUE;
+ si->editor.el_boulderdash_native = TRUE;
+ si->editor.el_emerald_mine = TRUE;
+ si->editor.el_emerald_mine_club = TRUE;
+ si->editor.el_more = TRUE;
+ si->editor.el_sokoban = TRUE;
+ si->editor.el_supaplex = TRUE;
+ si->editor.el_diamond_caves = TRUE;
+ si->editor.el_dx_boulderdash = TRUE;
+
+ si->editor.el_mirror_magic = TRUE;
+ si->editor.el_deflektor = TRUE;
+
+ si->editor.el_chars = TRUE;
+ si->editor.el_steel_chars = TRUE;
+
+ si->editor.el_classic = TRUE;
+ si->editor.el_custom = TRUE;
+
+ si->editor.el_user_defined = FALSE;
+ si->editor.el_dynamic = TRUE;
+
+ si->editor.el_headlines = TRUE;
+
+ si->editor.show_element_token = FALSE;
+
+ si->editor.show_read_only_warning = TRUE;
+
+ si->editor.use_template_for_new_levels = TRUE;
+
+ si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME;
+ si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME;
+ si->shortcut.restart_game = DEFAULT_KEY_RESTART_GAME;
+ si->shortcut.pause_before_end = DEFAULT_KEY_PAUSE_BEFORE_END;
+ si->shortcut.toggle_pause = DEFAULT_KEY_TOGGLE_PAUSE;
+
+ si->shortcut.focus_player[0] = DEFAULT_KEY_FOCUS_PLAYER_1;
+ si->shortcut.focus_player[1] = DEFAULT_KEY_FOCUS_PLAYER_2;
+ si->shortcut.focus_player[2] = DEFAULT_KEY_FOCUS_PLAYER_3;
+ si->shortcut.focus_player[3] = DEFAULT_KEY_FOCUS_PLAYER_4;
+ si->shortcut.focus_player_all = DEFAULT_KEY_FOCUS_PLAYER_ALL;
+
+ si->shortcut.tape_eject = DEFAULT_KEY_TAPE_EJECT;
+ si->shortcut.tape_extra = DEFAULT_KEY_TAPE_EXTRA;
+ si->shortcut.tape_stop = DEFAULT_KEY_TAPE_STOP;
+ si->shortcut.tape_pause = DEFAULT_KEY_TAPE_PAUSE;
+ si->shortcut.tape_record = DEFAULT_KEY_TAPE_RECORD;
+ si->shortcut.tape_play = DEFAULT_KEY_TAPE_PLAY;
+
+ si->shortcut.sound_simple = DEFAULT_KEY_SOUND_SIMPLE;
+ si->shortcut.sound_loops = DEFAULT_KEY_SOUND_LOOPS;
+ si->shortcut.sound_music = DEFAULT_KEY_SOUND_MUSIC;
+
+ si->shortcut.snap_left = DEFAULT_KEY_SNAP_LEFT;
+ si->shortcut.snap_right = DEFAULT_KEY_SNAP_RIGHT;
+ si->shortcut.snap_up = DEFAULT_KEY_SNAP_UP;
+ si->shortcut.snap_down = DEFAULT_KEY_SNAP_DOWN;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ si->input[i].use_joystick = FALSE;
+ si->input[i].joy.device_name = getStringCopy(getDeviceNameFromJoystickNr(i));
+ si->input[i].joy.xleft = JOYSTICK_XLEFT;
+ si->input[i].joy.xmiddle = JOYSTICK_XMIDDLE;
+ si->input[i].joy.xright = JOYSTICK_XRIGHT;
+ si->input[i].joy.yupper = JOYSTICK_YUPPER;
+ si->input[i].joy.ymiddle = JOYSTICK_YMIDDLE;
+ si->input[i].joy.ylower = JOYSTICK_YLOWER;
+ si->input[i].joy.snap = (i == 0 ? JOY_BUTTON_1 : 0);
+ si->input[i].joy.drop = (i == 0 ? JOY_BUTTON_2 : 0);
+ si->input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KSYM_UNDEFINED);
+ si->input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KSYM_UNDEFINED);
+ si->input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KSYM_UNDEFINED);
+ si->input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KSYM_UNDEFINED);
+ si->input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KSYM_UNDEFINED);
+ si->input[i].key.drop = (i == 0 ? DEFAULT_KEY_DROP : KSYM_UNDEFINED);
+ }
+
+ si->system.sdl_renderdriver = getStringCopy(ARG_DEFAULT);
+ si->system.sdl_videodriver = getStringCopy(ARG_DEFAULT);
+ si->system.sdl_audiodriver = getStringCopy(ARG_DEFAULT);
+ si->system.audio_fragment_size = DEFAULT_AUDIO_FRAGMENT_SIZE;
+
+ si->internal.program_title = getStringCopy(PROGRAM_TITLE_STRING);
+ si->internal.program_version = getStringCopy(getProgramRealVersionString());
+ si->internal.program_author = getStringCopy(PROGRAM_AUTHOR_STRING);
+ si->internal.program_email = getStringCopy(PROGRAM_EMAIL_STRING);
+ si->internal.program_website = getStringCopy(PROGRAM_WEBSITE_STRING);
+ si->internal.program_copyright = getStringCopy(PROGRAM_COPYRIGHT_STRING);
+ si->internal.program_company = getStringCopy(PROGRAM_COMPANY_STRING);
+
+ si->internal.program_icon_file = getStringCopy(PROGRAM_ICON_FILENAME);
+
+ si->internal.default_graphics_set = getStringCopy(GFX_CLASSIC_SUBDIR);
+ si->internal.default_sounds_set = getStringCopy(SND_CLASSIC_SUBDIR);
+ si->internal.default_music_set = getStringCopy(MUS_CLASSIC_SUBDIR);
+
+ si->internal.fallback_graphics_file = getStringCopy(UNDEFINED_FILENAME);
+ si->internal.fallback_sounds_file = getStringCopy(UNDEFINED_FILENAME);
+ si->internal.fallback_music_file = getStringCopy(UNDEFINED_FILENAME);
+
+ si->internal.default_level_series = getStringCopy(UNDEFINED_LEVELSET);
+ si->internal.choose_from_top_leveldir = FALSE;
+ si->internal.show_scaling_in_title = TRUE;
+ si->internal.create_user_levelset = TRUE;
+ si->internal.info_screens_from_main = FALSE;
+
+ si->internal.default_window_width = WIN_XSIZE_DEFAULT;
+ si->internal.default_window_height = WIN_YSIZE_DEFAULT;
+
+ si->debug.frame_delay[0] = DEFAULT_FRAME_DELAY_0;
+ si->debug.frame_delay[1] = DEFAULT_FRAME_DELAY_1;
+ si->debug.frame_delay[2] = DEFAULT_FRAME_DELAY_2;
+ si->debug.frame_delay[3] = DEFAULT_FRAME_DELAY_3;
+ si->debug.frame_delay[4] = DEFAULT_FRAME_DELAY_4;
+ si->debug.frame_delay[5] = DEFAULT_FRAME_DELAY_5;
+ si->debug.frame_delay[6] = DEFAULT_FRAME_DELAY_6;
+ si->debug.frame_delay[7] = DEFAULT_FRAME_DELAY_7;
+ si->debug.frame_delay[8] = DEFAULT_FRAME_DELAY_8;
+ si->debug.frame_delay[9] = DEFAULT_FRAME_DELAY_9;
+
+ si->debug.frame_delay_key[0] = DEFAULT_KEY_FRAME_DELAY_0;
+ si->debug.frame_delay_key[1] = DEFAULT_KEY_FRAME_DELAY_1;
+ si->debug.frame_delay_key[2] = DEFAULT_KEY_FRAME_DELAY_2;
+ si->debug.frame_delay_key[3] = DEFAULT_KEY_FRAME_DELAY_3;
+ si->debug.frame_delay_key[4] = DEFAULT_KEY_FRAME_DELAY_4;
+ si->debug.frame_delay_key[5] = DEFAULT_KEY_FRAME_DELAY_5;
+ si->debug.frame_delay_key[6] = DEFAULT_KEY_FRAME_DELAY_6;
+ si->debug.frame_delay_key[7] = DEFAULT_KEY_FRAME_DELAY_7;
+ si->debug.frame_delay_key[8] = DEFAULT_KEY_FRAME_DELAY_8;
+ si->debug.frame_delay_key[9] = DEFAULT_KEY_FRAME_DELAY_9;
+
+ si->debug.frame_delay_use_mod_key = DEFAULT_FRAME_DELAY_USE_MOD_KEY;
+ si->debug.frame_delay_game_only = DEFAULT_FRAME_DELAY_GAME_ONLY;
+
+ si->debug.show_frames_per_second = FALSE;
+
+ si->debug.xsn_mode = AUTO;
+ si->debug.xsn_percent = 0;
+
+ si->options.verbose = FALSE;
+ si->options.debug = FALSE;
+ si->options.debug_mode = getStringCopy(ARG_UNDEFINED_STRING);
+
+#if defined(PLATFORM_ANDROID)
+ si->fullscreen = TRUE;
+ si->touch.overlay_buttons = TRUE;
+#endif
+
+ setHideSetupEntry(&setup.debug.xsn_mode);
+}
+
+static void setSetupInfoToDefaults_AutoSetup(struct SetupInfo *si)
+{
+ si->auto_setup.editor_zoom_tilesize = MINI_TILESIZE;
+}
+
+static void setSetupInfoToDefaults_ServerSetup(struct SetupInfo *si)
+{
+ si->player_uuid = NULL; // (will be set later)
+ si->player_version = 1; // (will be set later)
+
+ si->use_api_server = TRUE;
+ si->api_server_hostname = getStringCopy(API_SERVER_HOSTNAME);
+ si->api_server_password = getStringCopy(UNDEFINED_PASSWORD);
+ si->ask_for_uploading_tapes = TRUE;
+ si->ask_for_remaining_tapes = FALSE;
+ si->provide_uploading_tapes = TRUE;
+ si->ask_for_using_api_server = TRUE;
+ si->has_remaining_tapes = FALSE;
+}
+
+static void setSetupInfoToDefaults_EditorCascade(struct SetupInfo *si)
+{
+ si->editor_cascade.el_bd = TRUE;
+ si->editor_cascade.el_bd_native = TRUE;
+ si->editor_cascade.el_em = TRUE;
+ si->editor_cascade.el_emc = TRUE;
+ si->editor_cascade.el_rnd = TRUE;
+ si->editor_cascade.el_sb = TRUE;
+ si->editor_cascade.el_sp = TRUE;
+ si->editor_cascade.el_dc = TRUE;
+ si->editor_cascade.el_dx = TRUE;
+
+ si->editor_cascade.el_mm = TRUE;
+ si->editor_cascade.el_df = TRUE;
+
+ si->editor_cascade.el_chars = FALSE;
+ si->editor_cascade.el_steel_chars = FALSE;
+ si->editor_cascade.el_ce = FALSE;
+ si->editor_cascade.el_ge = FALSE;
+ si->editor_cascade.el_es = FALSE;
+ si->editor_cascade.el_ref = FALSE;
+ si->editor_cascade.el_user = FALSE;
+ si->editor_cascade.el_dynamic = FALSE;
+}
+
+#define MAX_HIDE_SETUP_TOKEN_SIZE 20
+
+static char *getHideSetupToken(void *setup_value)
+{
+ static char hide_setup_token[MAX_HIDE_SETUP_TOKEN_SIZE];
+
+ if (setup_value != NULL)
+ snprintf(hide_setup_token, MAX_HIDE_SETUP_TOKEN_SIZE, "%p", setup_value);
+
+ return hide_setup_token;
+}
+
+void setHideSetupEntry(void *setup_value)