#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)
/*
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();
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 */
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];
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);
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)
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 ||
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;
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);
InitZoomLevelSettings(-1);
InitLevelSetInfo();
- OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
-
#if DEBUG
CheckElementDescriptions();
#endif
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();
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()
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);
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)
PickDrawingElement(3, new_element3);
}
-static void DrawDrawingWindow()
+static void DrawDrawingWindowExt(boolean remap_toolbox_gadgets)
{
stick_element_properties_window = FALSE;
ClearField();
UnmapLevelEditorFieldGadgets();
- UnmapLevelEditorToolboxCustomGadgets();
AdjustDrawingAreaGadgets();
AdjustLevelScrollPosition();
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()
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;
/* 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 &&