Esempio n. 1
0
        public static void Update()
        {
            if (!IsEnabled || Timer > Time.Ticks)
            {
                return;
            }

            Entity entity = World.Get(Serial);

            if (entity != null)
            {
                if (!World.ClientFeatures.TooltipsEnabled || SerialHelper.IsItem
                        (Serial) && ((Item)entity).IsLocked && ((Item)entity).ItemData.Weight == 255 &&
                    !((Item)entity).ItemData.IsContainer)
                {
                    GameActions.SingleClick(Serial);
                }

                if (World.ClientFeatures.PopupEnabled)
                {
                    GameActions.OpenPopupMenu(Serial);
                }
            }

            Clear();
        }
Esempio n. 2
0
        public static bool IsAllowed(Entity serial)
        {
            if (serial == null)
            {
                return(false);
            }

            if (TypeAllowed == NameOverheadTypeAllowed.All)
            {
                return(true);
            }

            if (SerialHelper.IsItem(serial.Serial) && TypeAllowed == NameOverheadTypeAllowed.Items)
            {
                return(true);
            }

            if (SerialHelper.IsMobile(serial.Serial) && TypeAllowed.HasFlag(NameOverheadTypeAllowed.Mobiles))
            {
                return(true);
            }

            if (TypeAllowed.HasFlag(NameOverheadTypeAllowed.Corpses) && SerialHelper.IsItem(serial.Serial) && World.Items.Get(serial)?.IsCorpse == true)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        private string ReadProperties(uint serial, out string htmltext)
        {
            bool hasStartColor = false;

            string result = null;

            htmltext = string.Empty;

            if (SerialHelper.IsValid(serial) && World.OPL.TryGetNameAndData(serial, out string name, out string data))
            {
                ValueStringBuilder sbHTML = new ValueStringBuilder();
                {
                    ValueStringBuilder sb = new ValueStringBuilder();
                    {
                        if (!string.IsNullOrEmpty(name))
                        {
                            if (SerialHelper.IsItem(serial))
                            {
                                sbHTML.Append("<basefont color=\"yellow\">");
                                hasStartColor = true;
                            }
                            else
                            {
                                Mobile mob = World.Mobiles.Get(serial);

                                if (mob != null)
                                {
                                    sbHTML.Append(Notoriety.GetHTMLHue(mob.NotorietyFlag));
                                    hasStartColor = true;
                                }
                            }

                            sb.Append(name);
                            sbHTML.Append(name);

                            if (hasStartColor)
                            {
                                sbHTML.Append("<basefont color=\"#FFFFFFFF\">");
                            }
                        }

                        if (!string.IsNullOrEmpty(data))
                        {
                            sb.Append('\n');
                            sb.Append(data);
                            sbHTML.Append('\n');
                            sbHTML.Append(data);
                        }

                        htmltext = sbHTML.ToString();
                        result   = sb.ToString();

                        sb.Dispose();
                        sbHTML.Dispose();
                    }
                }
            }
            return(string.IsNullOrEmpty(result) ? null : result);
        }
Esempio n. 4
0
        private string ReadProperties(uint serial, out string htmltext)
        {
            _sb.Clear();
            _sbHTML.Clear();

            bool hasStartColor = false;

            if (SerialHelper.IsValid(serial) &&
                World.OPL.TryGetNameAndData(serial, out string name, out string data))
            {
                if (!string.IsNullOrEmpty(name))
                {
                    if (SerialHelper.IsItem(serial))
                    {
                        _sbHTML.Append("<basefont color=\"yellow\">");
                        hasStartColor = true;
                    }
                    else
                    {
                        Mobile mob = World.Mobiles.Get(serial);

                        if (mob != null)
                        {
                            _sbHTML.Append(Notoriety.GetHTMLHue(mob.NotorietyFlag));
                            hasStartColor = true;
                        }
                    }

                    _sb.Append(name);
                    _sbHTML.Append(name);

                    if (hasStartColor)
                    {
                        _sbHTML.Append("<basefont color=\"#FFFFFFFF\">");
                    }
                }


                if (!string.IsNullOrEmpty(data))
                {
                    string s = $"\n{data}";
                    _sb.Append(s);
                    _sbHTML.Append(s);
                }
            }


            htmltext = _sbHTML.ToString();
            string result = _sb.ToString();

            return(string.IsNullOrEmpty(result) ? null : result);
        }
Esempio n. 5
0
 public void MergeHeldItem(Entity container)
 {
     if (ItemHold.Enabled && ItemHold.Serial != container)
     {
         if (SerialHelper.IsMobile(container.Serial))
         {
             GameActions.DropItem(ItemHold.Serial, 0xFFFF, 0xFFFF, 0, container.Serial);
         }
         else if (SerialHelper.IsItem(container.Serial))
         {
             GameActions.DropItem(ItemHold.Serial, container.X, container.Y, container.Z, container.Serial);
         }
     }
 }
Esempio n. 6
0
        public override void Destroy()
        {
            if (IsDestroyed)
            {
                return;
            }
            if (SerialHelper.IsItem(Serial))
            {
                UIManager.GetGump <Gump>(Serial)?.Dispose();
            }
            base.Destroy();

            //UIManager.GetGump<Gump>(Serial)?.Dispose();
            //_pool.Enqueue(this);
        }
Esempio n. 7
0
        protected override void OnMouseUp(int x, int y, MouseButtonType button)
        {
            base.OnMouseUp(x, y, button);

            if (button == MouseButtonType.Left)
            {
                GameScene gs = Client.Game.GetScene <GameScene>();
                if (gs == null)
                {
                    return;
                }

                if (Item == null || Item.IsDestroyed)
                {
                    Dispose();
                }

                if (IsDisposed)
                {
                    return;
                }

                if (TargetManager.IsTargeting)
                {
                    _clickedCanDrag = false;

                    if (Mouse.IsDragging && CanPickup())
                    {
                        if (!ItemHold.Enabled || !gs.IsMouseOverUI)
                        {
                            return;
                        }

                        SelectedObject.Object = Item;

                        if (Item.ItemData.IsContainer)
                        {
                            gs.DropHeldItemToContainer(Item);
                        }
                        else if (ItemHold.Graphic == Item.Graphic && ItemHold.IsStackable)
                        {
                            gs.MergeHeldItem(Item);
                        }
                        else
                        {
                            if (SerialHelper.IsItem(Item.Container))
                            {
                                gs.DropHeldItemToContainer(World.Items.Get(Item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY));
                            }
                        }

                        return;
                    }

                    switch (TargetManager.TargetingState)
                    {
                    case CursorTarget.Position:
                    case CursorTarget.Object:
                    case CursorTarget.Grab:
                    case CursorTarget.SetGrabBag:
                        SelectedObject.Object = Item;


                        if (Item != null)
                        {
                            TargetManager.Target(Item);
                            Mouse.LastLeftButtonClickTime = 0;
                        }

                        break;

                    case CursorTarget.SetTargetClientSide:
                        SelectedObject.Object = Item;

                        if (Item != null)
                        {
                            TargetManager.Target(Item);
                            Mouse.LastLeftButtonClickTime = 0;
                            UIManager.Add(new InspectorGump(Item));
                        }

                        break;

                    case CursorTarget.HueCommandTarget:
                        SelectedObject.Object = Item;

                        if (Item != null)
                        {
                            CommandManager.OnHueTarget(Item);
                        }

                        break;
                    }
                }
                else
                {
                    if (!ItemHold.Enabled || !gs.IsMouseOverUI)
                    {
                        //if (_clickedCanDrag)
                        //{
                        //    _clickedCanDrag = false;
                        //    _sendClickIfNotDClick = true;
                        //    _sClickTime = Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK;
                        //}
                        if (!DelayedObjectClickManager.IsEnabled)
                        {
                            DelayedObjectClickManager.Set(Item.Serial, Mouse.Position.X, Mouse.Position.Y, Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK);
                        }
                    }
                    else
                    {
                        SelectedObject.Object = Item;

                        if (Item.ItemData.IsContainer)
                        {
                            gs.DropHeldItemToContainer(Item);
                        }
                        else if (ItemHold.Graphic == Item.Graphic && ItemHold.IsStackable)
                        {
                            gs.MergeHeldItem(Item);
                        }
                        else
                        {
                            if (SerialHelper.IsItem(Item.Container))
                            {
                                gs.DropHeldItemToContainer(World.Items.Get(Item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY));
                            }
                        }
                    }
                }

                _clickedCanDrag = false;
            }
        }
Esempio n. 8
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid:
                    return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:

                    if (entity != World.Player)
                    {
                        LastTargetInfo.SetEntity(serial);
                    }

                    if (SerialHelper.IsMobile(serial) && serial != World.Player &&
                        (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally))
                    {
                        Mobile mobile = entity as Mobile;

                        if (mobile != null)
                        {
                            bool showCriminalQuery = false;

                            if (TargetingType == TargetType.Harmful && ProfileManager.Current.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent)
                            {
                                showCriminalQuery = true;
                            }
                            else if (TargetingType == TargetType.Beneficial && ProfileManager.Current.EnabledBeneficialCriminalActionQuery &&
                                     (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray))
                            {
                                showCriminalQuery = true;
                            }

                            if (showCriminalQuery)
                            {
                                QuestionGump messageBox = new QuestionGump("This may flag\nyou criminal!",
                                                                           s =>
                                {
                                    if (s)
                                    {
                                        NetClient.Socket.Send(new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType));
                                        ClearTargetingWithoutTargetCancelPacket();
                                    }
                                });

                                UIManager.Add(messageBox);

                                return;
                            }
                        }
                    }

                    if (TargetingState != CursorTarget.SetTargetClientSide)
                    {
                        var packet = new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargetingType);

                        for (int i = 0; i < _lastDataBuffer.Length; i++)
                        {
                            _lastDataBuffer[i] = packet[i];
                        }

                        NetClient.Socket.Send(packet);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;
                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.Current.GrabBagSerial = serial;
                        GameActions.Print($"Grab Bag set: {serial}");
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;
                }
            }
        }
