public GateMouseAndKeyboardControl(GameMenu gameMenu) { this.gameMenu = gameMenu; }
private void CreateGateButtons(InputContainer componentMenu, GameMenu gameMenu) { List <TextureField> icons = new List <TextureField>(); ButtonTexture bt = new ButtonTexture( InputController.DefaultTexture, new Color(50, 50, 50), new Color(100, 100, 100), new Color(75, 75, 75), new Color(95, 115, 255) ); int buttonSize = (Width - (ButtonPrRow + 1) * BPadding) / ButtonPrRow; int offsetY = 0; for (int i = 0; i < gateTypes.Count; i++) { Type gateType = gateTypes[i]; int offsetX = (i % ButtonPrRow); offsetX = offsetX * buttonSize + offsetX * BPadding; offsetY = (i / ButtonPrRow); offsetY = offsetY * buttonSize + offsetY * BPadding; Rectangle bounds = new Rectangle(X + BPadding + offsetX, Y + BPadding + offsetY, buttonSize, buttonSize); Rectangle iconBounds = bounds; iconBounds.Inflate(-4, -4); Texture2D texture; if (gameMenu.GateTextureMap.ContainsKey(gateType.FullName)) { texture = gameMenu.GateTextureMap[gateType.FullName]; } else { texture = InputController.DefaultTexture; } TextureField icon = new TextureField(iconBounds, texture, Color.White); Button temp = new Button(bounds, bt, new Text("", Color.White)); temp.ID = gateType.FullName; icons.Add(icon); group.Add(temp, false); } group.BeforeSelectedButtonChange += (object sender, ButtonEventArgs e) => { if (group.SelectedButton != null) { Containers[group.SelectedButton.ID].Active = false; Containers[group.SelectedButton.ID].DeFocus(); } if (!Selected) { OnActive?.Invoke(); } }; group.AfterSelectedButtonChange += (object sender, ButtonEventArgs e) => { Containers[e.Button.ID].Active = true; Containers[e.Button.ID].Focus(); }; componentMenu.Add(group); componentMenu.Add(icons); CurrentY = offsetY + buttonSize + BPadding; }