diff --git a/src/RynthCore.Engine/ImGui/Panels/SettingsFace.cs b/src/RynthCore.Engine/ImGui/Panels/SettingsFace.cs index e37aac2..9d2f9d8 100644 --- a/src/RynthCore.Engine/ImGui/Panels/SettingsFace.cs +++ b/src/RynthCore.Engine/ImGui/Panels/SettingsFace.cs @@ -53,6 +53,8 @@ internal sealed class SettingsFace : IImGuiPanel public bool Active; // the box had keyboard focus last frame } private readonly Dictionary _edits = new(); + // Text rows being typed in (the saved value shows again once the box loses focus). + private readonly Dictionary _textEdits = new(); /// Extra sidebar tab after the schema tabs; drawn from UiSources.Charms, not settings rows. private const string CharmsTabName = "Charms Tracking"; @@ -189,9 +191,64 @@ internal sealed class SettingsFace : IImGuiPanel case SettingKind.Note: Note(row.Label, w); break; case SettingKind.CraftingStatus: CraftingStatus(row); break; case SettingKind.Button: ButtonRow(row, w); break; + case SettingKind.Text: TextRow(row, w); break; + case SettingKind.Status: StatusRow(row, w); break; } } + // Label, then a full-width box; the value commits on Enter or focus loss (like the number boxes). + private void TextRow(SettingRow row, float w) + { + ImGuiNET.ImGui.Dummy(new Vector2(0, 2)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, TextDim); + ImGuiNET.ImGui.TextUnformatted(row.Label); + ImGuiNET.ImGui.PopStyleColor(); + Tooltip(row); + + string saved = row.GetText?.Invoke(_data) ?? string.Empty; + string text = _textEdits.TryGetValue(row, out string? typing) ? typing : saved; + ImGuiNET.ImGui.SetNextItemWidth(Math.Max(80, w - 4)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, PanelBg); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Amber); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, BtnBord); + ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f); + ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0f); + bool enter = ImGuiNET.ImGui.InputTextWithHint("##text", row.Hint ?? string.Empty, ref text, 512u, + ImGuiInputTextFlags.EnterReturnsTrue); + bool active = ImGuiNET.ImGui.IsItemActive(); + bool committed = enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit(); + ImGuiNET.ImGui.PopStyleVar(2); + ImGuiNET.ImGui.PopStyleColor(3); + Tooltip(row); + _editing |= active; + + if (committed) + { + _textEdits.Remove(row); + if (!string.Equals(text, saved, StringComparison.Ordinal)) + { + row.SetText?.Invoke(_data, text); + SettingsCommands.Save(_data.Clone()); + } + } + else if (active) _textEdits[row] = text; + else _textEdits.Remove(row); + ImGuiNET.ImGui.Dummy(new Vector2(0, 2)); + } + + // RynthAi's one-line status (teal), wrapped to the column. + private void StatusRow(SettingRow row, float w) + { + string text = row.GetText?.Invoke(_data) ?? string.Empty; + if (text.Length == 0) return; + ImGuiNET.ImGui.Dummy(new Vector2(0, 2)); + ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Teal); + ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w); + ImGuiNET.ImGui.TextUnformatted(text); + ImGuiNET.ImGui.PopTextWrapPos(); + ImGuiNET.ImGui.PopStyleColor(); + } + // Label | [caption]; Click posts its own work (never runs plugin code on AC's thread). private static void ButtonRow(SettingRow row, float w) { diff --git a/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs b/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs index 774dd03..e329f6f 100644 --- a/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs +++ b/src/RynthCore.Engine/ImGui/Panels/SkillsFace.Progression.cs @@ -3,6 +3,9 @@ // The Skills panel's Progression tab, shown on ILT-like worlds only: // - XP planner: exact XP for the next N raises of every attribute and vital, // from the client's XP tables (raising stays on the Attributes & Vitals tab). +// - Attribute raiser: infinite attributes past the retail cap. RynthAi reads the +// server's costs ("/xp all") and raises with "/attr", by hand (+1 / +10) or on a +// timer from unassigned XP, in the order and mode set here. // - Augmentations / Enlightenment: RynthAi's ILT Hub planners. RynthAi owns the // math and the saved inputs (UiSources.Progression snapshot); edits and // actions go back as "prog ..." remote commands. /enl and arming @@ -10,6 +13,7 @@ // ============================================================================ using System; +using System.Collections.Generic; using System.Globalization; using System.Numerics; using ImGuiNET; @@ -99,6 +103,8 @@ internal sealed partial class SkillsFace Message("Augmentations and Enlightenment need RynthAi's ILT Hub on an ILT world.", w); return; } + DrawAttrRaiser(info.Attr, w); + ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); DrawAugPlanner(info.Aug, w); ImGuiNET.ImGui.Dummy(new Vector2(0, 6)); DrawEnlPlanner(info.Enl, w); @@ -136,7 +142,8 @@ internal sealed partial class SkillsFace foreach (Row r in _vitals) PlannerRow(r, have); ImGuiNET.ImGui.EndTable(); } - Label("Exact costs from the client's XP tables. Raise on the Attributes & Vitals tab.", Dim); + Label("Exact costs from the client's XP tables. Raise on the Attributes & Vitals tab" + + (ProgressionTabVisible ? ", or past the cap with the Attribute raiser below." : "."), Dim); ImGuiNET.ImGui.Unindent(8); } @@ -159,6 +166,152 @@ internal sealed partial class SkillsFace Label(text, many >= 0 && many <= have ? Teal : Dim); } + private static readonly string[] AttrModes = + { + "Priority - top of the order first", + "Round robin - one level each, in order", + "Cheapest next level first", + }; + + private string? _attrKeepEdit; // reserve box being typed in (null = show RynthAi's value) + private int? _attrEveryEdit; // interval box being typed in + + private void DrawAttrRaiser(AttrRaiser? a, float w) + { + Section("Attribute raiser (infinite attributes)", w); + ImGuiNET.ImGui.Indent(8); + float wrap = ImGuiNET.ImGui.GetCursorPosX() + w - 24; + ImGuiNET.ImGui.PushTextWrapPos(wrap); + try + { + if (a == null) { Label("Update RynthAi to use the attribute raiser.", Mute); return; } + if (a.Off) { Label(a.Reason, Mute); return; } + + Label(a.Unassigned, Teal); + Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos(); + if (a.Running) + { + if (Button("##attr_stop", "Stop", p, new Vector2(90, 24), Text, StopBg)) SendProg("attrstop"); + } + else if (Button("##attr_run", "Raise now", p, new Vector2(110, 24), Text, StartBg, border: Teal)) + SendProg("attrrun"); + if (Button("##attr_costs", "Refresh costs", new Vector2(p.X + 116, p.Y), new Vector2(110, 24), Text, BtnFill)) + SendProg("attrcosts"); + NextLine(p, 28); + if (a.Status.Length > 0) ImGuiNET.ImGui.TextWrapped(a.Status); + if (a.LastRun.Length > 0) Label("Last run: " + a.LastRun, Dim); + + ImGuiNET.ImGui.Separator(); + bool auto = a.Auto; + if (ImGuiNET.ImGui.Checkbox("Auto-raise from unassigned XP##attr_auto", ref auto)) + SendProg("attrauto " + (auto ? "on" : "off")); + ImGuiNET.ImGui.SameLine(); + // Commit on Enter, the +/- buttons or focus loss (not on every keystroke: each send + // restarts the auto-raise timer). + int every = _attrEveryEdit ?? a.Every; + ImGuiNET.ImGui.SetNextItemWidth(90); + bool everyCommit = ImGuiNET.ImGui.InputInt("every (min)##attr_every", ref every, 1, 10, ImGuiInputTextFlags.EnterReturnsTrue); + bool everyActive = ImGuiNET.ImGui.IsItemActive(); + if (everyCommit || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit()) + { + _attrEveryEdit = null; + if (every != a.Every) SendProg("attrevery " + Math.Clamp(every, 1, 1440).ToString(CultureInfo.InvariantCulture)); + } + else _attrEveryEdit = everyActive ? every : null; + if (a.Auto && a.Next.Length > 0) Label($"Next auto-raise: {a.Next}", Dim); + + int mode = Math.Clamp(a.Mode, 0, AttrModes.Length - 1); + ImGuiNET.ImGui.SetNextItemWidth(260); + if (ImGuiNET.ImGui.Combo("Raise order##attr_mode", ref mode, AttrModes, AttrModes.Length)) + SendProg("attrmode " + mode.ToString(CultureInfo.InvariantCulture)); + + // The box holds the exact reserve (KeepFull); it is sent only when the text changed, so an + // Enter on an untouched box can't round the reserve. + string shownKeep = a.KeepFull.Length > 0 ? a.KeepFull : a.Keep; + string keep = _attrKeepEdit ?? shownKeep; + ImGuiNET.ImGui.SetNextItemWidth(140); + bool enter = ImGuiNET.ImGui.InputTextWithHint("Keep in reserve (XP)##attr_keep", "0, 500m, 2b", ref keep, 32u, + ImGuiInputTextFlags.EnterReturnsTrue); + bool keepActive = ImGuiNET.ImGui.IsItemActive(); + if (enter || ImGuiNET.ImGui.IsItemDeactivatedAfterEdit()) + { + _attrKeepEdit = null; + if (!string.Equals(keep.Trim(), shownKeep, StringComparison.Ordinal)) + SendProg("attrkeep " + keep.Replace(" ", "", StringComparison.Ordinal).Replace(",", "", StringComparison.Ordinal)); + } + else _attrKeepEdit = keepActive ? keep : null; + ImGuiNET.ImGui.SetItemTooltip("Unassigned XP the raiser never spends. Accepts k / m / b / t suffixes."); + + DrawAttrTable(a, w); + Label("Tick the stats Raise now / auto-raise may spend on; arrows set the order. " + a.CostsAge + ".", Dim); + } + finally + { + ImGuiNET.ImGui.PopTextWrapPos(); + ImGuiNET.ImGui.Unindent(8); + } + } + + private void DrawAttrTable(AttrRaiser a, float w) + { + if (!ImGuiNET.ImGui.BeginTable("##prog_attr", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV | ImGuiTableFlags.SizingStretchProp, + new Vector2(w - 16, 0))) + return; + ImGuiNET.ImGui.TableSetupColumn("Raise", ImGuiTableColumnFlags.WidthFixed, 40); + ImGuiNET.ImGui.TableSetupColumn("Stat"); + ImGuiNET.ImGui.TableSetupColumn("Base", ImGuiTableColumnFlags.WidthFixed, 56); + ImGuiNET.ImGui.TableSetupColumn("Next level", ImGuiTableColumnFlags.WidthFixed, 80); + ImGuiNET.ImGui.TableSetupColumn("Order / by hand", ImGuiTableColumnFlags.WidthFixed, 150); + ImGuiNET.ImGui.TableHeadersRow(); + for (int i = 0; i < a.Rows.Length; i++) + { + AttrRow r = a.Rows[i]; + ImGuiNET.ImGui.PushID("attr_" + r.Key); + ImGuiNET.ImGui.TableNextRow(); + + ImGuiNET.ImGui.TableNextColumn(); + bool on = r.On; + if (ImGuiNET.ImGui.Checkbox("##on", ref on)) SendProg($"attron {r.Key} {(on ? "on" : "off")}"); + + ImGuiNET.ImGui.TableNextColumn(); + Label($"{i + 1}. {r.Label}", r.On ? Text : Mute); + + ImGuiNET.ImGui.TableNextColumn(); + int clientBase = ClientBase(r); + Label(clientBase > 0 ? clientBase.ToString("N0", CultureInfo.InvariantCulture) + : r.Base >= 0 ? r.Base.ToString("N0", CultureInfo.InvariantCulture) : "-", Text); + + ImGuiNET.ImGui.TableNextColumn(); + Label(r.Cost, r.Afford ? Teal : Dim); + + ImGuiNET.ImGui.TableNextColumn(); + ImGuiNET.ImGui.BeginDisabled(i == 0); + if (ImGuiNET.ImGui.ArrowButton("##up", ImGuiDir.Up)) SendProg($"attrmove {r.Key} up"); + ImGuiNET.ImGui.EndDisabled(); + ImGuiNET.ImGui.SameLine(0, 2); + ImGuiNET.ImGui.BeginDisabled(i == a.Rows.Length - 1); + if (ImGuiNET.ImGui.ArrowButton("##down", ImGuiDir.Down)) SendProg($"attrmove {r.Key} down"); + ImGuiNET.ImGui.EndDisabled(); + ImGuiNET.ImGui.SameLine(0, 6); + ImGuiNET.ImGui.BeginDisabled(a.Running); + if (ImGuiNET.ImGui.SmallButton("+1")) SendProg($"attrraise {r.Key} 1"); + ImGuiNET.ImGui.SameLine(0, 2); + if (ImGuiNET.ImGui.SmallButton("+10")) SendProg($"attrraise {r.Key} 10"); + ImGuiNET.ImGui.EndDisabled(); + ImGuiNET.ImGui.PopID(); + } + ImGuiNET.ImGui.EndTable(); + } + + /// The client's own base value for a raiser row (0 when the snapshot has none). + private int ClientBase(AttrRow r) + { + List rows = r.Vital ? _vitals : _attributes; + foreach (Row row in rows) + if (row.Name.Equals(r.Label, StringComparison.OrdinalIgnoreCase)) return row.Base; + return 0; + } + private void DrawAugPlanner(AugPlanner a, float w) { Section("Augmentations", w); diff --git a/src/RynthCore.Engine/UI/Data/ProgressionData.cs b/src/RynthCore.Engine/UI/Data/ProgressionData.cs index 60bef5a..4c31042 100644 --- a/src/RynthCore.Engine/UI/Data/ProgressionData.cs +++ b/src/RynthCore.Engine/UI/Data/ProgressionData.cs @@ -1,7 +1,7 @@ // ============================================================================ // RynthCore.Engine - UI/Data/ProgressionData.cs -// RynthAi's ILT progression planners (augmentations, enlightenment) for the -// Skills panel's Progression tab. RynthAi owns the math and the persisted +// RynthAi's ILT progression planners (augmentations, enlightenment) and the +// infinite-attribute raiser for the Skills panel's Progression tab. RynthAi owns the math and the persisted // inputs; this side only shows the snapshot and sends "prog ..." remote // commands (RynthAiCommands.ApplyRemoteCommand) for edits and actions. // ============================================================================ @@ -22,6 +22,49 @@ internal sealed class ProgressionInfo [JsonPropertyName("world")] public string World { get; set; } = ""; [JsonPropertyName("aug")] public AugPlanner Aug { get; set; } = new(); [JsonPropertyName("enl")] public EnlPlanner Enl { get; set; } = new(); + /// Absent from an older RynthAi: stays empty and the section shows "update RynthAi". + [JsonPropertyName("attr")] public AttrRaiser? Attr { get; set; } +} + +/// RynthAi's IltAttributeRaiser: server costs ("/xp all") and the raise settings. +internal sealed class AttrRaiser +{ + /// The raiser can't run here; says why. + [JsonPropertyName("off")] public bool Off { get; set; } + [JsonPropertyName("reason")] public string Reason { get; set; } = ""; + [JsonPropertyName("auto")] public bool Auto { get; set; } + /// Minutes between auto-raise runs. + [JsonPropertyName("every")] public int Every { get; set; } = 5; + /// 0 priority, 1 round robin, 2 cheapest first. + [JsonPropertyName("mode")] public int Mode { get; set; } + [JsonPropertyName("running")] public bool Running { get; set; } + /// XP reserve, preformatted ("0", "1.50B"). + [JsonPropertyName("keep")] public string Keep { get; set; } = "0"; + /// XP reserve in full ("1,234,567"): what the reserve box edits. + [JsonPropertyName("keepFull")] public string KeepFull { get; set; } = ""; + [JsonPropertyName("status")] public string Status { get; set; } = ""; + [JsonPropertyName("lastRun")] public string LastRun { get; set; } = ""; + [JsonPropertyName("unassigned")] public string Unassigned { get; set; } = ""; + /// Time to the next auto run ("" when auto is off). + [JsonPropertyName("next")] public string Next { get; set; } = ""; + [JsonPropertyName("costsAge")] public string CostsAge { get; set; } = ""; + /// In raise-priority order. + [JsonPropertyName("rows")] public AttrRow[] Rows { get; set; } = Array.Empty(); +} + +internal sealed class AttrRow +{ + /// /attr abbreviation: str end coo qui foc sel hea sta man. + [JsonPropertyName("key")] public string Key { get; set; } = ""; + [JsonPropertyName("label")] public string Label { get; set; } = ""; + [JsonPropertyName("vital")] public bool Vital { get; set; } + /// Ticked: "Raise now" and auto-raise may spend on it. + [JsonPropertyName("on")] public bool On { get; set; } + /// Base value RynthAi last saw in a server reply (-1 = unknown; the panel prefers the client's). + [JsonPropertyName("base")] public int Base { get; set; } = -1; + /// Next-level cost from "/xp all", preformatted ("?" until read). + [JsonPropertyName("cost")] public string Cost { get; set; } = "?"; + [JsonPropertyName("afford")] public bool Afford { get; set; } } internal sealed class AugPlanner diff --git a/src/RynthCore.Engine/UI/Data/SettingsData.cs b/src/RynthCore.Engine/UI/Data/SettingsData.cs index 45704cb..5743159 100644 --- a/src/RynthCore.Engine/UI/Data/SettingsData.cs +++ b/src/RynthCore.Engine/UI/Data/SettingsData.cs @@ -44,6 +44,13 @@ internal sealed class RynthAiSettings // Decal bridge: stop RynthAi's macro when VTank's starts (one bot per client). Default on; // an older RynthAi doesn't send it, and a missing field must not read as "off". public bool YieldToVTank { get; set; } = true; + // Server Features (RynthAi ServerFeatureGate): world names that turn on the ILT Hub, the + // Progression planners and the attribute raiser, plus a manual override. An older RynthAi + // doesn't send them; RynthAi lays a save over its current values, so these defaults are + // only ever shown, never applied. ServerFeaturesStatus is read-only (RynthAi ignores it). + public string FeatureServerNames { get; set; } = "InfiniteLeaftide, *Leaftide*"; + public bool ForceServerFeatures { get; set; } + public string ServerFeaturesStatus { get; set; } = string.Empty; public bool EnableRaycasting { get; set; } public bool UseArcs { get; set; } public float BowArcVelocity { get; set; } = 25f; @@ -265,7 +272,7 @@ internal static unsafe class SettingsCommands // ── Schema ───────────────────────────────────────────────────────────────── -internal enum SettingKind { Bool, Int, Float, Double, Combo, Section, Spacer, Note, CraftingStatus, Button } +internal enum SettingKind { Bool, Int, Float, Double, Combo, Section, Spacer, Note, CraftingStatus, Button, Text, Status } /// /// One row of a settings tab. Numeric values go through double (bools as @@ -286,7 +293,12 @@ internal sealed record SettingRow( bool Gates = false, // Button rows: the button's caption (Label is the row label) and its action. Any thread. string? ButtonText = null, - Action? Click = null) + Action? Click = null, + // Text rows: the string value (committed on Enter / focus loss); Status rows: GetText only. + Func? GetText = null, + Action? SetText = null, + // Text rows: greyed hint shown while the box is empty. + string? Hint = null) { public bool IsVisible(RynthAiSettings s) => VisibleWhen == null || VisibleWhen(s); } @@ -367,6 +379,14 @@ internal static class SettingsSchema private static SettingRow Button(string label, string buttonText, Action click, string? tip = null) => new(SettingKind.Button, label, tip, ButtonText: buttonText, Click: click); + private static SettingRow Text(string label, Func get, Action set, + string? tip = null, string? hint = null) => + new(SettingKind.Text, label, tip, GetText: get, SetText: set, Hint: hint); + + // A one-line status RynthAi computes (read-only; empty = hidden). + private static SettingRow Status(Func get) => + new(SettingKind.Status, "", GetText: get, VisibleWhen: s => !string.IsNullOrEmpty(get(s))); + private static SettingRow[] Tiers(Func[] get, Action[] set) { var rows = new SettingRow[get.Length]; @@ -457,6 +477,17 @@ internal static class SettingsSchema "With Decal: when VTank's macro starts (/vt start), RynthAi's macro stops, and it won't start while VTank runs.\nOne bot per client. Without Decal this does nothing. Also: /ra vtankyield on|off."), Bool("Enable Raycasting", s => s.EnableRaycasting, (s, v) => s.EnableRaycasting = v), Spacer(), + Section("Server Features (ILT / infinite attributes)"), + Status(s => s.ServerFeaturesStatus), + Text("Servers", s => s.FeatureServerNames, (s, v) => s.FeatureServerNames = v, + "Comma-separated world names that turn on the ILT Hub, the Skills panel's Progression planners\n" + + "and the attribute raiser. * is a wildcard (*Leaftide* matches any name containing Leaftide).\n" + + "Case does not matter. Saved with the RynthAi profile.", + hint: "InfiniteLeaftide, *Leaftide*"), + Bool("Force enable on this server (manual override)", s => s.ForceServerFeatures, (s, v) => s.ForceServerFeatures = v, + "Turn the features on for whatever world you are on, even if it is not in the list.\n" + + "Each feature still follows what the server reports (for example /xp off keeps the attribute raiser off)."), + Spacer(), Section("Missile Arc Velocities (m/s)"), Bool("Use Arcs for Missile LoS", s => s.UseArcs, (s, v) => s.UseArcs = v, "A missile target must pass both the straight line and the real arrow arc, ceilings included (dungeons too).\nWhen off, all missile LoS checks are linear (eye-to-eye).", gates: true), diff --git a/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs b/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs index c8f4e1d..e3a7fe4 100644 --- a/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/SettingsPanel.cs @@ -335,6 +335,21 @@ internal static class SettingsPanel return Spacer(); case SettingKind.Button: return ButtonRow(row.Label, row.ButtonText ?? row.Label, () => row.Click?.Invoke(), row.Tooltip); + case SettingKind.Text: + return TextRow(row.Label, row.GetText?.Invoke(d) ?? string.Empty, row.Hint, v => + { + row.SetText?.Invoke(state.Data, v); + Push(state); + }, row.Tooltip); + case SettingKind.Status: + { + string status = row.GetText?.Invoke(d) ?? string.Empty; + return status.Length == 0 ? null : new TextBlock + { + Text = status, Foreground = ColTeal, FontSize = 11, + TextWrapping = Avalonia.Media.TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2), + }; + } case SettingKind.Note: return new TextBlock { @@ -418,6 +433,53 @@ internal static class SettingsPanel return row; } + /// Label above a full-width text box; commits on Enter or focus loss when the text changed. + private static Control TextRow(string label, string value, string? hint, Action onChange, string? tooltip = null) + { + string committed = value; + var box = new StackPanel { Margin = new Thickness(0, 2, 0, 2) }; + box.Children.Add(new TextBlock { Text = label, Foreground = ColTextDim, FontSize = 11, Margin = new Thickness(0, 0, 0, 2) }); + var tb = new TextBox + { + Text = value, + Watermark = hint, + FontSize = 11, + Height = 22, + Padding = new Thickness(4, 2), + Background = ColPanelBg, + Foreground = ColAmber, + BorderBrush = ColBtnBord, + BorderThickness = new Thickness(1), + VerticalContentAlignment = VerticalAlignment.Center, + }; + DisableInnerScroll(tb); + void Commit() + { + string text = tb.Text ?? string.Empty; + if (string.Equals(text, committed, StringComparison.Ordinal)) return; + committed = text; + onChange(text); + } + // Same keyboard gate as the number boxes: typed keys go to Avalonia, not the game. + tb.GotFocus += (_, _) => Win32Backend.AvaloniaTextInputActive = true; + tb.LostFocus += (_, _) => + { + Win32Backend.AvaloniaTextInputActive = false; + Commit(); + }; + tb.KeyDown += (_, e) => + { + if (e.Key == Avalonia.Input.Key.Enter) Commit(); + }; + box.Children.Add(tb); + if (tooltip != null) + { + ToolTip.SetTip(box, tooltip); + ToolTip.SetShowDelay(box, 400); + } + return box; + } + private static Control IntRow(string label, int value, int min, int max, int step, Action onChange, string? tooltip = null) { int current = Math.Clamp(value, min, max);