From 153b282296951750e540c03731952895056ac21a Mon Sep 17 00:00:00 2001 From: syrairc Date: Fri, 30 Aug 2024 12:17:13 -0500 Subject: [PATCH 1/2] Added an overlay that shows map completion % and mapper death % for each map in the Atlas runner interface. --- VillageHelper.cs | 110 +++++++++++++++++++++++++++++++++++++++ VillageHelperSettings.cs | 3 ++ 2 files changed, 113 insertions(+) diff --git a/VillageHelper.cs b/VillageHelper.cs index 4d86733..861a513 100644 --- a/VillageHelper.cs +++ b/VillageHelper.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; +using System.Configuration; using System.Globalization; using System.Linq; using System.Runtime.InteropServices.JavaScript; +using System.Text.RegularExpressions; using ExileCore; using ExileCore.PoEMemory; using ExileCore.PoEMemory.Components; @@ -302,10 +304,118 @@ public override void Render() } } } + + if (Settings.ShowAverageMapCompletionPercent || Settings.ShowMapperDeathChance) + { + + + if (GameController.IngameState.IngameUi.GetChildAtIndex(124) is + { + IsVisible: true + }) + { + ShowMapOverlay(GameController.IngameState.IngameUi.GetChildAtIndex(124)); + } + } } private record DrawItem(string Text, Color Color, Color BackgroundColor); + private void ShowMapOverlay(Element MapperScreen) + { + // Get the map "inventory" from the mapper screen + var Maps = MapperScreen.GetChildAtIndex(4)?.GetChildrenAs().Skip(1).ToList(); + + // Iterate over each map + foreach(var map in Maps) + { + + // Check if the map is visible and has a valid size + if (map is { IsVisible: true } && map.GetClientRectCache.Width > 0 && map.GetClientRectCache.Height > 0) + { + var tooltipText = map.Tooltip.GetChildAtIndex(1)?.TextNoTags; + + // Check if the map has a tooltip + if (tooltipText == null) + { + continue; + } + + string chanceToDie = ""; + string chanceToCompleteMin = ""; + string chanceToCompleteMax = ""; + Match match; + + if (Settings.ShowMapperDeathChance) + { + match = Regex.Match(tooltipText, @"(\d+)% chance for an Atlas Runner to be permanently killed in this Map"); + + if (match.Success) + { + chanceToDie = match.Groups[1].Value; + } + + // If no chance to die, skip + if (chanceToDie != "") + { + // Calculate the color based on the chance to die + var chanceColor = int.Parse(chanceToDie) switch + { + < 2 => Settings.GoodColor, + < 5 => Settings.NeutralColor, + _ => Settings.BadColor + }; + var chanceToDieText = $"{chanceToDie}%"; + var chanceToDieTextSize = Graphics.MeasureText(chanceToDieText); + var chanceToDieTextPlacement = map.GetClientRectCache.TopRight.ToVector2Num(); + chanceToDieTextPlacement.X -= (chanceToDieTextSize.X/2 + map.GetClientRectCache.Width/2); + chanceToDieTextPlacement.Y -= 25; + + // Draw the chance to die + Graphics.DrawTextWithBackground(chanceToDieText, chanceToDieTextPlacement, chanceColor, Color.Black); + } + } + + // Check if the map has a chance to complete + if (Settings.ShowAverageMapCompletionPercent) + { + + match = Regex.Match(tooltipText, @"Expected Map Completion: (\d+)-(\d+)%"); + if (match.Success) + { + chanceToCompleteMin = match.Groups[1].Value; + chanceToCompleteMax = match.Groups[2].Value; + } + + // If no chance to complete, skip + if (chanceToCompleteMin != "" && chanceToCompleteMax != "") + { + // Calculate the average chance to complete + var averageChance = (int.Parse(chanceToCompleteMin) + int.Parse(chanceToCompleteMax))/2; + + // Calculate the color based on the average chance to complete + var completionColor = averageChance switch + { + < 65 => Settings.BadColor, + < 85 => Settings.NeutralColor, + _ => Settings.GoodColor + }; + + var chanceToCompleteText = $"{averageChance}%"; + var chanceToCompleteTextSize = Graphics.MeasureText(chanceToCompleteText); + var chanceToCompleteTextPlacement = map.GetClientRectCache.BottomRight.ToVector2Num(); + chanceToCompleteTextPlacement.X -= chanceToCompleteTextSize.X;///2 + map.GetClientRectCache.Width/2); + chanceToCompleteTextPlacement.Y += 5; + + // Draw the average chance to complete + Graphics.DrawTextWithBackground(chanceToCompleteText, chanceToCompleteTextPlacement, completionColor, FontAlign.Center, Color.Black); + } + } + } + + + } + } private List ComputeStatusOverlayDrawItems(VillageScreen villageScreen, int villageGold) { var result = new List(); diff --git a/VillageHelperSettings.cs b/VillageHelperSettings.cs index 0b0fdd2..ef38629 100644 --- a/VillageHelperSettings.cs +++ b/VillageHelperSettings.cs @@ -18,11 +18,14 @@ public class VillageHelperSettings : ISettings public ToggleNode ShowEmptyResources { get; set; } = new ToggleNode(true); public ToggleNode ShowEmptyResourcesInColor { get; set; } = new ToggleNode(true); public ToggleNode ShowStatusOverlay { get; set; } = new ToggleNode(true); + public ToggleNode ShowAverageMapCompletionPercent { get; set; } = new ToggleNode(true); + public ToggleNode ShowMapperDeathChance { get; set; } = new ToggleNode(true); public RangeNode StatusOverlayXOffset { get; set; } = new RangeNode(0, 0, 200); public RangeNode StatusOverlayYOffset { get; set; } = new RangeNode(0, 0, 200); public RangeNode StatusOverlayUpdatePeriod { get; set; } = new(1, 0, 10); public ToggleNode ShowProjectedCurrentGold { get; set; } = new ToggleNode(false); + public ToggleNode ShowWorkerUpgradeTips { get; set; } = new ToggleNode(true); public ColorNode GoodColor { get; set; } = new ColorNode(Color.Green); public ColorNode NeutralColor { get; set; } = new ColorNode(Color.White); From a1349b7cd6662f9ae01006b6c0ba60a7bee74263 Mon Sep 17 00:00:00 2001 From: syrairc Date: Fri, 30 Aug 2024 12:24:25 -0500 Subject: [PATCH 2/2] Fixed text alignments on atlas runner interface. --- VillageHelper.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/VillageHelper.cs b/VillageHelper.cs index 861a513..fc3389c 100644 --- a/VillageHelper.cs +++ b/VillageHelper.cs @@ -368,11 +368,11 @@ private void ShowMapOverlay(Element MapperScreen) var chanceToDieText = $"{chanceToDie}%"; var chanceToDieTextSize = Graphics.MeasureText(chanceToDieText); var chanceToDieTextPlacement = map.GetClientRectCache.TopRight.ToVector2Num(); - chanceToDieTextPlacement.X -= (chanceToDieTextSize.X/2 + map.GetClientRectCache.Width/2); + chanceToDieTextPlacement.X -= map.GetClientRectCache.Width/2; chanceToDieTextPlacement.Y -= 25; // Draw the chance to die - Graphics.DrawTextWithBackground(chanceToDieText, chanceToDieTextPlacement, chanceColor, Color.Black); + Graphics.DrawTextWithBackground(chanceToDieText, chanceToDieTextPlacement, chanceColor, FontAlign.Center, Color.Black); } } @@ -396,15 +396,15 @@ private void ShowMapOverlay(Element MapperScreen) // Calculate the color based on the average chance to complete var completionColor = averageChance switch { - < 65 => Settings.BadColor, - < 85 => Settings.NeutralColor, + < 45 => Settings.BadColor, + < 65 => Settings.NeutralColor, _ => Settings.GoodColor }; var chanceToCompleteText = $"{averageChance}%"; var chanceToCompleteTextSize = Graphics.MeasureText(chanceToCompleteText); var chanceToCompleteTextPlacement = map.GetClientRectCache.BottomRight.ToVector2Num(); - chanceToCompleteTextPlacement.X -= chanceToCompleteTextSize.X;///2 + map.GetClientRectCache.Width/2); + chanceToCompleteTextPlacement.X -= map.GetClientRectCache.Width/2; chanceToCompleteTextPlacement.Y += 5; // Draw the average chance to complete