Snapshot for release 2026.10.31.4 (internal 34cea02)
This commit is contained in:
parent
057bb66426
commit
b1c182b05d
114 changed files with 8691 additions and 452 deletions
|
|
@ -14,7 +14,8 @@
|
|||
// highlights is laid out by hand (LayoutSpans) so each run can take its own
|
||||
// colour. Drag across lines to copy them (the keyboard stays with the game,
|
||||
// so copy is mouse-driven). Right-click a line to copy it or to make a rule
|
||||
// from it: move / copy lines like it to a tab, hide them, colour them. A line
|
||||
// from it: move / copy lines like it to a tab, hide them, colour or highlight
|
||||
// them (a "Highlight line" rule: a band behind the whole line). A line
|
||||
// with map coordinates in it ("42.1N, 33.6E") also offers "Arrow to" and "Go
|
||||
// to" them, sent to RynthNav (UI/Data/ChatCoords.cs finds them). The
|
||||
// coordinates are also drawn as underlined links: click points RynthNav's
|
||||
|
|
@ -638,6 +639,10 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
Vector2 p = basePos + new Vector2(0, _tops[i]);
|
||||
ChatLine line = _vis[i];
|
||||
ChatRoute route = line.Route;
|
||||
// A "Highlight line" rule: a band behind all of the line's rows, under the mention
|
||||
// tint and the selection. One rect, no allocation; _h[i] already spans every row.
|
||||
if (route.HighlightArgb is uint band)
|
||||
dl.AddRectFilled(p, p + new Vector2(wrapW + 6, _h[i]), RynthTheme.Argb(ChatColorModes.BandArgb(band)));
|
||||
if (route.Mention)
|
||||
dl.AddRectFilled(p, p + new Vector2(wrapW + 6, _h[i]), MentionBg);
|
||||
if (lo >= 0 && i >= lo && i <= hi)
|
||||
|
|
@ -1065,15 +1070,17 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
|
||||
// ── Rules from a line ────────────────────────────────────────────────
|
||||
|
||||
private void RuleFromLine(ChatRuleAction action, string? tab)
|
||||
private void RuleFromLine(ChatRuleAction action, string? tab, ChatColorMode colour = ChatColorMode.Line)
|
||||
{
|
||||
var rule = new ChatFilterRule { Pattern = _ctxPattern, Action = action, Tab = tab ?? "" };
|
||||
if (action == ChatRuleAction.Color)
|
||||
{
|
||||
rule.ColorMode = ChatColorMode.Line;
|
||||
rule.ColorMode = colour;
|
||||
ChatModel.AddRule(rule);
|
||||
if (!ImGuiPanelHost.IsOpen("ChatFilters")) PanelRouter.Toggle("ChatFilters");
|
||||
Flash("Rule added - pick its colour in Filters");
|
||||
Flash(colour == ChatColorMode.Highlight
|
||||
? "Rule added: lines like this are highlighted - pick its colour in Filters"
|
||||
: "Rule added - pick its colour in Filters");
|
||||
return;
|
||||
}
|
||||
ChatModel.AddRule(rule);
|
||||
|
|
@ -1486,6 +1493,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
TabMenu("Also show them in", ChatRuleAction.Copy);
|
||||
if (ImGuiNET.ImGui.MenuItem("Hide them")) RuleFromLine(ChatRuleAction.Hide, null);
|
||||
if (ImGuiNET.ImGui.MenuItem("Colour them…")) RuleFromLine(ChatRuleAction.Color, null);
|
||||
if (ImGuiNET.ImGui.MenuItem("Highlight them…")) RuleFromLine(ChatRuleAction.Color, null, ChatColorMode.Highlight);
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.MenuItem("Edit rules…") && !ImGuiPanelHost.IsOpen("ChatFilters"))
|
||||
PanelRouter.Toggle("ChatFilters");
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
//
|
||||
// [#] [on] [Contains v] [pattern ...................] [up] [down] [delete]
|
||||
// When [Any line v] [Move to v] [Junk v] [Colour line v] [swatch]
|
||||
// (colour: No colour / Colour line / Colour match / Highlight line)
|
||||
// (a regex error, a timed-out rule, a missing tab, or its hit count)
|
||||
//
|
||||
// The order and what each action does are spelled out in the header lines
|
||||
|
|
@ -84,7 +85,15 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
"Hide: the line is not shown anywhere (the chat log still has it).",
|
||||
"Colour only: no routing; the rule just colours.",
|
||||
};
|
||||
private static readonly string[] ColorLabels = { "No colour", "Colour line", "Colour match" };
|
||||
// Indexed by ChatColorMode.
|
||||
private static readonly string[] ColorLabels = { "No colour", "Colour line", "Colour match", "Highlight line" };
|
||||
private static readonly string[] ColorHelp =
|
||||
{
|
||||
"No colour: the rule doesn't colour the line.",
|
||||
"Colour line: the whole line's text in this colour.",
|
||||
"Colour match: just the text the rule matched, in this colour.",
|
||||
"Highlight line: a band in this colour behind the whole line; the text keeps its colour.",
|
||||
};
|
||||
private static readonly string[] ModeHelp =
|
||||
{
|
||||
"Regex: a case-insensitive regular expression (^ start, $ end, \\d+ a number...).",
|
||||
|
|
@ -116,7 +125,7 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
Label("Rules run top to bottom (" + PhosphorIcons.ArrowUp + PhosphorIcons.ArrowDown + " to reorder) on each line's text: plain text (any case) or a regex.", Mute);
|
||||
Label("Where it shows: Copy rules add a tab and go on; the first Move or Hide that matches decides.", Mute);
|
||||
Label("Colour: the first \"Colour line\" wins; \"Colour match\" colours every match (a higher rule wins an overlap).", Mute);
|
||||
Label("Colour: the first \"Colour line\" wins, and the first \"Highlight line\"; \"Colour match\" colours every match (a higher rule wins an overlap).", Mute);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 1));
|
||||
|
||||
|
|
@ -346,7 +355,7 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
|
||||
if (r.Action != ChatRuleAction.Hide)
|
||||
{
|
||||
int mode = (int)r.ColorMode;
|
||||
int mode = Math.Clamp((int)r.ColorMode, 0, ColorLabels.Length - 1);
|
||||
string colText = ColorLabels[mode] + Caret;
|
||||
Vector2 cPos = flow.Place(ButtonWidth(colText));
|
||||
if (Button("##colmode", colText, cPos, new Vector2(ButtonWidth(colText), rowH), Text, BtnFill))
|
||||
|
|
@ -354,8 +363,8 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
{
|
||||
rule.ColorMode = (ChatColorMode)k;
|
||||
ChatModel.FiltersChanged();
|
||||
}, 130);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Colour line: the whole line. Colour match: just the text the rule matched.");
|
||||
}, 140);
|
||||
SafeImGui.SetItemTooltip(ColorHelp[mode]);
|
||||
if (r.ColorMode != ChatColorMode.None)
|
||||
{
|
||||
Vector2 sPos = flow.Place(rowH);
|
||||
|
|
@ -629,6 +638,9 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
}
|
||||
uint color = RynthTheme.Argb(ChatLineColors.Resolve(route.LineArgb, ChatLineColors.KindOf(type, channel, text), channel, type));
|
||||
_testResult.Add((where + (route.LineArgb != null ? " (this is its colour)" : ""), route.Hidden ? Faded(Mute) : color));
|
||||
if (!route.Hidden && route.HighlightArgb is uint band)
|
||||
_testResult.Add(($"Highlighted: a {ChatModel.FormatColor(band | 0xFF000000)} band behind the line (this colour).",
|
||||
RynthTheme.Argb(band | 0xFF000000)));
|
||||
|
||||
// Not hidden: name a standard filter that would hide it (one not in the rules yet).
|
||||
if (!route.Hidden)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
// UiSources.LootEdit, shared with the Loot Editor): each rule
|
||||
// with its on/off gem, its action (Keep, Keep #, Salvage,
|
||||
// Sell, Read) and summary; move up / down, duplicate, delete,
|
||||
// add; Save and Reload; RynthAi's last message.
|
||||
// add; Why? (RynthAi's "Why this loot rule?" window for the
|
||||
// item selected in the game); Save and Reload; RynthAi's last
|
||||
// message.
|
||||
// A rule's conditions are written in the Loot Editor (the Editor plate opens it
|
||||
// on this file). Opening another file waits for unsaved changes to be saved or
|
||||
// reloaded (the Loot Editor asks about discarding them; this tab doesn't).
|
||||
|
|
@ -170,6 +172,11 @@ internal sealed class ClassicLootTab : IClassicTab
|
|||
if (Plate("##cl_add", "Add", new Vector2(x, y)) && editable)
|
||||
LootEditCommands.Simple("add", -1);
|
||||
SafeImGui.SetItemTooltip("Add a new rule at the end (write it in the Loot Editor)");
|
||||
x += Px(50);
|
||||
// The selected item, not the selected rule: RynthAi's "Why this loot rule?" window.
|
||||
if (x + Px(46) <= o.X + w && Plate("##cl_why", "Why?", new Vector2(x, y)))
|
||||
LootEditorFace.AskLootWhy();
|
||||
SafeImGui.SetItemTooltip(LootEditorFace.LootWhyLabel + "\n" + LootEditorFace.LootWhyTip);
|
||||
y += Px(21);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
// Monster Detail panel (weaknesses, accuracy, damage, summons, damage taken,
|
||||
// its rule). x removes the monster (confirmed). Gold = set by you, dim =
|
||||
// automatic.
|
||||
// Under a monster's row, when the plugin sends them (the row's "mstats",
|
||||
// UI/Data/DamageRowStats.cs, 2026-10-30): how often it evades and resists you
|
||||
// and you it since login, the full numbers on hover.
|
||||
// Where the server plugin reports difficulty tiers: a tier chip after Reset stats
|
||||
// (DamageView.Tier) - which tier the numbers are for, and a picker; "~" marks an
|
||||
// HP estimated from tier 0's. Hidden elsewhere.
|
||||
|
|
@ -97,6 +100,8 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
public string NameShown = "", NameTip = "";
|
||||
public string Weapon = "", Offhand = "", Pet = "", WeakTop = "", Sec = "", SecTip = "";
|
||||
public string Prefer = "Auto";
|
||||
/// <summary>The line under the row (the plugin's evades and resists since login) and its tooltip; "" for none.</summary>
|
||||
public string Stats = "", StatsTip = "";
|
||||
public bool CritSet, NonCritSet, WeaponGold, OffhandGold, PetGold, PreferGold;
|
||||
public string[] TierLines = Array.Empty<string>();
|
||||
/// <summary>Priority shown (int.MinValue = rules not loaded), whether it's the monster's own
|
||||
|
|
@ -361,6 +366,11 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
t.Sec = r.SecKill > 0 ? r.SecKill.ToString("0.0", inv) : "—";
|
||||
t.SecTip = (r.SecKill > 0 ? $"{r.SecKill:0.0} s from engaging to the kill (average of timed kills)." : "No timed kills yet.")
|
||||
+ (r.HitRate >= 0 ? $"\nHits: {r.HitRate * 100:0}% of attacks and casts landed." : "");
|
||||
if (r.Stats != null)
|
||||
{
|
||||
t.Stats = r.Stats.Line();
|
||||
t.StatsTip = r.Stats.Tip();
|
||||
}
|
||||
t.TierLines = new string[r.Tiers.Count];
|
||||
for (int i = 0; i < r.Tiers.Count; i++)
|
||||
{
|
||||
|
|
@ -756,29 +766,33 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
|
||||
// The line under a monster's row: the plugin's evades and resists since login (DamageRowStats).
|
||||
private const float StatsH = 16;
|
||||
|
||||
private void DrawRow(DamageRow r, Vector2 clipMin, Vector2 clipMax)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (p.Y + RowH < clipMin.Y || p.Y > clipMax.Y)
|
||||
RowText t = _text[r];
|
||||
float h = RowH + (t.Stats.Length > 0 ? StatsH : 0);
|
||||
if (p.Y + h < clipMin.Y || p.Y > clipMax.Y)
|
||||
{
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(TableW, RowH)); // off screen: keep the layout, skip the drawing
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(TableW, h)); // off screen: keep the layout, skip the drawing
|
||||
return;
|
||||
}
|
||||
RowText t = _text[r];
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
dl.AddRectFilled(p, p + new Vector2(TableW, RowH), r.IsDefault ? HeaderBg : RowBg);
|
||||
dl.AddRectFilled(p, p + new Vector2(TableW, h), r.IsDefault ? HeaderBg : RowBg);
|
||||
if (r.Targeted)
|
||||
{
|
||||
// The monster being fought (or selected): teal wash, a bar on the left, an outline.
|
||||
dl.AddRectFilled(p, p + new Vector2(TableW, RowH), TargetBg);
|
||||
dl.AddRectFilled(p, p + new Vector2(3, RowH), Teal);
|
||||
dl.AddRect(p, p + new Vector2(TableW, RowH), Teal);
|
||||
dl.AddRectFilled(p, p + new Vector2(TableW, h), TargetBg);
|
||||
dl.AddRectFilled(p, p + new Vector2(3, h), Teal);
|
||||
dl.AddRect(p, p + new Vector2(TableW, h), Teal);
|
||||
}
|
||||
else if (r.Nearby)
|
||||
{
|
||||
// On the player's landblock: a green wash and bar.
|
||||
dl.AddRectFilled(p, p + new Vector2(TableW, RowH), NearbyBg);
|
||||
dl.AddRectFilled(p, p + new Vector2(3, RowH), NearbyBar);
|
||||
dl.AddRectFilled(p, p + new Vector2(TableW, h), NearbyBg);
|
||||
dl.AddRectFilled(p, p + new Vector2(3, h), NearbyBar);
|
||||
}
|
||||
ImGuiNET.ImGui.PushID(r.IsDefault ? "default" : r.Key);
|
||||
float ty = p.Y + (RowH - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
|
|
@ -892,8 +906,21 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
}
|
||||
SafeImGui.SetItemTooltip("Remove " + r.Name + " from this list (asks first).");
|
||||
|
||||
if (t.Stats.Length > 0)
|
||||
{
|
||||
// Under the monster: its evades and resists both ways since login, the full numbers on hover.
|
||||
ImFontPtr small = ImGuiFonts.Get(UiFont.Ui10);
|
||||
var at = new Vector2(p.X + ColX[ColMonster] + 22, p.Y + RowH + (StatsH - small.FontSize) * 0.5f - 2);
|
||||
dl.PushClipRect(new Vector2(p.X, p.Y + RowH), new Vector2(p.X + TableW, p.Y + h), true);
|
||||
dl.AddText(small, small.FontSize, at, Dim, t.Stats);
|
||||
dl.PopClipRect();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X + ColX[ColMonster] + 22, p.Y + RowH));
|
||||
ImGuiNET.ImGui.InvisibleButton("##stats", new Vector2(Math.Max(1, TableW - ColX[ColMonster] - 26), StatsH));
|
||||
SafeImGui.SetItemTooltip(t.StatsTip);
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.PopID();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + RowH));
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + h));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(TableW, 0));
|
||||
}
|
||||
|
||||
|
|
@ -1442,7 +1469,7 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text), "Reset ALL learned damage statistics?");
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.Text),
|
||||
"Monster names and your settings (manual HP, weapon/offhand picks, debuffs) are KEPT — only the learned damage, crit, casts-to-kill, kills and HP are cleared. This cannot be undone.");
|
||||
"Monster names and your settings (manual HP, weapon/offhand picks, debuffs) are KEPT — only the learned damage, crit, casts-to-kill, kills and HP are cleared, and the evades and resists under each monster start over. This cannot be undone.");
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 6));
|
||||
float w = ImGuiNET.ImGui.GetContentRegionAvail().X;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ internal sealed class ItemsFace : IImGuiPanel
|
|||
"An entry whose item is gone but with an unlisted item of the same name in your pack\n" +
|
||||
"(a new stack of kits, a replacement weapon) is pointed at that item instead.\n" +
|
||||
"Does nothing while your inventory is still loading. Also: /ra items clean.");
|
||||
// The other way: everything in the pack that belongs here and isn't listed yet (answers in chat).
|
||||
AddSelected("##fill_from_pack", PhosphorIcons.Plus + " Add From Pack", "(weapons, healing kits, lockpicks, pet essences not listed yet)",
|
||||
() => RynthAiCommands.ApplyRemoteCommand("sendchat", "/ra items fill"),
|
||||
"Adds every weapon, healing kit, lockpick and pet essence in your pack that isn't listed yet.\nRynthAi says in chat what it added. Also: /ra items fill.");
|
||||
|
||||
// Weapons
|
||||
Section("Weapons", bw);
|
||||
|
|
|
|||
|
|
@ -158,6 +158,11 @@ internal sealed class LootEditorFace : IImGuiPanel
|
|||
public readonly byte[] Bytes = new byte[512];
|
||||
public string? Shown;
|
||||
public bool Active;
|
||||
// A text condition (TextPattern): the mode shown, the words in the box, and the pattern they were
|
||||
// read from (re-read only when the pattern changes, so a mode the player picked stays).
|
||||
public LootTextMode? Mode;
|
||||
public string Words = "";
|
||||
public string? ParsedFrom;
|
||||
}
|
||||
private readonly Dictionary<(int Cond, int Line), FieldBuffer> _fields = new();
|
||||
private readonly FieldBuffer _nameField = new(), _keepField = new();
|
||||
|
|
@ -758,10 +763,26 @@ internal sealed class LootEditorFace : IImGuiPanel
|
|||
? "A rule for the item selected in the game (click it first): preview, then add it here"
|
||||
: s.Dirty ? "Save or discard your edits first" : "This profile is read-only here");
|
||||
addW += itemW + 6;
|
||||
// RynthAi answers in its own "Why this loot rule?" window (an older RynthAi ignores it).
|
||||
string whyLabel = PhosphorIcons.Info + " " + LootWhyLabel;
|
||||
float whyW = ButtonWidth(whyLabel) + 6;
|
||||
if (Button("##loot_why", whyLabel, new Vector2(p.X + addW + 6, p.Y), new Vector2(whyW, h), Text, BtnFill))
|
||||
AskLootWhy();
|
||||
SafeImGui.SetItemTooltip(LootWhyTip);
|
||||
addW += whyW + 6;
|
||||
MessageText(new Vector2(p.X + addW + 8, p.Y), p.X + w - grip - 4, h);
|
||||
NextLine(p, h);
|
||||
}
|
||||
|
||||
/// <summary>The "Why this loot rule?" buttons (here and the Classic Loot tab).</summary>
|
||||
internal const string LootWhyLabel = "Why this loot rule?";
|
||||
internal const string LootWhyTip =
|
||||
"Which rule of the loot profile in use takes the item selected in the game, and why the rules above it\n" +
|
||||
"didn't (the first condition each failed, and the value it read). RynthAi shows it in a small window.\nAlso: /ra loot why";
|
||||
|
||||
/// <summary>RynthAi's "lootwhy" remote command: /ra loot why window, for the selected item. Any thread.</summary>
|
||||
internal static void AskLootWhy() => RynthAiCommands.ApplyRemoteCommand("lootwhy", "show");
|
||||
|
||||
private void MessageText(Vector2 at, float right, float h)
|
||||
{
|
||||
if (_msg.Length == 0 || (_msgOk && (DateTime.Now - _msgAt).TotalSeconds > 10)) return;
|
||||
|
|
@ -1110,14 +1131,13 @@ internal sealed class LootEditorFace : IImGuiPanel
|
|||
}
|
||||
case "keypattern":
|
||||
{
|
||||
float kw = w * 0.34f;
|
||||
float kw = w * 0.30f;
|
||||
IdPicker("##key", c, 1, KeyTable(node.KeyTable), "key", p, kw - 2, h, ro);
|
||||
if (Field("##pat", FieldFor(i, 0), c.Lines[0], new Vector2(p.X + kw + 2, p.Y), w - kw - 2, "pattern (regex)", ro, out string v, h))
|
||||
c.Lines[0] = v;
|
||||
TextPattern("##pat", c, i, new Vector2(p.X + kw + 2, p.Y), w - kw - 2, h, ro);
|
||||
break;
|
||||
}
|
||||
case "text":
|
||||
if (Field("##text", FieldFor(i, 0), c.Lines[0], p, w, "pattern (regex)", ro, out string t, h)) c.Lines[0] = t;
|
||||
TextPattern("##text", c, i, p, w, h, ro);
|
||||
break;
|
||||
default: // "value"
|
||||
if (Field("##value", FieldFor(i, 0), c.Lines[0], p, w, node.Labels.Count > 0 ? node.Labels[0].ToLowerInvariant() : "value", ro, out string n, h))
|
||||
|
|
@ -1188,6 +1208,62 @@ internal sealed class LootEditorFace : IImGuiPanel
|
|||
SafeImGui.SetItemTooltip(tip);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A text condition's pattern as a mode and plain words (2026-11-01: "people hate regex"): [contains v]
|
||||
/// [words]. The editor writes the regex (UI.LootPatternText) into the condition, so the profile stays a
|
||||
/// plain VTank .utl; "regex" shows the pattern itself. A mode the player picks stays while the pattern
|
||||
/// still reads back as it.
|
||||
/// </summary>
|
||||
private void TextPattern(string id, LootEditConditionDto c, int cond, Vector2 p, float w, float h, bool ro)
|
||||
{
|
||||
FieldBuffer buf = FieldFor(cond, 0);
|
||||
string pattern = c.Lines[0];
|
||||
if (!ReferenceEquals(buf.ParsedFrom, pattern))
|
||||
{
|
||||
var (mode, words) = LootPatternText.Parse(pattern);
|
||||
LootTextMode keep = buf.Mode ?? mode;
|
||||
if (keep == LootTextMode.Regex) { buf.Mode = LootTextMode.Regex; buf.Words = pattern; }
|
||||
else if (pattern.Length == 0) { buf.Mode = keep; buf.Words = ""; }
|
||||
else { buf.Mode = mode; buf.Words = mode == LootTextMode.Regex ? pattern : words; }
|
||||
buf.ParsedFrom = pattern;
|
||||
}
|
||||
LootTextMode shown = buf.Mode ?? LootTextMode.Contains;
|
||||
|
||||
float mw = Math.Min(120, Math.Max(80, w * 0.36f));
|
||||
if (PickerButton(id + "_mode", LootPatternText.Label(shown), p, mw - 2, h, ro))
|
||||
{
|
||||
FieldBuffer target = buf;
|
||||
LootEditConditionDto dto = c;
|
||||
_picker.Open(new Vector2(p.X, p.Y + h), LootPatternText.Labels, (int)shown, k =>
|
||||
{
|
||||
LootTextMode next = LootPatternText.Modes[k];
|
||||
LootTextMode was = target.Mode ?? LootTextMode.Contains;
|
||||
if (next == was || dto.Lines.Count == 0) return;
|
||||
// Into regex: the pattern as it is. Out of regex: its words when it has a plain shape.
|
||||
string words = next == LootTextMode.Regex ? dto.Lines[0]
|
||||
: was == LootTextMode.Regex ? (LootPatternText.Parse(dto.Lines[0]) is var (m2, w2) && m2 != LootTextMode.Regex ? w2 : "")
|
||||
: target.Words;
|
||||
dto.Lines[0] = LootPatternText.Build(next, words);
|
||||
target.Mode = next;
|
||||
target.Words = words;
|
||||
target.ParsedFrom = dto.Lines[0];
|
||||
target.Shown = null; // the box shows the new words
|
||||
}, Math.Max(150, mw));
|
||||
}
|
||||
SafeImGui.SetItemTooltip("How the text is matched (case doesn't matter). Pick \"regex\" to type a pattern yourself.");
|
||||
|
||||
if (Field(id, buf, buf.Words, new Vector2(p.X + mw, p.Y), w - mw, LootPatternText.Hint(shown), ro, out string typed, h))
|
||||
{
|
||||
buf.Words = typed;
|
||||
c.Lines[0] = LootPatternText.Build(shown, typed);
|
||||
buf.ParsedFrom = c.Lines[0];
|
||||
}
|
||||
if (shown != LootTextMode.Regex)
|
||||
SafeImGui.SetItemTooltip(c.Lines[0].Length > 0
|
||||
? "Written to the profile as: " + c.Lines[0] + (shown is LootTextMode.Contains or LootTextMode.NotContains ? "\nSeveral words: separate them with commas (either of them)." : "")
|
||||
: (shown is LootTextMode.Contains or LootTextMode.NotContains ? "Type a word. Several: separate them with commas (either of them)." : "Type the text."));
|
||||
}
|
||||
|
||||
/// <summary>A whole number: "45", "45.0" (a buffed-long value written as a double).</summary>
|
||||
private static bool TryWhole(string? raw, out int value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
// RynthCore.Engine - ImGui/Panels/LuaFace.cs
|
||||
// ImGui face of the Lua panel. Two layouts, picked by the payload:
|
||||
//
|
||||
// RynthLua v2 (ScriptInfos present), tabs "Scripts" | "Editor", and on the
|
||||
// right "N running · RynthAi: loaded / not loaded":
|
||||
// RynthLua v2 (ScriptInfos present), tabs "Scripts" | "Editor", "Live reload:
|
||||
// on/off" (a RynthLua with live reload; /lua livereload), and on the right
|
||||
// "N running · RynthAi: loaded / not loaded":
|
||||
// Scripts one row per script: running dot, name, description, autostart
|
||||
// (Off / global / this character), Run|Stop, Restart. Click a row
|
||||
// to select it; below, the selected script's state, "Open in
|
||||
|
|
@ -161,13 +162,37 @@ internal sealed class LuaFace : IImGuiPanel
|
|||
if (Button("##tab_editor", EditorTab, new Vector2(p.X + sw + 2, p.Y), new Vector2(ew, h), _editorTab ? Teal : Text, _editorTab ? Selected : BtnFill))
|
||||
_editorTab = true;
|
||||
|
||||
// RynthLua's live reload (a RynthLua that has it says so in the payload): /lua livereload on|off.
|
||||
float lrW = 0;
|
||||
if (LuaLiveReload.Label(d.LiveReload) is { } lrLabel)
|
||||
{
|
||||
bool on = d.LiveReload == true;
|
||||
string caption = PhosphorIcons.ArrowsClockwise + " " + lrLabel;
|
||||
lrW = ButtonWidth(caption) + 4;
|
||||
if (Button("##lua_live", caption, new Vector2(p.X + sw + ew + 8, p.Y), new Vector2(lrW, h), on ? Teal : Mute, on ? Selected : BtnFill))
|
||||
LuaCommands.Chat(LuaLiveReload.ClickArgs(on));
|
||||
SafeImGui.SetItemTooltip(LuaLiveReload.Tip(on));
|
||||
lrW += 6;
|
||||
}
|
||||
// Stop every running script (/lua stop all), while two or more run.
|
||||
if (d.RunningCount > 1 && d.ScriptInfos is { } running)
|
||||
{
|
||||
const string StopAll = PhosphorIcons.Stop + " Stop all";
|
||||
float saW = ButtonWidth(StopAll) + 4;
|
||||
if (Button("##lua_stopall", StopAll, new Vector2(p.X + sw + ew + 8 + lrW, p.Y), new Vector2(saW, h), Text, StopBg))
|
||||
foreach (LuaScriptInfo si in running)
|
||||
if (si.Running) LuaCommands.Send("stopScript", si.Name);
|
||||
SafeImGui.SetItemTooltip("Stop every running script. Also: /lua stop all");
|
||||
lrW += saW + 6;
|
||||
}
|
||||
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
bool ai = d.RynthAi == true;
|
||||
string run = d.RunningCount == 1 ? "1 running" : $"{d.RunningCount} running";
|
||||
const string sep = " · ";
|
||||
string aiText = ai ? "RynthAi: loaded" : "RynthAi: not loaded";
|
||||
float runW = ImGuiNET.ImGui.CalcTextSize(run).X, sepW = ImGuiNET.ImGui.CalcTextSize(sep).X, aiW = ImGuiNET.ImGui.CalcTextSize(aiText).X;
|
||||
float left = p.X + sw + ew + 10, right = p.X + w;
|
||||
float left = p.X + sw + ew + 10 + lrW, right = p.X + w;
|
||||
float x = Math.Max(left, right - runW - sepW - aiW);
|
||||
float ty = p.Y + (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f;
|
||||
dl.PushClipRect(new Vector2(left, p.Y), new Vector2(right, p.Y + h), true);
|
||||
|
|
|
|||
|
|
@ -691,6 +691,20 @@ internal sealed partial class MetaFace
|
|||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
bool canRevert = _editOriginal != null && !MetaRuleEdit.SameContent(_editRule, _editOriginal);
|
||||
string problem = SaveProblem();
|
||||
float problemX = p.X;
|
||||
if (canRevert) problemX += BtnW(PhosphorIcons.ArrowCounterClockwise + " Revert", 60) + 6;
|
||||
if (problem.Length > 0 && !_editConfirmDelete)
|
||||
{
|
||||
// The editor's status line: why the last change isn't saved (the full text on hover).
|
||||
string del = PhosphorIcons.Trash + (_editIndex < 0 ? " Discard" : " Delete rule");
|
||||
float room = p.X + w - BtnW(del, 70) - 6 - problemX;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
dl.AddText(new Vector2(problemX, p.Y + (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Red, Fit(problem, Math.Max(20, room)));
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
if (ImGuiNET.ImGui.IsWindowHovered() && ImGuiNET.ImGui.IsMouseHoveringRect(new Vector2(problemX, p.Y), new Vector2(problemX + Math.Max(20, room), p.Y + h)))
|
||||
ImGuiNET.ImGui.SetTooltip(problem);
|
||||
}
|
||||
if (canRevert)
|
||||
{
|
||||
string label = PhosphorIcons.ArrowCounterClockwise + " Revert";
|
||||
|
|
@ -702,7 +716,7 @@ internal sealed partial class MetaFace
|
|||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Undo every change since you opened this rule (and save that)");
|
||||
}
|
||||
else
|
||||
else if (problem.Length == 0)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
dl.AddText(new Vector2(p.X, p.Y + (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Faded(Mute),
|
||||
|
|
|
|||
|
|
@ -207,15 +207,18 @@ internal sealed partial class MetaFace
|
|||
FilterRow(w);
|
||||
|
||||
// A note over the list: the editor closed under a meta switch, or the meta can't do anything.
|
||||
string note = string.Empty;
|
||||
if (_listNote.Length > 0 && NowMs - _listNoteAt < 8000) note = _listNote;
|
||||
// A change that wasn't saved comes first, in red, and stays until the next result (2026-11-01).
|
||||
string note = SaveProblem();
|
||||
bool unsaved = note.Length > 0;
|
||||
if (unsaved) { }
|
||||
else if (_listNote.Length > 0 && NowMs - _listNoteAt < 8000) note = _listNote;
|
||||
else if (_data.Rules.Count > 0 && !HasRulesIn(_data.CurrentState))
|
||||
note = $"The current state, {_data.CurrentState}, has no rules: the meta does nothing until something changes the state.";
|
||||
if (note.Length > 0)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, unsaved ? Red : Amber);
|
||||
ImGuiNET.ImGui.TextUnformatted(note);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
|
|
|
|||
|
|
@ -102,8 +102,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
// ── Saving ───────────────────────────────────────────────────────────
|
||||
private readonly MetaAutosave _autosave = new();
|
||||
private readonly MetaBackupPlan _backup = new();
|
||||
private long _saveSentAt = -1; // ms (TickCount64) of the last rule command, for "Saving..."
|
||||
private long _saveSentVersion; // the snapshot version then
|
||||
private readonly MetaSaveWatch _saveWatch = new(); // waits for RynthAi's answer to each change
|
||||
private static long NowMs => Environment.TickCount64;
|
||||
|
||||
// ── Rule editor ──────────────────────────────────────────────────────
|
||||
|
|
@ -145,6 +144,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
UiSources.Meta.RequestRefresh();
|
||||
CodeEditor.SetMetaVocabulary(MetaVocabulary.StructKeywords, MetaVocabulary.ConditionKeywords, MetaVocabulary.ActionKeywords);
|
||||
_backup.NewSession(); // a new editing session: the first save backs the file up again
|
||||
_saveWatch.Reset();
|
||||
}
|
||||
|
||||
public void OnHidden()
|
||||
|
|
@ -271,8 +271,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
// Saving over another meta keeps that one's old copy as <file>.bak.
|
||||
MetaCommands.Backup(target, MetaBackupPlan.BackupOf(target));
|
||||
MetaCommands.Simple("save_file", path: target);
|
||||
_saveSentAt = NowMs;
|
||||
_saveSentVersion = _seenVersion;
|
||||
_saveWatch.Sent(NowMs, SeenSaveSeq, MetaCommands.Undelivered);
|
||||
}
|
||||
_saveAs = false;
|
||||
}
|
||||
|
|
@ -324,6 +323,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
{
|
||||
float m = Math.Max(ImGuiNET.ImGui.CalcTextSize(SavedText).X, ImGuiNET.ImGui.CalcTextSize(SavingText).X);
|
||||
m = Math.Max(m, Math.Max(ImGuiNET.ImGui.CalcTextSize(EditingText).X, ImGuiNET.ImGui.CalcTextSize(NoFileText).X));
|
||||
m = Math.Max(m, ImGuiNET.ImGui.CalcTextSize(UnconfirmedText).X);
|
||||
if (editor) m = Math.Max(m, ImGuiNET.ImGui.CalcTextSize(DraftText).X);
|
||||
return m + 6;
|
||||
}
|
||||
|
|
@ -339,10 +339,37 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
return _editTyping
|
||||
? (EditingText, Amber, "Saves when you leave the box (Enter, Tab or click elsewhere).")
|
||||
: (SavingText, Amber, "Saving in a moment...");
|
||||
if (_saveSentAt >= 0 && _seenVersion == _saveSentVersion && NowMs - _saveSentAt < 2500)
|
||||
return (SavingText, Amber, "Saving " + file + "...");
|
||||
switch (_saveWatch.State(NowMs, _data.SaveResult, MetaCommands.Undelivered))
|
||||
{
|
||||
case MetaSaveState.Saving:
|
||||
return (SavingText, Amber, "Saving " + file + "...");
|
||||
case MetaSaveState.Failed:
|
||||
case MetaSaveState.NotSent:
|
||||
return (NoFileText, Red, SaveProblem());
|
||||
case MetaSaveState.Unconfirmed:
|
||||
return (UnconfirmedText, Amber, SaveProblem());
|
||||
}
|
||||
string bak = System.IO.Path.GetFileName(MetaBackupPlan.BackupOf(MetaBackupPlan.WrittenFile(_data.CurrentMetaPath!)));
|
||||
return (SavedText, Green, $"Every change saves to {file} on its own. The first change after opening this panel keeps the file as it was in {bak}.");
|
||||
string last = _data.SaveResult is { Seq: > 0, Text.Length: > 0 } r ? $"\nLast: {r.Text}" : "";
|
||||
return (SavedText, Green, $"Every change saves to {file} on its own. The first change after opening this panel keeps the file as it was in {bak}.{last}");
|
||||
}
|
||||
|
||||
private const string UnconfirmedText = PhosphorIcons.Warning + " Not confirmed";
|
||||
|
||||
/// <summary>The result seq the panel has seen (0: none, or a RynthAi without results).</summary>
|
||||
private long SeenSaveSeq => _data.SaveResult?.Seq ?? 0;
|
||||
|
||||
/// <summary>Why the last change isn't saved, for the status line and the indicator's tooltip; empty when it is.</summary>
|
||||
private string SaveProblem()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_data.CurrentMetaPath)) return string.Empty; // "Not saved" + its own hint
|
||||
return _saveWatch.State(NowMs, _data.SaveResult, MetaCommands.Undelivered) switch
|
||||
{
|
||||
MetaSaveState.Failed => _data.SaveResult!.Text,
|
||||
MetaSaveState.NotSent => "Not saved: the change never reached RynthAi (it isn't loaded, or is too old for this panel). Reload RynthAi and make the change again.",
|
||||
MetaSaveState.Unconfirmed => "RynthAi hasn't confirmed the last change. If this stays, it may not have been saved: check the rule after reopening the meta.",
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The save status, right-aligned in (pos, width); hover for details.</summary>
|
||||
|
|
@ -360,15 +387,14 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
|
||||
/// <summary>
|
||||
/// Every command that changes the meta's rules goes through here: before the first one of this
|
||||
/// session the file is backed up, and the indicator shows "Saving..." until the next snapshot.
|
||||
/// (RynthAi writes the file after each such command.)
|
||||
/// session the file is backed up, and the indicator shows "Saving..." until RynthAi answers
|
||||
/// (MetaSaveWatch; RynthAi writes the file after each such command and reports the result).
|
||||
/// </summary>
|
||||
private void SendEdit(MetaCmd cmd)
|
||||
{
|
||||
if (_backup.Before(_data.CurrentMetaPath) is { } b) MetaCommands.Backup(b.File, b.Backup);
|
||||
MetaCommands.Send(cmd);
|
||||
_saveSentAt = NowMs;
|
||||
_saveSentVersion = _seenVersion;
|
||||
_saveWatch.Sent(NowMs, SeenSaveSeq, MetaCommands.Undelivered);
|
||||
}
|
||||
|
||||
private void BeginSaveAs()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
// Recall / Clear / Save / Dungeon Patrol, the route editor (move / duplicate /
|
||||
// delete / set active / move here on the selection; nearest, reverse, snap to
|
||||
// path, point at selection, pause, simplify; recording and trail -> route),
|
||||
// a chat waypoint, Save As, the nav file picker, the nav point reach
|
||||
// a chat waypoint, Save As, the nav file picker (at the top), the nav point reach
|
||||
// (RynthAi's FollowNavMin, the same row as Settings > Navigation), and the
|
||||
// waypoint list (click selects, Ctrl/Shift-click multi-selects, double-click
|
||||
// sets active, right-click edits, X or Delete deletes, => marks the active one).
|
||||
|
|
@ -56,6 +56,7 @@ internal sealed class NavFace : IImGuiPanel
|
|||
{
|
||||
PhosphorIcons.NavigationArrow + " Nearest", PhosphorIcons.ArrowsClockwise + " Reverse", PhosphorIcons.Path + " Snap to Path",
|
||||
PhosphorIcons.MapPin + " Point at Selected", PhosphorIcons.Hourglass + " Add Pause", PhosphorIcons.Scissors + " Simplify",
|
||||
PhosphorIcons.ArrowCounterClockwise + " Restart",
|
||||
};
|
||||
private static readonly string[] RowMenu =
|
||||
{ "Set Active", "Move Here", "Move Up", "Move Down", "Duplicate", "Delete" };
|
||||
|
|
@ -110,6 +111,19 @@ internal sealed class NavFace : IImGuiPanel
|
|||
bool typing = false;
|
||||
NavPayload d = _data;
|
||||
bool navActive = d.MacroRunning && d.NavigationEnabled;
|
||||
Vector2 p;
|
||||
|
||||
// Nav file picker, first (2026-11-01, the owner: "move the nav file selection to the top")
|
||||
if (_navFiles.Length > 0)
|
||||
{
|
||||
p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float lw = ImGuiNET.ImGui.CalcTextSize("Nav:").X + 6;
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddText(new Vector2(p.X, p.Y + (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Mute, "Nav:");
|
||||
if (Button("##navfile", _fileLabel, new Vector2(p.X + lw, p.Y), new Vector2(w - lw, 22), Text, BtnFill, leftAlign: true))
|
||||
_picker.Open(new Vector2(p.X + lw, p.Y + 22), _navFiles, Array.IndexOf(_navFiles, _data.ActiveNavName), i =>
|
||||
NavCommands.Send(new NavCmd { Cmd = "loadNav", NavName = _navFiles[i] }));
|
||||
NextLine(p, 26);
|
||||
}
|
||||
|
||||
// Active nav + status
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.UiBold11));
|
||||
|
|
@ -118,7 +132,7 @@ internal sealed class NavFace : IImGuiPanel
|
|||
if (d.NavStatusLine.Length > 0) Label(d.NavStatusLine, d.NavIsStuck ? Amber : Green);
|
||||
|
||||
// Start / Stop
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (Button("##startstop", navActive ? StopNav : StartNav, p, new Vector2(w, 28), Text, navActive ? StopBg : StartBg))
|
||||
{
|
||||
if (navActive)
|
||||
|
|
@ -258,18 +272,6 @@ internal sealed class NavFace : IImGuiPanel
|
|||
}
|
||||
NextLine(p, 26);
|
||||
|
||||
// Nav file picker
|
||||
if (_navFiles.Length > 0)
|
||||
{
|
||||
p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float lw = ImGuiNET.ImGui.CalcTextSize("Nav:").X + 6;
|
||||
ImGuiNET.ImGui.GetWindowDrawList().AddText(new Vector2(p.X, p.Y + (22 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Mute, "Nav:");
|
||||
if (Button("##navfile", _fileLabel, new Vector2(p.X + lw, p.Y), new Vector2(w - lw, 22), Text, BtnFill, leftAlign: true))
|
||||
_picker.Open(new Vector2(p.X + lw, p.Y + 22), _navFiles, Array.IndexOf(_navFiles, _data.ActiveNavName), i =>
|
||||
NavCommands.Send(new NavCmd { Cmd = "loadNav", NavName = _navFiles[i] }));
|
||||
NextLine(p, 26);
|
||||
}
|
||||
|
||||
// Waypoints
|
||||
Separator(w);
|
||||
Label($"Waypoints ({_data.Points.Count})", Mute);
|
||||
|
|
@ -441,6 +443,10 @@ internal sealed class NavFace : IImGuiPanel
|
|||
_picker.Open(at, NavCommands.SimplifyLabels, -1, i =>
|
||||
NavCommands.Send(new NavCmd { Cmd = "simplifyRoute", Yards = NavCommands.SimplifyYards[i] }), width: 300);
|
||||
break;
|
||||
case 6:
|
||||
// Run the route again from its first point (a finished Once route too); answers in chat.
|
||||
RynthAiCommands.ApplyRemoteCommand("sendchat", "/ra nav restart");
|
||||
break;
|
||||
}
|
||||
|
||||
// Record | Route from Trail...
|
||||
|
|
@ -456,7 +462,11 @@ internal sealed class NavFace : IImGuiPanel
|
|||
Vector2 tp = new(p.X + half + 4, p.Y);
|
||||
if (Button("##fromtrail", FromTrail, tp, new Vector2(half, 22), Text, BtnFill, enabled: _data.TrailPoints >= 2))
|
||||
_picker.Open(new Vector2(tp.X, tp.Y + 22), NavCommands.TrailChoices, -1, i =>
|
||||
NavCommands.Send(new NavCmd { Cmd = "trailToRoute", Reverse = i == 1 }), width: 300);
|
||||
{
|
||||
// The last choice wipes the trail (/ra navtrail clear); the others make a route of it.
|
||||
if (i == NavCommands.TrailClearChoice) RynthAiCommands.ApplyRemoteCommand("sendchat", "/ra navtrail clear");
|
||||
else NavCommands.Send(new NavCmd { Cmd = "trailToRoute", Reverse = i == 1 });
|
||||
}, width: 300);
|
||||
if (ImGuiNET.ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
|
||||
SafeImGui.SetTooltip(_data.TrailPoints >= 2
|
||||
? $"Breadcrumb trail: {_data.TrailPoints} crumbs, {_data.TrailYards:0} yd.\nThe new route is unsaved; the loaded nav file is not changed."
|
||||
|
|
|
|||
|
|
@ -210,15 +210,31 @@ internal sealed unsafe class LogFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Tracker: the session-stat rows (TrackerSource) over an adjustable-opacity background.</summary>
|
||||
/// <summary>
|
||||
/// Tracker: the session-stat rows (TrackerSource) over an adjustable-opacity background, or text only
|
||||
/// (TrackerSettings.TextOnly: bare, the rows shadowed, clicks pass through except over them).
|
||||
/// </summary>
|
||||
internal sealed class TrackerFace : IImGuiPanel
|
||||
{
|
||||
private static readonly Vector4 TitleColor = RynthTheme.Vec(0xFFE6B450);
|
||||
private static readonly Vector4 LabelColor = RynthTheme.Vec(0xFF999999);
|
||||
private static readonly uint ResetBg = RynthTheme.Argb(0xFF1A2E40);
|
||||
private static uint ResetBorder => RynthTheme.AccentFill;
|
||||
// Text only: no background behind it, so brighter than the framed look, each with a shadow.
|
||||
private static readonly uint BareLabel = RynthTheme.Argb(0xFFCFCFCF);
|
||||
private static readonly uint BareValue = RynthTheme.Argb(0xFFFFFFFF);
|
||||
private static readonly uint BareShadow = RynthTheme.Argb(0xD0000000);
|
||||
private int _opacity;
|
||||
|
||||
// Text only: the mouse is over what the last frame drew, so the window takes input (to drag it, or
|
||||
// for the frame button); elsewhere clicks reach the game. A press that began there keeps it.
|
||||
private bool _hot, _pressHot;
|
||||
|
||||
/// <summary>Text only is bare: docked, no frame, title, background or grip (popped out it is framed as usual).</summary>
|
||||
public bool Bare => TrackerSettings.TextOnly;
|
||||
|
||||
public bool ClickThrough => Bare && !_hot && !_pressHot;
|
||||
|
||||
public void OnShown()
|
||||
{
|
||||
UiSources.Tracker.Subscribe();
|
||||
|
|
@ -229,6 +245,90 @@ internal sealed class TrackerFace : IImGuiPanel
|
|||
public void OnHidden() => UiSources.Tracker.Unsubscribe();
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (TrackerSettings.TextOnly && !ImGuiPanelHost.DrawingEmbedded && !ImGuiPopOuts.InPopOutFrame)
|
||||
{
|
||||
DrawTextOnly();
|
||||
return;
|
||||
}
|
||||
_hot = _pressHot = false;
|
||||
DrawFramed();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Text only: each row's label and value with a 1 px shadow, nothing behind them. The rows are a
|
||||
/// drag handle; the button at the end of the first row (faint until the mouse is on the rows)
|
||||
/// brings the frame back.
|
||||
/// </summary>
|
||||
private void DrawTextOnly()
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
Vector2 origin = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float width = Math.Max(60, ImGuiNET.ImGui.GetContentRegionAvail().X);
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetIO().MousePos;
|
||||
bool wasHot = _hot;
|
||||
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
float rowH = ImGuiNET.ImGui.GetTextLineHeight() + 1;
|
||||
float buttonW = rowH + 4;
|
||||
TrackerSnapshot? snap = UiSources.Tracker.Current?.Value;
|
||||
string[]? values = snap?.Values;
|
||||
string[] labels = snap?.Labels ?? TrackerSnapshot.DefaultLabels;
|
||||
ImFontPtr labelFont = ImGuiNET.ImGui.GetFont();
|
||||
float labelSize = ImGuiNET.ImGui.GetFontSize();
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Mono9));
|
||||
ImFontPtr valueFont = ImGuiNET.ImGui.GetFont();
|
||||
float valueSize = ImGuiNET.ImGui.GetFontSize();
|
||||
float y = origin.Y;
|
||||
for (int i = 0; i < labels.Length; i++)
|
||||
{
|
||||
// The first row stops short of the frame button.
|
||||
float right = origin.X + width - (i == 0 ? buttonW + 2 : 0);
|
||||
Shadowed(dl, labelFont, labelSize, new Vector2(origin.X, y), BareLabel, labels[i]);
|
||||
string value = values != null && i < values.Length ? values[i] : "—";
|
||||
float w = ImGuiNET.ImGui.CalcTextSize(value).X;
|
||||
Shadowed(dl, valueFont, valueSize, new Vector2(Math.Max(origin.X, right - w), y), BareValue, value);
|
||||
y += rowH;
|
||||
}
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
float height = Math.Max(rowH, y - origin.Y);
|
||||
|
||||
// The rows: a drag handle (the window has no title bar to hold).
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(origin);
|
||||
ImGuiNET.ImGui.InvisibleButton("##tracker_textonly_drag", new Vector2(Math.Max(1, width - buttonW - 2), height));
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
if (ImGuiNET.ImGui.IsItemHovered() && !ImGuiNET.ImGui.IsItemActive())
|
||||
ImGuiNET.ImGui.SetTooltip("Drag to move the Tracker.");
|
||||
|
||||
// Frame button: faint until the mouse is on the rows.
|
||||
Vector2 bp = new(origin.X + width - buttonW, origin.Y);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(bp);
|
||||
float alpha = wasHot ? 1f : 0.35f;
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.Alpha, alpha);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(1, 0));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Button, ResetBg);
|
||||
if (ImGuiNET.ImGui.Button(PhosphorIcons.SquaresFour + "##tracker_frame", new Vector2(buttonW, rowH)))
|
||||
TrackerSettings.SetTextOnly(false);
|
||||
ImGuiNET.ImGui.SetItemTooltip("Show the Tracker's frame and background again.");
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
|
||||
// Hot for the next frame: the mouse over the rows or the button.
|
||||
bool over = mouse.X >= origin.X && mouse.X <= origin.X + width && mouse.Y >= origin.Y && mouse.Y <= origin.Y + height;
|
||||
_hot = over;
|
||||
bool down = ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left);
|
||||
if (!down) _pressHot = false;
|
||||
else if (over && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left)) _pressHot = true;
|
||||
}
|
||||
|
||||
private static void Shadowed(ImDrawListPtr dl, ImFontPtr font, float size, Vector2 p, uint color, string text)
|
||||
{
|
||||
dl.AddText(font, size, p + new Vector2(1, 1), BareShadow, text);
|
||||
dl.AddText(font, size, p, color, text);
|
||||
}
|
||||
|
||||
private void DrawFramed()
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
// Background behind the content only (like the Avalonia StackPanel), so
|
||||
|
|
@ -240,11 +340,12 @@ internal sealed class TrackerFace : IImGuiPanel
|
|||
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
|
||||
// Title row: [Tracker] [===slider===] [reset]
|
||||
// Title row: [Tracker] [===slider===] [text only] [reset]
|
||||
ImGuiNET.ImGui.TextColored(TitleColor, "Tracker");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
float resetW = ImGuiNET.ImGui.CalcTextSize(PhosphorIcons.ArrowCounterClockwise).X + 8;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(10, ImGuiNET.ImGui.GetContentRegionAvail().X - resetW - 4));
|
||||
float textOnlyW = ImGuiNET.ImGui.CalcTextSize(PhosphorIcons.TextAa).X + 8;
|
||||
ImGuiNET.ImGui.SetNextItemWidth(Math.Max(10, ImGuiNET.ImGui.GetContentRegionAvail().X - resetW - textOnlyW - 8));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(2, 0));
|
||||
if (ImGuiNET.ImGui.SliderInt("##opacity", ref _opacity, 0, 100, ""))
|
||||
TrackerSettings.SetBgAlpha((byte)Math.Round(_opacity * 2.55), save: false);
|
||||
|
|
@ -256,6 +357,15 @@ internal sealed class TrackerFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, ResetBorder);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, 1));
|
||||
bool canBare = !ImGuiPanelHost.DrawingEmbedded && !ImGuiPopOuts.InPopOutFrame;
|
||||
ImGuiNET.ImGui.BeginDisabled(!canBare);
|
||||
if (ImGuiNET.ImGui.Button(PhosphorIcons.TextAa + "##textonly"))
|
||||
TrackerSettings.SetTextOnly(true);
|
||||
ImGuiNET.ImGui.EndDisabled();
|
||||
ImGuiNET.ImGui.SetItemTooltip(canBare
|
||||
? "Text only: hide the frame and background, just the numbers (clicks pass through to the game).\nThe button at the end of its first row brings the frame back."
|
||||
: "Text only works while the Tracker is docked (not popped out).");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (ImGuiNET.ImGui.Button(PhosphorIcons.ArrowCounterClockwise + "##reset"))
|
||||
UiSources.Tracker.RequestReset();
|
||||
ImGuiNET.ImGui.SetItemTooltip("Reset the session stats");
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
// (wantHeight) as its minimum and is fitted to it whenever it changes and the
|
||||
// mouse is up (a frameless window's empty rows would still catch clicks meant
|
||||
// for the game); a text size change scales its width along with its fonts.
|
||||
// A "scale": "draw" window set bigger than normal (PanelDrawScale) gets the
|
||||
// fonts baked nearest above its size while the plugin draws (2026-11-01: from
|
||||
// the normal bake, stretched, its text blurred); the font pushed for its menus
|
||||
// and tooltips stays at the panel's text size.
|
||||
// docs/PLUGIN_WINDOWS.md. AC's render thread.
|
||||
// ============================================================================
|
||||
|
||||
|
|
@ -39,11 +43,12 @@ internal sealed class PluginWindowFace : IImGuiPanel
|
|||
|
||||
// "fitHeight" (v90): the content height the plugin asked for (logical units; 0 = not known
|
||||
// yet), and the text size factor and width (logical) the window was last fitted at.
|
||||
private readonly bool _fitHeight;
|
||||
private readonly bool _fitHeight, _drawScale;
|
||||
private readonly float _minWidth;
|
||||
private float _contentHeight, _fitK, _fitWidth;
|
||||
|
||||
public PluginWindowFace(string plugin, string surface, string title, bool fitHeight = false, float minWidth = 0f)
|
||||
public PluginWindowFace(string plugin, string surface, string title, bool fitHeight = false, float minWidth = 0f,
|
||||
bool drawScale = false)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_title = title;
|
||||
|
|
@ -51,6 +56,15 @@ internal sealed class PluginWindowFace : IImGuiPanel
|
|||
_idScope = "##pw_" + surface;
|
||||
_fitHeight = fitHeight;
|
||||
_minWidth = minWidth;
|
||||
_drawScale = drawScale;
|
||||
}
|
||||
|
||||
/// <summary>The font step the plugin draws with: a draw-scale window's own size's (baked), else the text size's.</summary>
|
||||
private int DrawFontStep(int textStep)
|
||||
{
|
||||
if (!_drawScale) return textStep;
|
||||
int pct = PanelDrawScale.Get(_title);
|
||||
return pct > 0 ? ImGuiFonts.BakedStepNear(PanelDrawScale.FontStep(pct, EngineFrameController.FontScale)) : textStep;
|
||||
}
|
||||
|
||||
/// <summary>A fitHeight window's minimum: its minimum width at its text size, and the content's height.</summary>
|
||||
|
|
@ -78,10 +92,13 @@ internal sealed class PluginWindowFace : IImGuiPanel
|
|||
guarded = guarded && ImGuiStackGuard.AtWindowBase(bodyBase); // drawn anywhere else: as before
|
||||
ImGuiNET.ImGui.PushID(_idScope);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
int textStep = ImGuiFonts.CurrentStep;
|
||||
ImGuiFonts.CurrentStep = DrawFontStep(textStep);
|
||||
ImGuiStackGuard.Mark given = guarded ? ImGuiStackGuard.Take() : default;
|
||||
try { result = PluginManager.RenderEmbed(_plugin, _surface, avail, out want); }
|
||||
finally
|
||||
{
|
||||
ImGuiFonts.CurrentStep = textStep;
|
||||
ImGuiStackGuard.Mark after = default;
|
||||
StackCheck check = guarded ? ImGuiStackGuard.Check(given, out after) : StackCheck.Balanced;
|
||||
if (check == StackCheck.Balanced)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@
|
|||
// legend. Your own arrow, the compass letters and the coordinates have sizes too.
|
||||
// Outdoors the World Map's picture can be drawn behind it (RadarSettingsStore.ShowWorldMap; the
|
||||
// tiles come from WorldMapTiles through WorldMapTileDrawer, the same code as the World Map).
|
||||
// The object selected in game is highlighted (RadarSettingsStore.HighlightSelected, RadarSelection):
|
||||
// a ring in its own colour round its marker and the hover label beside it, or an arrow on the
|
||||
// edge when it is off the picture.
|
||||
//
|
||||
// Data: UiSources.Radar (RadarView, lookups precomputed). World geometry is
|
||||
// drawn without anti-aliasing (crisp tiling like the Avalonia face's aliased
|
||||
|
|
@ -72,6 +75,8 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
// The round radar (RadarSettingsStore.RoundRadar): this frame's circle, read by the drawing helpers.
|
||||
private static bool _round;
|
||||
private static RoundMask _mask;
|
||||
// The selected object's marker this frame (RadarSelection.Highlighted), or null; drawn over everything.
|
||||
private static RadarMarker? _sel;
|
||||
|
||||
/// <summary>Markers move: popped out, redraw smoothly even when idle.</summary>
|
||||
public int PopOutIdleHz => 20;
|
||||
|
|
@ -167,6 +172,11 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
dl.AddLine(new Vector2(worldMin.X, centre.Y), new Vector2(worldMax.X, centre.Y), Crosshair);
|
||||
}
|
||||
|
||||
// The game's current selection (the global AC's SetSelectedObject writes; one read a frame).
|
||||
uint selectedId = view != null && RadarSettingsStore.HighlightSelected && Compatibility.SelectedTargetHooks.IsInstalled
|
||||
? Compatibility.SelectedTargetHooks.ReadCurrentSelectedId() : 0;
|
||||
_sel = view != null ? RadarSelection.Highlighted(RadarSettingsStore.HighlightSelected, view.Live.Markers, selectedId) : null;
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
ImDrawListFlags saved = dl.Flags;
|
||||
|
|
@ -175,6 +185,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
DrawWorld(dl, view, centre, worldMin, worldMax);
|
||||
dl.PopClipRect();
|
||||
dl.Flags = saved;
|
||||
DrawSelected(dl, view, centre, worldMin, worldMax, origin, panelMax);
|
||||
|
||||
DrawOutlinedText(dl, ImGuiFonts.Get(UiFont.UiBold11), view.CoordText,
|
||||
new Vector2((origin.X + panelMax.X) * 0.5f, panelMax.Y), CoordText, alignBottom: true,
|
||||
|
|
@ -306,7 +317,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
{
|
||||
foreach (RadarMarker m in live.Markers)
|
||||
{
|
||||
if (!RadarSettingsStore.ShowKind(m.Kind)) continue;
|
||||
if (m == _sel || !RadarSettingsStore.ShowKind(m.Kind)) continue; // the selected one: DrawSelected
|
||||
if ((pass == 1) != (RadarKind.IsCreature(m.Kind) || m.Kind is RadarKind.Portal or RadarKind.Door)) continue;
|
||||
Vector2 pp = proj.P(m.X, m.Y);
|
||||
if (_round ? !_mask.Contains(pp) : (pp.X < clipMin.X || pp.X > clipMax.X || pp.Y < clipMin.Y || pp.Y > clipMax.Y)) continue;
|
||||
|
|
@ -323,6 +334,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
foreach (RadarMarker m in live.Markers)
|
||||
{
|
||||
if (!markers.NameShown(m.Kind) || !RadarSettingsStore.ShowKind(m.Kind)) continue;
|
||||
if (m == _sel && RadarSettingsStore.ShowSelectedLabel) continue; // its label has the name
|
||||
Vector2 pp = proj.P(m.X, m.Y);
|
||||
if (pp.X < clipMin.X - 8 || pp.X > clipMax.X || pp.Y < clipMin.Y - 8 || pp.Y > clipMax.Y + 8) continue;
|
||||
if (_round && !_mask.Contains(pp)) continue;
|
||||
|
|
@ -338,6 +350,57 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
dl.AddLine(centre, tip, PlayerCol, 2);
|
||||
}
|
||||
|
||||
// ── The selected object ────────────────────────────────────────────────
|
||||
// A ring in the selection colour round its marker (the marker drawn over everything, even when its
|
||||
// kind's box is off), and the hover label beside it; off the picture, an arrow on the edge pointing
|
||||
// to it with the label next to the arrow. Drawn anti-aliased, after the world.
|
||||
|
||||
private const float ArrowInset = 3f, ArrowLength = 9f, ArrowHalfWidth = 5f;
|
||||
private readonly TipCache _selTip = new();
|
||||
|
||||
private void DrawSelected(ImDrawListPtr dl, RadarView view, Vector2 centre, Vector2 clipMin, Vector2 clipMax,
|
||||
Vector2 panelMin, Vector2 panelMax)
|
||||
{
|
||||
RadarMarker? sel = _sel;
|
||||
if (sel == null) return;
|
||||
var proj = new Projection(centre, view.Live.Player, RadarSettingsStore.RotateWithPlayer, MathF.Max(0.5f, RadarSettingsStore.Zoom));
|
||||
Vector2 pp = proj.P(sel.X, sel.Y);
|
||||
uint col = RynthTheme.Argb(RadarSettingsStore.SelectedColor);
|
||||
Vector2 anchor;
|
||||
float gap;
|
||||
dl.PushClipRect(clipMin, clipMax, true);
|
||||
if (RadarSelection.EdgeArrow(centre, pp, clipMin, clipMax, _round ? _mask : null, ArrowInset, out Vector2 tip, out Vector2 dir))
|
||||
{
|
||||
RadarSelection.ArrowCorners(tip, dir, ArrowLength, ArrowHalfWidth, out Vector2 a, out Vector2 b, out Vector2 c);
|
||||
dl.AddTriangleFilled(a, b, c, col);
|
||||
dl.AddTriangle(a, b, c, Outline, 1.5f);
|
||||
anchor = tip - dir * (ArrowLength * 0.5f);
|
||||
gap = ArrowLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
float size = RadarSettingsStore.Markers.SizeOf(sel.Kind);
|
||||
float r = MathF.Max(6.5f, RadarMarkerStyle.Radius(sel.Kind) * size + 3f);
|
||||
dl.AddCircle(pp, r, Outline, 20, 3.5f);
|
||||
RadarMarkerStyle.Draw(dl, sel.Kind, pp, KindCols[sel.Kind], size);
|
||||
dl.AddCircle(pp, r, col, 20, 2f);
|
||||
anchor = pp;
|
||||
gap = r + 4f;
|
||||
}
|
||||
dl.PopClipRect();
|
||||
if (!RadarSettingsStore.ShowSelectedLabel) return;
|
||||
|
||||
// The hover label, as a tooltip-styled box kept inside the panel.
|
||||
string text = _selTip.Get(view, sel);
|
||||
var style = ImGuiNET.ImGui.GetStyle();
|
||||
Vector2 pad = new Vector2(6f, 4f);
|
||||
Vector2 box = ImGuiNET.ImGui.CalcTextSize(text) + pad * 2f;
|
||||
Vector2 at = RadarSelection.LabelPos(anchor, gap, box, panelMin, panelMax);
|
||||
dl.AddRectFilled(at, at + box, ImGuiNET.ImGui.GetColorU32(ImGuiCol.PopupBg), style.PopupRounding);
|
||||
dl.AddRect(at, at + box, col, style.PopupRounding, ImDrawFlags.None, 1f);
|
||||
dl.AddText(at + pad, ImGuiNET.ImGui.GetColorU32(ImGuiCol.Text), text);
|
||||
}
|
||||
|
||||
// ── World map backdrop ─────────────────────────────────────────────────
|
||||
// The radar's world coordinates are yards from the world's south-west corner; the World Map's cells
|
||||
// are 24 yards, so cell = yards / 24 on both axes, and the radar's zoom (px per yard) is 24x that
|
||||
|
|
@ -475,11 +538,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
|
||||
private Vector2 _pressPos;
|
||||
private float _pressTravel;
|
||||
private byte _tipKind = byte.MaxValue;
|
||||
private string? _tipLabel;
|
||||
private int _tipDistance = int.MinValue;
|
||||
private int _tipPct = -1;
|
||||
private string _tipText = "";
|
||||
private readonly TipCache _hoverTip = new();
|
||||
|
||||
private void MarkerInput(ImDrawListPtr dl, RadarView view, Vector2 centre, Vector2 clipMin, Vector2 clipMax, bool clicked)
|
||||
{
|
||||
|
|
@ -517,8 +576,9 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
dl.PushClipRect(clipMin, clipMax, true);
|
||||
dl.AddCircle(hitPos, 6.5f, CoordText, 16, 1.5f);
|
||||
dl.PopClipRect();
|
||||
if (hit == _sel && RadarSettingsStore.ShowSelectedLabel) return; // its label is already showing
|
||||
ImGuiNET.ImGui.BeginTooltip();
|
||||
ImGuiNET.ImGui.TextUnformatted(TipText(view, hit));
|
||||
ImGuiNET.ImGui.TextUnformatted(_hoverTip.Get(view, hit));
|
||||
ImGuiNET.ImGui.EndTooltip();
|
||||
}
|
||||
|
||||
|
|
@ -621,34 +681,44 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Name\n12 yd" for the hovered marker, plus " 75%" when the marker has an id and
|
||||
/// the engine has a health reading for it (MonsterHudData: one locked lookup, hover
|
||||
/// only). Rebuilt only when the marker, whole yards or whole percent change.
|
||||
/// "Name\n12 yd" for the hovered (or selected) marker, plus " 75%" when the marker has an id and
|
||||
/// the engine has a health reading for it (MonsterHudData: one locked lookup, hover and the
|
||||
/// selected marker only). Rebuilt only when the marker, whole yards or whole percent change; one
|
||||
/// cache for the hover tooltip, one for the selected object's label, so neither rebuilds the other's.
|
||||
/// </summary>
|
||||
private string TipText(RadarView view, RadarMarker m)
|
||||
private sealed class TipCache
|
||||
{
|
||||
RadarPlayer p = view.Live.Player;
|
||||
float dx = m.X - p.WorldX, dy = m.Y - p.WorldY, dz = m.Z - p.Z;
|
||||
int d = (int)MathF.Round(MathF.Sqrt(dx * dx + dy * dy + dz * dz));
|
||||
int pct = -1;
|
||||
if (m.Id != 0 && RadarKind.IsCreature(m.Kind) && Hud.MonsterHudData.TryGetHealth(m.Id, out Hud.HealthObservation h))
|
||||
pct = (int)MathF.Round(h.Ratio * 100f);
|
||||
// Markers are rebuilt on every radar poll: key on what the text shows, not the instance.
|
||||
if (m.Kind == _tipKind && d == _tipDistance && pct == _tipPct
|
||||
&& string.Equals(m.Label, _tipLabel, StringComparison.Ordinal))
|
||||
private byte _tipKind = byte.MaxValue;
|
||||
private string? _tipLabel;
|
||||
private int _tipDistance = int.MinValue;
|
||||
private int _tipPct = -1;
|
||||
private string _tipText = "";
|
||||
|
||||
public string Get(RadarView view, RadarMarker m)
|
||||
{
|
||||
RadarPlayer p = view.Live.Player;
|
||||
float dx = m.X - p.WorldX, dy = m.Y - p.WorldY, dz = m.Z - p.Z;
|
||||
int d = (int)MathF.Round(MathF.Sqrt(dx * dx + dy * dy + dz * dz));
|
||||
int pct = -1;
|
||||
if (m.Id != 0 && RadarKind.IsCreature(m.Kind) && Hud.MonsterHudData.TryGetHealth(m.Id, out Hud.HealthObservation h))
|
||||
pct = (int)MathF.Round(h.Ratio * 100f);
|
||||
// Markers are rebuilt on every radar poll: key on what the text shows, not the instance.
|
||||
if (m.Kind == _tipKind && d == _tipDistance && pct == _tipPct
|
||||
&& string.Equals(m.Label, _tipLabel, StringComparison.Ordinal))
|
||||
return _tipText;
|
||||
_tipKind = m.Kind;
|
||||
_tipLabel = m.Label;
|
||||
_tipDistance = d;
|
||||
_tipPct = pct;
|
||||
// A label is the object's name; the kind always follows it, so a dot says which show box
|
||||
// in the settings hides it (a fellow is not a "Player", your kill's corpse not a "Corpse").
|
||||
string name = string.IsNullOrEmpty(m.Label) ? RadarKind.Name(m.Kind)
|
||||
: m.Label + " (" + RadarKind.Name(m.Kind) + ")";
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
_tipText = name + "\n" + d.ToString(inv) + " yd"
|
||||
+ (pct >= 0 ? " " + pct.ToString(inv) + "%" : "");
|
||||
return _tipText;
|
||||
_tipKind = m.Kind;
|
||||
_tipLabel = m.Label;
|
||||
_tipDistance = d;
|
||||
_tipPct = pct;
|
||||
// A label is the object's name; the kind always follows it, so a dot says which show box
|
||||
// in the settings hides it (a fellow is not a "Player", your kill's corpse not a "Corpse").
|
||||
string name = string.IsNullOrEmpty(m.Label) ? RadarKind.Name(m.Kind)
|
||||
: m.Label + " (" + RadarKind.Name(m.Kind) + ")";
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
_tipText = name + "\n" + d.ToString(inv) + " yd"
|
||||
+ (pct >= 0 ? " " + pct.ToString(inv) + "%" : "");
|
||||
return _tipText;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Compass and text ───────────────────────────────────────────────────
|
||||
|
|
@ -763,6 +833,26 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
changed |= Check("Click a dot to select it", ref RadarSettingsStore.ClickToSelect);
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
ImGuiNET.ImGui.SetTooltip("Left-click a dot to select that object in game. Hover a dot for its name and distance.");
|
||||
changed |= Check("Highlight the selected object", ref RadarSettingsStore.HighlightSelected);
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
ImGuiNET.ImGui.SetTooltip("Whatever you have selected in game (a monster, NPC, player, portal, door, corpse or item on the ground)\ngets a ring in this colour round its dot, even when its kind's box is off.\nOff the radar's picture, an arrow on the edge points the way to it.");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
Vector4 selCol = RynthTheme.Vec(RadarSettingsStore.SelectedColor);
|
||||
if (ImGuiNET.ImGui.ColorEdit4("##selcol", ref selCol, PickFlags))
|
||||
{
|
||||
RadarSettingsStore.SelectedColor = ToArgb(selCol);
|
||||
_colorDirty = true;
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered() && !ImGuiNET.ImGui.IsItemActive())
|
||||
ImGuiNET.ImGui.SetTooltip("The selection ring's colour (click to change it).");
|
||||
if (RadarSettingsStore.HighlightSelected)
|
||||
{
|
||||
ImGuiNET.ImGui.Indent();
|
||||
changed |= Check("Show its label", ref RadarSettingsStore.ShowSelectedLabel);
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
ImGuiNET.ImGui.SetTooltip("The hover label (name, distance, health) stays beside the selected object while it is selected.");
|
||||
ImGuiNET.ImGui.Unindent();
|
||||
}
|
||||
changed |= Slider("Opacity", ref RadarSettingsStore.Opacity, 0.05f, 1.0f, "%.2f");
|
||||
changed |= Slider("Zoom", ref RadarSettingsStore.Zoom, 0.5f, 6.0f, "%.1f");
|
||||
changed |= Check("World map behind the radar (outdoors)", ref RadarSettingsStore.ShowWorldMap);
|
||||
|
|
@ -865,8 +955,6 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
float xName = 232 * scale, xSize = 268 * scale, xText = 350 * scale;
|
||||
MarkerStyleSettings markers = RadarSettingsStore.Markers;
|
||||
MarkerStyleEditor.HeaderRow(xName, xSize, xText);
|
||||
const ImGuiColorEditFlags pickFlags = ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel
|
||||
| ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.AlphaPreviewHalf;
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(6, 3));
|
||||
foreach (var (kind, label) in KindRowsOrder)
|
||||
{
|
||||
|
|
@ -893,7 +981,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
if (ImGuiNET.ImGui.IsItemHovered()) SafeImGui.SetTooltip(KindTips[kind]);
|
||||
ImGuiNET.ImGui.SameLine(190 * scale);
|
||||
Vector4 v = RynthTheme.Vec(RadarSettingsStore.KindColors[kind]);
|
||||
if (ImGuiNET.ImGui.ColorEdit4("##col", ref v, pickFlags))
|
||||
if (ImGuiNET.ImGui.ColorEdit4("##col", ref v, PickFlags))
|
||||
{
|
||||
RadarSettingsStore.KindColors[kind] = ToArgb(v);
|
||||
_colorDirty = true;
|
||||
|
|
@ -922,7 +1010,7 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
RadarSettingsStore.ResetKindColors();
|
||||
changed = true;
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetTooltip("Every kind back to its default colour (show boxes stay as they are).");
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetTooltip("Every kind, and the selection ring, back to its default colour (show boxes stay as they are).");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (ImGuiNET.ImGui.SmallButton("Reset sizes and names"))
|
||||
{
|
||||
|
|
@ -935,6 +1023,10 @@ internal sealed class RadarFace : IImGuiPanel
|
|||
|
||||
private static bool _colorDirty;
|
||||
|
||||
// The colour swatches: click to pick, alpha included.
|
||||
private const ImGuiColorEditFlags PickFlags = ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel
|
||||
| ImGuiColorEditFlags.AlphaBar | ImGuiColorEditFlags.AlphaPreviewHalf;
|
||||
|
||||
private static uint ToArgb(Vector4 v)
|
||||
{
|
||||
static uint B(float f) => (uint)Math.Clamp((int)MathF.Round(f * 255f), 0, 255);
|
||||
|
|
|
|||
116
src/RynthCore.Engine/ImGui/Panels/RadarSelection.cs
Normal file
116
src/RynthCore.Engine/ImGui/Panels/RadarSelection.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/RadarSelection.cs
|
||||
// The object selected in game, highlighted on the radar (2026-10-31, a player's
|
||||
// request: "Can the hover icon stay over whichever mob/door/etc. you have
|
||||
// selected?"). RadarFace reads AC's current selection each frame (the global the
|
||||
// SetSelectedObject hook reads, SelectedTargetHooks.ReadCurrentSelectedId: no new
|
||||
// hook) and draws a ring in its own colour round that object's marker, with the
|
||||
// hover label (name, distance, health) beside it. Off the radar's picture, a small
|
||||
// arrow on the edge points the way to it.
|
||||
//
|
||||
// The rules, pure (no ImGui, no AC), so tools\RadarSettingsTests links this file:
|
||||
// - which marker is the selected one: the marker with the selected object's id;
|
||||
// none when nothing is selected or the marker has no id (RynthAi builds before
|
||||
// 2026-10-01 send none);
|
||||
// - it clears when the selection clears, or the object is no longer one of the
|
||||
// radar's markers (gone, out of the client's view, an item in a pack);
|
||||
// - the selected object is shown even when its kind's show box is off (items on
|
||||
// the ground start hidden, and the player picked this one);
|
||||
// - where the edge arrow goes, and where the label sits.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal static class RadarSelection
|
||||
{
|
||||
/// <summary>
|
||||
/// The marker of the selected object, or null: nothing selected (id 0), the object isn't one of
|
||||
/// the markers, or the markers carry no ids. A kind this engine doesn't know (a newer RynthAi's) is
|
||||
/// never highlighted: it has no shape or colour here. A List, not an interface, so the loop allocates nothing.
|
||||
/// </summary>
|
||||
public static RadarMarker? Find(List<RadarMarker>? markers, uint selectedId)
|
||||
{
|
||||
if (selectedId == 0 || markers == null) return null;
|
||||
foreach (RadarMarker m in markers)
|
||||
if (m.Id == selectedId)
|
||||
return m.Kind < RadarKind.Count ? m : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Whether a marker is highlighted this frame: the setting is on and it is the selected object's.</summary>
|
||||
public static RadarMarker? Highlighted(bool settingOn, List<RadarMarker>? markers, uint selectedId) =>
|
||||
settingOn ? Find(markers, selectedId) : null;
|
||||
|
||||
/// <summary>
|
||||
/// The edge arrow toward a marker that is off the radar's picture. <paramref name="target"/> is the
|
||||
/// marker's screen point; the picture is the box <paramref name="min"/>..<paramref name="max"/>, or the
|
||||
/// circle <paramref name="round"/> on the round radar. False when the marker is on the picture (it is
|
||||
/// drawn where it is) or is at the centre. Otherwise <paramref name="tip"/> is the arrow's point,
|
||||
/// <paramref name="inset"/> px inside the edge on the line from <paramref name="centre"/> to the marker,
|
||||
/// and <paramref name="dir"/> the unit direction it points.
|
||||
/// </summary>
|
||||
public static bool EdgeArrow(Vector2 centre, Vector2 target, Vector2 min, Vector2 max, RoundMask? round, float inset,
|
||||
out Vector2 tip, out Vector2 dir)
|
||||
{
|
||||
tip = default;
|
||||
dir = default;
|
||||
if (round is RoundMask circle)
|
||||
{
|
||||
if (circle.Contains(target)) return false;
|
||||
}
|
||||
else if (target.X >= min.X && target.X <= max.X && target.Y >= min.Y && target.Y <= max.Y) return false;
|
||||
|
||||
Vector2 d = target - centre;
|
||||
float len = d.Length();
|
||||
if (!(len > 1e-4f) || !float.IsFinite(len)) return false;
|
||||
dir = d / len;
|
||||
float t;
|
||||
if (round is RoundMask c)
|
||||
t = MathF.Max(0f, c.Radius - inset);
|
||||
else
|
||||
{
|
||||
// Onto the box: the nearer of the two sides the ray meets.
|
||||
float hx = MathF.Max(0f, MathF.Min(centre.X - min.X, max.X - centre.X) - inset);
|
||||
float hy = MathF.Max(0f, MathF.Min(centre.Y - min.Y, max.Y - centre.Y) - inset);
|
||||
float tx = MathF.Abs(dir.X) > 1e-6f ? hx / MathF.Abs(dir.X) : float.MaxValue;
|
||||
float ty = MathF.Abs(dir.Y) > 1e-6f ? hy / MathF.Abs(dir.Y) : float.MaxValue;
|
||||
t = MathF.Min(tx, ty);
|
||||
}
|
||||
tip = centre + dir * t;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The edge arrow's three corners: the point at <paramref name="tip"/>, the base
|
||||
/// <paramref name="length"/> px back toward the centre and <paramref name="halfWidth"/> px to each side.
|
||||
/// </summary>
|
||||
public static void ArrowCorners(Vector2 tip, Vector2 dir, float length, float halfWidth,
|
||||
out Vector2 a, out Vector2 b, out Vector2 c)
|
||||
{
|
||||
var side = new Vector2(-dir.Y, dir.X);
|
||||
Vector2 back = tip - dir * length;
|
||||
a = tip;
|
||||
b = back + side * halfWidth;
|
||||
c = back - side * halfWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Where the label's box (<paramref name="size"/>) goes: to the right of a marker at
|
||||
/// <paramref name="anchor"/>, <paramref name="gap"/> px clear of it, vertically centred; on the left when
|
||||
/// it would run past <paramref name="boundsMax"/>; then kept inside the bounds as far as it fits.
|
||||
/// </summary>
|
||||
public static Vector2 LabelPos(Vector2 anchor, float gap, Vector2 size, Vector2 boundsMin, Vector2 boundsMax)
|
||||
{
|
||||
float x = anchor.X + gap;
|
||||
if (x + size.X > boundsMax.X) x = anchor.X - gap - size.X;
|
||||
float y = anchor.Y - size.Y * 0.5f;
|
||||
x = MathF.Max(boundsMin.X, MathF.Min(x, boundsMax.X - size.X));
|
||||
y = MathF.Max(boundsMin.Y, MathF.Min(y, boundsMax.Y - size.Y));
|
||||
return new Vector2(x, y);
|
||||
}
|
||||
}
|
||||
|
|
@ -562,6 +562,15 @@ internal sealed class RynthNavFace : IImGuiPanel
|
|||
SectionLabel("WHERE YOUR RECALLS LAND");
|
||||
foreach (string line in st.MineLines) Wrapped(line, Text, iw);
|
||||
}
|
||||
// Lifestone Recall's landing, learned from the lifestone selected or stood at (/rnav tie lifestone).
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
const string LsLabel = PhosphorIcons.MapPin + " My lifestone is the one selected";
|
||||
if (Button("##rc_tiels", LsLabel, p, new Vector2(Math.Min(iw, ButtonWidth(LsLabel) + 8), 22), Text, BtnFill))
|
||||
RynthNavCommands.Command("tie lifestone");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Select the lifestone you are tied to (or stand at it), then click: routes can use\nLifestone Recall from then on, without casting it once first. Also: /rnav tie lifestone");
|
||||
NextLine(p, 26);
|
||||
}
|
||||
}
|
||||
else Wrapped("Update RynthNav (0.6.1) to see your portal ties here and answer \"which tie was it?\" with a button.", Mute, iw);
|
||||
|
||||
|
|
@ -858,6 +867,19 @@ internal sealed class RynthNavFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
Label(view.Summary.Length > 0 ? view.Summary : RynthNavAtlas.Status.Length > 0 ? RynthNavAtlas.Status : "Loading…", Mute);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
// Recent: forget them (/rnav recent clear).
|
||||
if (_mode == AtlasMode.Recent && view.Rows.Length > 0)
|
||||
{
|
||||
Vector2 cp = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
const string ClearLabel = PhosphorIcons.Eraser + " Forget recent places";
|
||||
if (Button("##atl_recent_clear", ClearLabel, cp, new Vector2(ButtonWidth(ClearLabel) + 8, 22), Text, BtnFill))
|
||||
{
|
||||
RynthNavCommands.Command("recent clear");
|
||||
PushQuery();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Empty the Recent list (favorites stay). Also: /rnav recent clear");
|
||||
NextLine(cp, 26);
|
||||
}
|
||||
|
||||
// List
|
||||
float listH = Math.Max(60, origin.Y + size.Y - 6 - ImGuiNET.ImGui.GetCursorScreenPos().Y - DetailH - 4);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,21 @@
|
|||
// gear a chat line and/or the system beep when a new match appears
|
||||
// (both off by default; they work with the panel closed).
|
||||
//
|
||||
// Compact (2026-10-31, the owner: "we should make a small version of it"; in
|
||||
// item-counter.lua's spirit): only the match rows, tighter, and docked no
|
||||
// frame or background (IImGuiPanel.Bare); clicks go through to the game except
|
||||
// over the rows (ClickThrough, worked out from the last frame's rows, as the
|
||||
// radar's dots). Each row: arrow, name, distance; the coordinates, then the
|
||||
// kind, when the window is wide enough (SenseLayout.Compact). After the first
|
||||
// row, two small buttons are always there (faint until the mouse is on the
|
||||
// panel; SenseLayout.OtherViews): collapse, and back to the full panel.
|
||||
// Collapsed: one line, "Sense: N"; a click on it (or the caret beside it)
|
||||
// opens it to compact. The full panel's add row has the compact and collapse
|
||||
// buttons. The look is kept in sense.txt
|
||||
// (view=...) and set by /rc sense compact on|off, collapse on|off. Moving and
|
||||
// resizing are the full panel's (the window keeps its place and size). Popped
|
||||
// out, or embedded in the Mini Remote, the frame stays; embedded is always full.
|
||||
//
|
||||
// Data: SenseStore (the list, sense.txt) and UiSources.Sense (the 2 Hz scan on
|
||||
// the pump thread, snapshots only; UI/Data/SenseData.cs). This face only reads
|
||||
// the published view and the player pose snapshot (for the arrows, per frame)
|
||||
|
|
@ -62,6 +77,7 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
"The distance shows when you and the object are both outdoors (or in surface buildings), or in the same dungeon. " +
|
||||
"Otherwise the row says elsewhere and gives the landblock.\n\n" +
|
||||
"Click a row to select it in game. Gear: a chat line or a beep when a new match appears.\n" +
|
||||
"The arrows-in button (or /rc sense compact on) shows just the matches, without the frame.\n" +
|
||||
"/rc sense opens and closes this panel.";
|
||||
|
||||
// ── State ───────────────────────────────────────────────────────────
|
||||
|
|
@ -72,6 +88,16 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
private bool _openSettings;
|
||||
private bool _flashing;
|
||||
|
||||
// Compact / collapsed: the mouse is over what the last frame drew (rows, the line, the
|
||||
// buttons), so the window takes input; elsewhere it lets clicks through. A press that began
|
||||
// there keeps it until the button is released.
|
||||
private bool _hot, _pressHot;
|
||||
|
||||
/// <summary>Compact and collapsed are bare: docked, no frame or background.</summary>
|
||||
public bool Bare => SenseStore.Layout != SenseLayoutMode.Full;
|
||||
|
||||
public bool ClickThrough => Bare && !_hot && !_pressHot;
|
||||
|
||||
public void OnShown()
|
||||
{
|
||||
SenseStore.EnsureLoadQueued();
|
||||
|
|
@ -82,6 +108,18 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
public void OnHidden() => UiSources.Sense.Unsubscribe();
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
SenseLayoutMode layout = SenseStore.Layout;
|
||||
if (layout != SenseLayoutMode.Full && !ImGuiPanelHost.DrawingEmbedded)
|
||||
{
|
||||
DrawSmall(layout);
|
||||
return;
|
||||
}
|
||||
_hot = _pressHot = false;
|
||||
DrawFull();
|
||||
}
|
||||
|
||||
private void DrawFull()
|
||||
{
|
||||
float w = Begin(out Vector2 origin, out Vector2 size);
|
||||
DrawAddRow(w);
|
||||
|
|
@ -113,7 +151,7 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
const float h = 22, iconW = 22;
|
||||
string addLabel = PhosphorIcons.Plus + " Add";
|
||||
float addW = ButtonWidth(addLabel);
|
||||
float boxW = Math.Max(60, w - addW - iconW * 2 - 12);
|
||||
float boxW = Math.Max(60, w - addW - iconW * 4 - 20);
|
||||
|
||||
bool enter = TextBox("##sense_input", _input, start, boxW,
|
||||
PhosphorIcons.MagnifyingGlass + " Name to watch for (* and ? wildcards)", out _,
|
||||
|
|
@ -124,6 +162,17 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
if (enter || add) AddTerm();
|
||||
|
||||
float gx = start.X + boxW + 4 + addW + 4;
|
||||
// The view switch: compact, then collapsed (one line).
|
||||
if (IconButton("##sense_compact", PhosphorIcons.ArrowsInLineVertical, new Vector2(gx, start.Y), new Vector2(iconW, h), Text, BtnFill,
|
||||
enabled: SenseStore.Loaded))
|
||||
SenseStore.SetLayout(SenseLayoutMode.Compact);
|
||||
SafeImGui.SetItemTooltip(SenseLayout.SwitchTip(SenseLayoutMode.Compact));
|
||||
gx += iconW + 4;
|
||||
if (IconButton("##sense_collapse", PhosphorIcons.CaretUp, new Vector2(gx, start.Y), new Vector2(iconW, h), Text, BtnFill,
|
||||
enabled: SenseStore.Loaded))
|
||||
SenseStore.SetLayout(SenseLayoutMode.Collapsed);
|
||||
SafeImGui.SetItemTooltip(SenseLayout.SwitchTip(SenseLayoutMode.Collapsed));
|
||||
gx += iconW + 4;
|
||||
if (IconButton("##sense_gear", PhosphorIcons.Gear, new Vector2(gx, start.Y), new Vector2(iconW, h), Text, BtnFill))
|
||||
_openSettings = true;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Alerts");
|
||||
|
|
@ -344,6 +393,218 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
|
||||
// ── Compact and collapsed (bare) ────────────────────────────────────
|
||||
|
||||
private static readonly uint Shadow = 0xB0000000;
|
||||
|
||||
/// <summary>
|
||||
/// The bare looks: compact (the match rows only) or collapsed ("Sense: N"). Works out
|
||||
/// <see cref="_hot"/> for the next frame's <see cref="ClickThrough"/> from what it draws.
|
||||
/// </summary>
|
||||
private void DrawSmall(SenseLayoutMode layout)
|
||||
{
|
||||
Vector2 origin = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
Vector2 size = ImGuiNET.ImGui.GetContentRegionAvail();
|
||||
bool popped = ImGuiPopOuts.InPopOutFrame;
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui10));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||
try
|
||||
{
|
||||
SenseView view = UiSources.Sense.Current?.Value ?? SenseView.Empty;
|
||||
Vector2 mouse = ImGuiNET.ImGui.GetIO().MousePos;
|
||||
bool wasHot = _hot;
|
||||
float k = MathF.Max(0.5f, ImGuiNET.ImGui.GetFontSize() / 10f);
|
||||
_flashing = false;
|
||||
|
||||
Vector2 drawnMax = layout == SenseLayoutMode.Collapsed || view.Rows.Length == 0
|
||||
? DrawCollapsedLine(origin, view, collapsed: layout == SenseLayoutMode.Collapsed, k)
|
||||
: DrawCompactRows(origin, size, view, k);
|
||||
|
||||
// The view switch after the first line, always there (2026-10-31: a control you can
|
||||
// see, not one that shows on hover): faint until the mouse is on the panel.
|
||||
float bh = MathF.Round(SenseLayout.CompactRowHeight * k), bw = bh + 2;
|
||||
Vector2 bp = new(drawnMax.X + 4, origin.Y);
|
||||
Vector2 buttonsMax = bp + new Vector2(bw * 2 + 2, bh);
|
||||
if (SenseStore.Loaded)
|
||||
{
|
||||
bool lit = wasHot || popped;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
dl.AddRectFilled(bp - new Vector2(2, 0), buttonsMax + new Vector2(2, 0), WithAlpha(ShellBg, lit ? 0.85f : 0.45f), 3);
|
||||
(SenseLayoutMode first, SenseLayoutMode second) = SenseLayout.OtherViews(layout);
|
||||
ViewButton("##sense_v1", first, bp, new Vector2(bw, bh), lit);
|
||||
ViewButton("##sense_v2", second, bp + new Vector2(bw + 2, 0), new Vector2(bw, bh), lit);
|
||||
}
|
||||
|
||||
// Hot for the next frame: the mouse over what was drawn or the view switch, or (once hot)
|
||||
// the strip out to the buttons.
|
||||
bool over = SenseStore.Loaded
|
||||
? SenseLayout.TakesMouse(mouse.X, mouse.Y, origin.X, origin.Y, drawnMax.X, drawnMax.Y, bp.X - 2, buttonsMax.X + 2, buttonsMax.Y, wasHot)
|
||||
: SenseLayout.IsHot(mouse.X, mouse.Y, origin.X, origin.Y, drawnMax.X, drawnMax.Y, buttonsMax.X, buttonsMax.Y, wasHot);
|
||||
_hot = over;
|
||||
bool down = ImGuiNET.ImGui.IsMouseDown(ImGuiMouseButton.Left);
|
||||
if (!down) _pressHot = false;
|
||||
else if (over && ImGuiNET.ImGui.IsMouseClicked(ImGuiMouseButton.Left)) _pressHot = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(origin);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(1, 1));
|
||||
}
|
||||
|
||||
/// <summary>One button of the view switch: to <paramref name="to"/> (its own glyph). <paramref name="lit"/>: full strength.</summary>
|
||||
private static void ViewButton(string id, SenseLayoutMode to, Vector2 pos, Vector2 size, bool lit)
|
||||
{
|
||||
string glyph = to switch
|
||||
{
|
||||
SenseLayoutMode.Compact => PhosphorIcons.CaretDown,
|
||||
SenseLayoutMode.Collapsed => PhosphorIcons.CaretUp,
|
||||
_ => PhosphorIcons.ArrowsOutLineVertical,
|
||||
};
|
||||
if (IconButton(id, glyph, pos, size, lit ? Text : Faded(Text), lit ? BtnFill : WithAlpha(BtnFill, 0.5f), font: UiFont.Ui11))
|
||||
SenseStore.SetLayout(to);
|
||||
SafeImGui.SetItemTooltip(SenseLayout.SwitchTip(to));
|
||||
}
|
||||
|
||||
/// <summary>"Sense: N" (collapsed, or compact with nothing to show). Click opens a collapsed one. Returns its far corner.</summary>
|
||||
private Vector2 DrawCollapsedLine(Vector2 origin, SenseView view, bool collapsed, float k)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float rowH = MathF.Round(SenseLayout.CompactRowHeight * k);
|
||||
string text = SenseLayout.CollapsedText(view.Rows.Length);
|
||||
float tw = ImGuiNET.ImGui.CalcTextSize(text).X;
|
||||
float iconW = rowH;
|
||||
Vector2 size = new(iconW + tw + 4, rowH);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(origin);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton("##sense_line", size);
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
if (hot)
|
||||
{
|
||||
dl.AddRectFilled(origin, origin + size, WithAlpha(ShellBg, 0.7f), 3);
|
||||
ImGuiNET.ImGui.BeginTooltip();
|
||||
ImGuiNET.ImGui.TextUnformatted(view.Status.Length > 0 ? view.Status : "Scanning...");
|
||||
ImGuiNET.ImGui.TextUnformatted(collapsed ? "Click to show the matches." : "Nothing matching to show.");
|
||||
ImGuiNET.ImGui.EndTooltip();
|
||||
}
|
||||
if (clicked && collapsed) SenseStore.SetLayout(SenseLayoutMode.Compact);
|
||||
|
||||
uint col = view.Rows.Length > 0 ? Amber : Faded(Text);
|
||||
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), PhosphorIcons.Binoculars, origin + new Vector2(1, 1), new Vector2(iconW, rowH), Shadow);
|
||||
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), PhosphorIcons.Binoculars, origin, new Vector2(iconW, rowH), col);
|
||||
ShadowText(dl, new Vector2(origin.X + iconW + 2, origin.Y + (rowH - ImGuiNET.ImGui.GetFontSize()) * 0.5f), view.Rows.Length > 0 ? Text : Faded(Text), text);
|
||||
return origin + size;
|
||||
}
|
||||
|
||||
/// <summary>The compact rows: arrow, name, distance, then the coordinates and the kind when they fit. Returns the far corner.</summary>
|
||||
private Vector2 DrawCompactRows(Vector2 origin, Vector2 size, SenseView view, float k)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
SenseRow[] rows = view.Rows;
|
||||
float rowH = MathF.Max(MathF.Round(SenseLayout.CompactRowHeight * k), MathF.Ceiling(ImGuiNET.ImGui.GetFontSize() + 3));
|
||||
(int shown, bool more) = SenseLayout.CompactFit(size.Y, rowH, rows.Length);
|
||||
SenseCompactColumns cols = SenseLayout.Compact(size.X, k);
|
||||
float arrowW = SenseLayout.CompactArrowWidth * k, distW = SenseLayout.CompactDistWidth * k,
|
||||
locW = SenseLayout.CompactLocWidth * k, kindW = SenseLayout.CompactKindWidth * k;
|
||||
|
||||
// The name column is as wide as the longest name shown (up to what the layout allows),
|
||||
// so the rows end where their text does: past that, clicks reach the game.
|
||||
float nameW = 0;
|
||||
for (int i = 0; i < shown; i++) nameW = MathF.Max(nameW, ImGuiNET.ImGui.CalcTextSize(rows[i].Name).X);
|
||||
nameW = MathF.Min(nameW + 8, cols.NameWidth);
|
||||
float used = arrowW + nameW + distW + (cols.Location ? locW : 0) + (cols.Kind ? kindW : 0);
|
||||
|
||||
long now = Environment.TickCount64;
|
||||
uint selected = ClientHelperHooks.GetSelectedItemId();
|
||||
float heading = PlayerHeading(out bool haveHeading);
|
||||
float fontH = ImGuiNET.ImGui.GetFontSize();
|
||||
int clicked = -1, hovered = -1;
|
||||
for (int i = 0; i < shown; i++)
|
||||
{
|
||||
SenseRow r = rows[i];
|
||||
var p = new Vector2(origin.X, origin.Y + i * rowH);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##crow", new Vector2(used, rowH))) clicked = i;
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (hot) hovered = i;
|
||||
|
||||
bool isSel = r.Id == selected;
|
||||
if (hot) dl.AddRectFilled(p, p + new Vector2(used, rowH), WithAlpha(ShellBg, 0.7f), 2);
|
||||
if (r.FirstSeenMs != 0)
|
||||
{
|
||||
long age = now - r.FirstSeenMs;
|
||||
if (age >= 0 && age < FlashMs)
|
||||
{
|
||||
_flashing = true;
|
||||
float pulse = 0.5f + 0.5f * MathF.Cos(age * 0.0126f);
|
||||
float a = (1f - age / (float)FlashMs) * (0.2f + 0.35f * pulse);
|
||||
dl.AddRectFilled(p, p + new Vector2(used, rowH), WithAlpha(Amber, a), 2);
|
||||
}
|
||||
}
|
||||
if (isSel) dl.AddRect(p, p + new Vector2(used, rowH), Teal, 2);
|
||||
|
||||
Vector2 mid = p + new Vector2(arrowW * 0.5f, rowH * 0.5f);
|
||||
uint kc = KindColor(r.Kind);
|
||||
if (r.Measured && haveHeading && !float.IsNaN(r.Bearing))
|
||||
{
|
||||
DrawArrow(dl, mid + new Vector2(1, 1), r.Bearing - heading, Shadow);
|
||||
DrawArrow(dl, mid, r.Bearing - heading, kc);
|
||||
}
|
||||
else if (r.Measured)
|
||||
dl.AddCircleFilled(mid, 2.5f, kc);
|
||||
else
|
||||
dl.AddCircle(mid, 3.5f, Faded(Mute), 12, 1.2f);
|
||||
|
||||
float ty = p.Y + (rowH - fontH) * 0.5f;
|
||||
float x = p.X + arrowW;
|
||||
ShadowCell(dl, r.Name, x, ty, nameW - 4, r.Measured ? Text : Mute);
|
||||
x += nameW;
|
||||
ShadowCell(dl, r.DistanceText, x, ty, distW - 4, r.Measured ? Text : Faded(Text));
|
||||
x += distW;
|
||||
if (cols.Location) { ShadowCell(dl, r.LocationText, x, ty, locW - 4, Mute); x += locW; }
|
||||
if (cols.Kind) ShadowCell(dl, SenseSource.KindName(r.Kind), x, ty, kindW - 4, kc);
|
||||
}
|
||||
int slots = shown;
|
||||
if (more)
|
||||
{
|
||||
// Rows that don't fit (the window keeps the full panel's size): how many, in the last slot.
|
||||
var p = new Vector2(origin.X, origin.Y + shown * rowH);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.InvisibleButton("##cmore", new Vector2(used, rowH));
|
||||
ImGuiNET.ImGui.SetItemTooltip("More matches than fit: make the panel taller in its full view (/rc sense compact off).");
|
||||
ShadowText(dl, new Vector2(p.X + arrowW, p.Y + (rowH - fontH) * 0.5f), Mute, SenseLayout.MoreText(rows.Length - shown));
|
||||
slots++;
|
||||
}
|
||||
|
||||
if (clicked >= 0)
|
||||
AcMainThreadQueue.EnqueueOverlaySelect(rows[clicked].Id);
|
||||
if (hovered >= 0)
|
||||
{
|
||||
ImGuiNET.ImGui.BeginTooltip();
|
||||
ImGuiNET.ImGui.TextUnformatted(rows[hovered].Tooltip);
|
||||
ImGuiNET.ImGui.EndTooltip();
|
||||
}
|
||||
return origin + new Vector2(used, slots * rowH);
|
||||
}
|
||||
|
||||
private static void ShadowText(ImDrawListPtr dl, Vector2 at, uint color, string text)
|
||||
{
|
||||
if (text.Length == 0) return;
|
||||
dl.AddText(at + new Vector2(1, 1), Shadow, text);
|
||||
dl.AddText(at, color, text);
|
||||
}
|
||||
|
||||
private static void ShadowCell(ImDrawListPtr dl, string text, float x, float y, float width, uint color)
|
||||
{
|
||||
if (text.Length == 0 || width <= 0) return;
|
||||
dl.PushClipRect(new Vector2(x, y - 2), new Vector2(x + width, y + 40), true);
|
||||
ShadowText(dl, new Vector2(x, y), color, text);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
|
||||
private static void Cell(ImDrawListPtr dl, string text, float x, float y, float width, uint color)
|
||||
{
|
||||
if (text.Length == 0 || width <= 0) return;
|
||||
|
|
|
|||
|
|
@ -251,7 +251,19 @@ internal sealed class SettingsRows
|
|||
ImGuiNET.ImGui.TextUnformatted(row.Label);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.SameLine(Math.Max(ImGuiNET.ImGui.GetCursorPosX() + 8, w * 0.45f));
|
||||
if (ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label))
|
||||
bool clicked = ImGuiNET.ImGui.Button(row.ButtonText ?? row.Label);
|
||||
Tooltip(row);
|
||||
if (row.Confirm != null)
|
||||
{
|
||||
// Asks first: the question, then the button's own caption to go ahead, or Cancel.
|
||||
if (clicked)
|
||||
{
|
||||
_confirmText = row.Confirm();
|
||||
ImGuiNET.ImGui.OpenPopup("##confirm");
|
||||
}
|
||||
clicked = ConfirmPopup(row.ButtonText ?? row.Label);
|
||||
}
|
||||
if (clicked)
|
||||
{
|
||||
// A settings edit is applied to this copy and saved like a typed value (the number
|
||||
// boxes re-sync from the copy next frame); Click, when also set, runs after.
|
||||
|
|
@ -262,7 +274,33 @@ internal sealed class SettingsRows
|
|||
}
|
||||
row.Click?.Invoke();
|
||||
}
|
||||
Tooltip(row);
|
||||
}
|
||||
|
||||
private string _confirmText = string.Empty;
|
||||
|
||||
/// <summary>The open confirmation (the row's ID scope): true when the player went ahead.</summary>
|
||||
private bool ConfirmPopup(string caption)
|
||||
{
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, ShellBg);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Teal);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(12, 10));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup("##confirm");
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!open) return false;
|
||||
bool go = false;
|
||||
try
|
||||
{
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim);
|
||||
ImGuiNET.ImGui.TextUnformatted(_confirmText);
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
if (ImGuiNET.ImGui.Button(caption.TrimEnd('.') + "##confirm_go")) { go = true; ImGuiNET.ImGui.CloseCurrentPopup(); }
|
||||
ImGuiNET.ImGui.SameLine(0, 8);
|
||||
if (ImGuiNET.ImGui.Button("Cancel##confirm_no")) ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
}
|
||||
finally { ImGuiNET.ImGui.EndPopup(); }
|
||||
return go;
|
||||
}
|
||||
|
||||
private void Changed(SettingRow row, double value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue