new_gadget->state = va_arg(ap, unsigned long);
break;
- case GDI_ALT_STATE:
- new_gadget->state = va_arg(ap, boolean);
+ case GDI_RADIO_NR:
+ new_gadget->radio_nr = va_arg(ap, unsigned long);
+ break;
+
+ case GDI_RADIO_PRESSED:
+ new_gadget->radio_pressed = va_arg(ap, boolean);
break;
case GDI_NUMBER_VALUE:
free(gi);
}
+/* values for DrawGadget() */
+#define DG_UNPRESSED 0
+#define DG_PRESSED 1
+#define DG_BUFFERED 0
+#define DG_DIRECT 1
+
static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
{
int state = (pressed ? 1 : 0);
- struct GadgetDesign *gd = (gi->alt_state ?
+ struct GadgetDesign *gd = (gi->radio_pressed ?
&gi->alt_design[state] :
&gi->design[state]);
- if (gi->type != GD_TYPE_NORMAL_BUTTON)
+ if (gi->type != GD_TYPE_NORMAL_BUTTON &&
+ gi->type != GD_TYPE_RADIO_BUTTON)
return;
XCopyArea(display, gd->pixmap, drawto, gc,
gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
if (direct)
- XCopyArea(display, gd->pixmap, window, gc,
- gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
+ XCopyArea(display, drawto, window, gc,
+ gi->x, gi->y, gi->width, gi->height, gi->x, gi->y);
else
redraw_mask |= REDRAW_ALL;
}
gi->mapped = TRUE;
- DrawGadget(gi, (gi->state == GD_BUTTON_PRESSED), FALSE);
+ DrawGadget(gi, (gi->state == GD_BUTTON_PRESSED), DG_BUFFERED);
}
void UnmapGadget(struct GadgetInfo *gi)
if (gadget_pressed)
{
- DrawGadget(gi, TRUE, TRUE);
+ if (gi->type == GD_TYPE_RADIO_BUTTON)
+ {
+ struct GadgetInfo *rgi = gadget_list_first_entry;
+
+ while (rgi)
+ {
+ if (rgi->mapped &&
+ rgi->type == GD_TYPE_RADIO_BUTTON &&
+ rgi->radio_nr == gi->radio_nr &&
+ rgi != gi)
+ {
+ rgi->radio_pressed = FALSE;
+ DrawGadget(rgi, DG_UNPRESSED, DG_DIRECT);
+ }
+
+ rgi = rgi->next;
+ }
+
+ gi->radio_pressed = TRUE;
+ }
+
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
gi->state = GD_BUTTON_PRESSED;
gi->event.type = GD_EVENT_PRESSED;
if (gadget_moving)
{
if (gi->state == GD_BUTTON_UNPRESSED)
- DrawGadget(gi, TRUE, TRUE);
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
gi->state = GD_BUTTON_PRESSED;
gi->event.type = GD_EVENT_MOVING;
if (gadget_moving_off_borders)
{
if (gi->state == GD_BUTTON_PRESSED)
- DrawGadget(gi, FALSE, TRUE);
+ DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
gi->state = GD_BUTTON_UNPRESSED;
gi->event.type = GD_EVENT_MOVING;
if (gadget_released)
{
- DrawGadget(gi, FALSE, TRUE);
+ DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
gi->state = GD_BUTTON_UNPRESSED;
gi->event.type = GD_EVENT_RELEASED;
#define RANDOM_USE_NUM_OBJECTS 1
/* values for the control window */
-#define ED_CTRL_BUTTONS_GFX_YPOS 236
+#define ED_CTRL_BUTTONS_GFX_YPOS 236
+#define ED_CTRL_BUTTONS_ALT_GFX_YPOS 142
+
#define ED_CTRL1_BUTTONS_HORIZ 4
#define ED_CTRL1_BUTTONS_VERT 4
#define ED_CTRL1_BUTTON_XSIZE 22
#define ED_CTRL_ID_PROPERTIES 7
#define ED_CTRL_ID_FLOOD_FILL 8
#define ED_CTRL_ID_WRAP_LEFT 9
+#define ED_CTRL_ID_UNUSED1 10
#define ED_CTRL_ID_WRAP_RIGHT 11
#define ED_CTRL_ID_RANDOM_PLACEMENT 12
#define ED_CTRL_ID_BRUSH 13
#define ED_CTRL_ID_WRAP_DOWN 14
+#define ED_CTRL_ID_UNUSED2 15
#define ED_CTRL_ID_UNDO 16
#define ED_CTRL_ID_INFO 17
#define ED_CTRL_ID_SAVE 18
Pixmap gd_pixmap = pix[PIX_DOOR];
struct GadgetInfo *gi;
int gd_xoffset, gd_yoffset;
- int gd_x1, gd_x2, gd_y;
+ int gd_x1, gd_x2, gd_y1, gd_y2;
int width, height;
+ int button_type;
+ int radio_button_nr;
+ boolean radio_button_pressed;
unsigned long event_mask;
int id = i;
- if (i < ED_NUM_CTRL1_BUTTONS)
+ if (id == ED_CTRL_ID_SINGLE_ITEMS ||
+ id == ED_CTRL_ID_CONNECTED_ITEMS ||
+ id == ED_CTRL_ID_LINE ||
+ id == ED_CTRL_ID_TEXT ||
+ id == ED_CTRL_ID_RECTANGLE ||
+ id == ED_CTRL_ID_FILLED_BOX ||
+ id == ED_CTRL_ID_FLOOD_FILL ||
+ id == ED_CTRL_ID_BRUSH)
+ {
+ button_type = GD_TYPE_RADIO_BUTTON;
+ radio_button_nr = 1;
+ radio_button_pressed = (id == drawing_function ? TRUE : FALSE);
+ event_mask = GD_EVENT_PRESSED;
+ }
+ else
+ {
+ button_type = GD_TYPE_NORMAL_BUTTON;
+ radio_button_nr = 0;
+ radio_button_pressed = FALSE;
+
+ if (id == ED_CTRL_ID_WRAP_LEFT ||
+ id == ED_CTRL_ID_WRAP_RIGHT ||
+ id == ED_CTRL_ID_WRAP_UP ||
+ id == ED_CTRL_ID_WRAP_DOWN)
+ event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
+ else
+ event_mask = GD_EVENT_RELEASED;
+ }
+
+ if (id < ED_NUM_CTRL1_BUTTONS)
{
int x = i % ED_CTRL1_BUTTONS_HORIZ;
int y = i / ED_CTRL1_BUTTONS_HORIZ;
gd_x1 = DOOR_GFX_PAGEX8 + gd_xoffset;
gd_x2 = DOOR_GFX_PAGEX7 + gd_xoffset;
- gd_y = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_GFX_YPOS + gd_yoffset;
-
- if (i == ED_CTRL_ID_WRAP_LEFT ||
- i == ED_CTRL_ID_WRAP_RIGHT ||
- i == ED_CTRL_ID_WRAP_UP ||
- i == ED_CTRL_ID_WRAP_DOWN)
- event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED;
- else
- event_mask = GD_EVENT_RELEASED;
+ gd_y1 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_GFX_YPOS + gd_yoffset;
+ gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
gi = CreateGadget(GDI_CUSTOM_ID, id,
GDI_X, EX + gd_xoffset,
GDI_Y, EY + gd_yoffset,
GDI_WIDTH, width,
GDI_HEIGHT, height,
- GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
+ GDI_TYPE, button_type,
GDI_STATE, GD_BUTTON_UNPRESSED,
- GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y,
- GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y,
+ GDI_RADIO_NR, radio_button_nr,
+ GDI_RADIO_PRESSED, radio_button_pressed,
+ GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1,
+ GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y1,
+ GDI_ALT_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y2,
+ GDI_ALT_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK, HandleControlButtons,
GDI_END);
DrawLine(from_x, y, to_x, y, element, change_level);
}
+static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
+{
+ unsigned long border_color = ReadPixel(pix[PIX_SMALLFONT], 2, 16);
+ int from_sx, from_sy;
+ int to_sx, to_sy;
+
+ if (from_x > to_x)
+ swap_numbers(&from_x, &to_x);
+
+ if (from_y > to_y)
+ swap_numbers(&from_y, &to_y);
+
+ from_sx = SX + from_x * MINI_TILEX;
+ from_sy = SY + from_y * MINI_TILEX;
+ to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
+ to_sy = SY + to_y * MINI_TILEX + MINI_TILEY - 1;
+
+ XSetForeground(display, gc, border_color);
+
+ XDrawLine(display, drawto, gc, from_sx, from_sy, to_sx, from_sy);
+ XDrawLine(display, drawto, gc, to_sx, from_sy, to_sx, to_sy);
+ XDrawLine(display, drawto, gc, to_sx, to_sy, from_sx, to_sy);
+ XDrawLine(display, drawto, gc, from_sx, to_sy, from_sx, from_sy);
+
+ XSetForeground(display, gc, BlackPixel(display,screen));
+
+ if (from_x == to_x && from_y == to_y)
+ MarkTileDirty(from_x/2, from_y/2);
+ else
+ redraw_mask |= REDRAW_FIELD;
+}
+
+static void SelectArea(int from_x, int from_y, int to_x, int to_y,
+ int element, boolean change_level)
+{
+ if (element == -1 || change_level)
+ DrawRectangle(from_x, from_y, to_x, to_y, -1, FALSE);
+ else
+ DrawAreaBorder(from_x, from_y, to_x, to_y);
+}
+
static void FloodFill(int from_x, int from_y, int fill_element)
{
int i,x,y;
safety--;
}
-static void DrawAreaBorder(int from_x, int from_y, int to_x, int to_y)
-{
- unsigned long border_color = ReadPixel(pix[PIX_SMALLFONT], 2, 16);
- int from_sx = SX + from_x * MINI_TILEX;
- int from_sy = SY + from_y * MINI_TILEX;
- int to_sx = SX + to_x * MINI_TILEX + MINI_TILEX - 1;
- int to_sy = SY + to_y * MINI_TILEX + MINI_TILEY - 1;
-
- XSetForeground(display, gc, border_color);
-
- XDrawLine(display, drawto, gc, from_sx, from_sy, to_sx, from_sy);
- XDrawLine(display, drawto, gc, to_sx, from_sy, to_sx, to_sy);
- XDrawLine(display, drawto, gc, to_sx, to_sy, from_sx, to_sy);
- XDrawLine(display, drawto, gc, from_sx, to_sy, from_sx, from_sy);
-
- XSetForeground(display, gc, BlackPixel(display,screen));
-
- if (from_x == to_x && from_y == to_y)
- MarkTileDirty(from_x/2, from_y/2);
- else
- redraw_mask |= REDRAW_FIELD;
-}
-
-/* values for DrawLeveltext() modes */
+/* values for DrawLevelText() modes */
#define TEXT_INIT 0
#define TEXT_SETCURSOR 1
#define TEXT_WRITECHAR 2
case ED_CTRL_ID_LINE:
case ED_CTRL_ID_RECTANGLE:
case ED_CTRL_ID_FILLED_BOX:
+ case ED_CTRL_ID_BRUSH:
{
static int last_sx = -1;
static int last_sy = -1;
draw_func = DrawLine;
else if (drawing_function == ED_CTRL_ID_RECTANGLE)
draw_func = DrawRectangle;
- else
+ else if (drawing_function == ED_CTRL_ID_FILLED_BOX)
draw_func = DrawFilledBox;
+ else
+ draw_func = SelectArea;
if (button_press_event)
{
}
break;
+ case ED_CTRL_ID_TEXT:
+ if (button_press_event)
+ DrawLevelText(sx, sy, 0, TEXT_INIT);
+ break;
+
case ED_CTRL_ID_FLOOD_FILL:
if (button_press_event && Feld[lx][ly] != new_element)
{
}
break;
- case ED_CTRL_ID_TEXT:
- if (button_press_event)
- DrawLevelText(sx, sy, 0, TEXT_INIT);
- break;
-
default:
break;
}