X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Feditor.c;h=9ce3bd5b1369f4b622be84da24beb02da8af7865;hp=67ff7203a7daa07ecb965df27e3967de2083647c;hb=abe44529b439ad39b4d8dbf19cbd67c9b9844279;hpb=5d406078199b3795eeadb3fc97ca2efa2e4e2e55 diff --git a/src/editor.c b/src/editor.c index 67ff7203..9ce3bd5b 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1,15 +1,13 @@ -/*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * -*----------------------------------------------------------* -* (c) 1995-2006 Artsoft Entertainment * -* Holger Schemel * -* Detmolder Strasse 189 * -* 33604 Bielefeld * -* Germany * -* e-mail: info@artsoft.org * -*----------------------------------------------------------* -* editor.c * -***********************************************************/ +// ============================================================================ +// Rocks'n'Diamonds - McDuffin Strikes Back! +// ---------------------------------------------------------------------------- +// (c) 1995-2014 by Artsoft Entertainment +// Holger Schemel +// info@artsoft.org +// http://www.artsoft.org/ +// ---------------------------------------------------------------------------- +// editor.c +// ============================================================================ #include @@ -3487,6 +3485,8 @@ static void HandleControlButtons(struct GadgetInfo *); static void HandleDrawingAreaInfo(struct GadgetInfo *); static void PrintEditorGadgetInfoText(struct GadgetInfo *); +static int num_editor_gadgets = 0; /* dynamically determined */ + #if 1 static struct GadgetInfo **level_editor_gadget = NULL; static int *right_gadget_border = NULL; @@ -4795,9 +4795,9 @@ static int *editor_el_dynamic_ptr = NULL; static int num_editor_hl_dynamic = SIZEOF_ARRAY_INT(editor_hl_dynamic); static int num_editor_el_dynamic = 0; -static int editor_hl_empty[] = { }; +static int editor_hl_empty[] = { EL_EMPTY }; #if 1 -static int *editor_el_empty = NULL; +static int *editor_el_empty = NULL; /* dynamically allocated */ #else static int editor_el_empty[ED_NUM_ELEMENTLIST_BUTTONS]; #endif @@ -6570,10 +6570,14 @@ void CreateLevelEditorGadgets() ed_fieldx = MAX_ED_FIELDX - 1; ed_fieldy = MAX_ED_FIELDY - 1; + num_editor_gadgets = NUM_EDITOR_GADGETS; + + // printf("::: allocating %d gadgets ...\n", num_editor_gadgets); + level_editor_gadget = - checked_calloc(NUM_EDITOR_GADGETS * sizeof(struct GadgetInfo *)); + checked_calloc(num_editor_gadgets * sizeof(struct GadgetInfo *)); right_gadget_border = - checked_calloc(NUM_EDITOR_GADGETS * sizeof(int)); + checked_calloc(num_editor_gadgets * sizeof(int)); editor_el_empty = checked_calloc(ED_NUM_ELEMENTLIST_BUTTONS * sizeof(int)); editor_el_empty_ptr = editor_el_empty; @@ -6601,7 +6605,9 @@ void FreeLevelEditorGadgets() { int i; - for (i = 0; i < NUM_EDITOR_GADGETS; i++) + // printf("::: freeing %d gadgets ...\n", num_editor_gadgets); + + for (i = 0; i < num_editor_gadgets; i++) { FreeGadget(level_editor_gadget[i]); @@ -6981,7 +6987,7 @@ static void UnmapLevelEditorFieldGadgets() int i; #if 1 - for (i = 0; i < NUM_EDITOR_GADGETS; i++) + 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]); @@ -6996,7 +7002,7 @@ void UnmapLevelEditorGadgets() { int i; - for (i = 0; i < NUM_EDITOR_GADGETS; i++) + for (i = 0; i < num_editor_gadgets; i++) UnmapGadget(level_editor_gadget[i]); } @@ -7735,14 +7741,27 @@ void CheckElementDescriptions() Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i)); } +static boolean playfield_area_changed = FALSE; + void DrawLevelEd() { + int old_sx = SX; + int old_sy = SY; + int old_sxsize = SXSIZE; + int old_sysize = SYSIZE; + StopAnimation(); CloseDoor(DOOR_CLOSE_ALL); #if 1 FadeOut(REDRAW_FIELD); + // FadeOut(REDRAW_ALL); +#endif + +#if 1 + /* needed after playing if editor playfield area has different size */ + ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); #endif #if 1 @@ -7750,7 +7769,27 @@ void DrawLevelEd() ChangeViewportPropertiesIfNeeded(); #endif + if (old_sx != SX || + old_sy != SY || + old_sxsize != SXSIZE || + old_sysize != SYSIZE) + { + playfield_area_changed = TRUE; + +#if 0 + printf("::: %d, %d, %d, %d != %d, %d, %d, %d\n", + old_sx, old_sy, old_sxsize, old_sysize, + SX, SY, SXSIZE, SYSIZE); +#endif + } + else + playfield_area_changed = FALSE; + +#if 1 + OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY); +#else OpenDoor(DOOR_OPEN_2 | DOOR_NO_DELAY); +#endif #if DEBUG CheckElementDescriptions(); @@ -7823,20 +7862,29 @@ void DrawLevelEd() DrawEditModeWindow(); #if 1 + FadeIn(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD); +#else FadeIn(REDRAW_FIELD); + // FadeIn(REDRAW_ALL); #endif /* copy actual editor door content to door double buffer for OpenDoor() */ +#if 1 + BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0); +#else BlitBitmap(drawto, bitmap_db_door, DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); +#endif -#if 1 +#if 0 /* draw new control window (with border) to window */ redraw_mask |= REDRAW_ALL; BackToFront(); #endif +#if 0 OpenDoor(DOOR_OPEN_1); +#endif } static void AdjustDrawingAreaGadgets() @@ -8524,9 +8572,23 @@ static int PrintElementDescriptionFromFile(char *filename, int start_line) int sy = SY + pad_y + start_line * font_height; int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width; int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1; + int max_lines_drawable = max_lines_per_screen - start_line; + +#if 0 + printf("::: SYSIZE == %d [%d / %d / %d]\n", SYSIZE, + max_chars_per_line, max_lines_per_screen, max_lines_drawable); +#endif + + if (start_line >= max_lines_per_screen) + return FALSE; +#if 1 + return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1, + max_lines_drawable, 0, -1, TRUE, FALSE, FALSE); +#else return DrawTextFile(sx, sy, filename, font_nr, max_chars_per_line, -1, max_lines_per_screen, 0, -1, TRUE, FALSE, FALSE); +#endif } static void DrawPropertiesInfo() @@ -8590,8 +8652,8 @@ static void DrawPropertiesInfo() { -1, NULL } }; char *filename = getElementDescriptionFilename(properties_element); - char *percentage_text = "In this level:"; - char *properties_text = "Standard properties:"; + char *percentage_text = "In this level: "; + char *properties_text = "Standard properties: "; float percentage; int num_elements_in_level; int num_standard_properties = 0; @@ -11872,7 +11934,16 @@ static void HandleControlButtons(struct GadgetInfo *gi) CloseDoor(DOOR_CLOSE_ALL); +#if 0 BackToFront(); /* force redraw of undrawn special door */ +#endif + +#if 1 + /* needed before playing if editor playfield area has different size */ + ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + + redraw_mask = REDRAW_ALL; +#endif #if 0 DrawCompleteVideoDisplay(); @@ -12354,8 +12425,13 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed, Request("Level has changed! Exit without saving?", REQ_ASK | REQ_STAY_OPEN)) { +#if 1 + // CloseDoor(DOOR_CLOSE_1); + SetDoorState(DOOR_CLOSE_2); +#else CloseDoor(DOOR_CLOSE_1); SetDoorState(DOOR_CLOSE_2); +#endif #if 1 if (quick_quit) @@ -12366,15 +12442,24 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed, #endif game_status = GAME_MODE_MAIN; +#if 1 + DrawAndFadeInMainMenu(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD); +#else #if 1 DrawAndFadeInMainMenu(REDRAW_FIELD); #else DrawMainMenu(); +#endif #endif } else { +#if 1 + // CloseDoor(DOOR_CLOSE_1); + OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); +#else CloseDoor(DOOR_CLOSE_1); OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); +#endif } }