X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=b5f5fc7cdc8a7667632417ce06ccbaef4304e5c0;hb=04b6a442e77073cbe0c99f3f343a737d471c3312;hp=df569c52794f4ddea14cb87c6a58566bd53c77d7;hpb=f7cfbcfe490a20f60a778ff9b05f174fab1ec2da;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index df569c52..b5f5fc7c 100644 --- a/src/files.c +++ b/src/files.c @@ -1861,13 +1861,15 @@ static void ActivateLevelTemplate() static char *getLevelFilenameFromBasename(char *basename) { - static char *filename = NULL; + /* use different slots for level template files and regular level files */ + static char *filename[2] = { NULL, NULL }; + int pos = (strEqual(basename, LEVELTEMPLATE_FILENAME) ? 0 : 1); - checked_free(filename); + checked_free(filename[pos]); - filename = getPath2(getCurrentLevelDir(), basename); + filename[pos] = getPath2(getCurrentLevelDir(), basename); - return filename; + return filename[pos]; } static int getFileTypeFromBasename(char *basename) @@ -1921,7 +1923,7 @@ static char *getSingleLevelBasenameExt(int nr, char *extension) static char basename[MAX_FILENAME_LEN]; if (nr < 0) - sprintf(basename, "template.%s", extension); + sprintf(basename, "%s", LEVELTEMPLATE_FILENAME); else sprintf(basename, "%03d.%s", nr, extension); @@ -2053,31 +2055,47 @@ static int getFiletypeFromID(char *filetype_id) return filetype; } -static void determineLevelFileInfo_Filename(struct LevelFileInfo *lfi) +char *getLocalLevelTemplateFilename() { - int nr = lfi->nr; + return getDefaultLevelFilename(-1); +} - /* special case: level number is negative => check for level template file */ - if (nr < 0) +char *getGlobalLevelTemplateFilename() +{ + /* global variable "leveldir_current" must be modified in the loop below */ + LevelDirTree *leveldir_current_last = leveldir_current; + char *filename = NULL; + + /* check for template level in path from current to topmost tree node */ + + while (leveldir_current != NULL) { - /* global variable "leveldir_current" must be modified in the loop below */ - LevelDirTree *leveldir_current_last = leveldir_current; + filename = getDefaultLevelFilename(-1); + + if (fileExists(filename)) + break; - /* check for template level in path from current to topmost tree node */ + leveldir_current = leveldir_current->node_parent; + } - while (leveldir_current != NULL) - { - setLevelFileInfo_FormatLevelFilename(lfi, LEVEL_FILE_TYPE_RND, - "template.%s", LEVELFILE_EXTENSION); + /* restore global variable "leveldir_current" modified in above loop */ + leveldir_current = leveldir_current_last; - if (fileExists(lfi->filename)) - break; + return filename; +} - leveldir_current = leveldir_current->node_parent; - } +static void determineLevelFileInfo_Filename(struct LevelFileInfo *lfi) +{ + int nr = lfi->nr; - /* restore global variable "leveldir_current" modified in above loop */ - leveldir_current = leveldir_current_last; + /* special case: level number is negative => check for level template file */ + if (nr < 0) + { + setLevelFileInfo_FormatLevelFilename(lfi, LEVEL_FILE_TYPE_RND, + getSingleLevelBasename(-1)); + + /* replace local level template filename with global template filename */ + lfi->filename = getGlobalLevelTemplateFilename(); /* no fallback if template file not existing */ return; @@ -7867,6 +7885,7 @@ void LoadScore(int nr) void SaveScore(int nr) { int i; + int permissions = (program.global_scores ? PERMS_PUBLIC : PERMS_PRIVATE); char *filename = getScoreFilename(nr); FILE *file; @@ -7885,7 +7904,7 @@ void SaveScore(int nr) fclose(file); - SetFilePermissions(filename, PERMS_PUBLIC); + SetFilePermissions(filename, permissions); } @@ -7943,25 +7962,14 @@ void SaveScore(int nr) #define NUM_GLOBAL_SETUP_TOKENS 43 /* editor setup */ -#define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0 -#define SETUP_TOKEN_EDITOR_EL_EMERALD_MINE 1 -#define SETUP_TOKEN_EDITOR_EL_EMERALD_MINE_CLUB 2 -#define SETUP_TOKEN_EDITOR_EL_MORE 3 -#define SETUP_TOKEN_EDITOR_EL_SOKOBAN 4 -#define SETUP_TOKEN_EDITOR_EL_SUPAPLEX 5 -#define SETUP_TOKEN_EDITOR_EL_DIAMOND_CAVES 6 -#define SETUP_TOKEN_EDITOR_EL_DX_BOULDERDASH 7 -#define SETUP_TOKEN_EDITOR_EL_CHARS 8 -#define SETUP_TOKEN_EDITOR_EL_STEEL_CHARS 9 -#define SETUP_TOKEN_EDITOR_EL_CUSTOM 10 -#define SETUP_TOKEN_EDITOR_EL_HEADLINES 11 -#define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 12 -#define SETUP_TOKEN_EDITOR_EL_DYNAMIC 13 -#define SETUP_TOKEN_EDITOR_EL_BY_GAME 14 -#define SETUP_TOKEN_EDITOR_EL_BY_TYPE 15 -#define SETUP_TOKEN_EDITOR_SHOW_ELEMENT_TOKEN 16 - -#define NUM_EDITOR_SETUP_TOKENS 17 +#define SETUP_TOKEN_EDITOR_EL_CHARS 0 +#define SETUP_TOKEN_EDITOR_EL_STEEL_CHARS 1 +#define SETUP_TOKEN_EDITOR_EL_CUSTOM 2 +#define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 3 +#define SETUP_TOKEN_EDITOR_EL_DYNAMIC 4 +#define SETUP_TOKEN_EDITOR_SHOW_ELEMENT_TOKEN 5 + +#define NUM_EDITOR_SETUP_TOKENS 6 /* editor cascade setup */ #define SETUP_TOKEN_EDITOR_CASCADE_BD 0 @@ -8146,22 +8154,11 @@ static struct TokenInfo global_setup_tokens[] = static struct TokenInfo editor_setup_tokens[] = { - { TYPE_SWITCH, &sei.el_boulderdash, "editor.el_boulderdash" }, - { TYPE_SWITCH, &sei.el_emerald_mine, "editor.el_emerald_mine" }, - { TYPE_SWITCH, &sei.el_emerald_mine_club,"editor.el_emerald_mine_club"}, - { TYPE_SWITCH, &sei.el_more, "editor.el_more" }, - { TYPE_SWITCH, &sei.el_sokoban, "editor.el_sokoban" }, - { TYPE_SWITCH, &sei.el_supaplex, "editor.el_supaplex" }, - { TYPE_SWITCH, &sei.el_diamond_caves, "editor.el_diamond_caves" }, - { TYPE_SWITCH, &sei.el_dx_boulderdash,"editor.el_dx_boulderdash" }, { TYPE_SWITCH, &sei.el_chars, "editor.el_chars" }, { TYPE_SWITCH, &sei.el_steel_chars, "editor.el_steel_chars" }, { TYPE_SWITCH, &sei.el_custom, "editor.el_custom" }, - { TYPE_SWITCH, &sei.el_headlines, "editor.el_headlines" }, { TYPE_SWITCH, &sei.el_user_defined, "editor.el_user_defined" }, { TYPE_SWITCH, &sei.el_dynamic, "editor.el_dynamic" }, - { TYPE_SWITCH, &sei.el_by_game, "editor.el_by_game" }, - { TYPE_SWITCH, &sei.el_by_type, "editor.el_by_type" }, { TYPE_SWITCH, &sei.show_element_token,"editor.show_element_token" }, }; @@ -8971,12 +8968,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; } } } @@ -9364,6 +9397,11 @@ void LoadMenuDesignSettings() InitMenuDesignSettings_SpecialPostProcessing(); } +void LoadMenuDesignSettings_AfterGraphics() +{ + InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(); +} + void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); @@ -10168,6 +10206,8 @@ void CreateCustomElementImages(char *directory) SDLInitVideoDisplay(); + ReCreateBitmap(&backbuffer, video.width, video.height); + src_bitmap = LoadImage(src_filename); bitmap = CreateBitmap(TILEX * 16 * 2,