/// <summary> /// Setup the panel that allows the user to set the active tactics group /// </summary> private void SetupTacticsGroupPanel() { List <TacticsGroupButton> groupButtons = new List <TacticsGroupButton>(); int rows = 2; int columns = 2; int width = 26; int height = 26; //Keep them even numbers, they are divided by 2 later int xMargin = 4; int yMargin = 4; int widthWithMargin = width + xMargin; int heightWithMargin = height + yMargin; Vector2 baseOffset = Vector2.One * 4; for (int i = 0; i < MinionTacticsPlayer.TACTICS_GROUPS_COUNT; i++) { TacticsGroupButton button = new TacticsGroupButton(i); // todo space these out radially int row = i / columns; int column = i % columns; //Top left of the position it should insert in int yPos = (int)baseOffset.Y + yMargin / 2 + heightWithMargin * row; // offset the X position of the icon in the second row int xPos = (int)baseOffset.X + xMargin / 2 + widthWithMargin * column + (row * widthWithMargin / 2); //Calculation so its centered around the center of both calculated pos and button (dynamic!) float yOffsetForSize = (heightWithMargin - button.Height.Pixels) / 2; float xOffsetForSize = (widthWithMargin - button.Width.Pixels) / 2; button.Top.Pixels = yPos + yOffsetForSize; button.Left.Pixels = xPos + xOffsetForSize; groupButtons.Add(button); } tacticsGroupPanel = new TacticsGroupPanel(groupButtons); //Make it so the panel aligns with the top left corner of the main element tacticsGroupPanel.Top.Precent = 0f; tacticsGroupPanel.Left.Precent = 0f; //Adjust the panels dimensions after populating it tacticsGroupPanel.Width.Pixels = xMargin + widthWithMargin * columns + 2 * baseOffset.X; tacticsGroupPanel.Height.Pixels = yMargin + heightWithMargin * rows + 2 * baseOffset.Y; }
private void SetupDropdown() { List<TacticsGroupButton> groupButtons = new List<TacticsGroupButton>(); int rows = 1; int columns = MinionTacticsPlayer.TACTICS_GROUPS_COUNT - 1;; int width = 40; int height = 40; //Keep them even numbers, they are divided by 2 later int xMargin = 0; int yMargin = 0; int widthWithMargin = width + xMargin; int heightWithMargin = height + yMargin; for(int i = 0; i< MinionTacticsPlayer.TACTICS_GROUPS_COUNT - 1; i++) { TacticsGroupButton button = new TacticsGroupButton(i, quiet: true, radialHover: true); //Top left of the position it should insert in int yPos = yMargin / 2; int xPos = xMargin / 2 + widthWithMargin * i; //Calculation so its centered around the center of both calculated pos and button (dynamic!) float yOffsetForSize = (heightWithMargin - button.Height.Pixels) / 2; float xOffsetForSize = (widthWithMargin - button.Width.Pixels) / 2; button.Top.Pixels = yPos + yOffsetForSize; button.Left.Pixels = xPos + xOffsetForSize; groupButtons.Add(button); } dropDown = new TacticsGroupBuffDropdown(groupButtons); // Initially start in the top corner, below the first buff row dropDown.Top.Pixels = 50; dropDown.Left.Precent = 0f; //Adjust the panels dimensions after populating it dropDown.Width.Pixels = xMargin + widthWithMargin * columns; dropDown.Height.Pixels = yMargin + heightWithMargin * rows; dropDown.PaddingLeft = xMargin; dropDown.PaddingRight = xMargin; }