Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map quant / packsize values - update drawing #2

Merged
merged 2 commits into from
Apr 16, 2024
Merged
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
29 changes: 21 additions & 8 deletions Main/EvaluateItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,23 @@ public void Update()
continue;
}
#endregion
quantity += mod.Value1;
packSize += mod.Value3;

if (WarningDictionary.Where(x => mod.RawName.Contains(x.Key)).Any())
UpdateValueIfStatExists("map_pack_size_+%", x => packSize += x);
UpdateValueIfStatExists("map_item_drop_quantity_+%", x => quantity += x);

if (WarningDictionary.Where(x => mod.RawName.Contains(x.Key)).Any())
{
StyledText warning = WarningDictionary.Where(x => mod.RawName.Contains(x.Key)).FirstOrDefault().Value;
if (warning.Bricking || (settings.ShowQuantityPercent && quantity <= settings.MapQuantSetting) || (settings.ShowPackSizePercent && packSize <= settings.MapPackSetting))
var warning = WarningDictionary.Where(x => mod.RawName.Contains(x.Key)).FirstOrDefault().Value;
if (warning.Bricking || settings.ShowQuantityPercent && quantity <= settings.MapQuantSetting || settings.ShowPackSizePercent && packSize <= settings.MapPackSetting)
{
Bricked = true;
}

ActiveWarnings.Add(warning);

// if (mod.Name.Equals("warningmods"))
// {
// }
// if (mod.Name.Equals("warningmods"))
// {
// }
}

if (BadModsDictionary.Where(x => mod.RawName.Contains(x.Key)).Any())
Expand All @@ -245,6 +247,17 @@ public void Update()
// {
// }
}
void UpdateValueIfStatExists(string key, Action<int> updateAction)
{
var index = mod.ModRecord.StatNames
.Select((value, index) => new { value, index })
.FirstOrDefault(pair => pair.value.Key == key)?.index ?? -1;

if (index != -1)
{
updateAction(mod.Values[index]);
}
}
}
}

Expand Down
40 changes: 36 additions & 4 deletions Main/MapNotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ public override void Render()
{
if (!item.Item.HasComponent<ExileCore.PoEMemory.Components.Map>())
continue;

var rect = item.GetClientRectCache;
double deflatePercent = Settings.BorderDeflation;
var deflateWidth = (int)(rect.Width * (deflatePercent / 100.0));
var deflateHeight = (int)(rect.Height * (deflatePercent / 100.0));
rect.Inflate(-deflateWidth, -deflateHeight);

// Get the item's details component or create a new one if it doesn't exist
var itemDetails = item.Item.GetHudComponent<ItemDetails>() ?? new ItemDetails(item, item.Item);
item.Item.SetHudComponent(itemDetails);
Expand All @@ -391,7 +398,10 @@ public override void Render()
.Any(mod => WarningDictionary.Where(warning => mod.RawName.Contains(warning.Key)).Any()) == true)
{
// Draw a red frame around the item's bounding rectangle
Graphics.DrawFrame(item.GetClientRectCache, Settings.MapBorderWarnings.ToSharpColor(), Settings.BorderThicknessMap);
if (Settings.MapBorderStyle)
Graphics.DrawBox(rect, Settings.MapBorderWarnings.ToSharpColor(), Settings.BorderThicknessMap);
else
Graphics.DrawFrame(rect, Settings.MapBorderWarnings.ToSharpColor(), Settings.BorderThicknessMap);
}
}

Expand All @@ -403,7 +413,10 @@ public override void Render()
.Any(mod => BadModsDictionary.Where(bad => mod.RawName.Contains(bad.Key)).Any()) == true)
{
// Draw a red frame around the item's bounding rectangle
Graphics.DrawFrame(item.GetClientRectCache, Settings.MapBorderBad.ToSharpColor(), Settings.BorderThicknessMap);
if (Settings.MapBorderStyle)
Graphics.DrawBox(rect, Settings.MapBorderBad.ToSharpColor(), Settings.BorderThicknessMap);
else
Graphics.DrawFrame(rect, Settings.MapBorderBad.ToSharpColor(), Settings.BorderThicknessMap);
}
}
}
Expand All @@ -419,6 +432,19 @@ public override void Render()
if (!item.Item.HasComponent<ExileCore.PoEMemory.Components.Map>())
continue;

// Assuming `item.GetClientRectCache` returns a Rectangle object.
var rect = item.GetClientRectCache;

// Percentage by which to deflate (e.g., 5%).
double deflatePercent = Settings.BorderDeflation;

