{
int max_textsize = MAX_GADGET_TEXTSIZE;
- if (new_gadget->text_size)
- max_textsize = MIN(new_gadget->text_size, MAX_GADGET_TEXTSIZE - 1);
+ if (new_gadget->text.size)
+ max_textsize = MIN(new_gadget->text.size, MAX_GADGET_TEXTSIZE - 1);
- strncpy(new_gadget->text_value, va_arg(ap, char *), max_textsize);
- new_gadget->text_value[max_textsize] = '\0';
+ strncpy(new_gadget->text.value, va_arg(ap, char *), max_textsize);
+ new_gadget->text.value[max_textsize] = '\0';
+ new_gadget->text.cursor_position = strlen(new_gadget->text.value);
}
break;
int tag_value = va_arg(ap, int);
int max_textsize = MIN(tag_value, MAX_GADGET_TEXTSIZE - 1);
- new_gadget->text_size = max_textsize;
- new_gadget->text_value[max_textsize] = '\0';
+ new_gadget->text.size = max_textsize;
+ new_gadget->text.value[max_textsize] = '\0';
if (new_gadget->width == 0 && new_gadget->height == 0)
{
- new_gadget->width = (new_gadget->text_size + 1) * FONT2_XSIZE + 6;
+ new_gadget->width = (new_gadget->text.size + 1) * FONT2_XSIZE + 6;
new_gadget->height = ED_WIN_COUNT_YSIZE;
}
}
case GD_TYPE_TEXTINPUT:
{
int i;
+ char cursor_letter;
+ char cursor_string[3];
+ char text[MAX_GADGET_TEXTSIZE + 1];
+ int font_color = (pressed ? FC_YELLOW : FC_GREEN);
+ int border = gi->design_border;
+ strcpy(text, gi->text.value);
+ strcat(text, " ");
/* left part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x, gd->y,
- gi->design_border, gi->height,
- gi->x, gi->y);
+ gd->x, gd->y, border, gi->height, gi->x, gi->y);
/* middle part of gadget */
- for (i=0; i<=gi->text_size; i++)
+ for (i=0; i<=gi->text.size; i++)
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + gi->design_border, gd->y,
- FONT2_XSIZE, gi->height,
- gi->x + gi->design_border + i * FONT2_XSIZE, gi->y);
+ gd->x + border, gd->y, FONT2_XSIZE, gi->height,
+ gi->x + border + i * FONT2_XSIZE, gi->y);
/* right part of gadget */
XCopyArea(display, gd->pixmap, drawto, gc,
- gd->x + ED_WIN_COUNT_XSIZE - gi->design_border, gd->y,
- gi->design_border, gi->height,
- gi->x + gi->width - gi->design_border, gi->y);
+ gd->x + ED_WIN_COUNT_XSIZE - border, gd->y,
+ border, gi->height, gi->x + gi->width - border, gi->y);
/* gadget text value */
- DrawText(gi->x + gi->design_border, gi->y + gi->design_border,
- gi->text_value, FS_SMALL, (pressed ? FC_GREEN : FC_YELLOW));
+ DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_color);
+
+ cursor_letter = gi->text.value[gi->text.cursor_position];
+ cursor_string[0] = '~';
+ cursor_string[1] = (cursor_letter != '\0' ? cursor_letter : ' ');
+ cursor_string[2] = '\0';
/* draw cursor, if active */
- DrawText(gi->x + gi->design_border +
- strlen(gi->text_value) * FONT2_XSIZE,
- gi->y + gi->design_border,
- (pressed ? "<" : " "),
- FS_SMALL, FC_RED);
+ if (pressed)
+ DrawText(gi->x + border + gi->text.cursor_position * FONT2_XSIZE,
+ gi->y + border, cursor_string, FS_SMALL, font_color);
}
break;
DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
}
+static struct GadgetInfo *last_gi = NULL;
+
void MapGadget(struct GadgetInfo *gi)
{
if (gi == NULL)
return;
gi->mapped = FALSE;
-}
-static struct GadgetInfo *last_gi = NULL;
+ if (gi == last_gi)
+ last_gi = NULL;
+}
void HandleGadgets(int mx, int my, int button)
{
last_mx = mx;
last_my = my;
- /* if mouse button pressed outside text input gadget, deactivate it */
- if (last_gi && last_gi->type == GD_TYPE_TEXTINPUT &&
- button != 0 && new_gi != last_gi && !motion_status)
+ /* special treatment for text input gadgets */
+ if (last_gi && last_gi->type == GD_TYPE_TEXTINPUT && last_gi->mapped &&
+ button != 0 && !motion_status)
{
struct GadgetInfo *gi = last_gi;
- DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
+ if (new_gi == last_gi)
+ {
+ /* if mouse button pressed inside activated text gadget, set cursor */
+ gi->text.cursor_position = (mx - gi->x) / FONT2_XSIZE;
- if (gi->event_mask & GD_EVENT_TEXT_LEAVING)
- gi->callback_action(gi);
+ if (gi->text.cursor_position < 0)
+ gi->text.cursor_position = 0;
+ else if (gi->text.cursor_position > strlen(gi->text.value))
+ gi->text.cursor_position = strlen(gi->text.value);
- last_gi = NULL;
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
+ }
+ else
+ {
+ /* if mouse button pressed outside text input gadget, deactivate it */
+ DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
+
+ if (gi->event_mask & GD_EVENT_TEXT_LEAVING)
+ gi->callback_action(gi);
+
+ last_gi = NULL;
+ }
}
gadget_pressed =
last_info_gi = new_gi;
if (new_gi != NULL)
+ {
+ new_gi->event.type = 0;
new_gi->callback_info(new_gi);
+ }
else
default_callback_info(NULL);
}
void HandleGadgetsKeyInput(KeySym key)
{
struct GadgetInfo *gi = last_gi;
+ char text[MAX_GADGET_TEXTSIZE];
int text_length;
+ int cursor_pos;
char letter;
- if (gi == NULL || gi->type != GD_TYPE_TEXTINPUT)
+ if (gi == NULL || gi->type != GD_TYPE_TEXTINPUT || !gi->mapped)
return;
- text_length = strlen(gi->text_value);
+ text_length = strlen(gi->text.value);
+ cursor_pos = gi->text.cursor_position;
letter = getCharFromKeySym(key);
- if (letter && text_length < gi->text_size)
+ if (letter && text_length < gi->text.size)
+ {
+ strcpy(text, gi->text.value);
+ strcpy(&gi->text.value[cursor_pos + 1], &text[cursor_pos]);
+ gi->text.value[cursor_pos] = letter;
+ gi->text.cursor_position++;
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
+ }
+ else if (key == XK_Left && cursor_pos > 0)
+ {
+ gi->text.cursor_position--;
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
+ }
+ else if (key == XK_Right && cursor_pos < text_length)
+ {
+ gi->text.cursor_position++;
+ DrawGadget(gi, DG_PRESSED, DG_DIRECT);
+ }
+ else if (key == XK_BackSpace && cursor_pos > 0)
{
- gi->text_value[text_length] = letter;
- gi->text_value[text_length + 1] = '\0';
+ strcpy(text, gi->text.value);
+ strcpy(&gi->text.value[cursor_pos - 1], &text[cursor_pos]);
+ gi->text.cursor_position--;
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
- else if ((key == XK_Delete || key == XK_BackSpace) && text_length > 0)
+ else if (key == XK_Delete && cursor_pos < text_length)
{
- gi->text_value[text_length - 1] = '\0';
+ strcpy(text, gi->text.value);
+ strcpy(&gi->text.value[cursor_pos], &text[cursor_pos + 1]);
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
else if (key == XK_Return)
/* gadget types */
-#define GD_TYPE_NORMAL_BUTTON (1<<0)
-#define GD_TYPE_RADIO_BUTTON (1<<1)
-#define GD_TYPE_DRAWING_AREA (1<<2)
-#define GD_TYPE_TEXTINPUT (1<<3)
-#define GD_TYPE_TEXTOUTPUT (1<<4)
-#define GD_TYPE_NUMBERINPUT (1<<5)
-#define GD_TYPE_NUMBEROUTPUT (1<<6)
-#define GD_TYPE_SCROLLBAR_VERTICAL (1<<7)
-#define GD_TYPE_SCROLLBAR_HORIZONTAL (1<<8)
+#define GD_TYPE_NORMAL_BUTTON (1 << 0)
+#define GD_TYPE_RADIO_BUTTON (1 << 1)
+#define GD_TYPE_DRAWING_AREA (1 << 2)
+#define GD_TYPE_TEXTINPUT (1 << 3)
+#define GD_TYPE_TEXTOUTPUT (1 << 4)
+#define GD_TYPE_NUMBERINPUT (1 << 5)
+#define GD_TYPE_NUMBEROUTPUT (1 << 6)
+#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 7)
+#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 8)
#define GD_TYPE_BUTTON (GD_TYPE_NORMAL_BUTTON | \
GD_TYPE_RADIO_BUTTON)
GD_TYPE_SCROLLBAR_HORIZONTAL)
/* gadget events */
-#define GD_EVENT_PRESSED (1<<0)
-#define GD_EVENT_RELEASED (1<<1)
-#define GD_EVENT_MOVING (1<<2)
-#define GD_EVENT_REPEATED (1<<3)
-#define GD_EVENT_OFF_BORDERS (1<<4)
-#define GD_EVENT_TEXT_RETURN (1<<5)
-#define GD_EVENT_TEXT_LEAVING (1<<6)
+#define GD_EVENT_PRESSED (1 << 0)
+#define GD_EVENT_RELEASED (1 << 1)
+#define GD_EVENT_MOVING (1 << 2)
+#define GD_EVENT_REPEATED (1 << 3)
+#define GD_EVENT_OFF_BORDERS (1 << 4)
+#define GD_EVENT_TEXT_RETURN (1 << 5)
+#define GD_EVENT_TEXT_LEAVING (1 << 6)
/* gadget button states */
#define GD_BUTTON_UNPRESSED 0
int item_xsize, item_ysize; /* size of each item in drawing area */
};
+struct GadgetTextInput
+{
+ char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
+ int size; /* maximal size of input text */
+ int cursor_position; /* actual cursor position */
+};
+
struct GadgetScrollbar
{
int items_max; /* number of items to access */
boolean radio_pressed; /* radio button state */
boolean mapped; /* gadget is active */
long number_value;
- char text_value[MAX_GADGET_TEXTSIZE];
- int text_size; /* maximal size of input text */
struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
struct GadgetDesign alt_design[2]; /* alternative design */
int design_border; /* border size of gadget decoration */
gadget_function callback_info; /* function for pop-up info text */
gadget_function callback_action; /* function for gadget action */
struct GadgetDrawingArea drawing; /* fields for drawing area gadget */
+ struct GadgetTextInput text; /* fields for text input gadget */
struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */
struct GadgetInfo *next; /* next list entry */
};
#define ED_SCROLL_HORIZONTAL_YSIZE ED_SCROLLBUTTON_YSIZE
/* control button identifiers */
+#define ED_CTRL_ID_NONE -1
+
#define ED_CTRL_ID_SINGLE_ITEMS 0
#define ED_CTRL_ID_CONNECTED_ITEMS 1
#define ED_CTRL_ID_LINE 2
#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_GRAB_BRUSH 13
#define ED_CTRL_ID_WRAP_DOWN 14
#define ED_CTRL_ID_PICK_ELEMENT 15
#define ED_CTRL_ID_UNDO 16
},
};
-
/* forward declaration for internal use */
static void DrawDrawingWindow();
static void DrawPropertiesWindow();
id == ED_CTRL_ID_RECTANGLE ||
id == ED_CTRL_ID_FILLED_BOX ||
id == ED_CTRL_ID_FLOOD_FILL ||
- id == ED_CTRL_ID_BRUSH ||
+ id == ED_CTRL_ID_GRAB_BRUSH ||
id == ED_CTRL_ID_PICK_ELEMENT)
{
button_type = GD_TYPE_RADIO_BUTTON;
if (!level_editor_gadgets_created)
CreateLevelEditorGadgets();
+ else
+ strcpy(level_editor_gadget[ED_CTRL_ID_LEVEL_NAME]->text.value, level.name);
MapControlButtons();
#define CB_BRUSH_TO_LEVEL 2
#define CB_DELETE_OLD_CURSOR 3
-static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y, int mode)
+static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
+ int button, int mode)
{
static short brush_buffer[ED_FIELDX][ED_FIELDY];
static int brush_width, brush_height;
static int last_cursor_x = -1, last_cursor_y = -1;
static boolean delete_old_brush;
+ int new_element;
int x, y;
if (mode == CB_DELETE_OLD_CURSOR && !delete_old_brush)
return;
+ new_element = (button == 1 ? new_element1 :
+ button == 2 ? new_element2 :
+ button == 3 ? new_element3 : 0);
+
if (mode == CB_AREA_TO_BRUSH)
{
int from_lx, from_ly;
from_ly = from_y + level_ypos;
for (y=0; y<brush_height; y++)
+ {
for (x=0; x<brush_width; x++)
+ {
brush_buffer[x][y] = Feld[from_lx + x][from_ly + y];
+ if (button != 1)
+ DrawLineElement(from_x + x, from_y + y, new_element, TRUE);
+ }
+ }
+
+ if (button != 1)
+ CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
+
delete_old_brush = FALSE;
}
else if (mode == CB_BRUSH_TO_CURSOR || mode == CB_DELETE_OLD_CURSOR ||
int border_to_x = cursor_x, border_to_y = cursor_y;
if (mode != CB_DELETE_OLD_CURSOR && delete_old_brush)
- CopyBrushExt(0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
+ CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
if (!IN_LEV_FIELD(cursor_x + level_xpos, cursor_y + level_ypos))
{
int sy = cursor_from_y + y;
int lx = sx + level_xpos;
int ly = sy + level_ypos;
- int element = (mode == CB_DELETE_OLD_CURSOR ? -1 : brush_buffer[x][y]);
boolean change_level = (mode == CB_BRUSH_TO_LEVEL);
+ int element = (mode == CB_DELETE_OLD_CURSOR ? -1 :
+ mode == CB_BRUSH_TO_CURSOR || button == 1 ?
+ brush_buffer[x][y] : new_element);
if (IN_LEV_FIELD(lx, ly) &&
sx >=0 && sx < ED_FIELDX && sy >=0 && sy < ED_FIELDY)
if (mode != CB_DELETE_OLD_CURSOR)
DrawAreaBorder(border_from_x, border_from_y, border_to_x, border_to_y);
+ /*
if (mode == CB_BRUSH_TO_LEVEL)
CopyLevelToUndoBuffer(UNDO_IMMEDIATE);
+ */
last_cursor_x = cursor_x;
last_cursor_y = cursor_y;
}
}
-static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y)
+static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y,
+ int button)
{
- CopyBrushExt(from_x, from_y, to_x, to_y, CB_AREA_TO_BRUSH);
+ CopyBrushExt(from_x, from_y, to_x, to_y, button, CB_AREA_TO_BRUSH);
}
-static void CopyBrushToLevel(int x, int y)
+static void CopyBrushToLevel(int x, int y, int button)
{
- CopyBrushExt(x, y, 0, 0, CB_BRUSH_TO_LEVEL);
+ CopyBrushExt(x, y, 0, 0, button, CB_BRUSH_TO_LEVEL);
}
static void CopyBrushToCursor(int x, int y)
{
- CopyBrushExt(x, y, 0, 0, CB_BRUSH_TO_CURSOR);
+ CopyBrushExt(x, y, 0, 0, 0, CB_BRUSH_TO_CURSOR);
}
static void DeleteBrushFromCursor()
{
- CopyBrushExt(0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
+ CopyBrushExt(0, 0, 0, 0, 0, CB_DELETE_OLD_CURSOR);
}
static void FloodFill(int from_x, int from_y, int fill_element)
int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
int x, y;
+ /* handle info callback for each invocation of action callback */
+ gi->callback_info(gi);
+
/*
if (edit_mode != ED_MODE_DRAWING)
return;
if (!button)
break;
- if (new_element != Feld[lx][ly])
+ if (draw_with_brush)
+ CopyBrushToLevel(sx, sy, button);
+ else if (new_element != Feld[lx][ly])
{
if (new_element == EL_SPIELFIGUR)
{
case ED_CTRL_ID_LINE:
case ED_CTRL_ID_RECTANGLE:
case ED_CTRL_ID_FILLED_BOX:
- case ED_CTRL_ID_BRUSH:
+ case ED_CTRL_ID_GRAB_BRUSH:
case ED_CTRL_ID_TEXT:
{
static int last_sx = -1;
draw_func = DrawRectangle;
else if (drawing_function == ED_CTRL_ID_FILLED_BOX)
draw_func = DrawFilledBox;
- else if (drawing_function == ED_CTRL_ID_BRUSH)
+ else if (drawing_function == ED_CTRL_ID_GRAB_BRUSH)
draw_func = SelectArea;
else /* (drawing_function == ED_CTRL_ID_TEXT) */
draw_func = SetTextCursor;
else if (button_release_event)
{
draw_func(start_sx, start_sy, sx, sy, new_element, TRUE);
- if (drawing_function == ED_CTRL_ID_BRUSH)
+ if (drawing_function == ED_CTRL_ID_GRAB_BRUSH)
{
- CopyAreaToBrush(start_sx, start_sy, sx, sy);
+ CopyAreaToBrush(start_sx, start_sy, sx, sy, button);
+ CopyBrushToCursor(sx, sy);
+ ClickOnGadget(level_editor_gadget[ED_CTRL_ID_SINGLE_ITEMS]);
draw_with_brush = TRUE;
}
else if (drawing_function == ED_CTRL_ID_TEXT)
case ED_CTRL_ID_RECTANGLE:
case ED_CTRL_ID_FILLED_BOX:
case ED_CTRL_ID_FLOOD_FILL:
- case ED_CTRL_ID_BRUSH:
+ case ED_CTRL_ID_GRAB_BRUSH:
case ED_CTRL_ID_PICK_ELEMENT:
last_drawing_function = drawing_function;
drawing_function = id;
+ draw_with_brush = FALSE;
break;
case ED_CTRL_ID_RANDOM_PLACEMENT:
void HandleLevelEditorKeyInput(KeySym key)
{
- if (edit_mode == ED_MODE_DRAWING && drawing_function == ED_CTRL_ID_TEXT)
+ if (edit_mode == ED_MODE_DRAWING)
{
char letter = getCharFromKeySym(key);
- if (letter)
- DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
- else if (key == XK_Delete || key == XK_BackSpace)
- DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
- else if (key == XK_Return)
- DrawLevelText(0, 0, 0, TEXT_NEWLINE);
+ if (drawing_function == ED_CTRL_ID_TEXT)
+ {
+ if (letter)
+ DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
+ else if (key == XK_Delete || key == XK_BackSpace)
+ DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
+ else if (key == XK_Return)
+ DrawLevelText(0, 0, 0, TEXT_NEWLINE);
+ }
+ else if (button_status == MB_RELEASED)
+ {
+ int id;
+
+ switch (letter)
+ {
+ case '.':
+ case 's':
+ id = ED_CTRL_ID_SINGLE_ITEMS;
+ break;
+ case 'd':
+ id = ED_CTRL_ID_CONNECTED_ITEMS;
+ break;
+ case 'l':
+ id = ED_CTRL_ID_LINE;
+ break;
+ case 't':
+ id = ED_CTRL_ID_TEXT;
+ break;
+ case 'r':
+ id = ED_CTRL_ID_RECTANGLE;
+ break;
+ case 'R':
+ id = ED_CTRL_ID_FILLED_BOX;
+ break;
+ case '?':
+ id = ED_CTRL_ID_PROPERTIES;
+ break;
+ case 'f':
+ id = ED_CTRL_ID_FLOOD_FILL;
+ break;
+ case 'b':
+ id = ED_CTRL_ID_GRAB_BRUSH;
+ break;
+ case ',':
+ id = ED_CTRL_ID_PICK_ELEMENT;
+ break;
+
+ case 'U':
+ id = ED_CTRL_ID_UNDO;
+ break;
+ case 'I':
+ id = ED_CTRL_ID_INFO;
+ break;
+ case 'S':
+ id = ED_CTRL_ID_SAVE;
+ break;
+ case 'C':
+ id = ED_CTRL_ID_CLEAR;
+ break;
+ case 'T':
+ id = ED_CTRL_ID_TEST;
+ break;
+ case 'E':
+ id = ED_CTRL_ID_EXIT;
+ break;
+
+ default:
+ id = ED_CTRL_ID_NONE;
+ break;
+ }
+
+ if (id != ED_CTRL_ID_NONE)
+ ClickOnGadget(level_editor_gadget[id]);
+ else
+ {
+ switch (key)
+ {
+ case XK_Left:
+ id = ED_CTRL_ID_SCROLL_LEFT;
+ break;
+ case XK_Right:
+ id = ED_CTRL_ID_SCROLL_RIGHT;
+ break;
+ case XK_Up:
+ id = ED_CTRL_ID_SCROLL_UP;
+ break;
+ case XK_Down:
+ id = ED_CTRL_ID_SCROLL_DOWN;
+ break;
+
+ default:
+ id = ED_CTRL_ID_NONE;
+ break;
+ }
+
+ if (id != ED_CTRL_ID_NONE)
+ ClickOnGadget(level_editor_gadget[id]);
+ }
+ }
}
}
switch (id)
{
case ED_CTRL_ID_LEVEL_NAME:
- strcpy(level.name, gi->text_value);
+ strcpy(level.name, gi->text.value);
break;
default:
static void HandleDrawingAreaInfo(struct GadgetInfo *gi)
{
+ static int start_lx, start_ly;
+ char *infotext;
int id = gi->custom_id;
int sx = gi->event.x;
int sy = gi->event.y;
if (id == ED_CTRL_ID_DRAWING_LEVEL)
{
if (IN_LEV_FIELD(lx, ly))
- DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
- "Level: %d, %d (Screen: %d, %d)", lx, ly, sx, sy);
+ {
+ if (gi->state == GD_BUTTON_PRESSED)
+ {
+ if (gi->event.type == GD_EVENT_PRESSED)
+ {
+ start_lx = lx;
+ start_ly = ly;
+ }
+
+ switch (drawing_function)
+ {
+ case ED_CTRL_ID_SINGLE_ITEMS:
+ infotext = "Drawing single items";
+ break;
+ case ED_CTRL_ID_CONNECTED_ITEMS:
+ infotext = "Drawing connected items";
+ break;
+ case ED_CTRL_ID_LINE:
+ infotext = "Drawing line";
+ break;
+ case ED_CTRL_ID_TEXT:
+ infotext = "Setting text cursor";
+ break;
+ case ED_CTRL_ID_RECTANGLE:
+ infotext = "Drawing rectangle";
+ break;
+ case ED_CTRL_ID_FILLED_BOX:
+ infotext = "Drawing filled box";
+ break;
+ case ED_CTRL_ID_FLOOD_FILL:
+ infotext = "Flood fill";
+ break;
+ case ED_CTRL_ID_GRAB_BRUSH:
+ infotext = "Grabbing brush";
+ break;
+ case ED_CTRL_ID_PICK_ELEMENT:
+ infotext = "Picking element";
+ break;
+
+ default:
+ infotext = "Drawing position";
+ break;
+ }
+
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ "%s: %d, %d", infotext,
+ ABS(lx - start_lx) + 1,
+ ABS(ly - start_ly) + 1);
+ }
+ else
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ "Level position: %d, %d", lx, ly);
+ }
/* misuse this function to draw brush cursor, if needed */
if (edit_mode == ED_MODE_DRAWING && draw_with_brush)
{ XK_slash, "XK_slash", "/" },
{ XK_colon, "XK_colon", ":" },
{ XK_semicolon, "XK_semicolon", ";" },
- { XK_less, "XK_less", "less" },
- { XK_equal, "XK_equal", "equal" },
- { XK_greater, "XK_greater", "greater" },
+ { XK_less, "XK_less", "<" },
+ { XK_equal, "XK_equal", "=" },
+ { XK_greater, "XK_greater", ">" },
{ XK_question, "XK_question", "?" },
{ XK_at, "XK_at", "@" },
letter = keyname[0];
else if (strcmp(keyname, "space") == 0)
letter = ' ';
- else if (strcmp(keyname, "less") == 0)
- letter = '<';
- else if (strcmp(keyname, "equal") == 0)
- letter = '=';
- else if (strcmp(keyname, "greater") == 0)
- letter = '>';
else if (strcmp(keyname, "circumflex") == 0)
letter = '^';
{
int font_width, font_height, font_start;
int font_pixmap;
+ boolean print_inverse = FALSE;
if (font_size != FS_SMALL && font_size != FS_BIG)
font_size = FS_SMALL;
font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : FONT2_YSIZE) *
FONT_LINES_PER_FONT);
- while(*text)
+ while (*text)
{
char c = *text++;
+ if (c == '~' && font_size == FS_SMALL && font_type <= FC_YELLOW)
+ {
+ print_inverse = TRUE;
+ continue;
+ }
+
if (c >= 'a' && c <= 'z')
c = 'A' + (c - 'a');
else if (c == 'ä' || c == 'Ä')
c = 93;
if (c >= 32 && c <= 95)
- XCopyArea(display, pix[font_pixmap], d, gc,
- ((c - 32) % FONT_CHARS_PER_LINE) * font_width,
- ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start,
- font_width, font_height, x, y);
+ {
+ int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width;
+ int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start;
+ int dest_x = x, dest_y = y;
+
+ if (print_inverse)
+ {
+ XCopyArea(display, pix[font_pixmap], d, gc,
+ FONT_CHARS_PER_LINE * font_width,
+ 3 * font_height + font_start,
+ font_width, font_height, x, y);
+
+ XSetClipOrigin(display, clip_gc[font_pixmap],
+ dest_x - src_x, dest_y - src_y);
+ XCopyArea(display, pix[font_pixmap], drawto, clip_gc[font_pixmap],
+ 0, 0, font_width, font_height, dest_x, dest_y);
+ }
+ else
+ XCopyArea(display, pix[font_pixmap], d, gc,
+ src_x, src_y, font_width, font_height, dest_x, dest_y);
+ }
x += font_width;
}