예제 #1
0
        private string GetItemName(KeyValuePair <EntityWrapper, AlertDrawStyle> kv)
        {
            string      text;
            EntityLabel labelFromEntity = model.GetLabelForEntity(kv.Key);

            if (labelFromEntity == null)
            {
                Entity itemEntity = kv.Key.GetComponent <WorldItem>().ItemEntity;
                if (!itemEntity.IsValid)
                {
                    return(null);
                }
                text = kv.Value.Text;
            }
            else
            {
                text = labelFromEntity.Text;
            }
            return(text);
        }
예제 #2
0
        public override void Render(RenderingContext rc, Dictionary <UiMountPoint, Vec2> mountPoints)
        {
            if (!Settings.ShowText && !Settings.ShowBorder)
            {
                return;
            }

            var playerPos = model.Player.GetComponent <Positioned>().GridPos;

            Vec2 rightTopAnchor = mountPoints[UiMountPoint.UnderMinimap];
            int  y                   = rightTopAnchor.Y;
            int  fontSize            = Settings.TextFontSize;
            var  itemsOnGroundLabels = model.Internal.IngameState.IngameUi.ItemsOnGroundLabels;

            const int VMargin = 2;

            foreach (KeyValuePair <EntityWrapper, AlertDrawStyle> kv in currentAlerts.Where(a => a.Key.IsValid))
            {
                string text = GetItemName(kv);
                if (null == text)
                {
                    continue;
                }

                if (Settings.ShowBorder)
                {
                    if (!groundItemLabels.Any(labeledItem => labeledItem.ItemOnGround.Address == kv.Key.Address))
                    {
                        ItemsOnGroundLabelElement labeledItem = model.Internal.IngameState.IngameUi.ItemsOnGroundLabels.FirstOrDefault(z => z.ItemOnGround.Address == kv.Key.Address);
                        if (labeledItem != null)
                        {
                            groundItemLabels.Add(labeledItem);
                        }
                    }
                    if (groundItemLabels.Any(labeledItem => labeledItem.ItemOnGround.Address == kv.Key.Address && labeledItem.Label.IsVisible))
                    {
                        var   rect      = groundItemLabels.First(labeledItem => labeledItem.ItemOnGround.Address == kv.Key.Address).Label.GetClientRect();
                        int   thickness = Settings.ShowBorder.Thickness.Value;
                        Color color     = Settings.ShowBorder.Color.Value;

                        if (Settings.ShowBorder.Customize.Enabled)
                        {
                            Entity e = kv.Key.GetComponent <WorldItem>().ItemEntity;
                            foreach (ShowBorderCustomizeSetting type in Settings.ShowBorder.Customize.GetSettings().Where(t => t.Enabled))
                            {
                                switch (type.BlockName)
                                {
                                case "Uniques":
                                    if (!e.GetComponent <Mods>().ItemRarity.Equals(Game.Rarity.Unique))
                                    {
                                        continue;
                                    }
                                    break;

                                case "Sockets":
                                    if (!new int[] { 0, 3, 4, 5 }.Contains(kv.Value.IconIndex))
                                    {
                                        continue;
                                    }
                                    break;

                                case "RGB":
                                    if (!kv.Value.IconIndex.Equals(1))
                                    {
                                        continue;
                                    }
                                    break;

                                case "CraftingBases":
                                    if (!kv.Value.IconIndex.Equals(2))
                                    {
                                        continue;
                                    }
                                    break;

                                default:
                                    if (!e.Path.Contains(type.BlockName))
                                    {
                                        continue;
                                    }
                                    break;
                                }

                                thickness = type.Thickness.Value;
                                color     = type.Color.Value;
                                break;
                            }
                        }

                        if (thickness > 0 &&
                            (model.Internal.IngameState.IngameUi.InventoryPanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.InventoryPanel.GetClientRect()) : true) &&
                            (model.Internal.IngameState.IngameUi.CharacterPanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.CharacterPanel.GetClientRect()) : true) &&
                            (model.Internal.IngameState.IngameUi.SocialPanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.SocialPanel.GetClientRect()) : true) &&
                            (model.Internal.IngameState.IngameUi.TreePanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.TreePanel.GetClientRect()) : true) &&
                            (model.Internal.IngameState.IngameUi.OptionsPanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.OptionsPanel.GetClientRect()) : true) &&
                            (model.Internal.IngameState.IngameUi.AchievementsPanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.AchievementsPanel.GetClientRect()) : true) &&
                            (model.Internal.IngameState.IngameUi.WorldPanel.IsVisible ? !rect.IntersectsWith(model.Internal.IngameState.IngameUi.WorldPanel.GetClientRect()) : true))
                        {
                            rc.AddFrame(rect, color, thickness);
                        }
                    }
                }

                if (Settings.ShowText)
                {
                    Vec2 itemPos = kv.Key.GetComponent <Positioned>().GridPos;
                    var  delta   = itemPos - playerPos;

                    Vec2 vPadding      = new Vec2(5, 2);
                    Vec2 itemDrawnSize = drawItem(rc, kv.Value, delta, rightTopAnchor.X, y, vPadding, text, fontSize);
                    y += itemDrawnSize.Y + VMargin;
                }
            }
        }