X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=a74d702c58d2c19539b79bcdac92ecd1380f415f;hb=c1d1d669f782d9af7dfa71159962d5a89c62f03b;hp=82e049596d20baa54ed2d5c4eb2e36bcef659d3a;hpb=6b83db8bee17d70c4e89dc3e3b703b7032aa5f27;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index 82e04959..a74d702c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -247,12 +247,13 @@ #define GADGET_ID_RANDOM_QUANTITY 107 #define GADGET_ID_RANDOM_RESTRICTED 108 #define GADGET_ID_DOUBLE_SPEED 109 -#define GADGET_ID_STICK_ELEMENT 110 +#define GADGET_ID_GRAVITY 110 +#define GADGET_ID_STICK_ELEMENT 111 /* another drawing area for random placement */ -#define GADGET_ID_RANDOM_BACKGROUND 111 +#define GADGET_ID_RANDOM_BACKGROUND 112 -#define NUM_EDITOR_GADGETS 112 +#define NUM_EDITOR_GADGETS 113 /* radio button numbers */ #define RADIO_NR_NONE 0 @@ -301,10 +302,11 @@ /* values for checkbutton gadgets */ #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0 -#define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 1 -#define ED_CHECKBUTTON_ID_STICK_ELEMENT 2 +#define ED_CHECKBUTTON_ID_GRAVITY 1 +#define ED_CHECKBUTTON_ID_RANDOM_RESTRICTED 2 +#define ED_CHECKBUTTON_ID_STICK_ELEMENT 3 -#define ED_NUM_CHECKBUTTONS 3 +#define ED_NUM_CHECKBUTTONS 4 #define ED_CHECKBUTTON_ID_LEVEL_FIRST ED_CHECKBUTTON_ID_DOUBLE_SPEED #define ED_CHECKBUTTON_ID_LEVEL_LAST ED_CHECKBUTTON_ID_RANDOM_RESTRICTED @@ -594,6 +596,12 @@ static struct &level.double_speed, "double speed movement", "set movement speed of player" }, + { + ED_SETTINGS_XPOS + 340, ED_COUNTER_YPOS(6) - MINI_TILEY, + GADGET_ID_GRAVITY, + &level.gravity, + "gravity", "set level gravity" + }, { ED_SETTINGS_XPOS, ED_COUNTER2_YPOS(9) - MINI_TILEY, GADGET_ID_RANDOM_RESTRICTED, @@ -661,20 +669,20 @@ int element_shift = 0; int editor_element[] = { - EL_CHAR_A + ('B' - 'A'), - EL_CHAR_A + ('O' - 'A'), - EL_CHAR_A + ('U' - 'A'), - EL_CHAR_A + ('L' - 'A'), + EL_CHAR('B'), + EL_CHAR('O'), + EL_CHAR('U'), + EL_CHAR('L'), EL_CHAR_MINUS, - EL_CHAR_A + ('D' - 'A'), - EL_CHAR_A + ('E' - 'A'), - EL_CHAR_A + ('R' - 'A'), + EL_CHAR('D'), + EL_CHAR('E'), + EL_CHAR('R'), - EL_CHAR_A + ('D' - 'A'), - EL_CHAR_A + ('A' - 'A'), - EL_CHAR_A + ('S' - 'A'), - EL_CHAR_A + ('H' - 'A'), + EL_CHAR('D'), + EL_CHAR('A'), + EL_CHAR('S'), + EL_CHAR('H'), EL_SPIELFIGUR, EL_LEERRAUM, @@ -701,20 +709,20 @@ int editor_element[] = EL_FIREFLY_U, EL_LEERRAUM, - EL_CHAR_A + ('E' - 'A'), - EL_CHAR_A + ('M' - 'A'), - EL_CHAR_A + ('E' - 'A'), + EL_CHAR('E'), + EL_CHAR('M'), + EL_CHAR('E'), EL_CHAR_MINUS, - EL_CHAR_A + ('R' - 'A'), - EL_CHAR_A + ('A' - 'A'), - EL_CHAR_A + ('L' - 'A'), - EL_CHAR_A + ('D' - 'A'), + EL_CHAR('R'), + EL_CHAR('A'), + EL_CHAR('L'), + EL_CHAR('D'), - EL_CHAR_A + ('M' - 'A'), - EL_CHAR_A + ('I' - 'A'), - EL_CHAR_A + ('N' - 'A'), - EL_CHAR_A + ('E' - 'A'), + EL_CHAR('M'), + EL_CHAR('I'), + EL_CHAR('N'), + EL_CHAR('E'), EL_SPIELER1, EL_SPIELER2, @@ -776,6 +784,26 @@ int editor_element[] = EL_AMOEBE_NASS, EL_AMOEBE_NORM, + EL_EM_KEY_1_FILE, + EL_EM_KEY_2_FILE, + EL_EM_KEY_3_FILE, + EL_EM_KEY_4_FILE, + + EL_EM_GATE_1, + EL_EM_GATE_2, + EL_EM_GATE_3, + EL_EM_GATE_4, + + EL_EM_GATE_1X, + EL_EM_GATE_2X, + EL_EM_GATE_3X, + EL_EM_GATE_4X, + + EL_CHAR('M'), + EL_CHAR('O'), + EL_CHAR('R'), + EL_CHAR('E'), + EL_SCHLUESSEL1, EL_SCHLUESSEL2, EL_SCHLUESSEL3, @@ -791,11 +819,6 @@ int editor_element[] = EL_PFORTE3X, EL_PFORTE4X, - EL_CHAR_A + ('M' - 'A'), - EL_CHAR_A + ('O' - 'A'), - EL_CHAR_A + ('R' - 'A'), - EL_CHAR_A + ('E' - 'A'), - EL_PFEIL_L, EL_PFEIL_R, EL_PFEIL_O, @@ -844,17 +867,17 @@ int editor_element[] = EL_INVISIBLE_STEEL, EL_UNSICHTBAR, EL_SPEED_PILL, - EL_LEERRAUM, + EL_BLACK_ORB, - EL_CHAR_A + ('S' - 'A'), - EL_CHAR_A + ('O' - 'A'), - EL_CHAR_A + ('K' - 'A'), - EL_CHAR_A + ('O' - 'A'), + EL_CHAR('S'), + EL_CHAR('O'), + EL_CHAR('K'), + EL_CHAR('O'), EL_CHAR_MINUS, - EL_CHAR_A + ('B' - 'A'), - EL_CHAR_A + ('A' - 'A'), - EL_CHAR_A + ('N' - 'A'), + EL_CHAR('B'), + EL_CHAR('A'), + EL_CHAR('N'), EL_SOKOBAN_OBJEKT, EL_SOKOBAN_FELD_LEER, @@ -927,20 +950,20 @@ int editor_element[] = EL_SP_CHIP_LOWER, /* - EL_CHAR_A + ('D' - 'A'), - EL_CHAR_A + ('Y' - 'A'), - EL_CHAR_A + ('N' - 'A'), - EL_CHAR_A + ('A' - 'A'), + EL_CHAR('D'), + EL_CHAR('Y'), + EL_CHAR('N'), + EL_CHAR('A'), - EL_CHAR_A + ('B' - 'A'), - EL_CHAR_A + ('L' - 'A'), - EL_CHAR_A + ('A' - 'A'), - EL_CHAR_A + ('S' - 'A'), + EL_CHAR('B'), + EL_CHAR('L'), + EL_CHAR('A'), + EL_CHAR('S'), EL_CHAR_MINUS, - EL_CHAR_A + ('T' - 'A'), - EL_CHAR_A + ('E' - 'A'), - EL_CHAR_A + ('R' - 'A'), + EL_CHAR('T'), + EL_CHAR('E'), + EL_CHAR('R'), */ EL_LEERRAUM, @@ -948,80 +971,85 @@ int editor_element[] = EL_LEERRAUM, EL_LEERRAUM, - EL_CHAR_AUSRUF, - EL_CHAR_ZOLL, - EL_CHAR_DOLLAR, - EL_CHAR_PROZ, + EL_CHAR(' '), + EL_CHAR('!'), + EL_CHAR('"'), + EL_CHAR('#'), + + EL_CHAR('$'), + EL_CHAR('%'), + EL_CHAR('&'), + EL_CHAR('\''), + + EL_CHAR('('), + EL_CHAR(')'), + EL_CHAR('*'), + EL_CHAR('+'), + + EL_CHAR(','), + EL_CHAR('-'), + EL_CHAR('.'), + EL_CHAR('/'), + + EL_CHAR('0'), + EL_CHAR('1'), + EL_CHAR('2'), + EL_CHAR('3'), + + EL_CHAR('4'), + EL_CHAR('5'), + EL_CHAR('6'), + EL_CHAR('7'), + + EL_CHAR('8'), + EL_CHAR('9'), + EL_CHAR(':'), + EL_CHAR(';'), + + EL_CHAR('<'), + EL_CHAR('='), + EL_CHAR('>'), + EL_CHAR('?'), + + EL_CHAR('@'), + EL_CHAR('A'), + EL_CHAR('B'), + EL_CHAR('C'), - EL_CHAR_APOSTR, - EL_CHAR_KLAMM1, - EL_CHAR_KLAMM2, - EL_CHAR_PLUS, + EL_CHAR('D'), + EL_CHAR('E'), + EL_CHAR('F'), + EL_CHAR('G'), - EL_CHAR_KOMMA, - EL_CHAR_MINUS, - EL_CHAR_PUNKT, - EL_CHAR_SLASH, - - EL_CHAR_0 + 0, - EL_CHAR_0 + 1, - EL_CHAR_0 + 2, - EL_CHAR_0 + 3, - - EL_CHAR_0 + 4, - EL_CHAR_0 + 5, - EL_CHAR_0 + 6, - EL_CHAR_0 + 7, - - EL_CHAR_0 + 8, - EL_CHAR_0 + 9, - EL_CHAR_DOPPEL, - EL_CHAR_SEMIKL, - - EL_CHAR_LT, - EL_CHAR_GLEICH, - EL_CHAR_GT, - EL_CHAR_FRAGE, - - EL_CHAR_AT, - EL_CHAR_A + 0, - EL_CHAR_A + 1, - EL_CHAR_A + 2, - - EL_CHAR_A + 3, - EL_CHAR_A + 4, - EL_CHAR_A + 5, - EL_CHAR_A + 6, - - EL_CHAR_A + 7, - EL_CHAR_A + 8, - EL_CHAR_A + 9, - EL_CHAR_A + 10, - - EL_CHAR_A + 11, - EL_CHAR_A + 12, - EL_CHAR_A + 13, - EL_CHAR_A + 14, - - EL_CHAR_A + 15, - EL_CHAR_A + 16, - EL_CHAR_A + 17, - EL_CHAR_A + 18, - - EL_CHAR_A + 19, - EL_CHAR_A + 20, - EL_CHAR_A + 21, - EL_CHAR_A + 22, - - EL_CHAR_A + 23, - EL_CHAR_A + 24, - EL_CHAR_A + 25, - EL_CHAR_AE, - - EL_CHAR_OE, - EL_CHAR_UE, - EL_CHAR_COPY, - EL_LEERRAUM + EL_CHAR('H'), + EL_CHAR('I'), + EL_CHAR('J'), + EL_CHAR('K'), + + EL_CHAR('L'), + EL_CHAR('M'), + EL_CHAR('N'), + EL_CHAR('O'), + + EL_CHAR('P'), + EL_CHAR('Q'), + EL_CHAR('R'), + EL_CHAR('S'), + + EL_CHAR('T'), + EL_CHAR('U'), + EL_CHAR('V'), + EL_CHAR('W'), + + EL_CHAR('X'), + EL_CHAR('Y'), + EL_CHAR('Z'), + EL_CHAR('Ä'), + + EL_CHAR('Ö'), + EL_CHAR('Ü'), + EL_CHAR('^'), + EL_CHAR(' ') }; int elements_in_list = sizeof(editor_element)/sizeof(int); @@ -2313,6 +2341,10 @@ static void DrawPropertiesWindow() { EL_SCHLUESSEL2, &level.score[9], TEXT_COLLECTING }, { EL_SCHLUESSEL3, &level.score[9], TEXT_COLLECTING }, { EL_SCHLUESSEL4, &level.score[9], TEXT_COLLECTING }, + { EL_EM_KEY_1_FILE, &level.score[9], TEXT_COLLECTING }, + { EL_EM_KEY_2_FILE, &level.score[9], TEXT_COLLECTING }, + { EL_EM_KEY_3_FILE, &level.score[9], TEXT_COLLECTING }, + { EL_EM_KEY_4_FILE, &level.score[9], TEXT_COLLECTING }, { EL_AMOEBE_NASS, &level.tempo_amoebe, TEXT_SPEED }, { EL_AMOEBE_NORM, &level.tempo_amoebe, TEXT_SPEED }, { EL_AMOEBE_VOLL, &level.tempo_amoebe, TEXT_SPEED }, @@ -2809,21 +2841,22 @@ static void FloodFill(int from_x, int from_y, int fill_element) } /* values for DrawLevelText() modes */ -#define TEXT_INIT 0 -#define TEXT_SETCURSOR 1 -#define TEXT_WRITECHAR 2 -#define TEXT_BACKSPACE 3 -#define TEXT_NEWLINE 4 -#define TEXT_END 5 +#define TEXT_INIT 0 +#define TEXT_SETCURSOR 1 +#define TEXT_WRITECHAR 2 +#define TEXT_BACKSPACE 3 +#define TEXT_NEWLINE 4 +#define TEXT_END 5 +#define TEXT_QUERY_TYPING 6 -static void DrawLevelText(int sx, int sy, char letter, int mode) +static int DrawLevelText(int sx, int sy, char letter, int mode) { static short delete_buffer[MAX_LEV_FIELDX]; static int start_sx, start_sy; static int last_sx, last_sy; static boolean typing = FALSE; int letter_element = EL_CHAR_ASCII0 + letter; - int lx, ly; + int lx = 0, ly = 0; /* map lower case letters to upper case and convert special characters */ if (letter >= 'a' && letter <= 'z') @@ -2842,7 +2875,7 @@ static void DrawLevelText(int sx, int sy, char letter, int mode) if (mode != TEXT_INIT) { if (!typing) - return; + return FALSE; if (mode != TEXT_SETCURSOR) { @@ -2892,7 +2925,7 @@ static void DrawLevelText(int sx, int sy, char letter, int mode) if (sx > start_sx) { Feld[lx - 1][ly] = delete_buffer[sx - start_sx - 1]; - DrawMiniElement(sx - 1, sy, new_element3); + DrawMiniElement(sx - 1, sy, Feld[lx - 1][ly]); DrawLevelText(sx - 1, sy, 0, TEXT_SETCURSOR); } break; @@ -2910,9 +2943,14 @@ static void DrawLevelText(int sx, int sy, char letter, int mode) typing = FALSE; break; + case TEXT_QUERY_TYPING: + break; + default: break; } + + return typing; } static void SetTextCursor(int unused_sx, int unused_sy, int sx, int sy, @@ -3064,7 +3102,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) int sx = gi->event.x, sy = gi->event.y; int min_sx = 0, min_sy = 0; int max_sx = gi->drawing.area_xsize - 1, max_sy = gi->drawing.area_ysize - 1; - int lx, ly; + int lx = 0, ly = 0; int min_lx = 0, min_ly = 0; int max_lx = lev_fieldx - 1, max_ly = lev_fieldy - 1; int x, y; @@ -3284,10 +3322,17 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) break; case GADGET_ID_PICK_ELEMENT: + + /* if (button_press_event) PickDrawingElement(button, Feld[lx][ly]); + */ + if (button_release_event) ClickOnGadget(level_editor_gadget[last_drawing_function], MB_LEFT); + else + PickDrawingElement(button, Feld[lx][ly]); + break; default: @@ -3777,6 +3822,10 @@ static void HandleControlButtons(struct GadgetInfo *gi) *checkbutton_info[ED_CHECKBUTTON_ID_DOUBLE_SPEED].value ^= TRUE; break; + case GADGET_ID_GRAVITY: + *checkbutton_info[ED_CHECKBUTTON_ID_GRAVITY].value ^= TRUE; + break; + case GADGET_ID_STICK_ELEMENT: *checkbutton_info[ED_CHECKBUTTON_ID_STICK_ELEMENT].value ^= TRUE; break; @@ -3797,6 +3846,9 @@ static void HandleControlButtons(struct GadgetInfo *gi) if (edit_mode == ED_MODE_PROPERTIES) DrawPropertiesWindow(); } + + if (drawing_function == GADGET_ID_PICK_ELEMENT) + ClickOnGadget(level_editor_gadget[last_drawing_function], MB_LEFT); } #ifdef DEBUG else if (gi->event.type == GD_EVENT_PRESSED) @@ -3817,7 +3869,8 @@ void HandleLevelEditorKeyInput(KeySym key) char letter = getCharFromKeySym(key); int button = MB_LEFT; - if (drawing_function == GADGET_ID_TEXT) + if (drawing_function == GADGET_ID_TEXT && + DrawLevelText(0, 0, 0, TEXT_QUERY_TYPING) == TRUE) { if (letter) DrawLevelText(0, 0, letter, TEXT_WRITECHAR); @@ -4001,11 +4054,17 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) break; } - DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, - "%s: %d, %d", infotext, - ABS(lx - start_lx) + 1, - ABS(ly - start_ly) + 1); + if (drawing_function == GADGET_ID_PICK_ELEMENT) + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + "%s: %d, %d", infotext, lx, ly); + else + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + "%s: %d, %d", infotext, + ABS(lx - start_lx) + 1, ABS(ly - start_ly) + 1); } + else if (drawing_function == GADGET_ID_PICK_ELEMENT) + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, + "%s", element_info[Feld[lx][ly]]); else DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FC_YELLOW, "Level position: %d, %d", lx, ly);