X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=2791934f678473d79b61c34a90eb875565adf6dc;hb=1952fc1018a7bde3f04b24485d8f89052e80da14;hp=67ff7203a7daa07ecb965df27e3967de2083647c;hpb=5d406078199b3795eeadb3fc97ca2efa2e4e2e55;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index 67ff7203..2791934f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -3487,6 +3487,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; @@ -4797,7 +4799,7 @@ static int num_editor_el_dynamic = 0; static int editor_hl_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 +6572,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 +6607,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 +6989,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 +7004,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]); } @@ -8524,9 +8532,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 +8612,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;