From: Holger Schemel Date: Sun, 5 Nov 2017 23:28:27 +0000 (+0100) Subject: added editor door 1 animation if viewport is unchanged and contains toolbox X-Git-Tag: 4.1.0.0~67 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=608452efc3cb8d145639e0f401d85996dfc4e698;p=rocksndiamonds.git added editor door 1 animation if viewport is unchanged and contains toolbox --- diff --git a/src/editor.c b/src/editor.c index 2ff9fef6..e311541a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -3722,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(); @@ -8319,6 +8321,58 @@ 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; @@ -8338,8 +8392,6 @@ void DrawLevelEd() InitZoomLevelSettings(-1); InitLevelSetInfo(); - SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2); - #if DEBUG CheckElementDescriptions(); #endif @@ -8363,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(); @@ -8396,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() @@ -8702,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; @@ -8710,7 +8752,6 @@ static void DrawDrawingWindow() ClearField(); UnmapLevelEditorFieldGadgets(); - UnmapLevelEditorToolboxCustomGadgets(); AdjustDrawingAreaGadgets(); AdjustLevelScrollPosition(); @@ -8720,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() @@ -13916,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 && diff --git a/src/tools.c b/src/tools.c index 2838908d..55c757af 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4770,7 +4770,7 @@ unsigned int MoveDoor(unsigned int door_state) door_state &= ~DOOR_CLOSE_ALL; } - if (game_status == GAME_MODE_EDITOR) + if (game_status == GAME_MODE_EDITOR && !(door_state & DOOR_FORCE_ANIM)) door_state |= DOOR_NO_DELAY; if (door_state & DOOR_ACTION) diff --git a/src/tools.h b/src/tools.h index 2efb705d..37c67dd4 100644 --- a/src/tools.h +++ b/src/tools.h @@ -40,9 +40,10 @@ #define DOOR_COPY_BACK (1 << 4) #define DOOR_NO_COPY_BACK (1 << 5) #define DOOR_NO_DELAY (1 << 6) -#define DOOR_FORCE_REDRAW (1 << 7) -#define DOOR_GET_STATE (1 << 8) -#define DOOR_SET_STATE (1 << 9) +#define DOOR_FORCE_ANIM (1 << 7) +#define DOOR_FORCE_REDRAW (1 << 8) +#define DOOR_GET_STATE (1 << 9) +#define DOOR_SET_STATE (1 << 10) #define DOOR_1 (DOOR_ACTION_1) #define DOOR_2 (DOOR_ACTION_2)