-----------------------------------------------------------------------------
*/
-/* 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
#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 * \
#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)
#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 * \
#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
#define INFOTEXT_XPOS SX
#define INFOTEXT_YPOS (SY + SYSIZE - MINI_TILEX + 2)
#define INFOTEXT_XSIZE SXSIZE
-#define INFOTEXT_YSIZE MINI_TILEX
+#define INFOTEXT_YSIZE MINI_TILEY
/*
#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)
#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)
#define ED_MODE_PROPERTIES_CHANGE ED_TEXTBUTTON_ID_PROPERTIES_CHANGE
/* how many steps can be cancelled */
-#define NUM_UNDO_STEPS (10 + 1)
+#define NUM_UNDO_STEPS (64 + 1)
/* values for elements with score for certain actions */
#define MIN_SCORE 0
#define RANDOM_USE_PERCENTAGE 0
#define RANDOM_USE_QUANTITY 1
-/* maximal size of level editor drawing area */
-#define MAX_ED_FIELDX (SCR_FIELDX)
-#define MAX_ED_FIELDY (SCR_FIELDY - 1)
+/* default value for element tile size in drawing area */
+#define DEFAULT_EDITOR_TILESIZE MINI_TILESIZE
/*
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", '-'
+ },
+ {
+ 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/redo 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;
/* ---------- 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,
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,
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,
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,
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,
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,
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,
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,
/* ---------- 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,
/* ---------- 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,
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,
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,
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,
"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,
/* ---------- 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,
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"
"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,
/* ---------- 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
-----------------------------------------------------------------------------
*/
+/* maximal size of level editor drawing area */
+static int MAX_ED_FIELDX, MAX_ED_FIELDY;
+
/* actual size of level editor drawing area */
static int ed_fieldx, ed_fieldy;
/* actual position of level editor drawing area in level playfield */
static int level_xpos = -1, level_ypos = -1;
+/* actual tile size used to display level editor playfield */
+static int ed_tilesize = DEFAULT_EDITOR_TILESIZE;
+
#define IN_ED_FIELD(x,y) IN_FIELD(x, y, ed_fieldx, ed_fieldy)
/* drawing elements on the three mouse buttons */
#define BUTTON_ELEMENT(button) ((button) == 1 ? new_element1 : \
(button) == 2 ? new_element2 : \
(button) == 3 ? new_element3 : EL_EMPTY)
-#define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : (button) == 2 ? 5 : 10)
+#define BUTTON_STEPSIZE(button) ((button) == 1 ? 1 : \
+ (button) == 2 ? 5 : \
+ (button) == 3 ? 10 : \
+ (button))
/* forward declaration for internal use */
static void ModifyEditorCounterValue(int, int);
static short IntelliDrawBuffer[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
static int undo_buffer_position = 0;
static int undo_buffer_steps = 0;
+static int redo_buffer_steps = 0;
static int edit_mode;
static int edit_mode_levelinfo;
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;
{
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++)
{
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;
}
}
{
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;
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];
}
}
(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;
ClearRectangle(drawto, dest_x - 1, dest_y - 1, width + 2, height + 2);
}
+static void DrawEditorElement(int x, int y, int element)
+{
+ DrawSizedElement(x, y, element, ed_tilesize);
+}
+
+static void DrawEditorElementOrWall(int x, int y, int scroll_x, int scroll_y)
+{
+ DrawSizedElementOrWall(x, y, scroll_x, scroll_y, ed_tilesize);
+}
+
+static void DrawEditorLevel(int size_x, int size_y, int scroll_x, int scroll_y)
+{
+ DrawSizedLevel(size_x, size_y, scroll_x, scroll_y, ed_tilesize);
+}
+
static void DrawDrawingArea(int id)
{
struct GadgetInfo *gi = level_editor_gadget[drawingarea_info[id].gadget_id];
el2edimg(value[x * area_ysize + y]));
}
-static void ScrollMiniLevel(int from_x, int from_y, int scroll)
+static void ScrollEditorLevel(int from_x, int from_y, int scroll)
{
int x, y;
int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0);
int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0);
BlitBitmap(drawto, drawto,
- SX + (dx == -1 ? MINI_TILEX : 0),
- SY + (dy == -1 ? MINI_TILEY : 0),
- (ed_fieldx * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0),
- (ed_fieldy * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0),
- SX + (dx == +1 ? MINI_TILEX : 0),
- SY + (dy == +1 ? MINI_TILEY : 0));
+ SX + (dx == -1 ? ed_tilesize : 0),
+ SY + (dy == -1 ? ed_tilesize : 0),
+ (ed_fieldx * ed_tilesize) - (dx != 0 ? ed_tilesize : 0),
+ (ed_fieldy * ed_tilesize) - (dy != 0 ? ed_tilesize : 0),
+ SX + (dx == +1 ? ed_tilesize : 0),
+ SY + (dy == +1 ? ed_tilesize : 0));
if (dx)
{
x = (dx == 1 ? 0 : ed_fieldx - 1);
for (y = 0; y < ed_fieldy; y++)
- DrawMiniElementOrWall(x, y, from_x, from_y);
+ DrawEditorElementOrWall(x, y, from_x, from_y);
}
else if (dy)
{
y = (dy == 1 ? 0 : ed_fieldy - 1);
for (x = 0; x < ed_fieldx; x++)
- DrawMiniElementOrWall(x, y, from_x, from_y);
+ DrawEditorElementOrWall(x, y, from_x, from_y);
}
redraw_mask |= REDRAW_FIELD;
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 ||
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,
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,
/* 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,
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;
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;
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
{
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,
GDI_Y, y,
GDI_TYPE, GD_TYPE_DRAWING_AREA,
GDI_AREA_SIZE, area_xsize, area_ysize,
- GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY,
+ GDI_ITEM_SIZE, ed_tilesize, ed_tilesize,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleDrawingAreaInfo,
GDI_CALLBACK_ACTION, HandleDrawingAreas,
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]);
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;
{
undo_buffer_position = -1;
undo_buffer_steps = -1;
+ redo_buffer_steps = 0;
+
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
level.changed = FALSE;
Error(ERR_WARN, "no element description for element '%s'", EL_NAME(i));
}
+static int getMaxEdFieldX(boolean has_scrollbar)
+{
+ int scrollbar_width = (has_scrollbar ? ED_SCROLLBUTTON_XSIZE : 0);
+ int sxsize = SXSIZE - scrollbar_width;
+ int max_ed_fieldx = sxsize / ed_tilesize;
+
+ return max_ed_fieldx;
+}
+
+static int getMaxEdFieldY(boolean has_scrollbar)
+{
+ int infotext_height = INFOTEXT_YSIZE;
+ int scrollbar_height = (has_scrollbar ? ED_SCROLLBUTTON_YSIZE : 0);
+ int sysize = SYSIZE - scrollbar_height - infotext_height;
+ int max_ed_fieldy = sysize / ed_tilesize;
+
+ return max_ed_fieldy;
+}
+
+void InitZoomLevelSettings()
+{
+ MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
+ MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
+}
+
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);
/* needed if different viewport properties defined for editor */
ChangeViewportPropertiesIfNeeded();
- if (old_sx != SX ||
- old_sy != SY ||
- old_sxsize != SXSIZE ||
- old_sysize != SYSIZE)
- playfield_area_changed = TRUE;
- else
- playfield_area_changed = FALSE;
+ InitZoomLevelSettings();
+
+ playfield_area_changed = DrawingAreaChanged();
OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
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,
BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY);
- redraw_mask |= REDRAW_ALL;
+ // redraw_mask |= REDRAW_ALL;
FreeLevelEditorGadgets();
CreateLevelEditorGadgets();
boolean horizontal_scrollbar_needed;
boolean vertical_scrollbar_needed;
int x, y, width, height;
- int xoffset, yoffset;
/* check if we need any scrollbars */
horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
- vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
+ vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
/* check if we have a smaller editor field because of scrollbars */
- if (horizontal_scrollbar_needed)
- max_ed_fieldy = MAX_ED_FIELDY - 1;
- if (vertical_scrollbar_needed)
- max_ed_fieldx = MAX_ED_FIELDX - 1;
+ max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
+ max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
/* check again if we now need more scrollbars because of less space */
horizontal_scrollbar_needed = (ed_xsize > max_ed_fieldx);
- vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
+ vertical_scrollbar_needed = (ed_ysize > max_ed_fieldy);
/* check if editor field gets even smaller after adding new scrollbars */
- if (horizontal_scrollbar_needed)
- max_ed_fieldy = MAX_ED_FIELDY - 1;
- if (vertical_scrollbar_needed)
- max_ed_fieldx = MAX_ED_FIELDX - 1;
+ max_ed_fieldx = getMaxEdFieldX(vertical_scrollbar_needed);
+ max_ed_fieldy = getMaxEdFieldY(horizontal_scrollbar_needed);
+
+ ed_fieldx = (ed_xsize > max_ed_fieldx ? max_ed_fieldx : ed_xsize);
+ ed_fieldy = (ed_ysize > max_ed_fieldy ? max_ed_fieldy : ed_ysize);
+
+ x = SX + ed_fieldx * ed_tilesize;
+ y = SY + ed_fieldy * ed_tilesize;
- ed_fieldx = (ed_xsize < MAX_ED_FIELDX ? ed_xsize : max_ed_fieldx);
- ed_fieldy = (ed_ysize < MAX_ED_FIELDY ? ed_ysize : max_ed_fieldy);
+ width = ed_fieldx * ed_tilesize - 2 * ED_SCROLLBUTTON_XSIZE;
+ height = ed_fieldy * ed_tilesize - 2 * ED_SCROLLBUTTON_YSIZE;
+ /* adjust drawing area gadget */
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_ITEM_SIZE, ed_tilesize, ed_tilesize,
GDI_END);
- xoffset = (ed_fieldx == MAX_ED_FIELDX ? ED_SCROLLBUTTON_XSIZE : 0);
- yoffset = (ed_fieldy == MAX_ED_FIELDY ? ED_SCROLLBUTTON_YSIZE : 0);
-
- x = SX + scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_RIGHT].x + xoffset;
- y = SX + scrollbutton_pos[ED_SCROLLBUTTON_ID_AREA_DOWN].y + yoffset;
-
- ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END);
- ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END);
-
- width = scrollbar_pos[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
- height = scrollbar_pos[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
-
+ /* adjust horizontal scrollbar gadgets */
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LEFT],
+ GDI_Y, y,
+ GDI_END);
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT],
+ GDI_X, x - ED_SCROLLBUTTON_XSIZE,
+ GDI_Y, y,
+ GDI_END);
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
+ GDI_Y, y,
GDI_WIDTH, width,
GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldx,
GDI_END);
+
+ /* adjust vertical scrollbar gadgets */
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_UP],
+ GDI_X, x,
+ GDI_END);
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN],
+ GDI_X, x,
+ GDI_Y, y - ED_SCROLLBUTTON_YSIZE,
+ GDI_END);
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
+ GDI_X, x,
GDI_HEIGHT, height,
GDI_SCROLLBAR_ITEMS_VISIBLE, ed_fieldy,
GDI_END);
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;
}
AdjustEditorScrollbar(GADGET_ID_SCROLL_HORIZONTAL);
AdjustEditorScrollbar(GADGET_ID_SCROLL_VERTICAL);
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
MapMainDrawingArea();
MapLevelEditorToolboxDrawingGadgets();
{
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;
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);
}
static void DrawPropertiesConfig()
{
+ boolean draw_footer_line = FALSE;
int max_num_element_counters = 4;
int num_element_counters = 0;
int i;
/* draw drawing area gadgets */
MapDrawingArea(ED_DRAWING_ID_CUSTOM_GRAPHIC);
+
+ draw_footer_line = TRUE;
}
else if (edit_mode_properties == ED_MODE_PROPERTIES_CONFIG_2)
{
/* 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);
}
}
Feld[x][y] = element;
if (IN_ED_FIELD(sx, sy))
- DrawMiniElement(sx, sy, element);
+ DrawEditorElement(sx, sy, element);
}
static void MergeAndCloseNeighbourElements(int x1, int y1, int *element1,
if (from_y > to_y)
swap_numbers(&from_y, &to_y);
- from_sx = SX + from_x * MINI_TILEX;
- from_sy = SY + from_y * MINI_TILEY;
- to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
- to_sy = SY + to_y * MINI_TILEY + MINI_TILEY - 1;
+ from_sx = SX + from_x * ed_tilesize;
+ from_sy = SY + from_y * ed_tilesize;
+ to_sx = SX + (to_x + 1) * ed_tilesize - 1;
+ to_sy = SY + (to_y + 1) * ed_tilesize - 1;
DrawSimpleWhiteLine(drawto, from_sx, from_sy, to_sx, from_sy);
DrawSimpleWhiteLine(drawto, to_sx, from_sy, to_sx, to_sy);
else if (element >= NUM_FILE_ELEMENTS)
element_mapped = EL_UNKNOWN;
+ // dump brush as level sketch text for the R'n'D forum:
+ // - large tiles: `xxx (0x60 ASCII)
+ // - small tiles: ¸xxx (0xb8 ISO-8859-1, 0xc2b8 UTF-8)
printf("%s%03d", (mode == CB_DUMP_BRUSH ? "`" : "¸"), element_mapped);
}
break;
case TEXT_SETCURSOR:
- DrawMiniElement(last_sx, last_sy, Feld[lx][ly]);
+ DrawEditorElement(last_sx, last_sy, Feld[lx][ly]);
DrawAreaBorder(sx, sy, sx, sy);
last_sx = sx;
last_sy = sy;
case TEXT_WRITECHAR:
if (letter_element >= EL_CHAR_START && letter_element <= EL_CHAR_END)
{
+ if (new_element1 >= EL_STEEL_CHAR_START &&
+ new_element1 <= EL_STEEL_CHAR_END)
+ letter_element = letter_element - EL_CHAR_START + EL_STEEL_CHAR_START;
+
delete_buffer[sx - start_sx] = Feld[lx][ly];
Feld[lx][ly] = letter_element;
if (sx > start_sx)
{
Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1];
- DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]);
+ DrawEditorElement(sx - 1, sy, Feld[lx - 1][ly]);
DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR);
}
break;
case TEXT_END:
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
- DrawMiniElement(sx, sy, Feld[lx][ly]);
+ DrawEditorElement(sx, sy, Feld[lx][ly]);
typing = FALSE;
break;
int ly = sy + level_ypos;
if (element == -1)
- DrawMiniElement(sx, sy, Feld[lx][ly]);
+ DrawEditorElement(sx, sy, Feld[lx][ly]);
else
DrawAreaBorder(sx, sy, sx, sy);
}
SetBorderElement();
if (redraw_playfield && BorderElement != last_border_element)
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
}
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:
if (new_undo_buffer_position)
{
- /* new position in undo buffer ring */
+ /* advance position in undo buffer ring */
undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
if (undo_buffer_steps < NUM_UNDO_STEPS - 1)
undo_buffer_steps++;
}
+ /* always reset redo buffer when storing level change into undo buffer */
+ redo_buffer_steps = 0;
+
for (x = 0; x < lev_fieldx; x++)
for (y = 0; y < lev_fieldy; y++)
UndoBuffer[undo_buffer_position][x][y] = Feld[x][y];
}
}
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
}
Feld[x][y] =
FieldBackup[(x + wrap_dx) % lev_fieldx][(y + wrap_dy) % lev_fieldy];
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
CopyLevelToUndoBuffer(UNDO_ACCUMULATE);
}
if (button_press_event && Feld[lx][ly] != new_element)
{
FloodFill(lx, ly, new_element);
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
}
break;
case ED_COUNTER_ID_LEVEL_YSIZE:
lev_fieldx = level.fieldx;
lev_fieldy = level.fieldy;
+
+ /* check if resizing of level results in change of border border */
+ SetBorderElement();
+
break;
default:
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 &&
if (level_xpos < -1)
level_xpos = -1;
if (button == 1)
- ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
+ ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_RIGHT);
else
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
if (level_xpos > lev_fieldx - ed_fieldx + 1)
level_xpos = lev_fieldx - ed_fieldx + 1;
if (button == 1)
- ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
+ ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
else
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
if (level_ypos < -1)
level_ypos = -1;
if (button == 1)
- ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
+ ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_DOWN);
else
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
if (level_ypos > lev_fieldy - ed_fieldy + 1)
level_ypos = lev_fieldy - ed_fieldy + 1;
if (button == 1)
- ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
+ ScrollEditorLevel(level_xpos, level_ypos, ED_SCROLL_UP);
else
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
case GADGET_ID_SCROLL_HORIZONTAL:
level_xpos = gi->event.item_position - 1;
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
break;
case GADGET_ID_SCROLL_VERTICAL:
level_ypos = gi->event.item_position - 1;
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
break;
case GADGET_ID_SCROLL_LIST_UP:
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;
RandomPlacement(new_element);
break;
- case GADGET_ID_PROPERTIES:
- if (edit_mode != ED_MODE_PROPERTIES)
- {
- properties_element = new_element;
- DrawPropertiesWindow();
- edit_mode = ED_MODE_PROPERTIES;
+ case GADGET_ID_ZOOM:
+ // zoom level editor tile size in or out (or reset to default size)
+ ed_tilesize = (button == 1 ? ed_tilesize / 2 :
+ button == 2 ? DEFAULT_EDITOR_TILESIZE :
+ button == 3 ? ed_tilesize * 2 : ed_tilesize);
- last_level_drawing_function = drawing_function;
- ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS],
- MB_LEFTBUTTON);
- }
- else
- {
+ // limit zoom level by upper and lower bound
+ ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
+
+ InitZoomLevelSettings();
+
+ if (edit_mode == ED_MODE_DRAWING)
DrawDrawingWindow();
- edit_mode = ED_MODE_DRAWING;
- ClickOnGadget(level_editor_gadget[last_level_drawing_function],
- MB_LEFTBUTTON);
- }
break;
case GADGET_ID_CUSTOM_COPY_FROM:
break;
case GADGET_ID_UNDO:
- if (undo_buffer_steps == 0)
+ if (button == 1 && undo_buffer_steps == 0)
{
Request("Undo buffer empty!", REQ_CONFIRM);
+
+ break;
+ }
+ else if (button == 2)
+ {
+ break;
+ }
+ else if (button == 3 && redo_buffer_steps == 0)
+ {
+ Request("Redo buffer empty!", REQ_CONFIRM);
+
break;
}
edit_mode = ED_MODE_DRAWING;
}
- undo_buffer_position =
- (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
- undo_buffer_steps--;
+ if (button == 1)
+ {
+ /* undo */
+
+ undo_buffer_position =
+ (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
+
+ undo_buffer_steps--;
+ redo_buffer_steps++;
+ }
+ else
+ {
+ /* redo */
+
+ undo_buffer_position = (undo_buffer_position + 1) % NUM_UNDO_STEPS;
+
+ undo_buffer_steps++;
+ redo_buffer_steps--;
+ }
for (x = 0; x < lev_fieldx; x++)
for (y = 0; y < lev_fieldy; y++)
/* check if undo operation forces change of border style */
CheckLevelBorderElement(FALSE);
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
break;
CopyLevelToUndoBuffer(GADGET_ID_CLEAR);
- DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
+ DrawEditorLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
break;
case GADGET_ID_SAVE:
/* needed before playing if editor playfield area has different size */
ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
- redraw_mask = REDRAW_ALL;
+ // redraw_mask = REDRAW_ALL;
level_editor_test_game = TRUE;
break;
case KSYM_Page_Up:
id = GADGET_ID_SCROLL_LIST_UP;
- button = MB_RIGHTBUTTON;
+ button = ED_ELEMENTLIST_BUTTONS_VERT - 1;
break;
case KSYM_Page_Down:
id = GADGET_ID_SCROLL_LIST_DOWN;
- button = MB_RIGHTBUTTON;
+ button = ED_ELEMENTLIST_BUTTONS_VERT - 1;
break;
case KSYM_Home:
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 (letter == 'U')
+ ClickOnGadget(level_editor_gadget[GADGET_ID_UNDO], 3);
+ else if (key == KSYM_KP_Subtract)
+ ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 1);
+ else if (key == KSYM_KP_0 || letter == '0')
+ ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 2);
+ else if (key == KSYM_KP_Add || letter == '+')
+ ClickOnGadget(level_editor_gadget[GADGET_ID_ZOOM], 3);
else if (key == KSYM_Return ||
key == KSYM_space ||
key == setup.shortcut.toggle_pause)
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);
}
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)
{
- if (gi->custom_id == GADGET_ID_SINGLE_ITEMS) /* special case 1 */
+ if (gi->custom_id == GADGET_ID_SINGLE_ITEMS)
sprintf(shortcut, " ('.' or '%c')", key);
- else if (gi->custom_id == GADGET_ID_PICK_ELEMENT) /* special case 2 */
+ else if (gi->custom_id == GADGET_ID_PICK_ELEMENT)
sprintf(shortcut, " ('%c' or 'Ctrl')", key);
- else if (gi->custom_id == GADGET_ID_TEST) /* special case 3 */
+ else if (gi->custom_id == GADGET_ID_TEST)
sprintf(shortcut, " ('Enter' or 'Shift-%c')", key);
- else /* normal case */
+ else if (gi->custom_id == GADGET_ID_UNDO)
+ sprintf(shortcut, " ('%c/Shift-U')", key);
+ else if (gi->custom_id == GADGET_ID_ZOOM)
+ sprintf(shortcut, " ('%c', '0', '+')", key);
+ else
sprintf(shortcut, " ('%s%c')",
(key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);