X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=725badd7b65cc5443a6d5317aea742f29604c3b7;hb=c903bd8cfb145b91de8a39204ea207ad0f5a3b49;hp=728ff1d71319fa680751f165b45d7545fa7daed6;hpb=f7165d318c089b77d0a91a77afc44cb8866dc1cc;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index 728ff1d7..725badd7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -31,42 +31,7 @@ ----------------------------------------------------------------------------- */ -/* positions in the level editor */ -#define ED_WIN_MB_LEFT_XPOS (editor.palette.element_left.x) -#define ED_WIN_MB_LEFT_YPOS (editor.palette.element_left.y) -#define ED_WIN_MB_MIDDLE_XPOS (editor.palette.element_middle.x) -#define ED_WIN_MB_MIDDLE_YPOS (editor.palette.element_middle.y) -#define ED_WIN_MB_RIGHT_XPOS (editor.palette.element_right.x) -#define ED_WIN_MB_RIGHT_YPOS (editor.palette.element_right.y) - /* values for the control window */ -#define ED_CTRL_NO_BUTTONS_GFX_XPOS 6 -#define ED_CTRL_NO_BUTTONS_GFX_YPOS 286 -#define ED_CTRL1_BUTTONS_GFX_YPOS 236 -#define ED_CTRL2_BUTTONS_GFX_YPOS 236 -#define ED_CTRL3_BUTTONS_GFX_YPOS 324 -#define ED_CTRL4_BUTTONS_GFX_XPOS 44 -#define ED_CTRL4_BUTTONS_GFX_YPOS 214 -#define ED_CTRL1_BUTTONS_ALT_GFX_YPOS 142 -#define ED_CTRL3_BUTTONS_ALT_GFX_YPOS 302 - -#define ED_CTRL1_BUTTON_XSIZE 22 -#define ED_CTRL1_BUTTON_YSIZE 22 -#define ED_CTRL1_BUTTONS_XPOS 6 -#define ED_CTRL1_BUTTONS_YPOS 6 -#define ED_CTRL2_BUTTON_XSIZE 30 -#define ED_CTRL2_BUTTON_YSIZE 20 -#define ED_CTRL2_BUTTONS_XPOS 5 -#define ED_CTRL2_BUTTONS_YPOS 99 -#define ED_CTRL3_BUTTON_XSIZE 22 -#define ED_CTRL3_BUTTON_YSIZE 22 -#define ED_CTRL3_BUTTONS_XPOS 6 -#define ED_CTRL3_BUTTONS_YPOS 6 -#define ED_CTRL4_BUTTON_XSIZE 22 -#define ED_CTRL4_BUTTON_YSIZE 22 -#define ED_CTRL4_BUTTONS_XPOS 6 -#define ED_CTRL4_BUTTONS_YPOS 6 - #define ED_CTRL1_BUTTONS_HORIZ 4 #define ED_CTRL1_BUTTONS_VERT 4 #define ED_CTRL2_BUTTONS_HORIZ 3 @@ -75,23 +40,24 @@ #define ED_CTRL3_BUTTONS_VERT 1 #define ED_CTRL4_BUTTONS_HORIZ 2 #define ED_CTRL4_BUTTONS_VERT 1 +#define ED_CTRL5_BUTTONS_HORIZ 1 +#define ED_CTRL5_BUTTONS_VERT 1 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT) #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT) #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT) #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT) +#define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT) #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS) #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS) -#define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + \ - ED_NUM_CTRL2_BUTTONS + \ - ED_NUM_CTRL3_BUTTONS + \ - ED_NUM_CTRL4_BUTTONS) +#define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS) +#define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS) /* values for the element list */ #define ED_ELEMENTLIST_XPOS (editor.palette.x) #define ED_ELEMENTLIST_YPOS (editor.palette.y) -#define ED_ELEMENTLIST_XSIZE 20 -#define ED_ELEMENTLIST_YSIZE 20 +#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_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \ @@ -101,6 +67,8 @@ #define ED_BORDER_SIZE 3 #define ED_BORDER_TEXT_XSIZE 5 #define ED_BORDER_AREA_YSIZE 1 +#define ED_ELEMENT_BORDER 8 +#define ED_ELEMENT_BORDER_INPUT 4 #define ED_GADGET_DISTANCE 2 #define ED_GADGET_TEXT_DISTANCE (2 * ED_GADGET_DISTANCE) @@ -208,8 +176,8 @@ #define ED_SCROLLBAR2_XPOS 50 #define ED_SCROLLBAR2_YPOS 20 -#define ED_SCROLLBUTTON2_XSIZE 10 -#define ED_SCROLLBUTTON2_YSIZE 10 +#define ED_SCROLLBUTTON2_XSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].width) +#define ED_SCROLLBUTTON2_YSIZE (graphic_info[IMG_EDITOR_PALETTE_SCROLL_UP].height) #define ED_SCROLL2_UP_XPOS (ED_ELEMENTLIST_XPOS + \ ED_ELEMENTLIST_BUTTONS_HORIZ * \ @@ -251,10 +219,6 @@ #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS #define ED_WIN_COUNT_XSIZE 52 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE -#define ED_WIN_COUNT2_XPOS 27 -#define ED_WIN_COUNT2_YPOS 3 -#define ED_WIN_COUNT2_XSIZE 46 -#define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE #define ED_BUTTON_MINUS_XPOS 2 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS @@ -315,7 +279,7 @@ #define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7) #define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8) #define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9) -#define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10) +#define GADGET_ID_ZOOM (GADGET_ID_TOOLBOX_FIRST + 10) #define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11) #define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12) #define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13) @@ -335,8 +299,10 @@ #define GADGET_ID_CUSTOM_COPY (GADGET_ID_TOOLBOX_FIRST + 25) #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26) +#define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 27) + /* counter gadget identifiers */ -#define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 27) +#define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 28) #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0) #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1) @@ -983,43 +949,168 @@ static struct { + int graphic; + int gadget_id; + struct XY *pos; + int gadget_type; + char *infotext; char shortcut; - char *text; -} control_info[ED_NUM_CTRL_BUTTONS] = +} controlbutton_info[ED_NUM_CTRL_BUTTONS] = { /* note: some additional characters are already reserved for "cheat mode" shortcuts (":XYZ" style) -- for details, see "events.c" */ - { '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', "properties of level" }, - { 'S', "save level" }, - { 'C', "clear level" }, - { 'T', "test level" }, - { 'E', "exit level editor" }, - - { '\0', "copy settings from other element" }, - { '\0', "copy settings to other element" }, - { '\0', "exchange element with other element" }, - - { '\0', "copy settings from this element" }, - { '\0', "paste settings to this element" }, + /* ---------- toolbox control buttons ------------------------------------ */ + + { + IMG_EDITOR_BUTTON_GFX_DRAW_SINGLE, GADGET_ID_SINGLE_ITEMS, + &editor.button.draw_single, GD_TYPE_RADIO_BUTTON, + "draw single items", 's' + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_CONNECTED, GADGET_ID_CONNECTED_ITEMS, + &editor.button.draw_connected, GD_TYPE_RADIO_BUTTON, + "draw connected items", 'd' + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_LINE, GADGET_ID_LINE, + &editor.button.draw_line, GD_TYPE_RADIO_BUTTON, + "draw lines", 'l' + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_ARC, GADGET_ID_ARC, + &editor.button.draw_arc, GD_TYPE_RADIO_BUTTON, + "draw arcs", 'a' + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_RECTANGLE, GADGET_ID_RECTANGLE, + &editor.button.draw_rectangle, GD_TYPE_RADIO_BUTTON, + "draw outline rectangles", 'r' + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_FILLED_BOX, GADGET_ID_FILLED_BOX, + &editor.button.draw_filled_box, GD_TYPE_RADIO_BUTTON, + "draw filled rectangles", 'R' + }, + { + IMG_EDITOR_BUTTON_GFX_ROTATE_UP, GADGET_ID_WRAP_UP, + &editor.button.rotate_up, GD_TYPE_NORMAL_BUTTON, + "wrap (rotate) level up", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_TEXT, GADGET_ID_TEXT, + &editor.button.draw_text, GD_TYPE_RADIO_BUTTON, + "enter text elements", 't' + }, + { + IMG_EDITOR_BUTTON_GFX_FLOOD_FILL, GADGET_ID_FLOOD_FILL, + &editor.button.flood_fill, GD_TYPE_RADIO_BUTTON, + "flood fill", 'f' + }, + { + IMG_EDITOR_BUTTON_GFX_ROTATE_LEFT, GADGET_ID_WRAP_LEFT, + &editor.button.rotate_left, GD_TYPE_NORMAL_BUTTON, + "wrap (rotate) level left", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_ZOOM_LEVEL, GADGET_ID_ZOOM, + &editor.button.zoom_level, GD_TYPE_NORMAL_BUTTON, + "zoom level tile size", 'z' + }, + { + IMG_EDITOR_BUTTON_GFX_ROTATE_RIGHT, GADGET_ID_WRAP_RIGHT, + &editor.button.rotate_right, GD_TYPE_NORMAL_BUTTON, + "wrap (rotate) level right", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_DRAW_RANDOM, GADGET_ID_RANDOM_PLACEMENT, + &editor.button.draw_random, GD_TYPE_NORMAL_BUTTON, + "random element placement", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_GRAB_BRUSH, GADGET_ID_GRAB_BRUSH, + &editor.button.grab_brush, GD_TYPE_RADIO_BUTTON, + "grab brush", 'b' + }, + { + IMG_EDITOR_BUTTON_GFX_ROTATE_DOWN, GADGET_ID_WRAP_DOWN, + &editor.button.rotate_down, GD_TYPE_NORMAL_BUTTON, + "wrap (rotate) level down", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_PICK_ELEMENT, GADGET_ID_PICK_ELEMENT, + &editor.button.pick_element, GD_TYPE_RADIO_BUTTON, + "pick drawing element", ',' + }, + + /* ---------- level control buttons -------------------------------------- */ + + { + IMG_EDITOR_BUTTON_GFX_UNDO, GADGET_ID_UNDO, + &editor.button.undo, GD_TYPE_NORMAL_BUTTON, + "undo last operation", 'U' + }, + { + IMG_EDITOR_BUTTON_GFX_CONF, GADGET_ID_INFO, + &editor.button.conf, GD_TYPE_NORMAL_BUTTON, + "properties of level", 'I' + }, + { + IMG_EDITOR_BUTTON_GFX_SAVE, GADGET_ID_SAVE, + &editor.button.save, GD_TYPE_NORMAL_BUTTON, + "save level", 'S' + }, + { + IMG_EDITOR_BUTTON_GFX_CLEAR, GADGET_ID_CLEAR, + &editor.button.clear, GD_TYPE_NORMAL_BUTTON, + "clear level", 'C' + }, + { + IMG_EDITOR_BUTTON_GFX_TEST, GADGET_ID_TEST, + &editor.button.test, GD_TYPE_NORMAL_BUTTON, + "test level", 'T' + }, + { + IMG_EDITOR_BUTTON_GFX_EXIT, GADGET_ID_EXIT, + &editor.button.exit, GD_TYPE_NORMAL_BUTTON, + "exit level editor", 'E' + }, + + /* ---------- CE and GE control buttons ---------------------------------- */ + + { + IMG_EDITOR_BUTTON_GFX_CE_COPY_FROM, GADGET_ID_CUSTOM_COPY_FROM, + &editor.button.ce_copy_from, GD_TYPE_RADIO_BUTTON, + "copy settings from other element", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_CE_COPY_TO, GADGET_ID_CUSTOM_COPY_TO, + &editor.button.ce_copy_to, GD_TYPE_RADIO_BUTTON, + "copy settings to other element", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_CE_SWAP, GADGET_ID_CUSTOM_EXCHANGE, + &editor.button.ce_swap, GD_TYPE_RADIO_BUTTON, + "exchange element with other element", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_CE_COPY, GADGET_ID_CUSTOM_COPY, + &editor.button.ce_copy, GD_TYPE_NORMAL_BUTTON, + "copy settings from this element", 0 + }, + { + IMG_EDITOR_BUTTON_GFX_CE_PASTE, GADGET_ID_CUSTOM_PASTE, + &editor.button.ce_paste, GD_TYPE_NORMAL_BUTTON, + "paste settings to this element", 0 + }, + + /* ---------- palette control buttons ------------------------------------ */ + + { + IMG_EDITOR_BUTTON_GFX_PROPERTIES, GADGET_ID_PROPERTIES, + &editor.button.properties, GD_TYPE_NORMAL_BUTTON, + "properties of drawing element", 'p' + } }; static int random_placement_value = 10; @@ -1200,7 +1291,7 @@ static struct /* ---------- element settings: configure 1 (custom elements) ------------ */ { - ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6), + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5), MIN_SCORE, MAX_SCORE, GADGET_ID_CUSTOM_SCORE_DOWN, GADGET_ID_CUSTOM_SCORE_UP, GADGET_ID_CUSTOM_SCORE_TEXT, GADGET_ID_NONE, @@ -1208,7 +1299,7 @@ static struct NULL, "CE score", " " }, { - -1, ED_ELEMENT_SETTINGS_YPOS(6), + -1, ED_ELEMENT_SETTINGS_YPOS(5), MIN_COLLECT_COUNT, MAX_COLLECT_COUNT, GADGET_ID_CUSTOM_GEMCOUNT_DOWN, GADGET_ID_CUSTOM_GEMCOUNT_UP, GADGET_ID_CUSTOM_GEMCOUNT_TEXT, GADGET_ID_CUSTOM_SCORE_UP, @@ -1216,7 +1307,7 @@ static struct NULL, "CE count", NULL }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10), 0, 9999, GADGET_ID_CUSTOM_VALUE_FIX_DOWN, GADGET_ID_CUSTOM_VALUE_FIX_UP, GADGET_ID_CUSTOM_VALUE_FIX_TEXT, GADGET_ID_NONE, @@ -1224,7 +1315,7 @@ static struct NULL, "CE value", NULL }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(12), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10), 0, 9999, GADGET_ID_CUSTOM_VALUE_RND_DOWN, GADGET_ID_CUSTOM_VALUE_RND_UP, GADGET_ID_CUSTOM_VALUE_RND_TEXT, GADGET_ID_CUSTOM_VALUE_FIX_UP, @@ -1232,7 +1323,7 @@ static struct NULL, "+random", NULL }, { - ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7), + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(6), 0, 999, GADGET_ID_PUSH_DELAY_FIX_DOWN, GADGET_ID_PUSH_DELAY_FIX_UP, GADGET_ID_PUSH_DELAY_FIX_TEXT, GADGET_ID_NONE, @@ -1240,7 +1331,7 @@ static struct NULL, "push delay", NULL }, { - -1, ED_ELEMENT_SETTINGS_YPOS(7), + -1, ED_ELEMENT_SETTINGS_YPOS(6), 0, 999, GADGET_ID_PUSH_DELAY_RND_DOWN, GADGET_ID_PUSH_DELAY_RND_UP, GADGET_ID_PUSH_DELAY_RND_TEXT, GADGET_ID_PUSH_DELAY_FIX_UP, @@ -1248,7 +1339,7 @@ static struct NULL, "+random", NULL }, { - ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(8), + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(7), 0, 999, GADGET_ID_DROP_DELAY_FIX_DOWN, GADGET_ID_DROP_DELAY_FIX_UP, GADGET_ID_DROP_DELAY_FIX_TEXT, GADGET_ID_NONE, @@ -1256,7 +1347,7 @@ static struct NULL, "drop delay", NULL }, { - -1, ED_ELEMENT_SETTINGS_YPOS(8), + -1, ED_ELEMENT_SETTINGS_YPOS(7), 0, 999, GADGET_ID_DROP_DELAY_RND_DOWN, GADGET_ID_DROP_DELAY_RND_UP, GADGET_ID_DROP_DELAY_RND_TEXT, GADGET_ID_DROP_DELAY_FIX_UP, @@ -1302,7 +1393,7 @@ static struct /* ---------- element settings: configure (group elements) --------------- */ { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3), MIN_ELEMENTS_IN_GROUP, MAX_ELEMENTS_IN_GROUP, GADGET_ID_GROUP_CONTENT_DOWN, GADGET_ID_GROUP_CONTENT_UP, GADGET_ID_GROUP_CONTENT_TEXT, GADGET_ID_NONE, @@ -2142,7 +2233,7 @@ static struct /* ---------- element settings: configure 1 (custom elements) ------------ */ { - ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3), + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(2), GADGET_ID_CUSTOM_ACCESS_TYPE, GADGET_ID_NONE, -1, options_access_type, @@ -2150,7 +2241,7 @@ static struct NULL, NULL, "type of access to this field" }, { - -1, ED_ELEMENT_SETTINGS_YPOS(3), + -1, ED_ELEMENT_SETTINGS_YPOS(2), GADGET_ID_CUSTOM_ACCESS_LAYER, GADGET_ID_CUSTOM_ACCESS_TYPE, -1, options_access_layer, @@ -2158,7 +2249,7 @@ static struct NULL, NULL, "layer of access for this field" }, { - -1, ED_ELEMENT_SETTINGS_YPOS(3), + -1, ED_ELEMENT_SETTINGS_YPOS(2), GADGET_ID_CUSTOM_ACCESS_PROTECTED, GADGET_ID_CUSTOM_ACCESS_LAYER, -1, options_access_protected, @@ -2166,7 +2257,7 @@ static struct NULL, NULL, "protected access for this field" }, { - ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4), + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(3), GADGET_ID_CUSTOM_ACCESS_DIRECTION, GADGET_ID_NONE, -1, options_access_direction, @@ -2174,7 +2265,7 @@ static struct "from", NULL, "access direction for this field" }, { - ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(5), + ED_ELEMENT_SETTINGS_XPOS(1), ED_ELEMENT_SETTINGS_YPOS(4), GADGET_ID_CUSTOM_WALK_TO_ACTION, GADGET_ID_NONE, -1, options_walk_to_action, @@ -2343,7 +2434,7 @@ static struct /* ---------- element settings: configure (group elements) --------------- */ { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(6), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4), GADGET_ID_GROUP_CHOICE_MODE, GADGET_ID_NONE, -1, options_group_choice_mode, @@ -2405,7 +2496,7 @@ static struct NULL, NULL, "Configure custom element change pages" }, { - -1, ED_ELEMENT_SETTINGS_YPOS(2), + -1, ED_ELEMENT_SETTINGS_YPOS(14), GADGET_ID_SAVE_AS_TEMPLATE, GADGET_ID_CUSTOM_USE_TEMPLATE, -1, "Save", " ", "As Template", "Save current settings as new template" @@ -2786,42 +2877,42 @@ static struct "use graphic of element:", "use existing element graphic" }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(14), GADGET_ID_CUSTOM_USE_TEMPLATE, GADGET_ID_NONE, &level.use_custom_template, NULL, "use template", "use template for custom properties" }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(3), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(2), GADGET_ID_CUSTOM_ACCESSIBLE, GADGET_ID_NONE, &custom_element_properties[EP_ACCESSIBLE], NULL, NULL, "player can walk to or pass this field" }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(10), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9), GADGET_ID_CUSTOM_GRAV_REACHABLE, GADGET_ID_NONE, &custom_element_properties[EP_GRAVITY_REACHABLE], NULL, "reachable despite gravity", "player can walk/dig despite gravity" }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(13), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(11), GADGET_ID_CUSTOM_USE_LAST_VALUE, GADGET_ID_NONE, &custom_element.use_last_ce_value, NULL, "use last CE value after change", "use last CE value after change" }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(5), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(4), GADGET_ID_CUSTOM_WALK_TO_OBJECT, GADGET_ID_NONE, &custom_element_properties[EP_WALK_TO_OBJECT], NULL, NULL, "player can dig/collect/push element" }, { - ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(9), + ED_ELEMENT_SETTINGS_XPOS(0), ED_ELEMENT_SETTINGS_YPOS(8), GADGET_ID_CUSTOM_INDESTRUCTIBLE, GADGET_ID_NONE, &custom_element_properties[EP_INDESTRUCTIBLE], NULL, @@ -3215,7 +3306,7 @@ static struct /* ---------- group element content -------------------------------------- */ { - ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(4), + ED_AREA_1X1_SETTINGS_XPOS(0), ED_AREA_1X1_SETTINGS_YPOS(2), GADGET_ID_GROUP_CONTENT, GADGET_ID_NONE, &group_element_info.element[0], MAX_ELEMENTS_IN_GROUP, 1, "content:", NULL, NULL, NULL @@ -4788,27 +4879,47 @@ static char *getElementInfoText(int element) return info_text; } -char *getElementDescriptionFilename(int element) +static char *getElementDescriptionFilenameExt(char *basename) { - char *docs_dir = options.docs_directory; char *elements_subdir = "elements"; + static char *elements_subdir2 = NULL; static char *filename = NULL; - char basename[MAX_FILENAME_LEN]; + + if (elements_subdir2 == NULL) + elements_subdir2 = getPath2(DOCS_DIRECTORY, elements_subdir); checked_free(filename); - /* 1st try: look for element description file for exactly this element */ - sprintf(basename, "%s.txt", element_info[element].token_name); - filename = getPath3(docs_dir, elements_subdir, basename); + /* 1st try: look for element description in current level set directory */ + filename = getPath3(getCurrentLevelDir(), elements_subdir2, basename); if (fileExists(filename)) return filename; free(filename); + /* 2nd try: look for element description in the game's base directory */ + filename = getPath3(options.docs_directory, elements_subdir, basename); + if (fileExists(filename)) + return filename; + + return NULL; +} + +char *getElementDescriptionFilename(int element) +{ + char basename[MAX_FILENAME_LEN]; + char *filename; + + /* 1st try: look for element description file for exactly this element */ + sprintf(basename, "%s.txt", element_info[element].token_name); + filename = getElementDescriptionFilenameExt(basename); + if (filename != NULL) + return filename; + /* 2nd try: look for element description file for this element's class */ sprintf(basename, "%s.txt", element_info[element].class_name); - filename = getPath3(docs_dir, elements_subdir, basename); - if (fileExists(filename)) + filename = getElementDescriptionFilenameExt(basename); + if (filename != NULL) return filename; return NULL; @@ -4927,7 +5038,9 @@ static void ReinitializeElementList() { if (setup.editor.el_headlines) { - num_editor_elements += *editor_elements_info[i].headline_list_size; + // required for correct padding of palette headline buttons + if (*editor_elements_info[i].headline_list_size > 0) + num_editor_elements += editor.palette.cols; for (j = 0; j < *editor_elements_info[i].headline_list_size; j++) { @@ -4941,7 +5054,13 @@ static void ReinitializeElementList() if (found_inactive_cascade) continue; - num_editor_elements += *editor_elements_info[i].element_list_size; + // 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; + + num_editor_elements += element_buttons; } } @@ -4965,9 +5084,16 @@ static void ReinitializeElementList() { if (setup.editor.el_headlines) { - for (j = 0; j < *editor_elements_info[i].headline_list_size; j++) + // required for correct padding of palette headline buttons + int headline_size = (*editor_elements_info[i].headline_list_size > 0 ? + editor.palette.cols : 0); + + for (j = 0; j < headline_size; j++) { - int element = (*editor_elements_info[i].headline_list)[j]; + // use empty elements for padding of palette headline buttons + int element = (j < *editor_elements_info[i].headline_list_size ? + (*editor_elements_info[i].headline_list)[j] : + editor_el_empty[0]); editor_elements[pos++] = element; @@ -4979,8 +5105,19 @@ static void ReinitializeElementList() if (found_inactive_cascade) continue; - for (j = 0; j < *editor_elements_info[i].element_list_size; j++) + // 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; + + // copy all elements from element list + for (j = 0; j < element_list_size; j++) editor_elements[pos++] = (*editor_elements_info[i].element_list)[j]; + + // use empty elements for padding of palette element buttons + for (j = 0; j < element_buttons - element_list_size; j++) + editor_elements[pos++] = editor_el_empty[0]; } } @@ -5071,8 +5208,8 @@ static void DrawElementBorder(int dest_x, int dest_y, int width, int height, (input ? IMG_EDITOR_ELEMENT_BORDER_INPUT : IMG_EDITOR_ELEMENT_BORDER); Bitmap *src_bitmap; int src_x, src_y; - int bx = (input ? 4 : 8); - int by = (input ? 4 : 8); + int bx = (input ? ED_ELEMENT_BORDER_INPUT : ED_ELEMENT_BORDER); + int by = (input ? ED_ELEMENT_BORDER_INPUT : ED_ELEMENT_BORDER); int bx2 = TILEX - bx; int by2 = TILEY - by; int i; @@ -5155,49 +5292,55 @@ static void ScrollMiniLevel(int from_x, int from_y, int scroll) BackToFront(); } +void getElementListGraphicSource(int element, Bitmap **bitmap, int *x, int *y) +{ + int graphic = el2edimg(element); + int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE : + MINI_TILESIZE); + + getSizedGraphicSource(graphic, 0, tile_size, bitmap, x, y); +} + static void CreateControlButtons() { - Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; struct GadgetInfo *gi; - unsigned int event_mask; int i; /* create toolbox buttons */ for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++) { - int id = i; - int width, height; - int gd_xoffset, gd_yoffset; - int gd_x1, gd_x2, gd_y1, gd_y2; - int button_type; - int radio_button_nr; - boolean checked; - - if (id == GADGET_ID_SINGLE_ITEMS || - id == GADGET_ID_CONNECTED_ITEMS || - id == GADGET_ID_LINE || - id == GADGET_ID_ARC || - id == GADGET_ID_TEXT || - id == GADGET_ID_RECTANGLE || - id == GADGET_ID_FILLED_BOX || - id == GADGET_ID_FLOOD_FILL || - id == GADGET_ID_GRAB_BRUSH || - id == GADGET_ID_PICK_ELEMENT || - id == GADGET_ID_CUSTOM_COPY_FROM || - id == GADGET_ID_CUSTOM_COPY_TO || - id == GADGET_ID_CUSTOM_EXCHANGE) + int id = controlbutton_info[i].gadget_id; + int type = controlbutton_info[i].gadget_type; + int graphic = controlbutton_info[i].graphic; + struct XY *pos = controlbutton_info[i].pos; + struct GraphicInfo *gd = &graphic_info[graphic]; + Bitmap *gd_bitmap = gd->bitmap; + int gd_x1 = gd->src_x; + int gd_y1 = gd->src_y; + int gd_x2 = gd->src_x + gd->pressed_xoffset; + int gd_y2 = gd->src_y + gd->pressed_yoffset; + int gd_x1a = gd->src_x + gd->active_xoffset; + int gd_y1a = gd->src_y + gd->active_yoffset; + int gd_x2a = gd->src_x + gd->active_xoffset + gd->pressed_xoffset; + int gd_y2a = gd->src_y + gd->active_yoffset + gd->pressed_yoffset; + int width = gd->width; + int height = gd->height; + int x = pos->x; + int y = pos->y; + unsigned int event_mask; + int radio_button_nr = RADIO_NR_NONE; + boolean checked = FALSE; + + if (type == GD_TYPE_RADIO_BUTTON) { - button_type = GD_TYPE_RADIO_BUTTON; - radio_button_nr = RADIO_NR_DRAWING_TOOLBOX; - checked = (id == drawing_function ? TRUE : FALSE); event_mask = GD_EVENT_PRESSED; + radio_button_nr = RADIO_NR_DRAWING_TOOLBOX; + + if (id == drawing_function) + checked = TRUE; } else { - button_type = GD_TYPE_NORMAL_BUTTON; - radio_button_nr = RADIO_NR_NONE; - checked = FALSE; - if (id == GADGET_ID_WRAP_LEFT || id == GADGET_ID_WRAP_RIGHT || id == GADGET_ID_WRAP_UP || @@ -5207,82 +5350,32 @@ static void CreateControlButtons() event_mask = GD_EVENT_RELEASED; } - if (id < ED_NUM_CTRL1_BUTTONS) + if (id == GADGET_ID_PROPERTIES) { - int x = i % ED_CTRL1_BUTTONS_HORIZ; - int y = i / ED_CTRL1_BUTTONS_HORIZ; - - gd_xoffset = ED_CTRL1_BUTTONS_XPOS + x * ED_CTRL1_BUTTON_XSIZE; - gd_yoffset = ED_CTRL1_BUTTONS_YPOS + y * ED_CTRL1_BUTTON_YSIZE; - width = ED_CTRL1_BUTTON_XSIZE; - height = ED_CTRL1_BUTTON_YSIZE; - - gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset; - gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_GFX_YPOS + gd_yoffset; - gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL1_BUTTONS_ALT_GFX_YPOS + gd_yoffset; - } - else if (id < ED_NUM_CTRL1_2_BUTTONS) - { - int x = (i - ED_NUM_CTRL1_BUTTONS) % ED_CTRL2_BUTTONS_HORIZ; - int y = (i - ED_NUM_CTRL1_BUTTONS) / ED_CTRL2_BUTTONS_HORIZ; - - gd_xoffset = ED_CTRL2_BUTTONS_XPOS + x * ED_CTRL2_BUTTON_XSIZE; - gd_yoffset = ED_CTRL2_BUTTONS_YPOS + y * ED_CTRL2_BUTTON_YSIZE; - width = ED_CTRL2_BUTTON_XSIZE; - height = ED_CTRL2_BUTTON_YSIZE; - - gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset; - gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL2_BUTTONS_GFX_YPOS + gd_yoffset; - gd_y2 = 0; /* no alternative graphic for these buttons */ - } - else if (id < ED_NUM_CTRL1_3_BUTTONS) - { - int x = (i - ED_NUM_CTRL1_2_BUTTONS) % ED_CTRL3_BUTTONS_HORIZ + 1; - int y = (i - ED_NUM_CTRL1_2_BUTTONS) / ED_CTRL3_BUTTONS_HORIZ; - - gd_xoffset = ED_CTRL3_BUTTONS_XPOS + x * ED_CTRL3_BUTTON_XSIZE; - gd_yoffset = ED_CTRL3_BUTTONS_YPOS + y * ED_CTRL3_BUTTON_YSIZE; - width = ED_CTRL3_BUTTON_XSIZE; - height = ED_CTRL3_BUTTON_YSIZE; - - gd_x1 = DOOR_GFX_PAGEX6 + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX5 + gd_xoffset; - gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_GFX_YPOS + gd_yoffset; - gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL3_BUTTONS_ALT_GFX_YPOS + gd_yoffset; + x += DX; + y += DY; } else { - int x = (i - ED_NUM_CTRL1_3_BUTTONS) % ED_CTRL4_BUTTONS_HORIZ; - int y = (i - ED_NUM_CTRL1_3_BUTTONS) / ED_CTRL4_BUTTONS_HORIZ + 3; - - gd_xoffset = ED_CTRL4_BUTTONS_XPOS + x * ED_CTRL4_BUTTON_XSIZE; - gd_yoffset = ED_CTRL4_BUTTONS_YPOS + y * ED_CTRL4_BUTTON_YSIZE; - width = ED_CTRL4_BUTTON_XSIZE; - height = ED_CTRL4_BUTTON_YSIZE; - - gd_x1 = DOOR_GFX_PAGEX6 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX5 + ED_CTRL4_BUTTONS_GFX_XPOS + gd_xoffset; - gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL4_BUTTONS_GFX_YPOS + gd_yoffset; - gd_y2 = 0; /* no alternative graphic for these buttons */ + x += EX; + y += EY; } gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_CUSTOM_TYPE_ID, i, - GDI_INFO_TEXT, control_info[i].text, - GDI_X, EX + gd_xoffset, - GDI_Y, EY + gd_yoffset, + GDI_INFO_TEXT, controlbutton_info[i].infotext, + GDI_X, x, + GDI_Y, y, GDI_WIDTH, width, GDI_HEIGHT, height, - GDI_TYPE, button_type, + GDI_TYPE, type, GDI_STATE, GD_BUTTON_UNPRESSED, GDI_RADIO_NR, radio_button_nr, GDI_CHECKED, checked, GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, - GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1, - GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2, - GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, + GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, + GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1a, gd_y1a, + GDI_ALT_DESIGN_PRESSED, gd_bitmap, gd_x2a, gd_y2a, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleControlButtons, @@ -5314,36 +5407,27 @@ static void CreateControlButtons() int id = scrollbutton_info[i].gadget_id; int graphic = scrollbutton_info[i].graphic; struct GraphicInfo *gd = &graphic_info[graphic]; - int x, y, width, height; - int gd_x1, gd_x2, gd_y1, gd_y2; - - x = scrollbutton_pos[i].x; - y = scrollbutton_pos[i].y; - - event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; + Bitmap *gd_bitmap = gd->bitmap; + int gd_x1 = gd->src_x; + int gd_y1 = gd->src_y; + int gd_x2 = gd->src_x + gd->pressed_xoffset; + int gd_y2 = gd->src_y + gd->pressed_yoffset; + int width = gd->width; + int height = gd->height; + int x = scrollbutton_pos[i].x; + int y = scrollbutton_pos[i].y; + unsigned int event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; if (id == GADGET_ID_SCROLL_LIST_UP || id == GADGET_ID_SCROLL_LIST_DOWN) { x += DX; y += DY; - width = gd->width; - height = gd->height; - gd_x1 = gd->src_x; - gd_y1 = gd->src_y; - gd_x2 = gd->src_x + gd->pressed_xoffset; - gd_y2 = gd->src_y + gd->pressed_yoffset; } else { x += SX; y += SY; - width = gd->width; - height = gd->height; - gd_x1 = gd->src_x; - gd_y1 = gd->src_y; - gd_x2 = gd->src_x + gd->pressed_xoffset; - gd_y2 = gd->src_y + gd->pressed_yoffset; } gi = CreateGadget(GDI_CUSTOM_ID, id, @@ -5371,44 +5455,43 @@ static void CreateControlButtons() /* create buttons for element list */ for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++) { - struct GraphicInfo *gd = &graphic_info[IMG_EDITOR_PALETTE_BUTTON]; + int id = GADGET_ID_ELEMENTLIST_FIRST + i; + int graphic = IMG_EDITOR_PALETTE_BUTTON; + struct GraphicInfo *gd = &graphic_info[graphic]; + Bitmap *gd_bitmap = gd->bitmap; Bitmap *deco_bitmap; int deco_x, deco_y, deco_xpos, deco_ypos; - int gd_xoffset, gd_yoffset; - int gd_x1, gd_y1, gd_x2, gd_y2; - int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ; - int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ; - int id = GADGET_ID_ELEMENTLIST_FIRST + i; + int gd_x1 = gd->src_x; + int gd_y1 = gd->src_y; + int gd_x2 = gd->src_x + gd->pressed_xoffset; + int gd_y2 = gd->src_y + gd->pressed_yoffset; + int xx = i % ED_ELEMENTLIST_BUTTONS_HORIZ; + int yy = i / ED_ELEMENTLIST_BUTTONS_HORIZ; + int x = DX + ED_ELEMENTLIST_XPOS + xx * gd->width; + int y = DY + ED_ELEMENTLIST_YPOS + yy * gd->height; int element = editor_elements[i]; + int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE : + MINI_TILESIZE); + unsigned int event_mask = GD_EVENT_RELEASED; - event_mask = GD_EVENT_RELEASED; - - gd_xoffset = ED_ELEMENTLIST_XPOS + x * gd->width; - gd_yoffset = ED_ELEMENTLIST_YPOS + y * gd->height; - - gd_x1 = gd->src_x; - gd_y1 = gd->src_y; - gd_x2 = gd->src_x + gd->pressed_xoffset; - gd_y2 = gd->src_y + gd->pressed_yoffset; - - getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y); - deco_xpos = (gd->width - MINI_TILEX) / 2; - deco_ypos = (gd->height - MINI_TILEY) / 2; + getElementListGraphicSource(element, &deco_bitmap, &deco_x, &deco_y); + deco_xpos = (gd->width - tile_size) / 2; + deco_ypos = (gd->height - tile_size) / 2; gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, getElementInfoText(element), - GDI_X, DX + gd_xoffset, - GDI_Y, DY + gd_yoffset, + GDI_X, x, + GDI_Y, y, GDI_WIDTH, gd->width, GDI_HEIGHT, gd->height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, GDI_STATE, GD_BUTTON_UNPRESSED, - GDI_DESIGN_UNPRESSED, gd->bitmap, gd_x1, gd_y1, - GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2, + GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, + GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_DECORATION_POSITION, deco_xpos, deco_ypos, - GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY, + GDI_DECORATION_SIZE, tile_size, tile_size, GDI_DECORATION_SHIFTING, 1, 1, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, @@ -5427,10 +5510,6 @@ static void CreateCounterButtons() int max_infotext_len = getMaxInfoTextLength(); int i; - /* these values are not constant, but can change at runtime */ - counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].x = DX + 5 - SX; - counterbutton_info[ED_COUNTER_ID_SELECT_LEVEL].y = DY + 3 - SY; - for (i = 0; i < ED_NUM_COUNTERBUTTONS; i++) { int j; @@ -5472,9 +5551,16 @@ static void CreateCounterButtons() event_mask |= GD_EVENT_RELEASED; - if (j == 1) - x += 2 * ED_GADGET_DISTANCE; - y += ED_GADGET_DISTANCE; + if (j == 0) + { + x = DX + editor.button.prev_level.x; + y = DY + editor.button.prev_level.y; + } + else + { + x = DX + editor.button.next_level.x; + y = DY + editor.button.next_level.y; + } gd_x1 = gd->src_x; gd_y1 = gd->src_y; @@ -5527,20 +5613,28 @@ static void CreateCounterButtons() int font_type = FONT_INPUT_1; int font_type_active = FONT_INPUT_1_ACTIVE; int gd_width = ED_WIN_COUNT_XSIZE; + int border_size = ED_BORDER_SIZE; id = counterbutton_info[i].gadget_id_text; event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING; if (i == ED_COUNTER_ID_SELECT_LEVEL) { + int graphic = IMG_EDITOR_INPUT_GFX_LEVEL_NUMBER; + struct GraphicInfo *gd = &graphic_info[graphic]; + + gd_bitmap = gd->bitmap; + + x = DX + editor.input.level_number.x; + y = DY + editor.input.level_number.y; + + gd_x = gd->src_x; + gd_y = gd->src_y; + gd_width = gd->width; + border_size = gd->border_size; + font_type = FONT_LEVEL_NUMBER; font_type_active = FONT_LEVEL_NUMBER_ACTIVE; - x += 2 * ED_GADGET_DISTANCE; - y -= ED_GADGET_DISTANCE; - - gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS; - gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS; - gd_width = ED_WIN_COUNT2_XSIZE; } else { @@ -5562,7 +5656,7 @@ static void CreateCounterButtons() GDI_TEXT_FONT_ACTIVE, font_type_active, GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y, GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y, - GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE, + GDI_BORDER_SIZE, border_size, border_size, GDI_DESIGN_WIDTH, gd_width, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, @@ -6318,6 +6412,9 @@ static void MapControlButtons() for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++) MapGadget(level_editor_gadget[i]); + /* map toolbox buttons (element properties button) */ + MapGadget(level_editor_gadget[ED_NUM_CTRL1_4_BUTTONS]); + /* map buttons to select elements */ for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++) MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]); @@ -6575,26 +6672,27 @@ static void UnmapLevelEditorToolboxCustomGadgets() static void MapOrUnmapLevelEditorToolboxDrawingGadgets(boolean map) { - Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; int i; for (i = 0; i < ED_NUM_CTRL1_BUTTONS; i++) { if (i != GADGET_ID_SINGLE_ITEMS && - i != GADGET_ID_PROPERTIES && i != GADGET_ID_PICK_ELEMENT) { struct GadgetInfo *gi = level_editor_gadget[i]; if (map) + { MapGadget(gi); + } else { + int graphic = IMG_EDITOR_NO_TOOLBOX_BUTTON; + struct GraphicInfo *gd = &graphic_info[graphic]; + UnmapGadget(gi); - BlitBitmap(gd_bitmap, drawto, - DOOR_GFX_PAGEX6 + ED_CTRL_NO_BUTTONS_GFX_XPOS, - DOOR_GFX_PAGEY1 + ED_CTRL_NO_BUTTONS_GFX_YPOS, + BlitBitmap(gd->bitmap, drawto, gd->src_x, gd->src_y, gi->width, gi->height, gi->x, gi->y); redraw_mask |= REDRAW_DOOR_3; @@ -7407,6 +7505,9 @@ void DrawLevelEd() level_ypos = -1; } + /* 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, @@ -7476,8 +7577,6 @@ static void AdjustDrawingAreaGadgets() ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy); ModifyGadget(level_editor_gadget[GADGET_ID_DRAWING_LEVEL], - GDI_WIDTH, ed_fieldx * MINI_TILEX, - GDI_HEIGHT, ed_fieldy * MINI_TILEY, GDI_AREA_SIZE, ed_fieldx, ed_fieldy, GDI_END); @@ -7641,39 +7740,41 @@ static void ModifyEditorElementList() UnmapGadget(gi); - getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y); + getElementListGraphicSource(element, &gd->bitmap, &gd->x, &gd->y); + ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END); MapGadget(gi); } } +static void DrawDrawingElement(int element, struct EditorPaletteElementInfo *e) +{ + int graphic = el2edimg(element); + int tile_size = (e->tile_size >= TILESIZE ? TILESIZE : MINI_TILESIZE); + + DrawSizedGraphicExt(drawto, DX + e->x, DY + e->y, graphic, 0, tile_size); +} + static void PickDrawingElement(int button, int element) { + struct + { + int *new_element; + struct EditorPaletteElementInfo *e; + } de, drawing_elements[] = + { + { &new_element1, &editor.palette.element_left }, + { &new_element2, &editor.palette.element_middle }, + { &new_element3, &editor.palette.element_right }, + }; + if (button < 1 || button > 3) return; - if (button == 1) - { - new_element1 = element; - DrawMiniGraphicExt(drawto, - DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS, - el2edimg(new_element1)); - } - else if (button == 2) - { - new_element2 = element; - DrawMiniGraphicExt(drawto, - DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS, - el2edimg(new_element2)); - } - else - { - new_element3 = element; - DrawMiniGraphicExt(drawto, - DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS, - el2edimg(new_element3)); - } + de = drawing_elements[button - 1]; + + DrawDrawingElement((*de.new_element = element), de.e); redraw_mask |= REDRAW_DOOR_1; } @@ -7986,8 +8087,10 @@ static void DrawGroupElementArea(int element) { int num_elements = group_element_info.num_elements; int id = ED_DRAWING_ID_GROUP_CONTENT; - int sx = SX + drawingarea_info[id].x - MINI_TILEX / 2; - int sy = SY + drawingarea_info[id].y - MINI_TILEY / 2; + int bx = ED_ELEMENT_BORDER_INPUT; + int by = ED_ELEMENT_BORDER_INPUT; + int sx = SX + drawingarea_info[id].x - bx; + int sy = SY + drawingarea_info[id].y - by; int xsize = MAX_ELEMENTS_IN_GROUP; int ysize = 1; @@ -7999,7 +8102,7 @@ static void DrawGroupElementArea(int element) ModifyEditorDrawingArea(id, num_elements, 1); /* delete content areas in case of reducing number of them */ - DrawBackground(sx, sy, (xsize + 1) * MINI_TILEX, (ysize + 1) * MINI_TILEY); + DrawBackground(sx, sy, xsize * MINI_TILEX + 2*bx, ysize * MINI_TILEY + 2*by); MapDrawingArea(id); } @@ -8369,6 +8472,7 @@ static boolean checkPropertiesConfig(int element) static void DrawPropertiesConfig() { + boolean draw_footer_line = FALSE; int max_num_element_counters = 4; int num_element_counters = 0; int i; @@ -8611,6 +8715,8 @@ static void DrawPropertiesConfig() /* draw drawing area gadgets */ MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC); + + draw_footer_line = TRUE; } else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2) { @@ -8661,6 +8767,25 @@ static void DrawPropertiesConfig() /* draw drawing area gadgets */ MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC); + + draw_footer_line = TRUE; + } + + /* draw little footer border line above CE/GE use/save template gadgets */ + if (draw_footer_line) + { + struct GadgetInfo *gd_gi1 = level_editor_gadget[GADGET_ID_PROPERTIES_INFO]; + struct GadgetDesign *gd = &gd_gi1->alt_design[GD_BUTTON_UNPRESSED]; + int gd_x = gd->x + gd_gi1->border.width / 2; + int gd_y = gd->y + gd_gi1->height - 1; + Pixel tab_color = GetPixel(gd->bitmap, gd_x, gd_y); + + if (tab_color != BLACK_PIXEL) /* black => transparent */ + FillRectangle(drawto, + SX + ED_ELEMENT_SETTINGS_XPOS(0), + SY + ED_ELEMENT_SETTINGS_YPOS(14) - MINI_TILEY / 2, + getTabulatorBarWidth(), ED_GADGET_DISTANCE, + tab_color); } } @@ -10352,6 +10477,9 @@ static void CopyLevelToUndoBuffer(int mode) boolean new_undo_buffer_position = TRUE; int x, y; + if (undo_buffer_steps == 0) + accumulated_undo = FALSE; + switch (mode) { case UNDO_IMMEDIATE: @@ -11054,7 +11182,6 @@ static void HandleControlButtons(struct GadgetInfo *gi) if (id < ED_NUM_CTRL1_BUTTONS && id != GADGET_ID_SINGLE_ITEMS && - id != GADGET_ID_PROPERTIES && id != GADGET_ID_PICK_ELEMENT && edit_mode != ED_MODE_DRAWING && drawing_function != GADGET_ID_PICK_ELEMENT && @@ -11180,6 +11307,27 @@ static void HandleControlButtons(struct GadgetInfo *gi) break; + case GADGET_ID_PROPERTIES: + if (edit_mode != ED_MODE_PROPERTIES) + { + properties_element = new_element; + DrawPropertiesWindow(); + edit_mode = ED_MODE_PROPERTIES; + + last_level_drawing_function = drawing_function; + ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], + MB_LEFTBUTTON); + } + else + { + DrawDrawingWindow(); + edit_mode = ED_MODE_DRAWING; + + ClickOnGadget(level_editor_gadget[last_level_drawing_function], + MB_LEFTBUTTON); + } + break; + case GADGET_ID_WRAP_LEFT: WrapLevel(-step, 0); break; @@ -11216,25 +11364,8 @@ static void HandleControlButtons(struct GadgetInfo *gi) RandomPlacement(new_element); break; - case GADGET_ID_PROPERTIES: - if (edit_mode != ED_MODE_PROPERTIES) - { - properties_element = new_element; - DrawPropertiesWindow(); - edit_mode = ED_MODE_PROPERTIES; - - last_level_drawing_function = drawing_function; - ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], - MB_LEFTBUTTON); - } - else - { - DrawDrawingWindow(); - edit_mode = ED_MODE_DRAWING; - - ClickOnGadget(level_editor_gadget[last_level_drawing_function], - MB_LEFTBUTTON); - } + case GADGET_ID_ZOOM: + printf("::: zoom button pressed with mouse button %d\n", button); break; case GADGET_ID_CUSTOM_COPY_FROM: @@ -11590,6 +11721,10 @@ void HandleLevelEditorKeyInput(Key key) if (id != GADGET_ID_NONE) ClickOnGadget(level_editor_gadget[id], button); + else if (letter >= '1' && letter <= '3') + ClickOnGadget(level_editor_gadget[GADGET_ID_PROPERTIES], letter - '0'); + else if (letter == '?') + ClickOnGadget(level_editor_gadget[GADGET_ID_PROPERTIES], button); else if (letter == '.') ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button); else if (key == KSYM_Return || @@ -11598,7 +11733,7 @@ void HandleLevelEditorKeyInput(Key key) ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button); else for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++) - if (letter && letter == control_info[i].shortcut) + if (letter && letter == controlbutton_info[i].shortcut) if (!anyTextGadgetActive()) ClickOnGadget(level_editor_gadget[i], button); } @@ -11653,7 +11788,7 @@ void PrintEditorGadgetInfoText(struct GadgetInfo *gi) if (gi->custom_id < ED_NUM_CTRL_BUTTONS) { - int key = control_info[gi->custom_id].shortcut; + int key = controlbutton_info[gi->custom_id].shortcut; if (key) {