Example #1
0
        private void BuildGump()
        {
            CanMove              = true;
            CanBeSaved           = true;
            LocalSerial          = _item.Serial;
            _isCorspeContainer   = _gumpID == 0x0009;
            _item.Items.Added   += ItemsOnAdded;
            _item.Items.Removed += ItemsOnRemoved;

            _data = ContainerManager.Get(_gumpID);
            Graphic g = _data.Graphic;

            Add(new GumpPicContainer(0, 0, g, 0, _item));
            if (_isCorspeContainer)
            {
                Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0));
            }

            ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial);

            if (gg == null)
            {
                if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && _item.Serial == World.Player.Equipment[(int)Layer.Backpack])
                {
                    Location = location;
                }
                else
                {
                    ContainerManager.CalculateContainerPosition(g);
                    X = ContainerManager.X;
                    Y = ContainerManager.Y;
                }
            }
            else
            {
                X = gg.X;
                Y = gg.Y;
            }


            if (_data.OpenSound != 0)
            {
                Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound);
            }
        }
Example #2
0
 private void SetPositionNearGameObject(Graphic g, Item item)
 {
     if (World.Player.Equipment[(int)Layer.Bank] != null && item.Serial == World.Player.Equipment[(int)Layer.Bank])
     {
         // open bank near player
         X = World.Player.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40;
         Y = World.Player.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1);
     }
     else if (item.OnGround)
     {
         // item is in world
         X = item.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40;
         Y = item.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1);
     }
     else if (item.Container.IsMobile)
     {
         // pack animal, snooped player, npc vendor
         Mobile mobile = World.Mobiles.Get(item.Container);
         if (mobile != null)
         {
             X = mobile.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40;
             Y = mobile.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1);
         }
     }
     else
     {
         // in a container, open near the container
         ContainerGump parentContainer = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == item.Container);
         if (parentContainer != null)
         {
             X = parentContainer.X + (Width >> 1);
             Y = parentContainer.Y;
         }
         else
         {
             // I don't think we ever get here?
             ContainerManager.CalculateContainerPosition(g);
             X = ContainerManager.X;
             Y = ContainerManager.Y;
         }
     }
 }
Example #3
0
        private void BuildGump()
        {
            CanMove            = true;
            CanBeSaved         = true;
            WantUpdateSize     = false;
            _isCorspeContainer = Graphic == 0x0009;

            Item item = World.Items.Get(LocalSerial);

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

            item.Items.Added   -= ItemsOnAdded;
            item.Items.Removed -= ItemsOnRemoved;
            item.Items.Added   += ItemsOnAdded;
            item.Items.Removed += ItemsOnRemoved;

            float scale = Engine.UI.ContainerScale;

            _data = ContainerManager.Get(Graphic);
            if (_data.MinimizerArea != Rectangle.Empty && _data.IconizedGraphic != 0)
            {
                _iconizerArea = new HitBox((int)(_data.MinimizerArea.X * scale),
                                           (int)(_data.MinimizerArea.Y * scale),
                                           (int)(_data.MinimizerArea.Width * scale),
                                           (int)(_data.MinimizerArea.Height * scale));
                _iconized = new GumpPic(0, 0, _data.IconizedGraphic, 0);
            }
            Graphic g = _data.Graphic;

            GumpPicContainer container;

            Add(container = new GumpPicContainer(0, 0, g, 0, item));

            if (_isCorspeContainer)
            {
                _eyeGumpPic?.Dispose();
                Add(_eyeGumpPic = new GumpPic((int)(45 * scale), (int)(30 * scale), 0x0045, 0));

                _eyeGumpPic.Width  = (int)(_eyeGumpPic.Width * scale);
                _eyeGumpPic.Height = (int)(_eyeGumpPic.Height * scale);
            }


            Width  = container.Width = (int)(container.Width * scale);
            Height = container.Height = (int)(container.Height * scale);

            ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial);

            if (gg == null)
            {
                if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && item.Serial == World.Player.Equipment[(int)Layer.Backpack])
                {
                    Location = location;
                }
                else
                {
                    if (Engine.Profile.Current.OverrideContainerLocation)
                    {
                        switch (Engine.Profile.Current.OverrideContainerLocationSetting)
                        {
                        case 0:
                            SetPositionNearGameObject(g, item);
                            break;

                        case 1:
                            SetPositionTopRight();
                            break;

                        case 2:
                            SetPositionByLastDragged();
                            break;
                        }

                        if ((X + Width) > Engine.WindowWidth)
                        {
                            X -= Width;
                        }

                        if ((Y + Height) > Engine.WindowHeight)
                        {
                            Y -= Height;
                        }
                    }
                    else
                    {
                        ContainerManager.CalculateContainerPosition(g);
                        X = ContainerManager.X;
                        Y = ContainerManager.Y;
                    }
                }
            }
            else
            {
                X = gg.X;
                Y = gg.Y;
            }


            if (_data.OpenSound != 0)
            {
                Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound);
            }
        }
