X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Feditor.c;h=0fb85a1a7fdc0c710f15e71333b11cfafc1ee6a8;hp=fe8df680b12f57ab0b83c4163b6cd70100a21efe;hb=5e616edfe5f101927d2ff3f7a14d2c65897de3cc;hpb=d8f48d3767794442340cb624ec866098766d4d92 diff --git a/src/editor.c b/src/editor.c index fe8df680..0fb85a1a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -24,6 +24,9 @@ #include "tape.h" +#define INFOTEXT_UNKNOWN_ELEMENT "unknown" + + /* ----------------------------------------------------------------------------- screen and artwork graphic pixel position definitions @@ -860,7 +863,7 @@ static struct MIN_ENVELOPE_XSIZE, MAX_ENVELOPE_XSIZE, GADGET_ID_ENVELOPE_XSIZE_DOWN, GADGET_ID_ENVELOPE_XSIZE_UP, GADGET_ID_ENVELOPE_XSIZE_TEXT, GADGET_ID_NONE, - &level.envelope_xsize, + NULL, NULL, NULL, "width", }, { @@ -868,7 +871,7 @@ static struct MIN_ENVELOPE_YSIZE, MAX_ENVELOPE_YSIZE, GADGET_ID_ENVELOPE_YSIZE_DOWN, GADGET_ID_ENVELOPE_YSIZE_UP, GADGET_ID_ENVELOPE_YSIZE_TEXT, GADGET_ID_ENVELOPE_XSIZE_UP, - &level.envelope_ysize, + NULL, NULL, " ", "height", }, @@ -996,7 +999,7 @@ static struct ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(2), GADGET_ID_ENVELOPE_INFO, MAX_ENVELOPE_XSIZE, MAX_ENVELOPE_YSIZE, - level.envelope, + NULL, "Envelope Info:", "Envelope Info" } }; @@ -1999,10 +2002,17 @@ static int editor_el_emerald_mine[] = EL_AMOEBA_WET, EL_AMOEBA_DRY, +#if 1 + EL_EM_KEY_1, + EL_EM_KEY_2, + EL_EM_KEY_3, + EL_EM_KEY_4, +#else EL_EM_KEY_1_FILE, EL_EM_KEY_2_FILE, EL_EM_KEY_3_FILE, EL_EM_KEY_4_FILE, +#endif EL_EM_GATE_1, EL_EM_GATE_2, @@ -2163,7 +2173,11 @@ static int editor_hl_supaplex[] = static int editor_el_supaplex[] = { +#if 1 + EL_EMPTY, +#else EL_SP_EMPTY, +#endif EL_SP_ZONK, EL_SP_BASE, EL_SP_MURPHY, @@ -2279,7 +2293,12 @@ static int editor_el_diamond_caves[] = EL_SWITCHGATE_OPEN, EL_SWITCHGATE_CLOSED, EL_SWITCHGATE_SWITCH_UP, - EL_ENVELOPE, + EL_EMPTY, + + EL_ENVELOPE_1, + EL_ENVELOPE_2, + EL_ENVELOPE_3, + EL_ENVELOPE_4, EL_TIMEGATE_CLOSED, EL_TIMEGATE_OPEN, @@ -2893,14 +2912,81 @@ editor_elements_info[] = ----------------------------------------------------------------------------- */ +static int getMaxInfoTextLength() +{ + return (SXSIZE / getFontWidth(FONT_TEXT_2)); +} + +static int getTextWidthForGadget(char *text) +{ + if (text == NULL) + return 0; + + return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE); +} + +static int getTextWidthForDrawingArea(char *text) +{ + if (text == NULL) + return 0; + + return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE); +} + +static int getRightGadgetBorder(struct GadgetInfo *gi, char *text) +{ + return (gi->x + gi->width + getTextWidthForGadget(text)); +} + +static char *getElementInfoText(int element) +{ + char *info_text = NULL; + + if (element < NUM_FILE_ELEMENTS) + { + if (strlen(element_info[element].description) > 0) + info_text = element_info[element].description; + else if (element_info[element].custom_description != NULL) + info_text = element_info[element].custom_description; + else if (element_info[element].editor_description != NULL) + info_text = element_info[element].editor_description; + } + + if (info_text == NULL) + info_text = INFOTEXT_UNKNOWN_ELEMENT; + + return info_text; +} + static void ReinitializeElementList() { + static boolean initialized = FALSE; int pos = 0; int i, j; if (editor_elements != NULL) free(editor_elements); + /* do some sanity check for each element from element list at startup */ + if (!initialized) + { + for (i=0; editor_elements_info[i].setup_value != NULL; i++) + { + for (j=0; j < *editor_elements_info[i].element_list_size; j++) + { + int element = editor_elements_info[i].element_list[j]; + + if (element >= NUM_FILE_ELEMENTS) + Error(ERR_WARN, "editor element %d is runtime element", element); + + if (strcmp(getElementInfoText(element), INFOTEXT_UNKNOWN_ELEMENT) == 0) + Error(ERR_WARN, "no element description for element %d", element); + } + } + + initialized = TRUE; + } + num_editor_elements = 0; /* determine size of element list */ @@ -2979,56 +3065,6 @@ static void ReinitializeElementListButtons() initialization_needed = FALSE; } -static int getMaxInfoTextLength() -{ - return (SXSIZE / getFontWidth(FONT_TEXT_2)); -} - -static int getTextWidthForGadget(char *text) -{ - if (text == NULL) - return 0; - - return (getTextWidth(text, FONT_TEXT_1) + ED_GADGET_TEXT_DISTANCE); -} - -static int getTextWidthForDrawingArea(char *text) -{ - if (text == NULL) - return 0; - - return (getTextWidth(text, FONT_TEXT_1) + ED_DRAWINGAREA_TEXT_DISTANCE); -} - -static int getRightGadgetBorder(struct GadgetInfo *gi, char *text) -{ - return (gi->x + gi->width + getTextWidthForGadget(text)); -} - -static char *getElementInfoText(int element) -{ - char *info_text = NULL; - - if (element < NUM_FILE_ELEMENTS) - { - if (strlen(element_info[element].description) > 0) - info_text = element_info[element].description; - else if (element_info[element].custom_description != NULL) - info_text = element_info[element].custom_description; - else if (element_info[element].editor_description != NULL) - info_text = element_info[element].editor_description; - } - - if (info_text == NULL) - { - info_text = "unknown"; - - Error(ERR_WARN, "no element description for element %d", element); - } - - return info_text; -} - static void DrawElementBorder(int dest_x, int dest_y, int width, int height, boolean input) { @@ -3285,7 +3321,7 @@ static void CreateControlButtons() } /* create buttons for element list */ - for (i=0; ix, gi->y, gi->width, gi->height); - ModifyGadget(gi, GDI_AREA_SIZE, level.envelope_xsize, level.envelope_ysize, + if (envelope_nr != -1) + textarea_info[id].value = level.envelope_text[envelope_nr]; + + ModifyGadget(gi, GDI_AREA_SIZE, + *counterbutton_info[ED_COUNTER_ID_ENVELOPE_XSIZE].value, + *counterbutton_info[ED_COUNTER_ID_ENVELOPE_YSIZE].value, GDI_END); + MapTextAreaGadget(ED_TEXTAREA_ID_ENVELOPE_INFO); } @@ -5467,10 +5509,17 @@ static struct { EL_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING }, { EL_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING }, { EL_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING }, +#if 1 + { EL_EM_KEY_1, &level.score[SC_KEY], TEXT_COLLECTING }, + { EL_EM_KEY_2, &level.score[SC_KEY], TEXT_COLLECTING }, + { EL_EM_KEY_3, &level.score[SC_KEY], TEXT_COLLECTING }, + { EL_EM_KEY_4, &level.score[SC_KEY], TEXT_COLLECTING }, +#else { EL_EM_KEY_1_FILE, &level.score[SC_KEY], TEXT_COLLECTING }, { EL_EM_KEY_2_FILE, &level.score[SC_KEY], TEXT_COLLECTING }, { EL_EM_KEY_3_FILE, &level.score[SC_KEY], TEXT_COLLECTING }, { EL_EM_KEY_4_FILE, &level.score[SC_KEY], TEXT_COLLECTING }, +#endif { EL_AMOEBA_WET, &level.amoeba_speed, TEXT_SPEED }, { EL_AMOEBA_DRY, &level.amoeba_speed, TEXT_SPEED }, { EL_AMOEBA_FULL, &level.amoeba_speed, TEXT_SPEED }, @@ -5486,8 +5535,8 @@ static boolean checkPropertiesConfig() if (IS_GEM(properties_element) || IS_CUSTOM_ELEMENT(properties_element) || - HAS_CONTENT(properties_element) || - properties_element == EL_ENVELOPE) + IS_ENVELOPE(properties_element) || + HAS_CONTENT(properties_element)) return TRUE; else for (i=0; elements_with_counter[i].element != -1; i++) @@ -5539,13 +5588,20 @@ static void DrawPropertiesConfig() if (IS_GEM(properties_element)) MapCheckbuttonGadget(ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS); - if (properties_element == EL_ENVELOPE) + if (IS_ENVELOPE(properties_element)) { + int counter1_id = ED_COUNTER_ID_ENVELOPE_XSIZE; + int counter2_id = ED_COUNTER_ID_ENVELOPE_YSIZE; + int envelope_nr = properties_element - EL_ENVELOPE_1; + + counterbutton_info[counter1_id].value = &level.envelope_xsize[envelope_nr]; + counterbutton_info[counter2_id].value = &level.envelope_ysize[envelope_nr]; + /* display counter to choose size of envelope text area */ MapCounterButtons(ED_COUNTER_ID_ENVELOPE_XSIZE); MapCounterButtons(ED_COUNTER_ID_ENVELOPE_YSIZE); - DrawEnvelopeTextArea(); + DrawEnvelopeTextArea(envelope_nr); } if (IS_CUSTOM_ELEMENT(properties_element)) @@ -6661,7 +6717,7 @@ static void HandleCounterButtons(struct GadgetInfo *gi) case ED_COUNTER_ID_ENVELOPE_XSIZE: case ED_COUNTER_ID_ENVELOPE_YSIZE: - DrawEnvelopeTextArea(); + DrawEnvelopeTextArea(-1); break; case ED_COUNTER_ID_LEVEL_XSIZE: