char cursor_letter;
char cursor_string[3];
char text[MAX_GADGET_TEXTSIZE + 1];
- int font_color = FC_YELLOW;
- int border = gi->design_border;
+ int font_type = gi->text.font_type;
+ int font_width = getFontWidth(FS_SMALL, font_type);
+ int border = gi->border.size;
strcpy(text, gi->text.value);
strcat(text, " ");
/* middle part of gadget */
for (i=0; i<=gi->text.size; i++)
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + border, gd->y, FONT2_XSIZE, gi->height,
- gi->x + border + i * FONT2_XSIZE, gi->y);
+ gd->x + border, gd->y, font_width, gi->height,
+ gi->x + border + i * font_width, gi->y);
/* right part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + ED_WIN_COUNT_XSIZE - border, gd->y,
+ gd->x + gi->border.width - border, gd->y,
border, gi->height, gi->x + gi->width - border, gi->y);
/* gadget text value */
- DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_color);
+ DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_type);
cursor_letter = gi->text.value[gi->text.cursor_position];
cursor_string[0] = '~';
/* draw cursor, if active */
if (pressed)
- DrawText(gi->x + border + gi->text.cursor_position * FONT2_XSIZE,
- gi->y + border, cursor_string, FS_SMALL, font_color);
+ DrawText(gi->x + border + gi->text.cursor_position * font_width,
+ gi->y + border, cursor_string, FS_SMALL, font_type);
}
break;
int xpos = gi->x;
int ypos = gi->y + gi->scrollbar.position;
int design_full = gi->width;
- int design_body = design_full - 2 * gi->design_border;
+ int design_body = design_full - 2 * gi->border.size;
int size_full = gi->scrollbar.size;
- int size_body = size_full - 2 * gi->design_border;
+ int size_body = size_full - 2 * gi->border.size;
int num_steps = size_body / design_body;
int step_size_remain = size_body - num_steps * design_body;
/* upper part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
gd->x, gd->y,
- gi->width, gi->design_border,
+ gi->width, gi->border.size,
xpos, ypos);
/* middle part of gadget */
for (i=0; i<num_steps; i++)
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x, gd->y + gi->design_border,
+ gd->x, gd->y + gi->border.size,
gi->width, design_body,
- xpos, ypos + gi->design_border + i * design_body);
+ xpos, ypos + gi->border.size + i * design_body);
/* remaining middle part of gadget */
if (step_size_remain > 0)
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x, gd->y + gi->design_border,
+ gd->x, gd->y + gi->border.size,
gi->width, step_size_remain,
- xpos, ypos + gi->design_border + num_steps * design_body);
+ xpos, ypos + gi->border.size + num_steps * design_body);
/* lower part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x, gd->y + design_full - gi->design_border,
- gi->width, gi->design_border,
- xpos, ypos + size_full - gi->design_border);
+ gd->x, gd->y + design_full - gi->border.size,
+ gi->width, gi->border.size,
+ xpos, ypos + size_full - gi->border.size);
}
break;
int xpos = gi->x + gi->scrollbar.position;
int ypos = gi->y;
int design_full = gi->height;
- int design_body = design_full - 2 * gi->design_border;
+ int design_body = design_full - 2 * gi->border.size;
int size_full = gi->scrollbar.size;
- int size_body = size_full - 2 * gi->design_border;
+ int size_body = size_full - 2 * gi->border.size;
int num_steps = size_body / design_body;
int step_size_remain = size_body - num_steps * design_body;
/* left part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
gd->x, gd->y,
- gi->design_border, gi->height,
+ gi->border.size, gi->height,
xpos, ypos);
/* middle part of gadget */
for (i=0; i<num_steps; i++)
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + gi->design_border, gd->y,
+ gd->x + gi->border.size, gd->y,
design_body, gi->height,
- xpos + gi->design_border + i * design_body, ypos);
+ xpos + gi->border.size + i * design_body, ypos);
/* remaining middle part of gadget */
if (step_size_remain > 0)
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + gi->design_border, gd->y,
+ gd->x + gi->border.size, gd->y,
step_size_remain, gi->height,
- xpos + gi->design_border + num_steps * design_body, ypos);
+ xpos + gi->border.size + num_steps * design_body, ypos);
/* right part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + design_full - gi->design_border, gd->y,
- gi->design_border, gi->height,
- xpos + size_full - gi->design_border, ypos);
+ gd->x + design_full - gi->border.size, gd->y,
+ gi->border.size, gi->height,
+ xpos + size_full - gi->border.size, ypos);
}
break;
gi->text.size = max_textsize;
gi->text.value[max_textsize] = '\0';
-
- if (gi->width == 0 && gi->height == 0)
- {
- gi->width = (gi->text.size + 1) * FONT2_XSIZE + 6;
- gi->height = ED_WIN_COUNT_YSIZE;
- }
}
break;
+ case GDI_TEXT_FONT:
+ gi->text.font_type = va_arg(ap, int);
+ break;
+
case GDI_DESIGN_UNPRESSED:
gi->design[GD_BUTTON_UNPRESSED].pixmap = va_arg(ap, Pixmap);
gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
gi->alt_design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
break;
- case GDI_DESIGN_BORDER:
- gi->design_border = va_arg(ap, int);
+ case GDI_BORDER_SIZE:
+ gi->border.size = va_arg(ap, int);
+ break;
+
+ case GDI_TEXTINPUT_DESIGN_WIDTH:
+ gi->border.width = va_arg(ap, int);
break;
case GDI_DECORATION_DESIGN:
/* adjust gadget values in relation to other gadget values */
+ if (gi->type & GD_TYPE_TEXTINPUT)
+ {
+ int font_width = getFontWidth(FS_SMALL, gi->text.font_type);
+ int font_height = getFontHeight(FS_SMALL, gi->text.font_type);
+
+ gi->width = 2 * gi->border.size + (gi->text.size + 1) * font_width;
+ gi->height = 2 * gi->border.size + font_height;
+ }
+
if (gi->type & GD_TYPE_TEXTINPUT_NUMERIC)
{
struct GadgetTextInput *text = &gi->text;
gs->size = gs->size_max * gs->items_visible / gs->items_max;
gs->position = gs->size_max * gs->item_position / gs->items_max;
gs->position_max = gs->size_max - gs->size;
+ gs->correction = gs->size_max / gs->items_max / 2;
/* finetuning for maximal right/bottom position */
if (gs->item_position == gs->items_max - gs->items_visible)
if (new_gi == last_gi)
{
/* if mouse button pressed inside activated text gadget, set cursor */
- gi->text.cursor_position = (mx - gi->x) / FONT2_XSIZE;
+ gi->text.cursor_position =
+ (mx - gi->x - gi->border.size) /
+ getFontWidth(FS_SMALL, gi->text.font_type);
if (gi->text.cursor_position < 0)
gi->text.cursor_position = 0;
CheckRangeOfNumericInputGadget(gi);
DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
+ gi->event.type = GD_EVENT_TEXT_LEAVING;
+
if (gi->event_mask & GD_EVENT_TEXT_LEAVING)
gi->callback_action(gi);
if (gs->position > gs->position_max)
gs->position = gs->position_max;
- gs->item_position = gs->items_max * gs->position / gs->size_max;
+ gs->item_position =
+ gs->items_max * (gs->position + gs->correction) / gs->size_max;
+
+ if (gs->item_position < 0)
+ gs->item_position = 0;
+ if (gs->item_position > gs->items_max - 1)
+ gs->item_position = gs->items_max - 1;
if (old_item_position != gs->item_position)
{
CheckRangeOfNumericInputGadget(gi);
DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
+ gi->event.type = GD_EVENT_TEXT_RETURN;
+
if (gi->event_mask & GD_EVENT_TEXT_RETURN)
gi->callback_action(gi);
#include "tape.h"
/* positions in the level editor */
-#define ED_WIN_MB_LEFT_XPOS 7
-#define ED_WIN_MB_LEFT_YPOS 6
-#define ED_WIN_LEVELNR_XPOS 77
-#define ED_WIN_LEVELNR_YPOS 7
-#define ED_WIN_MB_MIDDLE_XPOS 7
-#define ED_WIN_MB_MIDDLE_YPOS 258
-#define ED_WIN_MB_RIGHT_XPOS 77
-#define ED_WIN_MB_RIGHT_YPOS 258
+#define ED_WIN_MB_LEFT_XPOS 6
+#define ED_WIN_MB_LEFT_YPOS 258
+#define ED_WIN_MB_MIDDLE_XPOS 42
+#define ED_WIN_MB_MIDDLE_YPOS ED_WIN_MB_LEFT_YPOS
+#define ED_WIN_MB_RIGHT_XPOS 78
+#define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS
/* other constants for the editor */
#define ED_SCROLL_NO 0
#define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS)
/* values for the element list */
-#define ED_ELEMENTLIST_UP_XPOS 35
-#define ED_ELEMENTLIST_UP_YPOS 5
-#define ED_ELEMENTLIST_UP_ALT_YPOS 140
-#define ED_ELEMENTLIST_DOWN_XPOS 35
-#define ED_ELEMENTLIST_DOWN_YPOS 250
-#define ED_ELEMENTLIST_DOWN_ALT_YPOS 165
-#define ED_ELEMENTLIST_UPDOWN_XSIZE 30
-#define ED_ELEMENTLIST_UPDOWN_YSIZE 25
-#define ED_ELEMENTLIST_XPOS 6
+#define ED_ELEMENTLIST_XPOS 5
#define ED_ELEMENTLIST_YPOS 30
-#define ED_ELEMENTLIST_ALT_YPOS 190
-#define ED_ELEMENTLIST_XSIZE 22
-#define ED_ELEMENTLIST_YSIZE 22
+#define ED_ELEMENTLIST_XSIZE 20
+#define ED_ELEMENTLIST_YSIZE 20
#define ED_ELEMENTLIST_BUTTONS_HORIZ 4
-#define ED_ELEMENTLIST_BUTTONS_VERT 10
+#define ED_ELEMENTLIST_BUTTONS_VERT 11
#define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
ED_ELEMENTLIST_BUTTONS_VERT)
#define ED_AREA_RANDOM_BACKGROUND_XPOS (29 * MINI_TILEX)
#define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY)
-/* values for scrolling gadgets */
+/* values for scrolling gadgets for drawing area */
#define ED_SCROLLBUTTON_XPOS 24
#define ED_SCROLLBUTTON_YPOS 0
#define ED_SCROLLBAR_XPOS 24
#define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE
#define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE)
+/* values for scrolling gadgets for element list */
+#define ED_SCROLLBUTTON2_XPOS 50
+#define ED_SCROLLBUTTON2_YPOS 0
+#define ED_SCROLLBAR2_XPOS 50
+#define ED_SCROLLBAR2_YPOS 20
+
+#define ED_SCROLLBUTTON2_XSIZE 10
+#define ED_SCROLLBUTTON2_YSIZE 10
+
+#define ED_SCROLL2_UP_XPOS 85
+#define ED_SCROLL2_UP_YPOS 30
+#define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS
+#define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \
+ ED_ELEMENTLIST_BUTTONS_VERT * \
+ ED_ELEMENTLIST_YSIZE - \
+ ED_SCROLLBUTTON2_YSIZE)
+#define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS
+#define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \
+ ED_SCROLLBUTTON2_YSIZE)
+#define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE
+#define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \
+ ED_ELEMENTLIST_YSIZE - \
+ 2 * ED_SCROLLBUTTON2_YSIZE)
+
/* values for checkbutton gadgets */
#define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE
#define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE
#define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS
#define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS
#define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22)
-#define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 88)
+#define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44)
+#define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66)
/* some positions in the editor control window */
#define ED_BUTTON_ELEM_XPOS 6
#define ED_BUTTON_ELEM_XSIZE 22
#define ED_BUTTON_ELEM_YSIZE 22
+/* some values for text input and counter gadgets */
+#define ED_BUTTON_COUNT_YPOS 60
+#define ED_BUTTON_COUNT_XSIZE 20
+#define ED_BUTTON_COUNT_YSIZE 20
+#define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2)
+#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 ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
#define GADGET_ID_SCROLL_VERTICAL 66
/* gadgets for scrolling element list */
-#define GADGET_ID_ELEMENTLIST_UP 67
-#define GADGET_ID_ELEMENTLIST_DOWN 68
-
-/* gadgets for buttons in element list */
-#define GADGET_ID_ELEMENTLIST_FIRST 69
-#define GADGET_ID_ELEMENTLIST_LAST 108
+#define GADGET_ID_SCROLL_LIST_UP 67
+#define GADGET_ID_SCROLL_LIST_DOWN 68
+#define GADGET_ID_SCROLL_LIST_VERTICAL 69
/* buttons for level settings */
-#define GADGET_ID_RANDOM_PERCENTAGE 109
-#define GADGET_ID_RANDOM_QUANTITY 110
-#define GADGET_ID_RANDOM_RESTRICTED 111
-#define GADGET_ID_DOUBLE_SPEED 112
-#define GADGET_ID_GRAVITY 113
-#define GADGET_ID_STICK_ELEMENT 114
+#define GADGET_ID_RANDOM_PERCENTAGE 70
+#define GADGET_ID_RANDOM_QUANTITY 71
+#define GADGET_ID_RANDOM_RESTRICTED 72
+#define GADGET_ID_DOUBLE_SPEED 73
+#define GADGET_ID_GRAVITY 74
+#define GADGET_ID_STICK_ELEMENT 75
/* another drawing area for random placement */
-#define GADGET_ID_RANDOM_BACKGROUND 115
+#define GADGET_ID_RANDOM_BACKGROUND 76
+
+/* gadgets for buttons in element list */
+#define GADGET_ID_ELEMENTLIST_FIRST 77
+#define GADGET_ID_ELEMENTLIST_LAST (77 + ED_NUM_ELEMENTLIST_BUTTONS - 1)
-#define NUM_EDITOR_GADGETS 116
+#define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1)
/* radio button numbers */
#define RADIO_NR_NONE 0
#define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT
/* values for scrollbar gadgets */
-#define ED_SCROLLBAR_ID_HORIZONTAL 0
-#define ED_SCROLLBAR_ID_VERTICAL 1
+#define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0
+#define ED_SCROLLBAR_ID_AREA_VERTICAL 1
+#define ED_SCROLLBAR_ID_LIST_VERTICAL 2
-#define ED_NUM_SCROLLBARS 2
+#define ED_NUM_SCROLLBARS 3
+
+#define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL
+#define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL
/* values for text input gadgets */
#define ED_TEXTINPUT_ID_LEVEL_NAME 0
"random element placement", "in"
},
{
- DX - SX - 1, 0 - SY + 31,
+ DX + 5 - SX, DY + 3 - SY,
1, 100,
GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP,
GADGET_ID_SELECT_LEVEL_TEXT,
"scroll level editing area right"
},
{
- ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_ALT_YPOS,
- ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_YPOS,
- GADGET_ID_ELEMENTLIST_UP,
+ ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE,
+ ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS,
+ GADGET_ID_SCROLL_LIST_UP,
"scroll element list up ('Page Up')"
},
{
- ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_ALT_YPOS,
- ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_YPOS,
- GADGET_ID_ELEMENTLIST_DOWN,
+ ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE,
+ ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS,
+ GADGET_ID_SCROLL_LIST_DOWN,
"scroll element list down ('Page Down')"
}
};
} scrollbar_info[ED_NUM_SCROLLBARS] =
{
{
- ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
- ED_SCROLL_HORIZONTAL_XPOS, ED_SCROLL_HORIZONTAL_YPOS,
- ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
+ ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
+ SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS,
+ ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE,
GD_TYPE_SCROLLBAR_HORIZONTAL,
GADGET_ID_SCROLL_HORIZONTAL,
"scroll level editing area horizontally"
},
{
- ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
- ED_SCROLL_VERTICAL_XPOS, ED_SCROLL_VERTICAL_YPOS,
- ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
+ ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS,
+ SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS,
+ ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE,
GD_TYPE_SCROLLBAR_VERTICAL,
GADGET_ID_SCROLL_VERTICAL,
"scroll level editing area vertically"
+ },
+ {
+ ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS,
+ DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS,
+ ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE,
+ GD_TYPE_SCROLLBAR_VERTICAL,
+ GADGET_ID_SCROLL_LIST_VERTICAL,
+ "scroll element list vertically"
}
};
event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
- if (id == GADGET_ID_ELEMENTLIST_UP ||
- id == GADGET_ID_ELEMENTLIST_DOWN)
+ if (id == GADGET_ID_SCROLL_LIST_UP ||
+ id == GADGET_ID_SCROLL_LIST_DOWN)
{
x += DX;
y += DY;
- width = ED_ELEMENTLIST_UPDOWN_XSIZE;
- height = ED_ELEMENTLIST_UPDOWN_YSIZE;
- gd_x1 = DOOR_GFX_PAGEX6 + scrollbutton_info[i].xpos;
- gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].y;
- gd_x2 = gd_x1;
- gd_y2 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos;
+ width = ED_SCROLLBUTTON2_XSIZE;
+ height = ED_SCROLLBUTTON2_YSIZE;
+ gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].xpos;
+ gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos;
+ gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE;
+ gd_y2 = gd_y1;
}
else
{
Pixmap deco_pixmap;
int deco_x, deco_y, deco_xpos, deco_ypos;
int gd_xoffset, gd_yoffset;
- int gd_x, gd_y1, gd_y2;
+ int gd_x1, gd_x2, gd_y;
int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ;
int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ;
int id = GADGET_ID_ELEMENTLIST_FIRST + i;
gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE;
gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE;
- gd_x = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
- gd_y1 = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
- gd_y2 = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_ALT_YPOS;
+ gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE;
+ gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS;
+ gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS;
getMiniGraphicSource(el2gfx(editor_element[i]),
&deco_pixmap, &deco_x, &deco_y);
GDI_HEIGHT, ED_ELEMENTLIST_YSIZE,
GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
GDI_STATE, GD_BUTTON_UNPRESSED,
- GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y1,
- GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y2,
+ GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
+ GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
GDI_DECORATION_DESIGN, deco_pixmap, deco_x, deco_y,
GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
event_mask |= GD_EVENT_RELEASED;
if (j == 1)
- xpos += ED_GADGET_DISTANCE;
+ xpos += 2 * ED_GADGET_DISTANCE;
ypos += ED_GADGET_DISTANCE;
gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].xpos;
if (j == 0)
{
+ int font_type = FC_YELLOW;
+ int gd_width = ED_WIN_COUNT_XSIZE;
+
id = counterbutton_info[i].gadget_id_text;
event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING;
if (i == ED_COUNTER_ID_SELECT_LEVEL)
{
- xpos += ED_GADGET_DISTANCE;
+ font_type = FC_SPECIAL3;
+
+ xpos += 2 * ED_GADGET_DISTANCE;
ypos -= ED_GADGET_DISTANCE;
- gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS;
- gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS;
+ 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_NUMBER_MIN, counterbutton_info[i].min_value,
GDI_NUMBER_MAX, counterbutton_info[i].max_value,
GDI_TEXT_SIZE, 3,
+ GDI_TEXT_FONT, font_type,
GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
- GDI_DESIGN_BORDER, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_TEXTINPUT_DESIGN_WIDTH, gd_width,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_ACTION, HandleCounterButtons,
GDI_END);
GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
GDI_TEXT_VALUE, textinput_info[i].value,
GDI_TEXT_SIZE, textinput_info[i].size,
+ GDI_TEXT_FONT, FC_YELLOW,
GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y,
- GDI_DESIGN_BORDER, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_ACTION, HandleTextInputGadgets,
GDI_END);
int items_max, items_visible, item_position;
unsigned long event_mask;
- if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
+ if (i == ED_SCROLLBAR_ID_LIST_VERTICAL)
{
- items_max = MAX(lev_fieldx + 2, ed_fieldx);
- items_visible = ed_fieldx;
+ items_max = elements_in_list / ED_ELEMENTLIST_BUTTONS_HORIZ;
+ items_visible = ED_ELEMENTLIST_BUTTONS_VERT;
item_position = 0;
}
- else
+ else /* drawing area scrollbars */
{
- items_max = MAX(lev_fieldy + 2, ed_fieldy);
- items_visible = ed_fieldy;
- item_position = 0;
+ if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL)
+ {
+ items_max = MAX(lev_fieldx + 2, ed_fieldx);
+ items_visible = ed_fieldx;
+ item_position = 0;
+ }
+ else
+ {
+ items_max = MAX(lev_fieldy + 2, ed_fieldy);
+ items_visible = ed_fieldy;
+ item_position = 0;
+ }
}
event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].xpos;
- gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE;
+ gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ?
+ scrollbar_info[i].height : scrollbar_info[i].width));
gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_CUSTOM_TYPE_ID, i,
GDI_INFO_TEXT, scrollbar_info[i].infotext,
- GDI_X, SX + scrollbar_info[i].x,
- GDI_Y, SY + scrollbar_info[i].y,
+ GDI_X, scrollbar_info[i].x,
+ GDI_Y, scrollbar_info[i].y,
GDI_WIDTH, scrollbar_info[i].width,
GDI_HEIGHT, scrollbar_info[i].height,
GDI_TYPE, scrollbar_info[i].type,
GDI_STATE, GD_BUTTON_UNPRESSED,
GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
- GDI_DESIGN_BORDER, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_ACTION, HandleControlButtons,
GDI_END);
gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS;
gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS;
gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS;
- gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS;
+ gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS;
for (i=0; i<ED_NUM_RADIOBUTTONS; i++)
{
/* map buttons to select elements */
for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_FIRST + i]);
- MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_UP]);
- MapGadget(level_editor_gadget[GADGET_ID_ELEMENTLIST_DOWN]);
+ MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL]);
+ MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_UP]);
+ MapGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_DOWN]);
/* map buttons to select level */
counter_id = ED_COUNTER_ID_SELECT_LEVEL;
MapGadget(level_editor_gadget[scrollbutton_info[i].gadget_id]);
}
- for (i=0; i<ED_NUM_SCROLLBARS; i++)
+ for (i=ED_SCROLLBAR_ID_AREA_FIRST; i<=ED_SCROLLBAR_ID_AREA_LAST; i++)
{
- if ((i == ED_SCROLLBAR_ID_HORIZONTAL && no_horizontal_scrollbar) ||
- (i == ED_SCROLLBAR_ID_VERTICAL && no_vertical_scrollbar))
+ if ((i == ED_SCROLLBAR_ID_AREA_HORIZONTAL && no_horizontal_scrollbar) ||
+ (i == ED_SCROLLBAR_ID_AREA_VERTICAL && no_vertical_scrollbar))
continue;
MapGadget(level_editor_gadget[scrollbar_info[i].gadget_id]);
DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
el2gfx(new_element3));
- /* draw level number */
- DrawTextExt(pix[PIX_DB_DOOR], gc,
- DOOR_GFX_PAGEX2 + ED_WIN_LEVELNR_XPOS,
- DOOR_GFX_PAGEY1 + ED_WIN_LEVELNR_YPOS,
- int2str(level_nr, 2), FS_SMALL, FC_SPECIAL1);
- /* copy level number to fit into level number field */
- XCopyArea(display, pix[PIX_DB_DOOR], drawto, gc,
- DOOR_GFX_PAGEX2 + ED_WIN_LEVELNR_XPOS + 3,
- DOOR_GFX_PAGEY1 + ED_WIN_LEVELNR_YPOS,
- 7, FONT3_YSIZE,
- DX + ED_WIN_LEVELNR_XPOS,
- DY + ED_WIN_LEVELNR_YPOS);
- XCopyArea(display, pix[PIX_DB_DOOR], drawto, gc,
- DOOR_GFX_PAGEX2 + ED_WIN_LEVELNR_XPOS + 14,
- DOOR_GFX_PAGEY1 + ED_WIN_LEVELNR_YPOS,
- 7, FONT3_YSIZE,
- DX + ED_WIN_LEVELNR_XPOS + 9,
- DY + ED_WIN_LEVELNR_YPOS);
-
/* draw bigger door */
DrawSpecialEditorDoor();
XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc,
DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
- /*
- DrawDrawingWindow();
- */
-
DrawEditModeWindow();
/*
*/
}
-void SelectNewLevelToEdit(struct GadgetInfo *gi)
-{
- int gadget_id = gi->custom_id;
- int counter_id = gi->custom_type_id;
- int button = gi->event.button;
- int *counter_value = counterbutton_info[counter_id].value;
- int step = BUTTON_STEPSIZE(button) *
- (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1);
- int old_counter_value = *counter_value;
- boolean released = (gi->event.type == GD_EVENT_RELEASED);
-
- if (LevelChanged())
- {
- if (gi->event.type == GD_EVENT_PRESSED)
- return;
-
- if (!Request("Level has changed! Discard changes ?", REQ_ASK))
- {
- ModifyEditorCounter(counter_id, old_counter_value);
- return;
- }
- }
- else if (released)
- return;
-
- if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
- *counter_value = gi->text.number_value;
- else
- ModifyEditorCounter(counter_id, *counter_value + step);
-
- LoadLevel(level_nr);
- ResetUndoBuffer();
- DrawEditModeWindow();
-}
-
static void AdjustDrawingAreaGadgets()
{
int ed_xsize = lev_fieldx + 2;
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_info[ED_SCROLLBAR_ID_HORIZONTAL].width + xoffset;
- height = scrollbar_info[ED_SCROLLBAR_ID_VERTICAL].height + yoffset;
+ width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset;
+ height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset;
ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
GDI_WIDTH, width,
{
new_element1 = element;
DrawMiniGraphicExt(drawto, gc,
- DX + ED_WIN_MB_LEFT_XPOS,
- DY + ED_WIN_MB_LEFT_YPOS,
+ DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS,
el2gfx(new_element1));
}
else if (button == 2)
{
new_element2 = element;
DrawMiniGraphicExt(drawto, gc,
- DX + ED_WIN_MB_MIDDLE_XPOS,
- DY + ED_WIN_MB_MIDDLE_YPOS,
+ DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS,
el2gfx(new_element2));
}
else
{
new_element3 = element;
DrawMiniGraphicExt(drawto, gc,
- DX + ED_WIN_MB_RIGHT_XPOS,
- DY + ED_WIN_MB_RIGHT_YPOS,
+ DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS,
el2gfx(new_element3));
}
if (counter_id == ED_COUNTER_ID_SELECT_LEVEL)
{
- SelectNewLevelToEdit(gi);
- return;
+ boolean pressed = (gi->event.type == GD_EVENT_PRESSED);
+ boolean released = (gi->event.type == GD_EVENT_RELEASED);
+ boolean level_changed = LevelChanged();
+
+ if ((level_changed && pressed) || (!level_changed && released))
+ return;
+
+ if (level_changed && !Request("Level has changed! Discard changes ?",
+ REQ_ASK))
+ {
+ if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
+ ModifyEditorCounter(counter_id, *counter_value);
+ return;
+ }
}
if (gadget_id == counterbutton_info[counter_id].gadget_id_text)
else
ModifyEditorCounter(counter_id, *counter_value + step);
- if (counter_id == ED_COUNTER_ID_ELEM_CONTENT)
- DrawElementContentAreas();
- else if (counter_id == ED_COUNTER_ID_LEVEL_XSIZE)
- lev_fieldx = level.fieldx;
- else if (counter_id == ED_COUNTER_ID_LEVEL_YSIZE)
- lev_fieldy = level.fieldy;
+ switch (counter_id)
+ {
+ case ED_COUNTER_ID_ELEM_CONTENT:
+ DrawElementContentAreas();
+ break;
+
+ case ED_COUNTER_ID_LEVEL_XSIZE:
+ case ED_COUNTER_ID_LEVEL_YSIZE:
+ lev_fieldx = level.fieldx;
+ lev_fieldy = level.fieldy;
+ break;
+
+ case ED_COUNTER_ID_SELECT_LEVEL:
+ LoadLevel(level_nr);
+ ResetUndoBuffer();
+ DrawEditModeWindow();
+ break;
+
+ default:
+ break;
+ }
}
static void HandleTextInputGadgets(struct GadgetInfo *gi)
case GADGET_ID_SCROLL_LEFT:
if (level_xpos >= 0)
{
- int gadget_id = GADGET_ID_SCROLL_HORIZONTAL;
- struct GadgetInfo *gi = level_editor_gadget[gadget_id];
-
if (lev_fieldx < ed_fieldx - 2)
break;
else
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
- ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
+ GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
}
break;
case GADGET_ID_SCROLL_RIGHT:
if (level_xpos <= lev_fieldx - ed_fieldx)
{
- int gadget_id = GADGET_ID_SCROLL_HORIZONTAL;
- struct GadgetInfo *gi = level_editor_gadget[gadget_id];
-
if (lev_fieldx < ed_fieldx - 2)
break;
else
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
- ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL],
+ GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END);
}
break;
case GADGET_ID_SCROLL_UP:
if (level_ypos >= 0)
{
- int gadget_id = GADGET_ID_SCROLL_VERTICAL;
- struct GadgetInfo *gi = level_editor_gadget[gadget_id];
-
if (lev_fieldy < ed_fieldy - 2)
break;
else
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
- ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
+ GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
}
break;
case GADGET_ID_SCROLL_DOWN:
if (level_ypos <= lev_fieldy - ed_fieldy)
{
- int gadget_id = GADGET_ID_SCROLL_VERTICAL;
- struct GadgetInfo *gi = level_editor_gadget[gadget_id];
-
if (lev_fieldy < ed_fieldy - 2)
break;
else
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
- ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL],
+ GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END);
}
break;
DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos);
break;
- case GADGET_ID_ELEMENTLIST_UP:
- case GADGET_ID_ELEMENTLIST_DOWN:
- step *= (id == GADGET_ID_ELEMENTLIST_UP ? -1 : +1);
- element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
+ case GADGET_ID_SCROLL_LIST_UP:
+ case GADGET_ID_SCROLL_LIST_DOWN:
+ case GADGET_ID_SCROLL_LIST_VERTICAL:
+ if (id == GADGET_ID_SCROLL_LIST_VERTICAL)
+ element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ;
+ else
+ {
+ step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1);
+ element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ;
- if (element_shift < 0)
- element_shift = 0;
- if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS)
- element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS;
+ if (element_shift < 0)
+ element_shift = 0;
+ if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS)
+ element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS;
+
+ ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL],
+ GDI_SCROLLBAR_ITEM_POSITION,
+ element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END);
+ }
for (i=0; i<ED_NUM_ELEMENTLIST_BUTTONS; i++)
{
id = GADGET_ID_SCROLL_DOWN;
break;
case XK_Page_Up:
- id = GADGET_ID_ELEMENTLIST_UP;
+ id = GADGET_ID_SCROLL_LIST_UP;
button = 3;
break;
case XK_Page_Down:
- id = GADGET_ID_ELEMENTLIST_DOWN;
+ id = GADGET_ID_SCROLL_LIST_DOWN;
button = 3;
break;