private void CreateGateSettings(InputContainer componentMenu) { foreach (Type t in gateTypes) { ParameterInfo[] paras = { }; foreach (var cs in t.GetConstructors()) { if (paras.Length < cs.GetParameters().Length) { paras = cs.GetParameters(); } } InputContainer temp = new InputContainer(); List <Iinput> inputs = new List <Iinput>(); int oldY = CurrentY; foreach (var para in paras) { if (typeof(int).IsAssignableFrom(para.ParameterType)) { Point start = new Point(X + Padding, CurrentY); temp.Add(new Label(new Text(para.Name, Color.Black), start)); int textLength = (int)InputController.DefaultFont.MeasureString(para.Name).X; int textHeight = (int)InputController.DefaultFont.MeasureString(para.Name).Y; int x = start.X + Padding + textLength; int width = X + Width - x - Padding; var input = new NumberSelector(new Rectangle(x, start.Y, width, textHeight), 1, 99, textHeight, 10); temp.Add(input); inputs.Add(input); CurrentY += textHeight + Padding; temp.Active = false; temp.DeFocus(); } } CurrentY = oldY; Containers[t.FullName] = temp; Inputs.Add(temp, inputs); } componentMenu.Add(Containers.Values); }
//------------------------------------------------------------ //------------------------Constructors------------------------ //------------------------------------------------------------ public MessagesBox(TextureField BackgroundTexture) { Bounds = BackgroundTexture.Bounds; Inputs = new InputContainer(BackgroundTexture.Bounds.Location); Inputs.Add(BackgroundTexture, true); }
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; }