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
55 changes: 31 additions & 24 deletions AncestorQol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ public void RenderTribeTier()

public void RenderUnitTier()
{
if (GameController.Game.IngameState.UIHover?.Tooltip is not { IsVisible: true } &&
GameController.IngameState.IngameUi.AncestorMainShopWindow is { IsVisible: true, Options: { Count: > 0 } options })
if (GameController.IngameState.IngameUi.AncestorMainShopWindow is { IsVisible: true, Options: { Count: > 0 } options })
{
foreach (var option in options)
{
Expand All @@ -148,31 +147,39 @@ public void RenderUnitTier()
var tier = Settings.GetUnitTier(unit?.Id ?? item?.Id ?? string.Empty);
var unitNote = Settings.UnitNotes.GetValueOrDefault(unit?.Id ?? item?.Id ?? string.Empty);
var color = TierToColor(tier);
var tooltipDescription = (unit, item) switch
{
(_, { }) => string.Join("\n", option.Tooltip?.GetChildFromIndices(0, 0)?.Children.Where(x => x.IsVisible).Select(x => x.TextNoTags) ?? new List<string>()),
_ => option.Tooltip?.GetChildFromIndices(0, 0)?.TextNoTags,
};
if (string.IsNullOrWhiteSpace(tooltipDescription))
{
tooltipDescription = CleanDescriptionRegex.Replace(unit?.Description ?? string.Empty, "$1");
}

tooltipDescription = SentenceSplitRegex.Replace(LineEndingRegex.Replace(tooltipDescription, "\n\n"), ".\n");

var optionRect = option.GetClientRectCache;
var textPadding = Settings.FrameThickness + 2;
var rect = new Vector2(string.IsNullOrWhiteSpace(tooltipDescription) ? 0 : Graphics.MeasureText(tooltipDescription).X + textPadding * 2, optionRect.Height);
var topRight = optionRect.TopRight.ToVector2Num();
Graphics.DrawBox(topRight, topRight + rect, Color.Black);
Graphics.DrawFrame(topRight, topRight + rect, color, Settings.FrameThickness);
Graphics.DrawFrame(optionRect, color, Settings.FrameThickness);
Graphics.DrawText(tooltipDescription, topRight + new Vector2(textPadding), Color.White);
if (!string.IsNullOrEmpty(unitNote))
if (GameController.Game.IngameState.UIHover?.Tooltip is not { IsVisible: true })
{
var unitNoteRect = option[2]?.GetClientRectCache ?? default;
Graphics.DrawBox(unitNoteRect, Color.Black);
Graphics.DrawText(unitNote, unitNoteRect.TopLeft.ToVector2Num());
var tooltipDescription = (unit, item) switch
{
(_, { }) => string.Join("\n", option.Tooltip?.GetChildFromIndices(0, 0)?.Children.Where(x => x.IsVisible).Select(x => x.TextNoTags) ?? new List<string>()),
_ => option.Tooltip?.GetChildFromIndices(0, 0)?.TextNoTags,
};
if (string.IsNullOrWhiteSpace(tooltipDescription))
{
tooltipDescription = CleanDescriptionRegex.Replace(unit?.Description ?? string.Empty, "$1");
}
if (!Settings.ShowTooltip)
{
unitNote = string.Empty;
tooltipDescription = string.Empty;
}

tooltipDescription = SentenceSplitRegex.Replace(LineEndingRegex.Replace(tooltipDescription, "\n\n"), ".\n");

var textPadding = Settings.FrameThickness + 2;
var rect = new Vector2(string.IsNullOrWhiteSpace(tooltipDescription) ? 0 : Graphics.MeasureText(tooltipDescription).X + textPadding * 2, optionRect.Height);
var topRight = optionRect.TopRight.ToVector2Num();
Graphics.DrawBox(topRight, topRight + rect, Color.Black);
Graphics.DrawFrame(topRight, topRight + rect, color, Settings.FrameThickness);
Graphics.DrawText(tooltipDescription, topRight + new Vector2(textPadding), Color.White);
if (!string.IsNullOrEmpty(unitNote))
{
var unitNoteRect = option[2]?.GetClientRectCache ?? default;
Graphics.DrawBox(unitNoteRect, Color.Black);
Graphics.DrawText(unitNote, unitNoteRect.TopLeft.ToVector2Num());
}
}
}
catch (Exception ex)
Expand Down
1 change: 1 addition & 0 deletions AncestorQolSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public int GetTribeRewardTier(string tribeName)
public ColorNode Tier4Color { get; set; } = new(Color.Yellow);
public ColorNode Tier5Color { get; set; } = new(Color.Red);
public ToggleNode DrawTribeRewardFrameOverTheWholeElement { get; set; } = new ToggleNode(true);
public ToggleNode ShowTooltip { get; set; } = new ToggleNode(false);

[JsonIgnore]
public CustomNode Units { get; }
Expand Down