コード例 #1
0
ファイル: UIUtils.cs プロジェクト: Daribon/FreeSO
        public UIDragHandler(UIElement mouseTarget, UIElement dragControl)
        {
            UpdateHook = new UpdateHookDelegate(Update);

            MouseTarget = mouseTarget;
            DragControl = dragControl;
            MouseEvent = mouseTarget.ListenForMouse(mouseTarget.GetBounds(), new UIMouseEvent(DragMouseEvents));
        }
コード例 #2
0
ファイル: PrimitiveBox.cs プロジェクト: RHY3756547/FreeSO
 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));
 }
コード例 #3
0
ファイル: UIBlocker.cs プロジェクト: RHY3756547/FreeSO
 public UIBlocker()
 {
     MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, 10, 10), OnMouse);
     SetSize(GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight);
 }
コード例 #4
0
ファイル: UIClickableLabel.cs プロジェクト: RHY3756547/FreeSO
 public UIClickableLabel()
 {
     ClickHandler =
         ListenForMouse(new Rectangle(0, 0, 10, 10), new UIMouseEvent(OnMouseEvent));
 }
コード例 #5
0
ファイル: UITextEdit.cs プロジェクト: RHY3756547/FreeSO
        public UITextEdit()
        {
            UIUtils.GiveTooltip(this);
            TextStyle = TextStyle.DefaultLabel;

            m_MouseEvent = ListenForMouse(new Rectangle(0, 0, 10, 10), new UIMouseEvent(OnMouseEvent));
        }
コード例 #6
0
ファイル: PrimitiveBox.cs プロジェクト: RHY3756547/FreeSO
        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();
        }
コード例 #7
0
ファイル: UIButton.cs プロジェクト: Daribon/FreeSO
        /// <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
        }
コード例 #8
0
ファイル: UICatalogItem.cs プロジェクト: RHY3756547/FreeSO
 public UICatalogItem(bool Active)
 {
     SetActive(Active);
     m_TooltipHandler = UIUtils.GiveTooltip(this);
     ClickHandler = ListenForMouse(new Rectangle(0, 0, 45, 45), new UIMouseEvent(MouseEvt));
 }
コード例 #9
0
ファイル: InputManager.cs プロジェクト: RHY3756547/FreeSO
        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;
                }
            }
        }
コード例 #10
0
ファイル: UIImage.cs プロジェクト: RHY3756547/FreeSO
 /// <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);
 }
コード例 #11
0
ファイル: UISlider.cs プロジェクト: RHY3756547/FreeSO
        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));
        }
コード例 #12
0
ファイル: UIElement.cs プロジェクト: Daribon/FreeSO
        /**
         * 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;
        }
コード例 #13
0
ファイル: PrimitiveNode.cs プロジェクト: RHY3756547/FreeSO
 public PrimitiveNode()
 {
     HitTest = ListenForMouse(new Rectangle(-16, -16, 32, 32), new UIMouseEvent(MouseEvents));
 }
コード例 #14
0
ファイル: UILotControl.cs プロジェクト: RHY3756547/FreeSO
        /// <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);
        }
コード例 #15
0
ファイル: UILotControl.cs プロジェクト: Daribon/FreeSO
        /// <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;
        }
コード例 #16
0
ファイル: UIBlocker.cs プロジェクト: RHY3756547/FreeSO
 public UIBlocker(int width, int height)
 {
     MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0, 10, 10), OnMouse);
     SetSize(width, height);
 }
コード例 #17
0
ファイル: UITextBox.cs プロジェクト: RHY3756547/FreeSO
        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));
        }
コード例 #18
0
ファイル: BHAVContainer.cs プロジェクト: Daribon/FreeSO
        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));
        }
コード例 #19
0
ファイル: InputManager.cs プロジェクト: mitchellbarney/FreeSO
        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;
                }
            }
        }
コード例 #20
0
ファイル: UIElement.cs プロジェクト: RHY3756547/FreeSO
 public void RemoveMouseListener(UIMouseEventRef item)
 {
     if (m_MouseRefs == null) return;
     m_MouseRefs.Remove(item);
 }