Esempio n. 9
0
            public ShopItem
            (
                uint serial,
                ushort graphic,
                ushort hue,
                int count,
                uint price,
                string name
            )
            {
                LocalSerial = serial;
                Graphic     = graphic;
                Hue         = hue;
                Price       = price;
                Name        = name;

                Add
                (
                    new ResizePicLine(0x39)
                {
                    X     = 10,
                    Width = 190
                }
                );

                int offY = 15;

                string itemName = StringHelper.CapitalizeAllWords(Name);

                TextureControl control;

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort             hue2      = Hue;
                    AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1);

                    Add
                    (
                        control = new TextureControl
                    {
                        Texture          = direction != null ? direction.FrameCount != 0 ? direction.Frames[0] : null : null,
                        X                = 5,
                        Y                = 5 + offY,
                        AcceptMouseInput = false,
                        Hue              = Hue == 0 ? hue2 : Hue,
                        IsPartial        = TileDataLoader.Instance.StaticData[Graphic].IsPartialHue
                    }
                    );

                    if (control.Texture != null)
                    {
                        control.Width  = control.Texture.Width;
                        control.Height = control.Texture.Height;
                    }
                    else
                    {
                        control.Width  = 35;
                        control.Height = 35;
                    }

                    if (control.Width > 35)
                    {
                        control.Width = 35;
                    }

                    if (control.Height > 35)
                    {
                        control.Height = 35;
                    }
                }
                else if (SerialHelper.IsItem(LocalSerial))
                {
                    ArtTexture texture = ArtLoader.Instance.GetTexture(Graphic);

                    Add
                    (
                        control = new TextureControl
                    {
                        Texture          = texture,
                        X                = 10 - texture?.ImageRectangle.X ?? 0,
                        Y                = 5 + offY + texture?.ImageRectangle.Y ?? 0,
                        Width            = texture?.ImageRectangle.Width ?? 0,
                        Height           = texture?.ImageRectangle.Height ?? 0,
                        AcceptMouseInput = false,
                        ScaleTexture     = false,
                        Hue              = Hue,
                        IsPartial        = TileDataLoader.Instance.StaticData[Graphic].IsPartialHue
                    }
                    );
                }
                else
                {
                    return;
                }

                string subname = string.Format(ResGumps.Item0Price1, itemName, Price);

                Add
                (
                    _name = new Label(subname, true, 0x219, 110, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_LEFT, true)
                {
                    X = 55,
                    Y = offY
                }
                );

                int height = Math.Max(_name.Height, control.Height) + 10;

                Add
                (
                    _amountLabel = new Label
                                       (count.ToString(), true, 0x0219, 35, 1, FontStyle.None, TEXT_ALIGN_TYPE.TS_RIGHT)
                {
                    X = 168,
                    Y = offY + (height >> 2)
                }
                );

                Width  = 220;
                Height = Math.Max(50, height);

                WantUpdateSize = false;

                if (World.ClientFeatures.TooltipsEnabled)
                {
                    SetTooltip(LocalSerial);
                }

                Amount = count;
            }
