X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Feditor.c;h=12562f7671feb4c9f27e3e949e33845bf17e389f;hp=9396d5eff13053a7a27003c8b14be530745224c0;hb=1be3e5c990b84f8548a80ccd6b7b209a88312141;hpb=b77c449c5eb0d244bd0367746ce45da07b89e38a diff --git a/src/editor.c b/src/editor.c index 9396d5ef..12562f76 100644 --- a/src/editor.c +++ b/src/editor.c @@ -65,8 +65,10 @@ #define ED_ELEMENTLIST_YPOS (editor.palette.y) #define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width) #define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height) -#define ED_ELEMENTLIST_BUTTONS_HORIZ (editor.palette.cols) -#define ED_ELEMENTLIST_BUTTONS_VERT (editor.palette.rows) +#define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols) +#define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows) +#define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS) +#define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS) #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \ ED_ELEMENTLIST_BUTTONS_VERT) @@ -5758,7 +5760,7 @@ static void ReinitializeElementList(void) { // required for correct padding of palette headline buttons if (*editor_elements_info[i].headline_list_size > 0) - num_editor_elements += editor.palette.cols; + num_editor_elements += ED_ELEMENTLIST_COLS; for (j = 0; j < *editor_elements_info[i].headline_list_size; j++) { @@ -5775,8 +5777,8 @@ static void ReinitializeElementList(void) // required for correct padding of palette element buttons int element_list_size = *editor_elements_info[i].element_list_size; int element_rows = - (element_list_size + editor.palette.cols - 1) / editor.palette.cols; - int element_buttons = editor.palette.cols * element_rows; + (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS; + int element_buttons = ED_ELEMENTLIST_COLS * element_rows; num_editor_elements += element_buttons; } @@ -5808,7 +5810,7 @@ static void ReinitializeElementList(void) { // required for correct padding of palette headline buttons int headline_size = (*editor_elements_info[i].headline_list_size > 0 ? - editor.palette.cols : 0); + ED_ELEMENTLIST_COLS : 0); for (j = 0; j < headline_size; j++) { @@ -5830,8 +5832,8 @@ static void ReinitializeElementList(void) // required for correct padding of palette element buttons int element_list_size = *editor_elements_info[i].element_list_size; int element_rows = - (element_list_size + editor.palette.cols - 1) / editor.palette.cols; - int element_buttons = editor.palette.cols * element_rows; + (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS; + int element_buttons = ED_ELEMENTLIST_COLS * element_rows; // copy all elements from element list for (j = 0; j < element_list_size; j++) @@ -8501,29 +8503,31 @@ static boolean useEditorDoorAnimation(void) return (door_1_viewport_unchanged && door_1_contains_toolbox); } +static void DrawEditorDoorBackground(int graphic, int x, int y, + int width, int height) +{ + struct GraphicInfo *g = &graphic_info[graphic]; + + if (g->bitmap != NULL) + BlitBitmap(g->bitmap, drawto, g->src_x, g->src_y, + MIN(width, g->width), MIN(height, g->height), x, y); + else + ClearRectangle(drawto, x, y, width, height); +} + static void DrawEditorDoorContent(void) { // 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); + DrawEditorDoorBackground(IMG_BACKGROUND_PALETTE, DX, DY, DXSIZE, DYSIZE); // 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); + DrawEditorDoorBackground(IMG_BACKGROUND_TOOLBOX, EX, EY, EXSIZE, EYSIZE); // draw all toolbox gadgets to editor doors MapControlButtons(); @@ -8542,7 +8546,7 @@ void DrawLevelEd(void) FadeSoundsAndMusic(); - if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged()) + if (CheckFadeAll()) fade_mask = REDRAW_ALL; FadeOut(fade_mask); @@ -9748,10 +9752,43 @@ static void SetAutomaticNumberOfGemsNeeded(void) { int element = Feld[x][y]; - if (IS_GEM(element) || - element == EL_MM_KETTLE || - element == EL_DF_CELL) - level.gems_needed++; + switch (element) + { + case EL_EMERALD: + case EL_EMERALD_YELLOW: + case EL_EMERALD_RED: + case EL_EMERALD_PURPLE: + case EL_BD_DIAMOND: + case EL_WALL_EMERALD: + case EL_WALL_EMERALD_YELLOW: + case EL_WALL_EMERALD_RED: + case EL_WALL_EMERALD_PURPLE: + case EL_WALL_BD_DIAMOND: + case EL_NUT: + case EL_SP_INFOTRON: + case EL_MM_KETTLE: + case EL_DF_CELL: + level.gems_needed++; + break; + + case EL_DIAMOND: + case EL_WALL_DIAMOND: + level.gems_needed += 3; + break; + + case EL_PEARL: + case EL_WALL_PEARL: + level.gems_needed += 5; + break; + + case EL_CRYSTAL: + case EL_WALL_CRYSTAL: + level.gems_needed += 8; + break; + + default: + break; + } } } @@ -11623,11 +11660,21 @@ static void ResetIntelliDraw(void) static boolean draw_mode_hires = FALSE; +static boolean isHiresTileElement(int element) +{ + return (IS_MM_WALL(element) || element == EL_EMPTY); +} + +static boolean isHiresDrawElement(int element) +{ + return (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY); +} + static void SetDrawModeHiRes(int element) { draw_mode_hires = (level.game_engine_type == GAME_ENGINE_TYPE_MM && - (IS_MM_WALL_EDITOR(element) || element == EL_EMPTY)); + isHiresDrawElement(element)); } static boolean getDrawModeHiRes(void) @@ -12668,9 +12715,13 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) } else if (!button_press_event) { + int old_element = (IN_LEV_FIELD(lx, ly) ? Feld[lx][ly] : EL_UNDEFINED); + boolean hires_drawing = (level.game_engine_type == GAME_ENGINE_TYPE_MM && + isHiresTileElement(old_element) && + isHiresDrawElement(new_element)); + // prevent handling events for every pixel position when moving mouse - if ((sx == last_sx && sy == last_sy && - !IS_MM_WALL_EDITOR(new_element) && new_element != EL_EMPTY) || + if ((sx == last_sx && sy == last_sy && !hires_drawing) || (sx2 == last_sx2 && sy2 == last_sy2)) return; }