#define UNDO_IMMEDIATE 0
#define UNDO_ACCUMULATE 1
-static char *control_infotext[ED_NUM_CTRL_BUTTONS] =
-{
- "draw single items",
- "draw connected items",
- "draw lines",
- "enter text elements",
- "draw outline rectangles",
- "draw filled boxes",
- "wrap (rotate) level up",
- "properties of drawing element",
- "flood fill",
- "wrap (rotate) level left",
- "",
- "wrap (rotate) level right",
- "random element placement",
- "grab brush",
- "wrap (rotate) level down",
- "pick drawing element from editing area",
- "undo last operation",
- "level properties",
- "save level",
- "clear level",
- "test level",
- "exit level editor",
+static struct
+{
+ char shortcut;
+ char *text;
+} control_info[ED_NUM_CTRL_BUTTONS] =
+{
+ { 's', "draw single items" },
+ { 'd', "draw connected items" },
+ { 'l', "draw lines" },
+ { 't', "enter text elements" },
+ { 'r', "draw outline rectangles" },
+ { 'R', "draw filled rectangles" },
+ { '\0', "wrap (rotate) level up" },
+ { '?', "properties of drawing element" },
+ { 'f', "flood fill" },
+ { '\0', "wrap (rotate) level left" },
+ { '\0', "" },
+ { '\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', "level properties" },
+ { 'S', "save level" },
+ { 'C', "clear level" },
+ { 'T', "test level" },
+ { 'E', "exit level editor" }
};
static struct
gd_y2 = DOOR_GFX_PAGEY1 + ED_CTRL_BUTTONS_ALT_GFX_YPOS + gd_yoffset;
gi = CreateGadget(GDI_CUSTOM_ID, id,
- GDI_DESCRIPTION_TEXT, control_infotext[i],
+ GDI_DESCRIPTION_TEXT, control_info[i].text,
GDI_X, EX + gd_xoffset,
GDI_Y, EY + gd_yoffset,
GDI_WIDTH, width,
}
else if (button_status == MB_RELEASED)
{
- int id;
+ int i, id;
- switch (letter)
+ switch (key)
{
- 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;
+ case XK_Left:
+ id = ED_CTRL_ID_SCROLL_LEFT;
break;
- case '?':
- id = ED_CTRL_ID_PROPERTIES;
+ case XK_Right:
+ id = ED_CTRL_ID_SCROLL_RIGHT;
break;
- case 'f':
- id = ED_CTRL_ID_FLOOD_FILL;
+ case XK_Up:
+ id = ED_CTRL_ID_SCROLL_UP;
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;
+ case XK_Down:
+ id = ED_CTRL_ID_SCROLL_DOWN;
break;
default:
if (id != ED_CTRL_ID_NONE)
ClickOnGadget(level_editor_gadget[id]);
+ else if (letter == '.')
+ ClickOnGadget(level_editor_gadget[ED_CTRL_ID_SINGLE_ITEMS]);
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]);
- }
+ for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
+ if (letter && letter == control_info[i].shortcut)
+ ClickOnGadget(level_editor_gadget[i]);
}
}
}
{
struct GadgetInfo *gi = (struct GadgetInfo *)ptr;
char infotext[MAX_INFOTEXT_LEN + 1];
+ char shortcut[20];
ClearEditorGadgetInfoText();
strncpy(infotext, gi->description_text, MAX_INFOTEXT_LEN);
infotext[MAX_INFOTEXT_LEN] = '\0';
+ if (gi->custom_id < ED_NUM_CTRL_BUTTONS)
+ {
+ int key = control_info[gi->custom_id].shortcut;
+
+ if (key)
+ {
+ sprintf(shortcut, " ('%s%c')",
+ (key >= 'A' && key <= 'Z' ? "Shift-" : ""), key);
+
+ if (strlen(infotext) + strlen(shortcut) <= MAX_INFOTEXT_LEN)
+ strcat(infotext, shortcut);
+ }
+ }
+
DrawText(INFOTEXT_XPOS, INFOTEXT_YPOS, infotext, FS_SMALL, FC_YELLOW);
}