X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=c0f256c73c27016f42c2af688f47f97cc0769111;hp=edc1358edc4386ce944e6f6f3ecd84fbbf4cb9c1;hb=8d71e6fb8309bd90ce5f2900d84c686b17950492;hpb=61a2ef633881ce5e865c8747f6393700c870f675 diff --git a/src/files.c b/src/files.c index edc1358e..c0f256c7 100644 --- a/src/files.c +++ b/src/files.c @@ -1786,10 +1786,41 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info) level_file_info->filename = NULL; } +int getMappedElement_SB(int, boolean); + static void ActivateLevelTemplate() { int x, y; + if (check_special_flags("load_xsb_to_ces")) + { + /* fill smaller playfields with padding "beyond border wall" elements */ + if (level.fieldx < level_template.fieldx || + level.fieldy < level_template.fieldy) + { + short field[level.fieldx][level.fieldy]; + int new_fieldx = MAX(level.fieldx, level_template.fieldx); + int new_fieldy = MAX(level.fieldy, level_template.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('_', TRUE); + + /* 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; + } + } + /* 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. */ @@ -5756,32 +5787,6 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, { /* special global settings can now be set in level template */ - /* 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; } } @@ -7900,41 +7905,42 @@ void SaveScore(int nr) #define SETUP_TOKEN_SCROLL_DELAY 6 #define SETUP_TOKEN_SCROLL_DELAY_VALUE 7 #define SETUP_TOKEN_ENGINE_SNAPSHOT_MODE 8 -#define SETUP_TOKEN_FADE_SCREENS 9 -#define SETUP_TOKEN_AUTORECORD 10 -#define SETUP_TOKEN_SHOW_TITLESCREEN 11 -#define SETUP_TOKEN_QUICK_DOORS 12 -#define SETUP_TOKEN_TEAM_MODE 13 -#define SETUP_TOKEN_HANDICAP 14 -#define SETUP_TOKEN_SKIP_LEVELS 15 -#define SETUP_TOKEN_TIME_LIMIT 16 -#define SETUP_TOKEN_FULLSCREEN 17 -#define SETUP_TOKEN_WINDOW_SCALING_PERCENT 18 -#define SETUP_TOKEN_WINDOW_SCALING_QUALITY 19 -#define SETUP_TOKEN_SCREEN_RENDERING_MODE 20 -#define SETUP_TOKEN_ASK_ON_ESCAPE 21 -#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 22 -#define SETUP_TOKEN_QUICK_SWITCH 23 -#define SETUP_TOKEN_INPUT_ON_FOCUS 24 -#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 25 -#define SETUP_TOKEN_GAME_FRAME_DELAY 26 -#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 27 -#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 28 -#define SETUP_TOKEN_SHOW_SNAPSHOT_BUTTONS 29 -#define SETUP_TOKEN_GRAPHICS_SET 30 -#define SETUP_TOKEN_SOUNDS_SET 31 -#define SETUP_TOKEN_MUSIC_SET 32 -#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 33 -#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 34 -#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 35 -#define SETUP_TOKEN_VOLUME_SIMPLE 36 -#define SETUP_TOKEN_VOLUME_LOOPS 37 -#define SETUP_TOKEN_VOLUME_MUSIC 38 -#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 39 -#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 40 -#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 41 - -#define NUM_GLOBAL_SETUP_TOKENS 42 +#define SETUP_TOKEN_ENGINE_SNAPSHOT_MEMORY 9 +#define SETUP_TOKEN_FADE_SCREENS 10 +#define SETUP_TOKEN_AUTORECORD 11 +#define SETUP_TOKEN_SHOW_TITLESCREEN 12 +#define SETUP_TOKEN_QUICK_DOORS 13 +#define SETUP_TOKEN_TEAM_MODE 14 +#define SETUP_TOKEN_HANDICAP 15 +#define SETUP_TOKEN_SKIP_LEVELS 16 +#define SETUP_TOKEN_TIME_LIMIT 17 +#define SETUP_TOKEN_FULLSCREEN 18 +#define SETUP_TOKEN_WINDOW_SCALING_PERCENT 19 +#define SETUP_TOKEN_WINDOW_SCALING_QUALITY 20 +#define SETUP_TOKEN_SCREEN_RENDERING_MODE 21 +#define SETUP_TOKEN_ASK_ON_ESCAPE 22 +#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 23 +#define SETUP_TOKEN_QUICK_SWITCH 24 +#define SETUP_TOKEN_INPUT_ON_FOCUS 25 +#define SETUP_TOKEN_PREFER_AGA_GRAPHICS 26 +#define SETUP_TOKEN_GAME_FRAME_DELAY 27 +#define SETUP_TOKEN_SP_SHOW_BORDER_ELEMENTS 28 +#define SETUP_TOKEN_SMALL_GAME_GRAPHICS 29 +#define SETUP_TOKEN_SHOW_SNAPSHOT_BUTTONS 30 +#define SETUP_TOKEN_GRAPHICS_SET 31 +#define SETUP_TOKEN_SOUNDS_SET 32 +#define SETUP_TOKEN_MUSIC_SET 33 +#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 34 +#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 35 +#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 36 +#define SETUP_TOKEN_VOLUME_SIMPLE 37 +#define SETUP_TOKEN_VOLUME_LOOPS 38 +#define SETUP_TOKEN_VOLUME_MUSIC 39 +#define SETUP_TOKEN_TOUCH_CONTROL_TYPE 40 +#define SETUP_TOKEN_TOUCH_MOVE_DISTANCE 41 +#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 42 + +#define NUM_GLOBAL_SETUP_TOKENS 43 /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 @@ -8049,6 +8055,32 @@ void SaveScore(int nr) #define NUM_INTERNAL_SETUP_TOKENS 17 +/* debug setup */ +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_0 0 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_1 1 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_2 2 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_3 3 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_4 4 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_5 5 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_6 6 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_7 7 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_8 8 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_9 9 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_0 10 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_1 11 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_2 12 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_3 13 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_4 14 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_5 15 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_6 16 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_7 17 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_8 18 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_KEY_9 19 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_USE_MOD_KEY 20 +#define SETUP_TOKEN_DEBUG_FRAME_DELAY_GAME_ONLY 21 + +#define NUM_DEBUG_SETUP_TOKENS 22 + /* options setup */ #define SETUP_TOKEN_OPTIONS_VERBOSE 0 @@ -8062,6 +8094,7 @@ static struct SetupShortcutInfo ssi; static struct SetupInputInfo sii; static struct SetupSystemInfo syi; static struct SetupInternalInfo sxi; +static struct SetupDebugInfo sdi; static struct OptionInfo soi; static struct TokenInfo global_setup_tokens[] = @@ -8075,6 +8108,7 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.scroll_delay, "scroll_delay" }, { TYPE_INTEGER,&si.scroll_delay_value, "scroll_delay_value" }, { TYPE_STRING, &si.engine_snapshot_mode, "engine_snapshot_mode" }, + { TYPE_INTEGER,&si.engine_snapshot_memory, "engine_snapshot_memory" }, { TYPE_SWITCH, &si.fade_screens, "fade_screens" }, { TYPE_SWITCH, &si.autorecord, "automatic_tape_recording"}, { TYPE_SWITCH, &si.show_titlescreen, "show_titlescreen" }, @@ -8223,6 +8257,32 @@ static struct TokenInfo internal_setup_tokens[] = { TYPE_INTEGER,&sxi.default_window_height, "default_window_height" }, }; +static struct TokenInfo debug_setup_tokens[] = +{ + { TYPE_INTEGER, &sdi.frame_delay[0], "debug.frame_delay_0" }, + { TYPE_INTEGER, &sdi.frame_delay[1], "debug.frame_delay_1" }, + { TYPE_INTEGER, &sdi.frame_delay[2], "debug.frame_delay_2" }, + { TYPE_INTEGER, &sdi.frame_delay[3], "debug.frame_delay_3" }, + { TYPE_INTEGER, &sdi.frame_delay[4], "debug.frame_delay_4" }, + { TYPE_INTEGER, &sdi.frame_delay[5], "debug.frame_delay_5" }, + { TYPE_INTEGER, &sdi.frame_delay[6], "debug.frame_delay_6" }, + { TYPE_INTEGER, &sdi.frame_delay[7], "debug.frame_delay_7" }, + { TYPE_INTEGER, &sdi.frame_delay[8], "debug.frame_delay_8" }, + { TYPE_INTEGER, &sdi.frame_delay[9], "debug.frame_delay_9" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[0], "debug.key.frame_delay_0" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[1], "debug.key.frame_delay_1" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[2], "debug.key.frame_delay_2" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[3], "debug.key.frame_delay_3" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[4], "debug.key.frame_delay_4" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[5], "debug.key.frame_delay_5" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[6], "debug.key.frame_delay_6" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[7], "debug.key.frame_delay_7" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[8], "debug.key.frame_delay_8" }, + { TYPE_KEY_X11, &sdi.frame_delay_key[9], "debug.key.frame_delay_9" }, + { TYPE_BOOLEAN, &sdi.frame_delay_use_mod_key,"debug.frame_delay.use_mod_key"}, + { TYPE_BOOLEAN, &sdi.frame_delay_game_only, "debug.frame_delay.game_only" }, +}; + static struct TokenInfo options_setup_tokens[] = { { TYPE_BOOLEAN, &soi.verbose, "options.verbose" }, @@ -8257,6 +8317,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->scroll_delay = TRUE; 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->show_titlescreen = TRUE; @@ -8386,6 +8447,31 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) 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->options.verbose = FALSE; #if defined(PLATFORM_ANDROID) @@ -8474,6 +8560,13 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash) getHashEntry(setup_file_hash, internal_setup_tokens[i].text)); setup.internal = sxi; + /* debug setup */ + sdi = setup.debug; + for (i = 0; i < NUM_DEBUG_SETUP_TOKENS; i++) + setSetupInfo(debug_setup_tokens, i, + getHashEntry(setup_file_hash, debug_setup_tokens[i].text)); + setup.debug = sdi; + /* options setup */ soi = setup.options; for (i = 0; i < NUM_OPTIONS_SETUP_TOKENS; i++) @@ -8640,6 +8733,12 @@ void SaveSetup() /* internal setup */ /* (internal setup values not saved to user setup file) */ + /* debug setup */ + sdi = setup.debug; + fprintf(file, "\n"); + for (i = 0; i < NUM_DEBUG_SETUP_TOKENS; i++) + fprintf(file, "%s\n", getSetupLine(debug_setup_tokens, "", i)); + /* options setup */ soi = setup.options; fprintf(file, "\n"); @@ -8872,12 +8971,48 @@ static void InitMenuDesignSettings_SpecialPostProcessing() /* set default position for snapshot buttons to stop/pause/play buttons */ for (i = 0; game_buttons_xy[i].dst != NULL; i++) - { if ((*game_buttons_xy[i].dst).x == -1 && (*game_buttons_xy[i].dst).y == -1) + *game_buttons_xy[i].dst = *game_buttons_xy[i].src; +} + +static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics() +{ + static struct + { + struct XYTileSize *dst, *src; + int graphic; + } + editor_buttons_xy[] = + { { - (*game_buttons_xy[i].dst).x = (*game_buttons_xy[i].src).x; - (*game_buttons_xy[i].dst).y = (*game_buttons_xy[i].src).y; + &editor.button.element_left, &editor.palette.element_left, + IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT + }, + { + &editor.button.element_middle, &editor.palette.element_middle, + IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE + }, + { + &editor.button.element_right, &editor.palette.element_right, + IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT + }, + + { NULL, NULL } + }; + int i; + + /* set default position for element buttons to element graphics */ + for (i = 0; editor_buttons_xy[i].dst != NULL; i++) + { + if ((*editor_buttons_xy[i].dst).x == -1 && + (*editor_buttons_xy[i].dst).y == -1) + { + struct GraphicInfo *gd = &graphic_info[editor_buttons_xy[i].graphic]; + + gd->width = gd->height = editor_buttons_xy[i].src->tile_size; + + *editor_buttons_xy[i].dst = *editor_buttons_xy[i].src; } } } @@ -9265,6 +9400,11 @@ void LoadMenuDesignSettings() InitMenuDesignSettings_SpecialPostProcessing(); } +void LoadMenuDesignSettings_AfterGraphics() +{ + InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(); +} + void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); @@ -9902,15 +10042,15 @@ void ConvertLevels() convert_level_nr = convert_leveldir->first_level; - printf_line("=", 79); - printf("Converting levels\n"); - printf_line("-", 79); - printf("Level series identifier: '%s'\n", convert_leveldir->identifier); - printf("Level series name: '%s'\n", convert_leveldir->name); - printf("Level series author: '%s'\n", convert_leveldir->author); - printf("Number of levels: %d\n", convert_leveldir->levels); - printf_line("=", 79); - printf("\n"); + PrintLine("=", 79); + Print("Converting levels\n"); + PrintLine("-", 79); + Print("Level series identifier: '%s'\n", convert_leveldir->identifier); + Print("Level series name: '%s'\n", convert_leveldir->name); + Print("Level series author: '%s'\n", convert_leveldir->author); + Print("Number of levels: %d\n", convert_leveldir->levels); + PrintLine("=", 79); + Print("\n"); for (i = 0; i < MAX_NUM_CONVERT_LEVELS; i++) levels_failed[i] = FALSE; @@ -9922,16 +10062,16 @@ void ConvertLevels() level_nr = convert_level_nr++; - printf("Level %03d: ", level_nr); + Print("Level %03d: ", level_nr); LoadLevel(level_nr); if (level.no_valid_file) { - printf("(no level)\n"); + Print("(no level)\n"); continue; } - printf("converting level ... "); + Print("converting level ... "); level_filename = getDefaultLevelFilename(level_nr); new_level = !fileExists(level_filename); @@ -9942,28 +10082,28 @@ void ConvertLevels() num_levels_converted++; - printf("converted.\n"); + Print("converted.\n"); } else { if (level_nr >= 0 && level_nr < MAX_NUM_CONVERT_LEVELS) levels_failed[level_nr] = TRUE; - printf("NOT CONVERTED -- LEVEL ALREADY EXISTS.\n"); + Print("NOT CONVERTED -- LEVEL ALREADY EXISTS.\n"); } num_levels_handled++; } - printf("\n"); - printf_line("=", 79); - printf("Number of levels handled: %d\n", num_levels_handled); - printf("Number of levels converted: %d (%d%%)\n", num_levels_converted, + Print("\n"); + PrintLine("=", 79); + Print("Number of levels handled: %d\n", num_levels_handled); + Print("Number of levels converted: %d (%d%%)\n", num_levels_converted, (num_levels_handled ? num_levels_converted * 100 / num_levels_handled : 0)); - printf_line("-", 79); - printf("Summary (for automatic parsing by scripts):\n"); - printf("LEVELDIR '%s', CONVERTED %d/%d (%d%%)", + PrintLine("-", 79); + Print("Summary (for automatic parsing by scripts):\n"); + Print("LEVELDIR '%s', CONVERTED %d/%d (%d%%)", convert_leveldir->identifier, num_levels_converted, num_levels_handled, (num_levels_handled ? @@ -9971,14 +10111,14 @@ void ConvertLevels() if (num_levels_handled != num_levels_converted) { - printf(", FAILED:"); + Print(", FAILED:"); for (i = 0; i < MAX_NUM_CONVERT_LEVELS; i++) if (levels_failed[i]) - printf(" %03d", i); + Print(" %03d", i); } - printf("\n"); - printf_line("=", 79); + Print("\n"); + PrintLine("=", 79); CloseAllAndExit(0); }