Example #4
0
        public override void OnButtonClick(int buttonID)
        {
            switch ((Buttons)buttonID)
            {
            case Buttons.Map:
                MiniMapGump miniMapGump = UIManager.GetGump <MiniMapGump>();

                if (miniMapGump == null)
                {
                    UIManager.Add(new MiniMapGump());
                }
                else
                {
                    miniMapGump.SetInScreen();
                    miniMapGump.BringOnTop();
                }

                break;

            case Buttons.Paperdoll:
                PaperDollGump paperdollGump = UIManager.GetGump <PaperDollGump>(World.Player);

                if (paperdollGump == null)
                {
                    GameActions.OpenPaperdoll(World.Player);
                }
                else
                {
                    paperdollGump.SetInScreen();
                    paperdollGump.BringOnTop();
                }

                break;

            case Buttons.Inventory:
                Item backpack = World.Player.Equipment[(int)Layer.Backpack];

                ContainerGump backpackGump = UIManager.GetGump <ContainerGump>(backpack);

                if (backpackGump == null)
                {
                    GameActions.DoubleClick(backpack);
                }
                else
                {
                    backpackGump.SetInScreen();
                    backpackGump.BringOnTop();
                }

                break;

            case Buttons.Journal:
                JournalGump journalGump = UIManager.GetGump <JournalGump>();

                if (journalGump == null)
                {
                    UIManager.Add(new JournalGump
                    {
                        X = 64, Y = 64
                    });
                }
                else
                {
                    journalGump.SetInScreen();
                    journalGump.BringOnTop();
                }

                break;

            case Buttons.Chat:
                if (UOChatManager.ChatIsEnabled)
                {
                    UOChatGump chatGump = UIManager.GetGump <UOChatGump>();

                    if (chatGump == null)
                    {
                        UIManager.Add(new UOChatGump());
                    }
                    else
                    {
                        chatGump.SetInScreen();
                        chatGump.BringOnTop();
                    }
                }
                break;

            case Buttons.GlobalChat:
                Log.Warn("Chat button pushed! Not implemented yet!");
                GameActions.Print("GlobalChat not implemented yet.", 0x23, MessageType.System);
                break;

            case Buttons.UOStore:
                if (Client.Version >= ClientVersion.CV_706400)
                {
                    NetClient.Socket.Send(new POpenUOStore());
                }
                break;

            case Buttons.Help:
                GameActions.RequestHelp();

                break;

            case Buttons.Debug:

                DebugGump debugGump = UIManager.GetGump <DebugGump>();

                if (debugGump == null)
                {
                    debugGump = new DebugGump
                    {
                        X = ProfileManager.Current.DebugGumpPosition.X,
                        Y = ProfileManager.Current.DebugGumpPosition.Y
                    };

                    UIManager.Add(debugGump);
                }
                else
                {
                    debugGump.IsVisible = !debugGump.IsVisible;
                    debugGump.SetInScreen();
                }

                //Engine.DropFpsMinMaxValues();

                break;

            case Buttons.WorldMap:

                WorldMapGump worldMap = UIManager.GetGump <WorldMapGump>();

                if (worldMap == null || worldMap.IsDisposed)
                {
                    worldMap = new WorldMapGump();
                    UIManager.Add(worldMap);
                }
                else
                {
                    worldMap.BringOnTop();
                    worldMap.SetInScreen();
                }
                break;
            }
        }
