X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=d7837486d401d930248e8bfafe7836753027f1fe;hp=36939ac7d89ad264483dacae085317b3eadd64e7;hb=e51177796149f37de339bda83558c3c49758be93;hpb=b6847742a0713d8ed21bb6104476db54f8c1a4b9 diff --git a/src/files.c b/src/files.c index 36939ac7..d7837486 100644 --- a/src/files.c +++ b/src/files.c @@ -236,6 +236,12 @@ static struct LevelFileConfigInfo chunk_config_INFO[] = &li.score[SC_TIME_BONUS], 1 }, + { + -1, -1, + TYPE_BOOLEAN, CONF_VALUE_8_BIT(9), + &li.auto_exit_sokoban, FALSE + }, + { -1, -1, -1, -1, @@ -1314,6 +1320,22 @@ filetype_id_list[] = /* level file functions */ /* ========================================================================= */ +static boolean check_special_flags(char *flag) +{ +#if 0 + printf("::: '%s', '%s', '%s'\n", + flag, + options.special_flags, + leveldir_current->special_flags); +#endif + + if (strEqual(options.special_flags, flag) || + strEqual(leveldir_current->special_flags, flag)) + return TRUE; + + return FALSE; +} + static struct DateInfo getCurrentDate() { time_t epoch_seconds = time(NULL); @@ -1324,6 +1346,8 @@ static struct DateInfo getCurrentDate() date.month = now->tm_mon + 1; date.day = now->tm_mday; + date.src = DATE_SRC_CLOCK; + return date; } @@ -1752,9 +1776,44 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info) static void ActivateLevelTemplate() { + int x, y; + /* Currently there is no special action needed to activate the template data, because 'element_info' property settings overwrite the original level data, while all other variables do not change. */ + + /* Exception: 'from_level_template' elements in the original level playfield + are overwritten with the corresponding elements at the same position in + playfield from the level template. */ + + for (x = 0; x < level.fieldx; x++) + for (y = 0; y < level.fieldy; y++) + if (level.field[x][y] == EL_FROM_LEVEL_TEMPLATE) + level.field[x][y] = level_template.field[x][y]; + + if (check_special_flags("load_xsb_to_ces")) + { + struct LevelInfo level_backup = level; + + /* overwrite all individual level settings from template level settings */ + level = level_template; + + /* restore playfield size */ + level.fieldx = level_backup.fieldx; + level.fieldy = level_backup.fieldy; + + /* restore playfield content */ + for (x = 0; x < level.fieldx; x++) + for (y = 0; y < level.fieldy; y++) + level.field[x][y] = level_backup.field[x][y]; + + /* restore name and author from individual level */ + strcpy(level.name, level_backup.name); + strcpy(level.author, level_backup.author); + + /* restore flag "use_custom_template" */ + level.use_custom_template = level_backup.use_custom_template; + } } static char *getLevelFilenameFromBasename(char *basename) @@ -1820,18 +1879,23 @@ static boolean checkForPackageFromBasename(char *basename) return (getFileTypeFromBasename(basename) != LEVEL_FILE_TYPE_UNKNOWN); } -static char *getSingleLevelBasename(int nr) +static char *getSingleLevelBasenameExt(int nr, char *extension) { static char basename[MAX_FILENAME_LEN]; if (nr < 0) - sprintf(basename, "template.%s", LEVELFILE_EXTENSION); + sprintf(basename, "template.%s", extension); else - sprintf(basename, "%03d.%s", nr, LEVELFILE_EXTENSION); + sprintf(basename, "%03d.%s", nr, extension); return basename; } +static char *getSingleLevelBasename(int nr) +{ + return getSingleLevelBasenameExt(nr, LEVELFILE_EXTENSION); +} + static char *getPackedLevelBasename(int type) { static char basename[MAX_FILENAME_LEN]; @@ -1959,9 +2023,33 @@ static void determineLevelFileInfo_Filename(struct LevelFileInfo *lfi) /* special case: level number is negative => check for level template file */ if (nr < 0) { +#if 1 + /* global variable "leveldir_current" must be modified in the loop below */ + LevelDirTree *leveldir_current_last = leveldir_current; + + /* check for template level in path from current to topmost tree node */ + + while (leveldir_current != NULL) + { + setLevelFileInfo_FormatLevelFilename(lfi, LEVEL_FILE_TYPE_RND, + "template.%s", LEVELFILE_EXTENSION); + + if (fileExists(lfi->filename)) + break; + + leveldir_current = leveldir_current->node_parent; + } + + /* restore global variable "leveldir_current" modified in above loop */ + leveldir_current = leveldir_current_last; + +#else + setLevelFileInfo_FormatLevelFilename(lfi, LEVEL_FILE_TYPE_RND, "template.%s", LEVELFILE_EXTENSION); +#endif + /* no fallback if template file not existing */ return; } @@ -2139,6 +2227,8 @@ static int LoadLevel_DATE(FILE *file, int chunk_size, struct LevelInfo *level) level->creation_date.month = getFile8Bit(file); level->creation_date.day = getFile8Bit(file); + level->creation_date.src = DATE_SRC_LEVELFILE; + return chunk_size; } @@ -3042,8 +3132,12 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, { level->no_valid_file = TRUE; +#if 1 + Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); +#else if (level != &level_template) Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); +#endif return; } @@ -4184,29 +4278,12 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level) LevelInfoType *header = &level_sp->header; int i, x, y; - level_sp->width = level->fieldx; + level_sp->width = level->fieldx; level_sp->height = level->fieldy; for (x = 0; x < level->fieldx; x++) - { for (y = 0; y < level->fieldy; y++) - { - int element_old = level->field[x][y]; - int element_new; - - if (element_old >= EL_SP_START && - element_old <= EL_SP_END) - element_new = element_old - EL_SP_START; - else if (element_old == EL_EMPTY_SPACE) - element_new = 0x00; - else if (element_old == EL_INVISIBLE_WALL) - element_new = 0x28; - else - element_new = 0x20; /* map unknown elements to yellow "hardware" */ - - level_sp->playfield[x][y] = element_new; - } - } + level_sp->playfield[x][y] = map_element_RND_to_SP(level->field[x][y]); header->InitialGravity = (level->initial_player_gravity[0] ? 1 : 0); @@ -4216,7 +4293,67 @@ void CopyNativeLevel_RND_to_SP(struct LevelInfo *level) header->InfotronsNeeded = level->gems_needed; - /* !!! ADD SPECIAL PORT DATABASE STUFF !!! */ + header->SpecialPortCount = 0; + + for (x = 0; x < level->fieldx; x++) for (y = 0; y < level->fieldy; y++) + { + boolean gravity_port_found = FALSE; + boolean gravity_port_valid = FALSE; + int gravity_port_flag; + int gravity_port_base_element; + int element = level->field[x][y]; + + if (element >= EL_SP_GRAVITY_ON_PORT_RIGHT && + element <= EL_SP_GRAVITY_ON_PORT_UP) + { + gravity_port_found = TRUE; + gravity_port_valid = TRUE; + gravity_port_flag = 1; + gravity_port_base_element = EL_SP_GRAVITY_ON_PORT_RIGHT; + } + else if (element >= EL_SP_GRAVITY_OFF_PORT_RIGHT && + element <= EL_SP_GRAVITY_OFF_PORT_UP) + { + gravity_port_found = TRUE; + gravity_port_valid = TRUE; + gravity_port_flag = 0; + gravity_port_base_element = EL_SP_GRAVITY_OFF_PORT_RIGHT; + } + else if (element >= EL_SP_GRAVITY_PORT_RIGHT && + element <= EL_SP_GRAVITY_PORT_UP) + { + /* change R'n'D style gravity inverting special port to normal port + (there are no gravity inverting ports in native Supaplex engine) */ + + gravity_port_found = TRUE; + gravity_port_valid = FALSE; + gravity_port_base_element = EL_SP_GRAVITY_PORT_RIGHT; + } + + if (gravity_port_found) + { + if (gravity_port_valid && + header->SpecialPortCount < SP_MAX_SPECIAL_PORTS) + { + SpecialPortType *port = &header->SpecialPort[header->SpecialPortCount]; + + port->PortLocation = (y * level->fieldx + x) * 2; + port->Gravity = gravity_port_flag; + + element += EL_SP_GRAVITY_PORT_RIGHT - gravity_port_base_element; + + header->SpecialPortCount++; + } + else + { + /* change special gravity port to normal port */ + + element += EL_SP_PORT_RIGHT - gravity_port_base_element; + } + + level_sp->playfield[x][y] = element - EL_SP_START; + } + } } void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) @@ -4233,20 +4370,12 @@ void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) for (y = 0; y < level->fieldy; y++) { int element_old = level_sp->playfield[x][y]; - int element_new; + int element_new = getMappedElement(map_element_SP_to_RND(element_old)); - if (element_old <= 0x27) - element_new = getMappedElement(EL_SP_START + element_old); - else if (element_old == 0x28) - element_new = EL_INVISIBLE_WALL; - else - { + if (element_new == EL_UNKNOWN) Error(ERR_WARN, "invalid element %d at position %d, %d", element_old, x, y); - element_new = EL_UNKNOWN; - } - level->field[x][y] = element_new; } } @@ -4324,22 +4453,61 @@ void CopyNativeLevel_SP_to_RND(struct LevelInfo *level) level->yamyam_content[i].e[x][y] = EL_EMPTY; } +static void CopyNativeTape_RND_to_SP(struct LevelInfo *level) +{ + struct LevelInfo_SP *level_sp = level->native_sp_level; + struct DemoInfo_SP *demo = &level_sp->demo; + int i, j; + + /* always start with reliable default values */ + demo->is_available = FALSE; + demo->length = 0; + + if (TAPE_IS_EMPTY(tape)) + return; + + demo->level_nr = tape.level_nr; /* (currently not used) */ + + level_sp->header.DemoRandomSeed = tape.random_seed; + + demo->length = 0; + for (i = 0; i < tape.length; i++) + { + int demo_action = map_key_RND_to_SP(tape.pos[i].action[0]); + int demo_repeat = tape.pos[i].delay; + + for (j = 0; j < demo_repeat / 16; j++) + demo->data[demo->length++] = 0xf0 | demo_action; + + if (demo_repeat % 16) + demo->data[demo->length++] = ((demo_repeat % 16 - 1) << 4) | demo_action; + } + + demo->data[demo->length++] = 0xff; + + demo->is_available = TRUE; +} + static void setTapeInfoToDefaults(); static void CopyNativeTape_SP_to_RND(struct LevelInfo *level) { struct LevelInfo_SP *level_sp = level->native_sp_level; struct DemoInfo_SP *demo = &level_sp->demo; + char *filename = level->file_info.filename; int i; /* always start with reliable default values */ setTapeInfoToDefaults(); + if (!demo->is_available) + return; + tape.level_nr = demo->level_nr; /* (currently not used) */ tape.length = demo->length - 1; /* without "end of demo" byte */ tape.random_seed = level_sp->header.DemoRandomSeed; - // tape.date = + TapeSetDateFromEpochSeconds(getFileTimestampEpochSeconds(filename)); for (i = 0; i < demo->length - 1; i++) { @@ -6348,7 +6516,11 @@ int getMappedElement_SB(int element_ascii, boolean use_ces) { '.', EL_SOKOBAN_FIELD_EMPTY, EL_CUSTOM_5 }, /* goal square */ { '*', EL_SOKOBAN_FIELD_FULL, EL_CUSTOM_6 }, /* box on goal square */ { '+', EL_SOKOBAN_FIELD_PLAYER, EL_CUSTOM_7 }, /* player on goal square */ +#if 0 { '_', EL_INVISIBLE_STEELWALL, EL_CUSTOM_8 }, /* floor beyond border */ +#else + { '_', EL_INVISIBLE_STEELWALL, EL_FROM_LEVEL_TEMPLATE }, /* floor beyond border */ +#endif { 0, -1, -1 }, }; @@ -6376,10 +6548,10 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, boolean reading_playfield = FALSE; boolean got_valid_playfield_line = FALSE; boolean invalid_playfield_char = FALSE; - boolean load_xsb_to_ces = options.cmd_switches & CMD_SWITCH_LOAD_XSB_TO_CES; + boolean load_xsb_to_ces = check_special_flags("load_xsb_to_ces"); int file_level_nr = 0; int line_nr = 0; - int x, y; + int x = 0, y = 0; /* initialized to make compilers happy */ #if 0 printf("::: looking for level number %d [%d]\n", @@ -6621,12 +6793,44 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, level->field, level->fieldx, level->fieldy); } + /* set special level settings for Sokoban levels */ + + level->time = 0; + level->use_step_counter = TRUE; + if (load_xsb_to_ces) { - level->time = 0; - level->use_step_counter = TRUE; - +#if 1 + /* !!! special global settings can now be set in level template !!! */ +#else level->initial_player_stepsize[0] = STEPSIZE_SLOW; +#endif + + /* fill smaller playfields with padding "beyond border wall" elements */ + if (level->fieldx < SCR_FIELDX || + level->fieldy < SCR_FIELDY) + { + short field[level->fieldx][level->fieldy]; + int new_fieldx = MAX(level->fieldx, SCR_FIELDX); + int new_fieldy = MAX(level->fieldy, SCR_FIELDY); + int pos_fieldx = (new_fieldx - level->fieldx) / 2; + int pos_fieldy = (new_fieldy - level->fieldy) / 2; + + /* copy old playfield (which is smaller than the visible area) */ + for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) + field[x][y] = level->field[x][y]; + + /* fill new, larger playfield with "beyond border wall" elements */ + for (y = 0; y < new_fieldy; y++) for (x = 0; x < new_fieldx; x++) + level->field[x][y] = getMappedElement_SB('_', load_xsb_to_ces); + + /* copy the old playfield to the middle of the new playfield */ + for (y = 0; y < level->fieldy; y++) for (x = 0; x < level->fieldx; x++) + level->field[pos_fieldx + x][pos_fieldy + y] = field[x][y]; + + level->fieldx = new_fieldx; + level->fieldy = new_fieldy; + } level->use_custom_template = TRUE; } @@ -6673,6 +6877,20 @@ void CopyNativeLevel_Native_to_RND(struct LevelInfo *level) CopyNativeLevel_SP_to_RND(level); } +void SaveNativeLevel(struct LevelInfo *level) +{ + if (level->game_engine_type == GAME_ENGINE_TYPE_SP) + { + char *basename = getSingleLevelBasenameExt(level->file_info.nr, "sp"); + char *filename = getLevelFilenameFromBasename(basename); + + CopyNativeLevel_RND_to_SP(level); + CopyNativeTape_RND_to_SP(level); + + SaveNativeLevel_SP(filename); + } +} + /* ------------------------------------------------------------------------- */ /* functions for loading generic level */ @@ -8234,6 +8452,79 @@ static int LoadTape_BODY(FILE *file, int chunk_size, struct TapeInfo *tape) return chunk_size; } +void LoadTape_SokobanSolution(char *filename) +{ + FILE *file; + int move_delay = TILESIZE / level.initial_player_stepsize[0]; + + if (!(file = fopen(filename, MODE_READ))) + { + tape.no_valid_file = TRUE; + + return; + } + + while (!feof(file)) + { + unsigned char c = fgetc(file); + + if (feof(file)) + break; + + switch (c) + { + case 'u': + case 'U': + tape.pos[tape.length].action[0] = MV_UP; + tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0); + tape.length++; + break; + + case 'd': + case 'D': + tape.pos[tape.length].action[0] = MV_DOWN; + tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0); + tape.length++; + break; + + case 'l': + case 'L': + tape.pos[tape.length].action[0] = MV_LEFT; + tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0); + tape.length++; + break; + + case 'r': + case 'R': + tape.pos[tape.length].action[0] = MV_RIGHT; + tape.pos[tape.length].delay = move_delay + (c < 'a' ? 2 : 0); + tape.length++; + break; + + case '\n': + case '\r': + case '\t': + case ' ': + /* ignore white-space characters */ + break; + + default: + tape.no_valid_file = TRUE; + + Error(ERR_WARN, "unsupported Sokoban solution file '%s' ['%d']", filename, c); + + break; + } + } + + fclose(file); + + if (tape.no_valid_file) + return; + + tape.length_seconds = GetTapeLength(); +} + void LoadTapeFromFilename(char *filename) { char cookie[MAX_LINE_LEN]; @@ -8244,6 +8535,13 @@ void LoadTapeFromFilename(char *filename) /* always start with reliable default values */ setTapeInfoToDefaults(); + if (strSuffix(filename, ".sln")) + { + LoadTape_SokobanSolution(filename); + + return; + } + if (!(file = fopen(filename, MODE_READ))) { tape.no_valid_file = TRUE; @@ -8288,6 +8586,7 @@ void LoadTapeFromFilename(char *filename) Error(ERR_WARN, "unsupported version of tape file '%s'", filename); fclose(file); + return; } @@ -8701,14 +9000,15 @@ void SaveScore(int nr) #define SETUP_TOKEN_INPUT_ON_FOCUS 22 #define SETUP_TOKEN_PREFER_AGA_GRAPHICS 23 #define SETUP_TOKEN_GAME_FRAME_DELAY 24 -#define SETUP_TOKEN_GRAPHICS_SET 25 -#define SETUP_TOKEN_SOUNDS_SET 26 -#define SETUP_TOKEN_MUSIC_SET 27 -#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 28 -#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 29 -#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 30 +#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 25 +#define SETUP_TOKEN_GRAPHICS_SET 26 +#define SETUP_TOKEN_SOUNDS_SET 27 +#define SETUP_TOKEN_MUSIC_SET 28 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 29 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 30 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 31 -#define NUM_GLOBAL_SETUP_TOKENS 31 +#define NUM_GLOBAL_SETUP_TOKENS 32 /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 @@ -8759,8 +9059,16 @@ void SaveScore(int nr) #define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_3 5 #define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_4 6 #define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_ALL 7 +#define SETUP_TOKEN_SHORTCUT_TAPE_EJECT 8 +#define SETUP_TOKEN_SHORTCUT_TAPE_STOP 9 +#define SETUP_TOKEN_SHORTCUT_TAPE_PAUSE 10 +#define SETUP_TOKEN_SHORTCUT_TAPE_RECORD 11 +#define SETUP_TOKEN_SHORTCUT_TAPE_PLAY 12 +#define SETUP_TOKEN_SHORTCUT_SOUND_SIMPLE 13 +#define SETUP_TOKEN_SHORTCUT_SOUND_LOOPS 14 +#define SETUP_TOKEN_SHORTCUT_SOUND_MUSIC 15 -#define NUM_SHORTCUT_SETUP_TOKENS 8 +#define NUM_SHORTCUT_SETUP_TOKENS 16 /* player setup */ #define SETUP_TOKEN_PLAYER_USE_JOYSTICK 0 @@ -8805,34 +9113,35 @@ static struct OptionInfo soi; static struct TokenInfo global_setup_tokens[] = { - { TYPE_STRING, &si.player_name, "player_name" }, - { TYPE_SWITCH, &si.sound, "sound" }, - { TYPE_SWITCH, &si.sound_loops, "repeating_sound_loops" }, - { TYPE_SWITCH, &si.sound_music, "background_music" }, - { TYPE_SWITCH, &si.sound_simple, "simple_sound_effects" }, - { TYPE_SWITCH, &si.toons, "toons" }, - { TYPE_SWITCH, &si.scroll_delay, "scroll_delay" }, - { TYPE_INTEGER,&si.scroll_delay_value,"scroll_delay_value" }, - { TYPE_SWITCH, &si.soft_scrolling, "soft_scrolling" }, - { TYPE_SWITCH, &si.fade_screens, "fade_screens" }, - { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording" }, - { TYPE_SWITCH, &si.show_titlescreen, "show_titlescreen" }, - { TYPE_SWITCH, &si.quick_doors, "quick_doors" }, - { TYPE_SWITCH, &si.team_mode, "team_mode" }, - { TYPE_SWITCH, &si.handicap, "handicap" }, - { TYPE_SWITCH, &si.skip_levels, "skip_levels" }, - { TYPE_SWITCH, &si.time_limit, "time_limit" }, - { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, - { TYPE_STRING, &si.fullscreen_mode, "fullscreen_mode" }, - { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, - { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor" }, - { TYPE_SWITCH, &si.quick_switch, "quick_player_switch" }, - { TYPE_SWITCH, &si.input_on_focus, "input_on_focus" }, - { TYPE_SWITCH, &si.prefer_aga_graphics, "prefer_aga_graphics" }, - { TYPE_INTEGER,&si.game_frame_delay, "game_frame_delay" }, - { TYPE_STRING, &si.graphics_set, "graphics_set" }, - { TYPE_STRING, &si.sounds_set, "sounds_set" }, - { TYPE_STRING, &si.music_set, "music_set" }, + { TYPE_STRING, &si.player_name, "player_name" }, + { TYPE_SWITCH, &si.sound, "sound" }, + { TYPE_SWITCH, &si.sound_loops, "repeating_sound_loops" }, + { TYPE_SWITCH, &si.sound_music, "background_music" }, + { TYPE_SWITCH, &si.sound_simple, "simple_sound_effects" }, + { TYPE_SWITCH, &si.toons, "toons" }, + { TYPE_SWITCH, &si.scroll_delay, "scroll_delay" }, + { TYPE_INTEGER,&si.scroll_delay_value, "scroll_delay_value" }, + { TYPE_SWITCH, &si.soft_scrolling, "soft_scrolling" }, + { TYPE_SWITCH, &si.fade_screens, "fade_screens" }, + { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording"}, + { TYPE_SWITCH, &si.show_titlescreen, "show_titlescreen" }, + { TYPE_SWITCH, &si.quick_doors, "quick_doors" }, + { TYPE_SWITCH, &si.team_mode, "team_mode" }, + { TYPE_SWITCH, &si.handicap, "handicap" }, + { TYPE_SWITCH, &si.skip_levels, "skip_levels" }, + { TYPE_SWITCH, &si.time_limit, "time_limit" }, + { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, + { TYPE_STRING, &si.fullscreen_mode, "fullscreen_mode" }, + { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, + { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor" }, + { TYPE_SWITCH, &si.quick_switch, "quick_player_switch" }, + { TYPE_SWITCH, &si.input_on_focus, "input_on_focus" }, + { TYPE_SWITCH, &si.prefer_aga_graphics, "prefer_aga_graphics" }, + { TYPE_INTEGER,&si.game_frame_delay, "game_frame_delay" }, + { TYPE_SWITCH, &si.sp_show_border_elements, "sp_show_border_elements" }, + { TYPE_STRING, &si.graphics_set, "graphics_set" }, + { TYPE_STRING, &si.sounds_set, "sounds_set" }, + { TYPE_STRING, &si.music_set, "music_set" }, { TYPE_SWITCH3,&si.override_level_graphics, "override_level_graphics" }, { TYPE_SWITCH3,&si.override_level_sounds, "override_level_sounds" }, { TYPE_SWITCH3,&si.override_level_music, "override_level_music" }, @@ -8904,6 +9213,14 @@ static struct TokenInfo shortcut_setup_tokens[] = { TYPE_KEY_X11, &ssi.focus_player[2], "shortcut.focus_player_3" }, { TYPE_KEY_X11, &ssi.focus_player[3], "shortcut.focus_player_4" }, { TYPE_KEY_X11, &ssi.focus_player_all,"shortcut.focus_player_all" }, + { TYPE_KEY_X11, &ssi.tape_eject, "shortcut.tape_eject" }, + { TYPE_KEY_X11, &ssi.tape_stop, "shortcut.tape_stop" }, + { TYPE_KEY_X11, &ssi.tape_pause, "shortcut.tape_pause" }, + { TYPE_KEY_X11, &ssi.tape_record, "shortcut.tape_record" }, + { TYPE_KEY_X11, &ssi.tape_play, "shortcut.tape_play" }, + { TYPE_KEY_X11, &ssi.sound_simple, "shortcut.sound_simple" }, + { TYPE_KEY_X11, &ssi.sound_loops, "shortcut.sound_loops" }, + { TYPE_KEY_X11, &ssi.sound_music, "shortcut.sound_music" }, }; static struct TokenInfo player_setup_tokens[] = @@ -8983,6 +9300,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->input_on_focus = FALSE; si->prefer_aga_graphics = TRUE; si->game_frame_delay = GAME_FRAME_DELAY; + si->sp_show_border_elements = FALSE; si->graphics_set = getStringCopy(GFX_DEFAULT_SUBDIR); si->sounds_set = getStringCopy(SND_DEFAULT_SUBDIR); @@ -9019,6 +9337,16 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) 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_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; + for (i = 0; i < MAX_PLAYERS; i++) { si->input[i].use_joystick = FALSE; @@ -9046,6 +9374,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->options.verbose = FALSE; #if defined(CREATE_SPECIAL_EDITION_RND_JUE) + si->toons = FALSE; si->handicap = FALSE; si->fullscreen = TRUE; si->override_level_graphics = AUTO; @@ -9479,6 +9808,16 @@ static void InitMenuDesignSettings_SpecialPreProcessing() menu.enter_screen[i] = menu.enter_screen[GFX_SPECIAL_ARG_DEFAULT]; menu.leave_screen[i] = menu.leave_screen[GFX_SPECIAL_ARG_DEFAULT]; } + + /* special case: initialize "ARG_DEFAULT" values in static default config */ + /* (eg, init "viewport.door_1.MAIN.xyz" from "viewport.door_1.xyz") */ + for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) + { + viewport.playfield[i] = viewport.playfield[GFX_SPECIAL_ARG_DEFAULT]; + viewport.door_1[i] = viewport.door_1[GFX_SPECIAL_ARG_DEFAULT]; + if (i != GFX_SPECIAL_ARG_EDITOR) /* editor value already initialized */ + viewport.door_2[i] = viewport.door_2[GFX_SPECIAL_ARG_DEFAULT]; + } } static void InitMenuDesignSettings_SpecialPostProcessing() @@ -9616,6 +9955,50 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) value_6); } + /* special case: initialize with default values that may be overwritten */ + /* (eg, init "viewport.door_1.MAIN.xyz" from "viewport.door_1.xyz") */ + for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) + { + char *token_1 = "viewport.playfield.x"; + char *token_2 = "viewport.playfield.y"; + char *token_3 = "viewport.playfield.width"; + char *token_4 = "viewport.playfield.height"; + char *token_5 = "viewport.playfield.border_size"; + char *token_6 = "viewport.door_1.x"; + char *token_7 = "viewport.door_1.y"; + char *token_8 = "viewport.door_2.x"; + char *token_9 = "viewport.door_2.y"; + char *value_1 = getHashEntry(setup_file_hash, token_1); + char *value_2 = getHashEntry(setup_file_hash, token_2); + char *value_3 = getHashEntry(setup_file_hash, token_3); + char *value_4 = getHashEntry(setup_file_hash, token_4); + char *value_5 = getHashEntry(setup_file_hash, token_5); + char *value_6 = getHashEntry(setup_file_hash, token_6); + char *value_7 = getHashEntry(setup_file_hash, token_7); + char *value_8 = getHashEntry(setup_file_hash, token_8); + char *value_9 = getHashEntry(setup_file_hash, token_9); + + if (value_1 != NULL) + viewport.playfield[i].x = get_token_parameter_value(token_1, value_1); + if (value_2 != NULL) + viewport.playfield[i].y = get_token_parameter_value(token_2, value_2); + if (value_3 != NULL) + viewport.playfield[i].width = get_token_parameter_value(token_3, value_3); + if (value_4 != NULL) + viewport.playfield[i].height = get_token_parameter_value(token_4,value_4); + if (value_5 != NULL) + viewport.playfield[i].border_size = get_token_parameter_value(token_5, + value_5); + if (value_6 != NULL) + viewport.door_1[i].x = get_token_parameter_value(token_6, value_6); + if (value_7 != NULL) + viewport.door_1[i].y = get_token_parameter_value(token_7, value_7); + if (value_8 != NULL) + viewport.door_2[i].x = get_token_parameter_value(token_8, value_8); + if (value_9 != NULL) + viewport.door_2[i].y = get_token_parameter_value(token_9, value_9); + } + /* special case: initialize with default values that may be overwritten */ /* (e.g., init "titlemessage_1.fade_mode" from "[titlemessage].fade_mode") */ for (i = 0; titlemessage_arrays[i].array != NULL; i++) @@ -9952,6 +10335,10 @@ void LoadMusicInfo() if (!music_info_listed(music_file_info, music->filename)) { *new = get_music_file_info(music->filename, i); +#if 0 + if (*new != NULL) + printf(":1: adding '%s' ['%s'] ...\n", (*new)->title, music->filename); +#endif if (*new != NULL) new = &(*new)->next; } @@ -9997,6 +10384,10 @@ void LoadMusicInfo() if (!music_info_listed(music_file_info, basename)) { *new = get_music_file_info(basename, MAP_NOCONF_MUSIC(num_music_noconf)); +#if 0 + if (*new != NULL) + printf(":2: adding '%s' ['%s'] ...\n", (*new)->title, basename); +#endif if (*new != NULL) new = &(*new)->next; }