From: Holger Schemel Date: Tue, 12 Jan 1999 01:06:53 +0000 (+0100) Subject: rnd-19990112-1 X-Git-Tag: 1.3.0^2~26 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=446c65ff4739d51e02dd3556226b51f1b8fb8f79;p=rocksndiamonds.git rnd-19990112-1 --- diff --git a/src/editor.c b/src/editor.c index 44ad038d..faeca9b6 100644 --- a/src/editor.c +++ b/src/editor.c @@ -176,30 +176,34 @@ #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 @@ -794,7 +798,7 @@ static void CreateControlButtons() 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, @@ -3585,59 +3589,21 @@ void HandleLevelEditorKeyInput(KeySym key) } 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: @@ -3647,31 +3613,12 @@ void HandleLevelEditorKeyInput(KeySym key) 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; idescription_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); }