Index: binaries/data/mods/public/gui/session/selection_panels.js =================================================================== --- binaries/data/mods/public/gui/session/selection_panels.js +++ binaries/data/mods/public/gui/session/selection_panels.js @@ -101,10 +101,19 @@ } }; +/** + * The command buttons are grouped by pages the size of this variable. + */ +var g_CommandButtonsPerPage = 6; + +/** + * The current command buttons page. + */ +var g_OpenCommandPage = 1; g_SelectionPanels.Command = { "getMaxNumberOfItems": function() { - return 6; + return 18; }, "getItems": function(unitEntStates) { @@ -141,14 +150,24 @@ data.icon.sprite = "stretched:session/icons/" + data.item.icon; + let numberOfPages = Math.ceil(data.numberOfItems / g_CommandButtonsPerPage); let size = data.button.size; // relative to the center ( = 50%) size.rleft = 50; size.rright = 50; // offset from the center calculation, count on square buttons, so size.bottom is the width too - size.left = (data.i - data.numberOfItems / 2) * (size.bottom + 1); + size.left = (data.i % g_CommandButtonsPerPage - Math.min(data.numberOfItems, g_CommandButtonsPerPage) / 2) * + (size.bottom + 1); size.right = size.left + size.bottom; data.button.size = size; + + if (g_OpenCommandPage > numberOfPages) + g_OpenCommandPage = numberOfPages; + + data.button.hidden = g_OpenCommandPage != Math.ceil((data.i + 1) / g_CommandButtonsPerPage); + Engine.GetGUIObjectByName("unitCommandArrowN").hidden = g_OpenCommandPage == numberOfPages; + Engine.GetGUIObjectByName("unitCommandArrowP").hidden = g_OpenCommandPage == 1; + return true; } }; Index: binaries/data/mods/public/gui/session/selection_panels_middle/unit_commands.xml =================================================================== --- binaries/data/mods/public/gui/session/selection_panels_middle/unit_commands.xml +++ binaries/data/mods/public/gui/session/selection_panels_middle/unit_commands.xml @@ -6,12 +6,24 @@ z="30" > - -