internal static void BaserRemove(UIBaser baser) { if (AllBaser == null || !AllBaser.Contains(baser)) { return; } AllBaser.Remove(baser); }
/// <summary> /// 添加UI到此UI的DeBaser,视为所添加的UI依赖此UI /// </summary> /// <param name="baser">所添加的UI</param> public void AddUIBaser(UIBaser baser) { if (!DeBaser.Contains(baser)) { baser.OnBaser = this; DeBaser.Add(baser); } }
public static void Draw(this SpriteBatch spriteBatch, UIBaser baser) { if (baser == null) { throw new ArgumentNullException("baser"); } spriteBatch.Draw(baser.Texture, baser.ScreenPosition, null, baser.Color, baser.Rotation, Vector2.Zero, baser.Scale, baser.SpriteEffect, 0f); }
internal static void BaserAdd(UIBaser baser, int?index = null) { if (AllBaser == null) { AllBaser = new List <UIBaser>(); } if (index.HasValue && index >= 0 && index.Value < AllBaser.Count) { AllBaser.Insert(index.Value, baser); return; } AllBaser.Add(baser); }
public static void UpdateUI(GameTime gameTime) { if (UILoader.clickUINow != null) { UILoader.clickUIBefore = UILoader.clickUINow; UILoader.clickUINow = null; } foreach (UIBaser baser in UIBaser.AllBaser) { if (baser.Activated) { baser.Update(gameTime); if (Main.hasFocus) { baser.FocusUpdate(gameTime); if (!baser.MouseEntered && baser.Rectangle.Contains(Functionser.MousePoint)) { baser.MouseEnter(); baser.MouseEntered = true; } if (baser.MouseEntered && !baser.Rectangle.Contains(Functionser.MousePoint)) { baser.MouseLeave(); baser.MouseEntered = false; } } else { baser.NonFocusUpdate(gameTime); } } } if (Functionser.MouseInAnyBaser()) { if (UILoader.Mouse.Left.Click) { UpdateUIAction(true); } if (UILoader.Mouse.Middle.Click) { UpdateUIAction(null); } if (UILoader.Mouse.Right.Click) { UpdateUIAction(false); } void UpdateUIAction(bool?MouseLeft) { UIBaser clickBaser = UIBaser.AllBaser.FindAll((UIBaser baser) => baser.Rectangle.Contains(Functionser.MousePoint))[0]; UIBaser.AllBaser.ToFront(clickBaser); clickBaser.MouseClick(MouseLeft); UILoader.clickUINow = clickBaser; if (UILoader.clickUIBefore == clickBaser && DateTime.Now - UILoader.clickTime < UIBaser.MaxDoubleClickTime.FromSeconds()) { clickBaser.MouseDoubleClick(MouseLeft); UILoader.clickUIBefore = null; UILoader.clickUINow = null; } UILoader.clickTime = DateTime.Now; } } }