Esempio n. 10
0
        protected override void OnMouseUp(int x, int y, MouseButtonType button)
        {
            if (button == MouseButtonType.Left)
            {
                if (UIManager.MouseOverControl?.RootParent == RootParent)
                {
                    GameScene gs = Client.Game.GetScene <GameScene>();
                    if (gs != null)
                    {
                        Item item = World.Items.Get(LocalSerial);
                        if (item != null)
                        {
                            if (TargetManager.IsTargeting)
                            {
                                if (Mouse.IsDragging && CanPickup())
                                {
                                    if (ItemHold.Enabled && gs.IsMouseOverUI)
                                    {
                                        if (item.ItemData.IsContainer)
                                        {
                                            gs.DropHeldItemToContainer(item);
                                        }
                                        else if (ItemHold.Graphic == item.Graphic && ItemHold.IsStackable)
                                        {
                                            gs.MergeHeldItem(item);
                                        }
                                        else
                                        {
                                            if (SerialHelper.IsItem(item.Container))
                                            {
                                                gs.DropHeldItemToContainer(World.Items.Get(item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY));
                                            }
                                        }

                                        Mouse.CancelDoubleClick = true;

                                        return;
                                    }
                                }

                                switch (TargetManager.TargetingState)
                                {
                                case CursorTarget.Position:
                                case CursorTarget.Object:
                                case CursorTarget.Grab:
                                case CursorTarget.SetGrabBag:

                                    if (item != null)
                                    {
                                        var p = RootParent;

                                        if (p != null)
                                        {
                                            DelayedObjectClickManager.X = Mouse.Position.X - p.ScreenCoordinateX;
                                            DelayedObjectClickManager.Y = Mouse.Position.Y - p.ScreenCoordinateY;
                                        }

                                        TargetManager.Target(item);
                                        Mouse.LastLeftButtonClickTime = 0;
                                    }

                                    break;

                                case CursorTarget.SetTargetClientSide:

                                    if (item != null)
                                    {
                                        TargetManager.Target(item);
                                        Mouse.LastLeftButtonClickTime = 0;
                                        UIManager.Add(new InspectorGump(item));
                                    }

                                    break;

                                case CursorTarget.HueCommandTarget:

                                    if (item != null)
                                    {
                                        CommandManager.OnHueTarget(item);
                                    }

                                    break;
                                }

                                return;
                            }
                            else
                            {
                                Point offset = Mouse.LDroppedOffset;

                                if ((Math.Abs(offset.X) < Constants.MIN_PICKUP_DRAG_DISTANCE_PIXELS &&
                                     Math.Abs(offset.Y) < Constants.MIN_PICKUP_DRAG_DISTANCE_PIXELS) &&
                                    (!ItemHold.Enabled || !gs.IsMouseOverUI))
                                {
                                    if (!DelayedObjectClickManager.IsEnabled)
                                    {
                                        var p = RootParent;

                                        if (p != null)
                                        {
                                            var off = Mouse.LDroppedOffset;
                                            DelayedObjectClickManager.Set(LocalSerial,
                                                                          (Mouse.Position.X - off.X) - p.ScreenCoordinateX,
                                                                          (Mouse.Position.Y - off.Y) - p.ScreenCoordinateY,
                                                                          Time.Ticks + Mouse.MOUSE_DELAY_DOUBLE_CLICK);
                                        }

                                        return;
                                    }
                                }
                                else if (item != null)
                                {
                                    if (item.ItemData.IsContainer)
                                    {
                                        gs.DropHeldItemToContainer(item);
                                    }
                                    else if (ItemHold.Graphic == item.Graphic && ItemHold.IsStackable)
                                    {
                                        gs.MergeHeldItem(item);
                                    }
                                    else if (SerialHelper.IsItem(item.Container))
                                    {
                                        gs.DropHeldItemToContainer(World.Items.Get(item.Container), X + (Mouse.Position.X - ScreenCoordinateX), Y + (Mouse.Position.Y - ScreenCoordinateY));
                                    }
                                    else
                                    {
                                        base.OnMouseUp(x, y, button);
                                    }

                                    Mouse.CancelDoubleClick = true;

                                    return;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                base.OnMouseUp(x, y, button);
            }
        }
Esempio n. 11
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid: return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:

                    if (entity != World.Player)
                    {
                        LastTargetInfo.SetEntity(serial);
                    }

                    if (SerialHelper.IsMobile(serial) && serial != World.Player && (World.Player.NotorietyFlag == NotorietyFlag.Innocent || World.Player.NotorietyFlag == NotorietyFlag.Ally))
                    {
                        Mobile mobile = entity as Mobile;

                        if (mobile != null)
                        {
                            bool showCriminalQuery = false;

                            if (TargetingType == TargetType.Harmful && ProfileManager.CurrentProfile.EnabledCriminalActionQuery && mobile.NotorietyFlag == NotorietyFlag.Innocent)
                            {
                                showCriminalQuery = true;
                            }
                            else if (TargetingType == TargetType.Beneficial && ProfileManager.CurrentProfile.EnabledBeneficialCriminalActionQuery && (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Murderer || mobile.NotorietyFlag == NotorietyFlag.Gray))
                            {
                                showCriminalQuery = true;
                            }

                            if (showCriminalQuery && UIManager.GetGump <QuestionGump>() == null)
                            {
                                QuestionGump messageBox = new QuestionGump
                                                          (
                                    "This may flag\nyou criminal!",
                                    s =>
                                {
                                    if (s)
                                    {
                                        NetClient.Socket.Send_TargetObject(entity,
                                                                           entity.Graphic,
                                                                           entity.X,
                                                                           entity.Y,
                                                                           entity.Z,
                                                                           _targetCursorId,
                                                                           (byte)TargetingType);

                                        ClearTargetingWithoutTargetCancelPacket();

                                        if (LastTargetInfo.Serial != serial)
                                        {
                                            GameActions.RequestMobileStatus(serial);
                                        }
                                    }
                                }
                                                          );

                                UIManager.Add(messageBox);

                                return;
                            }
                        }
                    }

                    if (TargetingState != CursorTarget.SetTargetClientSide)
                    {
                        _lastDataBuffer[0] = 0x6C;

                        _lastDataBuffer[1] = 0x00;

                        _lastDataBuffer[2] = (byte)(_targetCursorId >> 24);
                        _lastDataBuffer[3] = (byte)(_targetCursorId >> 16);
                        _lastDataBuffer[4] = (byte)(_targetCursorId >> 8);
                        _lastDataBuffer[5] = (byte)_targetCursorId;

                        _lastDataBuffer[6] = (byte)TargetingType;

                        _lastDataBuffer[7]  = (byte)(entity.Serial >> 24);
                        _lastDataBuffer[8]  = (byte)(entity.Serial >> 16);
                        _lastDataBuffer[9]  = (byte)(entity.Serial >> 8);
                        _lastDataBuffer[10] = (byte)entity.Serial;

                        _lastDataBuffer[11] = (byte)(entity.X >> 8);
                        _lastDataBuffer[12] = (byte)entity.X;

                        _lastDataBuffer[13] = (byte)(entity.Y >> 8);
                        _lastDataBuffer[14] = (byte)entity.Y;

                        _lastDataBuffer[15] = (byte)(entity.Z >> 8);
                        _lastDataBuffer[16] = (byte)entity.Z;

                        _lastDataBuffer[17] = (byte)(entity.Graphic >> 8);
                        _lastDataBuffer[18] = (byte)entity.Graphic;


                        NetClient.Socket.Send_TargetObject(entity,
                                                           entity.Graphic,
                                                           entity.X,
                                                           entity.Y,
                                                           entity.Z,
                                                           _targetCursorId,
                                                           (byte)TargetingType);

                        if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial != serial)
                        {
                            GameActions.RequestMobileStatus(serial);
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;

                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.CurrentProfile.GrabBagSerial = serial;
                        GameActions.Print(string.Format(ResGeneral.GrabBagSet0, serial));
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.IgnorePlayerTarget:
                    if (SelectedObject.Object is Entity pmEntity)
                    {
                        IgnoreManager.AddIgnoredTarget(pmEntity);
                    }
                    CancelTarget();
                    return;
                }
            }
        }
Esempio n. 12
0
        private void SaveGumps(string path)
        {
            string gumpsXmlPath = Path.Combine(path, "gumps.xml");

            using (XmlTextWriter xml = new XmlTextWriter(gumpsXmlPath, Encoding.UTF8)
            {
                Formatting = Formatting.Indented,
                IndentChar = '\t',
                Indentation = 1
            })
            {
                xml.WriteStartDocument(true);
                xml.WriteStartElement("gumps");

                UIManager.AnchorManager.Save(xml);

                LinkedList <Gump> gumps = new LinkedList <Gump>();

                foreach (Gump gump in UIManager.Gumps)
                {
                    if (!gump.IsDisposed && gump.CanBeSaved && !(gump is AnchorableGump anchored && UIManager.AnchorManager[anchored] != null))
                    {
                        gumps.AddLast(gump);
                    }
                }


                LinkedListNode <Gump> first = gumps.First;

                while (first != null)
                {
                    Gump gump = first.Value;

                    if (gump.LocalSerial != 0)
                    {
                        Item item = World.Items.Get(gump.LocalSerial);

                        if (item != null && !item.IsDestroyed && item.Opened)
                        {
                            while (SerialHelper.IsItem(item.Container))
                            {
                                item = World.Items.Get(item.Container);
                            }

                            SaveItemsGumpRecursive(item, xml, gumps);

                            if (first.List != null)
                            {
                                gumps.Remove(first);
                            }

                            first = gumps.First;

                            continue;
                        }
                    }

                    xml.WriteStartElement("gump");
                    gump.Save(xml);
                    xml.WriteEndElement();

                    if (first.List != null)
                    {
                        gumps.Remove(first);
                    }

                    first = gumps.First;
                }

                xml.WriteEndElement();
                xml.WriteEndDocument();
            }


            SkillsGroupManager.Save();
        }
Esempio n. 13
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                Vector3 hueVector;

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort             hue2      = Hue;
                    AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1);

                    if (direction != null && direction.SpriteInfos != null && direction.FrameCount != 0)
                    {
                        hueVector = ShaderHueTranslator.GetHueVector(hue2, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f);

                        batcher.Draw
                        (
                            direction.SpriteInfos[0].Texture,
                            new Rectangle
                            (
                                x - 3,
                                y + 5 + 15,
                                Math.Min(direction.SpriteInfos[0].UV.Width, 45),
                                Math.Min(direction.SpriteInfos[0].UV.Height, 45)
                            ),
                            direction.SpriteInfos[0].UV,
                            hueVector
                        );
                    }
                }
                else if (SerialHelper.IsItem(LocalSerial))
                {
                    var texture = ArtLoader.Instance.GetStaticTexture(Graphic, out var bounds);

                    hueVector = ShaderHueTranslator.GetHueVector(Hue, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f);

                    var rect = ArtLoader.Instance.GetRealArtBounds(Graphic);

                    const int RECT_SIZE = 50;

                    Point originalSize = new Point(RECT_SIZE, Height);
                    Point point        = new Point();

                    if (rect.Width < RECT_SIZE)
                    {
                        originalSize.X = rect.Width;
                        point.X        = (RECT_SIZE >> 1) - (originalSize.X >> 1);
                    }

                    if (rect.Height < Height)
                    {
                        originalSize.Y = rect.Height;
                        point.Y        = (Height >> 1) - (originalSize.Y >> 1);
                    }

                    batcher.Draw
                    (
                        texture,
                        new Rectangle
                        (
                            x + point.X - 5,
                            y + point.Y + 10,
                            originalSize.X,
                            originalSize.Y
                        ),
                        new Rectangle
                        (
                            bounds.X + rect.X,
                            bounds.Y + rect.Y,
                            rect.Width,
                            rect.Height
                        ),
                        hueVector
                    );
                }

                return(base.Draw(batcher, x, y));
            }
