+
+ DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FS_SMALL, FC_YELLOW);
+}
+
+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;
+ int lx = sx + level_xpos;
+ int ly = sy + level_ypos;
+
+ ClearEditorGadgetInfoText();
+
+ if (id == ED_CTRL_ID_DRAWING_LEVEL)
+ {
+ if (button_status)
+ {
+ int min_sx = 0, min_sy = 0;
+ int max_sx = gi->drawing.area_xsize - 1;
+ int max_sy = gi->drawing.area_ysize - 1;
+ int min_lx = 0, min_ly = 0;
+ int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1;
+
+ /* make sure to stay inside drawing area boundaries */
+ sx = (sx < min_sx ? min_sx : sx > max_sx ? max_sx : sx);
+ sy = (sy < min_sy ? min_sy : sy > max_sy ? max_sy : sy);
+
+ /* get positions inside level field */
+ lx = sx + level_xpos;
+ ly = sy + level_ypos;
+
+ /* make sure to stay inside level field boundaries */
+ lx = (lx < min_lx ? min_lx : lx > max_lx ? max_lx : lx);
+ ly = (ly < min_ly ? min_ly : ly > max_ly ? max_ly : ly);
+
+ /* correct drawing area positions accordingly */
+ sx = lx - level_xpos;
+ sy = ly - level_ypos;
+ }
+
+ if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
+ {
+ if (button_status) /* 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 && !button_status)
+ {
+ if (IN_ED_FIELD(sx,sy) && IN_LEV_FIELD(lx, ly))
+ CopyBrushToCursor(sx, sy);
+ else
+ DeleteBrushFromCursor();
+ }
+ }
+ else if (id == ED_CTRL_ID_AMOEBA_CONTENT)
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ "Amoeba content");
+ else
+ DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW,
+ "Cruncher %d content: %d, %d", id - ED_CTRL_ID_ELEMCONT_0 + 1,
+ sx, sy);