X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=e311541abdcf975346589cb53addf1787c0c24e6;hb=608452efc3cb8d145639e0f401d85996dfc4e698;hp=fb40606a0239b4ffb4973c3956a9fc7fe594d80a;hpb=2600d5817fa65a212ef097890560dd2550ba6c5f;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index fb40606a..e311541a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -346,8 +346,12 @@ #define INFOTEXT_XSIZE SXSIZE #define INFOTEXT_YSIZE getFontHeight(INFOTEXT_FONT) #define INFOTEXT_YSIZE_FULL (INFOTEXT_YSIZE + ED_GADGET_SMALL_DISTANCE) -#define INFOTEXT_XPOS SX -#define INFOTEXT_YPOS (SY + SYSIZE - INFOTEXT_YSIZE) +#define INFOTEXT_X (editor.settings.tooltip.x) +#define INFOTEXT_Y (editor.settings.tooltip.y) +#define INFOTEXT_XY_REDEFINED (INFOTEXT_X != -1 || INFOTEXT_Y != -1) +#define INFOTEXT_XPOS SX + (INFOTEXT_XY_REDEFINED ? INFOTEXT_X : 0) +#define INFOTEXT_YPOS SY + (INFOTEXT_XY_REDEFINED ? INFOTEXT_Y : \ + SYSIZE - INFOTEXT_YSIZE) /* @@ -3718,7 +3722,9 @@ static void ModifyEditorDrawingArea(int, int, int); static void ModifyEditorElementList(); static void AdjustElementListScrollbar(); static void RedrawDrawingElements(); +static void DrawDrawingWindowExt(boolean); static void DrawDrawingWindow(); +static void DrawDrawingWindow_PlayfieldOnly(); static void DrawLevelInfoWindow(); static void DrawPropertiesWindow(); static void DrawPaletteWindow(); @@ -3741,6 +3747,9 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *); static void PrintEditorGadgetInfoText(struct GadgetInfo *); static boolean AskToCopyAndModifyLevelTemplate(); static boolean getDrawModeHiRes(); +static int getTabulatorBarWidth(); +static int getTabulatorBarHeight(); +static Pixel getTabulatorBarColor(); static int num_editor_gadgets = 0; /* dynamically determined */ @@ -5430,6 +5439,13 @@ char *getElementDescriptionFilename(int element) return NULL; } +static boolean suppressBorderElement() +{ + return (level.game_engine_type == GAME_ENGINE_TYPE_MM && + lev_fieldx <= MAX_ED_FIELDX && + lev_fieldy <= MAX_ED_FIELDY); +} + static void InitDynamicEditorElementList(int **elements, int *num_elements) { boolean element_found[NUM_FILE_ELEMENTS]; @@ -5872,6 +5888,45 @@ static void DrawElementBorder(int dest_x, int dest_y, int width, int height, ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2); } +static void DrawEditorLevelBorderLine(int x, int y, int xsize, int ysize) +{ + int xsize_tile = MAX(ed_tilesize, xsize); + int ysize_tile = MAX(ed_tilesize, ysize); + int xsize_full = xsize + 1; + int ysize_full = ysize + 1; + int xsize_thin = (xsize < ed_tilesize ? 1 : xsize); + int ysize_thin = (ysize < ed_tilesize ? 1 : ysize); + Pixel line_color = getTabulatorBarColor(); + + if (line_color == BLACK_PIXEL) /* black => transparent */ + return; + + FillRectangle(drawto, SX + x, SY + y, xsize_tile, ysize_tile, BLACK_PIXEL); + FillRectangle(drawto, SX + x, SY + y, xsize_full, ysize_full, line_color); + FillRectangle(drawto, SX + x, SY + y, xsize_thin, ysize_thin, BLACK_PIXEL); +} + +static void DrawEditorLevelBorderLinesIfNeeded() +{ + int xsize = lev_fieldx * ed_tilesize; + int ysize = lev_fieldy * ed_tilesize; + int line_size = getTabulatorBarHeight(); + + if (!suppressBorderElement()) + return; + + /* draw little border line around editable level playfield */ + + if (xsize < SXSIZE) + DrawEditorLevelBorderLine(xsize, 0, line_size, ysize); + + if (ysize < SYSIZE) + DrawEditorLevelBorderLine(0, ysize, xsize, line_size); + + if (xsize < SXSIZE && ysize < SYSIZE) + DrawEditorLevelBorderLine(xsize, ysize, line_size, line_size); +} + static void DrawEditorElement(int x, int y, int element) { DrawSizedElement(x, y, element, ed_tilesize); @@ -5890,6 +5945,7 @@ static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y) static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y) { DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize); + DrawEditorLevelBorderLinesIfNeeded(); } static void DrawDrawingArea(int id) @@ -7342,6 +7398,12 @@ static void MapMainDrawingArea() boolean no_vertical_scrollbar = (lev_fieldy + 2 <= ed_fieldy); int i; + if (suppressBorderElement()) + { + no_horizontal_scrollbar = (lev_fieldx <= ed_fieldx); + no_vertical_scrollbar = (lev_fieldy <= ed_fieldy); + } + for (i=ED_SCROLLBUTTON_ID_AREA_FIRST; i <= ED_SCROLLBUTTON_ID_AREA_LAST; i++) { if (((i == ED_SCROLLBUTTON_ID_AREA_LEFT || @@ -8204,7 +8266,8 @@ static int getMaxEdFieldX(boolean has_scrollbar) static int getMaxEdFieldY(boolean has_scrollbar) { - int infotext_height = INFOTEXT_YSIZE_FULL; + int infotext_height = (IN_PIX_FIELD(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY) ? + INFOTEXT_YSIZE_FULL : 0); int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0); int sysize = SYSIZE - scrollbar_height - infotext_height; int max_ed_fieldy = sysize / ed_tilesize; @@ -8258,13 +8321,65 @@ static void ChangeEditorToLevelSet(char *levelset_subdir) DrawLevelEd(); } +static boolean useEditorDoorAnimation() +{ + struct RectWithBorder *vp_door_1 = &viewport.door_1[GAME_MODE_MAIN]; + boolean door_1_viewport_unchanged = + (vp_door_1->x == DX && + vp_door_1->y == DY && + vp_door_1->width == DXSIZE && + vp_door_1->height == DYSIZE); + boolean door_1_contains_toolbox = + (EX >= DX && + EY >= DY && + EX + EXSIZE <= DX + DXSIZE && + EY + EYSIZE <= DY + DYSIZE); + + return (door_1_viewport_unchanged && door_1_contains_toolbox); +} + +void DrawEditorDoorContent() +{ + /* needed for gadgets drawn on background (like palette scrollbar) */ + SetDoorBackgroundImage(IMG_UNDEFINED); + + /* copy default editor door content to main double buffer */ + BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto, + graphic_info[IMG_BACKGROUND_PALETTE].src_x, + graphic_info[IMG_BACKGROUND_PALETTE].src_y, + MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width), + MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height), + DX, DY); + + /* draw bigger door */ + DrawSpecialEditorDoor(); + + /* draw new control window */ + BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto, + graphic_info[IMG_BACKGROUND_TOOLBOX].src_x, + graphic_info[IMG_BACKGROUND_TOOLBOX].src_y, + MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width), + MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height), + EX, EY); + + /* draw all toolbox gadgets to editor doors */ + MapControlButtons(); + + /* draw all palette gadgets to editor doors */ + ModifyEditorElementList(); + RedrawDrawingElements(); + + /* copy actual editor door content to door double buffer for OpenDoor() */ + BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0); +} + void DrawLevelEd() { int fade_mask = REDRAW_FIELD; FadeSoundsAndMusic(); - if (CheckIfGlobalBorderHasChanged()) + if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged()) fade_mask = REDRAW_ALL; FadeOut(fade_mask); @@ -8277,8 +8392,6 @@ void DrawLevelEd() InitZoomLevelSettings(-1); InitLevelSetInfo(); - SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2); - #if DEBUG CheckElementDescriptions(); #endif @@ -8302,28 +8415,6 @@ void DrawLevelEd() level_ypos = -1; } - /* needed for gadgets drawn on background (like palette scrollbar) */ - SetDoorBackgroundImage(IMG_UNDEFINED); - - /* copy default editor door content to main double buffer */ - BlitBitmap(graphic_info[IMG_BACKGROUND_PALETTE].bitmap, drawto, - graphic_info[IMG_BACKGROUND_PALETTE].src_x, - graphic_info[IMG_BACKGROUND_PALETTE].src_y, - MIN(DXSIZE, graphic_info[IMG_BACKGROUND_PALETTE].width), - MIN(DYSIZE, graphic_info[IMG_BACKGROUND_PALETTE].height), - DX, DY); - - /* draw bigger door */ - DrawSpecialEditorDoor(); - - /* draw new control window */ - BlitBitmap(graphic_info[IMG_BACKGROUND_TOOLBOX].bitmap, drawto, - graphic_info[IMG_BACKGROUND_TOOLBOX].src_x, - graphic_info[IMG_BACKGROUND_TOOLBOX].src_y, - MIN(EXSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].width), - MIN(EYSIZE, graphic_info[IMG_BACKGROUND_TOOLBOX].height), - EX, EY); - // redraw_mask |= REDRAW_ALL; FreeLevelEditorGadgets(); @@ -8335,16 +8426,28 @@ void DrawLevelEd() InitElementPropertiesGfxElement(); UnmapAllGadgets(); - MapControlButtons(); - DrawEditModeWindow(); + DrawDrawingWindow_PlayfieldOnly(); DrawMaskedBorder(fade_mask); - FadeIn(fade_mask); + // use door animation if door 1 viewport is unchanged and contains toolbox + if (useEditorDoorAnimation()) + { + FadeIn(fade_mask); - /* copy actual editor door content to door double buffer for OpenDoor() */ - BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0); + DrawEditorDoorContent(); + + OpenDoor(DOOR_OPEN_1 | DOOR_FORCE_ANIM); + } + else + { + DrawEditorDoorContent(); + + FadeIn(fade_mask); + } + + SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2); } static void AdjustDrawingAreaGadgets() @@ -8357,6 +8460,12 @@ static void AdjustDrawingAreaGadgets() boolean vertical_scrollbar_needed; int x, y, width, height; + if (suppressBorderElement()) + { + ed_xsize = max_ed_fieldx; + ed_ysize = max_ed_fieldy; + } + /* check if we need any scrollbars */ horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx); vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy); @@ -8432,6 +8541,12 @@ static void AdjustLevelScrollPosition() level_ypos = lev_fieldy - ed_fieldy + 1; if (lev_fieldy < ed_fieldy - 2) level_ypos = -1; + + if (suppressBorderElement()) + { + level_xpos = 0; + level_ypos = 0; + } } static void AdjustEditorScrollbar(int id) @@ -8629,7 +8744,7 @@ static void RedrawDrawingElements() PickDrawingElement(3, new_element3); } -static void DrawDrawingWindow() +static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets) { stick_element_properties_window = FALSE; @@ -8637,7 +8752,6 @@ static void DrawDrawingWindow() ClearField(); UnmapLevelEditorFieldGadgets(); - UnmapLevelEditorToolboxCustomGadgets(); AdjustDrawingAreaGadgets(); AdjustLevelScrollPosition(); @@ -8647,7 +8761,22 @@ static void DrawDrawingWindow() DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos); MapMainDrawingArea(); - MapLevelEditorToolboxDrawingGadgets(); + + if (remap_toolbox_gadgets) + { + UnmapLevelEditorToolboxCustomGadgets(); + MapLevelEditorToolboxDrawingGadgets(); + } +} + +static void DrawDrawingWindow() +{ + DrawDrawingWindowExt(TRUE); +} + +static void DrawDrawingWindow_PlayfieldOnly() +{ + DrawDrawingWindowExt(FALSE); } static int getTabulatorBarWidth() @@ -8663,13 +8792,20 @@ static int getTabulatorBarHeight() return ED_TAB_BAR_HEIGHT; } -static void DrawLevelInfoTabulatorGadgets() +static Pixel getTabulatorBarColor() { struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL]; struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED]; int gd_x = gd->x + gd_gi1->border.width / 2; int gd_y = gd->y + gd_gi1->height - 1; - Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y); + + return GetPixel(gd->bitmap, gd_x, gd_y); +} + +static void DrawLevelInfoTabulatorGadgets() +{ + struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_LEVELINFO_LEVEL]; + Pixel tab_color = getTabulatorBarColor(); int id_first = ED_TAB_BUTTON_ID_LEVELINFO_FIRST; int id_last = ED_TAB_BUTTON_ID_LEVELINFO_LAST; int i; @@ -13836,6 +13972,10 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed, /* draw normal door */ UndrawSpecialEditorDoor(); + // use door animation if door 1 viewport is unchanged and contains toolbox + if (useEditorDoorAnimation()) + CloseDoor(DOOR_CLOSE_1 | DOOR_FORCE_ANIM); + // close editor doors if viewport definition is the same as in main menu if (vp_door_1->x == DX && vp_door_1->y == DY &&