Esempio n. 14
0
            public ShopItem
            (
                uint serial,
                ushort graphic,
                ushort hue,
                int count,
                uint price,
                string name
            )
            {
                LocalSerial = serial;
                Graphic     = graphic;
                Hue         = hue;
                Price       = price;
                Name        = name;

                ResizePicLine line = new ResizePicLine(0x39)
                {
                    X     = 10,
                    Width = 190
                };

                Add(line);

                int offY = 15;

                string itemName = StringHelper.CapitalizeAllWords(Name);

                if (!SerialHelper.IsValid(serial))
                {
                    return;
                }


                string subname = string.Format(ResGumps.Item0Price1, itemName, Price);

                Add
                (
                    _name = new Label
                            (
                        subname,
                        true,
                        0x219,
                        110,
                        1,
                        FontStyle.None,
                        TEXT_ALIGN_TYPE.TS_LEFT,
                        true
                            )
                {
                    X = 55,
                    Y = offY
                }
                );

                int height = Math.Max(_name.Height, 35) + 10;

                if (SerialHelper.IsItem(serial))
                {
                    height = Math.Max(TileDataLoader.Instance.StaticData[graphic].Height, height);
                }

                Add
                (
                    _amountLabel = new Label
                                   (
                        count.ToString(),
                        true,
                        0x0219,
                        35,
                        1,
                        FontStyle.None,
                        TEXT_ALIGN_TYPE.TS_RIGHT
                                   )
                {
                    X = 168,
                    Y = offY + (height >> 2)
                }
                );

                Width  = 220;
                Height = Math.Max(50, height) + line.Height;

                WantUpdateSize = false;

                if (World.ClientFeatures.TooltipsEnabled)
                {
                    SetTooltip(LocalSerial);
                }

                Amount = count;
            }
