Snapshot for release 2026.11.2.1 (internal 8d9795d)
This commit is contained in:
parent
b1c182b05d
commit
00ee01167e
29 changed files with 925 additions and 52 deletions
|
|
@ -234,6 +234,30 @@ internal static class EngineFrameController
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init worker, before the plugins load and before the EndScene hook can go in (2026-11-02):
|
||||
/// starts the first atlas's bake (~2 s) for the game window's DPI scale, so it runs during the
|
||||
/// world load rather than after login. Init's first part then finds it baking or baked; for a
|
||||
/// different scale it bakes again (ImGuiFonts.StartInitialBake).
|
||||
/// </summary>
|
||||
internal static void StartEarlyFontBake()
|
||||
{
|
||||
float scale = UiScale.ForWindow(FindGameWindow());
|
||||
if (ImGuiFonts.StartInitialBake(scale))
|
||||
RynthLog.UI($"EngineFrameController: the font atlas bakes now, before login (scale {scale:0.##}).");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Engine shutdown, after the EndScene hook is gone: frees an atlas baked before login for a
|
||||
/// context that was never made (no login, or the hook never got that far). With a context,
|
||||
/// <see cref="Shutdown"/> did it; a second call finds nothing to free.
|
||||
/// </summary>
|
||||
internal static void FreeFontsWithoutContext()
|
||||
{
|
||||
if (_context == IntPtr.Zero && !_imguiInitialized)
|
||||
ImGuiFonts.Free();
|
||||
}
|
||||
|
||||
/// <summary>The new context's ini handling, flags, DPI scale and theme (Init's first part). Context current.</summary>
|
||||
private static void SetUpContext(ImGuiIOPtr io)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ internal static class ImGuiBar
|
|||
// Skills moves under RynthOracle (Skills / Attributes / Progress tabs): its icon shows only while Oracle's
|
||||
// tabs can't be reached (SkillsRouting.ShowSkillsBarIcon), so nobody loses the way in. Mini Remote stays.
|
||||
private static readonly string[] ImGuiOnlyBarPanels =
|
||||
{ Panels.InventoryFace.Title, Panels.SkillsFace.Title, Panels.SenseFace.Title, Panels.MiniRemoteFace.Title };
|
||||
{ Panels.InventoryFace.Title, Panels.SkillsFace.Title, Panels.SenseFace.Title, Panels.MiniRemoteFace.Title,
|
||||
Panels.ItemToolFace.Title };
|
||||
|
||||
/// <summary>An ImGui-only panel's bar button is wanted: it has a face, and Skills only while Oracle can't host it.</summary>
|
||||
private static bool ImGuiOnlyWanted(string title) =>
|
||||
|
|
@ -117,8 +118,10 @@ internal static class ImGuiBar
|
|||
["Inventory"] = PhosphorIcons.Package, // not Backpack: the dashboard's Items launcher has that
|
||||
["Log"] = PhosphorIcons.TerminalWindow,
|
||||
["Item Count"] = PhosphorIcons.Bag,
|
||||
["Item Tool"] = PhosphorIcons.Wrench,
|
||||
["Mini Remote"] = PhosphorIcons.SquaresFour,
|
||||
["Characters"] = PhosphorIcons.UsersThree,
|
||||
["Item Tool"] = PhosphorIcons.Wrench, // RynthAi's chest looter + Quick give
|
||||
// Plugin windows with a bar button of their own (script windows, by title).
|
||||
["RynthSort"] = PhosphorIcons.SortAscending,
|
||||
["Oracle"] = PhosphorIcons.Sparkle,
|
||||
|
|
|
|||
|
|
@ -433,6 +433,7 @@ internal static unsafe class ImGuiFonts
|
|||
|
||||
private static System.Threading.Thread? _bakeThread;
|
||||
private static Bake? _bakeDone; // set by the worker as it ends
|
||||
private static float _bakeScale; // the scale _bakeThread bakes for
|
||||
private static readonly List<System.Threading.Thread> FreeThreads = new();
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -452,6 +453,7 @@ internal static unsafe class ImGuiFonts
|
|||
try
|
||||
{
|
||||
_bakeDone = null;
|
||||
_bakeScale = scale;
|
||||
_bakeThread = EngineThreads.Start("ImGuiFonts.Bake", () => BakeWorker(scale, steps, prepare: false));
|
||||
return false;
|
||||
}
|
||||
|
|
@ -468,16 +470,26 @@ internal static unsafe class ImGuiFonts
|
|||
/// <summary>
|
||||
/// The first atlas of a context, baked on a worker (see the header): reading the font files if
|
||||
/// the init worker hasn't, making their native copies, queueing every font, rasterizing, the
|
||||
/// BGRA copy and freeing the TTF copies all happen there. AC thread, once the scale is known.
|
||||
/// False when no worker could be started (the caller then calls <see cref="Build"/>).
|
||||
/// BGRA copy and freeing the TTF copies all happen there. AC thread, once the scale is known,
|
||||
/// or the init worker before login (EngineFrameController.StartEarlyFontBake; never both at
|
||||
/// once: the EndScene hook goes in after that call). False when no worker could be started
|
||||
/// (the caller then calls <see cref="Build"/>).
|
||||
/// </summary>
|
||||
public static bool StartInitialBake(float scale)
|
||||
{
|
||||
if (_bakeThread != null) return true;
|
||||
if (_bakeThread != null)
|
||||
{
|
||||
// Started early, on the init worker before login (EngineFrameController.StartEarlyFontBake),
|
||||
// for the scale the game window had then: kept when the context gets that scale too.
|
||||
if (_bakeScale == scale) return true;
|
||||
RynthLog.UI($"ImGuiFonts: the atlas baked before login is for scale {_bakeScale:0.##}, the context's is {scale:0.##}: baking again.");
|
||||
DropBake();
|
||||
}
|
||||
List<int> steps = RynthCore.Engine.UI.PanelTextScale.StepsInUse();
|
||||
try
|
||||
{
|
||||
_bakeDone = null;
|
||||
_bakeScale = scale;
|
||||
_bakeThread = EngineThreads.Start("ImGuiFonts.Bake", () => BakeWorker(scale, steps, prepare: true));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -489,6 +501,18 @@ internal static unsafe class ImGuiFonts
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Waits for the running bake and frees what it made, never swapped in.</summary>
|
||||
private static void DropBake()
|
||||
{
|
||||
_bakeThread?.Join();
|
||||
_bakeThread = null;
|
||||
Bake? pending = _bakeDone;
|
||||
_bakeDone = null;
|
||||
if (pending == null) return;
|
||||
if (pending.Atlas != IntPtr.Zero) ImGuiNative.ImFontAtlas_destroy((ImFontAtlas*)pending.Atlas);
|
||||
FreeBgraPixels(pending.Bgra);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Render thread, with <paramref name="io"/>'s context current: swaps a finished bake (the
|
||||
/// first atlas, or a re-bake) into it. True when the atlas changed (the caller makes its
|
||||
|
|
@ -642,15 +666,7 @@ internal static unsafe class ImGuiFonts
|
|||
{
|
||||
// A worker may still read the buffers below (a bake) or free an atlas.
|
||||
WaitForWorkers();
|
||||
if (_bakeThread != null || _bakeDone != null)
|
||||
{
|
||||
_bakeThread = null;
|
||||
Bake? pending = _bakeDone;
|
||||
_bakeDone = null;
|
||||
if (pending != null && pending.Atlas != IntPtr.Zero)
|
||||
ImGuiNative.ImFontAtlas_destroy((ImFontAtlas*)pending.Atlas); // baked, never swapped in
|
||||
if (pending != null) FreeBgraPixels(pending.Bgra);
|
||||
}
|
||||
DropBake(); // baked, never swapped in
|
||||
FreeBgraPixels(_bgra);
|
||||
_bgra = IntPtr.Zero;
|
||||
_bgraWidth = _bgraHeight = 0;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// (the subsystem toggles) with a live line
|
||||
// Ranges monster range, ring range, approach, follow/nav min
|
||||
// Behavior autostack, autocram, peace mode / rebuff when idle,
|
||||
// navigation first, looting first, rare corpses only,
|
||||
// navigate only, looting first, rare corpses only,
|
||||
// manage fellowship
|
||||
// Magic and pets dispel items / self, M. charges when off, summon pets,
|
||||
// pet range, pet min monsters
|
||||
|
|
@ -50,7 +50,7 @@ internal sealed class ClassicMainTab : IClassicTab
|
|||
|
||||
private static readonly (string Schema, string Label)[] BehaviorRight =
|
||||
{
|
||||
("Boost Nav Priority", "Navigation first"), ("Boost Loot Priority", "Looting first"),
|
||||
("Boost Nav Priority", "Navigate only (no hunting, no looting)"), ("Boost Loot Priority", "Looting first"),
|
||||
("Loot Only Rare Corpses", "Rare corpses only"), ("Auto Fellowship Management", "Manage fellowship"),
|
||||
};
|
||||
|
||||
|
|
|
|||
143
src/RynthCore.Engine/ImGui/Panels/ItemToolFace.cs
Normal file
143
src/RynthCore.Engine/ImGui/Panels/ItemToolFace.cs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/ItemToolFace.cs
|
||||
// The Item Tool panel: two small tools of RynthAi's, each picked, started and
|
||||
// stopped by the player. Engine only, ImGui only; the work is RynthAi's
|
||||
// (RynthAiPlugin.ItemTool.cs), this is its buttons and status lines.
|
||||
//
|
||||
// Chest looter "Pick a chest. Pick a key. It just loots the chest based on the
|
||||
// current loot profile until it's out of keys."
|
||||
// Select the chest in the world, press Use selected as chest;
|
||||
// select the key in your pack, press Use selected as key; Start.
|
||||
// Quick give Select an item in your pack (Use selected as item) and a player
|
||||
// or NPC in the world (Use selected as target), press Give: every
|
||||
// such item in your packs is handed over, one give at a time.
|
||||
// The target's name is shown (PLAYER for a player).
|
||||
//
|
||||
// Data: ItemToolSource (RynthPluginGetItemToolJson, 250 ms while open). Buttons
|
||||
// post words to RynthPluginItemToolCommand (ItemToolCommands.Send), the same
|
||||
// words as "/ra itemtool ...". Draw reads a snapshot and posts; no AC calls.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.FaceKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels;
|
||||
|
||||
internal sealed class ItemToolFace : IImGuiPanel
|
||||
{
|
||||
public const string Title = "Item Tool";
|
||||
|
||||
public static void Register() => ImGuiPanelHost.Register(Title,
|
||||
new PanelSpec(new Vector2(320, 400), new Vector2(240, 260), EdgeToEdge: true, GripInBody: true),
|
||||
() => new ItemToolFace());
|
||||
|
||||
public void OnShown()
|
||||
{
|
||||
UiSources.ItemTool.Subscribe();
|
||||
UiSources.ItemTool.RequestRefresh();
|
||||
}
|
||||
|
||||
public void OnHidden() => UiSources.ItemTool.Unsubscribe();
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
float w = Begin(out Vector2 origin, out Vector2 size);
|
||||
ItemToolSnapshot? snap = UiSources.ItemTool.Current?.Value;
|
||||
float bodyH = Math.Max(30, Remaining(origin, size) - GripOverlap());
|
||||
ImGuiNET.ImGui.BeginChild("##itemtool_body", new Vector2(w, bodyH));
|
||||
if (snap == null)
|
||||
Wrapped("Waiting for RynthAi (log in, and RynthAi must be loaded).", Mute, w);
|
||||
else
|
||||
{
|
||||
DrawChest(snap.Chest, w);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(0, 4));
|
||||
Separator(w);
|
||||
DrawGive(snap.Give, w);
|
||||
}
|
||||
ImGuiNET.ImGui.EndChild();
|
||||
End(origin, size);
|
||||
}
|
||||
|
||||
// ── Chest looter ────────────────────────────────────────────────────
|
||||
|
||||
private static void DrawChest(ChestToolState c, float w)
|
||||
{
|
||||
Label("Chest looter", Teal);
|
||||
Wrapped("Loots the chest with the current loot profile, then waits for it to re-lock and goes again, until the key is used up.", Mute, w);
|
||||
Pick("Chest:", c.Name, "(none: select the chest in the world)", w);
|
||||
Pick("Key:", c.Key, "(none: select the key in your pack)", w);
|
||||
|
||||
bool ready = c.Name.Length > 0 && c.Key.Length > 0;
|
||||
int hit = WrapButtons("##chest_pick", new[] { "Use selected as chest", "Use selected as key" }, w, 22,
|
||||
new[] { !c.Running, !c.Running });
|
||||
if (hit == 0) ItemToolCommands.Send("chest set");
|
||||
else if (hit == 1) ItemToolCommands.Send("chest key");
|
||||
|
||||
hit = StartStop("##chest_run", "Start", "Stop", ready && !c.Running, c.Running, w);
|
||||
if (hit == 0) ItemToolCommands.Send("chest start");
|
||||
else if (hit == 1) ItemToolCommands.Send("chest stop");
|
||||
|
||||
Wrapped(c.Status, c.Running ? Amber : Text, w);
|
||||
}
|
||||
|
||||
// ── Quick give ──────────────────────────────────────────────────────
|
||||
|
||||
private static void DrawGive(GiveToolState g, float w)
|
||||
{
|
||||
Label("Quick give", Teal);
|
||||
Wrapped("Hands every matching item in your packs to one player or NPC, one give at a time, until none is left or you press Stop. Never worn gear.", Mute, w);
|
||||
Pick("Item:", g.Item, "(none: select the item in your pack)", w);
|
||||
Pick("Target:", g.Target, "(none: select the player or NPC in the world)", w);
|
||||
|
||||
bool ready = g.Item.Length > 0 && g.Target.Length > 0;
|
||||
int hit = WrapButtons("##give_pick", new[] { "Use selected as item", "Use selected as target" }, w, 22,
|
||||
new[] { !g.Running, !g.Running });
|
||||
if (hit == 0) ItemToolCommands.Send("giveitem");
|
||||
else if (hit == 1) ItemToolCommands.Send("givetarget");
|
||||
|
||||
hit = StartStop("##give_run", "Give", "Stop", ready && !g.Running, g.Running, w);
|
||||
if (hit == 0) ItemToolCommands.Send("give");
|
||||
else if (hit == 1) ItemToolCommands.Send("givestop");
|
||||
|
||||
Wrapped(g.Status, g.Running ? Amber : Text, w);
|
||||
}
|
||||
|
||||
// ── Pieces ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>"Label value" (amber while nothing is picked, the hint then).</summary>
|
||||
private static void Pick(string label, string value, string hint, float w)
|
||||
{
|
||||
Label(label, Mute);
|
||||
ImGuiNET.ImGui.SameLine(0, 6);
|
||||
bool none = value.Length == 0;
|
||||
Wrapped(none ? hint : value, none ? Mute : Text, Math.Max(40, w - ImGuiNET.ImGui.CalcTextSize(label).X - 10));
|
||||
}
|
||||
|
||||
/// <summary>A Start and a Stop button side by side; returns 0 (start), 1 (stop) or -1.</summary>
|
||||
private static int StartStop(string id, string startLabel, string stopLabel, bool canStart, bool canStop, float w)
|
||||
{
|
||||
Vector2 start = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
const float h = 24;
|
||||
float bw = Math.Max(ButtonWidth(startLabel), ButtonWidth(stopLabel)) + 20;
|
||||
int hit = -1;
|
||||
ImGuiNET.ImGui.PushID(id);
|
||||
if (Button("##start", startLabel, start, new Vector2(bw, h), Text, StartBg, canStart)) hit = 0;
|
||||
if (Button("##stop", stopLabel, new Vector2(start.X + bw + 6, start.Y), new Vector2(bw, h), Text, StopBg, canStop)) hit = 1;
|
||||
ImGuiNET.ImGui.PopID();
|
||||
NextLine(start, h + 4);
|
||||
return hit;
|
||||
}
|
||||
|
||||
private static void Wrapped(string text, uint color, float w)
|
||||
{
|
||||
if (text.Length == 0) return;
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, color);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
}
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
const float refreshW = 26;
|
||||
float saveAsW = BtnW("Save As", 60), indW = SaveIndicatorWidth();
|
||||
float pickW = Math.Max(60, w - refreshW - saveAsW - indW - 12);
|
||||
float pickW = Math.Max(60, w - refreshW * 2 - saveAsW - indW - 16);
|
||||
int picked = Picker("##file", _fileDisplay, _fileDisplays, MetaVocabulary.CurrentFileIndex(_data), p, pickW);
|
||||
if (picked >= 0 && picked < _data.Files.Count)
|
||||
{
|
||||
|
|
@ -302,6 +302,18 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
UiSources.Meta.RequestRefresh();
|
||||
ImGuiNET.ImGui.SetItemTooltip("Refresh file list");
|
||||
x += refreshW + 4;
|
||||
// Reload: read the loaded meta's file again (the same as picking it in the list), e.g. after
|
||||
// a new build of it was copied in.
|
||||
int cur = MetaVocabulary.CurrentFileIndex(_data);
|
||||
string? reloadPath = cur >= 0 && cur < _data.Files.Count ? _data.Files[cur].Path : _data.CurrentMetaPath;
|
||||
if (IconButton("##reload", PhosphorIcons.ArrowCounterClockwise, new Vector2(x, p.Y), new Vector2(refreshW, 22), TextDim, BtnFill, BtnBord,
|
||||
font: UiFont.Ui14) && !string.IsNullOrEmpty(reloadPath))
|
||||
{
|
||||
FlushEdit();
|
||||
MetaCommands.Simple("load_file", path: reloadPath);
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Reload this meta from its file");
|
||||
x += refreshW + 4;
|
||||
bool noFile = string.IsNullOrEmpty(_data.CurrentMetaPath);
|
||||
if (Button("Save As##save_as", new Vector2(x, p.Y), new Vector2(saveAsW, 22), TextDim, noFile ? NewFill : BtnFill, noFile ? Green : BtnBord))
|
||||
BeginSaveAs();
|
||||
|
|
@ -875,6 +887,9 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
/// one more entry after the items ("+ New state..."): picking it returns items.Length. Returns the
|
||||
/// picked index or -1.
|
||||
/// </summary>
|
||||
// Set when a picker's list is opened; the first frame of the list scrolls its chosen row to the top.
|
||||
private bool _pickerScrollToSelected;
|
||||
|
||||
private int Picker(string id, string shown, string[] items, int selected, Vector2 pos, float width, float height = 22,
|
||||
string? extra = null, string? badge = null)
|
||||
{
|
||||
|
|
@ -888,6 +903,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
Vector2 display = ImGuiNET.ImGui.GetIO().DisplaySize;
|
||||
ImGuiNET.ImGui.SetNextWindowPos(new Vector2(Math.Clamp(pos.X, 0, Math.Max(0, display.X - listW)), pos.Y + height));
|
||||
ImGuiNET.ImGui.OpenPopup("##list");
|
||||
_pickerScrollToSelected = true;
|
||||
}
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
dl.AddRectFilled(pos, pos + new Vector2(width, height), hot ? Lighten(BtnFill) : BtnFill, 3);
|
||||
|
|
@ -931,6 +947,8 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PopID();
|
||||
bool isExtra = i == items.Length;
|
||||
bool sel = !isExtra && i == selected;
|
||||
// The list opens with the chosen row at its top, not at the first row every time.
|
||||
if (sel && _pickerScrollToSelected) ImGuiNET.ImGui.SetScrollHereY(0f);
|
||||
pdl.AddRectFilled(ip, ip + new Vector2(iw, 20), sel ? PickSel : ih ? Lighten(BtnFill) : isExtra ? NewFill : BtnFill);
|
||||
pdl.AddRect(ip, ip + new Vector2(iw, 20), isExtra ? Green : BtnBord);
|
||||
pdl.AddText(ip + new Vector2(6, (20 - ImGuiNET.ImGui.GetFontSize()) * 0.5f), isExtra ? Green : sel ? Teal : TextDim,
|
||||
|
|
@ -942,6 +960,7 @@ internal sealed partial class MetaFace : IImGuiPanel
|
|||
}
|
||||
}
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
_pickerScrollToSelected = false;
|
||||
}
|
||||
ImGuiNET.ImGui.PopID();
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(pos.X, pos.Y + height));
|
||||
|
|
|
|||
|
|
@ -1144,6 +1144,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
SkillsMenuItem("Progress", "/rc progression", 2, "Augmentation, Enlightenment and XP planners (Infinite Leaftide).");
|
||||
PanelMenuItem(InventoryFace.Title, "/rc inventory");
|
||||
PanelMenuItem(ItemCountFace.Title, "/rc itemcount");
|
||||
PanelMenuItem(ItemToolFace.Title, "/rc itemtool");
|
||||
// RynthInventory's script window (same as /ginv and Inventory's GInv button).
|
||||
const string ginvKey = "RynthInventory/Main";
|
||||
bool hasGinv = UI.ScriptWindows.ScriptWindowRegistry.Has(ginvKey);
|
||||
|
|
|
|||
Loading…
Reference in a new issue