Example #5
0
        public override void OnButtonClick(int buttonID)
        {
            switch ((Buttons)buttonID)
            {
            case Buttons.Map:
                MiniMapGump miniMapGump = UIManager.GetGump <MiniMapGump>();

                if (miniMapGump == null)
                {
                    UIManager.Add(new MiniMapGump());
                }
                else
                {
                    miniMapGump.SetInScreen();
                    miniMapGump.BringOnTop();
                }

                break;

            case Buttons.Paperdoll:
                PaperDollGump paperdollGump = UIManager.GetGump <PaperDollGump>(World.Player);

                if (paperdollGump == null)
                {
                    GameActions.OpenPaperdoll(World.Player);
                }
                else
                {
                    paperdollGump.SetInScreen();
                    paperdollGump.BringOnTop();
                }

                break;

            case Buttons.Inventory:
                Item backpack = World.Player.FindItemByLayer(Layer.Backpack);
                if (backpack == null)
                {
                    return;
                }

                ContainerGump backpackGump = UIManager.GetGump <ContainerGump>(backpack);

                if (backpackGump == null)
                {
                    GameActions.DoubleClick(backpack);
                }
                else
                {
                    backpackGump.SetInScreen();
                    backpackGump.BringOnTop();
                }

                break;

            case Buttons.Journal:
                JournalGump journalGump = UIManager.GetGump <JournalGump>();

                if (journalGump == null)
                {
                    UIManager.Add(new JournalGump
                    {
                        X = 64, Y = 64
                    });
                }
                else
                {
                    journalGump.SetInScreen();
                    journalGump.BringOnTop();
                }

                break;

            case Buttons.Chat:
                if (UOChatManager.ChatIsEnabled == CHAT_STATUS.ENABLED)
                {
                    UOChatGump chatGump = UIManager.GetGump <UOChatGump>();

                    if (chatGump == null)
                    {
                        UIManager.Add(new UOChatGump());
                    }
                    else
                    {
                        chatGump.SetInScreen();
                        chatGump.BringOnTop();
                    }
                }
                else if (UOChatManager.ChatIsEnabled == CHAT_STATUS.ENABLED_USER_REQUEST)
                {
                    UOChatGumpChooseName chatGump = UIManager.GetGump <UOChatGumpChooseName>();

                    if (chatGump == null)
                    {
                        UIManager.Add(new UOChatGumpChooseName());
                    }
                    else
                    {
                        chatGump.SetInScreen();
                        chatGump.BringOnTop();
                    }
                }

                break;

            case Buttons.GlobalChat:
                Log.Warn("Chat button pushed! Not implemented yet!");
                GameActions.Print("GlobalChat not implemented yet.", 0x23, MessageType.System);
                break;

            case Buttons.UOStore:
                if (Client.Version >= ClientVersion.CV_706400)
                {
                    NetClient.Socket.Send(new POpenUOStore());
                }
                break;

            case Buttons.Help:
                GameActions.RequestHelp();

                break;

            case Buttons.Debug:

                DebugGump debugGump = UIManager.GetGump <DebugGump>();

                if (debugGump == null)
                {
                    debugGump = new DebugGump(100, 100);
                    UIManager.Add(debugGump);
                }
                else
                {
                    debugGump.IsVisible = !debugGump.IsVisible;
                    debugGump.SetInScreen();
                }

                break;

            case Buttons.NetStats:
                NetworkStatsGump netstatsgump = UIManager.GetGump <NetworkStatsGump>();

                if (netstatsgump == null)
                {
                    netstatsgump = new NetworkStatsGump(100, 100);
                    UIManager.Add(netstatsgump);
                }
                else
                {
                    netstatsgump.IsVisible = !netstatsgump.IsVisible;
                    netstatsgump.SetInScreen();
                }

                break;

            case Buttons.WorldMap:

                WorldMapGump worldMap = UIManager.GetGump <WorldMapGump>();

                if (worldMap == null || worldMap.IsDisposed)
                {
                    worldMap = new WorldMapGump();
                    UIManager.Add(worldMap);
                }
                else
                {
                    worldMap.BringOnTop();
                    worldMap.SetInScreen();
                }
                break;
            }
        }