Esempio n. 15
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid: return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:

                    if (entity != World.Player)
                    {
                        LastTargetInfo.SetEntity(serial);
                    }

                    if (SerialHelper.IsMobile
                            (serial) && serial != World.Player &&
                        (World.Player.NotorietyFlag == NotorietyFlag.Innocent ||
                         World.Player.NotorietyFlag == NotorietyFlag.Ally))
                    {
                        Mobile mobile = entity as Mobile;

                        if (mobile != null)
                        {
                            bool showCriminalQuery = false;

                            if (TargetingType == TargetType.Harmful &&
                                ProfileManager.CurrentProfile.EnabledCriminalActionQuery &&
                                mobile.NotorietyFlag == NotorietyFlag.Innocent)
                            {
                                showCriminalQuery = true;
                            }
                            else if (TargetingType == TargetType.Beneficial &&
                                     ProfileManager.CurrentProfile.EnabledBeneficialCriminalActionQuery &&
                                     (mobile.NotorietyFlag == NotorietyFlag.Criminal ||
                                      mobile.NotorietyFlag == NotorietyFlag.Murderer ||
                                      mobile.NotorietyFlag == NotorietyFlag.Gray))
                            {
                                showCriminalQuery = true;
                            }

                            if (showCriminalQuery && UIManager.GetGump <QuestionGump>() == null)
                            {
                                QuestionGump messageBox = new QuestionGump
                                                          (
                                    "This may flag\nyou criminal!", s =>
                                {
                                    if (s)
                                    {
                                        NetClient.Socket.Send
                                        (
                                            new PTargetObject
                                            (
                                                entity, entity.Graphic, entity.X, entity.Y, entity.Z,
                                                _targetCursorId, (byte)TargetingType
                                            )
                                        );

                                        ClearTargetingWithoutTargetCancelPacket();

                                        if (LastTargetInfo.Serial != serial)
                                        {
                                            GameActions.RequestMobileStatus(serial);
                                        }
                                    }
                                }
                                                          );

                                UIManager.Add(messageBox);

                                return;
                            }
                        }
                    }

                    if (TargetingState != CursorTarget.SetTargetClientSide)
                    {
                        PTargetObject packet = new PTargetObject
                                               (
                            entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId,
                            (byte)TargetingType
                                               );

                        for (int i = 0; i < _lastDataBuffer.Length; i++)
                        {
                            _lastDataBuffer[i] = packet[i];
                        }

                        NetClient.Socket.Send(packet);

                        if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial != serial)
                        {
                            GameActions.RequestMobileStatus(serial);
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;

                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.CurrentProfile.GrabBagSerial = serial;
                        GameActions.Print(string.Format(ResGeneral.GrabBagSet0, serial));
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                // ## BEGIN - END ## //
                case CursorTarget.SetCustomSerial:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.CurrentProfile.CustomSerial = serial;
                        GameActions.Print($"Custom UOClassicEquipment Item set: {serial}", 88);
                    }
                    else if ((TargetingType == TargetType.Neutral && SerialHelper.IsMobile(serial)))
                    {
                        Mobile mobile = entity as Mobile;

                        if ((!World.Player.IsDead && !mobile.IsDead) && serial != World.Player)
                        {
                            ProfileManager.CurrentProfile.Mimic_PlayerSerial = entity;                          //entity.serial
                            GameActions.Print($"Mimic Player Serial Set: {entity.Name} : {entity.Serial}", 88); //entity.serial
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;
                    // ## BEGIN - END ## //
                }
            }
        }
