From 70fab7480fcedd8f51015d592fc94f3ce50172d0 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 18 Mar 2015 21:37:57 +0100 Subject: [PATCH] improved dynamic layout of editor gadgets (continued) --- build-scripts/create_element_defs.pl | 2 + src/conf_gfx.c | 26 +++++------ src/editor.c | 67 +++++++++++++++++----------- src/main.h | 21 ++++++--- 4 files changed, 70 insertions(+), 46 deletions(-) diff --git a/build-scripts/create_element_defs.pl b/build-scripts/create_element_defs.pl index 06e18972..a2d92d35 100755 --- a/build-scripts/create_element_defs.pl +++ b/build-scripts/create_element_defs.pl @@ -2396,7 +2396,9 @@ sub print_image_config_vars $var =~ s/^(game\.panel\..*)\.tile_size$/$1.size/; $var =~ s/^(request\.button\..*)\.tile_size$/$1.size/; $var =~ s/\.digits$/.size/; + $var =~ s/\.2nd_offset$/.offset2/; $var =~ s/\.2nd_xoffset$/.xoffset2/; + $var =~ s/\.2nd_yoffset$/.yoffset2/; $var =~ s/\.element$/.id/; $var =~ s/\.draw_order$/.sort_priority/; diff --git a/src/conf_gfx.c b/src/conf_gfx.c index d309fb87..bf3a49b7 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -7588,26 +7588,24 @@ struct ConfigInfo image_config[] = { "editor.palette.element_right.y", "258" }, { "editor.palette.element_right.tile_size", "16" }, - { "editor.level_settings.headline.x", "272" }, - { "editor.level_settings.headline.y", "16" }, - { "editor.level_settings.headline.align", "center" }, - { "editor.level_settings.tabs.x", "24" }, - { "editor.level_settings.tabs.y", "64" }, - - { "editor.element_settings.headline.x", "272" }, - { "editor.element_settings.headline.y", "16" }, - { "editor.element_settings.headline.align", "center" }, - { "editor.element_settings.element.x", "24" }, - { "editor.element_settings.element.y", "64" }, - { "editor.element_settings.tabs.x", "24" }, - { "editor.element_settings.tabs.y", "128" }, + { "editor.settings.headline.x", "272" }, + { "editor.settings.headline.y", "16" }, + { "editor.settings.headline.align", "center" }, + { "editor.settings.element_graphic.x", "24" }, + { "editor.settings.element_graphic.y", "64" }, + { "editor.settings.element_name.x", "-1" }, + { "editor.settings.element_name.y", "-1" }, + { "editor.settings.tabs.x", "24" }, + { "editor.settings.tabs.y", "64" }, + { "editor.settings.tabs.2nd_yoffset", "64" }, + { "editor.settings.tabs.draw_xoffset", "0" }, + { "editor.settings.tabs.draw_yoffset", "8" }, { "editor.gadget.normal_spacing", "4" }, { "editor.gadget.small_spacing", "2" }, { "editor.gadget.tiny_spacing", "1" }, { "editor.gadget.line_spacing", "4" }, { "editor.gadget.text_spacing", "4" }, - { "editor.gadget.tab_spacing", "8" }, { "editor.gadget.separator_line.height", "2" }, { "request.button.yes.x", "2" }, diff --git a/src/editor.c b/src/editor.c index 632810d3..091bbd7c 100644 --- a/src/editor.c +++ b/src/editor.c @@ -69,7 +69,6 @@ #define ED_GADGET_TINY_DISTANCE (editor.gadget.tiny_spacing) #define ED_GADGET_LINE_DISTANCE (editor.gadget.line_spacing) #define ED_GADGET_TEXT_DISTANCE (editor.gadget.text_spacing) -#define ED_GADGET_TAB_DISTANCE (editor.gadget.tab_spacing) #define ED_TAB_BAR_HEIGHT (editor.gadget.separator_line.height) #define ED_DRAWINGAREA_TEXT_DISTANCE (ED_GADGET_TEXT_DISTANCE + \ ED_DRAWINGAREA_BORDER_SIZE) @@ -89,25 +88,31 @@ #define ED_TABBUTTON_XSIZE (graphic_info[IMG_EDITOR_TABBUTTON].width) #define ED_TABBUTTON_YSIZE (graphic_info[IMG_EDITOR_TABBUTTON].height) -#define ED_LEVEL_SETTINGS_TABS_XPOS (editor.level_settings.tabs.x) -#define ED_LEVEL_SETTINGS_TABS_YPOS (editor.level_settings.tabs.y) -#define ED_ELEMENT_SETTINGS_TABS_XPOS (editor.element_settings.tabs.x) -#define ED_ELEMENT_SETTINGS_TABS_YPOS (editor.element_settings.tabs.y) +#define ED_LEVEL_SETTINGS_TABS_X (editor.settings.tabs.x) +#define ED_LEVEL_SETTINGS_TABS_Y (editor.settings.tabs.y) +#define ED_ELEMENT_SETTINGS_TABS_X (editor.settings.tabs.x) +#define ED_ELEMENT_SETTINGS_TABS_Y (editor.settings.tabs.y + \ + editor.settings.tabs.yoffset2) -#define ED_LEVEL_SETTINGS_XSTART (ED_LEVEL_SETTINGS_TABS_XPOS) -#define ED_LEVEL_SETTINGS_YSTART (ED_LEVEL_SETTINGS_TABS_YPOS + \ +#define ED_SETTINGS_TABS_XOFFSET (editor.settings.tabs.draw_xoffset) +#define ED_SETTINGS_TABS_YOFFSET (editor.settings.tabs.draw_yoffset) + +#define ED_LEVEL_SETTINGS_XSTART (ED_LEVEL_SETTINGS_TABS_X + \ + ED_SETTINGS_TABS_XOFFSET) +#define ED_LEVEL_SETTINGS_YSTART (ED_LEVEL_SETTINGS_TABS_Y + \ ED_TABBUTTON_YSIZE + \ ED_GADGET_TINY_DISTANCE + \ ED_TAB_BAR_HEIGHT + \ - ED_GADGET_TAB_DISTANCE + \ + ED_SETTINGS_TABS_YOFFSET + \ getFontHeight(FONT_TEXT_1) + \ ED_GADGET_TEXT_DISTANCE) -#define ED_ELEMENT_SETTINGS_XSTART (ED_ELEMENT_SETTINGS_TABS_XPOS) -#define ED_ELEMENT_SETTINGS_YSTART (ED_ELEMENT_SETTINGS_TABS_YPOS + \ +#define ED_ELEMENT_SETTINGS_XSTART (ED_ELEMENT_SETTINGS_TABS_X + \ + ED_SETTINGS_TABS_XOFFSET) +#define ED_ELEMENT_SETTINGS_YSTART (ED_ELEMENT_SETTINGS_TABS_Y + \ ED_TABBUTTON_YSIZE + \ ED_GADGET_TINY_DISTANCE + \ ED_TAB_BAR_HEIGHT + \ - ED_GADGET_TAB_DISTANCE) + ED_SETTINGS_TABS_YOFFSET) #define ED_SETTINGS_XOFFSET (ED_CHECKBUTTON_XSIZE + \ ED_GADGET_TEXT_DISTANCE) @@ -164,11 +169,11 @@ ED_POS_TO_ELEMENT_SETTINGS_Y(n) : (n)) #define ED_TAB_SETTINGS_X(n) (IS_POS_LEVEL_SETTINGS(n) ? \ - ED_LEVEL_SETTINGS_TABS_XPOS : \ - ED_ELEMENT_SETTINGS_TABS_XPOS) + ED_LEVEL_SETTINGS_TABS_X : \ + ED_ELEMENT_SETTINGS_TABS_X) #define ED_TAB_SETTINGS_Y(n) (IS_POS_LEVEL_SETTINGS(n) ? \ - ED_LEVEL_SETTINGS_TABS_YPOS : \ - ED_ELEMENT_SETTINGS_TABS_YPOS) + ED_LEVEL_SETTINGS_TABS_Y : \ + ED_ELEMENT_SETTINGS_TABS_Y) #define ED_SETTINGS_XOFF(n) (5 * ((n) % 4) * \ ED_DRAWINGAREA_TILE_SIZE) @@ -5844,8 +5849,12 @@ static void CreateTextInputGadgets() int xoffset = element_border + TILEX + element_border + 3 * border_size; int yoffset = element_border + (TILEY - font_height) / 2; - x = editor.element_settings.element.x + xoffset - border_size; - y = editor.element_settings.element.y + yoffset - border_size; + x = (editor.settings.element_name.x != -1 ? + editor.settings.element_name.x : + editor.settings.element_graphic.x + xoffset) - border_size; + y = (editor.settings.element_name.y != -1 ? + editor.settings.element_name.y : + editor.settings.element_graphic.y + yoffset) - border_size; } else { @@ -8107,7 +8116,7 @@ static void DrawLevelInfoWindow() { char *text = "Global Settings"; int font_nr = FONT_TITLE_1; - struct MenuPosInfo *pos = &editor.level_settings.headline; + struct MenuPosInfo *pos = &editor.settings.headline; int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font_nr), pos->align); int sy = SY + pos->y; @@ -8972,7 +8981,7 @@ static void DrawPropertiesConfig() if (tab_color != BLACK_PIXEL) /* black => transparent */ FillRectangle(drawto, SX + ED_ELEMENT_SETTINGS_X(0), - SY + ED_ELEMENT_SETTINGS_Y(14) - ED_GADGET_TAB_DISTANCE - + SY + ED_ELEMENT_SETTINGS_Y(14) - ED_SETTINGS_TABS_YOFFSET - ED_TAB_BAR_HEIGHT, getTabulatorBarWidth(), getTabulatorBarHeight(), tab_color); } @@ -9093,13 +9102,17 @@ static void DrawPropertiesWindow() int border_size = gd->border_size; int font_nr = FONT_TEXT_1; int font_height = getFontHeight(font_nr); - int x = editor.element_settings.element.x + element_border; - int y = editor.element_settings.element.y + element_border; int xoffset = TILEX + element_border + 3 * border_size; int yoffset = (TILEY - font_height) / 2; + int x1 = editor.settings.element_graphic.x + element_border; + int y1 = editor.settings.element_graphic.y + element_border; + int x2 = (editor.settings.element_name.x == -1 ? x1 + xoffset : + editor.settings.element_name.x); + int y2 = (editor.settings.element_name.y == -1 ? y1 + yoffset : + editor.settings.element_name.y); char *text = "Element Settings"; int font2_nr = FONT_TITLE_1; - struct MenuPosInfo *pos = &editor.element_settings.headline; + struct MenuPosInfo *pos = &editor.settings.headline; int sx = SX + ALIGNED_XPOS(pos->x, getTextWidth(text, font2_nr), pos->align); int sy = SY + pos->y; @@ -9137,9 +9150,9 @@ static void DrawPropertiesWindow() FrameCounter = 0; /* restart animation frame counter */ - DrawElementBorder(SX + x, SY + y, TILEX, TILEY, FALSE); - DrawEditorElementAnimation(SX + x, SY + y); - DrawEditorElementName(x + xoffset, y + yoffset, font_nr); + DrawElementBorder(SX + x1, SY + y1, TILEX, TILEY, FALSE); + DrawEditorElementAnimation(SX + x1, SY + y1); + DrawEditorElementName(x2, y2, font_nr); DrawPropertiesTabulatorGadgets(); @@ -11995,8 +12008,8 @@ void HandleLevelEditorKeyInput(Key key) void HandleLevelEditorIdle() { int element_border = graphic_info[IMG_EDITOR_ELEMENT_BORDER].border_size; - int x = editor.element_settings.element.x + element_border; - int y = editor.element_settings.element.y + element_border; + int x = editor.settings.element_graphic.x + element_border; + int y = editor.settings.element_graphic.y + element_border; static unsigned int action_delay = 0; unsigned int action_delay_value = GameFrameDelay; int i; diff --git a/src/main.h b/src/main.h index 9917df22..aeceace3 100644 --- a/src/main.h +++ b/src/main.h @@ -2248,12 +2248,25 @@ struct PreviewInfo int anim_mode; }; +struct EditorTabsInfo +{ + int x; + int y; + int yoffset2; + int width; + int height; + int draw_xoffset; + int draw_yoffset; +}; + struct EditorSettingsInfo { struct MenuPosInfo headline; - struct XY element; - struct XY tabs; + struct XY element_graphic; + struct XY element_name; + + struct EditorTabsInfo tabs; }; struct EditorGadgetInfo @@ -2330,9 +2343,7 @@ struct EditorPaletteInfo struct EditorInfo { - struct EditorSettingsInfo level_settings; - struct EditorSettingsInfo element_settings; - + struct EditorSettingsInfo settings; struct EditorGadgetInfo gadget; struct EditorButtonInfo button; struct EditorInputInfo input; -- 2.34.1