Example #6
0
        public override void OnButtonClick(int buttonID)
        {
            switch ((Buttons)buttonID)
            {
            case Buttons.Map:

                MiniMapGump miniMapGump = Engine.UI.GetControl <MiniMapGump>();

                if (miniMapGump == null)
                {
                    Engine.UI.Add(new MiniMapGump());
                }
                else
                {
                    miniMapGump.SetInScreen();
                    miniMapGump.BringOnTop();
                }

                break;

            case Buttons.Paperdoll:
                PaperDollGump paperdollGump = Engine.UI.GetControl <PaperDollGump>(World.Player);

                if (paperdollGump == null)
                {
                    GameActions.OpenPaperdoll(World.Player);
                }
                else
                {
                    paperdollGump.SetInScreen();
                    paperdollGump.BringOnTop();
                }

                break;

            case Buttons.Inventory:
                Item backpack = World.Player.Equipment[(int)Layer.Backpack];

                ContainerGump backpackGump = Engine.UI.GetControl <ContainerGump>(backpack);

                if (backpackGump == null)
                {
                    GameActions.DoubleClick(backpack);
                }
                else
                {
                    backpackGump.SetInScreen();
                    backpackGump.BringOnTop();
                }

                break;

            case Buttons.Journal:
                JournalGump journalGump = Engine.UI.GetControl <JournalGump>();

                if (journalGump == null)
                {
                    Engine.UI.Add(new JournalGump
                    {
                        X = 64, Y = 64
                    });
                }
                else
                {
                    journalGump.SetInScreen();
                    journalGump.BringOnTop();
                }

                break;

            case Buttons.Chat:
                Log.Message(LogTypes.Warning, "Chat button pushed! Not implemented yet!");

                break;

            case Buttons.Help:
                GameActions.RequestHelp();

                break;

            case Buttons.Debug:

                DebugGump debugGump = Engine.UI.GetControl <DebugGump>();

                if (debugGump == null)
                {
                    debugGump = new DebugGump
                    {
                        X = Engine.Profile.Current.DebugGumpPosition.X,
                        Y = Engine.Profile.Current.DebugGumpPosition.Y
                    };

                    Engine.UI.Add(debugGump);
                }
                else
                {
                    debugGump.IsVisible = !debugGump.IsVisible;
                    debugGump.SetInScreen();
                }

                Engine.DropFpsMinMaxValues();

                break;
            }
        }
