Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions VillageHelper.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Element>().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 -= map.GetClientRectCache.Width/2;
chanceToDieTextPlacement.Y -= 25;

// Draw the chance to die
Graphics.DrawTextWithBackground(chanceToDieText, chanceToDieTextPlacement, chanceColor, FontAlign.Center, 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
{
< 45 => Settings.BadColor,
< 65 => Settings.NeutralColor,
_ => Settings.GoodColor
};

var chanceToCompleteText = $"{averageChance}%";
var chanceToCompleteTextSize = Graphics.MeasureText(chanceToCompleteText);
var chanceToCompleteTextPlacement = map.GetClientRectCache.BottomRight.ToVector2Num();
chanceToCompleteTextPlacement.X -= map.GetClientRectCache.Width/2;
chanceToCompleteTextPlacement.Y += 5;

// Draw the average chance to complete
Graphics.DrawTextWithBackground(chanceToCompleteText, chanceToCompleteTextPlacement, completionColor, FontAlign.Center, Color.Black);
}
}
}


}
}
private List<DrawItem> ComputeStatusOverlayDrawItems(VillageScreen villageScreen, int villageGold)
{
var result = new List<DrawItem>();
Expand Down
3 changes: 3 additions & 0 deletions VillageHelperSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> StatusOverlayXOffset { get; set; } = new RangeNode<int>(0, 0, 200);
public RangeNode<int> StatusOverlayYOffset { get; set; } = new RangeNode<int>(0, 0, 200);
public RangeNode<float> 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);
Expand Down