X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=7f1ec19f128fd20935d2fce1332786339313a9c9;hb=c6d59064aa782b8ad71eddac2797fdc50e4858f9;hp=a5e5006e4c45964d1a005c805b2c8e55e9f449ff;hpb=2d769736ea3634a55a88c1d792ffdbefb190d1f3;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index a5e5006e..7f1ec19f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1047,7 +1047,11 @@ static struct /* ---------- current level number --------------------------------------- */ { +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else DX + 5 - SX, DY + 3 - SY, +#endif 1, 100, GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP, GADGET_ID_SELECT_LEVEL_TEXT, GADGET_ID_NONE, @@ -2474,25 +2478,41 @@ static struct { { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, +#endif GADGET_ID_SCROLL_UP, "scroll level editing area up" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, +#endif GADGET_ID_SCROLL_DOWN, "scroll level editing area down" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, +#endif GADGET_ID_SCROLL_LEFT, "scroll level editing area left" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, +#endif GADGET_ID_SCROLL_RIGHT, "scroll level editing area right" }, @@ -2524,14 +2544,16 @@ static struct { { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ +#else SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS, ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, -#if 1 SX, SY, SXSIZE, SYSIZE, -#else - 0, 0, - SX + SXSIZE + SX, WIN_YSIZE, #endif GD_TYPE_SCROLLBAR_HORIZONTAL, GADGET_ID_SCROLL_HORIZONTAL, @@ -2539,14 +2561,16 @@ static struct }, { ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ + -1, -1, /* these values are not constant, but can change at runtime */ +#else SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS, ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, -#if 1 SX, SY, SXSIZE, SYSIZE, -#else - 0, 0, - SX + SXSIZE + SX, WIN_YSIZE, #endif GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_VERTICAL, @@ -2554,15 +2578,16 @@ static struct }, { ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ + ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, + -1, -1, /* these values are not constant, but can change at runtime */ +#else DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS, ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, -#if 1 DX, DY, - DXSIZE, DYSIZE, -#else - SX + SXSIZE + SX, 0, - WIN_XSIZE - (SX + SXSIZE + SX), WIN_YSIZE, #endif + DXSIZE, DYSIZE, GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_LIST_VERTICAL, "scroll element list vertically" @@ -3007,7 +3032,12 @@ static struct { 0, 0, GADGET_ID_DRAWING_LEVEL, GADGET_ID_NONE, - NULL, MAX_ED_FIELDX, MAX_ED_FIELDY, + NULL, +#if 1 + -1, -1, /* these values are not constant, but can change at runtime */ +#else + MAX_ED_FIELDX, MAX_ED_FIELDY, +#endif NULL, NULL, NULL, NULL }, @@ -3269,7 +3299,11 @@ static struct */ /* actual size of level editor drawing area */ +#if 1 +static int ed_fieldx, ed_fieldy; +#else static int ed_fieldx = MAX_ED_FIELDX - 1, ed_fieldy = MAX_ED_FIELDY - 1; +#endif /* actual position of level editor drawing area in level playfield */ static int level_xpos = -1, level_ypos = -1; @@ -3714,6 +3748,16 @@ static int editor_el_supaplex[] = EL_SP_GRAVITY_PORT_UP, EL_SP_GRAVITY_PORT_DOWN, + EL_SP_GRAVITY_ON_PORT_LEFT, + EL_SP_GRAVITY_ON_PORT_RIGHT, + EL_SP_GRAVITY_ON_PORT_UP, + EL_SP_GRAVITY_ON_PORT_DOWN, + + EL_SP_GRAVITY_OFF_PORT_LEFT, + EL_SP_GRAVITY_OFF_PORT_RIGHT, + EL_SP_GRAVITY_OFF_PORT_UP, + EL_SP_GRAVITY_OFF_PORT_DOWN, + EL_SP_HARDWARE_GRAY, EL_SP_HARDWARE_GREEN, EL_SP_HARDWARE_BLUE, @@ -5148,38 +5192,10 @@ static void DrawDrawingArea(int id) static void ScrollMiniLevel(int from_x, int from_y, int scroll) { -#if 0 - /* (directly solved in BlitBitmap() now) */ - static Bitmap *tmp_backbuffer = NULL; -#endif int x, y; int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0); int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0); -#if 0 - /* (directly solved in BlitBitmap() now) */ - if (tmp_backbuffer == NULL) - tmp_backbuffer = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); - - /* needed when blitting directly to same bitmap -- should not be needed with - recent SDL libraries, but apparently does not work in 1.2.11 directly */ - BlitBitmap(drawto, tmp_backbuffer, - SX + (dx == -1 ? MINI_TILEX : 0), - SY + (dy == -1 ? MINI_TILEY : 0), - (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0), - (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), - SX + (dx == +1 ? MINI_TILEX : 0), - SY + (dy == +1 ? MINI_TILEY : 0)); - BlitBitmap(tmp_backbuffer, drawto, - SX + (dx == +1 ? MINI_TILEX : 0), - SY + (dy == +1 ? MINI_TILEY : 0), - (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0), - (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), - SX + (dx == +1 ? MINI_TILEX : 0), - SY + (dy == +1 ? MINI_TILEY : 0)); - -#else - BlitBitmap(drawto, drawto, SX + (dx == -1 ? MINI_TILEX : 0), SY + (dy == -1 ? MINI_TILEY : 0), @@ -5187,7 +5203,6 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll) (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), SX + (dx == +1 ? MINI_TILEX : 0), SY + (dy == +1 ? MINI_TILEY : 0)); -#endif if (dx) { @@ -5345,6 +5360,16 @@ static void CreateControlButtons() level_editor_gadget[id] = gi; } + /* these values are not constant, but can change at runtime */ + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].x = ED_SCROLL_UP_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_UP].y = ED_SCROLL_UP_YPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].x = ED_SCROLL_DOWN_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_DOWN].y = ED_SCROLL_DOWN_YPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].x = ED_SCROLL_LEFT_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_LEFT].y = ED_SCROLL_LEFT_YPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].x = ED_SCROLL_RIGHT_XPOS; + scrollbutton_info[ED_SCROLLBUTTON_ID_AREA_RIGHT].y = ED_SCROLL_RIGHT_YPOS; + /* create buttons for scrolling of drawing area and element list */ for (i = 0; i < ED_NUM_SCROLLBUTTONS; i++) { @@ -5460,6 +5485,10 @@ static void CreateCounterButtons() int max_infotext_len = getMaxInfoTextLength(); int i; + /* these values are not constant, but can change at runtime */ + counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].x = DX + 5 - SX; + counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].y = DY + 3 - SY; + for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++) { int j; @@ -5614,6 +5643,10 @@ static void CreateDrawingAreas() { int i; + /* these values are not constant, but can change at runtime */ + drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_xsize = MAX_ED_FIELDX; + drawingarea_info[ED_DRAWING_ID_DRAWING_LEVEL].area_ysize = MAX_ED_FIELDY; + for (i = 0; i < ED_NUM_DRAWING_AREAS; i++) { struct GadgetInfo *gi; @@ -5981,6 +6014,40 @@ static void CreateScrollbarGadgets() { int i; + /* these values are not constant, but can change at runtime */ + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].x = + SX + ED_SCROLL_HORIZONTAL_XPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].y = + SY + ED_SCROLL_HORIZONTAL_YPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width = + ED_SCROLL_HORIZONTAL_XSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].height = + ED_SCROLL_HORIZONTAL_YSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_x = SX; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_y = SY; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_width = SXSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].wheel_height = SYSIZE; + + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].x = + SX + ED_SCROLL_VERTICAL_XPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].y = + SY + ED_SCROLL_VERTICAL_YPOS; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].width = + ED_SCROLL_VERTICAL_XSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height = + ED_SCROLL_VERTICAL_YSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_x = SX; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_y = SY; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_width = SXSIZE; + scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].wheel_height = SYSIZE; + + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].x = + DX + ED_SCROLL2_VERTICAL_XPOS; + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].y = + DY + ED_SCROLL2_VERTICAL_YPOS; + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_x = DX; + scrollbar_info[ED_SCROLLBAR_ID_LIST_VERTICAL].wheel_y = DY; + for (i = 0; i < ED_NUM_SCROLLBARS; i++) { int id = scrollbar_info[i].gadget_id; @@ -6183,6 +6250,10 @@ void CreateLevelEditorGadgets() /* setting 'game_status' is needed to get the right fonts for the editor */ game_status = GAME_MODE_EDITOR; + /* these values are not constant, but can change at runtime */ + ed_fieldx = MAX_ED_FIELDX - 1; + ed_fieldy = MAX_ED_FIELDY - 1; + ReinitializeElementList(); CreateControlButtons(); @@ -6620,8 +6691,12 @@ static boolean LevelChanged() boolean field_changed = FALSE; int x, y; +#if 1 + /* changed read-only levels can now be saved in personal level set */ +#else if (leveldir_current->readonly) return FALSE; +#endif for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++) @@ -6631,21 +6706,151 @@ static boolean LevelChanged() return (level.changed || field_changed); } -static boolean LevelContainsPlayer() +static boolean PrepareSavingIntoPersonalLevelSet() { - boolean player_found = FALSE; - int x, y; + static LevelDirTree *last_copied_leveldir = NULL; + static LevelDirTree *last_written_leveldir = NULL; + static int last_copied_level_nr = -1; + static int last_written_level_nr = -1; + LevelDirTree *leveldir_former = leveldir_current; + int level_nr_former = level_nr; + int new_level_nr; + + // remember last mod/save so that for current session, we write + // back to the same personal copy, asking only about overwrite. + if (leveldir_current == last_copied_leveldir && + level_nr == last_copied_level_nr) + { + // "cd" to personal level set dir (as used when writing last copy) + leveldir_current = last_written_leveldir; + level_nr = last_written_level_nr; + + return TRUE; + } + + if (!Request("This level is read only ! " + "Save into personal level set ?", REQ_ASK)) + return FALSE; + + // "cd" to personal level set dir (for writing copy the first time) + leveldir_current = + getTreeInfoFromIdentifier(leveldir_first, getLoginName()); + + // find unused level number + for (new_level_nr = leveldir_current->first_level; ; new_level_nr++) + { + static char *level_filename = NULL; + + setString(&level_filename, getDefaultLevelFilename(new_level_nr)); + + if (!fileExists(level_filename)) + break; + } + + last_copied_leveldir = leveldir_former; + last_copied_level_nr = level_nr_former; + + last_written_leveldir = leveldir_current; + last_written_level_nr = level_nr = new_level_nr; + + return TRUE; +} + +static void ModifyLevelInfoForSavingIntoPersonalLevelSet(char *former_name) +{ + static char *filename_levelinfo = NULL, *mod_name = NULL; + FILE *file; + + // annotate this copy-and-mod in personal levelinfo.conf + setString(&filename_levelinfo, + getPath2(getCurrentLevelDir(), LEVELINFO_FILENAME)); + + if ((file = fopen(filename_levelinfo, MODE_APPEND))) + { + fprintf(file, "\n"); + fprintf(file, "# level %d was modified from:\n", level_nr); + fprintf(file, "# - previous level set name: %s\n", + former_name); + fprintf(file, "# - level within previous set: %d \"%s\"\n", + level.file_info.nr, level.name); + fprintf(file, "# - previous author: %s\n", + level.author); + fprintf(file, "# - previous save date: "); + + if (level.creation_date.src == DATE_SRC_LEVELFILE) + { + fprintf(file, "%04d-%02d-%02d\n", + level.creation_date.year, + level.creation_date.month, + level.creation_date.day); + } + else + { + fprintf(file, "not recorded\n"); + } - return TRUE; /* !!! CURRENTLY DEACTIVATED !!! */ + fclose(file); + } - for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++) + if (level_nr > leveldir_current->last_level) { - if (Feld[x][y] == EL_PLAYER_1 || - Feld[x][y] == EL_SP_MURPHY) - player_found = TRUE; + static char *temp_levelinfo = NULL; + FILE *temp_file = NULL; + char line[MAX_LINE_LEN]; + + setString(&temp_levelinfo, + getPath2(getCurrentLevelDir(), + getStringCat2(LEVELINFO_FILENAME, ".new"))); + + if ((file = fopen(filename_levelinfo, MODE_READ)) && + (temp_file = fopen(temp_levelinfo, MODE_WRITE))) + { + while (fgets(line, MAX_LINE_LEN, file)) + { + if (!strPrefix(line, "levels:")) + fputs(line, temp_file); + else + fprintf(temp_file, "%-32s%d\n", "levels:", level_nr + 9); + } + } + + if (temp_file) + fclose(temp_file); + + if (file) + fclose(file); + + // needs error handling; also, ok on dos/win? + unlink(filename_levelinfo); + rename(temp_levelinfo, filename_levelinfo); } - return player_found; + // else: allow the save even if annotation failed + + // now... spray graffiti on the old level vital statistics + // user can change these; just trying to set a good baseline + + // don't truncate names for fear of making offensive or silly: + // long-named original author only recorded in levelinfo.conf. + // try to fit "Joe after Bob", "Joe (ed.)", then just "Joe" + if (!strEqual(level.author, leveldir_current->author)) + { + setString(&mod_name, getStringCat3(leveldir_current->author, + " after ", level.author)); + + if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN) + setString(&mod_name, + getStringCat2(leveldir_current->author, " (ed.)")); + + if (strlen(mod_name) > MAX_LEVEL_AUTHOR_LEN) + setString(&mod_name, leveldir_current->author); + + strncpy(level.author, mod_name, MAX_LEVEL_AUTHOR_LEN); + + // less worried about truncation here + setString(&mod_name, getStringCat2("Mod: ", level.name)); + strncpy(level.name, mod_name, MAX_LEVEL_NAME_LEN); + } } static void CopyPlayfield(short src[MAX_LEV_FIELDX][MAX_LEV_FIELDY], @@ -7204,6 +7409,11 @@ void DrawLevelEd() FadeOut(REDRAW_FIELD); #endif +#if 1 + /* needed if different viewport properties defined for editor */ + ChangeViewportPropertiesIfNeeded(); +#endif + OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY); #if DEBUG @@ -7233,6 +7443,10 @@ void DrawLevelEd() BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, DOOR_GFX_PAGEX6, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY); +#if 0 + printf("::: %d, %d / %d, %d\n", VX, VY, EX, EY); +#endif + /* draw bigger door */ DrawSpecialEditorDoor(); @@ -7242,6 +7456,11 @@ void DrawLevelEd() redraw_mask |= REDRAW_ALL; +#if 1 + FreeLevelEditorGadgets(); + CreateLevelEditorGadgets(); +#endif + ReinitializeElementList(); /* update dynamic level element list */ ReinitializeElementListButtons(); /* custom element may look different */ @@ -9610,20 +9829,6 @@ static void SetElementIntelliDraw(int x, int y, int new_element, EL_SP_GRAVITY_PORT_LEFT }, - { - EL_MOLE_UP, - EL_MOLE_RIGHT, - EL_MOLE_DOWN, - EL_MOLE_LEFT - }, - - { - EL_BALLOON_SWITCH_UP, - EL_BALLOON_SWITCH_RIGHT, - EL_BALLOON_SWITCH_DOWN, - EL_BALLOON_SWITCH_LEFT - }, - { EL_SP_GRAVITY_ON_PORT_UP, EL_SP_GRAVITY_ON_PORT_RIGHT, @@ -9638,6 +9843,20 @@ static void SetElementIntelliDraw(int x, int y, int new_element, EL_SP_GRAVITY_OFF_PORT_LEFT }, + { + EL_MOLE_UP, + EL_MOLE_RIGHT, + EL_MOLE_DOWN, + EL_MOLE_LEFT + }, + + { + EL_BALLOON_SWITCH_UP, + EL_BALLOON_SWITCH_RIGHT, + EL_BALLOON_SWITCH_DOWN, + EL_BALLOON_SWITCH_LEFT + }, + { -1, -1, @@ -9905,7 +10124,11 @@ static void SelectArea(int from_x, int from_y, int to_x, int to_y, static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y, int button, int mode) { +#if 1 + static short brush_buffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +#else static short brush_buffer[MAX_ED_FIELDX][MAX_ED_FIELDY]; +#endif static int brush_width, brush_height; static int last_cursor_x = -1, last_cursor_y = -1; static boolean delete_old_brush; @@ -11227,60 +11450,78 @@ static void HandleControlButtons(struct GadgetInfo *gi) break; case GADGET_ID_SAVE: - if (leveldir_current->readonly) - { - Request("This level is read only !", REQ_CONFIRM); + { + /* saving read-only levels into personal level set modifies global vars + "leveldir_current" and "level_nr"; restore them after saving level */ + LevelDirTree *leveldir_former = leveldir_current; + int level_nr_former = level_nr; + char *level_filename; + boolean new_level; + + if (leveldir_current->readonly && + !PrepareSavingIntoPersonalLevelSet()) break; - } - if (!LevelContainsPlayer()) - Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM); - else + level_filename = getDefaultLevelFilename(level_nr); + new_level = !fileExists(level_filename); + + if (new_level || + Request("Save this level and kill the old ?", REQ_ASK)) { - char *level_filename = getDefaultLevelFilename(level_nr); - boolean new_level = !fileExists(level_filename); + if (leveldir_former->readonly) + ModifyLevelInfoForSavingIntoPersonalLevelSet(leveldir_former->name); - if (new_level || - Request("Save this level and kill the old ?", REQ_ASK)) - { - CopyPlayfield(Feld, level.field); + CopyPlayfield(Feld, level.field); + SaveLevel(level_nr); - SaveLevel(level_nr); - } + level.changed = FALSE; if (new_level) - Request("Level saved !", REQ_CONFIRM); + { + char level_saved_msg[64]; - level.changed = FALSE; + if (leveldir_former->readonly) + sprintf(level_saved_msg, + "Level saved as level %d into personal level set !", + level_nr); + else + strcpy(level_saved_msg, "Level saved !"); + + Request(level_saved_msg, REQ_CONFIRM); + } } + + /* "cd" back to copied-from levelset (in case of saved read-only level) */ + leveldir_current = leveldir_former; + level_nr = level_nr_former; + break; + } case GADGET_ID_TEST: - if (!LevelContainsPlayer()) - Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM); - else - { - if (LevelChanged()) - level.game_version = GAME_VERSION_ACTUAL; + if (LevelChanged()) + level.game_version = GAME_VERSION_ACTUAL; - CopyPlayfield(level.field, FieldBackup); - CopyPlayfield(Feld, level.field); + CopyPlayfield(level.field, FieldBackup); + CopyPlayfield(Feld, level.field); - CopyNativeLevel_RND_to_Native(&level); + CopyNativeLevel_RND_to_Native(&level); - UnmapLevelEditorGadgets(); - UndrawSpecialEditorDoor(); + UnmapLevelEditorGadgets(); + UndrawSpecialEditorDoor(); - CloseDoor(DOOR_CLOSE_ALL); + CloseDoor(DOOR_CLOSE_ALL); - BackToFront(); /* force redraw of undrawn special door */ + BackToFront(); /* force redraw of undrawn special door */ - DrawCompleteVideoDisplay(); +#if 0 + DrawCompleteVideoDisplay(); +#endif - level_editor_test_game = TRUE; + level_editor_test_game = TRUE; + + StartGameActions(FALSE, setup.autorecord, level.random_seed); - StartGameActions(FALSE, setup.autorecord, level.random_seed); - } break; case GADGET_ID_EXIT: @@ -11489,7 +11730,9 @@ void HandleLevelEditorKeyInput(Key key) ClickOnGadget(level_editor_gadget[id], button); else if (letter == '.') ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button); - else if (key == KSYM_Return || key == setup.shortcut.toggle_pause) + else if (key == KSYM_Return || + key == KSYM_space || + key == setup.shortcut.toggle_pause) ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button); else for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++)