Example #7
0
        public override void OnButtonClick(int buttonID)
        {
            switch ((Buttons)buttonID)
            {
            case Buttons.Map:

                MiniMapGump miniMapGump = Engine.UI.GetByLocalSerial <MiniMapGump>();
                if (miniMapGump == null)
                {
                    Engine.UI.Add(new MiniMapGump());
                }
                else
                {
                    miniMapGump.BringOnTop();
                }

                break;

            case Buttons.Paperdoll:
                PaperDollGump paperdollGump = Engine.UI.GetByLocalSerial <PaperDollGump>(World.Player);
                if (paperdollGump == null)
                {
                    GameActions.OpenPaperdoll(World.Player);
                }
                else
                {
                    paperdollGump.BringOnTop();
                }

                break;

            case Buttons.Inventory:
                Item backpack = World.Player.Equipment[(int)Layer.Backpack];

                ContainerGump backpackGump = Engine.UI.GetByLocalSerial <ContainerGump>(backpack);

                if (backpackGump == null)
                {
                    GameActions.DoubleClick(backpack);
                }
                else
                {
                    backpackGump.BringOnTop();
                }

                break;

            case Buttons.Journal:
                JournalGump journalGump = Engine.UI.GetByLocalSerial <JournalGump>();

                if (journalGump == null)
                {
                    Engine.UI.Add(new JournalGump()
                    {
                        X = 64, Y = 64
                    });
                }
                else
                {
                    journalGump.BringOnTop();
                }

                break;

            case Buttons.Chat:
                Log.Message(LogTypes.Warning, "Chat button pushed! Not implemented yet!");

                break;

            case Buttons.Help:
                GameActions.RequestHelp();

                break;

            case Buttons.Debug:

                DebugGump debugGump = Engine.UI.GetByLocalSerial <DebugGump>();

                if (debugGump == null)
                {
                    // dont consider this case
                }
                else
                {
                    debugGump.IsVisible = !debugGump.IsVisible;
                }

                break;
            }
        }
Example #8
0
        public ContainerGump(uint serial, ushort gumpid, bool playsound, Mobile parent = null) : base(serial, 0)
        {
            item = World.Items.Get(serial);

            _parent = parent;

            if (item == null)
            {
                Dispose();

                return;
            }

            ContainerGump nameGump = new ContainerGump();

            Graphic = gumpid;

            // New Backpack gumps. Client Version 7.0.53.1
            if (item == World.Player.FindItemByLayer(Layer.Backpack) && Client.Version >= ClassicUO.Data.ClientVersion.CV_705301 && ProfileManager.CurrentProfile != null)
            {
                GumpsLoader loader = GumpsLoader.Instance;

                switch (ProfileManager.CurrentProfile.BackpackStyle)
                {
                case 1:
                    if (loader.GetTexture(0x775E) != null)
                    {
                        Graphic = 0x775E;     // Suede Backpack
                    }

                    break;

                case 2:
                    if (loader.GetTexture(0x7760) != null)
                    {
                        Graphic = 0x7760;     // Polar Bear Backpack
                    }

                    break;

                case 3:
                    if (loader.GetTexture(0x7762) != null)
                    {
                        Graphic = 0x7762;     // Ghoul Skin Backpack
                    }

                    break;

                default:
                    if (loader.GetTexture(0x003C) != null)
                    {
                        Graphic = 0x003C;     // Default Backpack
                    }

                    break;
                }
            }

            BuildGump();

            if (Graphic == 0x0009)
            {
                if (World.Player.ManualOpenedCorpses.Contains(LocalSerial))
                {
                    World.Player.ManualOpenedCorpses.Remove(LocalSerial);
                }
                else if (World.Player.AutoOpenedCorpses.Contains(LocalSerial) && ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.SkipEmptyCorpse)
                {
                    IsVisible    = false;
                    _hideIfEmpty = true;
                }
            }

            if (_data.OpenSound != 0 && playsound)
            {
                Client.Game.Scene.Audio.PlaySound(_data.OpenSound);
            }
        }