// Calculate the deflate values based on the current size.
int deflateWidth = (int)(rect.Width * (deflatePercent / 100.0));
int deflateHeight = (int)(rect.Height * (deflatePercent / 100.0));

// Use negative values to deflate the rectangle.
rect.Inflate(-deflateWidth, -deflateHeight);

// Get the item's details component or create a new one if it doesn't exist
var itemDetails = item.Item.GetHudComponent<ItemDetails>() ?? new ItemDetails(item, item.Item);
item.Item.SetHudComponent(itemDetails);
Expand All @@ -432,7 +458,10 @@ public override void Render()
.Any(mod => WarningDictionary.Where(warning => mod.RawName.Contains(warning.Key)).Any()) == true)
{
// Draw a red frame around the item's bounding rectangle
Graphics.DrawFrame(item.GetClientRectCache, Settings.MapBorderWarnings.ToSharpColor(), Settings.BorderThicknessMap);
if (Settings.MapBorderStyle)
Graphics.DrawBox(rect, Settings.MapBorderWarnings.ToSharpColor(), Settings.BorderThicknessMap);
else
Graphics.DrawFrame(rect, Settings.MapBorderWarnings.ToSharpColor(), Settings.BorderThicknessMap);
}
}

Expand All @@ -444,7 +473,10 @@ public override void Render()
.Any(mod => BadModsDictionary.Where(bad => mod.RawName.Contains(bad.Key)).Any()) == true)
{
// Draw a red frame around the item's bounding rectangle
Graphics.DrawFrame(item.GetClientRectCache, Settings.MapBorderBad.ToSharpColor(), Settings.BorderThicknessMap);
if (Settings.MapBorderStyle)
Graphics.DrawBox(rect, Settings.MapBorderBad.ToSharpColor(), Settings.BorderThicknessMap);
else
Graphics.DrawFrame(rect, Settings.MapBorderBad.ToSharpColor(), Settings.BorderThicknessMap);
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions Settings/DrawSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using ExileCore.PoEMemory.MemoryObjects;
using ExileCore.Shared.Nodes;
using ImGuiNET;
using SharpDX;
using nuVector2 = System.Numerics.Vector2;
using nuVector4 = System.Numerics.Vector4;

namespace MapNotify
Expand Down Expand Up @@ -41,7 +39,7 @@ public static int IntSlider(string labelString, RangeNode<int> setting)
public static nuVector4 ColorButton(string labelString, nuVector4 setting)
{
var refValue = setting;
ImGui.ColorEdit4(labelString, ref refValue);
ImGui.ColorEdit4(labelString, ref refValue, ImGuiColorEditFlags.AlphaPreviewHalf | ImGuiColorEditFlags.AlphaBar);
return refValue;
}

Expand Down Expand Up @@ -159,7 +157,7 @@ public override void DrawSettings()
if (Settings.ShowCompletion) Settings.ShowMapName.Value = true;
ImGui.SameLine(); HelpMarker("Requires map names.\nDisplays a red letter for each missing completion.\nA for Awakened Completion\nB for Bonus Completion\nC for Completion.");
Settings.ShowMapRegion.Value = Checkbox("Show Region Name", Settings.ShowMapRegion);
Settings.TargetRegions.Value = Checkbox("Enable Region Targetting ", Settings.TargetRegions);
Settings.TargetRegions.Value = Checkbox("Enable Region Targeting ", Settings.TargetRegions);
ImGui.SameLine(); HelpMarker("Open the Atlas and tick the regions you want to highlight. Requires Show Region Name.");
if (Settings.TargetRegions) Settings.ShowMapRegion.Value = true;
Settings.ShowModWarnings.Value = Checkbox("Show Mod Warnings", Settings.ShowModWarnings);
Expand All @@ -176,6 +174,10 @@ public override void DrawSettings()
if (ImGui.TreeNodeEx("Borders and Colours", ImGuiTreeNodeFlags.CollapsingHeader))
{

Settings.MapBorderStyle.Value = Checkbox("Map Item Draw Style", Settings.MapBorderStyle); ImGui.SameLine();
ImGui.SameLine(); HelpMarker("Frame = off, Box = on");

Settings.BorderDeflation.Value = IntSlider("Map Border Deflation##MapBorderDeflation", Settings.BorderDeflation);
Settings.BorderThickness.Value = IntSlider("Border Thickness##BorderThickness", Settings.BorderThickness);
Settings.BorderThickness.Value = IntSlider("Completion Border Thickness##BorderThickness", Settings.BorderThickness);

Expand Down
Loading