added editor door 1 animation if viewport is unchanged and contains toolbox
authorHolger Schemel <info@artsoft.org>
Sun, 5 Nov 2017 23:28:27 +0000 (00:28 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:15 +0000 (23:21 +0100)
src/editor.c
src/tools.c
src/tools.h

index 2ff9fef641007fafb983cabe3f83d946db3c7c9f..e311541abdcf975346589cb53addf1787c0c24e6 100644 (file)
@@ -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     &&
index 2838908d99e93954787d83d96547b9df58cb95e2..55c757afa9c215d63c56ffc20b64ed02518bc6d3 100644 (file)
@@ -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)
index 2efb705d828d136bf6ed1a3e8d1d09d68a54b8f8..37c67dd47878c1e2eb1a8a7548202788d1c2b403 100644 (file)
 #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)