Example #9
0
        private void BuildGump()
        {
            CanMove              = true;
            CanBeSaved           = true;
            LocalSerial          = _item.Serial;
            WantUpdateSize       = false;
            _isCorspeContainer   = Graphic == 0x0009;
            _item.Items.Added   += ItemsOnAdded;
            _item.Items.Removed += ItemsOnRemoved;

            _data = ContainerManager.Get(Graphic);
            Graphic g = _data.Graphic;

            GumpPicContainer container;

            Add(container = new GumpPicContainer(0, 0, g, 0, _item));

            if (_isCorspeContainer)
            {
                Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0));
            }

            Width  = container.Width;
            Height = container.Height;

            ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial);

            if (gg == null)
            {
                if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && _item.Serial == World.Player.Equipment[(int)Layer.Backpack])
                {
                    Location = location;
                }
                else
                {
                    if (Engine.Profile.Current.OverrideContainerLocation)
                    {
                        switch (Engine.Profile.Current.OverrideContainerLocationSetting)
                        {
                        case 0:
                            SetPositionNearGameObject(g);
                            break;

                        case 1:
                            SetPositionTopRight();
                            break;

                        case 2:
                            SetPositionByLastDragged();
                            break;
                        }

                        if ((X + Width) > Engine.WindowWidth)
                        {
                            X -= Width;
                        }

                        if ((Y + Height) > Engine.WindowHeight)
                        {
                            Y -= Height;
                        }
                    }
                    else
                    {
                        ContainerManager.CalculateContainerPosition(g);
                        X = ContainerManager.X;
                        Y = ContainerManager.Y;
                    }
                }
            }
            else
            {
                X = gg.X;
                Y = gg.Y;
            }


            if (_data.OpenSound != 0)
            {
                Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound);
            }
        }
Example #10
0
        private void BuildGump()
        {
            CanMove              = true;
            CanBeSaved           = true;
            LocalSerial          = _item.Serial;
            WantUpdateSize       = false;
            _isCorspeContainer   = Graphic == 0x0009;
            _item.Items.Added   += ItemsOnAdded;
            _item.Items.Removed += ItemsOnRemoved;

            _data = ContainerManager.Get(Graphic);
            Graphic g = _data.Graphic;

            GumpPicContainer container;

            Add(container = new GumpPicContainer(0, 0, g, 0, _item));

            if (_isCorspeContainer)
            {
                Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0));
            }

            Width  = container.Width;
            Height = container.Height;

            ContainerGump gg = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == LocalSerial);

            if (gg == null)
            {
                if (Engine.UI.GetGumpCachePosition(LocalSerial, out Point location) && _item.Serial == World.Player.Equipment[(int)Layer.Backpack])
                {
                    Location = location;
                }
                else
                {
                    if (Engine.Profile.Current.OpenContainersNearRealPosition)
                    {
                        if (World.Player.Equipment[(int)Layer.Bank] != null && _item.Serial == World.Player.Equipment[(int)Layer.Bank])
                        {
                            // open bank near player
                            X = World.Player.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40;
                            Y = World.Player.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1);
                        }
                        else if (_item.OnGround)
                        {
                            // item is in world
                            X = _item.RealScreenPosition.X + Engine.Profile.Current.GameWindowPosition.X + 40;
                            Y = _item.RealScreenPosition.Y + Engine.Profile.Current.GameWindowPosition.Y - (Height >> 1);
                        }
                        else
                        {
                            // in a container, open near the container
                            ContainerGump parentContainer = Engine.UI.Gumps.OfType <ContainerGump>().FirstOrDefault(s => s.LocalSerial == _item.Container);
                            if (parentContainer != null)
                            {
                                X = parentContainer.X + (Width >> 1);
                                Y = parentContainer.Y;
                            }
                            else
                            {
                                // I don't think we ever get here?
                                ContainerManager.CalculateContainerPosition(g);
                                X = ContainerManager.X;
                                Y = ContainerManager.Y;
                            }
                        }

                        if ((X + Width) > Engine.WindowWidth)
                        {
                            X -= Width;
                        }

                        if ((Y + Height) > Engine.WindowHeight)
                        {
                            Y -= Height;
                        }
                    }
                    else
                    {
                        ContainerManager.CalculateContainerPosition(g);
                        X = ContainerManager.X;
                        Y = ContainerManager.Y;
                    }
                }
            }
            else
            {
                X = gg.X;
                Y = gg.Y;
            }


            if (_data.OpenSound != 0)
            {
                Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound);
            }
        }