From 04822a800bb5479087613b0730fdf7e765ba012c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 13 Feb 2014 22:54:26 +0100 Subject: [PATCH] rnd-20140213-1-src * fixed various problems with playfield and requester/tape/editor doors defined to be at non-standard screen positions in artwork config file --- ChangeLog | 4 ++++ src/conftime.h | 2 +- src/editor.c | 15 +++++++++---- src/events.c | 2 +- src/init.c | 22 ++---------------- src/libgame/gadgets.c | 29 ++++++++++++++++++++++-- src/libgame/system.c | 22 ++++++++++++++++++ src/libgame/system.h | 16 ++++++++++--- src/libgame/text.c | 13 +++++++++++ src/screens.c | 2 ++ src/tools.c | 52 ++++++++++++++++++++++++++++++------------- 11 files changed, 132 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index 414b0d22..160fec38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-02-13 + * fixed various problems with playfield and requester/tape/editor doors + defined to be at non-standard screen positions in artwork config file + 2014-01-28 * added envelope style requester dialog (alternative to door requester) diff --git a/src/conftime.h b/src/conftime.h index 24f236ea..e0e5e7fd 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-02-12 02:10" +#define COMPILE_DATE_STRING "2014-02-13 21:54" diff --git a/src/editor.c b/src/editor.c index d939c154..15b71a09 100644 --- a/src/editor.c +++ b/src/editor.c @@ -6655,13 +6655,20 @@ static void UnmapDrawingArea(int id) UnmapGadget(level_editor_gadget[drawingarea_info[id].gadget_id]); } -static void UnmapLevelEditorWindowGadgets() +static void UnmapLevelEditorFieldGadgets() { int i; +#if 1 + for (i = 0; i < NUM_EDITOR_GADGETS; i++) + if (IN_GFX_FIELD_FULL(level_editor_gadget[i]->x, + level_editor_gadget[i]->y)) + UnmapGadget(level_editor_gadget[i]); +#else for (i = 0; i < NUM_EDITOR_GADGETS; i++) if (level_editor_gadget[i]->x < SX + SXSIZE) UnmapGadget(level_editor_gadget[i]); +#endif } void UnmapLevelEditorGadgets() @@ -7755,7 +7762,7 @@ static void DrawDrawingWindow() SetMainBackgroundImage(IMG_UNDEFINED); ClearField(); - UnmapLevelEditorWindowGadgets(); + UnmapLevelEditorFieldGadgets(); UnmapLevelEditorToolboxCustomGadgets(); AdjustDrawingAreaGadgets(); @@ -7926,7 +7933,7 @@ static void DrawLevelInfoWindow() { stick_element_properties_window = FALSE; - UnmapLevelEditorWindowGadgets(); + UnmapLevelEditorFieldGadgets(); SetMainBackgroundImage(IMG_BACKGROUND_EDITOR); ClearField(); @@ -8892,7 +8899,7 @@ static void DrawPropertiesWindow() CopyElementPropertiesToEditor(properties_element); - UnmapLevelEditorWindowGadgets(); + UnmapLevelEditorFieldGadgets(); UnmapLevelEditorToolboxDrawingGadgets(); UnmapLevelEditorToolboxCustomGadgets(); diff --git a/src/events.c b/src/events.c index 071796d8..f9e74a76 100644 --- a/src/events.c +++ b/src/events.c @@ -1146,7 +1146,7 @@ void HandleButton(int mx, int my, int button, int button_nr) case GAME_MODE_PLAYING: #ifdef DEBUG - if (button == MB_PRESSED && !motion_status && IN_GFX_SCREEN(mx, my)) + if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD(mx, my)) DumpTile(LEVELX((mx - SX) / TILEX), LEVELY((my - SY) / TILEY)); #endif break; diff --git a/src/init.c b/src/init.c index ab342b8a..5f18d26f 100644 --- a/src/init.c +++ b/src/init.c @@ -5493,6 +5493,7 @@ static void InitMixer() void InitGfxBuffers() { + /* create additional image buffers for double-buffering and cross-fading */ ReCreateBitmap(&bitmap_db_store, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); ReCreateBitmap(&bitmap_db_cross, WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); ReCreateBitmap(&bitmap_db_field, FXSIZE, FYSIZE, DEFAULT_DEPTH); @@ -5506,6 +5507,7 @@ void InitGfxBuffers() bitmap_db_field); InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE); InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); + InitGfxDoor3Info(EX, EY, EXSIZE, EYSIZE); InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE); InitGfxScrollbufferInfo(FXSIZE, FYSIZE); InitGfxClipRegion(FALSE, -1, -1, -1, -1); @@ -5560,27 +5562,7 @@ void InitGfx() if (filename_font_initial == NULL) /* should not happen */ Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL); -#if 1 InitGfxBuffers(); -#else - /* create additional image buffers for double-buffering and cross-fading */ - bitmap_db_store = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); - bitmap_db_cross = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); - bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); - bitmap_db_panel = CreateBitmap(DXSIZE, DYSIZE, DEFAULT_DEPTH); - bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); - bitmap_db_toons = CreateBitmap(FULL_SXSIZE, FULL_SYSIZE, DEFAULT_DEPTH); - - /* initialize screen properties */ - InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE, - REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, - bitmap_db_field); - InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE); - InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE); - InitGfxWindowInfo(WIN_XSIZE, WIN_YSIZE); - InitGfxScrollbufferInfo(FXSIZE, FYSIZE); -#endif - InitGfxCustomArtworkInfo(); bitmap_font_initial = LoadCustomImage(filename_font_initial); diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 2113b824..26454d47 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -706,9 +706,21 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) gi->selectbox.x, gi->selectbox.y); } else + { +#if 1 + int x = gi->x; + int y = gi->y; + + redraw_mask |= (IN_GFX_FIELD_FULL(x, y) ? REDRAW_FIELD : + IN_GFX_DOOR_1(x, y) ? REDRAW_DOOR_1 : + IN_GFX_DOOR_2(x, y) ? REDRAW_DOOR_2 : + IN_GFX_DOOR_3(x, y) ? REDRAW_DOOR_3 : REDRAW_ALL); +#else redraw_mask |= (gi->x < gfx.sx + gfx.sxsize ? REDRAW_FIELD : gi->y < gfx.dy + gfx.dysize ? REDRAW_DOOR_1 : gi->y > gfx.vy ? REDRAW_DOOR_2 : REDRAW_DOOR_3); +#endif + } } static int get_minimal_size_for_numeric_input(int minmax_value) @@ -1324,9 +1336,11 @@ void UnmapGadget(struct GadgetInfo *gi) #define MULTIMAP_PLAYFIELD (1 << 3) #define MULTIMAP_DOOR_1 (1 << 4) #define MULTIMAP_DOOR_2 (1 << 5) +#define MULTIMAP_DOOR_3 (1 << 6) #define MULTIMAP_ALL (MULTIMAP_PLAYFIELD | \ - MULTIMAP_DOOR_1 | \ - MULTIMAP_DOOR_2) + MULTIMAP_DOOR_1 | \ + MULTIMAP_DOOR_2 | \ + MULTIMAP_DOOR_3) static void MultiMapGadgets(int mode) { @@ -1336,6 +1350,16 @@ static void MultiMapGadgets(int mode) while (gi != NULL) { +#if 1 + int x = gi->x; + int y = gi->y; + + if ((mode & MULTIMAP_PLAYFIELD && IN_GFX_FIELD_FULL(x, y)) || + (mode & MULTIMAP_DOOR_1 && IN_GFX_DOOR_1(x, y)) || + (mode & MULTIMAP_DOOR_2 && IN_GFX_DOOR_2(x, y)) || + (mode & MULTIMAP_DOOR_3 && IN_GFX_DOOR_3(x, y)) || + (mode & MULTIMAP_ALL) == MULTIMAP_ALL) +#else if ((mode & MULTIMAP_PLAYFIELD && gi->x < gfx.sx + gfx.sxsize) || (mode & MULTIMAP_DOOR_1 && @@ -1343,6 +1367,7 @@ static void MultiMapGadgets(int mode) (mode & MULTIMAP_DOOR_2 && gi->x >= gfx.dx && gi->y > gfx.dy + gfx.dysize) || (mode & MULTIMAP_ALL) == MULTIMAP_ALL) +#endif { if (mode & MULTIMAP_UNMAP) { diff --git a/src/libgame/system.c b/src/libgame/system.c index 9ac05663..7902f42b 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -214,6 +214,14 @@ void InitGfxDoor2Info(int vx, int vy, int vxsize, int vysize) gfx.vysize = vysize; } +void InitGfxDoor3Info(int ex, int ey, int exsize, int eysize) +{ + gfx.ex = ex; + gfx.ey = ey; + gfx.exsize = exsize; + gfx.eysize = eysize; +} + void InitGfxWindowInfo(int win_xsize, int win_ysize) { gfx.win_xsize = win_xsize; @@ -563,6 +571,19 @@ inline static boolean CheckDrawingArea(int x, int y, int width, int height, if (draw_mask & REDRAW_ALL) return TRUE; +#if 1 + if ((draw_mask & REDRAW_FIELD) && IN_GFX_FIELD_FULL(x, y)) + return TRUE; + + if ((draw_mask & REDRAW_DOOR_1) && IN_GFX_DOOR_1(x, y)) + return TRUE; + + if ((draw_mask & REDRAW_DOOR_2) && IN_GFX_DOOR_2(x, y)) + return TRUE; + + if ((draw_mask & REDRAW_DOOR_3) && IN_GFX_DOOR_3(x, y)) + return TRUE; +#else if ((draw_mask & REDRAW_FIELD) && x >= gfx.real_sx && x < gfx.real_sx + gfx.full_sxsize) return TRUE; @@ -574,6 +595,7 @@ inline static boolean CheckDrawingArea(int x, int y, int width, int height, if ((draw_mask & REDRAW_DOOR_2) && x >= gfx.dx && y >= gfx.vy) return TRUE; +#endif return FALSE; } diff --git a/src/libgame/system.h b/src/libgame/system.h index 9ec6e757..b10232fe 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -317,12 +317,18 @@ #define REDRAWTILES_THRESHOLD 0 #endif -#define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ +#define IN_GFX_FIELD(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ y >= gfx.sy && y < gfx.sy + gfx.sysize) -#define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \ +#define IN_GFX_FIELD_FULL(x, y) (x >= gfx.real_sx && \ + x < gfx.real_sx + gfx.full_sxsize && \ + y >= gfx.real_sy && \ + y < gfx.real_sy + gfx.full_sysize) +#define IN_GFX_DOOR_1(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \ y >= gfx.dy && y < gfx.dy + gfx.dysize) -#define IN_GFX_VIDEO(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \ +#define IN_GFX_DOOR_2(x, y) (x >= gfx.vx && x < gfx.vx + gfx.vxsize && \ y >= gfx.vy && y < gfx.vy + gfx.vysize) +#define IN_GFX_DOOR_3(x, y) (x >= gfx.ex && x < gfx.ex + gfx.exsize && \ + y >= gfx.ey && y < gfx.ey + gfx.eysize) /* values for mouse cursor */ #define CURSOR_DEFAULT 0 @@ -804,6 +810,9 @@ struct GfxInfo int vx, vy; int vxsize, vysize; + int ex, ey; + int exsize, eysize; + int win_xsize, win_ysize; int draw_deactivation_mask; @@ -1274,6 +1283,7 @@ void ClosePlatformDependentStuff(void); void InitGfxFieldInfo(int, int, int, int, int, int, int, int, Bitmap *); void InitGfxDoor1Info(int, int, int, int); void InitGfxDoor2Info(int, int, int, int); +void InitGfxDoor3Info(int, int, int, int); void InitGfxWindowInfo(int, int); void InitGfxScrollbufferInfo(int, int); void InitGfxClipRegion(boolean, int, int, int, int); diff --git a/src/libgame/text.c b/src/libgame/text.c index 69132fa0..b771c1a3 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -361,10 +361,23 @@ void DrawText(int x, int y, char *text, int font_nr) DrawTextExt(drawto, x, y, text, font_nr, mask_mode); +#if 1 + if (IN_GFX_FIELD_FULL(x, y)) + redraw_mask |= REDRAW_FIELD; + else if (IN_GFX_DOOR_1(x, y)) + redraw_mask |= REDRAW_DOOR_1; + else if (IN_GFX_DOOR_2(x, y)) + redraw_mask |= REDRAW_DOOR_2; + else if (IN_GFX_DOOR_3(x, y)) + redraw_mask |= REDRAW_DOOR_3; + else + redraw_mask |= REDRAW_ALL; +#else if (x < gfx.dx) redraw_mask |= REDRAW_FIELD; else if (y < gfx.vy || gfx.vy == 0) redraw_mask |= REDRAW_DOOR_1; +#endif } void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, diff --git a/src/screens.c b/src/screens.c index 4d951f5a..43ad44de 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1914,6 +1914,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) !strEqual(setup.player_name, "Artsoft")) Request("This level is read only!", REQ_CONFIRM); + CloseDoor(DOOR_CLOSE_2); + game_status = GAME_MODE_EDITOR; FadeSetEnterScreen(); diff --git a/src/tools.c b/src/tools.c index 71e6486e..49d42960 100644 --- a/src/tools.c +++ b/src/tools.c @@ -5520,18 +5520,23 @@ void DrawSpecialEditorDoor() { #if 1 struct GraphicInfo *gfx1 = &graphic_info[IMG_DOOR_2_TOP_BORDER_CORRECTION]; + int top_border_width = gfx1->width; + int top_border_height = gfx1->height; int outer_border = viewport.door_2[GAME_MODE_EDITOR].border_size; - - /* draw bigger toolbox window */ - BlitBitmap(gfx1->bitmap, drawto, - gfx1->src_x, gfx1->src_y, gfx1->width, gfx1->height, - EX - outer_border, EY - outer_border - gfx1->height); - BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, - EX - outer_border, VY - outer_border, - EXSIZE + 2 * outer_border, EYSIZE - VYSIZE + outer_border, - EX - outer_border, EY - outer_border); + int ex = EX - outer_border; + int ey = EY - outer_border; + int vy = VY - outer_border; + int exsize = EXSIZE + 2 * outer_border; + + CloseDoor(DOOR_CLOSE_2); + + /* draw bigger level editor toolbox window */ + BlitBitmap(gfx1->bitmap, drawto, gfx1->src_x, gfx1->src_y, + top_border_width, top_border_height, ex, ey - top_border_height); + BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, ex, vy, + exsize, EYSIZE - VYSIZE + outer_border, ex, ey); #else - /* draw bigger toolbox window */ + /* draw bigger level editor toolbox window */ BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8, EX - 4, EY - 12); @@ -5547,15 +5552,30 @@ void UndrawSpecialEditorDoor() { #if 1 struct GraphicInfo *gfx1 = &graphic_info[IMG_DOOR_2_TOP_BORDER_CORRECTION]; + int top_border_width = gfx1->width; + int top_border_height = gfx1->height; int outer_border = viewport.door_2[GAME_MODE_EDITOR].border_size; - int top_border = gfx1->height; + int ex = EX - outer_border; + int ey = EY - outer_border; + int ey_top = ey - top_border_height; + int exsize = EXSIZE + 2 * outer_border; + int eysize = EYSIZE + 2 * outer_border; /* draw normal tape recorder window */ - BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, - EX - outer_border, EY - outer_border - top_border, - EXSIZE + 2 * outer_border, - EYSIZE - VYSIZE + outer_border + top_border, - EX - outer_border, EY - outer_border - top_border); + if (graphic_info[IMG_GLOBAL_BORDER].bitmap) + { + BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + ex, ey_top, top_border_width, top_border_height, + ex, ey_top); + BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + ex, ey, exsize, eysize, ex, ey); + } + else + { + // if screen background is set to "[NONE]", clear editor toolbox window + ClearRectangle(drawto, ex, ey_top, top_border_width, top_border_height); + ClearRectangle(drawto, ex, ey, exsize, eysize); + } #else /* draw normal tape recorder window */ BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, -- 2.34.1