Ejemplo n.º 1
0
 /** Override transaction to give player the item, gold etc */
 override public bool Transact(IDragDrop source)
 {
     if (source.DDContent is GuiGold)
     {
         Trace.Log("transfering gold...");
         var gold = (source.DDContent as GuiGold);
         Character.CreditGold(gold.Amount, true);
         gold.DebitSource();
         return(true);
     }
     if (source is GuiItemSlot)
     {
         DDContent        = source.DDContent;
         source.DDContent = new GuiItem();
         return(true);
     }
     if (source is GuiCharacterFrame)
     {
         //swap characters
         CoM.Party.SwapCharacters(this.Character, (source as GuiCharacterFrame).Character);
         CoM.Party.Selected = (source as GuiCharacterFrame).Character;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override void CancelDrag(IDragDrop drag)
    {
        if (drag is WebMapObjectBase)
        {
            DeleteMapObject(drag as WebMapObjectBase);
        }
    }
Ejemplo n.º 3
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override void UpdateDrag(IDragDrop drag)
    {
        if (drag is WebMapObjectBase)
        {
            (drag as WebMapObjectBase).transform.position = m_handpick.Point + (Vector3.up * 40.0f);
        }
    }
Ejemplo n.º 4
0
        /** Overrides transact to make a copy of the dragged in item, but leave the origional intact */
        public override bool Transact(IDragDrop source)
        {
            if (!(source is GuiItemSlot))
            {
                return(false);
            }

            var item = source.DDContent;

            if (item == null)
            {
                return(false);
            }

            if (OrigionalSource != null)
            {
                OrigionalSource.Locked = false;
                if (OrigionalSource.DDContent != null)
                {
                    OrigionalSource.DDContent.SelfEnabled = true;
                }
            }

            OrigionalSource = (GuiItemSlot)source;
            DDContent       = (GuiComponent)item.Clone();

            OrigionalSource.Locked = true;
            if (OrigionalSource.DDContent != null)
            {
                OrigionalSource.DDContent.SelfEnabled = false;
            }

            return(true);
        }
Ejemplo n.º 5
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override bool AcceptDrop(IDragDrop drop)
    {
        if (drop is WebMapObjectBase)
        {
            WebMapObjectBase mapObject = drop as WebMapObjectBase;

            Localizable localizable = CreateMapObjectLocalizable((drop is WebMapFlag) ? OBJECT_TYPE.FLAG : OBJECT_TYPE.PIN);

            if (localizable != null)
            {
                localizable.m_coord.latitude = GetLatitudeFrom3DCoord(mapObject.transform.position);

                localizable.m_coord.longitude = GetLongitudeFrom3DCoord(mapObject.transform.position);

                localizable.m_coord.altitude = 0.0f;

                localizable.DBPush();
            }

            DeleteMapObject(mapObject);

            return(true);
        }

        return(false);
    }
 internal static void SetDragDrop(this PanelDesktop desktop)
 {
     foreach (IDragDrop dd in dragDrop)
     {
         IDragDrop d = dd.New;
         d.Set(null, desktop);
     }
 }
Ejemplo n.º 7
0
 /** Override can send to notify player the item is cursed */
 public override bool CanSend(IDragDrop destination)
 {
     if ((DataLink != null) && (!(destination is GuiInspectionSlot)) && DataLink.IsEquipSlot && containsCursedItem())
     {
         CoM.PostMessage("This item is cursed!");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 8
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    static public void Cancel()
    {
        if ((m_handler != null) && (m_cur != null))
        {
            m_handler.CancelDrag(m_cur);

            m_handler = null;

            m_cur = null;
        }
    }
Ejemplo n.º 9
0
        /** Add character to the list, remove it from source. */
        public override bool Transact(IDragDrop source)
        {
            MDRCharacter character;

            character = source == null ? null : (source.DDContent as GuiCharacterPortrait).Character;
            if (character != null && !characterList.Contains(character))
            {
                characterList.Add(character);
            }
            source.DDContent = null;
            Refresh();
            return(true);
        }
Ejemplo n.º 10
0
        /** Checks if we are dragging an object.  If so draws it, and tests for when to release it */
        private void UpdateDragDrop()
        {
            // reset initial source when mousebutton is up so that when we click next time we can detect the fresh click
            if (Input.GetMouseButton(0) == false)
            {
                initialSource = null;
            }

            // release our object, objects update first so if we get this this point no one has 'accepted' the payload... just cancel the trade.
            if (IsDragging && Input.GetMouseButtonUp(0))
            {
                Cancel();
            }
        }
Ejemplo n.º 11
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    static public bool Begin(IDragDrop handler, IDragDrop obj)
    {
        if (m_cur == null)
        {
            if ((handler != null) && (obj != null) && (handler.BeginDrag(obj)))
            {
                m_cur = obj;

                m_handler = handler;

                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 12
0
        /**
         * Begins the drag / drop process
         * @param forceStart Forces drag drop to begin now rather than waiting for the mouse to move a little
         */
        public void BeginDragDrop(IDragDrop source, bool forceStart = false)
        {
            if (IsDragging)
            {
                return;
            }
            if (source.DDContent == null)
            {
                return;
            }
            if (source.DDContent.IsEmpty)
            {
                return;
            }

            // make sure we've moved a little
            if (!forceStart)
            {
                if (initialSource == null)
                {
                    initialSource = source;
                    initialTime   = Time.time;
                    initialX      = (int)Mouse.Position.x;
                    initialY      = (int)Mouse.Position.y;
                    return;
                }
                else
                {
                    if ((new Vector2(Mouse.Position.x - initialX, Mouse.Position.y - initialY).magnitude < Settings.Advanced.DragMovementThreshold) && (Time.time - initialTime < Settings.Advanced.DragDelay))
                    {
                        return;
                    }
                }
            }

            // begin the drag, and make a copy of this object to show under mouse
            if (source is GuiComponent)
            {
                offset.x = MOUSE_OFFSET_X - MOUSE_RAW_OFFSET * (Mouse.Position.x - (source as GuiComponent).AbsoluteBounds.x);
                offset.y = MOUSE_OFFSET_Y - MOUSE_RAW_OFFSET * (Mouse.Position.y - (source as GuiComponent).AbsoluteBounds.y);
            }
            DDContent       = (GuiComponent)source.DDContent.Clone();
            origionalSender = source;
            source.DDContent.BeingDragged = true;
        }
Ejemplo n.º 13
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    static public bool Drop(IDragDrop container)
    {
        if ((m_handler != null) && (m_cur != null) && (container != null) && (m_cur != container))
        {
            if (container.AcceptDrop(m_cur))
            {
                m_handler = null;

                m_cur = null;

                return(true);
            }

            Cancel();
        }

        return(false);
    }
Ejemplo n.º 14
0
        void DragArea_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            IsDrag = true;//表示开始拖放
            //fe.CaptureMouse();
            ActionDragDrop.DropObject = ParentUC.getDragObject();
            ActionDragDrop.Source     = ParentUC;
            FrameworkElement fe = sender as FrameworkElement;

            if (fe == null)
            {
                return;
            }

            SP = e.GetCurrentPoint(null).Position;
            ShowIcon(SP);

            //e.Handled = true;
        }
Ejemplo n.º 15
0
        /** Ends the drag / drop process */
        public void EndDragDrop(IDragDrop destination)
        {
            // make sure we have something to drop
            if (!IsDragging)
            {
                return;
            }

            if (origionalSender.DDContent != null)
            {
                origionalSender.DDContent.BeingDragged = false;
            }

            // transfer object destination
            if (destination.CanReceive(DDContent) && origionalSender.CanSend(destination))
            {
                destination.Transact(origionalSender);
                DDContent       = null;
                origionalSender = null;
            }
        }
Ejemplo n.º 16
0
        public override bool Transact(IDragDrop source)
        {
            if ((source == null) || !(source is GuiItemSlot))
            {
                return(false);
            }

            var modal = new ModalDecisionState("Are you sure?", "Do you want to destroy " + source.DDContent + "?\nThis item will be permanently destroyed.");

            modal.OnNo += delegate {
                // nothing to do.
            };

            modal.OnYes += delegate {
                (source as GuiItemSlot).DataLink.ItemInstance = null;
            };

            Engine.PushState(modal);

            return(false);
        }
Ejemplo n.º 17
0
        public ActionDragDrop(IDragDrop UC, FrameworkElement dragArea, FrameworkElement dropArea, Panel dp, FrameworkElement Icon)//构造函数
        {
            DragArea = dragArea;
            DropArea = dropArea;
            ParentUC = UC;
            if (dp == null)
            {
                dp = FindDesktop();
            }

            DeskPanel = dp;
            dragicon  = Icon;
            //SProc = sp;
            //TProc = td;
            DragArea.PointerPressed  += new PointerEventHandler(DragArea_PointerPressed);
            DragArea.PointerReleased += new PointerEventHandler(DragArea_PointerReleased);
            //DragArea.PointerExited += new PointerEventHandler(DragArea_PointerExited);
            DropArea.PointerReleased  += new PointerEventHandler(DropArea_PointerReleased);
            DropArea.PointerEntered   += new PointerEventHandler(DropArea_PointerEntered);
            DropArea.PointerExited    += new PointerEventHandler(DropArea_PointerExited);
            DeskPanel.PointerMoved    += new PointerEventHandler(DeskPanel_PointerMoved);
            DeskPanel.PointerReleased += new PointerEventHandler(DeskPanel_PointerReleased);
        }
Ejemplo n.º 18
0
 /** Disable dragging from this reference slot */
 public override bool CanSend(IDragDrop destination)
 {
     return(false);
 }
Ejemplo n.º 19
0
 public virtual void UpdateDrag(IDragDrop obj)
 {
 }
Ejemplo n.º 20
0
 public virtual bool BeginDrag(IDragDrop obj)
 {
     return(false);
 }
Ejemplo n.º 21
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public override bool BeginDrag(IDragDrop drag)
    {
        return(drag is WebMapObjectBase);
    }
Ejemplo n.º 22
0
 public virtual void CancelDrag(IDragDrop obj)
 {
 }
Ejemplo n.º 23
0
 /** Override transaction to switch the store to sell mode, and transfer a copy to the inspection slot */
 override public bool Transact(IDragDrop source)
 {
     Mode = StoreMode.Sell;
     return(sellItemArea.ItemSlot.Transact(source));
 }
Ejemplo n.º 24
0
 public virtual bool AcceptDrop(IDragDrop obj)
 {
     return(false);
 }