public override void DrawAt(RenderingContext rc, Vec2 point, Rect rect) { float xD = ((float)(SpriteSize.X)) / SpriteSize.X; float yD = ((float)(SpriteSize.Y)) / SpriteSize.Y; RectUV uvRect = new RectUV(xD * ChosenImage.X, yD * ChosenImage.Y, xD * (ChosenImage.X + 1), yD * (ChosenImage.Y + 1)); rc.AddSprite(this.TextureFile, rect, uvRect, TintColor); }
private void RednerIconsOnLargeMap(RenderingContext rc) { var camera = model.Internal.Game.IngameState.Camera; var cw = camera.Width; var ch = camera.Height; BigMinimap mapWindow = model.Internal.Game.IngameState.IngameUi.Minimap; Rect rcMap = mapWindow.GetClientRect(); Vec2 playerPos = model.Player.GetComponent<Positioned>().GridPos; float pPosZ = model.Player.GetComponent<Render>().Z; Vec2 screenCenter = new Vec2(rcMap.W / 2, rcMap.H / 2) + new Vec2(rcMap.X, rcMap.Y) + new Vec2((int)mapWindow.ShiftX, (int)mapWindow.ShiftY); float diag = (float)Math.Sqrt(cw * cw + ch * ch); // const float scale = 1280f; var k = cw < 1024 ? 1120 : 1024; float scale = (float)k / ch * cw * 3 / 4; foreach (MapIcon icon in _getIcons()) { if (ShouldSkipIcon(icon)) continue; float iZ = icon.Entity.GetComponent<Render>().Z; Vec2 point = screenCenter + MapIcon.deltaInWorldToMinimapDelta(icon.WorldPosition - playerPos, diag, scale, (int)((iZ - pPosZ) / 10)); var texture = icon.LargeMapIcon ?? icon.MinimapIcon; int size = icon.SizeOfLargeIcon.GetValueOrDefault(icon.Size * 2); Rect rect = new Rect(point.X - size / 2, point.Y - size / 2, size, size); texture.DrawAt(rc, point, rect); } }
public override void Render(RenderingContext rc) { if (!this.poe.InGame || !Settings.GetBool("MinimapIcons")) { return; } this.playerPos = this.poe.Player.GetComponent<Positioned>().GridPos; Element smallMinimap = this.poe.Internal.IngameState.IngameUi.Minimap.SmallMinimap; float scale = 240f; Rect clientRect = smallMinimap.GetClientRect(); Vec2 minimapCenter = new Vec2(clientRect.X + clientRect.W / 2, clientRect.Y + clientRect.H / 2); double diag = Math.Sqrt((double)(clientRect.W * clientRect.W + clientRect.H * clientRect.H)) / 2.0; List<MinimapIcon>[] array = this.icons; for (int i = 0; i < array.Length; i++) { List<MinimapIcon> list = array[i]; list.RemoveAll((MinimapIcon x) => !x.Validate()); foreach (MinimapIcon current in from x in list where x.WantsToRender() select x) { Vec2 point = this.WorldToMinimap(current.WorldPosition, minimapCenter, diag, scale); current.RenderAt(rc, point); } } }
protected override void HandleEvent(MouseEventID id, Vec2 pos) { if (id == MouseEventID.LeftButtonDown) { this.isEnabled = !this.isEnabled; } Settings.SetBool(this.settingName, this.isEnabled); }
public Vec2 AddTextWithHeight(Vec2 pos, string text, Color color, int height, DrawTextFormat format) { SlimDX.Direct3D9.Font font = this.GetFont(height); Rectangle rectangle = font.MeasureString(this.textSprite, text, format); rectangle.X += pos.X; rectangle.Y += pos.Y; font.DrawString(this.textSprite, text, rectangle, format, color); return new Vec2(rectangle.Width, rectangle.Height); }
protected override void HandleEvent(MouseEventID id, Vec2 pos) { if (null == setting) return; if (id == MouseEventID.LeftButtonDown) { this.isEnabled = !this.isEnabled; setting.Value = this.isEnabled; } }
public static Vec2 deltaInWorldToMinimapDelta(Vec2 delta, double diag, float scale, int deltaZ = 0) { const float CameraAngle = 38; // Values according to 40 degree rotation of cartesian coordiantes, still doesn't seem right but closer float cosX = (float)(delta.X / scale * diag * Math.Cos(Math.PI / 180 * CameraAngle)); float cosY = (float)(delta.Y / scale * diag * Math.Cos(Math.PI / 180 * CameraAngle)); float sinX = (float)(delta.X / scale * diag * Math.Sin(Math.PI / 180 * CameraAngle)); float sinY = (float)(delta.Y / scale * diag * Math.Sin(Math.PI / 180 * CameraAngle)); // 2D rotation formulas not correct, but it's what appears to work? return new Vec2((int)(cosX - cosY), -(int)((sinX + sinY)) + deltaZ); }
public override void Render(RenderingContext rc) { if (!Settings.GetBool("XphDisplay") || (this.poe.Player != null && this.poe.Player.GetComponent<Player>().Level >= 100)) { return; } if (!this.hasStarted) { this.startXp = this.poe.Player.GetComponent<Player>().XP; this.startTime = DateTime.Now; this.lastCalcTime = DateTime.Now; this.hasStarted = true; return; } DateTime dtNow = DateTime.Now; TimeSpan delta = dtNow - this.lastCalcTime; if (delta.TotalSeconds > 1.0) { this.poe.Area.CurrentArea.AddTimeSpent(delta); calculateRemainingExp(dtNow); this.lastCalcTime = dtNow; } int fontSize = Settings.GetInt("XphDisplay.FontSize"); int bgAlpha = Settings.GetInt("XphDisplay.BgAlpha"); Rect clientRect = this.poe.Internal.IngameState.IngameUi.Minimap.SmallMinimap.GetClientRect(); Vec2 mapWithOffset = new Vec2(clientRect.X - 10, clientRect.Y + 5); int yCursor = 0; Vec2 rateTextSize = rc.AddTextWithHeight(new Vec2(mapWithOffset.X, mapWithOffset.Y), this.curDisplayString, Color.White, fontSize, DrawTextFormat.Right); yCursor += rateTextSize.Y; Vec2 remainingTextSize = rc.AddTextWithHeight(new Vec2(mapWithOffset.X, mapWithOffset.Y + yCursor), this.curTimeLeftString, Color.White, fontSize, DrawTextFormat.Right); yCursor += remainingTextSize.Y; int thirdLine = mapWithOffset.Y + yCursor; Vec2 areaLevelNote = rc.AddTextWithHeight(new Vec2(mapWithOffset.X, thirdLine), this.poe.Area.CurrentArea.DisplayName, Color.White, fontSize, DrawTextFormat.Right); string strTimer = this.poe.Area.CurrentArea.TimeString; Vec2 timerSize = rc.MeasureString(strTimer, fontSize, DrawTextFormat.Left); yCursor += areaLevelNote.Y; int textWidth = Math.Max( Math.Max(rateTextSize.X, remainingTextSize.X), areaLevelNote.X + timerSize.X + 20 ) + 10; int width = Math.Max(textWidth, Math.Max(clientRect.W, this.overlay.PreloadAlert.Bounds.W)); Rect rect = new Rect(mapWithOffset.X - width + 5, mapWithOffset.Y - 5, width, yCursor + 10); this.Bounds = rect; rc.AddTextWithHeight(new Vec2(rect.X + 5, mapWithOffset.Y), dtNow.ToShortTimeString(), Color.White, fontSize, DrawTextFormat.Left); rc.AddTextWithHeight(new Vec2(rect.X + 5, thirdLine), strTimer, Color.White, fontSize, DrawTextFormat.Left); rc.AddBox(rect, Color.FromArgb(bgAlpha, 1, 1, 1)); }
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; } }
public void OnEvent(MouseEventID id, Vec2 pos) { if (id == MouseEventID.MouseMove) { if (this.TestBounds(pos)) { this.HandleEvent(id, pos); if (this.currentHover != null) { this.currentHover.SetHovered(false); this.currentHover = null; } return; } if (this.currentHover != null) { if (this.currentHover.TestHit(pos)) { this.currentHover.OnEvent(id, pos); return; } this.currentHover.SetHovered(false); } MenuItem childAt = this.GetChildAt(pos); if (childAt != null) { childAt.SetHovered(true); this.currentHover = childAt; return; } this.currentHover = null; return; } else { if (this.TestBounds(pos)) { this.HandleEvent(id, pos); return; } if (this.currentHover != null) { this.currentHover.OnEvent(id, pos); } return; } }
protected override void HandleEvent(MouseEventID id, Vec2 pos) { int colorHovered = (int)Math.Floor((double)(pos.Y - base.Bounds.Y) / (double)(base.Bounds.H / 3)); if (id == MouseEventID.LeftButtonDown) { this.barBeingDragged = colorHovered; return; } if (id == MouseEventID.LeftButtonUp) { this.CalcValue(pos.X); this.barBeingDragged = -1; return; } if (this.barBeingDragged != -1 && id == MouseEventID.MouseMove) { this.CalcValue(pos.X); } }
public override void Render(RenderingContext rc) { if (!Settings.GetBool("PreloadAlert")) { return; } int num = this.poe.Memory.ReadInt(this.poe.Memory.BaseAddress + poe.Memory.offsets.FileRoot, new int[] { 12 }); if (num != this.lastCount) { this.lastCount = num; this.Parse(); } if (this.disp.Count > 0) { Rect clientRect = this.poe.Internal.IngameState.IngameUi.Minimap.SmallMinimap.GetClientRect(); Rect rect = this.overlay.XphRenderer.Bounds; Vec2 vec = new Vec2(clientRect.X - 10, rect.Y + rect.H + 10); int num2 = vec.Y; int num3 = clientRect.W; int @int = Settings.GetInt("PreloadAlert.FontSize"); int int2 = Settings.GetInt("PreloadAlert.BgAlpha"); foreach (string current in this.disp) { Vec2 vec2 = rc.AddTextWithHeight(new Vec2(vec.X, num2), current, Color.White, @int, DrawTextFormat.Right); if (vec2.X + 10 > num3) { num3 = vec2.X + 10; } num2 += vec2.Y; } if (num3 > 0 && int2 > 0) { this.bounds = new Rect(vec.X - num3 + 5, vec.Y - 5, num3, num2 - vec.Y + 10); rc.AddBox(this.bounds, Color.FromArgb(int2, 1, 1, 1)); } } }
public Vec2 AddTextWithHeightAndOutline(Vec2 pos, string text, Color color, Color outLine, int height, DrawTextFormat format, int outlineOsset = 1) { SlimDX.Direct3D9.Font font = this.GetFont(height); Rectangle rectangle = font.MeasureString(this.textSprite, text, format); rectangle.X += pos.X; rectangle.Y += pos.Y; rectangle.X -= 1 * outlineOsset; rectangle.Y -= 1 * outlineOsset; font.DrawString(this.textSprite, text, rectangle, format, outLine); rectangle.Y += 2 * outlineOsset; font.DrawString(this.textSprite, text, rectangle, format, outLine); rectangle.X += 2 * outlineOsset; font.DrawString(this.textSprite, text, rectangle, format, outLine); rectangle.Y -= 2 * outlineOsset; font.DrawString(this.textSprite, text, rectangle, format, outLine); rectangle.X -= 1 * outlineOsset; rectangle.Y += 1 * outlineOsset; font.DrawString(this.textSprite, text, rectangle, format, color); return new Vec2(rectangle.Width, rectangle.Height); }
private static void drawElt(RenderingContext rc, Element root, Vec2 parent, ref int x, ref int yPos, int[] path, int depth = 0) { if (!root.IsVisibleLocal || depth > 3) { return; } //Rect rC = new Rect(parent.X + (int)(root.X * 0.75), parent.Y + (int)(root.Y * 0.75), (int)(root.Width * 0.75), (int)(root.Height * 0.75)); Rect rC = new Rect(parent.X + (int)(root.X * 0.75), parent.Y + (int)(root.Y * 0.75), (int)(root.Width * 0.75), (int)(root.Height * 0.75)); if (rC.W < 20) return; string sPath = path[0].ToString("X3") + "-" + String.Join("-", path.Skip(1).Take(depth-1)); int ix = depth > 0 ? path[depth - 1] : 0; var c = Color.FromArgb(255, 255 - 25 * (ix % 10), 255 - 25 * ((ix % 100) / 10), 255); string msg = string.Format("[{2}] {1:X8} : {0}", rC, root.Address, sPath); var v = rc.AddTextWithHeight(new Vec2(x, yPos), msg, c, 9, DrawTextFormat.Left); rc.AddTextWithHeight(new Vec2(rC.X, rC.Y + depth * 10 - 10), sPath, c, 8, DrawTextFormat.Left); rc.AddFrame(rC, c); yPos += v.Y; if (yPos > 1100) { yPos = 80; x += 300; } var pp = new Vec2(rC.X, rC.Y); for (int i = 0; i < root.Children.Count; i++) { var elt = root.Children[i]; path[depth] = i; if (depth < 8) drawElt(rc, elt, pp, ref x, ref yPos, path, depth + 1); } }
public bool TestHit(Vec2 pos) { return this.isVisible && (this.TestBounds(pos) || this.children.Any(current => current.TestHit(pos))); }
private void RenderIconsOnMiniMap(RenderingContext rc, Element smallMinimap) { Vec2 playerPos = model.Player.GetComponent<Positioned>().GridPos; float pPosZ = model.Player.GetComponent<Render>().Z; const float scale = 240f; Rect clientRect = smallMinimap.GetClientRect(); Vec2 minimapCenter = new Vec2(clientRect.X + clientRect.W/2, clientRect.Y + clientRect.H/2); double diag = Math.Sqrt(clientRect.W*clientRect.W + clientRect.H*clientRect.H)/2.0; foreach (MapIcon icon in _getIcons()) { if (ShouldSkipIcon(icon)) continue; float iZ = icon.Entity.GetComponent<Render>().Z; Vec2 point = minimapCenter + MapIcon.deltaInWorldToMinimapDelta(icon.WorldPosition - playerPos, diag, scale, (int) ((iZ - pPosZ)/20)); var texture = icon.MinimapIcon; int size = icon.Size; Rect rect = new Rect(point.X - size/2, point.Y - size/2, size, size); texture.DrawAt(rc, point, rect); } }
public virtual void DrawAt(RenderingContext rc, Vec2 point, Rect rect) { rc.AddTexture(this.TextureFile, rect, TintColor); }
public Vec2 ClientToScreen(Vec2 v) { Imports.ClientToScreen(this.handle, ref v); return v; }
public Vec2 ScreenToClient(Vec2 v) { Imports.ScreenToClient(this.handle, ref v); return v; }
private MenuItem GetChildAt(Vec2 pos) { foreach (MenuItem current in this.children) { if (current.TestHit(pos)) { return current; } } return null; }
private void RenderWeaponStats(RenderingContext rc, Rect clientRect) { const int innerPadding = 3; float aSpd = ((float)1000) / _weaponAttack.AttackDelay; int cntDamages = Enum.GetValues(typeof(DamageType)).Length; float[] doubleDpsPerStat = new float[cntDamages]; float physDmgMultiplier = 1; doubleDpsPerStat[(int)DamageType.Physical] = _weaponAttack.MaxDamage + _weaponAttack.MinDamage; foreach (RollValue roll in _explicitMods) { for (int iStat = 0; iStat < 4; iStat++) { IntRange range = roll.TheMod.StatRange[iStat]; if (range.Min == 0 && range.Max == 0) continue; StatsDat.StatRecord theStat = roll.TheMod.StatNames[iStat]; int val = roll.StatValue[iStat]; switch (theStat.Key) { case "physical_damage_+%": case "local_physical_damage_+%": physDmgMultiplier += val / 100f; break; case "local_attack_speed_+%": aSpd *= (100f + val) / 100; break; case "local_minimum_added_physical_damage": case "local_maximum_added_physical_damage": doubleDpsPerStat[(int)DamageType.Physical] += val; break; case "local_minimum_added_fire_damage": case "local_maximum_added_fire_damage": case "unique_local_minimum_added_fire_damage_when_in_main_hand": case "unique_local_maximum_added_fire_damage_when_in_main_hand": doubleDpsPerStat[(int)DamageType.Fire] += val; break; case "local_minimum_added_cold_damage": case "local_maximum_added_cold_damage": case "unique_local_minimum_added_cold_damage_when_in_off_hand": case "unique_local_maximum_added_cold_damage_when_in_off_hand": doubleDpsPerStat[(int)DamageType.Cold] += val; break; case "local_minimum_added_lightning_damage": case "local_maximum_added_lightning_damage": doubleDpsPerStat[(int)DamageType.Lightning] += val; break; case "unique_local_minimum_added_chaos_damage_when_in_off_hand": case "unique_local_maximum_added_chaos_damage_when_in_off_hand": case "local_minimum_added_chaos_damage": case "local_maximum_added_chaos_damage": doubleDpsPerStat[(int)DamageType.Chaos] += val; break; default: break; } } } doubleDpsPerStat[(int)DamageType.Physical] *= physDmgMultiplier; if (_quality > 0) doubleDpsPerStat[(int)DamageType.Physical] += (_weaponAttack.MaxDamage + _weaponAttack.MinDamage) * _quality / 100f; float pDps = doubleDpsPerStat[(int)DamageType.Physical] / 2 * aSpd; float eDps = 0; int firstEmg = 0; Color eDpsColor = Color.White; for(int i = 1; i < cntDamages; i++) { eDps += doubleDpsPerStat[i] / 2 * aSpd; if (doubleDpsPerStat[i] > 0) { if (firstEmg == 0) { firstEmg = i; eDpsColor = eleCols[i]; } else { eDpsColor = Color.DarkViolet; } } } Vec2 sz = new Vec2(); if (pDps > 0) sz = rc.AddTextWithHeight(new Vec2(clientRect.X + clientRect.W - Settings.OffsetInnerX, clientRect.Y + Settings.OffsetInnerY), pDps.ToString("#.#"), Color.White, Settings.DpsFontSize, DrawTextFormat.Right); Vec2 sz2 = new Vec2(); if( eDps > 0 ) sz2 = rc.AddTextWithHeight(new Vec2(clientRect.X + clientRect.W - Settings.OffsetInnerX, clientRect.Y + Settings.OffsetInnerY + sz.Y), eDps.ToString("#.#"), eDpsColor, Settings.DpsFontSize, DrawTextFormat.Right); rc.AddTextWithHeight(new Vec2(clientRect.X + clientRect.W - Settings.OffsetInnerX, clientRect.Y + Settings.OffsetInnerY + sz.Y + sz2.Y), "DPS", Color.White, 8, DrawTextFormat.Right); }
private static void drawElt(RenderingContext rc, Element root, Vec2 parent, ref int x, ref int yPos, int[] path, int depth = 0) { if ( /* !root.IsVisibleLocal || */ depth > MAX_DEPTH) { return; } var scale = root.Scale; Vec2f position = new Vec2f(parent.X + root.X * scale, parent.Y + root.Y * scale); Vec2 size = new Vec2((int)(root.Width * scale), (int)(root.Height * scale)); // if (rC.W < 20) return; string sPath = path[0].ToString("X3") + "-" + String.Join("-", path.Skip(1).Take(depth-1)); int ix = depth > 0 ? path[depth - 1] : 0; var c = Color.FromArgb(255, 255 - 25 * (ix % 10), 255 - 25 * ((ix % 100) / 10), 255); string msg = string.Format("[{2}] {1:X8} : {0} {3}", position, root.Address, sPath, size); var v = rc.AddTextWithHeight(new Vec2(x, yPos), msg, c, 9, DrawTextFormat.Left); rc.AddTextWithHeight(new Vec2f(position.X, position.Y + depth * 10 - 10), sPath, c, 8, DrawTextFormat.Left); // rc.AddTextWithHeightAndOutline(new Vec2(rC.X, rC.Y + depth * 10 - 10), sPath, c, Color.Black, 8, DrawTextFormat.Left); rc.AddFrame(new Rect(position, size), c); yPos += v.Y; if (yPos > 1100) { yPos = 80; x += 300; } position.Y += root.ScrollY * root.Scale; List<Element> children = root.Children; for (int i = 0; i < children.Count && i < MAX_CHILDREN; i++) { var elt = children[i]; path[depth] = i; drawElt(rc, elt, position, ref x, ref yPos, path, depth + 1); } }
protected override bool TestBounds(Vec2 pos) { return this.barBeingDragged >= 0 || base.TestBounds(pos); }
public static extern bool ClientToScreen(IntPtr hWnd, ref Vec2 lpPoint);
public static extern bool ScreenToClient(IntPtr hWnd, ref Vec2 lpPoint);
public bool HasPoint(Vec2 v) { return(HasPoint(v.X, v.Y)); }
private MenuItem GetChildAt(Vec2 pos) { return this.children.FirstOrDefault(current => current.TestHit(pos)); }
protected abstract void HandleEvent(MouseEventID id, Vec2 pos);
protected virtual bool TestBounds(Vec2 pos) { return this.Bounds.HasPoint(pos); }
public bool TestHit(Vec2 pos) { if (!this.isVisible) { return false; } if (this.TestBounds(pos)) { return true; } foreach (MenuItem current in this.children) { if (current.TestHit(pos)) { return true; } } return false; }
public float Dist(Vec2 other) { float num = (float)(other.X - this.X); float num2 = (float)(other.Y - this.Y); return (float)Math.Sqrt((double)(num * num + num2 * num2)); }
public Rect(Vec2 position, Vec2 size = default(Vec2)) { this = new Rect(position.X, position.Y, size.X, size.Y); }