From: Holger Schemel Date: Fri, 8 Jan 1999 14:50:53 +0000 (+0100) Subject: rnd-19990108-1 X-Git-Tag: 1.3.0^2~33 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f70652c4a2f2e45d0f4ed7baf62e2311e66d4b13;p=rocksndiamonds.git rnd-19990108-1 --- diff --git a/src/buttons.h b/src/buttons.h index 5dfeb377..5a62e9a4 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -151,6 +151,9 @@ #define ED_BUTTON_EDOWN_Y2POS 165 #define ED_BUTTON_ELEM_Y2POS 190 +#define ED_SCROLLBUTTON_XSIZE 30 +#define ED_SCROLLBUTTON_YSIZE 20 + #define ED_BUTTON_CTRL_XPOS 5 #define ED_BUTTON_CTRL_YPOS 5 #define ED_BUTTON_CTRL_XSIZE 90 @@ -161,20 +164,20 @@ #define ED_BUTTON_FILL_YSIZE 20 #define ED_BUTTON_LEFT_XPOS 5 #define ED_BUTTON_LEFT_YPOS 65 -#define ED_BUTTON_LEFT_XSIZE 30 -#define ED_BUTTON_LEFT_YSIZE 20 +#define ED_BUTTON_LEFT_XSIZE ED_SCROLLBUTTON_XSIZE +#define ED_BUTTON_LEFT_YSIZE ED_SCROLLBUTTON_YSIZE #define ED_BUTTON_UP_XPOS 35 #define ED_BUTTON_UP_YPOS 55 -#define ED_BUTTON_UP_XSIZE 30 -#define ED_BUTTON_UP_YSIZE 20 +#define ED_BUTTON_UP_XSIZE ED_SCROLLBUTTON_XSIZE +#define ED_BUTTON_UP_YSIZE ED_SCROLLBUTTON_YSIZE #define ED_BUTTON_DOWN_XPOS 35 #define ED_BUTTON_DOWN_YPOS 75 -#define ED_BUTTON_DOWN_XSIZE 30 -#define ED_BUTTON_DOWN_YSIZE 20 +#define ED_BUTTON_DOWN_XSIZE ED_SCROLLBUTTON_XSIZE +#define ED_BUTTON_DOWN_YSIZE ED_SCROLLBUTTON_YSIZE #define ED_BUTTON_RIGHT_XPOS 65 #define ED_BUTTON_RIGHT_YPOS 65 -#define ED_BUTTON_RIGHT_XSIZE 30 -#define ED_BUTTON_RIGHT_YSIZE 20 +#define ED_BUTTON_RIGHT_XSIZE ED_SCROLLBUTTON_XSIZE +#define ED_BUTTON_RIGHT_YSIZE ED_SCROLLBUTTON_YSIZE #define ED_BUTTON_EDIT_XPOS 5 #define ED_BUTTON_EDIT_YPOS 5 diff --git a/src/editor.c b/src/editor.c index 1265f4f7..4b3110b1 100644 --- a/src/editor.c +++ b/src/editor.c @@ -86,6 +86,16 @@ #define ED_AREA_ELEMCONT_XPOS (TILEX) #define ED_AREA_ELEMCONT_YPOS (10 * TILEY) +/* values for scrolling gadgets */ +#define ED_SCROLL_UP_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE) +#define ED_SCROLL_UP_YPOS (0) +#define ED_SCROLL_DOWN_XPOS (SXSIZE - ED_SCROLLBUTTON_XSIZE) +#define ED_SCROLL_DOWN_YPOS (SYSIZE - TILEX - ED_SCROLLBUTTON_YSIZE) +#define ED_SCROLL_LEFT_XPOS (0) +#define ED_SCROLL_LEFT_YPOS (SYSIZE - ED_SCROLLBUTTON_YSIZE) +#define ED_SCROLL_RIGHT_XPOS (SXSIZE - TILEX - ED_SCROLLBUTTON_XSIZE) +#define ED_SCROLL_RIGHT_YPOS (SYSIZE - ED_SCROLLBUTTON_YSIZE) + /* control button identifiers */ #define ED_CTRL_ID_SINGLE_ITEMS 0 #define ED_CTRL_ID_CONNECTED_ITEMS 1 @@ -125,30 +135,57 @@ /* text input identifiers */ #define ED_CTRL_ID_LEVEL_NAME 36 -#define ED_NUM_GADGETS 37 +/* gadgets for scrolling of drawing area */ +#define ED_CTRL_ID_SCROLL_UP 37 +#define ED_CTRL_ID_SCROLL_DOWN 38 +#define ED_CTRL_ID_SCROLL_LEFT 39 +#define ED_CTRL_ID_SCROLL_RIGHT 40 + +#define ED_NUM_GADGETS 41 /* values for counter gadgets */ #define ED_COUNTER_SCORE 0 #define ED_COUNTER_ELEMCONT 1 -#define ED_NUM_COUNTERS 2 +#define ED_NUM_COUNTERBUTTONS 2 +#define ED_NUM_SCROLLBUTTONS 4 + +/* values for CopyLevelToUndoBuffer() */ +#define UNDO_IMMEDIATE 0 +#define UNDO_ACCUMULATE 1 static struct { int x, y; int gadget_id; -} counter_info[ED_NUM_COUNTERS] = +} counterbutton_info[ED_NUM_COUNTERBUTTONS] = { - { ED_COUNT_SCORE_XPOS, ED_COUNT_SCORE_YPOS, - ED_CTRL_ID_SCORE_DOWN }, - { ED_COUNT_ELEMCONT_XPOS, ED_COUNT_ELEMCONT_YPOS, - ED_CTRL_ID_ELEMCONT_DOWN } + { ED_COUNT_SCORE_XPOS, ED_COUNT_SCORE_YPOS, ED_CTRL_ID_SCORE_DOWN }, + { ED_COUNT_ELEMCONT_XPOS, ED_COUNT_ELEMCONT_YPOS, ED_CTRL_ID_ELEMCONT_DOWN } }; +static struct +{ + int xpos, ypos; + int x, y; + int gadget_id; +} scrollbutton_info[ED_NUM_SCROLLBUTTONS] = +{ + { ED_BUTTON_UP_XPOS, ED_BUTTON_UP_YPOS, + ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, ED_CTRL_ID_SCROLL_UP }, + { ED_BUTTON_DOWN_XPOS, ED_BUTTON_DOWN_YPOS, + ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, ED_CTRL_ID_SCROLL_DOWN }, + { ED_BUTTON_LEFT_XPOS, ED_BUTTON_LEFT_YPOS, + ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, ED_CTRL_ID_SCROLL_LEFT }, + { ED_BUTTON_RIGHT_XPOS, ED_BUTTON_RIGHT_YPOS, + ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, ED_CTRL_ID_SCROLL_RIGHT } +}; + + /* forward declaration for internal use */ static void DrawDrawingWindow(); static void DrawPropertiesWindow(); -static void CopyLevelToUndoBuffer(); +static void CopyLevelToUndoBuffer(int); static void HandleControlButtons(struct GadgetInfo *); static void HandleCounterButtons(struct GadgetInfo *); static void HandleDrawingAreas(struct GadgetInfo *); @@ -162,7 +199,7 @@ static int last_drawing_function = ED_CTRL_ID_SINGLE_ITEMS; static int properties_element = 0; static short ElementContent[MAX_ELEMCONT][3][3]; -static short OrigBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +static short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static int undo_buffer_position = 0; static int undo_buffer_steps = 0; @@ -557,24 +594,27 @@ int elements_in_list = sizeof(editor_element)/sizeof(int); static void ScrollMiniLevel(int from_x, int from_y, int scroll) { int x,y; - int dx = (scroll==ED_SCROLL_LEFT ? -1 : scroll==ED_SCROLL_RIGHT ? 1 : 0); - int dy = (scroll==ED_SCROLL_UP ? -1 : scroll==ED_SCROLL_DOWN ? 1 : 0); + int dx = (scroll == ED_SCROLL_LEFT ? -1 : scroll == ED_SCROLL_RIGHT ? 1 : 0); + int dy = (scroll == ED_SCROLL_UP ? -1 : scroll == ED_SCROLL_DOWN ? 1 : 0); - XCopyArea(display,drawto,drawto,gc, - SX+MINI_TILEX*(dx==-1),SY+MINI_TILEY*(dy==-1), - SXSIZE-MINI_TILEX*ABS(dx),SYSIZE-MINI_TILEY*ABS(dy), - SX+MINI_TILEX*(dx==+1),SY+MINI_TILEY*(dy==+1)); + XCopyArea(display, drawto, drawto, gc, + SX + (dx == -1 ? MINI_TILEX : 0), + SY + (dy == -1 ? MINI_TILEY : 0), + (ED_FIELDX * MINI_TILEX) - (dx != 0 ? MINI_TILEX : 0), + (ED_FIELDY * MINI_TILEY) - (dy != 0 ? MINI_TILEY : 0), + SX + (dx == +1 ? MINI_TILEX : 0), + SY + (dy == +1 ? MINI_TILEY : 0)); if (dx) { - x = (dx==1 ? 0 : 2*SCR_FIELDX-1); - for(y=0;y<2*SCR_FIELDY;y++) - DrawMiniElementOrWall(x,y,from_x,from_y); + x = (dx == 1 ? 0 : ED_FIELDX - 1); + for(y=0; y lev_fieldx - 2*SCR_FIELDX + 1) - level_xpos = lev_fieldx - 2*SCR_FIELDX + 1; - if (lev_fieldx < 2*SCR_FIELDX - 2) + if (level_xpos > lev_fieldx - ED_FIELDX + 1) + level_xpos = lev_fieldx - ED_FIELDX + 1; + if (lev_fieldx < ED_FIELDX - 2) level_xpos = -1; if (level_ypos < -1) level_ypos = -1; - if (level_ypos > lev_fieldy - 2*SCR_FIELDY + 1) - level_ypos = lev_fieldy - 2*SCR_FIELDY + 1; - if (lev_fieldy < 2*SCR_FIELDY - 2) + if (level_ypos > lev_fieldy - ED_FIELDY + 1) + level_ypos = lev_fieldy - ED_FIELDY + 1; + if (lev_fieldy < ED_FIELDY - 2) level_ypos = -1; } @@ -1262,9 +1352,9 @@ void LevelEd(int mx, int my, int button) if (x>lev_fieldx || y>lev_fieldy || (x==0 && level_xpos<0) || - (x==2*SCR_FIELDX-1 && level_xpos>lev_fieldx-2*SCR_FIELDX) || + (x==ED_FIELDX-1 && level_xpos>lev_fieldx-ED_FIELDX) || (y==0 && level_ypos<0) || - (y==2*SCR_FIELDY-1 && level_ypos>lev_fieldy-2*SCR_FIELDY)) + (y==ED_FIELDY-1 && level_ypos>lev_fieldy-ED_FIELDY)) return; from_x = x+level_xpos; @@ -1369,7 +1459,7 @@ void LevelEd(int mx, int my, int button) { if (!DelayReached(&choice_delay, GADGET_FRAME_DELAY)) break; - if (lev_fieldx<2*SCR_FIELDX-2) + if (lev_fieldxlev_fieldx-2*SCR_FIELDX+1) - level_xpos = lev_fieldx-2*SCR_FIELDX+1; + if (level_xpos>lev_fieldx-ED_FIELDX+1) + level_xpos = lev_fieldx-ED_FIELDX+1; if (button==1) ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_LEFT); else @@ -1403,7 +1493,7 @@ void LevelEd(int mx, int my, int button) { if (!DelayReached(&choice_delay, GADGET_FRAME_DELAY)) break; - if (lev_fieldy<2*SCR_FIELDY-2) + if (lev_fieldylev_fieldy-2*SCR_FIELDY+1) - level_ypos = lev_fieldy-2*SCR_FIELDY+1; + if (level_ypos>lev_fieldy-ED_FIELDY+1) + level_ypos = lev_fieldy-ED_FIELDY+1; if (button==1) ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_UP); else @@ -1451,9 +1541,9 @@ void LevelEd(int mx, int my, int button) if (!button || !in_field_pressed || button<1 || button>3 || (y==0 && level_ypos<0) || - (y==2*SCR_FIELDY-1 && level_ypos>lev_fieldy-2*SCR_FIELDY) || + (y==ED_FIELDY-1 && level_ypos>lev_fieldy-ED_FIELDY) || (x==0 && level_xpos<0) || - (x==2*SCR_FIELDX-1 && level_xpos>lev_fieldx-2*SCR_FIELDX) || + (x==ED_FIELDX-1 && level_xpos>lev_fieldx-ED_FIELDX) || x>lev_fieldx || y>lev_fieldy) return; @@ -1472,8 +1562,8 @@ void LevelEd(int mx, int my, int button) if (Feld[x][y]==EL_SPIELFIGUR || Feld[x][y]==EL_SPIELER1) { Feld[x][y] = EL_LEERRAUM; - if (x-level_xpos>=0 && x-level_xpos<2*SCR_FIELDX && - y-level_ypos>=0 && y-level_ypos<2*SCR_FIELDY) + if (x-level_xpos>=0 && x-level_xpos=0 && y-level_ypos= 0 && x - level_xpos < 2*SCR_FIELDX && - y - level_ypos >= 0 && y - level_ypos < 2*SCR_FIELDY) + if (x - level_xpos >= 0 && x - level_xpos < ED_FIELDX && + y - level_ypos >= 0 && y - level_ypos < ED_FIELDY) DrawMiniElement(x - level_xpos, y - level_ypos, EL_LEERRAUM); } @@ -2640,7 +2776,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) static int last_sy = -1; if (button_release_event) - CopyLevelToUndoBuffer(); + CopyLevelToUndoBuffer(UNDO_IMMEDIATE); if (button) { @@ -2688,7 +2824,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) draw_with_brush = TRUE; } else - CopyLevelToUndoBuffer(); + CopyLevelToUndoBuffer(UNDO_IMMEDIATE); } else if (last_sx != sx || last_sy != sy) { @@ -2710,7 +2846,7 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) { FloodFill(lx, ly, new_element); DrawMiniLevel(level_xpos, level_ypos); - CopyLevelToUndoBuffer(); + CopyLevelToUndoBuffer(UNDO_IMMEDIATE); } break; @@ -2779,7 +2915,8 @@ static void HandleControlButtons(struct GadgetInfo *gi) if (edit_mode == ED_MODE_DRAWING && drawing_function == ED_CTRL_ID_TEXT) DrawLevelText(0, 0, 0, TEXT_END); - if (id < ED_NUM_CTRL1_BUTTONS && edit_mode != ED_MODE_DRAWING) + if (id < ED_NUM_CTRL1_BUTTONS && id != ED_CTRL_ID_PROPERTIES && + edit_mode != ED_MODE_DRAWING) { DrawDrawingWindow(); edit_mode = ED_MODE_DRAWING; @@ -2787,23 +2924,10 @@ static void HandleControlButtons(struct GadgetInfo *gi) switch (id) { - case ED_CTRL_ID_SINGLE_ITEMS: - case ED_CTRL_ID_CONNECTED_ITEMS: - case ED_CTRL_ID_LINE: - case ED_CTRL_ID_TEXT: - case ED_CTRL_ID_RECTANGLE: - case ED_CTRL_ID_FILLED_BOX: - case ED_CTRL_ID_FLOOD_FILL: - case ED_CTRL_ID_BRUSH: - case ED_CTRL_ID_PICK_ELEMENT: - last_drawing_function = drawing_function; - drawing_function = id; - break; - - case ED_CTRL_ID_WRAP_LEFT: + case ED_CTRL_ID_SCROLL_LEFT: if (level_xpos >= 0) { - if (lev_fieldx < 2*SCR_FIELDX - 2) + if (lev_fieldx < ED_FIELDX - 2) break; level_xpos -= step; @@ -2816,15 +2940,15 @@ static void HandleControlButtons(struct GadgetInfo *gi) } break; - case ED_CTRL_ID_WRAP_RIGHT: - if (level_xpos <= lev_fieldx - 2*SCR_FIELDX) + case ED_CTRL_ID_SCROLL_RIGHT: + if (level_xpos <= lev_fieldx - ED_FIELDX) { - if (lev_fieldx < 2*SCR_FIELDX - 2) + if (lev_fieldx < ED_FIELDX - 2) break; level_xpos += step; - if (level_xpos > lev_fieldx - 2*SCR_FIELDX + 1) - level_xpos = lev_fieldx - 2*SCR_FIELDX + 1; + if (level_xpos > lev_fieldx - ED_FIELDX + 1) + level_xpos = lev_fieldx - ED_FIELDX + 1; if (button == 1) ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT); else @@ -2832,10 +2956,10 @@ static void HandleControlButtons(struct GadgetInfo *gi) } break; - case ED_CTRL_ID_WRAP_UP: + case ED_CTRL_ID_SCROLL_UP: if (level_ypos >= 0) { - if (lev_fieldy < 2*SCR_FIELDY - 2) + if (lev_fieldy < ED_FIELDY - 2) break; level_ypos -= step; @@ -2848,15 +2972,15 @@ static void HandleControlButtons(struct GadgetInfo *gi) } break; - case ED_CTRL_ID_WRAP_DOWN: - if (level_ypos <= lev_fieldy - 2*SCR_FIELDY) + case ED_CTRL_ID_SCROLL_DOWN: + if (level_ypos <= lev_fieldy - ED_FIELDY) { - if (lev_fieldy < 2*SCR_FIELDY - 2) + if (lev_fieldy < ED_FIELDY - 2) break; level_ypos += step; - if (level_ypos > lev_fieldy - 2*SCR_FIELDY + 1) - level_ypos = lev_fieldy - 2*SCR_FIELDY + 1; + if (level_ypos > lev_fieldy - ED_FIELDY + 1) + level_ypos = lev_fieldy - ED_FIELDY + 1; if (button == 1) ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP); else @@ -2864,16 +2988,53 @@ static void HandleControlButtons(struct GadgetInfo *gi) } break; - case ED_CTRL_ID_PROPERTIES: - properties_element = new_element; - DrawPropertiesWindow(); - edit_mode = ED_MODE_PROPERTIES; + case ED_CTRL_ID_WRAP_LEFT: + WrapLevel(-step, 0); + break; + + case ED_CTRL_ID_WRAP_RIGHT: + WrapLevel(step, 0); + break; + + case ED_CTRL_ID_WRAP_UP: + WrapLevel(0, -step); + break; + + case ED_CTRL_ID_WRAP_DOWN: + WrapLevel(0, step); + break; + + case ED_CTRL_ID_SINGLE_ITEMS: + case ED_CTRL_ID_CONNECTED_ITEMS: + case ED_CTRL_ID_LINE: + case ED_CTRL_ID_TEXT: + case ED_CTRL_ID_RECTANGLE: + case ED_CTRL_ID_FILLED_BOX: + case ED_CTRL_ID_FLOOD_FILL: + case ED_CTRL_ID_BRUSH: + case ED_CTRL_ID_PICK_ELEMENT: + last_drawing_function = drawing_function; + drawing_function = id; break; case ED_CTRL_ID_RANDOM_PLACEMENT: RandomPlacement(button); break; + case ED_CTRL_ID_PROPERTIES: + if (edit_mode != ED_MODE_PROPERTIES) + { + properties_element = new_element; + DrawPropertiesWindow(); + edit_mode = ED_MODE_PROPERTIES; + } + else + { + DrawDrawingWindow(); + edit_mode = ED_MODE_DRAWING; + } + break; + case ED_CTRL_ID_UNDO: if (undo_buffer_steps == 0) { @@ -2908,7 +3069,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) for(x=0; xevent.type == GD_EVENT_PRESSED) printf("default: HandleControlButtons: GD_EVENT_PRESSED\n"); else if (gi->event.type == GD_EVENT_RELEASED) @@ -3040,6 +3202,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) printf("default: HandleControlButtons: GD_EVENT_MOVING\n"); else printf("default: HandleControlButtons: ?\n"); +#endif break; } } @@ -3069,7 +3232,6 @@ void HandleLevelEditorKeyInput(KeySym key) } } - static void HandleTextInputGadgets(struct GadgetInfo *gi) { int id = gi->custom_id; diff --git a/src/main.c b/src/main.c index f117a856..106fda22 100644 --- a/src/main.c +++ b/src/main.c @@ -94,8 +94,8 @@ int GameFrameDelay = GAME_FRAME_DELAY; int FfwdFrameDelay = FFWD_FRAME_DELAY; int MoveSpeed = 8; int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1; -int SBX_Left, SBX_Middle, SBX_Right; -int SBY_Upper, SBY_Middle, SBY_Lower; +int SBX_Left, SBX_Right; +int SBY_Upper, SBY_Lower; int ZX,ZY, ExitX,ExitY; int AllPlayersGone; int FrameCounter, TimeFrames, TimePlayed, TimeLeft; diff --git a/src/main.h b/src/main.h index c945cec0..f6c62f4b 100644 --- a/src/main.h +++ b/src/main.h @@ -71,6 +71,8 @@ typedef unsigned char byte; #define STD_LEV_FIELDY 32 #define MAX_LEV_FIELDX 128 #define MAX_LEV_FIELDY 128 +#define ED_FIELDX (2 * SCR_FIELDX - 2) +#define ED_FIELDY (2 * SCR_FIELDY - 2) #define MAX_PLAYERS 4 @@ -438,8 +440,8 @@ extern int GameFrameDelay; extern int FfwdFrameDelay; extern int MoveSpeed; extern int BX1,BY1, BX2,BY2; -extern int SBX_Left, SBX_Middle, SBX_Right; -extern int SBY_Upper, SBY_Middle, SBY_Lower; +extern int SBX_Left, SBX_Right; +extern int SBY_Upper, SBY_Lower; extern int ZX,ZY, ExitX,ExitY; extern int AllPlayersGone; extern int FrameCounter, TimeFrames, TimePlayed, TimeLeft; diff --git a/src/tools.c b/src/tools.c index 0c8bde1b..972d7c23 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1370,10 +1370,8 @@ void DrawMiniLevel(int scroll_x, int scroll_y) { int x,y; - ClearWindow(); - - for(x=0; x<2*SCR_FIELDX; x++) - for(y=0; y<2*SCR_FIELDY; y++) + for(x=0; x