+ for (i = 0; i < scores->num_entries; i++)
+ putFile16BitBE(file, scores->entry[i].score);
+}
+
+static void SaveScore_SC4R(FILE *file, struct ScoreInfo *scores)
+{
+ int i;
+
+ for (i = 0; i < scores->num_entries; i++)
+ putFile32BitBE(file, scores->entry[i].score);
+}
+
+static void SaveScore_TIME(FILE *file, struct ScoreInfo *scores)
+{
+ int i;
+
+ for (i = 0; i < scores->num_entries; i++)
+ putFile32BitBE(file, scores->entry[i].time);
+}
+
+static void SaveScore_TAPE(FILE *file, struct ScoreInfo *scores)
+{
+ int i, j;
+
+ for (i = 0; i < scores->num_entries; i++)
+ {
+ int size = strlen(scores->entry[i].tape_basename);
+
+ for (j = 0; j < MAX_SCORE_TAPE_BASENAME_LEN; j++)
+ putFile8Bit(file, (j < size ? scores->entry[i].tape_basename[j] : 0));
+ }
+}
+
+static void SaveScoreToFilename(char *filename)
+{
+ FILE *file;
+ int info_chunk_size;
+ int name_chunk_size;
+ int scor_chunk_size;
+ int sc4r_chunk_size;
+ int time_chunk_size;
+ int tape_chunk_size;
+ boolean has_large_score_values;
+ int i;
+
+ if (!(file = fopen(filename, MODE_WRITE)))
+ {
+ Warn("cannot save score file '%s'", filename);
+
+ return;
+ }
+
+ info_chunk_size = 2 + (strlen(scores.level_identifier) + 1) + 2 + 2;
+ name_chunk_size = scores.num_entries * MAX_PLAYER_NAME_LEN;
+ scor_chunk_size = scores.num_entries * 2;
+ sc4r_chunk_size = scores.num_entries * 4;
+ time_chunk_size = scores.num_entries * 4;
+ tape_chunk_size = scores.num_entries * MAX_SCORE_TAPE_BASENAME_LEN;
+
+ has_large_score_values = FALSE;
+ for (i = 0; i < scores.num_entries; i++)
+ if (scores.entry[i].score > 0xffff)
+ has_large_score_values = TRUE;
+
+ putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED);
+ putFileChunkBE(file, "SCOR", CHUNK_SIZE_NONE);
+
+ putFileChunkBE(file, "VERS", SCORE_CHUNK_VERS_SIZE);
+ SaveScore_VERS(file, &scores);
+
+ putFileChunkBE(file, "INFO", info_chunk_size);
+ SaveScore_INFO(file, &scores);
+
+ putFileChunkBE(file, "NAME", name_chunk_size);
+ SaveScore_NAME(file, &scores);
+
+ if (has_large_score_values)
+ {
+ putFileChunkBE(file, "SC4R", sc4r_chunk_size);
+ SaveScore_SC4R(file, &scores);
+ }
+ else
+ {
+ putFileChunkBE(file, "SCOR", scor_chunk_size);
+ SaveScore_SCOR(file, &scores);
+ }
+
+ putFileChunkBE(file, "TIME", time_chunk_size);
+ SaveScore_TIME(file, &scores);
+
+ putFileChunkBE(file, "TAPE", tape_chunk_size);
+ SaveScore_TAPE(file, &scores);
+
+ fclose(file);
+
+ SetFilePermissions(filename, PERMS_PRIVATE);
+}
+
+void SaveScore(int nr)
+{
+ char *filename = getScoreFilename(nr);
+ int i;
+
+ // used instead of "leveldir_current->subdir" (for network games)
+ InitScoreDirectory(levelset.identifier);
+
+ scores.file_version = FILE_VERSION_ACTUAL;
+ scores.game_version = GAME_VERSION_ACTUAL;
+
+ strncpy(scores.level_identifier, levelset.identifier, MAX_FILENAME_LEN);
+ scores.level_identifier[MAX_FILENAME_LEN] = '\0';
+ scores.level_nr = level_nr;
+
+ for (i = 0; i < MAX_SCORE_ENTRIES; i++)
+ if (scores.entry[i].score == 0 &&
+ scores.entry[i].time == 0 &&
+ strEqual(scores.entry[i].name, EMPTY_PLAYER_NAME))
+ break;
+
+ scores.num_entries = i;
+
+ if (scores.num_entries == 0)
+ return;
+
+ SaveScoreToFilename(filename);
+}
+
+static void LoadServerScoreFromCache(int nr)
+{
+ struct ScoreEntry score_entry;
+ struct
+ {
+ void *value;
+ boolean is_string;
+ int string_size;
+ }
+ score_mapping[] =
+ {
+ { &score_entry.score, FALSE, 0 },
+ { &score_entry.time, FALSE, 0 },
+ { score_entry.name, TRUE, MAX_PLAYER_NAME_LEN },
+ { score_entry.tape_basename, TRUE, MAX_FILENAME_LEN },
+ { score_entry.tape_date, TRUE, MAX_ISO_DATE_LEN },
+ { &score_entry.id, FALSE, 0 },
+ { score_entry.platform, TRUE, MAX_PLATFORM_TEXT_LEN },
+ { score_entry.version, TRUE, MAX_VERSION_TEXT_LEN },
+ { score_entry.country_code, TRUE, MAX_COUNTRY_CODE_LEN },
+ { score_entry.country_name, TRUE, MAX_COUNTRY_NAME_LEN },
+
+ { NULL, FALSE, 0 }
+ };
+ char *filename = getScoreCacheFilename(nr);
+ SetupFileHash *score_hash = loadSetupFileHash(filename);
+ int i, j;
+
+ server_scores.num_entries = 0;
+
+ if (score_hash == NULL)
+ return;
+
+ for (i = 0; i < MAX_SCORE_ENTRIES; i++)
+ {
+ score_entry = server_scores.entry[i];
+
+ for (j = 0; score_mapping[j].value != NULL; j++)
+ {
+ char token[10];
+
+ sprintf(token, "%02d.%d", i, j);
+
+ char *value = getHashEntry(score_hash, token);
+
+ if (value == NULL)
+ continue;
+
+ if (score_mapping[j].is_string)
+ {
+ char *score_value = (char *)score_mapping[j].value;
+ int value_size = score_mapping[j].string_size;
+
+ strncpy(score_value, value, value_size);
+ score_value[value_size] = '\0';
+ }
+ else
+ {
+ int *score_value = (int *)score_mapping[j].value;
+
+ *score_value = atoi(value);
+ }
+
+ server_scores.num_entries = i + 1;
+ }
+
+ server_scores.entry[i] = score_entry;
+ }
+
+ freeSetupFileHash(score_hash);
+}
+
+void LoadServerScore(int nr, boolean download_score)
+{
+ if (!setup.use_api_server)
+ return;
+
+ // always start with reliable default values
+ setServerScoreInfoToDefaults();
+
+ // 1st step: load server scores from cache file (which may not exist)
+ // (this should prevent reading it while the thread is writing to it)
+ LoadServerScoreFromCache(nr);
+
+ if (download_score && runtime.use_api_server)
+ {
+ // 2nd step: download server scores from score server to cache file
+ // (as thread, as it might time out if the server is not reachable)
+ ApiGetScoreAsThread(nr);
+ }
+}
+
+void PrepareScoreTapesForUpload(char *leveldir_subdir)
+{
+ MarkTapeDirectoryUploadsAsIncomplete(leveldir_subdir);
+
+ // if score tape not uploaded, ask for uploading missing tapes later
+ if (!setup.has_remaining_tapes)
+ setup.ask_for_remaining_tapes = TRUE;
+
+ setup.provide_uploading_tapes = TRUE;
+ setup.has_remaining_tapes = TRUE;
+
+ SaveSetup_ServerSetup();
+}
+
+void SaveServerScore(int nr, boolean tape_saved)
+{
+ if (!runtime.use_api_server)
+ {
+ PrepareScoreTapesForUpload(leveldir_current->subdir);
+
+ return;
+ }
+
+ ApiAddScoreAsThread(nr, tape_saved, NULL);
+}
+
+void SaveServerScoreFromFile(int nr, boolean tape_saved,
+ char *score_tape_filename)
+{
+ if (!runtime.use_api_server)
+ return;
+
+ ApiAddScoreAsThread(nr, tape_saved, score_tape_filename);
+}
+
+void LoadLocalAndServerScore(int nr, boolean download_score)
+{
+ int last_added_local = scores.last_added_local;
+ boolean force_last_added = scores.force_last_added;
+
+ // needed if only showing server scores
+ setScoreInfoToDefaults();
+
+ if (!strEqual(setup.scores_in_highscore_list, STR_SCORES_TYPE_SERVER_ONLY))
+ LoadScore(nr);
+
+ // restore last added local score entry (before merging server scores)
+ scores.last_added = scores.last_added_local = last_added_local;
+
+ if (setup.use_api_server &&
+ !strEqual(setup.scores_in_highscore_list, STR_SCORES_TYPE_LOCAL_ONLY))
+ {
+ // load server scores from cache file and trigger update from server
+ LoadServerScore(nr, download_score);
+
+ // merge local scores with scores from server
+ MergeServerScore();
+ }
+
+ if (force_last_added)
+ scores.force_last_added = force_last_added;
+}
+
+
+// ============================================================================
+// setup file functions
+// ============================================================================
+
+#define TOKEN_STR_PLAYER_PREFIX "player_"
+
+
+static struct TokenInfo global_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.player_name, "player_name"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.multiple_users, "multiple_users"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound, "sound"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound_loops, "repeating_sound_loops"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound_music, "background_music"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sound_simple, "simple_sound_effects"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.toons, "toons"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.global_animations, "global_animations"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.scroll_delay, "scroll_delay"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.forced_scroll_delay, "forced_scroll_delay"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.scroll_delay_value, "scroll_delay_value"
+ },
+ {
+ TYPE_STRING,
+ &setup.engine_snapshot_mode, "engine_snapshot_mode"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.engine_snapshot_memory, "engine_snapshot_memory"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.fade_screens, "fade_screens"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.autorecord, "automatic_tape_recording"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.autorecord_after_replay, "autorecord_after_replay"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.auto_pause_on_start, "auto_pause_on_start"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.show_titlescreen, "show_titlescreen"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.quick_doors, "quick_doors"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.team_mode, "team_mode"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.handicap, "handicap"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.skip_levels, "skip_levels"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.increment_levels, "increment_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_SWITCH,
+ &setup.time_limit, "time_limit"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.fullscreen, "fullscreen"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.window_scaling_percent, "window_scaling_percent"
+ },
+ {
+ TYPE_STRING,
+ &setup.window_scaling_quality, "window_scaling_quality"
+ },
+ {
+ TYPE_STRING,
+ &setup.screen_rendering_mode, "screen_rendering_mode"
+ },
+ {
+ TYPE_STRING,
+ &setup.vsync_mode, "vsync_mode"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_escape, "ask_on_escape"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_escape_editor, "ask_on_escape_editor"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_game_over, "ask_on_game_over"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_quit_game, "ask_on_quit_game"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_on_quit_program, "ask_on_quit_program"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.quick_switch, "quick_player_switch"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.input_on_focus, "input_on_focus"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.prefer_aga_graphics, "prefer_aga_graphics"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.prefer_lowpass_sounds, "prefer_lowpass_sounds"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.prefer_extra_panel_items, "prefer_extra_panel_items"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.game_speed_extended, "game_speed_extended"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.game_frame_delay, "game_frame_delay"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.bd_skip_uncovering, "bd_skip_uncovering"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.bd_skip_hatching, "bd_skip_hatching"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.bd_scroll_delay, "bd_scroll_delay"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.bd_smooth_movements, "bd_smooth_movements"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.sp_show_border_elements, "sp_show_border_elements"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.small_game_graphics, "small_game_graphics"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.show_load_save_buttons, "show_load_save_buttons"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.show_undo_redo_buttons, "show_undo_redo_buttons"
+ },
+ {
+ TYPE_STRING,
+ &setup.scores_in_highscore_list, "scores_in_highscore_list"
+ },
+ {
+ TYPE_STRING,
+ &setup.graphics_set, "graphics_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.sounds_set, "sounds_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.music_set, "music_set"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.override_level_graphics, "override_level_graphics"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.override_level_sounds, "override_level_sounds"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.override_level_music, "override_level_music"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.volume_simple, "volume_simple"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.volume_loops, "volume_loops"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.volume_music, "volume_music"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.network_mode, "network_mode"
+ },
+ {
+ TYPE_PLAYER,
+ &setup.network_player_nr, "network_player"
+ },
+ {
+ TYPE_STRING,
+ &setup.network_server_hostname, "network_server_hostname"
+ },
+ {
+ TYPE_STRING,
+ &setup.touch.control_type, "touch.control_type"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.move_distance, "touch.move_distance"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.drop_distance, "touch.drop_distance"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.transparency, "touch.transparency"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.draw_outlined, "touch.draw_outlined"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.draw_pressed, "touch.draw_pressed"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_xsize[0], "touch.virtual_buttons.0.xsize"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.touch.grid_ysize[1], "touch.virtual_buttons.1.ysize"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.touch.overlay_buttons, "touch.overlay_buttons"
+ },
+};
+
+static struct TokenInfo auto_setup_tokens[] =
+{
+ {
+ TYPE_INTEGER,
+ &setup.auto_setup.editor_zoom_tilesize, "editor.zoom_tilesize"
+ },
+};
+
+static struct TokenInfo server_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.player_uuid, "player_uuid"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.player_version, "player_version"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.use_api_server, TEST_PREFIX "use_api_server"
+ },
+ {
+ TYPE_STRING,
+ &setup.api_server_hostname, TEST_PREFIX "api_server_hostname"
+ },
+ {
+ TYPE_STRING,
+ &setup.api_server_password, TEST_PREFIX "api_server_password"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_for_uploading_tapes, TEST_PREFIX "ask_for_uploading_tapes"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_for_remaining_tapes, TEST_PREFIX "ask_for_remaining_tapes"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.provide_uploading_tapes, TEST_PREFIX "provide_uploading_tapes"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.ask_for_using_api_server,TEST_PREFIX "ask_for_using_api_server"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.has_remaining_tapes, TEST_PREFIX "has_remaining_tapes"
+ },
+};
+
+static struct TokenInfo editor_setup_tokens[] =
+{
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_classic, "editor.el_classic"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_custom, "editor.el_custom"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_user_defined, "editor.el_user_defined"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_dynamic, "editor.el_dynamic"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.el_headlines, "editor.el_headlines"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.show_element_token, "editor.show_element_token"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor.show_read_only_warning, "editor.show_read_only_warning"
+ },
+};
+
+static struct TokenInfo editor_cascade_setup_tokens[] =
+{
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_bd, "editor.cascade.el_bd"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_bd_native, "editor.cascade.el_bd_native"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_em, "editor.cascade.el_em"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_emc, "editor.cascade.el_emc"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_rnd, "editor.cascade.el_rnd"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_sb, "editor.cascade.el_sb"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_sp, "editor.cascade.el_sp"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_dc, "editor.cascade.el_dc"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_dx, "editor.cascade.el_dx"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_mm, "editor.cascade.el_mm"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_df, "editor.cascade.el_df"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_chars, "editor.cascade.el_chars"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_steel_chars, "editor.cascade.el_steel_chars"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_ce, "editor.cascade.el_ce"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_ge, "editor.cascade.el_ge"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_es, "editor.cascade.el_es"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_ref, "editor.cascade.el_ref"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_user, "editor.cascade.el_user"
+ },
+ {
+ TYPE_SWITCH,
+ &setup.editor_cascade.el_dynamic, "editor.cascade.el_dynamic"
+ },
+};
+
+static struct TokenInfo shortcut_setup_tokens[] =
+{
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.save_game, "shortcut.save_game"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.load_game, "shortcut.load_game"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.restart_game, "shortcut.restart_game"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.pause_before_end, "shortcut.pause_before_end"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.toggle_pause, "shortcut.toggle_pause"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[0], "shortcut.focus_player_1"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[1], "shortcut.focus_player_2"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[2], "shortcut.focus_player_3"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player[3], "shortcut.focus_player_4"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.focus_player_all, "shortcut.focus_player_all"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_eject, "shortcut.tape_eject"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_extra, "shortcut.tape_extra"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_stop, "shortcut.tape_stop"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_pause, "shortcut.tape_pause"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_record, "shortcut.tape_record"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.tape_play, "shortcut.tape_play"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.sound_simple, "shortcut.sound_simple"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.sound_loops, "shortcut.sound_loops"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.sound_music, "shortcut.sound_music"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_left, "shortcut.snap_left"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_right, "shortcut.snap_right"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_up, "shortcut.snap_up"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.shortcut.snap_down, "shortcut.snap_down"
+ },
+};
+
+static struct SetupInputInfo setup_input;
+static struct TokenInfo player_setup_tokens[] =
+{
+ {
+ TYPE_BOOLEAN,
+ &setup_input.use_joystick, ".use_joystick"
+ },
+ {
+ TYPE_STRING,
+ &setup_input.joy.device_name, ".joy.device_name"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.xleft, ".joy.xleft"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.xmiddle, ".joy.xmiddle"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.xright, ".joy.xright"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.yupper, ".joy.yupper"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.ymiddle, ".joy.ymiddle"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.ylower, ".joy.ylower"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.snap, ".joy.snap_field"
+ },
+ {
+ TYPE_INTEGER,
+ &setup_input.joy.drop, ".joy.place_bomb"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.left, ".key.move_left"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.right, ".key.move_right"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.up, ".key.move_up"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.down, ".key.move_down"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.snap, ".key.snap_field"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup_input.key.drop, ".key.place_bomb"
+ },
+};
+
+static struct TokenInfo system_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.system.sdl_renderdriver, "system.sdl_renderdriver"
+ },
+ {
+ TYPE_STRING,
+ &setup.system.sdl_videodriver, "system.sdl_videodriver"
+ },
+ {
+ TYPE_STRING,
+ &setup.system.sdl_audiodriver, "system.sdl_audiodriver"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.system.audio_fragment_size, "system.audio_fragment_size"
+ },
+};
+
+static struct TokenInfo internal_setup_tokens[] =
+{
+ {
+ TYPE_STRING,
+ &setup.internal.program_title, "program_title"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_version, "program_version"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_author, "program_author"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_email, "program_email"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_website, "program_website"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_copyright, "program_copyright"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_company, "program_company"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.program_icon_file, "program_icon_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_graphics_set, "default_graphics_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_sounds_set, "default_sounds_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_music_set, "default_music_set"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.fallback_graphics_file, "fallback_graphics_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.fallback_sounds_file, "fallback_sounds_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.fallback_music_file, "fallback_music_file"
+ },
+ {
+ TYPE_STRING,
+ &setup.internal.default_level_series, "default_level_series"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.internal.default_window_width, "default_window_width"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.internal.default_window_height, "default_window_height"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.choose_from_top_leveldir, "choose_from_top_leveldir"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.show_scaling_in_title, "show_scaling_in_title"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.create_user_levelset, "create_user_levelset"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_screens_from_main, "info_screens_from_main"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_game, "menu_game"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_engines, "menu_engines"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_editor, "menu_editor"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_graphics, "menu_graphics"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_sound, "menu_sound"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_artwork, "menu_artwork"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_input, "menu_input"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_touch, "menu_touch"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_shortcuts, "menu_shortcuts"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_exit, "menu_exit"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_save_and_exit, "menu_save_and_exit"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_shortcuts_various, "menu_shortcuts_various"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_shortcuts_focus, "menu_shortcuts_focus"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_shortcuts_tape, "menu_shortcuts_tape"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_shortcuts_sound, "menu_shortcuts_sound"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.menu_shortcuts_snap, "menu_shortcuts_snap"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_title, "info_title"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_elements, "info_elements"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_music, "info_music"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_credits, "info_credits"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_program, "info_program"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_version, "info_version"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_levelset, "info_levelset"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.internal.info_exit, "info_exit"
+ },
+};
+
+static struct TokenInfo debug_setup_tokens[] =
+{
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[0], "debug.frame_delay_0"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[1], "debug.frame_delay_1"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[2], "debug.frame_delay_2"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[3], "debug.frame_delay_3"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[4], "debug.frame_delay_4"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[5], "debug.frame_delay_5"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[6], "debug.frame_delay_6"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[7], "debug.frame_delay_7"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[8], "debug.frame_delay_8"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.frame_delay[9], "debug.frame_delay_9"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[0], "debug.key.frame_delay_0"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[1], "debug.key.frame_delay_1"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[2], "debug.key.frame_delay_2"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[3], "debug.key.frame_delay_3"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[4], "debug.key.frame_delay_4"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[5], "debug.key.frame_delay_5"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[6], "debug.key.frame_delay_6"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[7], "debug.key.frame_delay_7"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[8], "debug.key.frame_delay_8"
+ },
+ {
+ TYPE_KEY_X11,
+ &setup.debug.frame_delay_key[9], "debug.key.frame_delay_9"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.debug.frame_delay_use_mod_key, "debug.frame_delay.use_mod_key"},
+ {
+ TYPE_BOOLEAN,
+ &setup.debug.frame_delay_game_only, "debug.frame_delay.game_only"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.debug.show_frames_per_second, "debug.show_frames_per_second"
+ },
+ {
+ TYPE_SWITCH3,
+ &setup.debug.xsn_mode, "debug.xsn_mode"
+ },
+ {
+ TYPE_INTEGER,
+ &setup.debug.xsn_percent, "debug.xsn_percent"
+ },
+};
+
+static struct TokenInfo options_setup_tokens[] =
+{
+ {
+ TYPE_BOOLEAN,
+ &setup.options.verbose, "options.verbose"
+ },
+ {
+ TYPE_BOOLEAN,
+ &setup.options.debug, "options.debug"
+ },
+ {
+ TYPE_STRING,
+ &setup.options.debug_mode, "options.debug_mode"
+ },
+};
+
+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->bd_scroll_delay = TRUE;
+ si->bd_smooth_movements = AUTO;
+ 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());