X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=2ff9fef641007fafb983cabe3f83d946db3c7c9f;hb=35fe4b6c88b0b77f64449b7d4d25a79e54dc2156;hp=cef0b2875b2430259ceef346eea90e00777abd1a;hpb=05818ea4267c3e2a196071d17d8735d6f6fe65c9;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index cef0b287..2ff9fef6 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) /* @@ -3741,6 +3745,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 +5437,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]; @@ -5688,6 +5702,10 @@ static void ReinitializeElementList() num_editor_elements += num_editor_el_empty; } + else + { + num_editor_el_empty = 0; + } editor_elements = checked_malloc(num_editor_elements * sizeof(int)); @@ -5868,6 +5886,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); @@ -5886,6 +5943,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) @@ -7338,6 +7396,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 || @@ -8200,7 +8264,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; @@ -8260,7 +8325,7 @@ void DrawLevelEd() FadeSoundsAndMusic(); - if (CheckIfGlobalBorderHasChanged()) + if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged()) fade_mask = REDRAW_ALL; FadeOut(fade_mask); @@ -8273,7 +8338,7 @@ void DrawLevelEd() InitZoomLevelSettings(-1); InitLevelSetInfo(); - OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY); + SetDoorState(DOOR_OPEN_1 | DOOR_OPEN_2); #if DEBUG CheckElementDescriptions(); @@ -8353,6 +8418,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); @@ -8428,6 +8499,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) @@ -8659,13 +8736,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;