X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Feditor.c;h=1b40735e534c999ce503e86cabd0cee885e04257;hb=cd47bf969c6d8c602b8f5dfa100f0be944bd0e46;hp=fef23e2b5d3ba6fb172af8e1205a82aa10320606;hpb=c4baa69cc8d5e8398425e67498b49f4b77f8e477;p=rocksndiamonds.git diff --git a/src/editor.c b/src/editor.c index fef23e2b..1b40735e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1,13 +1,12 @@ /*********************************************************** * Rocks'n'Diamonds -- McDuffin Strikes Back! * *----------------------------------------------------------* -* ©1995 Artsoft Development * -* Holger Schemel * -* 33659 Bielefeld-Senne * -* Telefon: (0521) 493245 * -* eMail: aeglos@valinor.owl.de * -* aeglos@uni-paderborn.de * -* q99492@pbhrzx.uni-paderborn.de * +* (c) 1995-98 Artsoft Entertainment * +* Holger Schemel * +* Oststrasse 11a * +* 33604 Bielefeld * +* phone: ++49 +521 290471 * +* email: aeglos@valinor.owl.de * *----------------------------------------------------------* * editor.c * ***********************************************************/ @@ -19,11 +18,29 @@ #include "buttons.h" #include "files.h" +/* positions in the level editor */ +#define ED_WIN_MB_LEFT_XPOS 7 +#define ED_WIN_MB_LEFT_YPOS 6 +#define ED_WIN_LEVELNR_XPOS 77 +#define ED_WIN_LEVELNR_YPOS 7 +#define ED_WIN_MB_MIDDLE_XPOS 7 +#define ED_WIN_MB_MIDDLE_YPOS 258 +#define ED_WIN_MB_RIGHT_XPOS 77 +#define ED_WIN_MB_RIGHT_YPOS 258 + +/* other constants for the editor */ +#define ED_SCROLL_NO 0 +#define ED_SCROLL_LEFT 1 +#define ED_SCROLL_RIGHT 2 +#define ED_SCROLL_UP 4 +#define ED_SCROLL_DOWN 8 + +/* delay value to avoid too fast scrolling etc. */ #define CHOICE_DELAY_VALUE 100 static int level_xpos,level_ypos; -static BOOL edit_mode; -static BOOL name_typing; +static boolean edit_mode; +static boolean name_typing; static int new_element1 = EL_MAUERWERK; static int new_element2 = EL_LEERRAUM; static int new_element3 = EL_ERDREICH; @@ -86,6 +103,11 @@ int editor_element[] = EL_CHAR_A + ('N' - 'A'), EL_CHAR_A + ('E' - 'A'), + EL_SPIELER1, + EL_SPIELER2, + EL_SPIELER3, + EL_SPIELER4, + EL_SPIELFIGUR, EL_LEERRAUM, EL_ERDREICH, @@ -202,9 +224,9 @@ int editor_element[] = EL_DRACHE, EL_SONDE, - EL_LEERRAUM, - EL_LEERRAUM, - EL_LEERRAUM, + EL_MAUER_X, + EL_MAUER_Y, + EL_MAUER_XY, EL_CHAR_A + ('S' - 'A'), EL_CHAR_A + ('O' - 'A'), @@ -397,6 +419,22 @@ void DrawLevelEd() OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2); } + + +void test_func(struct GadgetInfo *gi) +{ + if (gi->event == GD_EVENT_PRESSED) + printf("test_func: GD_EVENT_PRESSED\n"); + else if (gi->event == GD_EVENT_RELEASED) + printf("test_func: GD_EVENT_RELEASED\n"); + else + printf("test_func: ?\n"); +} + + + + + void DrawControlWindow() { int i,x,y; @@ -553,6 +591,32 @@ void DrawControlWindow() int2str(level.fieldx,3),FS_SMALL,FC_YELLOW); DrawText(ED_SIZE_VALUE_XPOS,ED_SIZE_VALUE_YPOS+1*ED_SIZE_GADGET_YSIZE, int2str(level.fieldy,3),FS_SMALL,FC_YELLOW); + + { + Pixmap gd_pixmap = pix[PIX_DOOR]; + int gd_x1 = DOOR_GFX_PAGEX4 + ED_BUTTON_MINUS_XPOS; + int gd_x2 = DOOR_GFX_PAGEX3 + ED_BUTTON_MINUS_XPOS; + int gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS; + struct GadgetInfo *gi; + + gi = CreateGadget(GDI_X, 100, + GDI_Y, 100, + GDI_WIDTH, ED_BUTTON_MINUS_XSIZE, + GDI_HEIGHT, ED_BUTTON_MINUS_YSIZE, + GDI_TYPE, GD_TYPE_NORMAL_BUTTON, + GDI_STATE, GD_BUTTON_UNPRESSED, + GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y, + GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y, + GDI_CALLBACK, test_func, + GDI_END); + + if (gi == NULL) + Error(ERR_EXIT, "cannot create gadget"); + + MapGadget(gi); + } + + } void ScrollMiniLevel(int from_x, int from_y, int scroll) @@ -606,24 +670,25 @@ void FloodFill(int from_x, int from_y, int fill_element) static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} }; static int safety = 0; + /* check if starting field still has the desired content */ + if (Feld[from_x][from_y] == fill_element) + return; + safety++; - if (safety>lev_fieldx*lev_fieldy) - { - fprintf(stderr,"Something went wrong in 'FloodFill()'. Please debug.\n"); - exit(-1); - } + if (safety > lev_fieldx*lev_fieldy) + Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug."); old_element = Feld[from_x][from_y]; Feld[from_x][from_y] = fill_element; for(i=0;i<4;i++) { - x = from_x+check[i][0]; - y = from_y+check[i][1]; + x = from_x + check[i][0]; + y = from_y + check[i][1]; - if (IN_LEV_FIELD(x,y) && Feld[x][y]==old_element) - FloodFill(x,y,fill_element); + if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element) + FloodFill(x, y, fill_element); } safety--; @@ -633,7 +698,7 @@ void LevelEd(int mx, int my, int button) { static int last_button = 0; static int in_field_pressed = FALSE; - static BOOL use_floodfill = FALSE; + static boolean use_floodfill = FALSE; int x = (mx-SX)/MINI_TILEX; int y = (my-SY)/MINI_TILEY; @@ -671,7 +736,7 @@ void LevelEd(int mx, int my, int button) } else /********** EDIT/CTRL-FENSTER **********/ { - static long choice_delay = 0; + static unsigned long choice_delay = 0; int choice = CheckElemButtons(mx,my,button); int elem_pos = choice-ED_BUTTON_ELEM; @@ -741,7 +806,7 @@ void LevelEd(int mx, int my, int button) edit_mode = FALSE; break; case ED_BUTTON_FILL: - AreYouSure("Caution ! Flood fill mode ! Choose area !",AYS_OPEN); + Request("Caution ! Flood fill mode ! Choose area !",REQ_OPEN); use_floodfill = TRUE; return; break; @@ -1006,7 +1071,7 @@ void LevelEd(int mx, int my, int button) edit_mode = TRUE; break; case ED_BUTTON_CLEAR: - if (AreYouSure("Are you sure to clear this level ?",AYS_ASK)) + if (Request("Are you sure to clear this level ?",REQ_ASK)) { for(x=0;x