#define ED_ELEMENTLIST_YPOS (editor.palette.y)
#define ED_ELEMENTLIST_XSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].width)
#define ED_ELEMENTLIST_YSIZE (graphic_info[IMG_EDITOR_PALETTE_BUTTON].height)
-#define ED_ELEMENTLIST_BUTTONS_HORIZ (editor.palette.cols)
-#define ED_ELEMENTLIST_BUTTONS_VERT (editor.palette.rows)
+#define ED_ELEMENTLIST_COLS MAX(1, editor.palette.cols)
+#define ED_ELEMENTLIST_ROWS MAX(1, editor.palette.rows)
+#define ED_ELEMENTLIST_BUTTONS_HORIZ (ED_ELEMENTLIST_COLS)
+#define ED_ELEMENTLIST_BUTTONS_VERT (ED_ELEMENTLIST_ROWS)
#define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \
ED_ELEMENTLIST_BUTTONS_VERT)
{
// required for correct padding of palette headline buttons
if (*editor_elements_info[i].headline_list_size > 0)
- num_editor_elements += editor.palette.cols;
+ num_editor_elements += ED_ELEMENTLIST_COLS;
for (j = 0; j < *editor_elements_info[i].headline_list_size; j++)
{
// required for correct padding of palette element buttons
int element_list_size = *editor_elements_info[i].element_list_size;
int element_rows =
- (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
- int element_buttons = editor.palette.cols * element_rows;
+ (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
+ int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
num_editor_elements += element_buttons;
}
{
// required for correct padding of palette headline buttons
int headline_size = (*editor_elements_info[i].headline_list_size > 0 ?
- editor.palette.cols : 0);
+ ED_ELEMENTLIST_COLS : 0);
for (j = 0; j < headline_size; j++)
{
// required for correct padding of palette element buttons
int element_list_size = *editor_elements_info[i].element_list_size;
int element_rows =
- (element_list_size + editor.palette.cols - 1) / editor.palette.cols;
- int element_buttons = editor.palette.cols * element_rows;
+ (element_list_size + ED_ELEMENTLIST_COLS - 1) / ED_ELEMENTLIST_COLS;
+ int element_buttons = ED_ELEMENTLIST_COLS * element_rows;
// copy all elements from element list
for (j = 0; j < element_list_size; j++)
*editor_buttons_xy[i].dst = *editor_buttons_xy[i].src;
}
}
+
+ // adjust editor palette rows and columns if specified to be dynamic
+
+ if (editor.palette.cols == -1)
+ {
+ int vp_width = viewport.playfield[GFX_SPECIAL_ARG_EDITOR].width;
+ int bt_width = graphic_info[IMG_EDITOR_PALETTE_BUTTON].width;
+ int sc_width = graphic_info[IMG_EDITOR_PALETTE_SCROLLBAR].width;
+
+ editor.palette.cols = (vp_width - sc_width) / bt_width;
+
+ if (editor.palette.x == -1)
+ {
+ int palette_width = editor.palette.cols * bt_width + sc_width;
+
+ editor.palette.x = (vp_width - palette_width) / 2;
+ }
+ }
+
+ if (editor.palette.rows == -1)
+ {
+ int vp_height = viewport.playfield[GFX_SPECIAL_ARG_EDITOR].height;
+ int bt_height = graphic_info[IMG_EDITOR_PALETTE_BUTTON].height;
+ int tx_height = getFontHeight(FONT_TEXT_2);
+
+ editor.palette.rows = (vp_height - tx_height) / bt_height;
+
+ if (editor.palette.y == -1)
+ {
+ int palette_height = editor.palette.rows * bt_height + tx_height;
+
+ editor.palette.y = (vp_height - palette_height) / 2;
+ }
+ }
}
static void LoadMenuDesignSettingsFromFilename(char *filename)