public UIDragHandler(UIElement mouseTarget, UIElement dragControl) { UpdateHook = new UpdateHookDelegate(Update); MouseTarget = mouseTarget; DragControl = dragControl; MouseEvent = mouseTarget.ListenForMouse(mouseTarget.GetBounds(), new UIMouseEvent(DragMouseEvents)); }
public PrimitiveBox(PrimBoxType mode, BHAVContainer master) { Type = mode; if (mode == PrimBoxType.True) InstPtr = 254; else InstPtr = 255; Master = master; Nodes = new PrimitiveNode[0]; Width = 32; Height = 32; HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents)); }
public UIBlocker() { MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, 10, 10), OnMouse); SetSize(GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight); }
public UIClickableLabel() { ClickHandler = ListenForMouse(new Rectangle(0, 0, 10, 10), new UIMouseEvent(OnMouseEvent)); }
public UITextEdit() { UIUtils.GiveTooltip(this); TextStyle = TextStyle.DefaultLabel; m_MouseEvent = ListenForMouse(new Rectangle(0, 0, 10, 10), new UIMouseEvent(OnMouseEvent)); }
public PrimitiveBox(BHAVInstruction inst, byte ptr, BHAVContainer master) { Type = PrimBoxType.Primitive; Instruction = inst; Descriptor = PrimitiveRegistry.GetDescriptor(inst.Opcode); Operand = (VMPrimitiveOperand)Activator.CreateInstance(Descriptor.OperandType); Operand.Read(inst.Operand); InstPtr = ptr; Nodes = new PrimitiveNode[2]; Nodes[0] = new PrimitiveNode(); Nodes[0].Type = NodeType.False; Nodes[1] = new PrimitiveNode(); Nodes[1].Type = NodeType.True; Title = new UILabel(); Title.Alignment = TextAlignment.Middle | TextAlignment.Center; Title.Y = 0; Title.X = 0; this.Add(Title); Title.CaptionStyle = TextStyle.DefaultLabel.Clone(); Title.CaptionStyle.Font = FSO.Client.GameFacade.EdithFont; Title.CaptionStyle.Size = 14; BodyTextStyle = TextStyle.DefaultLabel.Clone(); BodyTextStyle.Font = FSO.Client.GameFacade.EdithFont; BodyTextStyle.Size = 12; this.Add(Nodes[0]); this.Add(Nodes[1]); HitTest = ListenForMouse(new Rectangle(0, 0, Width, Height), new UIMouseEvent(MouseEvents)); Master = master; UpdateDisplay(); }
/// <summary> /// /// </summary> /// <param name="Texture"></param> public UIButton(Texture2D Texture) { this.Texture = Texture; ClickHandler = ListenForMouse(new Rectangle(0, 0, m_Width, m_Texture.Height), new UIMouseEvent(OnMouseEvent)); m_TooltipHandler = UIUtils.GiveTooltip(this); //buttons can have tooltips }
public UICatalogItem(bool Active) { SetActive(Active); m_TooltipHandler = UIUtils.GiveTooltip(this); ClickHandler = ListenForMouse(new Rectangle(0, 0, 45, 45), new UIMouseEvent(MouseEvt)); }
public void HandleMouseEvents(UpdateState state) { var mouseBtnDown = state.MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed; var mouseDif = mouseBtnDown != LastMouseDownState; LastMouseDownState = mouseBtnDown; if (mouseDif) { if (mouseBtnDown) { if (LastMouseDown != null) { /** We already have mouse down on an object **/ return; } if (LastMouseOver != null) { LastMouseDown = LastMouseOver; LastMouseDown.Callback(UIMouseEventType.MouseDown, state); } } else { if (LastMouseDown != null) { LastMouseDown.Callback(UIMouseEventType.MouseUp, state); LastMouseDown = null; } } } if (state.MouseEvents.Count > 0) { var topMost = state.MouseEvents.OrderByDescending(x => x.Element.Depth).First(); /** Same element **/ if (LastMouseOver == topMost) { return; } if (LastMouseOver != null) { LastMouseOver.Callback(UIMouseEventType.MouseOut, state); } topMost.Callback(UIMouseEventType.MouseOver, state); LastMouseOver = topMost; } else { if (LastMouseOver != null) { LastMouseOver.Callback(UIMouseEventType.MouseOut, state); LastMouseOver = null; } } }
/// <summary> /// Listen for mouse events on the whole image /// </summary> /// <param name="callback"></param> public void ListenForMouse(UIMouseEvent callback) { m_MouseEvent = ListenForMouse(new Rectangle(0, 0, (int)Width, (int)Height), callback); }
private int _Orientation = 1; //0 is horizontal, 1 is vertical #endregion Fields #region Constructors public UISlider() { m_ThumbEvent = this.ListenForMouse(new Rectangle(0, 0, 0, 0), new UIMouseEvent(OnThumbClick)); }
/** * Mouse utilities */ public UIMouseEventRef ListenForMouse(Rectangle region, UIMouseEvent callback) { var newRegion = new UIMouseEventRef() { Callback = callback, Region = region, Element = this }; if (m_MouseRefs == null) { m_MouseRefs = new List<UIMouseEventRef>(); } m_MouseRefs.Add(newRegion); return newRegion; }
public PrimitiveNode() { HitTest = ListenForMouse(new Rectangle(-16, -16, 32, 32), new UIMouseEvent(MouseEvents)); }
/// <summary> /// Creates a new UILotControl instance. /// </summary> /// <param name="vm">A SimAntics VM instance.</param> /// <param name="World">A World instance.</param> public UILotControl(FSO.SimAntics.VM vm, LotView.World World) { this.vm = vm; this.World = World; ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse); Queue = new UIInteractionQueue(ActiveEntity, vm); this.Add(Queue); ObjectHolder = new UIObjectHolder(vm, World, this); QueryPanel = new UIQueryPanel(World); QueryPanel.OnSellBackClicked += ObjectHolder.SellBack; QueryPanel.X = 0; QueryPanel.Y = -114; //this.Add(QueryPanel); ChatPanel = new UIChatPanel(vm, this); this.Add(ChatPanel); RMBCursor = GetTexture(0x24B00000001); //exploreanchor.bmp vm.OnChatEvent += Vm_OnChatEvent; vm.OnDialog += vm_OnDialog; vm.OnBreakpoint += Vm_OnBreakpoint; Cheats = new UICheatHandler(this); EODs = new UIEODController(this); }
/// <summary> /// Creates a new UILotControl instance. /// </summary> /// <param name="vm">A SimAntics VM instance.</param> /// <param name="World">A World instance.</param> public UILotControl(FSO.SimAntics.VM vm, LotView.World World) { this.vm = vm; this.World = World; ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse); testimg = new UIImage(); testimg.X = 20; testimg.Y = 20; this.Add(testimg); Queue = new UIInteractionQueue(ActiveEntity, vm); this.Add(Queue); ObjectHolder = new UIObjectHolder(vm, World, this); QueryPanel = new UIQueryPanel(World); QueryPanel.OnSellBackClicked += ObjectHolder.SellBack; QueryPanel.X = 177; QueryPanel.Y = GlobalSettings.Default.GraphicsHeight - 228; this.Add(QueryPanel); ChatPanel = new UIChatPanel(vm, this); this.Add(ChatPanel); vm.OnDialog += vm_OnDialog; }
public UIBlocker(int width, int height) { MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, 10, 10), OnMouse); SetSize(width, height); }
public UITextBox() { this.SetBackgroundTexture( GetTexture((ulong)FileIDs.UIFileIDs.dialog_textboxbackground), 13, 13, 13, 13); TextMargin = new Rectangle(8, 3, 8, 5); m_MouseEvent = ListenForMouse(new Rectangle(0, 0, 10, 10), new UIMouseEvent(OnMouseEvent)); }
public BHAVContainer(BHAV target, EditorScope scope) { Scope = scope; EditTarget = target; Selected = new List<PrimitiveBox>(); Primitives = new List<PrimitiveBox>(); RealPrim = new List<PrimitiveBox>(); byte i = 0; foreach (var inst in EditTarget.Instructions) { var ui = new PrimitiveBox(inst, i++, this); Primitives.Add(ui); RealPrim.Add(ui); this.Add(ui); } var RealPrims = new List<PrimitiveBox>(Primitives); foreach (var prim in RealPrims) { if (prim.Instruction.FalsePointer > 252 && prim.Returns != PrimitiveReturnTypes.Done) { var dest = new PrimitiveBox((prim.Instruction.FalsePointer == 254) ? PrimBoxType.True : PrimBoxType.False, this); Primitives.Add(dest); this.Add(dest); prim.FalseUI = dest; } else if (prim.Instruction.FalsePointer < RealPrim.Count) prim.FalseUI = RealPrim[prim.Instruction.FalsePointer]; if (prim.Instruction.TruePointer > 252) { var dest = new PrimitiveBox((prim.Instruction.TruePointer == 254) ? PrimBoxType.True : PrimBoxType.False, this); Primitives.Add(dest); this.Add(dest); prim.TrueUI = dest; } else if (prim.Instruction.TruePointer < RealPrim.Count) prim.TrueUI = RealPrim[prim.Instruction.TruePointer]; } CleanPosition(); HitTest = ListenForMouse(new Rectangle(Int32.MinValue/2, Int32.MinValue / 2, Int32.MaxValue, Int32.MaxValue), new UIMouseEvent(DragMouseEvents)); }
public void RemoveMouseListener(UIMouseEventRef item) { if (m_MouseRefs == null) return; m_MouseRefs.Remove(item); }