From: Holger Schemel Date: Tue, 15 Dec 1998 01:56:48 +0000 (+0100) Subject: rnd-19981215-2 X-Git-Tag: 1.3.0^2~59 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=76e9111869247eae9edd4e65ee4e8ab615110744;p=rocksndiamonds.git rnd-19981215-2 --- diff --git a/src/buttons.c b/src/buttons.c index 8148e448..c9e00fca 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1721,7 +1721,6 @@ void HandleGadgets(int mx, int my, int button) DrawGadget(gi, TRUE, TRUE); gi->state = GD_BUTTON_PRESSED; gi->event.type = GD_EVENT_MOVING; - gi->event.button = button; if (gi->event_mask & GD_EVENT_MOVING) gi->callback(gi); @@ -1736,7 +1735,6 @@ void HandleGadgets(int mx, int my, int button) { gi->state = GD_BUTTON_UNPRESSED; gi->event.type = GD_EVENT_RELEASED; - gi->event.button = button; DrawGadget(gi, FALSE, TRUE); if (gi->event_mask & GD_EVENT_RELEASED) diff --git a/src/editor.c b/src/editor.c index 5a8035a8..0c97b9ee 100644 --- a/src/editor.c +++ b/src/editor.c @@ -42,6 +42,10 @@ /* how many steps can be cancelled */ #define NUM_UNDO_STEPS (10 + 1) +/* values for random placement */ +#define RANDOM_USE_PERCENTAGE 0 +#define RANDOM_USE_NUM_OBJECTS 1 + /* values for the control window */ #define ED_CTRL_BUTTONS_GFX_YPOS 236 #define ED_CTRL1_BUTTONS_HORIZ 4 @@ -98,6 +102,14 @@ static short UndoBuffer[NUM_UNDO_STEPS][MAX_LEV_FIELDX][MAX_LEV_FIELDY]; static int undo_buffer_position = 0; static int undo_buffer_steps = 0; +static int random_placement_percentage = 10; +static int random_placement_num_objects = 10; +#if 0 +static int random_placement_method = RANDOM_USE_PERCENTAGE; +#else +static int random_placement_method = RANDOM_USE_NUM_OBJECTS; +#endif + static int level_xpos,level_ypos; static boolean edit_mode; static boolean name_typing; @@ -1643,6 +1655,44 @@ void CopyLevelToUndoBuffer() */ } +void RandomPlacement(int button) +{ + int new_element; + int x, y; + + new_element = (button == 1 ? new_element1 : + button == 2 ? new_element2 : + button == 3 ? new_element3 : 0); + + CopyLevelToUndoBuffer(); + + if (random_placement_method == RANDOM_USE_PERCENTAGE) + { + for(x=0; x 0) + { + x = RND(lev_fieldx); + y = RND(lev_fieldy); + + if (Feld[x][y] != new_element) + { + Feld[x][y] = new_element; + elements_left--; + } + } + } + + DrawMiniLevel(level_xpos, level_ypos); +} + void HandleDrawingFunctions(int mx, int my, int button) { static int last_button = 0; @@ -1892,6 +1942,7 @@ void HandlePressedControlButtons() void HandleControlButtons(struct GadgetInfo *gi) { int event_type = gi->event.type; + int button = gi->event.button; int player_present = FALSE; int level_changed = FALSE; int id; @@ -1918,11 +1969,14 @@ void HandleControlButtons(struct GadgetInfo *gi) case ED_CTRL_ID_RECTANGLE: case ED_CTRL_ID_FILLED_BOX: case ED_CTRL_ID_FLOOD_FILL: - case ED_CTRL_ID_RANDOM_PLACEMENT: case ED_CTRL_ID_BRUSH: drawing_function = id; break; + case ED_CTRL_ID_RANDOM_PLACEMENT: + RandomPlacement(button); + break; + case ED_CTRL_ID_UNDO: if (undo_buffer_steps == 0) { @@ -2063,11 +2117,11 @@ void HandleControlButtons(struct GadgetInfo *gi) default: if (event_type == GD_EVENT_PRESSED) - printf("test_func2: GD_EVENT_PRESSED\n"); + printf("HandleControlButtons: GD_EVENT_PRESSED\n"); else if (event_type == GD_EVENT_RELEASED) - printf("test_func2: GD_EVENT_RELEASED\n"); + printf("HandleControlButtons: GD_EVENT_RELEASED\n"); else - printf("test_func2: ?\n"); + printf("HandleControlButtons: ?\n"); break; } }