From: Holger Schemel Date: Thu, 20 Oct 2016 21:35:28 +0000 (+0200) Subject: added separate buttons for element properties of drawing elements X-Git-Tag: 4.0.0.0~31 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=cb586ba720ddae3c6d05ba1723b5bd4d58bc98bd added separate buttons for element properties of drawing elements --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 7fe204c9..fd0551f5 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5461,6 +5461,27 @@ struct ConfigInfo image_config[] = { "gfx.editor.button.properties.height", "20" }, { "gfx.editor.button.properties.pressed_xoffset", "-100" }, + { "gfx.editor.button.element_left", "RocksDoor2.png" }, + { "gfx.editor.button.element_left.x", "368" }, + { "gfx.editor.button.element_left.y", "48" }, + { "gfx.editor.button.element_left.width", "16" }, + { "gfx.editor.button.element_left.height", "16" }, + { "gfx.editor.button.element_left.pressed_xoffset", "0" }, + + { "gfx.editor.button.element_middle", "RocksDoor2.png" }, + { "gfx.editor.button.element_middle.x", "368" }, + { "gfx.editor.button.element_middle.y", "48" }, + { "gfx.editor.button.element_middle.width", "16" }, + { "gfx.editor.button.element_middle.height", "16" }, + { "gfx.editor.button.element_middle.pressed_xoffset", "0" }, + + { "gfx.editor.button.element_right", "RocksDoor2.png" }, + { "gfx.editor.button.element_right.x", "368" }, + { "gfx.editor.button.element_right.y", "48" }, + { "gfx.editor.button.element_right.width", "16" }, + { "gfx.editor.button.element_right.height", "16" }, + { "gfx.editor.button.element_right.pressed_xoffset", "0" }, + { "editor.no_toolbox_button", "RocksDoor.png" }, { "editor.no_toolbox_button.x", "506" }, { "editor.no_toolbox_button.y", "286" }, @@ -7665,6 +7686,16 @@ struct ConfigInfo image_config[] = { "editor.button.properties.x", "5" }, { "editor.button.properties.y", "230" }, + { "editor.button.element_left.x", "-1" }, + { "editor.button.element_left.y", "-1" }, + { "editor.button.element_left.tile_size", "-1" }, + { "editor.button.element_middle.x", "-1" }, + { "editor.button.element_middle.y", "-1" }, + { "editor.button.element_middle.tile_size", "-1" }, + { "editor.button.element_right.x", "-1" }, + { "editor.button.element_right.y", "-1" }, + { "editor.button.element_right.tile_size", "-1" }, + { "editor.button.draw_single.x", "6" }, { "editor.button.draw_single.y", "6" }, { "editor.button.draw_connected.x", "28" }, diff --git a/src/editor.c b/src/editor.c index 98c25977..da94af77 100644 --- a/src/editor.c +++ b/src/editor.c @@ -32,26 +32,31 @@ */ /* values for the control window */ -#define ED_CTRL1_BUTTONS_HORIZ 4 +#define ED_CTRL1_BUTTONS_HORIZ 4 /* toolbox */ #define ED_CTRL1_BUTTONS_VERT 4 -#define ED_CTRL2_BUTTONS_HORIZ 3 +#define ED_CTRL2_BUTTONS_HORIZ 3 /* level */ #define ED_CTRL2_BUTTONS_VERT 2 -#define ED_CTRL3_BUTTONS_HORIZ 3 +#define ED_CTRL3_BUTTONS_HORIZ 3 /* CE and GE */ #define ED_CTRL3_BUTTONS_VERT 1 -#define ED_CTRL4_BUTTONS_HORIZ 2 +#define ED_CTRL4_BUTTONS_HORIZ 2 /* CE and GE */ #define ED_CTRL4_BUTTONS_VERT 1 -#define ED_CTRL5_BUTTONS_HORIZ 1 +#define ED_CTRL5_BUTTONS_HORIZ 1 /* properties */ #define ED_CTRL5_BUTTONS_VERT 1 +#define ED_CTRL6_BUTTONS_HORIZ 3 /* properties */ +#define ED_CTRL6_BUTTONS_VERT 1 #define ED_NUM_CTRL1_BUTTONS (ED_CTRL1_BUTTONS_HORIZ * ED_CTRL1_BUTTONS_VERT) #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT) #define ED_NUM_CTRL3_BUTTONS (ED_CTRL3_BUTTONS_HORIZ * ED_CTRL3_BUTTONS_VERT) #define ED_NUM_CTRL4_BUTTONS (ED_CTRL4_BUTTONS_HORIZ * ED_CTRL4_BUTTONS_VERT) #define ED_NUM_CTRL5_BUTTONS (ED_CTRL5_BUTTONS_HORIZ * ED_CTRL5_BUTTONS_VERT) +#define ED_NUM_CTRL6_BUTTONS (ED_CTRL6_BUTTONS_HORIZ * ED_CTRL6_BUTTONS_VERT) #define ED_NUM_CTRL1_2_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS) #define ED_NUM_CTRL1_3_BUTTONS (ED_NUM_CTRL1_2_BUTTONS + ED_NUM_CTRL3_BUTTONS) #define ED_NUM_CTRL1_4_BUTTONS (ED_NUM_CTRL1_3_BUTTONS + ED_NUM_CTRL4_BUTTONS) -#define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS) +#define ED_NUM_CTRL1_5_BUTTONS (ED_NUM_CTRL1_4_BUTTONS + ED_NUM_CTRL5_BUTTONS) +#define ED_NUM_CTRL1_6_BUTTONS (ED_NUM_CTRL1_5_BUTTONS + ED_NUM_CTRL6_BUTTONS) +#define ED_NUM_CTRL_BUTTONS ED_NUM_CTRL1_6_BUTTONS /* values for the element list */ #define ED_ELEMENTLIST_XPOS (editor.palette.x) @@ -341,9 +346,13 @@ #define GADGET_ID_CUSTOM_PASTE (GADGET_ID_TOOLBOX_FIRST + 26) #define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 27) +#define GADGET_ID_ELEMENT_LEFT (GADGET_ID_TOOLBOX_FIRST + 28) +#define GADGET_ID_ELEMENT_MIDDLE (GADGET_ID_TOOLBOX_FIRST + 29) +#define GADGET_ID_ELEMENT_RIGHT (GADGET_ID_TOOLBOX_FIRST + 30) + /* counter gadget identifiers */ -#define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 28) +#define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 31) #define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 0) #define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 1) @@ -993,7 +1002,7 @@ static struct { int graphic; int gadget_id; - struct XY *pos; + struct XYTileSize *pos; int gadget_type; char *infotext; char shortcut; @@ -1152,6 +1161,21 @@ static struct IMG_GFX_EDITOR_BUTTON_PROPERTIES, GADGET_ID_PROPERTIES, &editor.button.properties, GD_TYPE_NORMAL_BUTTON, "properties of drawing element", 'p' + }, + { + IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT, GADGET_ID_ELEMENT_LEFT, + &editor.button.element_left, GD_TYPE_NORMAL_BUTTON, + "properties of drawing element 1", '1' + }, + { + IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE, GADGET_ID_ELEMENT_MIDDLE, + &editor.button.element_middle, GD_TYPE_NORMAL_BUTTON, + "properties of drawing element 2", '2' + }, + { + IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT, GADGET_ID_ELEMENT_RIGHT, + &editor.button.element_right, GD_TYPE_NORMAL_BUTTON, + "properties of drawing element 3", '3' } }; @@ -3434,6 +3458,8 @@ static int new_element3 = EL_SAND; (button) == 2 ? new_element2 : \ (button) == 3 ? new_element3 : EL_EMPTY) +#define BUTTON_TILE_SIZE(x) ((x) >= TILESIZE ? TILESIZE : MINI_TILESIZE) + /* forward declaration for internal use */ static void ModifyEditorCounterValue(int, int); static void ModifyEditorCounterLimits(int, int, int); @@ -5403,13 +5429,10 @@ static void ScrollEditorLevel(int from_x, int from_y, int scroll) BackToFront(); } -void getElementListGraphicSource(int element, Bitmap **bitmap, int *x, int *y) +void getEditorGraphicSource(int element, int tile_size, Bitmap **bitmap, + int *x, int *y) { - int graphic = el2edimg(element); - int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE : - MINI_TILESIZE); - - getSizedGraphicSource(graphic, 0, tile_size, bitmap, x, y); + getSizedGraphicSource(el2edimg(element), 0, tile_size, bitmap, x, y); } static void CreateControlButtons() @@ -5423,8 +5446,11 @@ static void CreateControlButtons() int id = controlbutton_info[i].gadget_id; int type = controlbutton_info[i].gadget_type; int graphic = controlbutton_info[i].graphic; - struct XY *pos = controlbutton_info[i].pos; + struct XYTileSize *pos = controlbutton_info[i].pos; struct GraphicInfo *gd = &graphic_info[graphic]; + Bitmap *deco_bitmap = NULL; + int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0; + int tile_size = 0, deco_shift = 0; int gd_x1 = gd->src_x; int gd_y1 = gd->src_y; int gd_x2 = gd->src_x + gd->pressed_xoffset; @@ -5463,6 +5489,33 @@ static void CreateControlButtons() x += DX; y += DY; } + else if (id == GADGET_ID_ELEMENT_LEFT || + id == GADGET_ID_ELEMENT_MIDDLE || + id == GADGET_ID_ELEMENT_RIGHT) + { + x += DX; + y += DY; + + int element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 : + id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 : + id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : EL_EMPTY); + + tile_size = BUTTON_TILE_SIZE(id == GADGET_ID_ELEMENT_LEFT ? + editor.button.element_left.tile_size : + id == GADGET_ID_ELEMENT_MIDDLE ? + editor.button.element_middle.tile_size : + id == GADGET_ID_ELEMENT_RIGHT ? + editor.button.element_right.tile_size : 0); + + // make sure that decoration does not overlap gadget border + tile_size = MIN(tile_size, MIN(gd->width, gd->height)); + + getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x,&deco_y); + + deco_xpos = (gd->width - tile_size) / 2; + deco_ypos = (gd->height - tile_size) / 2; + deco_shift = 1; + } else { x += EX; @@ -5484,6 +5537,10 @@ static void CreateControlButtons() GDI_DESIGN_PRESSED, gd->bitmap, gd_x2, gd_y2, GDI_ALT_DESIGN_UNPRESSED, gd->bitmap, gd_x1a, gd_y1a, GDI_ALT_DESIGN_PRESSED, gd->bitmap, gd_x2a, gd_y2a, + GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, + GDI_DECORATION_POSITION, deco_xpos, deco_ypos, + GDI_DECORATION_SIZE, tile_size, tile_size, + GDI_DECORATION_SHIFTING, deco_shift, deco_shift, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_INFO, HandleEditorGadgetInfoText, GDI_CALLBACK_ACTION, HandleControlButtons, @@ -5578,11 +5635,11 @@ static void CreateControlButtons() int x = DX + ED_ELEMENTLIST_XPOS + xx * gd->width; int y = DY + ED_ELEMENTLIST_YPOS + yy * gd->height; int element = editor_elements[i]; - int tile_size = (editor.palette.tile_size >= TILESIZE ? TILESIZE : - MINI_TILESIZE); + int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size); unsigned int event_mask = GD_EVENT_RELEASED; - getElementListGraphicSource(element, &deco_bitmap, &deco_x, &deco_y); + getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y); + deco_xpos = (gd->width - tile_size) / 2; deco_ypos = (gd->height - tile_size) / 2; @@ -6527,8 +6584,9 @@ static void MapControlButtons() for (i = 0; i < ED_NUM_CTRL1_2_BUTTONS; i++) MapGadget(level_editor_gadget[i]); - /* map toolbox buttons (element properties button) */ - MapGadget(level_editor_gadget[ED_NUM_CTRL1_4_BUTTONS]); + /* map toolbox buttons (element properties buttons) */ + for (i = ED_NUM_CTRL1_4_BUTTONS; i < ED_NUM_CTRL1_6_BUTTONS; i++) + MapGadget(level_editor_gadget[i]); /* map buttons to select elements */ for (i = 0; i < ED_NUM_ELEMENTLIST_BUTTONS; i++) @@ -7913,10 +7971,11 @@ static void ModifyEditorElementList() struct GadgetInfo *gi = level_editor_gadget[gadget_id]; struct GadgetDesign *gd = &gi->deco.design; int element = editor_elements[element_shift + i]; + int tile_size = BUTTON_TILE_SIZE(editor.palette.tile_size); UnmapGadget(gi); - getElementListGraphicSource(element, &gd->bitmap, &gd->x, &gd->y); + getEditorGraphicSource(element, tile_size, &gd->bitmap, &gd->x, &gd->y); ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END); @@ -7924,12 +7983,28 @@ static void ModifyEditorElementList() } } -static void DrawDrawingElement(int element, struct EditorPaletteElementInfo *e) +static void DrawDrawingElementGraphic(int element, struct XYTileSize *pos) { int graphic = el2edimg(element); - int tile_size = (e->tile_size >= TILESIZE ? TILESIZE : MINI_TILESIZE); + int tile_size = BUTTON_TILE_SIZE(pos->tile_size); + + if (pos->x == -1 && + pos->y == -1) + return; + + DrawSizedGraphicExt(drawto, DX + pos->x, DY + pos->y, graphic, 0, tile_size); +} + +static void ModifyDrawingElementButton(int element, int id) +{ + struct GadgetInfo *gi = level_editor_gadget[id]; + Bitmap *deco_bitmap; + int deco_x, deco_y; + int tile_size = gi->deco.width; - DrawSizedGraphicExt(drawto, DX + e->x, DY + e->y, graphic, 0, tile_size); + getEditorGraphicSource(element, tile_size, &deco_bitmap, &deco_x, &deco_y); + + ModifyGadget(gi, GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y, GDI_END); } static void PickDrawingElement(int button, int element) @@ -7937,12 +8012,13 @@ static void PickDrawingElement(int button, int element) struct { int *new_element; - struct EditorPaletteElementInfo *e; + struct XYTileSize *pos; + int id; } de, drawing_elements[] = { - { &new_element1, &editor.palette.element_left }, - { &new_element2, &editor.palette.element_middle }, - { &new_element3, &editor.palette.element_right }, + { &new_element1, &editor.palette.element_left, GADGET_ID_ELEMENT_LEFT }, + { &new_element2, &editor.palette.element_middle, GADGET_ID_ELEMENT_MIDDLE }, + { &new_element3, &editor.palette.element_right, GADGET_ID_ELEMENT_RIGHT }, }; if (button < 1 || button > 3) @@ -7950,7 +8026,10 @@ static void PickDrawingElement(int button, int element) de = drawing_elements[button - 1]; - DrawDrawingElement((*de.new_element = element), de.e); + *de.new_element = element; // update global drawing element variable + + DrawDrawingElementGraphic(element, de.pos); + ModifyDrawingElementButton(element, de.id); redraw_mask |= REDRAW_DOOR_1; } @@ -11396,6 +11475,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) int button = gi->event.button; int step = BUTTON_STEPSIZE(button); int new_element = BUTTON_ELEMENT(button); + int last_properties_element = properties_element; int x, y; if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT) @@ -11535,9 +11615,19 @@ static void HandleControlButtons(struct GadgetInfo *gi) break; case GADGET_ID_PROPERTIES: - if (edit_mode != ED_MODE_PROPERTIES) + // always switch off element properties when they are already displayed + last_properties_element = new_element; + case GADGET_ID_ELEMENT_LEFT: + case GADGET_ID_ELEMENT_MIDDLE: + case GADGET_ID_ELEMENT_RIGHT: + properties_element = (id == GADGET_ID_ELEMENT_LEFT ? new_element1 : + id == GADGET_ID_ELEMENT_MIDDLE ? new_element2 : + id == GADGET_ID_ELEMENT_RIGHT ? new_element3 : + new_element); + + if (edit_mode != ED_MODE_PROPERTIES || + properties_element != last_properties_element) { - properties_element = new_element; DrawPropertiesWindow(); edit_mode = ED_MODE_PROPERTIES; diff --git a/src/files.c b/src/files.c index df569c52..c0f256c7 100644 --- a/src/files.c +++ b/src/files.c @@ -8971,12 +8971,48 @@ static void InitMenuDesignSettings_SpecialPostProcessing() /* set default position for snapshot buttons to stop/pause/play buttons */ for (i = 0; game_buttons_xy[i].dst != NULL; i++) - { if ((*game_buttons_xy[i].dst).x == -1 && (*game_buttons_xy[i].dst).y == -1) + *game_buttons_xy[i].dst = *game_buttons_xy[i].src; +} + +static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics() +{ + static struct + { + struct XYTileSize *dst, *src; + int graphic; + } + editor_buttons_xy[] = + { + { + &editor.button.element_left, &editor.palette.element_left, + IMG_GFX_EDITOR_BUTTON_ELEMENT_LEFT + }, + { + &editor.button.element_middle, &editor.palette.element_middle, + IMG_GFX_EDITOR_BUTTON_ELEMENT_MIDDLE + }, + { + &editor.button.element_right, &editor.palette.element_right, + IMG_GFX_EDITOR_BUTTON_ELEMENT_RIGHT + }, + + { NULL, NULL } + }; + int i; + + /* set default position for element buttons to element graphics */ + for (i = 0; editor_buttons_xy[i].dst != NULL; i++) + { + if ((*editor_buttons_xy[i].dst).x == -1 && + (*editor_buttons_xy[i].dst).y == -1) { - (*game_buttons_xy[i].dst).x = (*game_buttons_xy[i].src).x; - (*game_buttons_xy[i].dst).y = (*game_buttons_xy[i].src).y; + struct GraphicInfo *gd = &graphic_info[editor_buttons_xy[i].graphic]; + + gd->width = gd->height = editor_buttons_xy[i].src->tile_size; + + *editor_buttons_xy[i].dst = *editor_buttons_xy[i].src; } } } @@ -9364,6 +9400,11 @@ void LoadMenuDesignSettings() InitMenuDesignSettings_SpecialPostProcessing(); } +void LoadMenuDesignSettings_AfterGraphics() +{ + InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(); +} + void LoadUserDefinedEditorElementList(int **elements, int *num_elements) { char *filename = getEditorSetupFilename(); diff --git a/src/files.h b/src/files.h index 2a3900eb..1bb53808 100644 --- a/src/files.h +++ b/src/files.h @@ -64,6 +64,7 @@ void SaveSetup_EditorCascade(); void LoadCustomElementDescriptions(); void InitMenuDesignSettings_Static(); void LoadMenuDesignSettings(); +void LoadMenuDesignSettings_AfterGraphics(); void LoadUserDefinedEditorElementList(int **, int *); void LoadMusicInfo(); void LoadHelpAnimInfo(); diff --git a/src/init.c b/src/init.c index ccdda8e8..c480850c 100644 --- a/src/init.c +++ b/src/init.c @@ -5456,6 +5456,9 @@ static void InitImages() ReinitializeGraphics(); print_timestamp_time("ReinitializeGraphics"); + LoadMenuDesignSettings_AfterGraphics(); + print_timestamp_time("LoadMenuDesignSettings_AfterGraphics"); + UPDATE_BUSY_STATE(); print_timestamp_done("InitImages"); diff --git a/src/libgame/system.h b/src/libgame/system.h index fa422caf..48e06ae1 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1294,6 +1294,12 @@ struct XY int x, y; }; +struct XYTileSize +{ + int x, y; + int tile_size; +}; + struct Rect { int x, y; diff --git a/src/main.h b/src/main.h index 566e0069..b6da3629 100644 --- a/src/main.h +++ b/src/main.h @@ -2349,40 +2349,43 @@ struct EditorGadgetInfo struct EditorButtonInfo { - struct XY prev_level; - struct XY next_level; - - struct XY properties; - - struct XY draw_single; - struct XY draw_connected; - struct XY draw_line; - struct XY draw_arc; - struct XY draw_rectangle; - struct XY draw_filled_box; - struct XY rotate_up; - struct XY draw_text; - struct XY flood_fill; - struct XY rotate_left; - struct XY zoom_level; - struct XY rotate_right; - struct XY draw_random; - struct XY grab_brush; - struct XY rotate_down; - struct XY pick_element; - - struct XY ce_copy_from; - struct XY ce_copy_to; - struct XY ce_swap; - struct XY ce_copy; - struct XY ce_paste; - - struct XY undo; - struct XY conf; - struct XY save; - struct XY clear; - struct XY test; - struct XY exit; + struct XYTileSize prev_level; + struct XYTileSize next_level; + + struct XYTileSize properties; + struct XYTileSize element_left; + struct XYTileSize element_middle; + struct XYTileSize element_right; + + struct XYTileSize draw_single; + struct XYTileSize draw_connected; + struct XYTileSize draw_line; + struct XYTileSize draw_arc; + struct XYTileSize draw_rectangle; + struct XYTileSize draw_filled_box; + struct XYTileSize rotate_up; + struct XYTileSize draw_text; + struct XYTileSize flood_fill; + struct XYTileSize rotate_left; + struct XYTileSize zoom_level; + struct XYTileSize rotate_right; + struct XYTileSize draw_random; + struct XYTileSize grab_brush; + struct XYTileSize rotate_down; + struct XYTileSize pick_element; + + struct XYTileSize ce_copy_from; + struct XYTileSize ce_copy_to; + struct XYTileSize ce_swap; + struct XYTileSize ce_copy; + struct XYTileSize ce_paste; + + struct XYTileSize undo; + struct XYTileSize conf; + struct XYTileSize save; + struct XYTileSize clear; + struct XYTileSize test; + struct XYTileSize exit; }; struct EditorInputInfo @@ -2390,21 +2393,15 @@ struct EditorInputInfo struct XY level_number; }; -struct EditorPaletteElementInfo -{ - int x, y; - int tile_size; -}; - struct EditorPaletteInfo { int x, y; int cols, rows; int tile_size; - struct EditorPaletteElementInfo element_left; - struct EditorPaletteElementInfo element_middle; - struct EditorPaletteElementInfo element_right; + struct XYTileSize element_left; + struct XYTileSize element_middle; + struct XYTileSize element_right; }; struct EditorDrawingAreaInfo