Exemple #1
0
 private void PageCornerOnMouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
 {
     if (e.Button == MouseButton.Left && sender is Control ctrl)
     {
         SetActivePage(ctrl.LocalSerial == 0 ? 1 : _maxPage);
     }
 }
Exemple #2
0
        private void ShopItem_MouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
        {
            var shopItem = (ShopItem)sender;

            if (shopItem.Amount <= 0)
            {
                return;
            }


            int total = _shiftPressed ? shopItem.Amount : 1;

            if (_transactionItems.TryGetValue(shopItem.Item, out TransactionItem transactionItem))
            {
                transactionItem.Amount += total;
            }
            else
            {
                transactionItem = new TransactionItem(shopItem.Item, total, shopItem.ShopItemName);
                transactionItem.OnIncreaseButtomClicked += TransactionItem_OnIncreaseButtomClicked;
                transactionItem.OnDecreaseButtomClicked += TransactionItem_OnDecreaseButtomClicked;
                _transactionScrollArea.Add(transactionItem);
                _transactionItems.Add(shopItem.Item, transactionItem);
            }

            shopItem.Amount -= total;
            _updateTotal     = true;
        }
Exemple #3
0
        private void ShopItem_MouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
        {
            ShopItem shopItem = (ShopItem)sender;

            if (shopItem.Amount <= 0)
            {
                return;
            }


            int total = _shiftPressed ? shopItem.Amount : 1;

            if (_transactionItems.TryGetValue(shopItem.LocalSerial, out TransactionItem transactionItem))
            {
                transactionItem.Amount += total;
            }
            else
            {
                transactionItem = new TransactionItem
                                  (
                    shopItem.LocalSerial, shopItem.Graphic, shopItem.Hue, total, (ushort)shopItem.Price,
                    shopItem.ShopItemName
                                  );

                transactionItem.OnIncreaseButtomClicked += TransactionItem_OnIncreaseButtomClicked;
                transactionItem.OnDecreaseButtomClicked += TransactionItem_OnDecreaseButtomClicked;
                _transactionDataBox.Add(transactionItem);
                _transactionItems.Add(shopItem.LocalSerial, transactionItem);
                _transactionDataBox.WantUpdateSize = true;
                _transactionDataBox.ReArrangeChildren();
            }

            shopItem.Amount -= total;
            _updateTotal     = true;
        }
Exemple #4
0
 private void Profile_MouseDoubleClickEvent(object o, MouseDoubleClickEventArgs args)
 {
     if (args.Button == MouseButton.Left)
     {
         GameActions.RequestProfile(Mobile.Serial);
     }
 }
Exemple #5
0
 private void ButtonOnMouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
 {
     if (e.Button == MouseButton.Left)
     {
         GameActions.CastSpell(_spell.ID);
     }
 }
Exemple #6
0
        private void ShopItem_MouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
        {
            var             shopItem = (ShopItem)sender;
            TransactionItem transactionItem;

            if (shopItem.Amount <= 0)
            {
                return;
            }

            if (_transactionItems.TryGetValue(shopItem.Item, out transactionItem))
            {
                transactionItem.Amount++;
            }
            else
            {
                transactionItem = new TransactionItem(shopItem.Item);
                transactionItem.OnIncreaseButtomClicked += TransactionItem_OnIncreaseButtomClicked;
                transactionItem.OnDecreaseButtomClicked += TransactionItem_OnDecreaseButtomClicked;
                _transactionScrollArea.AddChildren(transactionItem);
                _transactionItems.Add(shopItem.Item, transactionItem);
            }

            shopItem.Amount--;
            updateTotal = true;
        }
Exemple #7
0
        private void OnMouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
        {
            if (e.Button == MouseButton.Left)
            {
                GameObject obj = _mousePicker.MouseOverObject;

                switch (obj)
                {
                case Item item:
                    e.Result = true;
                    GameActions.DoubleClick(item);

                    break;

                case Mobile mob:
                    e.Result = true;

                    if (World.Player.InWarMode && World.Player != mob)
                    {
                        GameActions.Attack(mob);
                    }
                    else
                    {
                        GameActions.DoubleClick(mob);
                    }

                    break;

                case GameEffect effect when effect.Source is Item item:
                    e.Result = true;
                    GameActions.DoubleClick(item);

                    break;

                case TextOverhead overhead when overhead.Parent is Entity entity:
                    e.Result = true;
                    GameActions.DoubleClick(entity);
                    break;
                }

                ClearDequeued();
            }
            else if (e.Button == MouseButton.Right)
            {
                if (Engine.Profile.Current.EnablePathfind && !Pathfinder.AutoWalking)
                {
                    if (_mousePicker.MouseOverObject is Land || (GameObjectHelper.TryGetStaticData(_mousePicker.MouseOverObject, out var itemdata) && itemdata.IsSurface))
                    {
                        GameObject obj = _mousePicker.MouseOverObject;

                        if (Pathfinder.WalkTo(obj.X, obj.Y, obj.Z, 0))
                        {
                            World.Player.AddOverhead(MessageType.Label, "Pathfinding!", 3, 0, false);

                            e.Result = true;
                        }
                    }
                }
            }
        }
 private void OnDoubleClicked(object sender, MouseDoubleClickEventArgs e)
 {
     if (_lastPressed != null && e.Button == MouseButton.Left)
     {
         _clickTiming = -Mouse.MOUSE_DELAY_DOUBLE_CLICK;
         GameActions.CastSpell((int)_lastPressed.Tag);
         _lastPressed = null;
     }
 }
Exemple #9
0
 private void VirtueMenu_MouseDoubleClickEvent(object sender, MouseDoubleClickEventArgs args)
 {
     if (args.Button == MouseButton.Left)
     {
         GameActions.ReplyGump(World.Player, 0x000001CD, 0x00000001, new[]
         {
             Mobile.Serial
         }, new Tuple <ushort, string> [0]);
     }
 }
Exemple #10
0
 private void VirtueMenu_MouseDoubleClickEvent(object sender, MouseDoubleClickEventArgs args)
 {
     if (args.Button == MouseButton.Left)
     {
         GameActions.ReplyGump(World.Player, 0x000001CD, 0x00000001, new[]
         {
             Mobile.Serial
         });
         Log.Message(LogTypes.Info, "Virtue DoubleClick event!!");
     }
 }
Exemple #11
0
 private void ButtonOnMouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
 {
     if (e.Button == MouseButton.Left)
     {
         if (_isPrimary)
         {
             GameActions.UsePrimaryAbility();
         }
         else
         {
             GameActions.UseSecondaryAbility();
         }
     }
 }
Exemple #12
0
        private void OnDoubleClicked(object sender, MouseDoubleClickEventArgs e)
        {
            if (_lastPressed != null && e.Button == MouseButton.Left)
            {
                _clickTiming = -Mouse.MOUSE_DELAY_DOUBLE_CLICK;
                var def = GetSpellDefinition((int)_lastPressed.Tag);

                if (def != null)
                {
                    GameActions.CastSpell(def.ID);
                }

                _lastPressed = null;
            }
        }
Exemple #13
0
 private void PartyManifest_MouseDoubleClickEvent(object sender, MouseDoubleClickEventArgs args)
 {
     if (args.Button == MouseButton.Left)
     {
         var party = Engine.UI.GetByLocalSerial <PartyGumpAdvanced>();
         if (party == null)
         {
             Engine.UI.Add(new PartyGumpAdvanced());
         }
         else
         {
             party.BringOnTop();
         }
     }
 }
Exemple #14
0
        private void PartyManifest_MouseDoubleClickEvent(object sender, MouseDoubleClickEventArgs args)
        {
            //CALLS PARTYGUMP
            if (args.Button == MouseButton.Left)
            {
                Log.Message(LogTypes.Warning, "Party manifest pic event!!");

                if (Engine.UI.GetByLocalSerial <PartyGumpAdvanced>() == null)
                {
                    Engine.UI.Add(new PartyGumpAdvanced());
                }
                else
                {
                    Engine.UI.Remove <PartyGumpAdvanced>();
                }
            }
        }
Exemple #15
0
        private void ButtonOnMouseDoubleClick(object sender, MouseDoubleClickEventArgs e)
        {
            if (e.Button == MouseButton.Left)
            {
                ref Ability ability = ref World.Player.Abilities[_isPrimary ? 0 : 1];

                if (((byte)ability & 0x80) == 0)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        World.Player.Abilities[i] &= (Ability)0x7F;
                    }
                    GameActions.UseAbility((byte)ability);
                }
                else
                {
                    GameActions.UseAbility(0);
                }

                ability ^= (Ability)0x80;
            }