Esempio n. 16
0
        public static void Target(uint serial)
        {
            if (!IsTargeting)
            {
                return;
            }

            Entity entity = World.InGame ? World.Get(serial) : null;

            if (entity != null)
            {
                switch (TargetingState)
                {
                case CursorTarget.Invalid:
                    return;

                case CursorTarget.MultiPlacement:
                case CursorTarget.Position:
                case CursorTarget.Object:
                case CursorTarget.HueCommandTarget:
                case CursorTarget.SetTargetClientSide:
                    Mobile m = World.Mobiles.Get(entity);
                    if (entity != World.Player)
                    {
                        UIManager.RemoveTargetLineGump(LastAttack);
                        UIManager.RemoveTargetLineGump(LastTarget);
                        LastTarget      = entity.Serial;
                        LastTarget_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }
                    if (m != null && m != World.Player)
                    {
                        switch (m.NotorietyFlag)
                        {
                        case NotorietyFlag.Ally:
                        case NotorietyFlag.Innocent:
                            LastBeneficialTarget      = entity.Serial;
                            LastBeneficialTarget_name = entity.Name;
                            TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                            if (tm != null)
                            {
                                tm.SetName();
                            }
                            break;

                        case NotorietyFlag.Enemy:
                        case NotorietyFlag.Gray:
                        case NotorietyFlag.Murderer:
                        case NotorietyFlag.Unknown:
                        case NotorietyFlag.Criminal:

                            LastHarmfulTarget      = entity.Serial;
                            LastHarmfulTarget_name = entity.Name;
                            tm = UIManager.GetGump <TargetMenuGump>();
                            if (tm != null)
                            {
                                tm.SetName();
                            }
                            break;
                        }
                    }
                    if (TargeringType == TargetType.Harmful && SerialHelper.IsMobile(serial) &&
                        ProfileManager.Current.EnabledCriminalActionQuery)
                    {
                        Mobile mobile = entity as Mobile;

                        if (((World.Player.NotorietyFlag == NotorietyFlag.Innocent ||
                              World.Player.NotorietyFlag == NotorietyFlag.Ally) && mobile.NotorietyFlag == NotorietyFlag.Innocent && serial != World.Player))
                        {
                            QuestionGump messageBox = new QuestionGump(LanguageManager.Current.UI_Public_Criminal,
                                                                       s =>
                            {
                                if (s)
                                {
                                    NetClient.Socket.Send(new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargeringType));
                                    ClearTargetingWithoutTargetCancelPacket();
                                }
                            });

                            UIManager.Add(messageBox);

                            return;
                        }
                    }

                    var packet = new PTargetObject(entity, entity.Graphic, entity.X, entity.Y, entity.Z, _targetCursorId, (byte)TargeringType);

                    for (int i = 0; i < _lastDataBuffer.Length; i++)
                    {
                        _lastDataBuffer[i] = packet[i];
                    }

                    NetClient.Socket.Send(packet);
                    ClearTargetingWithoutTargetCancelPacket();

                    Mouse.CancelDoubleClick = true;
                    break;

                case CursorTarget.Grab:

                    if (SerialHelper.IsItem(serial))
                    {
                        GameActions.GrabItem(serial, ((Item)entity).Amount);
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.SetGrabBag:

                    if (SerialHelper.IsItem(serial))
                    {
                        ProfileManager.Current.GrabBagSerial = serial;
                        GameActions.Print(LanguageManager.Current.UI_GrabBagSet + $"{ serial}");
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.AddToLootlist:
                    Item item = World.Items.Get(serial);
                    if (SerialHelper.IsItem(serial))
                    {
                        ushort[] obj = new ushort[2];
                        obj[0] = item.Graphic;
                        obj[1] = item.Hue;

                        if (ProfileManager.Current.LootList == null)
                        {
                            ProfileManager.Current.LootList = new List <ushort[]>();
                        }
                        bool contain = false;
                        foreach (ushort[] i in ProfileManager.Current.LootList)
                        {
                            if (obj[0] == i[0] && obj[1] == i[1])
                            {
                                contain = true;
                                break;
                            }
                        }
                        if (!contain)
                        {
                            ProfileManager.Current.LootList.Add(obj);
                            UIManager.GetGump <LootListGump>()?.Dispose();
                            UIManager.Add(new LootListGump());
                        }
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.AddToSelllist:

                    if (SerialHelper.IsItem(serial))
                    {
                        item = World.GetOrCreateItem(serial);
                        ushort[] obj = new ushort[3];
                        obj[0] = item.Graphic;
                        obj[1] = item.Hue;
                        obj[2] = (ushort)ProfileManager.Current.AutoBuyAmount;

                        if (ProfileManager.Current.SellList == null)
                        {
                            ProfileManager.Current.SellList = new List <ushort[]>();
                        }
                        bool contain = false;
                        foreach (ushort[] i in ProfileManager.Current.SellList)
                        {
                            if (obj[0] == i[0] && obj[1] == i[1])
                            {
                                contain = true;
                                break;
                            }
                        }
                        if (!contain)
                        {
                            ProfileManager.Current.SellList.Add(obj);
                            UIManager.GetGump <SellListGump>()?.Dispose();
                            UIManager.Add(new SellListGump(false));
                        }
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.AddToBuylist:

                    if (SerialHelper.IsItem(serial))
                    {
                        item = World.GetOrCreateItem(serial);
                        ushort[] obj = new ushort[3];
                        obj[0] = item.Graphic;
                        obj[1] = item.Hue;
                        obj[2] = (ushort)ProfileManager.Current.AutoBuyAmount;

                        if (ProfileManager.Current.BuyList == null)
                        {
                            ProfileManager.Current.BuyList = new List <ushort[]>();
                        }
                        bool contain = false;
                        foreach (ushort[] i in ProfileManager.Current.BuyList)
                        {
                            if (obj[0] == i[0] && obj[1] == i[1])
                            {
                                contain = true;
                                break;
                            }
                        }
                        if (!contain)
                        {
                            ProfileManager.Current.BuyList.Add(obj);
                            UIManager.GetGump <SellListGump>()?.Dispose();
                            UIManager.Add(new SellListGump(true));
                        }
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.Target_1:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_1      = m;
                        Target_1_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_2:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_2      = m;
                        Target_2_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_3:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_3      = m;
                        Target_3_name = entity.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_4:
                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_4      = m;
                        Target_4_name = m.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Target_5:

                    if (SerialHelper.IsMobile(serial))
                    {
                        m             = World.GetOrCreateMobile(serial);
                        Target_5      = m;
                        Target_5_name = m.Name;
                        TargetMenuGump tm = UIManager.GetGump <TargetMenuGump>();
                        if (tm != null)
                        {
                            tm.SetName();
                        }
                    }

                    ClearTargetingWithoutTargetCancelPacket();

                    return;

                case CursorTarget.Clear:
                    if (SerialHelper.IsItem(serial))
                    {
                        PlayerMobile.MoveObject = true;
                        PlayerMobile.MoveType   = 0;
                        PlayerMobile.MoveBag    = World.GetOrCreateItem(serial);
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;

                case CursorTarget.Supply:
                    if (SerialHelper.IsItem(serial))
                    {
                        PlayerMobile.MoveObject = true;
                        PlayerMobile.MoveType   = 1;
                        PlayerMobile.MoveBag    = World.GetOrCreateItem(serial);
                    }
                    ClearTargetingWithoutTargetCancelPacket();
                    return;
//                    case CursorTarget.Object_1:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_1 = item.Graphic;
////                            Object_1_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;

//                    case CursorTarget.Object_2:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_2 = item.Graphic;
//                            //Object_2_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
//                    case CursorTarget.Object_3:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_3 = item.Graphic;
//                            //Object_3_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
//                    case CursorTarget.Object_4:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_4 = item.Graphic;
//                            //Object_4_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
//                    case CursorTarget.Object_5:
//                        if (SerialHelper.IsItem(serial))
//                        {
//                            item = World.GetOrCreateItem(serial);
//                            Object_5 = item.Graphic;
//                            //Object_5_name = item.Name;
//                            TargetMenuGump tm = UIManager.GetGump<TargetMenuGump>();
//                            if (tm != null)
//                            {
//                                tm.SetName();
//                            }
//                        }
//                        ClearTargetingWithoutTargetCancelPacket();
//                        return;
                }
            }
        }