From: Holger Schemel Date: Mon, 2 Feb 2015 23:30:57 +0000 (+0100) Subject: fixed configurability of editor element palette (for columns != 4) X-Git-Tag: 4.0.0.0-rc1~301 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a1627e4fd77cc7d612fd77e56c7fb35e19d9092a;p=rocksndiamonds.git fixed configurability of editor element palette (for columns != 4) --- diff --git a/src/editor.c b/src/editor.c index 5fc8ccd4..d993af34 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4946,7 +4946,9 @@ static void ReinitializeElementList() { if (setup.editor.el_headlines) { - num_editor_elements += *editor_elements_info[i].headline_list_size; + // required for correct padding of palette headline buttons + if (*editor_elements_info[i].headline_list_size > 0) + num_editor_elements += editor.palette.cols; for (j = 0; j < *editor_elements_info[i].headline_list_size; j++) { @@ -4960,7 +4962,13 @@ static void ReinitializeElementList() if (found_inactive_cascade) continue; - num_editor_elements += *editor_elements_info[i].element_list_size; + // 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; + + num_editor_elements += element_buttons; } } @@ -4984,9 +4992,16 @@ static void ReinitializeElementList() { if (setup.editor.el_headlines) { - for (j = 0; j < *editor_elements_info[i].headline_list_size; j++) + // required for correct padding of palette headline buttons + int headline_size = (*editor_elements_info[i].headline_list_size > 0 ? + editor.palette.cols : 0); + + for (j = 0; j < headline_size; j++) { - int element = (*editor_elements_info[i].headline_list)[j]; + // use empty elements for padding of palette headline buttons + int element = (j < *editor_elements_info[i].headline_list_size ? + (*editor_elements_info[i].headline_list)[j] : + editor_el_empty[0]); editor_elements[pos++] = element; @@ -4998,8 +5013,19 @@ static void ReinitializeElementList() if (found_inactive_cascade) continue; - for (j = 0; j < *editor_elements_info[i].element_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; + + // copy all elements from element list + for (j = 0; j < element_list_size; j++) editor_elements[pos++] = (*editor_elements_info[i].element_list)[j]; + + // use empty elements for padding of palette element buttons + for (j = 0; j < element_buttons - element_list_size; j++) + editor_elements[pos++] = editor_el_empty[0]; } }