Exemple #16
0
        private unsafe void HandleSDLEvent(ref SDL.SDL_Event e)
        {
            switch (e.type)
            {
            case SDL.SDL_EventType.SDL_AUDIODEVICEADDED:
                Console.WriteLine("AUDIO ADDED: {0}", e.adevice.which);

                break;

            case SDL.SDL_EventType.SDL_AUDIODEVICEREMOVED:
                Console.WriteLine("AUDIO REMOVED: {0}", e.adevice.which);

                break;


            case SDL.SDL_EventType.SDL_WINDOWEVENT:

                switch (e.window.windowEvent)
                {
                case SDL_WindowEventID.SDL_WINDOWEVENT_MOVED:


                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                    Mouse.MouseInWindow = true;

                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                    Mouse.MouseInWindow = false;

                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                    Plugin.OnFocusGained();

                    // SDL_CaptureMouse(SDL_bool.SDL_TRUE);
                    //Log.Debug("FOCUS");
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                    Plugin.OnFocusLost();
                    //Log.Debug("NO FOCUS");
                    //SDL_CaptureMouse(SDL_bool.SDL_FALSE);

                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_TAKE_FOCUS:

                    //Log.Debug("TAKE FOCUS");
                    break;

                case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIT_TEST:

                    break;
                }

                break;

            case SDL.SDL_EventType.SDL_SYSWMEVENT:

                break;

            case SDL.SDL_EventType.SDL_KEYDOWN:

                Keyboard.OnKeyDown(e.key);

                if (Plugin.ProcessHotkeys((int)e.key.keysym.sym, (int)e.key.keysym.mod, true))
                {
                    _ignoreNextTextInput = false;

                    //UIManager.MouseOverControl?.InvokeKeyDown(e.key.keysym.sym, e.key.keysym.mod);
                    //if (UIManager.MouseOverControl != UIManager.KeyboardFocusControl)
                    UIManager.KeyboardFocusControl?.InvokeKeyDown(e.key.keysym.sym, e.key.keysym.mod);

                    _scene.OnKeyDown(e.key);
                }
                else
                {
                    _ignoreNextTextInput = true;
                }

                break;

            case SDL.SDL_EventType.SDL_KEYUP:

                Keyboard.OnKeyUp(e.key);

                //if (e.key.keysym.sym == SDL_Keycode.SDLK_0)
                //{


                //    byte[] firebreathcode = {

                //   0xC0,
                //  0x00, 0x00, 0x00, 0x00 , // source serial
                //  0x00 ,0x00 ,0x00 , 0x00,  // target serial
                //    0x00, 0xAA,  // graphic
                //    0xAC, 0x06, // src X
                //    0x74, 0x06,  // src Y
                //    0x28,       // src Z
                //   0x3F, 0x06, // targ X
                //    0x74, 0x06, // targY
                //        0x2B,   // targZ
                //        0x3F, 0x01, 0xF0 , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ,0x00, 0x00,
                //   0x00, 0x00, 0x00, 0x00,
                //    };
                //    int xx =  (0x06 << 8) | (0xAC ) ;
                //    int yy =  (0x06 << 8) | (0x74 ) ;
                //    int txx = (0x06 << 8) |  (0x3F);
                //    int tyy = (0x06 << 8) | (0x74 );

                //    NetClient.EnqueuePacketFromPlugin(firebreathcode, 36);
                //}

                //UIManager.MouseOverControl?.InvokeKeyUp(e.key.keysym.sym, e.key.keysym.mod);
                //if (UIManager.MouseOverControl != UIManager.KeyboardFocusControl)
                UIManager.KeyboardFocusControl?.InvokeKeyUp(e.key.keysym.sym, e.key.keysym.mod);

                _scene.OnKeyUp(e.key);

                break;

            case SDL.SDL_EventType.SDL_TEXTINPUT:

                if (_ignoreNextTextInput)
                    break;

                fixed(SDL.SDL_Event *ev = &e)
                {
                    string s = StringHelper.ReadUTF8(ev->text.text);

                    if (!string.IsNullOrEmpty(s))
                    {
                        UIManager.KeyboardFocusControl?.InvokeTextInput(s);
                        _scene.OnTextInput(s);
                    }
                }

                break;

            case SDL.SDL_EventType.SDL_MOUSEMOTION:
                Mouse.Update();

                if (Mouse.IsDragging)
                {
                    UIManager.OnMouseDragging();
                    _scene.OnMouseDragging();
                }

                if (Mouse.IsDragging && !_dragStarted)
                {
                    _dragStarted = true;
                }

                break;

            case SDL.SDL_EventType.SDL_MOUSEWHEEL:
                Mouse.Update();
                bool isup = e.wheel.y > 0;

                Plugin.ProcessMouse(0, e.wheel.y);

                UIManager.OnMouseWheel(isup);
                _scene.OnMouseWheel(isup);

                break;

            case SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
            case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                Mouse.Update();
                bool isDown    = e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN;
                bool resetTime = false;

                if (_dragStarted && !isDown)
                {
                    _dragStarted = false;
                    resetTime    = true;
                }

                SDL.SDL_MouseButtonEvent mouse = e.button;

                switch ((uint)mouse.button)
                {
                case SDL_BUTTON_LEFT:

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.LButtonPressed    = true;
                        Mouse.LDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastLeftButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastLeftButtonClickTime = 0;
                            bool res;

                            if (UIManager.ValidForDClick())
                            {
                                res = UIManager.OnLeftMouseDoubleClick();
                            }
                            else
                            {
                                res = _scene.OnLeftMouseDoubleClick();
                            }

                            //bool res = _scene.OnLeftMouseDoubleClick() || UIManager.OnLeftMouseDoubleClick();

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Left);

                            if (!arg.Result && !res)
                            {
                                _scene.OnLeftMouseDown();
                                UIManager.OnLeftMouseButtonDown();
                            }
                            else
                            {
                                Mouse.LastLeftButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        _scene.OnLeftMouseDown();
                        UIManager.OnLeftMouseButtonDown();

                        Mouse.LastLeftButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (resetTime)
                        {
                            Mouse.LastLeftButtonClickTime = 0;
                        }

                        if (Mouse.LastLeftButtonClickTime != 0xFFFF_FFFF)
                        {
                            _scene.OnLeftMouseUp();
                            UIManager.OnLeftMouseButtonUp();
                        }
                        Mouse.LButtonPressed = false;
                        Mouse.End();

                        Mouse.LastClickPosition = Mouse.Position;
                    }

                    break;

                case SDL_BUTTON_MIDDLE:

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.MButtonPressed    = true;
                        Mouse.MDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastMidButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastMidButtonClickTime = 0;
                            var res = _scene.OnMiddleMouseDoubleClick();

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Middle);

                            if (!arg.Result && !res)
                            {
                                _scene.OnMiddleMouseDown();
                            }

                            break;
                        }

                        Plugin.ProcessMouse(e.button.button, 0);

                        _scene.OnMiddleMouseDown();
                        Mouse.LastMidButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        Mouse.MButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_RIGHT:

                    if (isDown)
                    {
                        Mouse.Begin();
                        Mouse.RButtonPressed    = true;
                        Mouse.RDropPosition     = Mouse.Position;
                        Mouse.CancelDoubleClick = false;
                        uint ticks = SDL_GetTicks();

                        if (Mouse.LastRightButtonClickTime + Mouse.MOUSE_DELAY_DOUBLE_CLICK >= ticks)
                        {
                            Mouse.LastRightButtonClickTime = 0;

                            var res = _scene.OnRightMouseDoubleClick() || UIManager.OnRightMouseDoubleClick();

                            MouseDoubleClickEventArgs arg = new MouseDoubleClickEventArgs(Mouse.Position.X, Mouse.Position.Y, MouseButton.Right);

                            if (!arg.Result && !res)
                            {
                                _scene.OnRightMouseDown();
                                UIManager.OnRightMouseButtonDown();
                            }
                            else
                            {
                                Mouse.LastRightButtonClickTime = 0xFFFF_FFFF;
                            }

                            break;
                        }

                        _scene.OnRightMouseDown();
                        UIManager.OnRightMouseButtonDown();

                        Mouse.LastRightButtonClickTime = Mouse.CancelDoubleClick ? 0 : ticks;
                    }
                    else
                    {
                        if (resetTime)
                        {
                            Mouse.LastRightButtonClickTime = 0;
                        }

                        if (Mouse.LastRightButtonClickTime != 0xFFFF_FFFF)
                        {
                            _scene.OnRightMouseUp();
                            UIManager.OnRightMouseButtonUp();
                        }
                        Mouse.RButtonPressed = false;
                        Mouse.End();
                    }

                    break;

                case SDL_BUTTON_X1:

                    if (isDown)
                    {
                        Plugin.ProcessMouse(e.button.button, 0);
                    }

                    break;

                case SDL_BUTTON_X2:

                    if (isDown)
                    {
                        Plugin.ProcessMouse(e.button.button, 0);
                    }

                    break;
                }

                break;
            }
        }