private static Vec2 drawItem(RenderingContext rc, AlertDrawStyle drawStyle, int x, int y, Vec2 vPadding, string text, int fontSize) { // collapse padding when there's a frame vPadding.X -= drawStyle.FrameWidth; vPadding.Y -= drawStyle.FrameWidth; // item will appear to have equal size Vec2 textPos = new Vec2(x - vPadding.X, y + vPadding.Y); Vec2 vTextSize = rc.AddTextWithHeight(textPos, text, drawStyle.color, fontSize, DrawTextFormat.Right); int iconSize = drawStyle.IconIndex >= 0 ? vTextSize.Y : 0; int fullHeight = vTextSize.Y + 2 * vPadding.Y + 2 * drawStyle.FrameWidth; int fullWidth = vTextSize.X + 2 * vPadding.X + iconSize + 2 * drawStyle.FrameWidth; rc.AddBox(new Rect(x - fullWidth, y, fullWidth, fullHeight), Color.FromArgb(180, 0, 0, 0)); if (iconSize > 0) { const float iconsInSprite = 4; Rect iconPos = new Rect(textPos.X - iconSize - vTextSize.X, textPos.Y, iconSize, iconSize); RectUV uv = new RectUV(drawStyle.IconIndex / iconsInSprite, 0, (drawStyle.IconIndex + 1) / iconsInSprite, 1); rc.AddSprite("item_icons.png", iconPos, uv); } if (drawStyle.FrameWidth > 0) { Rect frame = new Rect(x - fullWidth, y, fullWidth, fullHeight); rc.AddFrame(frame, drawStyle.color, drawStyle.FrameWidth); } return(new Vec2(fullWidth, fullHeight)); }
protected override void OnEntityAdded(EntityWrapper entity) { if (Settings.Enable && entity != null && !GameController.Area.CurrentArea.IsTown && !currentAlerts.ContainsKey(entity) && entity.HasComponent <WorldItem>()) { IEntity item = entity.GetComponent <WorldItem>().ItemEntity; if (Settings.Alternative && !string.IsNullOrEmpty(Settings.FilePath)) { var result = visitor.Visit(item); if (result != null) { AlertDrawStyle drawStyle = result; PrepareForDrawingAndPlaySound(entity, drawStyle); } } else { ItemUsefulProperties props = initItem(item); if (props == null) { return; } if (props.ShouldAlert(currencyNames, Settings)) { AlertDrawStyle drawStyle = props.GetDrawStyle(); PrepareForDrawingAndPlaySound(entity, drawStyle); } Settings.Alternative.Value = false; } } }
protected override void OnEntityAdded(EntityWrapper entity) { if (!Settings.Enable || currentAlerts.ContainsKey(entity)) { return; } if (entity.HasComponent <WorldItem>()) { IEntity item = entity.GetComponent <WorldItem>().ItemEntity; ItemUsefulProperties props = EvaluateItem(item); if (props.IsWorthAlertingPlayer(currencyNames, Settings)) { AlertDrawStyle drawStyle = props.GetDrawStyle(); currentAlerts.Add(entity, drawStyle); CurrentIcons[entity] = new MapIcon(entity, new HudTexture("minimap_default_icon.png", drawStyle.Color), () => Settings.ShowItemOnMap, 8); if (Settings.PlaySound && !playedSoundsCache.Contains(entity.LongId)) { playedSoundsCache.Add(entity.LongId); Sounds.AlertSound.Play(); } } } }
public void EntityAdded(EntityWrapper entity) { if (!Settings.Enabled || currentAlerts.ContainsKey(entity)) { return; } if (!entity.HasComponent <WorldItem>()) { return; } EntityWrapper item = new EntityWrapper(model, entity.GetComponent <WorldItem>().ItemEntity); ItemUsefulProperties props = EvaluateItem(item); if (!props.IsWorthAlertingPlayer(Settings, currencyNames)) { return; } AlertDrawStyle drawStyle = props.GetDrawStyle(); currentAlerts.Add(entity, drawStyle); drawStyle.IconForMap = new MapIcon(entity, new HudTexture("minimap_default_icon.png", drawStyle.color), 8) { Type = MapIcon.IconType.Item }; if (Settings.PlaySound && drawStyle.soundToPlay != null && !playedSoundsCache.Contains(entity.LongId)) { playedSoundsCache.Add(entity.LongId); drawStyle.soundToPlay.Play(); } }
public override void Render(RenderingContext rc) { if (!Settings.GetBool("ItemAlert") || !Settings.GetBool("ItemAlert.ShowText")) { return; } Rect clientRect = this.poe.Internal.game.IngameState.IngameUi.Minimap.SmallMinimap.GetClientRect(); Vec2 rightTopAnchor = new Vec2(clientRect.X + clientRect.W, clientRect.Y + clientRect.H + 5); int y = rightTopAnchor.Y; int fontSize = Settings.GetInt("ItemAlert.ShowText.FontSize"); foreach (KeyValuePair <ExileBot.Entity, AlertDrawStyle> kv in this.currentAlerts) { if (!kv.Key.IsValid) { continue; } string text = GetItemName(kv); if (null == text) { continue; } AlertDrawStyle drawStyle = kv.Value; int frameWidth = drawStyle.FrameWidth; Vec2 vPadding = new Vec2(frameWidth + 5, frameWidth); int frameMargin = frameWidth + 2; Vec2 textPos = new Vec2(rightTopAnchor.X - vPadding.X, y + vPadding.Y); var vTextFrame = rc.AddTextWithHeight(textPos, text, drawStyle.color, fontSize, DrawTextFormat.Right); int iconSize = vTextFrame.Y; bool hasIcon = drawStyle.IconIndex >= 0; int maxHeight = vTextFrame.Y + 2 * vPadding.Y + frameMargin; int maxWidth = vTextFrame.X + 2 * vPadding.X + (hasIcon ? iconSize : 0); rc.AddBox(new Rect(rightTopAnchor.X - maxWidth, y, maxWidth, maxHeight), Color.FromArgb(180, 0, 0, 0)); if (hasIcon) { const float iconsInSprite = 4; Rect iconPos = new Rect(textPos.X - iconSize - vTextFrame.X, textPos.Y, iconSize, iconSize); RectUV uv = new RectUV(drawStyle.IconIndex / iconsInSprite, 0, (drawStyle.IconIndex + 1) / iconsInSprite, 1); rc.AddSprite("item_icons.png", iconPos, uv); } if (frameWidth > 0) { Rect frame = new Rect(rightTopAnchor.X - vTextFrame.X - 2 * vPadding.X, y, vTextFrame.X + 2 * vPadding.X, vTextFrame.Y + 2 * vPadding.Y); rc.AddFrame(frame, kv.Value.color, frameWidth); } y += vTextFrame.Y + 2 * vPadding.Y + frameMargin; } }
private void PrepareForDrawingAndPlaySound(EntityWrapper entity, AlertDrawStyle drawStyle) { currentAlerts.Add(entity, drawStyle); CurrentIcons[entity] = new MapIcon(entity, new HudTexture("currency.png", drawStyle.TextColor), () => Settings.ShowItemOnMap, Settings.LootIcon); if (Settings.PlaySound && !playedSoundsCache.Contains(entity.LongId)) { playedSoundsCache.Add(entity.LongId); Sounds.AlertSound.Play(Settings.SoundVolume); } }
private void DoAlert(ExileBot.Entity entity, ItemUsefulProperties ip) { AlertDrawStyle drawStyle = ip.GetDrawStyle(); this.currentAlerts.Add(entity, drawStyle); this.overlay.MinimapRenderer.AddIcon(new ItemMinimapIcon(entity, "minimap_default_icon.png", drawStyle.color, 8)); if (Settings.GetBool("ItemAlert.PlaySound") && !this.playedSoundsCache.Contains(entity.LongId)) { this.playedSoundsCache.Add(entity.LongId); Sounds.AlertSound.Play(); } }
private static Vec2 drawItem(RenderingContext rc, AlertDrawStyle drawStyle, Vec2 delta, int x, int y, Vec2 vPadding, string text, int fontSize) { // collapse padding when there's a frame vPadding.X -= drawStyle.FrameWidth; vPadding.Y -= drawStyle.FrameWidth; // item will appear to have equal size double phi; var distance = delta.GetPolarCoordinates(out phi); //text = text + " @ " + (int)distance + " : " + (int)(phi / Math.PI * 180) + " : " + xSprite; int compassOffset = fontSize + 8; Vec2 textPos = new Vec2(x - vPadding.X - compassOffset, y + vPadding.Y); Vec2 vTextSize = rc.AddTextWithHeight(textPos, text, drawStyle.color, fontSize, DrawTextFormat.Right); int iconSize = drawStyle.IconIndex >= 0 ? vTextSize.Y : 0; int fullHeight = vTextSize.Y + 2 * vPadding.Y + 2 * drawStyle.FrameWidth; int fullWidth = vTextSize.X + 2 * vPadding.X + iconSize + 2 * drawStyle.FrameWidth + compassOffset; rc.AddBox(new Rect(x - fullWidth, y, fullWidth - compassOffset, fullHeight), Color.FromArgb(180, 0, 0, 0)); var rectUV = GetDirectionsUv(phi, distance); rc.AddSprite("directions.png", new Rect(x - vPadding.X - compassOffset + 6, y + vPadding.Y, vTextSize.Y, vTextSize.Y), rectUV); if (iconSize > 0) { const float iconsInSprite = 6; Rect iconPos = new Rect(textPos.X - iconSize - vTextSize.X, textPos.Y, iconSize, iconSize); RectUV uv = new RectUV(drawStyle.IconIndex / iconsInSprite, 0, (drawStyle.IconIndex + 1) / iconsInSprite, 1); rc.AddSprite("item_icons.png", iconPos, uv); } if (drawStyle.FrameWidth > 0) { Rect frame = new Rect(x - fullWidth, y, fullWidth - compassOffset, fullHeight); rc.AddFrame(frame, drawStyle.color, drawStyle.FrameWidth); } return(new Vec2(fullWidth, fullHeight)); }
private Vector2 DrawItem(AlertDrawStyle drawStyle, Vector2 delta, Vector2 position, Vector2 padding, string text) { padding.X -= drawStyle.FrameWidth; padding.Y -= drawStyle.FrameWidth; double phi; double distance = delta.GetPolarCoordinates(out phi); float compassOffset = Settings.TextSize + 8; Vector2 textPos = position.Translate(-padding.X - compassOffset, padding.Y); Size2 textSize = Graphics.DrawText(text, Settings.TextSize, textPos, drawStyle.AlertColor, FontDrawFlags.Right); if (textSize == new Size2()) // Access Violation { return(new Vector2()); } int iconSize = drawStyle.IconIndex >= 0 ? textSize.Height : 0; float fullHeight = textSize.Height + 2 * padding.Y + 2 * drawStyle.FrameWidth; float fullWidth = textSize.Width + 2 * padding.X + iconSize + 2 * drawStyle.FrameWidth + compassOffset; var boxRect = new RectangleF(position.X - fullWidth, position.Y, fullWidth - compassOffset, fullHeight); Graphics.DrawBox(boxRect, new ColorBGRA(0, 0, 0, 180)); RectangleF rectUV = GetDirectionsUV(phi, distance); var rectangleF = new RectangleF(position.X - padding.X - compassOffset + 6, position.Y + padding.Y, textSize.Height, textSize.Height); Graphics.DrawImage("directions.png", rectangleF, rectUV); if (iconSize > 0) { const float ICONS_IN_SPRITE = 4; var iconPos = new RectangleF(textPos.X - iconSize - textSize.Width, textPos.Y, iconSize, iconSize); float iconX = drawStyle.IconIndex / ICONS_IN_SPRITE; var uv = new RectangleF(iconX, 0, (drawStyle.IconIndex + 1) / ICONS_IN_SPRITE - iconX, 1); Graphics.DrawImage("item_icons.png", iconPos, uv); } if (drawStyle.FrameWidth > 0) { Graphics.DrawFrame(boxRect, drawStyle.FrameWidth, drawStyle.AlertColor); } return(new Vector2(fullWidth, fullHeight)); }
protected override void OnEntityAdded(EntityWrapper entity) { if (Settings.Enable && entity != null && !GameController.Area.CurrentArea.IsTown && !currentAlerts.ContainsKey(entity) && entity.HasComponent <WorldItem>()) { IEntity item = entity.GetComponent <WorldItem>().ItemEntity; ItemUsefulProperties props = initItem(item); if (props.ShouldAlert(currencyNames, Settings)) { AlertDrawStyle drawStyle = props.GetDrawStyle(); currentAlerts.TryAdd(entity, drawStyle); CurrentIcons[entity] = new MapIcon(entity, new HudTexture("minimap_default_icon.png", drawStyle.AlertColor), () => Settings.ShowItemOnMap, 8); if (Settings.PlaySound && !playedSoundsCache.Contains(entity.LongId)) { playedSoundsCache.Add(entity.LongId); Sounds.AlertSound.Play(); } } } }
public override void Render() { if (!holdKey && WinApi.IsKeyDown(Keys.F10)) { holdKey = true; Settings.Enable.Value = !Settings.Enable.Value; SettingsHub.Save(settingsHub); } else if (holdKey && !WinApi.IsKeyDown(Keys.F10)) { holdKey = false; } if (!Settings.Enable) { return; } if (Settings.Enable) { var pos = GameController.Player.GetComponent <Positioned>(); var playerPos = pos.GridPos; var position = StartDrawPointFunc(); const int BOTTOM_MARGIN = 2; var shouldUpdate = false; var validAlerts = currentAlerts.ToList().Where( x => x.Key != null && x.Key.Address != 0 && x.Key.IsValid); foreach (KeyValuePair <EntityWrapper, AlertDrawStyle> kv in validAlerts) { if (string.IsNullOrEmpty(kv.Value.Text)) { continue; } LabelOnGround entityLabel; if (!currentLabels.TryGetValue(kv.Key.Address, out entityLabel)) { shouldUpdate = true; } else { if (Settings.BorderSettings.Enable) { DrawBorder(entityLabel); } if (Settings.ShowText) { if (entityLabel.CanPickUp || entityLabel.MaxTimeForPickUp.TotalSeconds == 0) { position = DrawText(playerPos, position, BOTTOM_MARGIN, kv, kv.Value.Text); } else if (!Settings.HideOthers) { // get current values Color TextColor = kv.Value.TextColor; Color BorderColor = kv.Value.BorderColor; Color BackgroundColor = kv.Value.BackgroundColor; if (Settings.DimOtherByPercentToggle) { // edit values to new ones double ReduceByPercent = (double)Settings.DimOtherByPercent / 100; TextColor = ReduceNumbers(TextColor, ReduceByPercent); BorderColor = ReduceNumbers(BorderColor, ReduceByPercent); BackgroundColor = ReduceNumbers(BackgroundColor, ReduceByPercent); // backgrounds with low alpha start to look a little strange when dark so im adding an alpha threshold if (BackgroundColor.A < 210) { BackgroundColor.A = 210; } } // Complete new KeyValuePair with new stuff AlertDrawStyle ModifiedDrawStyle = new AlertDrawStyle(kv.Value.Text, TextColor, kv.Value.BorderWidth, BorderColor, BackgroundColor, kv.Value.IconIndex); KeyValuePair <EntityWrapper, AlertDrawStyle> NewKV = new KeyValuePair <EntityWrapper, AlertDrawStyle>(kv.Key, ModifiedDrawStyle); position = DrawText(playerPos, position, BOTTOM_MARGIN, NewKV, kv.Value.Text); } } } } Size = new Size2F(0, position.Y); //bug absent width if (shouldUpdate) { currentLabels = GameController.Game.IngameState.IngameUi.ItemsOnGroundLabels .GroupBy(y => y.ItemOnGround.Address).ToDictionary(y => y.Key, y => y.First()); } } }
private static Vec2 drawItem(RenderingContext rc, AlertDrawStyle drawStyle, Vec2 delta, int x, int y, Vec2 vPadding, string text, int fontSize) { // collapse padding when there's a frame vPadding.X -= drawStyle.FrameWidth; vPadding.Y -= drawStyle.FrameWidth; // item will appear to have equal size double phi; var distance = delta.GetPolarCoordinates(out phi); //text = text + " @ " + (int)distance + " : " + (int)(phi / Math.PI * 180) + " : " + xSprite; int compassOffset = fontSize + 8; Vec2 textPos = new Vec2(x - vPadding.X - compassOffset, y + vPadding.Y); Vec2 vTextSize = rc.AddTextWithHeight(textPos, text, drawStyle.color, fontSize, DrawTextFormat.Right); int iconSize = drawStyle.IconIndex >= 0 ? vTextSize.Y : 0; int fullHeight = vTextSize.Y + 2 * vPadding.Y + 2 * drawStyle.FrameWidth; int fullWidth = vTextSize.X + 2 * vPadding.X + iconSize + 2 * drawStyle.FrameWidth + compassOffset; rc.AddBox(new Rect(x - fullWidth, y, fullWidth - compassOffset, fullHeight), Color.FromArgb(180, 0, 0, 0)); var rectUV = GetDirectionsUv(phi, distance); rc.AddSprite("directions.png", new Rect(x - vPadding.X - compassOffset + 6, y + vPadding.Y, vTextSize.Y, vTextSize.Y), rectUV); if (iconSize > 0) { const float iconsInSprite = 6; Rect iconPos = new Rect(textPos.X - iconSize - vTextSize.X, textPos.Y, iconSize, iconSize); RectUV uv = new RectUV(drawStyle.IconIndex/iconsInSprite, 0, (drawStyle.IconIndex + 1)/iconsInSprite, 1); rc.AddSprite("item_icons.png", iconPos, uv); } if (drawStyle.FrameWidth > 0) { Rect frame = new Rect(x - fullWidth, y, fullWidth - compassOffset , fullHeight); rc.AddFrame(frame, drawStyle.color, drawStyle.FrameWidth); } return new Vec2(fullWidth, fullHeight); }