X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=42926f06e77f695bccaa90b349a43b4985788764;hb=5a5342a6ab48037839b783adc4f3304331834a8c;hp=15a3b692ddc8b9464bdf84bf3417a1f9ec8b0385;hpb=5f926b2dd808d7336f7ec63499fb0776e8513e97;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index 15a3b692..42926f06 100644 --- a/src/editor.c +++ b/src/editor.c @@ -292,11 +292,14 @@ #define GADGET_ID_EM_SLIPPERY_GEMS 77 #define GADGET_ID_CUSTOM_INDESTRUCTIBLE 78 #define GADGET_ID_CUSTOM_CAN_FALL 79 -#define GADGET_ID_CUSTOM_SLIPPERY 80 +#define GADGET_ID_CUSTOM_CAN_SMASH 80 +#define GADGET_ID_CUSTOM_PUSHABLE 81 +#define GADGET_ID_CUSTOM_SLIPPERY 82 /* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST 81 -#define GADGET_ID_ELEMENTLIST_LAST (81 + ED_NUM_ELEMENTLIST_BUTTONS - 1) +#define GADGET_ID_ELEMENTLIST_FIRST 83 +#define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \ + ED_NUM_ELEMENTLIST_BUTTONS - 1) #define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1) @@ -361,13 +364,18 @@ #define ED_CHECKBUTTON_ID_EM_SLIPPERY_GEMS 4 #define ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE 5 #define ED_CHECKBUTTON_ID_CUSTOM_CAN_FALL 6 -#define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 7 +#define ED_CHECKBUTTON_ID_CUSTOM_CAN_SMASH 7 +#define ED_CHECKBUTTON_ID_CUSTOM_PUSHABLE 8 +#define ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY 9 -#define ED_NUM_CHECKBUTTONS 8 +#define ED_NUM_CHECKBUTTONS 10 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED +#define ED_CHECKBUTTON_ID_CUSTOM_FIRST ED_CHECKBUTTON_ID_CUSTOM_INDESTRUCTIBLE +#define ED_CHECKBUTTON_ID_CUSTOM_LAST ED_CHECKBUTTON_ID_CUSTOM_SLIPPERY + /* values for radiobutton gadgets */ #define ED_RADIOBUTTON_ID_PERCENTAGE 0 #define ED_RADIOBUTTON_ID_QUANTITY 1 @@ -386,7 +394,6 @@ #define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2) #define INFOTEXT_XSIZE SXSIZE #define INFOTEXT_YSIZE MINI_TILEX -#define MAX_INFOTEXT_LEN (SXSIZE / FONT2_XSIZE) static struct { @@ -394,28 +401,28 @@ static struct char *text; } control_info[ED_NUM_CTRL_BUTTONS] = { - { 's', "draw single items" }, - { 'd', "draw connected items" }, - { 'l', "draw lines" }, - { 'a', "draw arcs" }, - { 'r', "draw outline rectangles" }, - { 'R', "draw filled rectangles" }, - { '\0', "wrap (rotate) level up" }, - { 't', "enter text elements" }, - { 'f', "flood fill" }, - { '\0', "wrap (rotate) level left" }, - { '?', "properties of drawing element" }, - { '\0', "wrap (rotate) level right" }, - { '\0', "random element placement" }, - { 'b', "grab brush" }, - { '\0', "wrap (rotate) level down" }, - { ',', "pick drawing element" }, - { 'U', "undo last operation" }, - { 'I', "level properties" }, - { 'S', "save level" }, - { 'C', "clear level" }, - { 'T', "test level" }, - { 'E', "exit level editor" } + { 's', "draw single items" }, + { 'd', "draw connected items" }, + { 'l', "draw lines" }, + { 'a', "draw arcs" }, + { 'r', "draw outline rectangles" }, + { 'R', "draw filled rectangles" }, + { '\0', "wrap (rotate) level up" }, + { 't', "enter text elements" }, + { 'f', "flood fill" }, + { '\0', "wrap (rotate) level left" }, + { '?', "properties of drawing element" }, + { '\0', "wrap (rotate) level right" }, + { '\0', "random element placement" }, + { 'b', "grab brush" }, + { '\0', "wrap (rotate) level down" }, + { ',', "pick drawing element" }, + { 'U', "undo last operation" }, + { 'I', "level properties" }, + { 'S', "save level" }, + { 'C', "clear level" }, + { 'T', "test level" }, + { 'E', "exit level editor" } }; /* values for random placement */ @@ -432,6 +439,8 @@ static struct { boolean indestructible; boolean can_fall; + boolean can_smash; + boolean pushable; boolean slippery; } custom_element_properties[NUM_CUSTOM_ELEMENTS]; @@ -704,6 +713,18 @@ static struct }, { ED_SETTINGS_XPOS, ED_COUNTER_YPOS(6), + GADGET_ID_CUSTOM_CAN_SMASH, + &custom_element_properties[0].can_smash, + "can smash", "element can smash other elements" + }, + { + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(7), + GADGET_ID_CUSTOM_PUSHABLE, + &custom_element_properties[0].pushable, + "pushable", "element can be pushed" + }, + { + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(8), GADGET_ID_CUSTOM_SLIPPERY, &custom_element_properties[0].slippery, "slippery", "other elements can fall down from it" @@ -762,11 +783,9 @@ static int undo_buffer_steps = 0; static int edit_mode; -static int counter_xsize = DXSIZE + FONT2_XSIZE - 2 * ED_GADGET_DISTANCE; - -int element_shift = 0; +static int element_shift = 0; -int editor_el_boulderdash[] = +static int editor_el_boulderdash[] = { EL_CHAR('B'), EL_CHAR('O'), @@ -808,9 +827,9 @@ int editor_el_boulderdash[] = EL_BD_FIREFLY_DOWN, EL_EMPTY, }; -int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash); +static int num_editor_el_boulderdash = SIZEOF_ARRAY_INT(editor_el_boulderdash); -int editor_el_emerald_mine[] = +static int editor_el_emerald_mine[] = { EL_CHAR('E'), EL_CHAR('M'), @@ -902,9 +921,9 @@ int editor_el_emerald_mine[] = EL_EM_GATE3_GRAY, EL_EM_GATE4_GRAY, }; -int num_editor_el_emerald_mine = SIZEOF_ARRAY_INT(editor_el_emerald_mine); +static int num_editor_el_emerald_mine = SIZEOF_ARRAY_INT(editor_el_emerald_mine); -int editor_el_more[] = +static int editor_el_more[] = { EL_CHAR('M'), EL_CHAR('O'), @@ -926,10 +945,10 @@ int editor_el_more[] = EL_GATE3_GRAY, EL_GATE4_GRAY, - EL_ARROW_BLUE_LEFT, - EL_ARROW_BLUE_RIGHT, - EL_ARROW_BLUE_UP, - EL_ARROW_BLUE_DOWN, + EL_ARROW_LEFT, + EL_ARROW_RIGHT, + EL_ARROW_UP, + EL_ARROW_DOWN, EL_AMOEBA_FULL, EL_EMERALD_YELLOW, @@ -1006,9 +1025,9 @@ int editor_el_more[] = EL_EMC_WALL6, EL_EMC_WALL7, }; -int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more); +static int num_editor_el_more = SIZEOF_ARRAY_INT(editor_el_more); -int editor_el_sokoban[] = +static int editor_el_sokoban[] = { EL_CHAR('S'), EL_CHAR('O'), @@ -1025,9 +1044,9 @@ int editor_el_sokoban[] = EL_SOKOBAN_FIELD_FULL, EL_STEELWALL, }; -int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban); +static int num_editor_el_sokoban = SIZEOF_ARRAY_INT(editor_el_sokoban); -int editor_el_supaplex[] = +static int editor_el_supaplex[] = { EL_CHAR('S'), EL_CHAR('U'), @@ -1089,9 +1108,9 @@ int editor_el_supaplex[] = EL_SP_CHIP_UPPER, EL_SP_CHIP_LOWER, }; -int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex); +static int num_editor_el_supaplex = SIZEOF_ARRAY_INT(editor_el_supaplex); -int editor_el_diamond_caves[] = +static int editor_el_diamond_caves[] = { EL_CHAR('D'), EL_CHAR('I'), @@ -1173,9 +1192,9 @@ int editor_el_diamond_caves[] = EL_EXTRA_TIME, EL_EMPTY, }; -int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves); +static int num_editor_el_diamond_caves = SIZEOF_ARRAY_INT(editor_el_diamond_caves); -int editor_el_dx_boulderdash[] = +static int editor_el_dx_boulderdash[] = { EL_CHAR('D'), EL_CHAR('X'), @@ -1217,9 +1236,9 @@ int editor_el_dx_boulderdash[] = EL_EMPTY, EL_EMPTY }; -int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash); +static int num_editor_el_dx_boulderdash = SIZEOF_ARRAY_INT(editor_el_dx_boulderdash); -int editor_el_chars[] = +static int editor_el_chars[] = { EL_CHAR('T'), EL_CHAR('E'), @@ -1311,9 +1330,9 @@ int editor_el_chars[] = EL_CHAR('ยด'), EL_CHAR('|') }; -int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars); +static int num_editor_el_chars = SIZEOF_ARRAY_INT(editor_el_chars); -int editor_el_custom[] = +static int editor_el_custom[] = { EL_CHAR('C'), EL_CHAR('U'), @@ -1495,12 +1514,12 @@ int editor_el_custom[] = EL_CUSTOM_START + 126, EL_CUSTOM_START + 127 }; -int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom); +static int num_editor_el_custom = SIZEOF_ARRAY_INT(editor_el_custom); -int *editor_elements = NULL; /* dynamically allocated */ -int num_editor_elements = 0; /* dynamically determined */ +static int *editor_elements = NULL; /* dynamically allocated */ +static int num_editor_elements = 0; /* dynamically determined */ -struct +static struct { boolean *setup_value; int *element_list; @@ -1590,6 +1609,16 @@ static void ReinitializeElementListButtons() initialization_needed = FALSE; } +static int getCounterGadgetWidth() +{ + return (DXSIZE + getFontWidth(FONT_INPUT) - 2 * ED_GADGET_DISTANCE); +} + +static int getMaxInfoTextLength() +{ + return (SXSIZE / getFontWidth(FONT_TEXT_2)); +} + static char *getElementInfoText(int element) { char *info_text = NULL; @@ -1855,6 +1884,7 @@ static void CreateControlButtons() static void CreateCounterButtons() { + int max_infotext_len = getMaxInfoTextLength(); int i; for (i=0; icustom_type_id].value ^= TRUE; + int type_id = gi->custom_type_id; + + *checkbutton_info[type_id].value ^= TRUE; + + if (type_id >= ED_CHECKBUTTON_ID_CUSTOM_FIRST && + type_id <= ED_CHECKBUTTON_ID_CUSTOM_LAST) + CopyCustomElementPropertiesToGame(); } static void HandleControlButtons(struct GadgetInfo *gi) @@ -4255,9 +4372,8 @@ static void HandleControlButtons(struct GadgetInfo *gi) { if (Request("Save this level and kill the old ?", REQ_ASK)) { - for(x=0; xinfo_text == NULL) return; - strncpy(infotext, gi->info_text, MAX_INFOTEXT_LEN); - infotext[MAX_INFOTEXT_LEN] = '\0'; + strncpy(infotext, gi->info_text, max_infotext_len); + infotext[max_infotext_len] = '\0'; if (gi->custom_id < ED_NUM_CTRL_BUTTONS) { @@ -4499,12 +4587,12 @@ void HandleEditorGadgetInfoText(void *ptr) sprintf(shortcut, " ('%s%c')", (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key); - if (strlen(infotext) + strlen(shortcut) <= MAX_INFOTEXT_LEN) + if (strlen(infotext) + strlen(shortcut) <= max_infotext_len) strcat(infotext, shortcut); } } - DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FS_SMALL, FC_YELLOW); + DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FONT_TEXT_2); } static void HandleDrawingAreaInfo(struct GadgetInfo *gi) @@ -4598,18 +4686,18 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) } if (drawing_function == GADGET_ID_PICK_ELEMENT) - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s: %d, %d", infotext, lx, ly); else - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s: %d, %d", infotext, ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1); } else if (drawing_function == GADGET_ID_PICK_ELEMENT) - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "%s", getElementInfoText(Feld[lx][ly])); else - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "Level position: %d, %d", lx, ly); } @@ -4623,13 +4711,13 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) } } else if (id == GADGET_ID_AMOEBA_CONTENT) - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "Amoeba content"); else if (id == GADGET_ID_RANDOM_BACKGROUND) - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "Random placement background"); else - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "Content area %d position: %d, %d", id - GADGET_ID_ELEM_CONTENT_0 + 1, sx, sy); }