From 66ee990434a0509486d3d2ba69181094d97f35b5 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 20 Dec 1998 05:31:17 +0100 Subject: [PATCH] rnd-19981220-2 --- src/buttons.h | 22 +-- src/editor.c | 416 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 335 insertions(+), 103 deletions(-) diff --git a/src/buttons.h b/src/buttons.h index 91ec8f1e..718f1ee5 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -308,16 +308,18 @@ int CheckCountButtons(int, int, int); #define GDI_RADIO_NR 8 #define GDI_RADIO_PRESSED 9 #define GDI_NUMBER_VALUE 10 -#define GDI_TEXT_VALUE 11 -#define GDI_DESIGN_UNPRESSED 12 -#define GDI_DESIGN_PRESSED 13 -#define GDI_ALT_DESIGN_UNPRESSED 14 -#define GDI_ALT_DESIGN_PRESSED 15 -#define GDI_EVENT_MASK 16 -#define GDI_EVENT 17 -#define GDI_CALLBACK 18 -#define GDI_AREA_SIZE 19 -#define GDI_ITEM_SIZE 20 +#define GDI_NUMBER_MIN 11 +#define GDI_NUMBER_MAX 12 +#define GDI_TEXT_VALUE 13 +#define GDI_DESIGN_UNPRESSED 14 +#define GDI_DESIGN_PRESSED 15 +#define GDI_ALT_DESIGN_UNPRESSED 16 +#define GDI_ALT_DESIGN_PRESSED 17 +#define GDI_EVENT_MASK 18 +#define GDI_EVENT 19 +#define GDI_CALLBACK 20 +#define GDI_AREA_SIZE 21 +#define GDI_ITEM_SIZE 22 typedef void (*gadget_callback_function)(void *); diff --git a/src/editor.c b/src/editor.c index 4ae9f6fd..28d08635 100644 --- a/src/editor.c +++ b/src/editor.c @@ -68,11 +68,17 @@ #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT) #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS) -/* values for other gadgets */ -#define ED_SCORE_XPOS TILEX -#define ED_SCORE_YPOS (7 * TILEY) +/* values for counter gadgets */ #define ED_COUNT_VALUE_XOFFSET 5 #define ED_COUNT_VALUE_YOFFSET 3 +#define ED_COUNT_SCORE_XPOS (TILEX) +#define ED_COUNT_SCORE_YPOS (14 * MINI_TILEY) +#define ED_COUNT_ELEMCONT_XPOS (TILEX) +#define ED_COUNT_ELEMCONT_YPOS (17 * MINI_TILEY) + +/* values for element content drawing areas */ +#define ED_AREA_ELEMCONT_XPOS (TILEX) +#define ED_AREA_ELEMCONT_YPOS (10 * TILEY) /* control button identifiers */ #define ED_CTRL_ID_SINGLE_ITEMS 0 @@ -101,16 +107,21 @@ /* counter button identifiers */ #define ED_CTRL_ID_SCORE_DOWN 22 #define ED_CTRL_ID_SCORE_UP 23 +#define ED_CTRL_ID_ELEMCONT_DOWN 24 +#define ED_CTRL_ID_ELEMCONT_UP 25 /* drawing area identifiers */ -#define ED_CTRL_ID_DRAWING_LEVEL 24 +#define ED_CTRL_ID_DRAWING_LEVEL 26 +#define ED_CTRL_ID_ELEMCONT_0 27 +#define ED_CTRL_ID_ELEMCONT_7 34 -#define ED_NUM_GADGETS 25 +#define ED_NUM_GADGETS 35 /* values for counter gadgets */ #define ED_COUNTER_SCORE 0 +#define ED_COUNTER_ELEMCONT 1 -#define ED_NUM_COUNTERS 1 +#define ED_NUM_COUNTERS 2 static struct { @@ -118,7 +129,10 @@ static struct int gadget_id; } counter_info[ED_NUM_COUNTERS] = { - { ED_SCORE_XPOS, ED_SCORE_YPOS, ED_CTRL_ID_SCORE_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 } }; /* forward declaration for internal use */ @@ -134,6 +148,7 @@ static boolean level_editor_gadgets_created = FALSE; static int drawing_function = ED_CTRL_ID_SINGLE_ITEMS; +static short ElementContent[8][3][3]; static short OrigBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static int undo_buffer_position = 0; @@ -149,6 +164,7 @@ static int random_placement_method = RANDOM_USE_NUM_OBJECTS; /* pointer to score value */ static int *gadget_score_value; +static int *gadget_areas_value; static int level_xpos,level_ypos; static int edit_mode; @@ -584,43 +600,46 @@ static void CreateControlButtons() } } -static void CreateCounterButtons(int counter_id) +static void CreateCounterButtons() { - int i; + int i, j; - for (i=0; i<2; i++) + for (i=0; i to_x) + swap_numbers(&from_x, &to_x); + + if (from_y > to_y) + swap_numbers(&from_y, &to_y); + + if (mode == CB_AREA_TO_BRUSH) + { + for (y=from_y; y<=to_y; y++) + for (x=from_x; x<=to_x; x++) + brush_buffer[x][y] = Feld[x][y]; + + brush_from_x = from_x; + brush_from_y = from_y; + brush_to_x = to_x; + brush_to_y = to_y; + } + else + { + for (y=brush_from_y; y<=brush_to_y; y++) + for (x=brush_from_x; x<=brush_to_x; x++) + Feld[x][y] = brush_buffer[x][y]; + CopyLevelToUndoBuffer(); + } +} + +static void CopyAreaToBrush(int from_x, int from_y, int to_x, int to_y) +{ + CopyBrushExt(from_x, from_y, to_x, to_y, CB_AREA_TO_BRUSH); +} + +#if 0 +static void CopyBrushToLevel() +{ + CopyBrushExt(0, 0, 0, 0, CB_BRUSH_TO_LEVEL); +} +#endif + static void FloodFill(int from_x, int from_y, int fill_element) { int i,x,y; @@ -2112,35 +2299,48 @@ static void RandomPlacement(int button) } DrawMiniLevel(level_xpos, level_ypos); + CopyLevelToUndoBuffer(); } static void HandleDrawingAreas(struct GadgetInfo *gi) { static boolean started_inside_drawing_area = FALSE; + static boolean draw_with_brush = FALSE; boolean inside_drawing_area = !gi->event.off_borders; boolean button_press_event; boolean button_release_event; + boolean draw_level = (gi->custom_id == ED_CTRL_ID_DRAWING_LEVEL); int new_element; int button = gi->event.button; int sx = gi->event.x, sy = gi->event.y; int lx, ly; int x, y; + /* if (edit_mode != ED_MODE_DRAWING) return; + */ button_press_event = (gi->event.type == GD_EVENT_PRESSED); button_release_event = (gi->event.type == GD_EVENT_RELEASED); - sx = (sx < 0 ? 0 : sx > 2*SCR_FIELDX - 1 ? 2*SCR_FIELDX - 1 : sx); - sy = (sy < 0 ? 0 : sy > 2*SCR_FIELDY - 1 ? 2*SCR_FIELDY - 1 : sy); - lx = sx + level_xpos; - ly = sy + level_ypos; - - lx = (lx < 0 ? 0 : lx > lev_fieldx - 1 ? lev_fieldx - 1 : lx); - ly = (ly < 0 ? 0 : ly > lev_fieldy - 1 ? lev_fieldy - 1 : ly); - sx = lx - level_xpos; - sy = ly - level_ypos; + if (draw_level) + { + sx = (sx < 0 ? 0 : sx > 2*SCR_FIELDX - 1 ? 2*SCR_FIELDX - 1 : sx); + sy = (sy < 0 ? 0 : sy > 2*SCR_FIELDY - 1 ? 2*SCR_FIELDY - 1 : sy); + lx = sx + level_xpos; + ly = sy + level_ypos; + + lx = (lx < 0 ? 0 : lx > lev_fieldx - 1 ? lev_fieldx - 1 : lx); + ly = (ly < 0 ? 0 : ly > lev_fieldy - 1 ? lev_fieldy - 1 : ly); + sx = lx - level_xpos; + sy = ly - level_ypos; + } + else + { + sx = (sx < 0 ? 0 : sx > 2 ? 2 : sx); + sy = (sy < 0 ? 0 : sy > 2 ? 2 : sy); + } if (button_press_event) started_inside_drawing_area = inside_drawing_area; @@ -2148,49 +2348,62 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) if (!started_inside_drawing_area) return; - if ((!button && !button_release_event) || - sx > lev_fieldx || sy > lev_fieldy || - (sx == 0 && level_xpos<0) || - (sx == 2*SCR_FIELDX - 1 && level_xpos > lev_fieldx - 2*SCR_FIELDX) || - (sy == 0 && level_ypos < 0) || - (sy == 2*SCR_FIELDY - 1 && level_ypos > lev_fieldy - 2*SCR_FIELDY)) + if (!button && !button_release_event) return; new_element = (button == 1 ? new_element1 : button == 2 ? new_element2 : button == 3 ? new_element3 : 0); + if (!draw_level && drawing_function != ED_CTRL_ID_SINGLE_ITEMS) + return; + switch (drawing_function) { case ED_CTRL_ID_SINGLE_ITEMS: - if (button_release_event) - CopyLevelToUndoBuffer(); + if (draw_level) + { + if (button_release_event) + CopyLevelToUndoBuffer(); - if (!button) - break; + if (!button) + break; - if (new_element != Feld[lx][ly]) - { - if (new_element == EL_SPIELFIGUR) + if (new_element != Feld[lx][ly]) { - /* remove player at old position */ - for(y=0; y= 0 && x - level_xpos < 2*SCR_FIELDX && - y - level_ypos >= 0 && y - level_ypos < 2*SCR_FIELDY) - DrawMiniElement(x - level_xpos, y - level_ypos, EL_LEERRAUM); + 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) + DrawMiniElement(x - level_xpos, y - level_ypos, + EL_LEERRAUM); + } } } } - } - Feld[lx][ly] = new_element; - DrawMiniElement(sx, sy, new_element); + Feld[lx][ly] = new_element; + DrawMiniElement(sx, sy, new_element); + } + } + else + { + DrawMiniGraphicExt(drawto, gc, + gi->x + sx * MINI_TILEX, + gi->y + sy * MINI_TILEY, + el2gfx(new_element)); + DrawMiniGraphicExt(window, gc, + gi->x + sx * MINI_TILEX, + gi->y + sy * MINI_TILEY, + el2gfx(new_element)); } break; @@ -2242,7 +2455,13 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) else if (button_release_event) { draw_func(start_sx, start_sy, sx, sy, new_element, TRUE); - CopyLevelToUndoBuffer(); + if (drawing_function == ED_CTRL_ID_BRUSH) + { + CopyAreaToBrush(start_sx, start_sy, sx, sy); + draw_with_brush = TRUE; + } + else + CopyLevelToUndoBuffer(); } else if (last_sx != sx || last_sy != sy) { @@ -2292,6 +2511,18 @@ static void HandleCounterButtons(struct GadgetInfo *gi) DrawCounterValueField(ED_COUNTER_SCORE, *gadget_score_value); break; + case ED_CTRL_ID_ELEMCONT_DOWN: + case ED_CTRL_ID_ELEMCONT_UP: + *gadget_areas_value += (id == ED_CTRL_ID_ELEMCONT_DOWN ? -step : step); + if (*gadget_areas_value < 1) + *gadget_areas_value = 1; + else if (*gadget_areas_value > 8) + *gadget_areas_value = 8; + + DrawCounterValueField(ED_COUNTER_ELEMCONT, *gadget_areas_value); + DrawElementContentAreas(); + break; + default: break; } @@ -2404,7 +2635,6 @@ static void HandleControlButtons(struct GadgetInfo *gi) case ED_CTRL_ID_RANDOM_PLACEMENT: RandomPlacement(button); - CopyLevelToUndoBuffer(); break; case ED_CTRL_ID_UNDO: -- 2.34.1