Snapshot for release 2026.10.20.1 (internal e05e9a8)
This commit is contained in:
parent
7439236e1d
commit
286abd1445
35 changed files with 3569 additions and 65 deletions
|
|
@ -316,7 +316,7 @@
|
|||
<Border Background="#132028" CornerRadius="16" Padding="18">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock Text="Plugins" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
|
||||
<TextBlock Text="The plugins RynthCore loads. Untick one to skip it; the X takes it out of the list (its files stay on disk). RynthSuite plugins you don't have are under Available plugins below; Add Plugin is for any other plugin DLL."
|
||||
<TextBlock Text="The plugins RynthCore loads. Untick one to skip it; the X takes it out of the list (its files stay on disk). RynthSuite plugins you don't have are under Available plugins below; plugins for one game server are on the Server plugins tab. Add Plugin is for any other plugin DLL."
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#9AA8B3" />
|
||||
<StackPanel x:Name="PluginLoadoutPanel" Spacing="10" />
|
||||
|
|
@ -337,6 +337,36 @@
|
|||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
||||
<!-- Server plugins: one per game server, kept apart from the regular plugins. RynthCore loads
|
||||
one only when you connect to its server, so installing several costs nothing elsewhere. -->
|
||||
<TabItem x:Name="ServerPluginsTab" Header="Server plugins">
|
||||
<ScrollViewer>
|
||||
<StackPanel Spacing="12" Margin="6">
|
||||
<Border Background="#132028" CornerRadius="16" Padding="18">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock Text="Your server plugins" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
|
||||
<TextBlock Text="Extras for one game server each. RynthCore loads a server plugin only when you connect to its server; everywhere else it stays off. Untick one to skip it; the X takes it out of the list (its files stay on disk)."
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#9AA8B3" />
|
||||
<TextBlock x:Name="ServerPluginsEmptyText" Text="No server plugins installed."
|
||||
Foreground="#6F7F8A" IsVisible="False" />
|
||||
<StackPanel x:Name="ServerPluginLoadoutPanel" Spacing="10" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Background="#132028" CornerRadius="16" Padding="18">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock Text="Available server plugins" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
|
||||
<TextBlock x:Name="AvailableServerPluginsHint"
|
||||
Text="Server plugins you can add appear here after the first update check."
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#9AA8B3" />
|
||||
<StackPanel x:Name="AvailableServerPluginsPanel" Spacing="10" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Runtime">
|
||||
<ScrollViewer>
|
||||
<StackPanel Spacing="12" Margin="6">
|
||||
|
|
|
|||
|
|
@ -405,18 +405,22 @@ internal partial class MainWindow : Window
|
|||
checkBox.IsCheckedChanged += (_, _) => OnPluginSelectionChanged(plugin, checkBox);
|
||||
_pluginChecks[plugin.Id] = checkBox;
|
||||
|
||||
PluginLoadoutPanel.Children.Add(BuildPluginCard(checkBox, plugin.Summary, null));
|
||||
PluginLoadoutPanel.Children.Add(BuildPluginCard(checkBox, plugin.Summary, null, null));
|
||||
}
|
||||
|
||||
var disabledSet = new HashSet<string>(
|
||||
_settings.DisabledPluginDllPaths ?? new List<string>(),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
ServerPluginLoadoutPanel.Children.Clear();
|
||||
foreach (string dllPath in _pluginDllPaths)
|
||||
{
|
||||
string capturedPath = dllPath;
|
||||
string pluginName = Path.GetFileNameWithoutExtension(dllPath);
|
||||
// "RynthAi", what it does and its folder - not "RynthCore.Plugin.RynthAi" over the DLL's full path.
|
||||
string pluginName = PluginNames.Friendly(dllPath);
|
||||
string pluginVersion = BuildVersion.OfFile(dllPath);
|
||||
KnownServer? server = PluginNames.ServerOf(dllPath);
|
||||
string about = DescribeInstalled(dllPath, server);
|
||||
|
||||
var checkBox = new CheckBox
|
||||
{
|
||||
|
|
@ -425,7 +429,8 @@ internal partial class MainWindow : Window
|
|||
};
|
||||
checkBox.IsCheckedChanged += (_, _) => OnUserPluginEnabledChanged(capturedPath, checkBox);
|
||||
|
||||
PluginLoadoutPanel.Children.Add(BuildPluginCard(checkBox, capturedPath, () =>
|
||||
StackPanel target = server != null ? ServerPluginLoadoutPanel : PluginLoadoutPanel;
|
||||
target.Children.Add(BuildPluginCard(checkBox, about, Path.GetDirectoryName(capturedPath) ?? capturedPath, () =>
|
||||
{
|
||||
// Out of the list (and out of the disabled list, so adding it back starts it
|
||||
// enabled). The files stay where they are.
|
||||
|
|
@ -439,10 +444,25 @@ internal partial class MainWindow : Window
|
|||
RefreshUpdateCard();
|
||||
}));
|
||||
}
|
||||
ServerPluginsEmptyText.IsVisible = ServerPluginLoadoutPanel.Children.Count == 0;
|
||||
|
||||
BuildAvailablePlugins();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One line about an installed plugin: the update feed's description (or the launcher's own line) for a
|
||||
/// RynthSuite plugin; for a server plugin its server and what that server is; otherwise nothing.
|
||||
/// </summary>
|
||||
private string DescribeInstalled(string dllPath, KnownServer? server)
|
||||
{
|
||||
RynthUpdater.PluginEntry? e = _updateCheck?.Manifest.Plugins.FirstOrDefault(p =>
|
||||
string.Equals(p.File, Path.GetFileName(dllPath), StringComparison.OrdinalIgnoreCase));
|
||||
string feed = e != null ? RynthUpdater.DescribePlugin(e) : RynthUpdater.DescribeByName(PluginNames.Friendly(dllPath));
|
||||
if (server == null) return feed;
|
||||
string forServer = $"For {server.Name} ({server.Address}): {server.Note}";
|
||||
return feed.Length > 0 && !feed.Contains(server.Name, StringComparison.OrdinalIgnoreCase) ? $"{forServer} {feed}" : forServer;
|
||||
}
|
||||
|
||||
// ── Available plugins (feed plugins not in the list) ──────────────────────
|
||||
|
||||
private List<RynthUpdater.AvailablePlugin> _available = new();
|
||||
|
|
@ -450,23 +470,36 @@ internal partial class MainWindow : Window
|
|||
private void BuildAvailablePlugins()
|
||||
{
|
||||
AvailablePluginsPanel.Children.Clear();
|
||||
AvailableServerPluginsPanel.Children.Clear();
|
||||
_available = _updateCheck == null ? new() : _updater.GetAvailable(_updateCheck, _pluginDllPaths);
|
||||
if (_updateCheck == null)
|
||||
{
|
||||
AvailablePluginsHint.Text = _updater.IsConfigured
|
||||
string none = _updater.IsConfigured
|
||||
? "Plugins you can add appear here after the first update check."
|
||||
: "Updates aren't set up in this build, so there is no plugin list to install from.";
|
||||
AvailablePluginsHint.Text = none;
|
||||
AvailableServerPluginsHint.Text = none.Replace("Plugins you can add", "Server plugins you can add");
|
||||
return;
|
||||
}
|
||||
if (_available.Count == 0)
|
||||
{
|
||||
AvailablePluginsHint.Text = "You have every RynthSuite plugin.";
|
||||
return;
|
||||
}
|
||||
string suite = Path.GetDirectoryName(Path.GetDirectoryName(_available[0].Path)) ?? RynthUpdater.DefaultSuiteDir;
|
||||
AvailablePluginsHint.Text = $"RynthSuite plugins you don't have. Install downloads one into {suite} and adds it to the list above; it loads the next time AC starts.";
|
||||
foreach (RynthUpdater.AvailablePlugin a in _available)
|
||||
// Server plugins (one game server each) go on their own tab; they muddied the regular list.
|
||||
var regular = _available.Where(a => !PluginNames.IsServerPlugin(a.Entry.Name)).ToList();
|
||||
var forServers = _available.Where(a => PluginNames.IsServerPlugin(a.Entry.Name))
|
||||
.OrderBy(a => PluginNames.ServerOf(a.Entry.Name)?.Name, StringComparer.OrdinalIgnoreCase).ToList();
|
||||
string suite = _available.Count > 0
|
||||
? Path.GetDirectoryName(Path.GetDirectoryName(_available[0].Path)) ?? RynthUpdater.DefaultSuiteDir
|
||||
: RynthUpdater.DefaultSuiteDir;
|
||||
|
||||
AvailablePluginsHint.Text = regular.Count == 0
|
||||
? "You have every RynthSuite plugin."
|
||||
: $"RynthSuite plugins you don't have. Install downloads one into {suite} and adds it to the list above; it loads the next time AC starts.";
|
||||
foreach (RynthUpdater.AvailablePlugin a in regular)
|
||||
AvailablePluginsPanel.Children.Add(BuildAvailableCard(a));
|
||||
|
||||
AvailableServerPluginsHint.Text = forServers.Count == 0
|
||||
? "You have every server plugin."
|
||||
: $"Add the one for the server you play on. Install downloads it into {suite}; RynthCore loads it only when you connect to that server.";
|
||||
foreach (RynthUpdater.AvailablePlugin a in forServers)
|
||||
AvailableServerPluginsPanel.Children.Add(BuildAvailableCard(a));
|
||||
}
|
||||
|
||||
private Border BuildAvailableCard(RynthUpdater.AvailablePlugin a)
|
||||
|
|
@ -485,6 +518,8 @@ internal partial class MainWindow : Window
|
|||
|
||||
var stack = new StackPanel { Spacing = 4 };
|
||||
stack.Children.Add(name);
|
||||
if (PluginNames.ServerOf(a.Entry.Name) is { } server)
|
||||
stack.Children.Add(new TextBlock { Text = $"For {server.Name} ({server.Address}): {server.Note}", TextWrapping = TextWrapping.Wrap, Foreground = Brush.Parse("#9AA8B3") });
|
||||
if (a.Description.Length > 0)
|
||||
stack.Children.Add(new TextBlock { Text = a.Description, TextWrapping = TextWrapping.Wrap, Foreground = Brush.Parse("#9AA8B3") });
|
||||
stack.Children.Add(new TextBlock
|
||||
|
|
@ -579,7 +614,7 @@ internal partial class MainWindow : Window
|
|||
Dispatcher.UIThread.Post(() => AvailablePluginsBorder.BringIntoView(), DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private static Border BuildPluginCard(CheckBox checkBox, string description, Action? onRemove)
|
||||
private static Border BuildPluginCard(CheckBox checkBox, string description, string? location, Action? onRemove)
|
||||
{
|
||||
var host = new Border
|
||||
{
|
||||
|
|
@ -590,14 +625,23 @@ internal partial class MainWindow : Window
|
|||
Padding = new Thickness(12)
|
||||
};
|
||||
|
||||
var stack = new StackPanel { Spacing = 6 };
|
||||
var stack = new StackPanel { Spacing = 4 };
|
||||
stack.Children.Add(checkBox);
|
||||
stack.Children.Add(new TextBlock
|
||||
{
|
||||
Text = description,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Foreground = Brush.Parse("#9AA8B3")
|
||||
});
|
||||
if (description.Length > 0)
|
||||
stack.Children.Add(new TextBlock
|
||||
{
|
||||
Text = description,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Foreground = Brush.Parse("#9AA8B3")
|
||||
});
|
||||
if (!string.IsNullOrEmpty(location))
|
||||
stack.Children.Add(new TextBlock
|
||||
{
|
||||
Text = location,
|
||||
FontSize = 11,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
Foreground = Brush.Parse("#6F7F8A")
|
||||
});
|
||||
|
||||
if (onRemove == null)
|
||||
{
|
||||
|
|
|
|||
46
src/RynthCore.App.Avalonia/PluginNames.cs
Normal file
46
src/RynthCore.App.Avalonia/PluginNames.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using RynthCore.App;
|
||||
|
||||
namespace RynthCore.App.Avalonia;
|
||||
|
||||
/// <summary>
|
||||
/// How the launcher names a plugin, and which plugins are server plugins. The plugin list used to
|
||||
/// show each DLL's file name ("RynthCore.Plugin.RynthAi") over its full path; it shows "RynthAi", a line
|
||||
/// about what it does and its folder instead. A server plugin (one per game server, KnownServerCatalog)
|
||||
/// goes on the Server plugins tab, not among the regular plugins.
|
||||
/// </summary>
|
||||
internal static class PluginNames
|
||||
{
|
||||
private const string Prefix = "RynthCore.Plugin.";
|
||||
|
||||
/// <summary>"RynthCore.Plugin.RynthAi.dll" or "RynthCore.Plugin.RynthAi" or "RynthAi" -> "RynthAi".</summary>
|
||||
public static string Friendly(string fileOrName)
|
||||
{
|
||||
string n = Path.GetFileName(fileOrName ?? string.Empty);
|
||||
if (n.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) n = n[..^4];
|
||||
if (n.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase) && n.Length > Prefix.Length) n = n[Prefix.Length..];
|
||||
return n;
|
||||
}
|
||||
|
||||
/// <summary>Plugins for one server besides its own server plugin (catalog id of that server).</summary>
|
||||
private static readonly (string Plugin, string ServerId)[] AlsoForOneServer =
|
||||
{
|
||||
("RynthThreads", "dreamweave"), // DreamWeave's Fragment Press recorder
|
||||
};
|
||||
|
||||
/// <summary>The server a plugin belongs to, or null for a regular plugin.</summary>
|
||||
public static KnownServer? ServerOf(string fileOrName)
|
||||
{
|
||||
string n = Friendly(fileOrName);
|
||||
KnownServer? s = KnownServerCatalog.All.FirstOrDefault(k => string.Equals(k.PluginName, n, StringComparison.OrdinalIgnoreCase));
|
||||
if (s != null) return s;
|
||||
foreach (var (plugin, id) in AlsoForOneServer)
|
||||
if (string.Equals(plugin, n, StringComparison.OrdinalIgnoreCase))
|
||||
return KnownServerCatalog.All.FirstOrDefault(k => k.Id == id);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsServerPlugin(string fileOrName) => ServerOf(fileOrName) != null;
|
||||
}
|
||||
|
|
@ -65,8 +65,12 @@ internal sealed partial class RynthUpdater
|
|||
["RynthNav"] = "Walks you to coordinates and towns, with route planning and the Atlas. Downloads its map (about 540 MB).",
|
||||
["RynthVision"] = "Shows unclimbable slopes, impassable water and your radar range in the world.",
|
||||
["RynthLua"] = "Lua scripting for metas and your own scripts.",
|
||||
["RynthOracle"] = "Quests, character, titles and leaderboards.",
|
||||
["RynthOracle"] = "Quests, character and titles.",
|
||||
["RynthInventory"] = "Search every character's items.",
|
||||
["RynthSort"] = "Keeps your packs sorted: new loot goes to the pack its rule names.",
|
||||
["RynthILT"] = "Infinite Leaftide only: the ILT Hub, the Guardian, bounty tracking and progression planning.",
|
||||
["RynthThreads"] = "DreamWeave only: records Fragment Press results and works out what each component brings.",
|
||||
["RynthNet"] = "Links your characters on this PC: broadcast commands, shared vitals and the Characters panel.",
|
||||
};
|
||||
|
||||
/// <summary>The feed's description, else the launcher's own line, else "".</summary>
|
||||
|
|
@ -74,6 +78,10 @@ internal sealed partial class RynthUpdater
|
|||
e.Description.Length > 0 ? e.Description
|
||||
: BuiltInDescriptions.TryGetValue(e.Name, out string? d) ? d : "";
|
||||
|
||||
/// <summary>The launcher's own line for a RynthSuite plugin by name (no feed entry at hand), else "".</summary>
|
||||
public static string DescribeByName(string name) =>
|
||||
BuiltInDescriptions.TryGetValue(name, out string? d) ? d : "";
|
||||
|
||||
private string? _suiteDirOverride;
|
||||
/// <summary>Tests: the folder to use when no plugin in the list shows where RynthSuite lives.</summary>
|
||||
internal void SetDefaultSuiteDir(string dir) => _suiteDirOverride = dir;
|
||||
|
|
|
|||
25
src/RynthCore.Engine/Compatibility/HeadingMath.cs
Normal file
25
src/RynthCore.Engine/Compatibility/HeadingMath.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace RynthCore.Engine.Compatibility;
|
||||
|
||||
/// <summary>
|
||||
/// The engine's two heading bases. Measured on Freya 2026-10-20, standing still: the yaw
|
||||
/// quaternion said 13.9 (NNE) while GetPlayerHeading said 76.1, which is 90 - 13.9.
|
||||
/// <list type="bullet">
|
||||
/// <item>Compass: 0 = North, clockwise. Map bearings (RynthNavAtlas.Bearing, the Sense and
|
||||
/// Characters rows), TurnToHeading (SetPlayerHeadingDirect writes the quaternion this way)
|
||||
/// and every nav and combat steer, which read the quaternion.</item>
|
||||
/// <item>GetPlayerHeading (AC's get_heading, a compass value, through NormalizeDecalHeading):
|
||||
/// 0 = East, counter-clockwise. The radar and world map draw with it as that.</item>
|
||||
/// </list>
|
||||
/// Compare a bearing with <see cref="CompassFromYaw"/>, never with GetPlayerHeading.
|
||||
/// </summary>
|
||||
internal static class HeadingMath
|
||||
{
|
||||
/// <summary>The compass heading of a yaw-only quaternion (AC's physics yaw is counter-clockwise from North).</summary>
|
||||
public static float CompassFromYaw(float qw, float qz)
|
||||
{
|
||||
double yaw = 2.0 * Math.Atan2(qz, qw) * (180.0 / Math.PI);
|
||||
return (float)((-yaw % 360.0 + 720.0) % 360.0);
|
||||
}
|
||||
}
|
||||
|
|
@ -191,14 +191,25 @@ internal static class PlayerPhysicsHooks
|
|||
|
||||
/// <summary>
|
||||
/// The per-frame main-thread pose copy (cell, cell-local origin, yaw quaternion
|
||||
/// qw/qz and AC's heading, 0 = North, clockwise), read from any thread without
|
||||
/// calling into AC. headingValid is false while AC's get_heading isn't bound;
|
||||
/// derive the heading from qw/qz then. False when nothing valid is published.
|
||||
/// qw/qz and GetPlayerHeading's value, 0 = East, counter-clockwise: see HeadingMath),
|
||||
/// read from any thread without calling into AC. headingValid is false while AC's
|
||||
/// get_heading isn't bound. False when nothing valid is published. Against a map
|
||||
/// bearing use <see cref="TryGetPlayerCompassSnapshot"/>.
|
||||
/// </summary>
|
||||
public static bool TryGetPlayerPoseSnapshot(out uint objCellId, out float x, out float y, out float z,
|
||||
out float qw, out float qz, out bool headingValid, out float heading)
|
||||
=> TryReadPoseSnapshot(out objCellId, out x, out y, out z, out qw, out _, out _, out qz, out headingValid, out heading);
|
||||
|
||||
/// <summary>Your compass heading (0 = North, clockwise) from the pose snapshot's quaternion; any thread, no AC call.</summary>
|
||||
public static bool TryGetPlayerCompassSnapshot(out float heading)
|
||||
{
|
||||
heading = 0;
|
||||
if (!TryReadPoseSnapshot(out _, out _, out _, out _, out float qw, out _, out _, out float qz, out _, out _))
|
||||
return false;
|
||||
heading = HeadingMath.CompassFromYaw(qw, qz);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryGetPlayerPose(
|
||||
out uint objCellId,
|
||||
out float x,
|
||||
|
|
@ -623,9 +634,10 @@ internal static class PlayerPhysicsHooks
|
|||
return BitConverter.Int32BitsToSingle(bits);
|
||||
}
|
||||
|
||||
// CPhysicsObj heading is rotated 90 degrees from the Decal/VTank basis
|
||||
// used by old RynthAi Actions.Heading. Normalize here so plugins can stay
|
||||
// on the original T1 heading math.
|
||||
// AC's get_heading is already a compass value (0 = North, clockwise); 90 - it is
|
||||
// 0 = East, counter-clockwise, which GetPlayerHeading has always returned and the
|
||||
// radar and world map draw with. Kept as it is for them; a bearing wants
|
||||
// HeadingMath.CompassFromYaw (measured 2026-10-20, see HeadingMath).
|
||||
private static float NormalizeDecalHeading(float physicsHeading)
|
||||
{
|
||||
return NormalizeDegrees(90f - physicsHeading);
|
||||
|
|
|
|||
|
|
@ -350,6 +350,15 @@ internal static class RynthCoreChatCommands
|
|||
return true;
|
||||
}
|
||||
|
||||
// /rc dashboard [classic|modern|tab <name>] : the RynthAi dashboard's look (the title bar buttons and
|
||||
// Settings > Display), and the Classic look's tab (main, monsters, gear, buffs, route, loot, meta,
|
||||
// tuning); either opens the dashboard. No argument: says which look is on.
|
||||
if (IsVerb(sub, "dashboard", out string dashArgs))
|
||||
{
|
||||
DashboardCommand(dashArgs.Trim());
|
||||
return true;
|
||||
}
|
||||
|
||||
// /rc miniremote [show|hide|toggle|tab <tab>|section <id>] : the ImGui Mini Remote panel, like
|
||||
// its bar button (RynthAi's dashboard and "/ra hub" use show / hide). "tab" opens it on one of
|
||||
// its tabs (RynthAi's pets, crafting; RynthILT's gear, games; none = the remote). Quests are
|
||||
|
|
@ -1027,6 +1036,32 @@ internal static class RynthCoreChatCommands
|
|||
UI.PanelRouter.Toggle(title);
|
||||
}
|
||||
|
||||
private static readonly string[] ClassicTabNames = { "main", "monsters", "gear", "buffs", "route", "loot", "meta", "tuning" };
|
||||
|
||||
/// <summary>"/rc dashboard [classic|modern|tab <name>]": the RynthAi dashboard's look and the Classic look's tab.</summary>
|
||||
private static void DashboardCommand(string args)
|
||||
{
|
||||
string title = ImGuiBackend.Panels.RynthAiFace.Title;
|
||||
string usage = "Usage: /rc dashboard classic|modern|tab <" + string.Join("|", ClassicTabNames) + ">";
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Reply("The RynthAi dashboard's look is " + (UI.RynthAiDashboardState.Classic ? "Classic" : "Modern") + ". " + usage);
|
||||
return;
|
||||
}
|
||||
if (IsVerb(args, "tab", out string tab))
|
||||
{
|
||||
int i = Array.FindIndex(ClassicTabNames, n => n.Equals(tab.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||
if (i < 0) { Reply(usage); return; }
|
||||
UI.RynthAiDashboardState.SetClassicTab(i);
|
||||
ImGuiBackend.Panels.RynthAiFace.SwitchLook(classic: true);
|
||||
}
|
||||
else if (args.Equals("classic", StringComparison.OrdinalIgnoreCase)) ImGuiBackend.Panels.RynthAiFace.SwitchLook(classic: true);
|
||||
else if (args.Equals("modern", StringComparison.OrdinalIgnoreCase)) ImGuiBackend.Panels.RynthAiFace.SwitchLook(classic: false);
|
||||
else { Reply(usage); return; }
|
||||
if (ImGuiBackend.ImGuiPanelHost.HasFace(title) && !ImGuiBackend.ImGuiPanelHost.IsOpen(title))
|
||||
ImGuiBackend.ImGuiPanelHost.Open(title);
|
||||
}
|
||||
|
||||
/// <summary>"/rc bounties|guardian [show|hide|toggle]": one of the ILT section's panels.</summary>
|
||||
private static void IltPanel(string title, string label, string plugin, string args)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -499,6 +499,9 @@ internal static class HotkeyService
|
|||
{
|
||||
_capturing = false;
|
||||
_captured = null;
|
||||
Tracker.Reset();
|
||||
// Not Tracker.Reset(): the tracker is AC's main thread only, and shutdown runs on the loader's
|
||||
// reload thread while the window procedure can still be in it. The tracker belongs to this
|
||||
// engine generation and goes with it; the next one starts with its own. (A reload died here,
|
||||
// a write through a bad pointer on the ReloadWatcher thread, 2026-10-20.)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,15 +324,11 @@ internal sealed class CharactersFace : IImGuiPanel
|
|||
private static Vector2 Rot(Vector2 c, float x, float y, float s, float co) =>
|
||||
new(c.X + x * co - y * s, c.Y + x * s + y * co);
|
||||
|
||||
/// <summary>Your heading this frame (compass degrees) from the pose snapshot; no AC call (SenseFace's way).</summary>
|
||||
/// <summary>Your compass heading this frame from the pose snapshot's quaternion; no AC call (SenseFace's way).</summary>
|
||||
private static float PlayerHeading(out bool ok)
|
||||
{
|
||||
ok = PlayerPhysicsHooks.TryGetPlayerPoseSnapshot(out _, out _, out _, out _, out float qw, out float qz,
|
||||
out bool headingValid, out float heading);
|
||||
if (!ok) return 0;
|
||||
if (headingValid) return heading;
|
||||
double yaw = 2.0 * Math.Atan2(qz, qw) * (180.0 / Math.PI);
|
||||
return (float)((-yaw % 360.0 + 720.0) % 360.0);
|
||||
ok = PlayerPhysicsHooks.TryGetPlayerCompassSnapshot(out float heading);
|
||||
return heading;
|
||||
}
|
||||
|
||||
// ── Right-click menu ────────────────────────────────────────────────
|
||||
|
|
|
|||
|
|
@ -51,8 +51,9 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
{
|
||||
public const string Title = "Chat";
|
||||
|
||||
// The channel tabs live in a drawer on the window's left edge (Tom 2026-10-09: the
|
||||
// wrapped tab rows took too much room), the way the dashboard's ranges do.
|
||||
// The channel tabs live in a drawer on the window's left edge (2026-10-09: the wrapped
|
||||
// tab rows took too much room), the way the dashboard's ranges do; "Tabs across the
|
||||
// top" (ChatModel.TabsAcross, 2026-10-20) puts the row back for those who want it.
|
||||
private readonly ChannelsDrawer _channels;
|
||||
private readonly DashboardDrawers _drawers;
|
||||
private bool _openTabsPopup;
|
||||
|
|
@ -176,7 +177,15 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
string tab = ChatModel.CurrentTab();
|
||||
UpdateUnread(lines, snap?.Version ?? -1, tab);
|
||||
|
||||
float y = DrawHeader(new Vector2(x0, origin.Y + 4), w);
|
||||
bool across = ChatModel.TabsAcross;
|
||||
float y;
|
||||
if (across)
|
||||
{
|
||||
y = DrawTabStrip(new Vector2(x0, origin.Y + 4), w);
|
||||
DrawSearch(new Vector2(x0, y), w);
|
||||
y += 26;
|
||||
}
|
||||
else y = DrawHeader(new Vector2(x0, origin.Y + 4), w);
|
||||
|
||||
SyncLines(snap, lines, tab);
|
||||
|
||||
|
|
@ -194,7 +203,7 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.PopStyleVar();
|
||||
DrawPopups();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
_drawers.Draw(); // last: its own window, placed against this one
|
||||
if (!across) _drawers.Draw(); // last: its own window, placed against this one
|
||||
}
|
||||
|
||||
// ── Tabs ─────────────────────────────────────────────────────────────
|
||||
|
|
@ -260,6 +269,58 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
return start.Y + h + 4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "Tabs across the top" (ChatModel.TabsAcross): every tab in a row that wraps left of
|
||||
/// Filters and the gear, as before the drawer; right-click a tab to rename or delete it,
|
||||
/// + adds one. Returns the y below the strip.
|
||||
/// </summary>
|
||||
private float DrawTabStrip(Vector2 start, float w)
|
||||
{
|
||||
const float h = 20;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float gearW = 22, filtW = 22, right = start.X + w;
|
||||
if (IconButton("##chat_gear", PhosphorIcons.Gear, new Vector2(right - gearW, start.Y), new Vector2(gearW, h), Text, BtnFill))
|
||||
_openSettings = true;
|
||||
ImGuiNET.ImGui.SetItemTooltip("Chat settings");
|
||||
if (IconButton("##chat_filters", PhosphorIcons.Funnel, new Vector2(right - gearW - 3 - filtW, start.Y), new Vector2(filtW, h), Text, BtnFill))
|
||||
PanelRouter.Toggle("ChatFilters");
|
||||
ImGuiNET.ImGui.SetItemTooltip("Filters: move, copy or hide lines by regex, and colour them");
|
||||
|
||||
float stripRight = right - gearW - filtW - 8;
|
||||
float x = start.X, y = start.Y;
|
||||
string current = ChatModel.CurrentTab();
|
||||
foreach (string tab in ChatModel.AllTabs())
|
||||
{
|
||||
bool active = string.Equals(tab, current, StringComparison.OrdinalIgnoreCase);
|
||||
_unread.TryGetValue(tab, out var unread);
|
||||
string? badge = !active && unread.Count > 0 ? (unread.Count > 99 ? "99+" : unread.Count.ToString()) : null;
|
||||
float badgeW = badge != null ? BadgeWidth(badge) : 0;
|
||||
float textW = ImGuiNET.ImGui.CalcTextSize(tab).X;
|
||||
float bw = textW + 12 + (badge != null ? badgeW + 3 : 0);
|
||||
if (x > start.X && x + bw > stripRight) { x = start.X; y += h + 2; }
|
||||
ImGuiNET.ImGui.PushID(tab);
|
||||
var p = new Vector2(x, y);
|
||||
if (Button("##tab", "", p, new Vector2(bw, h), Text, active ? TabActive : BtnFill))
|
||||
ChatModel.SelectTab(tab);
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right)) { _ctxTab = tab; _openTabMenu = true; }
|
||||
if (unread.Mention && !active) ImGuiNET.ImGui.SetItemTooltip("Someone mentioned you here");
|
||||
else if (!ChatModel.IsBaseTab(tab)) ImGuiNET.ImGui.SetItemTooltip("Right-click to rename or delete this tab");
|
||||
dl.AddText(new Vector2(x + 6, y + (h - ImGuiNET.ImGui.GetFontSize()) * 0.5f), Text, tab);
|
||||
if (badge != null) DrawBadge(dl, new Vector2(x + 6 + textW + 3, y + 4), badgeW, h - 8, badge, unread.Mention);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
x += bw + 2;
|
||||
}
|
||||
if (x > start.X && x + 18 > stripRight) { x = start.X; y += h + 2; }
|
||||
if (IconButton("##chat_addtab", PhosphorIcons.Plus, new Vector2(x, y), new Vector2(18, h), TabAdd, BtnFill, font: UiFont.Ui11))
|
||||
{
|
||||
_pendingRule = null;
|
||||
WriteUtf8(_newTab, "");
|
||||
_openNewTab = _focusNewTab = true;
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("New tab (fill it with a rule: right-click a line, or Filters)");
|
||||
return y + h + 4;
|
||||
}
|
||||
|
||||
private static float BadgeWidth(string badge)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui9));
|
||||
|
|
@ -1102,6 +1163,15 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
"About 2 MB of memory per 1000 lines. Lowering it drops the oldest lines.");
|
||||
ImGuiNET.ImGui.PopItemWidth();
|
||||
|
||||
bool across = ChatModel.TabsAcross;
|
||||
if (ImGuiNET.ImGui.Checkbox("Tabs across the top", ref across))
|
||||
{
|
||||
ChatModel.TabsAcross = across;
|
||||
if (across) _drawers.Close(_channels);
|
||||
ChatModel.SaveSettings();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("On: every tab in a row across the top, with search under it.\n" +
|
||||
"Off: one channel button that opens the tabs in a drawer beside the chat.");
|
||||
bool ts = ChatModel.ShowTimestamps;
|
||||
if (ImGuiNET.ImGui.Checkbox("Timestamps", ref ts))
|
||||
{
|
||||
|
|
|
|||
205
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicBuffsTab.cs
Normal file
205
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicBuffsTab.cs
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicBuffsTab.cs
|
||||
// The Classic look's Buffs tab: the buff profile (the dashboard's Buffs
|
||||
// picker and RynthAi's Spells window), buffing on/off, Rebuff all / Cancel,
|
||||
// and every spell on you now with its icon and time left, soonest first,
|
||||
// harmful ones on top in red. The list is the engine's player enchantment
|
||||
// snapshot (EnchantmentHooks.CopyPlayerStatMods: refreshed by the main thread
|
||||
// every 250 ms, read here four times a second); names and icons come from the
|
||||
// client's spell table (PortalSpellTable), the icons drawn by RetailSprites.
|
||||
// What a buff profile holds is RynthAi's (its Spells window), not shown here.
|
||||
// AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.ImGuiBackend.Hud;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicBuffsTab : IClassicTab
|
||||
{
|
||||
public string Name => "Buffs";
|
||||
|
||||
private const int MaxEnch = 256, VisibleRows = 16;
|
||||
private const double NoEnd = 1e12;
|
||||
|
||||
private sealed class Line
|
||||
{
|
||||
public uint SpellId;
|
||||
public string Name = "";
|
||||
public double Expiry;
|
||||
public bool Harmful;
|
||||
public string Left = "";
|
||||
public uint LeftColor;
|
||||
}
|
||||
|
||||
private readonly uint[] _ids = new uint[MaxEnch], _types = new uint[MaxEnch], _keys = new uint[MaxEnch], _cats = new uint[MaxEnch];
|
||||
private readonly double[] _exp = new double[MaxEnch];
|
||||
private readonly float[] _vals = new float[MaxEnch];
|
||||
private readonly List<Line> _lines = new();
|
||||
private readonly Dictionary<uint, Line> _byId = new();
|
||||
private long _nextRead, _nextText;
|
||||
private bool _valid;
|
||||
private int _first, _soon;
|
||||
private float _grab;
|
||||
private string _soonest = "";
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
PortalSpellTable.EnsureLoadQueued();
|
||||
_nextRead = _nextText = 0;
|
||||
}
|
||||
|
||||
public void Hidden() { }
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
Refresh();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
RynthAiSnapshot raw = ctx.Raw;
|
||||
float y = o.Y;
|
||||
|
||||
// ── Profile ──
|
||||
Header(dl, new Vector2(o.X, y), w, "Buff profile", _soonest.Length > 0 ? "first to end: " + _soonest : null);
|
||||
y += Px(23);
|
||||
{
|
||||
float rowH = Px(22), labelW = Px(52);
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Profile", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(6), y + (rowH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(6) - Px(52);
|
||||
string[] profiles = raw.BuffProfiles;
|
||||
if (Dropdown("##cb_profile", ctx.View?.BuffText ?? "Built-in", ddPos, ddW, ctx.Popup.IsOpen) && profiles.Length > 0)
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, profiles, raw.SelectedBuffIdx, i => RynthAiCommands.SelectProfile(4, i));
|
||||
SafeImGui.SetItemTooltip(profiles.Length > 0 ? "The buff profile buffing uses" : "Buff profiles need RynthAi 0.5.31 or newer");
|
||||
if (Plate("##cb_spells", "Spells", new Vector2(o.X + w - Px(46), y + (rowH - Px(17)) * 0.5f)))
|
||||
RynthAiCommands.ApplyRemoteCommand("spells", "toggle");
|
||||
SafeImGui.SetItemTooltip("RynthAi Spells: browse the spell list and build buff profiles.");
|
||||
y += rowH;
|
||||
}
|
||||
{
|
||||
bool on = raw.BuffingEnabled;
|
||||
if (Gem("##cb_on", "Buffing", new Vector2(o.X, y), w / 2, on))
|
||||
RynthAiCommands.SetSubsystemEnabled(1, !on);
|
||||
SafeImGui.SetItemTooltip(on ? "Buffing on. Click to turn it off." : "Buffing off. Click to turn it on.");
|
||||
y += Px(20);
|
||||
}
|
||||
|
||||
// ── Active ──
|
||||
y += Px(6);
|
||||
int harmful = 0;
|
||||
foreach (Line l in _lines) if (l.Harmful) harmful++;
|
||||
string right = !_valid ? "not in game" : _lines.Count == 0 ? "none"
|
||||
: $"{_lines.Count - harmful} buffs" + (harmful > 0 ? $" · {harmful} harmful" : "") + (_soon > 0 ? $" · {_soon} ending soon" : "");
|
||||
Header(dl, new Vector2(o.X, y), w, "On you now", right);
|
||||
y += Px(23);
|
||||
float rowH2 = Px(18), listW = w - Px(16), listH = rowH2 * VisibleRows;
|
||||
var listMin = new Vector2(o.X, y);
|
||||
dl.AddRectFilled(listMin, listMin + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
_first = Wheel(listMin, listMin + new Vector2(w, listH), _first, _lines.Count, VisibleRows);
|
||||
for (int r = 0; r < VisibleRows && _first + r < _lines.Count; r++)
|
||||
{
|
||||
Line l = _lines[_first + r];
|
||||
var p = new Vector2(o.X, y + r * rowH2);
|
||||
if (((_first + r) & 1) == 1) dl.AddRectFilled(p, p + new Vector2(listW, rowH2), AltRow);
|
||||
float icon = Px(16);
|
||||
var ip = new Vector2(p.X + Px(3), p.Y + (rowH2 - icon) * 0.5f);
|
||||
if (PortalSpellTable.TryGetIcon(l.SpellId, out uint iconId) && RetailSprites.TryGet(iconId, out IntPtr tex))
|
||||
dl.AddImage(tex, ip, ip + new Vector2(icon, icon));
|
||||
else
|
||||
dl.AddRect(ip, ip + new Vector2(icon, icon), l.Harmful ? Down : GoldDim);
|
||||
float tw = Px(60);
|
||||
TextClip(dl, p.X + Px(24), p.Y, rowH2, p.X + listW - tw, l.Name, l.Harmful ? Down : White, 10);
|
||||
TextRight(dl, p.X + listW - Px(4), p.Y, rowH2, l.Left, l.LeftColor, 10);
|
||||
}
|
||||
if (_lines.Count == 0)
|
||||
TextMid(dl, o.X + Px(6), y, rowH2, _valid ? "No spells on you." : "Log in to see your buffs.", Dim, 10);
|
||||
_first = Scrollbar("##cb_sb", new Vector2(o.X + listW, y), listH, _lines.Count, VisibleRows, _first, ref _grab);
|
||||
y += listH + Px(6);
|
||||
|
||||
// ── Rebuff ──
|
||||
{
|
||||
float bw = Px(118);
|
||||
if (Button("##cb_rebuff", "Rebuff all", new Vector2(o.X, y), bw, ButtonColor.Blue))
|
||||
RynthAiCommands.ForceRebuff();
|
||||
SafeImGui.SetItemTooltip("Force rebuff: recast every buff in the profile now.");
|
||||
if (Button("##cb_cancel", "Cancel", new Vector2(o.X + bw + Px(6), y), Px(96), ButtonColor.Red))
|
||||
RynthAiCommands.CancelForceRebuff();
|
||||
SafeImGui.SetItemTooltip("Cancel a force rebuff");
|
||||
y += Px(32);
|
||||
}
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
// ── Data ────────────────────────────────────────────────────────────
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
if (now >= _nextRead)
|
||||
{
|
||||
_nextRead = now + 250;
|
||||
int n = EnchantmentHooks.CopyPlayerStatMods(_ids, _exp, _types, _keys, _vals, _cats);
|
||||
_valid = n >= 0;
|
||||
Rebuild(Math.Max(0, n));
|
||||
_nextText = 0;
|
||||
}
|
||||
if (now >= _nextText)
|
||||
{
|
||||
_nextText = now + 1000;
|
||||
Texts();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The lines for this read: one per spell (the strongest copy's expiry), cooldowns and unnamed left out.</summary>
|
||||
private void Rebuild(int n)
|
||||
{
|
||||
_byId.Clear();
|
||||
_lines.Clear();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
uint id = _ids[i];
|
||||
if (id == 0 || id >= 0x8000) continue; // 0x8000+: cooldowns, not spells
|
||||
if (!PortalSpellTable.TryGetName(id, out string name) || name.Length == 0) continue;
|
||||
if (_byId.TryGetValue(id, out Line? have))
|
||||
{
|
||||
if (_exp[i] > have.Expiry) have.Expiry = _exp[i];
|
||||
continue;
|
||||
}
|
||||
var line = new Line { SpellId = id, Name = name, Expiry = _exp[i], Harmful = PortalSpellTable.TryGetById(id, out _) };
|
||||
_byId[id] = line;
|
||||
_lines.Add(line);
|
||||
}
|
||||
// Harmful first, then the soonest to end; spells with no end last.
|
||||
_lines.Sort((a, b) =>
|
||||
{
|
||||
if (a.Harmful != b.Harmful) return a.Harmful ? -1 : 1;
|
||||
int c = a.Expiry.CompareTo(b.Expiry);
|
||||
return c != 0 ? c : string.CompareOrdinal(a.Name, b.Name);
|
||||
});
|
||||
}
|
||||
|
||||
private void Texts()
|
||||
{
|
||||
double serverNow = TimeSyncHooks.GetCurrentServerTime();
|
||||
_soon = 0;
|
||||
_soonest = "";
|
||||
foreach (Line l in _lines)
|
||||
{
|
||||
if (l.Expiry >= NoEnd) { l.Left = "no end"; l.LeftColor = Faint; continue; }
|
||||
if (serverNow <= 0) { l.Left = ""; l.LeftColor = Faint; continue; }
|
||||
double left = l.Expiry - serverNow;
|
||||
long s = (long)Math.Max(0, left);
|
||||
l.Left = left <= 0 ? "ending" : s >= 3600 ? $"{s / 3600}h {s % 3600 / 60:00}m" : s >= 60 ? $"{s / 60}m {s % 60:00}s" : $"{s}s";
|
||||
l.LeftColor = l.Harmful ? Down : left < 60 ? Down : left < 600 ? Amber : Green;
|
||||
if (!l.Harmful && left < 600) _soon++;
|
||||
if (!l.Harmful && _soonest.Length == 0) _soonest = l.Name + " in " + l.Left;
|
||||
}
|
||||
}
|
||||
}
|
||||
310
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicDashboard.cs
Normal file
310
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicDashboard.cs
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicDashboard.cs
|
||||
// The RynthAi dashboard's Classic look (Tom 2026-10-19: "implement the AC
|
||||
// style as an option"): one retail-style window, drawn with the client's own
|
||||
// UI pictures (ClassicKit), with eight tabs: Main (every VTank-options-page
|
||||
// setting, the macro, live systems, recharge meters), Monsters, Gear, Buffs,
|
||||
// Route, Loot, Meta and Tuning. The design is the RynthAi Classic canvas
|
||||
// (claude.ai artifact 2VCb8Lk7vGjBfoX73PJKVL, "Classic" page); our own layout
|
||||
// and wording, the retail art read from the player's install.
|
||||
//
|
||||
// RynthAiFace draws this instead of the dashboard while
|
||||
// RynthAiDashboardState.Classic is on; the title bar's Modern button and
|
||||
// Settings > Display switch back. Minimized (the dashboard's shared flag)
|
||||
// shows the title bar over a compact strip: the systems, Stop/Start and the
|
||||
// three vitals meters.
|
||||
//
|
||||
// Layout, in retail px times ClassicKit.S (the UI scale x the dashboard's
|
||||
// size): a 5 px gold frame; the 25 px title bar and its close button; the
|
||||
// 25 px tab row; the body (8 px in from the frame). The window is 400 retail
|
||||
// px wide and as tall as the open tab's content (measured each frame, fitted
|
||||
// when it changes, like the dashboard's MeasureAndFit).
|
||||
//
|
||||
// AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
/// <summary>One tab of the Classic window.</summary>
|
||||
internal interface IClassicTab
|
||||
{
|
||||
string Name { get; }
|
||||
/// <summary>The tab became the open one (subscribe to what it reads).</summary>
|
||||
void Shown();
|
||||
/// <summary>The tab stopped showing (unsubscribe).</summary>
|
||||
void Hidden();
|
||||
/// <summary>Draws the tab's body at <paramref name="o"/>, <paramref name="w"/> wide; returns the height it used.</summary>
|
||||
float Draw(ClassicContext ctx, Vector2 o, float w);
|
||||
}
|
||||
|
||||
/// <summary>What every tab gets each frame.</summary>
|
||||
internal sealed class ClassicContext
|
||||
{
|
||||
public RynthAiView? View;
|
||||
public RynthAiSnapshot Raw = new();
|
||||
public readonly Popup Popup = new("##classic_popup");
|
||||
/// <summary>Opens another tab (the Main tab's "More" goes to Tuning).</summary>
|
||||
public Action<int> OpenTab = _ => { };
|
||||
}
|
||||
|
||||
internal sealed class ClassicDashboard
|
||||
{
|
||||
public const float RetailW = 400, FrameW = 5, TitleH = 25, TabH = 25, BodyPad = 8, BottomPad = 10;
|
||||
private const string SizePopupId = "##classic_size";
|
||||
|
||||
private readonly IClassicTab[] _tabs;
|
||||
private readonly ClassicContext _ctx = new();
|
||||
private int _shownTab = -1;
|
||||
private float _contentH; // the open tab's body height last frame (screen px)
|
||||
private float _fittedH = -1, _fittedW = -1;
|
||||
|
||||
public ClassicDashboard()
|
||||
{
|
||||
_tabs = new IClassicTab[]
|
||||
{
|
||||
new ClassicMainTab(), new ClassicMonstersTab(), new ClassicGearTab(), new ClassicBuffsTab(),
|
||||
new ClassicRouteTab(), new ClassicLootTab(), new ClassicMetaTab(), new ClassicTuningTab(),
|
||||
};
|
||||
_ctx.OpenTab = i => RynthAiDashboardState.SetClassicTab(Math.Clamp(i, 0, _tabs.Length - 1));
|
||||
}
|
||||
|
||||
/// <summary>The window's minimum (logical px): the retail width and the content's height.</summary>
|
||||
public Vector2 MinSize(float k)
|
||||
{
|
||||
float s = Scale(k);
|
||||
float h = _fittedH > 0 ? _fittedH : 200 * s;
|
||||
return new Vector2(RetailW * s / Placement(), h);
|
||||
}
|
||||
|
||||
public void OnShown() { _shownTab = -1; _fittedH = -1; _fittedW = -1; }
|
||||
|
||||
public void OnHidden()
|
||||
{
|
||||
if (_shownTab >= 0) _tabs[_shownTab].Hidden();
|
||||
_shownTab = -1;
|
||||
}
|
||||
|
||||
private static float Placement() => Math.Max(0.01f, ImGuiPanelHost.PlacementScale());
|
||||
|
||||
private static float Scale(float k)
|
||||
{
|
||||
float ui = EngineFrameController.FontScale;
|
||||
if (!(ui > 0f) || !float.IsFinite(ui)) ui = 1f;
|
||||
return Math.Max(0.5f, ui * k);
|
||||
}
|
||||
|
||||
public void Draw(RynthAiView? view, RynthAiSnapshot raw, float k)
|
||||
{
|
||||
S = Scale(k);
|
||||
_ctx.View = view;
|
||||
_ctx.Raw = raw;
|
||||
bool minimized = RynthAiDashboardState.Minimized;
|
||||
int tab = Math.Clamp(RynthAiDashboardState.ClassicTab, 0, _tabs.Length - 1);
|
||||
if (minimized) tab = -1;
|
||||
if (tab != _shownTab)
|
||||
{
|
||||
if (_shownTab >= 0) _tabs[_shownTab].Hidden();
|
||||
if (tab >= 0) _tabs[tab].Shown();
|
||||
_shownTab = tab;
|
||||
}
|
||||
|
||||
Vector2 wp = ImGuiNET.ImGui.GetWindowPos(), ws = ImGuiNET.ImGui.GetWindowSize();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
dl.PushClipRect(wp, wp + ws, false);
|
||||
try
|
||||
{
|
||||
float w = ws.X;
|
||||
float frame = Px(FrameW);
|
||||
var inner0 = wp + new Vector2(frame, frame);
|
||||
float innerW = w - 2 * frame;
|
||||
byte alpha = view?.PanelAlpha ?? 242;
|
||||
|
||||
// Body backdrop first (the title and tabs draw over its top).
|
||||
Backdrop(dl, new Vector2(inner0.X, inner0.Y + Px(TitleH)), new Vector2(inner0.X + innerW, wp.Y + ws.Y - frame), alpha);
|
||||
|
||||
TitleRow(dl, inner0, innerW, raw, minimized);
|
||||
float y = inner0.Y + Px(TitleH);
|
||||
float used;
|
||||
if (minimized)
|
||||
{
|
||||
used = CompactStrip(dl, new Vector2(inner0.X + Px(BodyPad), y + Px(6)), innerW - 2 * Px(BodyPad), view, raw) + Px(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
TabRow(dl, new Vector2(inner0.X, y), innerW, tab);
|
||||
y += Px(TabH);
|
||||
float body = _tabs[tab].Draw(_ctx, new Vector2(inner0.X + Px(BodyPad), y + Px(BodyPad)), innerW - 2 * Px(BodyPad));
|
||||
used = Px(TabH) + Px(BodyPad) + body + Px(BottomPad);
|
||||
}
|
||||
Frame(dl, wp, wp + ws);
|
||||
|
||||
_contentH = Px(TitleH) + used + 2 * frame;
|
||||
Fit(w);
|
||||
}
|
||||
finally
|
||||
{
|
||||
dl.PopClipRect();
|
||||
}
|
||||
_ctx.Popup.Draw();
|
||||
SizePopup();
|
||||
}
|
||||
|
||||
/// <summary>Fits the window to the retail width and the content's height when either changed.</summary>
|
||||
private void Fit(float w)
|
||||
{
|
||||
if (ImGuiPopOuts.InPopOutFrame) return;
|
||||
float place = Placement();
|
||||
float wantW = RetailW * S, wantH = MathF.Ceiling(_contentH);
|
||||
if (Math.Abs(wantH - _fittedH) < 1 && Math.Abs(wantW - _fittedW) < 1) return;
|
||||
_fittedH = wantH;
|
||||
_fittedW = wantW;
|
||||
ImGuiPanelHost.RequestSize(RynthAiFace.Title, new Vector2(wantW / place, wantH / place));
|
||||
// Applied after the size, clamped to the screen at it (the dashboard's MeasureAndFit does the same):
|
||||
// a taller tab near the bottom of the screen moves the window up instead of running off it.
|
||||
ImGuiPanelHost.RequestPos(RynthAiFace.Title, ImGuiNET.ImGui.GetWindowPos() / place);
|
||||
}
|
||||
|
||||
// ── Title bar ───────────────────────────────────────────────────────
|
||||
|
||||
private void TitleRow(ImDrawListPtr dl, Vector2 o, float w, RynthAiSnapshot raw, bool minimized)
|
||||
{
|
||||
float h = Px(TitleH), closeW = Px(24);
|
||||
float barW = w - closeW;
|
||||
if (!HSlice(dl, Art.TitleBar, o, o + new Vector2(barW, h), 276, 14, 20))
|
||||
{
|
||||
dl.AddRectFilled(o, o + new Vector2(barW, h - 1), Black);
|
||||
dl.AddRect(o, o + new Vector2(barW, h - 1), Gold);
|
||||
}
|
||||
|
||||
// Buttons at the bar's right end: Modern look, minimize / expand.
|
||||
float btn = Px(17), by = o.Y + (h - btn) * 0.5f;
|
||||
float bx = o.X + barW - Px(20) - btn;
|
||||
if (TitleIcon("##cl_min", minimized ? PhosphorIcons.ArrowsOutLineVertical : PhosphorIcons.ArrowsInLineVertical, new Vector2(bx, by), btn))
|
||||
RynthAiDashboardState.SetMinimized(!minimized);
|
||||
SafeImGui.SetItemTooltip(minimized ? "Expand" : "Minimize");
|
||||
bx -= btn + Px(3);
|
||||
if (TitleIcon("##cl_modern", PhosphorIcons.SquaresFour, new Vector2(bx, by), btn))
|
||||
RynthAiFace.SwitchLook(classic: false);
|
||||
SafeImGui.SetItemTooltip("Modern look (the compact dashboard)");
|
||||
float buttonsLeft = bx - Px(4);
|
||||
|
||||
// Drag surface: the bar left of the buttons. Right-click: the window's size.
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(o);
|
||||
ImGuiNET.ImGui.InvisibleButton("##cl_drag", new Vector2(Math.Max(1, buttonsLeft - o.X), h));
|
||||
ImGuiPanelHost.DragWindowWithLastItem();
|
||||
SafeImGui.SetItemTooltip("Drag to move. Right-click: size. Ctrl+wheel: bigger or smaller.");
|
||||
if (ImGuiNET.ImGui.IsItemClicked(ImGuiMouseButton.Right)) ImGuiNET.ImGui.OpenPopup(SizePopupId);
|
||||
if (ImGuiNET.ImGui.IsItemHovered())
|
||||
{
|
||||
ImGuiIOPtr io = ImGuiNET.ImGui.GetIO();
|
||||
if (io.KeyCtrl && io.MouseWheel != 0f)
|
||||
PanelTextScale.SetForWindow(RynthAiFace.Title, PanelTextScale.Get(RynthAiFace.Title) + (io.MouseWheel > 0f ? 1 : -1));
|
||||
}
|
||||
|
||||
// "RynthAi" in gold, then the profile and what the bot is doing.
|
||||
float tx = o.X + Px(10);
|
||||
TextMid(dl, tx, o.Y, h, "RynthAi", Gold, 12, bold: true);
|
||||
tx += Measure("RynthAi", 12, true).X + Px(8);
|
||||
string sub = (raw.MacroRunning ? "running" : "stopped") + " · " + (_ctx.View?.ProfileText ?? "Default");
|
||||
TextClip(dl, tx, o.Y, h, buttonsLeft, sub, raw.MacroRunning ? Green : Dim, 10);
|
||||
|
||||
// The retail close button.
|
||||
if (CloseButton("##cl_close", new Vector2(o.X + barW, o.Y)))
|
||||
ImGuiPanelHost.Close(RynthAiFace.Title);
|
||||
SafeImGui.SetItemTooltip("Close");
|
||||
}
|
||||
|
||||
private static bool TitleIcon(string id, string glyph, Vector2 pos, float size)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(size, size));
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
if (hot) dl.AddRect(pos, pos + new Vector2(size, size), FaceKit.Faded(Gold), Px(2));
|
||||
PhosphorIcons.DrawCentered(dl, ImGuiFonts.Get(UiFont.Ui11), glyph, pos, new Vector2(size, size), hot ? Gold : GoldDim);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
private void SizePopup()
|
||||
{
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, RynthTheme.Background);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Gold);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(8, 8));
|
||||
bool open = ImGuiNET.ImGui.BeginPopup(SizePopupId);
|
||||
ImGuiNET.ImGui.PopStyleVar();
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!open) return;
|
||||
try { ImGuiPanelHost.TextSizeRows(RynthAiFace.Title, S, "Window size"); }
|
||||
finally { ImGuiNET.ImGui.EndPopup(); }
|
||||
}
|
||||
|
||||
// ── Tabs ────────────────────────────────────────────────────────────
|
||||
|
||||
private void TabRow(ImDrawListPtr dl, Vector2 o, float w, int open)
|
||||
{
|
||||
dl.AddRectFilled(o, o + new Vector2(w, Px(TabH)), Black);
|
||||
float x = o.X;
|
||||
for (int i = 0; i < _tabs.Length; i++)
|
||||
{
|
||||
// Even widths that add up to the row exactly.
|
||||
float next = o.X + w * (i + 1) / _tabs.Length;
|
||||
float tw = MathF.Round(next) - MathF.Round(x);
|
||||
if (Tab("##cl_tab" + i, _tabs[i].Name, new Vector2(MathF.Round(x), o.Y), tw, i == open))
|
||||
RynthAiDashboardState.SetClassicTab(i);
|
||||
x = next;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Minimized: systems, Stop/Start, vitals ──────────────────────────
|
||||
|
||||
private static readonly string[] ShortNames = { "Combat", "Buff", "Nav", "Loot", "Meta" };
|
||||
|
||||
private static float CompactStrip(ImDrawListPtr dl, Vector2 o, float w, RynthAiView? view, RynthAiSnapshot raw)
|
||||
{
|
||||
float y = o.Y;
|
||||
// Five gems (subsystem toggles), then Stop / Start on a gold plate.
|
||||
float plateW = Px(46);
|
||||
float gemW = (w - plateW - Px(6)) / 5;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bool on = SubsystemOn(raw, i);
|
||||
if (Gem("##cl_cs" + i, ShortNames[i], new Vector2(o.X + i * gemW, y), gemW, on, 20))
|
||||
RynthAiCommands.SetSubsystemEnabled(i, !on);
|
||||
SafeImGui.SetItemTooltip(SubsystemNames[i] + (on ? " on. Click to turn it off." : " off. Click to turn it on."));
|
||||
}
|
||||
if (Plate("##cl_cs_run", raw.MacroRunning ? "Stop" : "Start", new Vector2(o.X + w - plateW, y + Px(1.5f))))
|
||||
RynthAiCommands.ToggleMacro();
|
||||
SafeImGui.SetItemTooltip(raw.MacroRunning ? "Macro running. Click to stop it." : "Macro stopped. Click to start it.");
|
||||
y += Px(24);
|
||||
|
||||
VitalView hp = view?.Health ?? default, st = view?.Stamina ?? default, mn = view?.Mana ?? default;
|
||||
y = CompactVital(dl, o.X, y, w, Vital.Health, hp);
|
||||
y = CompactVital(dl, o.X, y, w, Vital.Stamina, st);
|
||||
y = CompactVital(dl, o.X, y, w, Vital.Mana, mn);
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
private static float CompactVital(ImDrawListPtr dl, float x, float y, float w, Vital vital, VitalView v)
|
||||
{
|
||||
float rowH = Px(25), valW = Px(36);
|
||||
Heart(dl, new Vector2(x, y), vital);
|
||||
float mx = x + Px(31), mw = w - Px(31) - valW - Px(6);
|
||||
Meter(dl, new Vector2(mx, y + (rowH - Px(16)) * 0.5f), mw, vital, v.Fraction);
|
||||
TextRight(dl, x + w, y, rowH, (int)MathF.Round(v.Fraction * 100) + "%", Text, 10);
|
||||
return y + rowH;
|
||||
}
|
||||
|
||||
internal static readonly string[] SubsystemNames = { "Combat", "Buffing", "Navigation", "Looting", "Meta" };
|
||||
|
||||
internal static bool SubsystemOn(RynthAiSnapshot raw, int i) => i switch
|
||||
{
|
||||
0 => raw.CombatEnabled, 1 => raw.BuffingEnabled, 2 => raw.NavigationEnabled, 3 => raw.LootingEnabled, _ => raw.MetaEnabled,
|
||||
};
|
||||
}
|
||||
273
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicGearTab.cs
Normal file
273
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicGearTab.cs
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicGearTab.cs
|
||||
// The Classic look's Gear tab: RynthAi's Items lists (UiSources.Items, the
|
||||
// Items panel's source) in the retail style. Weapons with their element (a
|
||||
// drop-down; a weapon no longer carried shows "missing"), consumables with
|
||||
// their kind, a remove mark on each row; add the item selected in game as a
|
||||
// weapon, a shield or a consumable; drop the missing ones; the shield and
|
||||
// mana-tap settings that ride the same list. Saved like the Items panel: the
|
||||
// whole payload (ItemsCommands.SetJson), older snapshots ignored after a save
|
||||
// so an edit doesn't flicker back. AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using RynthCore.Engine.UI.Panels;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicGearTab : IClassicTab
|
||||
{
|
||||
public string Name => "Gear";
|
||||
|
||||
// ItemsPanel's choice lists (the plugin's names).
|
||||
private static readonly string[] Elements = { "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||
private static readonly string[] ConsumableTypes =
|
||||
{ "General", "Lockpick", "HealthKit", "HealthPotion", "ManaPotion", "StaminaPotion", "ManaStone", "Stamina", "Pet" };
|
||||
|
||||
private const int WeaponRows = 8, ConsumableRows = 6;
|
||||
|
||||
private ItemsPanel.Payload _data = new();
|
||||
private long _seenVersion = -1, _savedAtVersion = -1;
|
||||
private readonly HashSet<int> _missing = new();
|
||||
private int _wFirst, _cFirst;
|
||||
private float _wGrab, _cGrab;
|
||||
private readonly byte[] _minMana = new byte[16], _keepStones = new byte[16];
|
||||
private int _minManaShown = int.MinValue, _keepShown = int.MinValue;
|
||||
private bool _typingMana, _typingKeep;
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
UiSources.Items.Subscribe();
|
||||
UiSources.Items.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Hidden() => UiSources.Items.Unsubscribe();
|
||||
|
||||
private void TakeSnapshot()
|
||||
{
|
||||
var snap = UiSources.Items.Current;
|
||||
if (snap == null || snap.Version == _seenVersion || snap.Version <= _savedAtVersion || _typingMana || _typingKeep) return;
|
||||
_seenVersion = snap.Version;
|
||||
_data = snap.Value.ParseCopy();
|
||||
_missing.Clear();
|
||||
foreach (int id in _data.MissingIds) _missing.Add(id);
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
_savedAtVersion = UiSources.Items.Current?.Version ?? _savedAtVersion;
|
||||
ItemsCommands.SetJson(ItemsCommands.Serialize(_data));
|
||||
}
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
TakeSnapshot();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float y = o.Y;
|
||||
bool loaded = UiSources.Items.Current != null;
|
||||
|
||||
// ── Weapons ──
|
||||
Header(dl, new Vector2(o.X, y), w, "Weapons", loaded ? _data.Weapons.Count + " listed" : "waiting for RynthAi");
|
||||
y += Px(23);
|
||||
y = WeaponList(ctx, dl, new Vector2(o.X, y), w);
|
||||
|
||||
// ── Consumables ──
|
||||
y += Px(8);
|
||||
Header(dl, new Vector2(o.X, y), w, "Consumables", loaded ? _data.Consumables.Count + " listed" : null);
|
||||
y += Px(23);
|
||||
y = ConsumableList(ctx, dl, new Vector2(o.X, y), w);
|
||||
|
||||
// ── Add the selected item ──
|
||||
y += Px(6);
|
||||
{
|
||||
float bw = (w - Px(12)) / 3;
|
||||
if (Button("##cg_addw", "Add weapon", new Vector2(o.X, y), bw, ButtonColor.Blue, loaded))
|
||||
ItemsCommands.AddSelectedWeapon();
|
||||
SafeImGui.SetItemTooltip("Add the item selected in game as a weapon.");
|
||||
if (Button("##cg_adds", "Add shield", new Vector2(o.X + bw + Px(6), y), bw, ButtonColor.Blue, loaded))
|
||||
ItemsCommands.AddSelectedShield();
|
||||
SafeImGui.SetItemTooltip("Add the item selected in game as a shield (worn with one-handed weapons).");
|
||||
if (Button("##cg_addc", "Add consumable", new Vector2(o.X + 2 * (bw + Px(6)), y), bw, ButtonColor.Blue, loaded))
|
||||
ItemsCommands.AddSelectedConsumable();
|
||||
SafeImGui.SetItemTooltip("Add the item selected in game as a consumable (kits, potions, food, stones).");
|
||||
y += Px(36);
|
||||
}
|
||||
|
||||
// ── Shield, mana tapping, missing ──
|
||||
if (loaded)
|
||||
{
|
||||
float colW = (w - Px(8)) / 2;
|
||||
if (_data.AutoEquipShield is bool shield)
|
||||
{
|
||||
if (Gem("##cg_shield", "Equip a shield", new Vector2(o.X, y), colW, shield))
|
||||
{
|
||||
_data.AutoEquipShield = !shield;
|
||||
Save();
|
||||
}
|
||||
SafeImGui.SetItemTooltip("Wear a listed shield with one-handed weapons.");
|
||||
}
|
||||
if (Gem("##cg_tap", "Mana tapping", new Vector2(o.X + colW + Px(8), y), colW, _data.EnableManaTapping))
|
||||
{
|
||||
_data.EnableManaTapping = !_data.EnableManaTapping;
|
||||
Save();
|
||||
}
|
||||
SafeImGui.SetItemTooltip("Use mana stones on your gear's mana when it runs low.");
|
||||
y += Px(20);
|
||||
NumberField("##cg_minmana", "Tap below mana", _minMana, ref _minManaShown, ref _typingMana, _data.ManaTapMinMana, 0, 100000,
|
||||
v => { _data.ManaTapMinMana = v; Save(); }, new Vector2(o.X, y), colW);
|
||||
NumberField("##cg_keep", "Keep stones", _keepStones, ref _keepShown, ref _typingKeep, _data.ManaStoneKeepCount, 0, 100,
|
||||
v => { _data.ManaStoneKeepCount = v; Save(); }, new Vector2(o.X + colW + Px(8), y), colW);
|
||||
y += Px(22);
|
||||
|
||||
y += Px(4);
|
||||
if (Plate("##cg_missing", "Clean", new Vector2(o.X, y)))
|
||||
ItemsCommands.CleanMissing();
|
||||
SafeImGui.SetItemTooltip("Remove listed weapons and consumables that are no longer in your inventory.\n" +
|
||||
"An entry whose item is gone but with an unlisted item of the same name in your pack is pointed at that item.");
|
||||
int missing = _missing.Count;
|
||||
TextMid(dl, o.X + Px(52), y, Px(17), missing > 0 ? missing + " listed item" + (missing == 1 ? " is" : "s are") + " missing" : "Nothing missing",
|
||||
missing > 0 ? Down : Faint, 10);
|
||||
y += Px(17);
|
||||
}
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
// ── Lists ───────────────────────────────────────────────────────────
|
||||
|
||||
private float WeaponList(ClassicContext ctx, ImDrawListPtr dl, Vector2 o, float w)
|
||||
{
|
||||
List<ItemsPanel.WeaponEntry> list = _data.Weapons;
|
||||
float rowH = Px(19), listW = w - Px(16), listH = rowH * WeaponRows;
|
||||
float ddW = Px(92), xW = Px(16), kindW = Px(70);
|
||||
dl.AddRectFilled(o, o + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
_wFirst = Wheel(o, o + new Vector2(w, listH), _wFirst, list.Count, WeaponRows);
|
||||
int remove = -1;
|
||||
for (int r = 0; r < WeaponRows && _wFirst + r < list.Count; r++)
|
||||
{
|
||||
int i = _wFirst + r;
|
||||
ItemsPanel.WeaponEntry e = list[i];
|
||||
var p = new Vector2(o.X, o.Y + r * rowH);
|
||||
if ((i & 1) == 1) dl.AddRectFilled(p, p + new Vector2(listW, rowH), AltRow);
|
||||
bool missing = _missing.Contains(e.Id);
|
||||
string kind = e.IsShield ? "Shield" : e.Kind.Length > 0 ? e.Kind : "";
|
||||
float nameRight = p.X + listW - xW - ddW - kindW - Px(8);
|
||||
TextClip(dl, p.X + Px(4), p.Y, rowH, nameRight, e.Name.Length > 0 ? e.Name : "#" + e.Id, missing ? Faint : White, 10);
|
||||
TextClip(dl, nameRight + Px(4), p.Y, rowH, nameRight + kindW, missing ? "missing" : kind, missing ? Down : Dim, 10);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
if (!e.IsShield)
|
||||
{
|
||||
var ddPos = new Vector2(p.X + listW - xW - ddW - Px(2), p.Y);
|
||||
int el = Math.Max(0, Array.IndexOf(Elements, e.Element));
|
||||
if (Dropdown("##el", Elements[el], ddPos, ddW))
|
||||
{
|
||||
int idx = i;
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, Elements, el, k =>
|
||||
{
|
||||
if (idx < _data.Weapons.Count) { _data.Weapons[idx].Element = Elements[k]; Save(); }
|
||||
});
|
||||
}
|
||||
SafeImGui.SetItemTooltip("The damage this weapon deals (picks it for monsters weak to it)");
|
||||
}
|
||||
if (RemoveMark("##x", new Vector2(p.X + listW - xW, p.Y), rowH)) remove = i;
|
||||
SafeImGui.SetItemTooltip("Remove " + e.Name + " from the list");
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
if (list.Count == 0)
|
||||
TextMid(dl, o.X + Px(6), o.Y, rowH, "No weapons. Select one in game and press Add weapon.", Dim, 10);
|
||||
_wFirst = Scrollbar("##cg_wsb", new Vector2(o.X + listW, o.Y), listH, list.Count, WeaponRows, _wFirst, ref _wGrab);
|
||||
if (remove >= 0) { list.RemoveAt(remove); Save(); }
|
||||
return o.Y + listH;
|
||||
}
|
||||
|
||||
private float ConsumableList(ClassicContext ctx, ImDrawListPtr dl, Vector2 o, float w)
|
||||
{
|
||||
List<ItemsPanel.ConsumableEntry> list = _data.Consumables;
|
||||
float rowH = Px(19), listW = w - Px(16), listH = rowH * ConsumableRows;
|
||||
float ddW = Px(110), xW = Px(16);
|
||||
dl.AddRectFilled(o, o + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
_cFirst = Wheel(o, o + new Vector2(w, listH), _cFirst, list.Count, ConsumableRows);
|
||||
int remove = -1;
|
||||
for (int r = 0; r < ConsumableRows && _cFirst + r < list.Count; r++)
|
||||
{
|
||||
int i = _cFirst + r;
|
||||
ItemsPanel.ConsumableEntry e = list[i];
|
||||
var p = new Vector2(o.X, o.Y + r * rowH);
|
||||
if ((i & 1) == 1) dl.AddRectFilled(p, p + new Vector2(listW, rowH), AltRow);
|
||||
bool missing = _missing.Contains(e.Id);
|
||||
float nameRight = p.X + listW - xW - ddW - Px(8);
|
||||
TextClip(dl, p.X + Px(4), p.Y, rowH, nameRight, (e.Name.Length > 0 ? e.Name : "#" + e.Id) + (missing ? " (missing)" : ""),
|
||||
missing ? Faint : White, 10);
|
||||
ImGuiNET.ImGui.PushID(1000 + i);
|
||||
var ddPos = new Vector2(p.X + listW - xW - ddW - Px(2), p.Y);
|
||||
int t = Math.Max(0, Array.IndexOf(ConsumableTypes, e.Type));
|
||||
if (Dropdown("##ty", ConsumableTypes[t], ddPos, ddW))
|
||||
{
|
||||
int idx = i;
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, ConsumableTypes, t, k =>
|
||||
{
|
||||
if (idx < _data.Consumables.Count) { _data.Consumables[idx].Type = ConsumableTypes[k]; Save(); }
|
||||
});
|
||||
}
|
||||
SafeImGui.SetItemTooltip("What it's used for");
|
||||
if (RemoveMark("##x", new Vector2(p.X + listW - xW, p.Y), rowH)) remove = i;
|
||||
SafeImGui.SetItemTooltip("Remove " + e.Name + " from the list");
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
if (list.Count == 0)
|
||||
TextMid(dl, o.X + Px(6), o.Y, rowH, "No consumables. Select one in game and press Add consumable.", Dim, 10);
|
||||
_cFirst = Scrollbar("##cg_csb", new Vector2(o.X + listW, o.Y), listH, list.Count, ConsumableRows, _cFirst, ref _cGrab);
|
||||
if (remove >= 0) { list.RemoveAt(remove); Save(); }
|
||||
return o.Y + listH;
|
||||
}
|
||||
|
||||
/// <summary>A small gold × that removes its row; true when clicked.</summary>
|
||||
private static bool RemoveMark(string id, Vector2 pos, float h)
|
||||
{
|
||||
float s = Px(16);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(s, h));
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
var c = new Vector2(pos.X + s * 0.5f, pos.Y + h * 0.5f);
|
||||
float r = Px(3.5f);
|
||||
uint col = hot ? Down : GoldDim;
|
||||
dl.AddLine(c - new Vector2(r, r), c + new Vector2(r, r), col, Math.Max(1, Px(1.5f)));
|
||||
dl.AddLine(c + new Vector2(-r, r), c + new Vector2(r, -r), col, Math.Max(1, Px(1.5f)));
|
||||
return clicked;
|
||||
}
|
||||
|
||||
private static void NumberField(string id, string label, byte[] buffer, ref int shown, ref bool typing, int value, int min, int max,
|
||||
Action<int> commit, Vector2 pos, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float rh = Px(22), boxW = Px(56);
|
||||
TextClip(dl, pos.X + Px(3), pos.Y, rh, pos.X + w - boxW - Px(6), label, Text, 10);
|
||||
if (!typing && shown != value) { Write(buffer, value); shown = value; }
|
||||
bool done = NumberBox(id, buffer, new Vector2(pos.X + w - boxW, pos.Y + (rh - Px(17)) * 0.5f), boxW, out bool active);
|
||||
typing = active;
|
||||
if (!done) return;
|
||||
if (ClassicSettings.TryParse(buffer, out double v))
|
||||
{
|
||||
int clamped = (int)Math.Clamp(Math.Round(v), min, max);
|
||||
Write(buffer, clamped);
|
||||
shown = clamped;
|
||||
if (clamped != value) commit(clamped);
|
||||
}
|
||||
else { Write(buffer, value); shown = value; }
|
||||
}
|
||||
|
||||
private static void Write(byte[] buffer, int value)
|
||||
{
|
||||
string text = value.ToString(CultureInfo.InvariantCulture);
|
||||
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, buffer, 0);
|
||||
buffer[Math.Min(n, buffer.Length - 1)] = 0;
|
||||
}
|
||||
}
|
||||
613
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicKit.cs
Normal file
613
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicKit.cs
Normal file
|
|
@ -0,0 +1,613 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicKit.cs
|
||||
// The retail pieces the RynthAi dashboard's Classic look is drawn from: the
|
||||
// client's own UI pictures (0x06 textures in client_portal.dat, through
|
||||
// RetailSprites) cut and stretched the way the retail windows use them, plus
|
||||
// the few widgets built on them (tabs, the red and blue buttons, the gem
|
||||
// check, the green drop-down, the gold plate, number boxes, the vitals
|
||||
// meters, the chain scrollbar, a popup list).
|
||||
//
|
||||
// Where the ids come from: the retail layouts as OpenAC resolves them
|
||||
// (tests/AcDream.App.Tests/UI/Layout/fixtures: options 0x2100006E, social,
|
||||
// vitals 0x2100006C) and AcClientReborn's tools/tex.py renders of them. The
|
||||
// art is the player's own install, read at runtime; nothing ships with it.
|
||||
//
|
||||
// Geometry is in retail pixels times S (set by the face each frame: the UI
|
||||
// scale times the dashboard's size). A picture that isn't in yet draws a flat
|
||||
// stand-in so the window never shows holes while RetailSprites decodes.
|
||||
//
|
||||
// AC's render thread only (inside the dashboard face's Draw). No per-frame
|
||||
// allocation.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal static class ClassicKit
|
||||
{
|
||||
// ── Retail pictures ─────────────────────────────────────────────────
|
||||
internal static class Art
|
||||
{
|
||||
// Window frame (5 px gold edges and corners; RetailChromeSprites in OpenAC).
|
||||
public const uint EdgeTop = 0x060074BFu, EdgeLeft = 0x060074C0u, EdgeBottom = 0x060074C1u, EdgeRight = 0x060074C2u;
|
||||
public const uint CornerTL = 0x060074C3u, CornerTR = 0x060074C4u, CornerBL = 0x060074C5u, CornerBR = 0x060074C6u;
|
||||
public const uint Fill = 0x06004CC2u; // 48x48 dark panel fill
|
||||
public const uint Stone = 0x06004D0Au; // 300x362 stone backdrop, 25 px title band on top
|
||||
public const uint TitleBar = 0x06004CFAu; // 276x25 gold-bevelled title bar
|
||||
public const uint Close = 0x06004D0Cu; // 24x25; +1 = pressed
|
||||
// Tabs (options panel 0x2100006E): 17 | 12 (stretched) | 17, 25 high. Even = open, odd = closed.
|
||||
public const uint TabLeftOpen = 0x06005D92u, TabLeftClosed = 0x06005D93u;
|
||||
public const uint TabMidOpen = 0x06005D94u, TabMidClosed = 0x06005D95u;
|
||||
public const uint TabRightOpen = 0x06005D96u, TabRightClosed = 0x06005D97u;
|
||||
public const uint Header = 0x06000F93u; // 282x20 black bar, gold border (a 3 px nine-slice)
|
||||
public const uint RowSelected = 0x06000F86u; // 282x20 teal row (skill header, trained)
|
||||
// Buttons: 32 | 15 (stretched) | 32, 32 high. -1 = pressed, -2 = ghosted.
|
||||
public const uint RedLeft = 0x06004C96u, RedMid = 0x06004C99u, RedRight = 0x06004C9Cu;
|
||||
public const uint BlueLeft = 0x060074A9u, BlueMid = 0x060074ACu, BlueRight = 0x060074AFu;
|
||||
public const uint GemOff = 0x06004D15u, GemOn = 0x06004D17u; // 13x13 checkbox lights
|
||||
public const uint DropField = 0x060012B3u; // 100x18 green field (3 px nine-slice); +1 = pressed
|
||||
public const uint DropCap = 0x060012B1u; // 17x19 arrow cap; +1 = open
|
||||
public const uint ListBack = 0x0600124Eu, ListPick = 0x0600124Du; // 191x17 popup rows
|
||||
public const uint Plate = 0x06004D65u; // 46x17 gold plate; +1 = pressed
|
||||
// Vitals meters (0x2100006C): 10 | 100 (stretched) | 10, 16 high.
|
||||
public const uint HpFill = 0x06007481u, StFill = 0x06007487u, MnFill = 0x0600748Du;
|
||||
public const uint MeterBack = 0x06007484u, MeterBackMana = 0x0600748Au;
|
||||
public const uint HeartHp = 0x06004C3Bu, HeartSt = 0x06004C3Cu, HeartMn = 0x06004C3Du; // 25x25
|
||||
// Chain scrollbar (0x2100003E).
|
||||
public const uint Track = 0x06004C5Fu; // 16x32, tiled
|
||||
public const uint ThumbTop = 0x06004C60u, ThumbMid = 0x06004C63u, ThumbBottom = 0x06004C66u;
|
||||
public const uint ArrowUp = 0x06004C6Cu, ArrowDown = 0x06004C69u; // 16x16; +1 rollover, +2 pressed
|
||||
}
|
||||
|
||||
// ── Colours (ABGR) ──────────────────────────────────────────────────
|
||||
public static readonly uint Gold = C(0xFFF0C850), GoldDim = C(0xFFBCAA7C), White = C(0xFFFFFFFF),
|
||||
Text = C(0xFFD8D8D8), Dim = C(0xFFA8A8A8), Faint = C(0xFF8F8F8F), Black = C(0xFF000000),
|
||||
Shadow = C(0xC0000000), Red = C(0xFFFF8A70), Green = C(0xFF86D686), Amber = C(0xFFE8BC52),
|
||||
Down = C(0xFFFF8070), Hover = C(0x14FFDC8C), StoneFallback = C(0xFF111111), Field = C(0xFF0B0B0B),
|
||||
AltRow = C(0x0DFFFFFF);
|
||||
|
||||
private static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
/// <summary>Retail pixels to screen pixels this frame (UI scale x dashboard size). Set by the face.</summary>
|
||||
public static float S = 1f;
|
||||
|
||||
public static float Px(float v) => v * S;
|
||||
|
||||
// ── Pictures ────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>One picture (or a sub-rectangle by uv) into min..max; false (nothing drawn) until it's in.</summary>
|
||||
public static bool Img(ImDrawListPtr dl, uint id, Vector2 min, Vector2 max, Vector2 uv0, Vector2 uv1)
|
||||
{
|
||||
if (!RetailSprites.TryGet(id, out IntPtr tex)) return false;
|
||||
dl.AddImage(tex, min, max, uv0, uv1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Img(ImDrawListPtr dl, uint id, Vector2 min, Vector2 max) => Img(dl, id, min, max, Vector2.Zero, Vector2.One);
|
||||
|
||||
/// <summary>A picture with fixed-width ends (srcL / srcR retail px of a srcW-wide picture) and a stretched middle.</summary>
|
||||
public static bool HSlice(ImDrawListPtr dl, uint id, Vector2 min, Vector2 max, float srcW, float srcL, float srcR)
|
||||
{
|
||||
if (!RetailSprites.TryGet(id, out IntPtr tex)) return false;
|
||||
float w = max.X - min.X;
|
||||
float l = Math.Min(Px(srcL), w * 0.5f), r = Math.Min(Px(srcR), w * 0.5f);
|
||||
float ul = srcL / srcW, ur = 1f - srcR / srcW;
|
||||
dl.AddImage(tex, min, new Vector2(min.X + l, max.Y), Vector2.Zero, new Vector2(ul, 1));
|
||||
if (w - l - r > 0)
|
||||
dl.AddImage(tex, new Vector2(min.X + l, min.Y), new Vector2(max.X - r, max.Y), new Vector2(ul, 0), new Vector2(ur, 1));
|
||||
dl.AddImage(tex, new Vector2(max.X - r, min.Y), max, new Vector2(ur, 0), Vector2.One);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Three pictures side by side: fixed left and right caps, the middle one stretched between them.</summary>
|
||||
public static bool Three(ImDrawListPtr dl, uint left, uint mid, uint right, Vector2 min, Vector2 max, float capW)
|
||||
{
|
||||
if (!RetailSprites.TryGet(left, out IntPtr l) || !RetailSprites.TryGet(mid, out IntPtr m)
|
||||
|| !RetailSprites.TryGet(right, out IntPtr r)) return false;
|
||||
float cap = Math.Min(Px(capW), (max.X - min.X) * 0.5f);
|
||||
dl.AddImage(l, min, new Vector2(min.X + cap, max.Y));
|
||||
if (max.X - min.X > 2 * cap) dl.AddImage(m, new Vector2(min.X + cap, min.Y), new Vector2(max.X - cap, max.Y));
|
||||
dl.AddImage(r, new Vector2(max.X - cap, min.Y), max);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>A nine-slice: a b-px border (retail px) kept, edges and centre stretched.</summary>
|
||||
public static bool Nine(ImDrawListPtr dl, uint id, Vector2 min, Vector2 max, float srcW, float srcH, float b)
|
||||
{
|
||||
if (!RetailSprites.TryGet(id, out IntPtr tex)) return false;
|
||||
float bx = Math.Min(Px(b), (max.X - min.X) * 0.5f), by = Math.Min(Px(b), (max.Y - min.Y) * 0.5f);
|
||||
float u1 = b / srcW, u2 = 1 - b / srcW, v1 = b / srcH, v2 = 1 - b / srcH;
|
||||
float x0 = min.X, x1 = min.X + bx, x2 = max.X - bx, x3 = max.X;
|
||||
float y0 = min.Y, y1 = min.Y + by, y2 = max.Y - by, y3 = max.Y;
|
||||
Span<float> xs = stackalloc float[] { x0, x1, x2, x3 };
|
||||
Span<float> ys = stackalloc float[] { y0, y1, y2, y3 };
|
||||
Span<float> us = stackalloc float[] { 0, u1, u2, 1 };
|
||||
Span<float> vs = stackalloc float[] { 0, v1, v2, 1 };
|
||||
for (int j = 0; j < 3; j++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (xs[i + 1] > xs[i] && ys[j + 1] > ys[j])
|
||||
dl.AddImage(tex, new Vector2(xs[i], ys[j]), new Vector2(xs[i + 1], ys[j + 1]),
|
||||
new Vector2(us[i], vs[j]), new Vector2(us[i + 1], vs[j + 1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Window ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The 5 px gold frame around min..max (drawn inside it).</summary>
|
||||
public static void Frame(ImDrawListPtr dl, Vector2 min, Vector2 max)
|
||||
{
|
||||
float e = Px(5);
|
||||
if (!RetailSprites.TryGet(Art.EdgeTop, out IntPtr top) || !RetailSprites.TryGet(Art.EdgeBottom, out IntPtr bottom)
|
||||
|| !RetailSprites.TryGet(Art.EdgeLeft, out IntPtr left) || !RetailSprites.TryGet(Art.EdgeRight, out IntPtr right))
|
||||
{
|
||||
dl.AddRect(min, max, Gold, 0, ImDrawFlags.None, Math.Max(1, Px(1.5f)));
|
||||
return;
|
||||
}
|
||||
dl.AddImage(top, new Vector2(min.X + e, min.Y), new Vector2(max.X - e, min.Y + e));
|
||||
dl.AddImage(bottom, new Vector2(min.X + e, max.Y - e), new Vector2(max.X - e, max.Y));
|
||||
dl.AddImage(left, new Vector2(min.X, min.Y + e), new Vector2(min.X + e, max.Y - e));
|
||||
dl.AddImage(right, new Vector2(max.X - e, min.Y + e), new Vector2(max.X, max.Y - e));
|
||||
Img(dl, Art.CornerTL, min, min + new Vector2(e, e));
|
||||
Img(dl, Art.CornerTR, new Vector2(max.X - e, min.Y), new Vector2(max.X, min.Y + e));
|
||||
Img(dl, Art.CornerBL, new Vector2(min.X, max.Y - e), new Vector2(min.X + e, max.Y));
|
||||
Img(dl, Art.CornerBR, max - new Vector2(e, e), max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The body: the dark fill, with the stone picture over its top at the window's width (its 25 px
|
||||
/// title band left out, its height kept in proportion so the rock doesn't smear).
|
||||
/// </summary>
|
||||
public static void Backdrop(ImDrawListPtr dl, Vector2 min, Vector2 max, byte alpha)
|
||||
{
|
||||
uint tint = (uint)alpha << 24 | 0x00FFFFFF;
|
||||
float w = max.X - min.X, h = max.Y - min.Y;
|
||||
dl.AddRectFilled(min, max, (StoneFallback & 0x00FFFFFF) | ((uint)alpha << 24));
|
||||
if (!RetailSprites.TryGet(Art.Stone, out IntPtr stone)) return;
|
||||
const float SrcW = 300f, SrcH = 362f, Band = 25f;
|
||||
float stoneH = w * (SrcH - Band) / SrcW;
|
||||
float shown = Math.Min(h, stoneH);
|
||||
float v0 = Band / SrcH, v1 = v0 + (shown / stoneH) * (1 - v0);
|
||||
dl.AddImage(stone, min, new Vector2(max.X, min.Y + shown), new Vector2(0, v0), new Vector2(1, v1), tint);
|
||||
}
|
||||
|
||||
/// <summary>The retail close button at pos (24x25 retail px); true when clicked.</summary>
|
||||
public static bool CloseButton(string id, Vector2 pos)
|
||||
{
|
||||
var size = new Vector2(Px(24), Px(25));
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size);
|
||||
bool down = ImGuiNET.ImGui.IsItemActive();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
if (!Img(dl, down ? Art.Close + 1 : Art.Close, pos, pos + size))
|
||||
{
|
||||
dl.AddRect(pos + new Vector2(Px(3), Px(3)), pos + size - new Vector2(Px(3), Px(3)), Gold, 2);
|
||||
dl.AddLine(pos + new Vector2(Px(7), size.Y * 0.5f), pos + new Vector2(size.X - Px(7), size.Y * 0.5f), Gold, 2);
|
||||
}
|
||||
return clicked;
|
||||
}
|
||||
|
||||
// ── Text ────────────────────────────────────────────────────────────
|
||||
|
||||
public static ImFontPtr Font(bool bold = false) => ImGuiFonts.Get(bold ? UiFont.UiBold11 : UiFont.Ui11);
|
||||
|
||||
/// <summary>Text size in screen px at retail size <paramref name="px"/>.</summary>
|
||||
public static Vector2 Measure(string text, float px, bool bold = false)
|
||||
{
|
||||
ImFontPtr f = Font(bold);
|
||||
ImGuiNET.ImGui.PushFont(f);
|
||||
Vector2 v = ImGuiNET.ImGui.CalcTextSize(text) * (Px(px) / f.FontSize);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
return v;
|
||||
}
|
||||
|
||||
/// <summary>Retail text: a 1 px black shadow under it, like the client's.</summary>
|
||||
public static void Print(ImDrawListPtr dl, Vector2 pos, string text, uint color, float px = 11, bool bold = false)
|
||||
{
|
||||
ImFontPtr f = Font(bold);
|
||||
float size = Px(px);
|
||||
float o = Math.Max(1f, Px(1));
|
||||
dl.AddText(f, size, pos + new Vector2(o, o), Shadow, text);
|
||||
dl.AddText(f, size, pos, color, text);
|
||||
}
|
||||
|
||||
/// <summary>Text centred vertically in a row of height h starting at y.</summary>
|
||||
public static void TextMid(ImDrawListPtr dl, float x, float y, float h, string text, uint color, float px = 11, bool bold = false)
|
||||
=> Print(dl, new Vector2(x, y + (h - Px(px) * 1.15f) * 0.5f), text, color, px, bold);
|
||||
|
||||
/// <summary>Right-aligned text ending at <paramref name="right"/>.</summary>
|
||||
public static void TextRight(ImDrawListPtr dl, float right, float y, float h, string text, uint color, float px = 11, bool bold = false)
|
||||
{
|
||||
float w = Measure(text, px, bold).X;
|
||||
TextMid(dl, right - w, y, h, text, color, px, bold);
|
||||
}
|
||||
|
||||
/// <summary>Text clipped to [x, right).</summary>
|
||||
public static void TextClip(ImDrawListPtr dl, float x, float y, float h, float right, string text, uint color, float px = 11, bool bold = false)
|
||||
{
|
||||
dl.PushClipRect(new Vector2(x, y), new Vector2(Math.Max(x + 1, right), y + h), true);
|
||||
TextMid(dl, x, y, h, text, color, px, bold);
|
||||
dl.PopClipRect();
|
||||
}
|
||||
|
||||
// ── Widgets ─────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>A section header: the gold-bordered black bar with a title and an optional right note.</summary>
|
||||
public static void Header(ImDrawListPtr dl, Vector2 pos, float w, string title, string? right = null)
|
||||
{
|
||||
float h = Px(18);
|
||||
var max = new Vector2(pos.X + w, pos.Y + h);
|
||||
if (!Nine(dl, Art.Header, pos, max, 282, 20, 3))
|
||||
{
|
||||
dl.AddRectFilled(pos, max, Black);
|
||||
dl.AddRect(pos, max, Gold);
|
||||
}
|
||||
TextMid(dl, pos.X + Px(6), pos.Y, h, title, Gold);
|
||||
if (!string.IsNullOrEmpty(right)) TextRight(dl, max.X - Px(6), pos.Y, h, right!, GoldDim, 10);
|
||||
}
|
||||
|
||||
/// <summary>One retail tab (25 px high); true when clicked.</summary>
|
||||
public static bool Tab(string id, string label, Vector2 pos, float w, bool open)
|
||||
{
|
||||
float h = Px(25);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(w, h));
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
var max = new Vector2(pos.X + w, pos.Y + h);
|
||||
if (!Three(dl, open ? Art.TabLeftOpen : Art.TabLeftClosed, open ? Art.TabMidOpen : Art.TabMidClosed,
|
||||
open ? Art.TabRightOpen : Art.TabRightClosed, pos, max, 17))
|
||||
{
|
||||
dl.AddRectFilled(pos, max, open ? StoneFallback : Black);
|
||||
dl.AddRect(pos, max, Gold);
|
||||
}
|
||||
float tw = Measure(label, 10).X;
|
||||
Print(dl, new Vector2(pos.X + (w - tw) * 0.5f, pos.Y + Px(8)), label, open ? White : hot ? Gold : Dim, 10);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
public enum ButtonColor { Red, Blue }
|
||||
|
||||
/// <summary>A retail button (32 px high, any width); true when clicked.</summary>
|
||||
public static bool Button(string id, string label, Vector2 pos, float w, ButtonColor color, bool enabled = true)
|
||||
{
|
||||
float h = Px(32);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(w, h)) && enabled;
|
||||
bool down = enabled && ImGuiNET.ImGui.IsItemActive();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
var max = new Vector2(pos.X + w, pos.Y + h);
|
||||
uint l = color == ButtonColor.Red ? Art.RedLeft : Art.BlueLeft;
|
||||
uint m = color == ButtonColor.Red ? Art.RedMid : Art.BlueMid;
|
||||
uint r = color == ButtonColor.Red ? Art.RedRight : Art.BlueRight;
|
||||
uint d = !enabled ? 2u : down ? 1u : 0u;
|
||||
if (!Three(dl, l - d, m - d, r - d, pos, max, 32))
|
||||
{
|
||||
dl.AddRectFilled(pos, max, color == ButtonColor.Red ? C(0xFF6A1010) : C(0xFF10206A), Px(3));
|
||||
dl.AddRect(pos, max, Gold, Px(3));
|
||||
}
|
||||
float tw = Measure(label, 11).X;
|
||||
TextMid(dl, pos.X + (w - tw) * 0.5f, pos.Y, h, label, enabled ? White : Dim);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A gem check with its label: the whole row is the button. Returns true when clicked (the caller flips
|
||||
/// the value). <paramref name="w"/> is the row's width.
|
||||
/// </summary>
|
||||
public static bool Gem(string id, string label, Vector2 pos, float w, bool on, float h = 18)
|
||||
{
|
||||
float rh = Px(h);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(w, rh));
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
if (hot) dl.AddRectFilled(pos, pos + new Vector2(w, rh), Hover);
|
||||
GemPicture(dl, new Vector2(pos.X + Px(3), pos.Y + (rh - Px(13)) * 0.5f), on);
|
||||
TextClip(dl, pos.X + Px(22), pos.Y, rh, pos.X + w, label, on ? White : Text);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
public static void GemPicture(ImDrawListPtr dl, Vector2 pos, bool on)
|
||||
{
|
||||
var size = new Vector2(Px(13), Px(13));
|
||||
if (!Img(dl, on ? Art.GemOn : Art.GemOff, pos, pos + size))
|
||||
dl.AddCircleFilled(pos + size * 0.5f, size.X * 0.45f, on ? C(0xFF9BE65A) : C(0xFF3A3328));
|
||||
}
|
||||
|
||||
/// <summary>The green drop-down (field + arrow cap) showing <paramref name="text"/>; true when clicked.</summary>
|
||||
public static bool Dropdown(string id, string text, Vector2 pos, float w, bool open = false)
|
||||
{
|
||||
float h = Px(19), capW = Px(17);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, new Vector2(w, h));
|
||||
bool down = ImGuiNET.ImGui.IsItemActive() || open;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
var fieldMax = new Vector2(pos.X + w - capW, pos.Y + h);
|
||||
if (!Nine(dl, down ? Art.DropField + 1 : Art.DropField, pos, fieldMax, 100, 18, 3))
|
||||
{
|
||||
dl.AddRectFilled(pos, fieldMax, C(0xFF0E2A12));
|
||||
dl.AddRect(pos, fieldMax, C(0xFF3C7A44));
|
||||
}
|
||||
if (!Img(dl, down ? Art.DropCap + 1 : Art.DropCap, new Vector2(fieldMax.X, pos.Y), new Vector2(pos.X + w, pos.Y + h)))
|
||||
dl.AddTriangleFilled(new Vector2(fieldMax.X + Px(4), pos.Y + Px(7)), new Vector2(pos.X + w - Px(4), pos.Y + Px(7)),
|
||||
new Vector2(fieldMax.X + capW * 0.5f, pos.Y + Px(13)), C(0xFF3CC85A));
|
||||
TextClip(dl, pos.X + Px(5), pos.Y, h, fieldMax.X - Px(3), text, White, 10);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
/// <summary>The small gold plate button (46x17 retail px); true when clicked.</summary>
|
||||
public static bool Plate(string id, string label, Vector2 pos)
|
||||
{
|
||||
var size = new Vector2(Px(46), Px(17));
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton(id, size);
|
||||
bool down = ImGuiNET.ImGui.IsItemActive();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
if (!Img(dl, down ? Art.Plate + 1 : Art.Plate, pos, pos + size))
|
||||
{
|
||||
dl.AddRectFilled(pos, pos + size, C(0xFFB08A3C), Px(2));
|
||||
dl.AddRect(pos, pos + size, Gold, Px(2));
|
||||
}
|
||||
float tw = Measure(label, 10).X;
|
||||
ImFontPtr f = Font();
|
||||
dl.AddText(f, Px(10), new Vector2(pos.X + Px(7) + (size.X - Px(7) - tw) * 0.5f, pos.Y + (size.Y - Px(10) * 1.15f) * 0.5f),
|
||||
C(0xFF3A2200), label);
|
||||
return clicked;
|
||||
}
|
||||
|
||||
/// <summary>A selected list row's teal highlight.</summary>
|
||||
public static void RowSelected(ImDrawListPtr dl, Vector2 min, Vector2 max)
|
||||
{
|
||||
if (!Nine(dl, Art.RowSelected, min, max, 282, 20, 2))
|
||||
dl.AddRectFilled(min, max, C(0xFF1D5A63));
|
||||
}
|
||||
|
||||
/// <summary>The frame of a number box (the header bar's gold border, small); the caller draws the input over it.</summary>
|
||||
public static void FieldFrame(ImDrawListPtr dl, Vector2 min, Vector2 max)
|
||||
{
|
||||
if (!Nine(dl, Art.Header, min, max, 282, 20, 3))
|
||||
{
|
||||
dl.AddRectFilled(min, max, Field);
|
||||
dl.AddRect(min, max, Gold);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A retail number box: the gold-bordered field with an ImGui text input over it (keys kept out of AC
|
||||
/// while it's typed in, like FaceKit's boxes). Returns true when an edit was finished (Enter or focus
|
||||
/// loss) with <paramref name="buffer"/> holding the text.
|
||||
/// </summary>
|
||||
public static bool NumberBox(string id, byte[] buffer, Vector2 pos, float w, out bool active)
|
||||
{
|
||||
float h = Px(17);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
FieldFrame(dl, pos, pos + new Vector2(w, h));
|
||||
ImFontPtr f = Font();
|
||||
ImGuiNET.ImGui.PushFont(f);
|
||||
ImGuiNET.ImGui.SetWindowFontScale(Px(10) / f.FontSize);
|
||||
float fs = ImGuiNET.ImGui.GetFontSize();
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, White);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.TextSelectedBg, C(0x66F0C850));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 0f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(Px(4), Math.Max(0, (h - fs) * 0.5f)));
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(w);
|
||||
ImGuiNET.ImGui.InputText(id, buffer, (uint)buffer.Length, ImGuiInputTextFlags.CharsDecimal | ImGuiInputTextFlags.AutoSelectAll);
|
||||
active = ImGuiNET.ImGui.IsItemActive();
|
||||
if (active) ImGuiTextFocus.NoteActive(id); // keys stay out of AC from this frame on
|
||||
bool done = ImGuiNET.ImGui.IsItemDeactivatedAfterEdit();
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(6);
|
||||
ImGuiNET.ImGui.SetWindowFontScale(1f);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
return done;
|
||||
}
|
||||
|
||||
public enum Vital { Health, Stamina, Mana }
|
||||
|
||||
/// <summary>A retail vitals meter (16 px high): the empty bar, the filled part clipped to <paramref name="frac"/>.</summary>
|
||||
public static void Meter(ImDrawListPtr dl, Vector2 pos, float w, Vital vital, float frac)
|
||||
{
|
||||
float h = Px(16);
|
||||
var max = new Vector2(pos.X + w, pos.Y + h);
|
||||
uint back = vital == Vital.Mana ? Art.MeterBackMana : Art.MeterBack;
|
||||
uint fill = vital switch { Vital.Health => Art.HpFill, Vital.Stamina => Art.StFill, _ => Art.MnFill };
|
||||
if (!Three(dl, back, back + 1, back + 2, pos, max, 10))
|
||||
dl.AddRectFilled(pos, max, C(0xFF161210), Px(3));
|
||||
float fx = pos.X + w * Math.Clamp(frac, 0f, 1f);
|
||||
if (fx <= pos.X) return;
|
||||
dl.PushClipRect(pos, new Vector2(fx, max.Y), true);
|
||||
if (!Three(dl, fill, fill + 1, fill + 2, pos, max, 10))
|
||||
{
|
||||
uint col = vital switch { Vital.Health => C(0xFFC81E1E), Vital.Stamina => C(0xFFD8A21E), _ => C(0xFF1E78DC) };
|
||||
dl.AddRectFilled(pos, max, col, Px(3));
|
||||
}
|
||||
dl.PopClipRect();
|
||||
}
|
||||
|
||||
public static void Heart(ImDrawListPtr dl, Vector2 pos, Vital vital)
|
||||
{
|
||||
uint id = vital switch { Vital.Health => Art.HeartHp, Vital.Stamina => Art.HeartSt, _ => Art.HeartMn };
|
||||
var size = new Vector2(Px(25), Px(25));
|
||||
if (!Img(dl, id, pos, pos + size))
|
||||
dl.AddCircleFilled(pos + size * 0.5f, Px(8), vital switch
|
||||
{ Vital.Health => C(0xFFC81E1E), Vital.Stamina => C(0xFFD8C21E), _ => C(0xFF1E5ADC) });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The chain scrollbar beside a list (16 px wide, <paramref name="h"/> high): arrows step one row, the
|
||||
/// thumb drags, the track pages. Returns the first visible row.
|
||||
/// </summary>
|
||||
public static int Scrollbar(string id, Vector2 pos, float h, int total, int visible, int first, ref float grab)
|
||||
{
|
||||
int maxFirst = Math.Max(0, total - visible);
|
||||
first = Math.Clamp(first, 0, maxFirst);
|
||||
float w = Px(16), arrow = Px(16);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
|
||||
// The chain, tiled (32 px a link pattern).
|
||||
if (RetailSprites.TryGet(Art.Track, out IntPtr track))
|
||||
{
|
||||
float tile = Px(32);
|
||||
for (float y = arrow; y < h - arrow; y += tile)
|
||||
{
|
||||
float th = Math.Min(tile, h - arrow - y);
|
||||
dl.AddImage(track, new Vector2(pos.X, pos.Y + y), new Vector2(pos.X + w, pos.Y + y + th),
|
||||
Vector2.Zero, new Vector2(1, th / tile));
|
||||
}
|
||||
}
|
||||
else dl.AddRectFilled(pos, pos + new Vector2(w, h), C(0xFF2A2214));
|
||||
|
||||
ImGuiNET.ImGui.PushID(id);
|
||||
// Arrows.
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##up", new Vector2(w, arrow))) first = Math.Max(0, first - 1);
|
||||
uint upState = ImGuiNET.ImGui.IsItemActive() ? 2u : ImGuiNET.ImGui.IsItemHovered() ? 1u : 0u;
|
||||
if (!Img(dl, Art.ArrowUp + upState, pos, pos + new Vector2(w, arrow)))
|
||||
dl.AddTriangleFilled(pos + new Vector2(w * 0.5f, Px(4)), pos + new Vector2(Px(3), arrow - Px(4)), pos + new Vector2(w - Px(3), arrow - Px(4)), Gold);
|
||||
var dn = new Vector2(pos.X, pos.Y + h - arrow);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(dn);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##down", new Vector2(w, arrow))) first = Math.Min(maxFirst, first + 1);
|
||||
uint dnState = ImGuiNET.ImGui.IsItemActive() ? 2u : ImGuiNET.ImGui.IsItemHovered() ? 1u : 0u;
|
||||
if (!Img(dl, Art.ArrowDown + dnState, dn, dn + new Vector2(w, arrow)))
|
||||
dl.AddTriangleFilled(dn + new Vector2(Px(3), Px(4)), dn + new Vector2(w - Px(3), Px(4)), dn + new Vector2(w * 0.5f, arrow - Px(4)), Gold);
|
||||
|
||||
// Thumb: its height is the visible share of the track, at least 24 px.
|
||||
float trackY = pos.Y + arrow, trackH = h - 2 * arrow;
|
||||
if (maxFirst > 0 && trackH > Px(24))
|
||||
{
|
||||
float thumbH = Math.Max(Px(24), trackH * visible / Math.Max(1, total));
|
||||
float travel = trackH - thumbH;
|
||||
float ty = trackY + travel * first / maxFirst;
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(pos.X, trackY));
|
||||
ImGuiNET.ImGui.InvisibleButton("##track", new Vector2(w, trackH));
|
||||
if (ImGuiNET.ImGui.IsItemActivated())
|
||||
{
|
||||
float my = ImGuiNET.ImGui.GetMousePos().Y;
|
||||
if (my >= ty && my <= ty + thumbH) grab = my - ty;
|
||||
else { grab = -1; first = Math.Clamp(first + (my < ty ? -visible : visible), 0, maxFirst); }
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemActive() && grab >= 0 && travel > 0)
|
||||
{
|
||||
float y = ImGuiNET.ImGui.GetMousePos().Y - grab - trackY;
|
||||
first = (int)MathF.Round(Math.Clamp(y / travel, 0f, 1f) * maxFirst);
|
||||
ty = trackY + travel * first / maxFirst;
|
||||
}
|
||||
var t0 = new Vector2(pos.X, ty);
|
||||
float cap = Px(3);
|
||||
if (!(Img(dl, Art.ThumbTop, t0, t0 + new Vector2(w, cap))
|
||||
& Img(dl, Art.ThumbMid, t0 + new Vector2(0, cap), t0 + new Vector2(w, thumbH - cap))
|
||||
& Img(dl, Art.ThumbBottom, t0 + new Vector2(0, thumbH - cap), t0 + new Vector2(w, thumbH))))
|
||||
dl.AddRectFilled(t0, t0 + new Vector2(w, thumbH), C(0xFF203C8C), Px(2));
|
||||
}
|
||||
ImGuiNET.ImGui.PopID();
|
||||
return first;
|
||||
}
|
||||
|
||||
/// <summary>Mouse wheel over min..max scrolls the list (one row a notch).</summary>
|
||||
public static int Wheel(Vector2 min, Vector2 max, int first, int total, int visible)
|
||||
{
|
||||
if (!ImGuiNET.ImGui.IsWindowHovered() || !ImGuiNET.ImGui.IsMouseHoveringRect(min, max)) return first;
|
||||
float wheel = ImGuiNET.ImGui.GetIO().MouseWheel;
|
||||
if (wheel == 0) return first;
|
||||
return Math.Clamp(first - (int)MathF.Round(wheel * 3), 0, Math.Max(0, total - visible));
|
||||
}
|
||||
|
||||
// ── Popup list (one per face) ───────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// A retail popup list under a drop-down: Open from the drop-down's click, Draw once a frame at the
|
||||
/// end of the face's Draw. Rows are the retail list rows; the picked one is the lit row.
|
||||
/// </summary>
|
||||
internal sealed class Popup
|
||||
{
|
||||
private readonly string _id;
|
||||
private string[] _items = Array.Empty<string>();
|
||||
private int _selected = -1, _first;
|
||||
private Action<int>? _onPick;
|
||||
private Vector2 _pos;
|
||||
private float _w;
|
||||
private bool _openRequested;
|
||||
private float _grab;
|
||||
|
||||
public Popup(string id) => _id = id;
|
||||
|
||||
public bool IsOpen => ImGuiNET.ImGui.IsPopupOpen(_id);
|
||||
|
||||
public void Open(Vector2 below, float w, string[] items, int selected, Action<int> onPick)
|
||||
{
|
||||
_items = items;
|
||||
_selected = selected;
|
||||
_onPick = onPick;
|
||||
_pos = below;
|
||||
_w = w;
|
||||
_first = Math.Max(0, selected - 4);
|
||||
_openRequested = items.Length > 0;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (_openRequested)
|
||||
{
|
||||
_openRequested = false;
|
||||
ImGuiNET.ImGui.SetNextWindowPos(_pos);
|
||||
ImGuiNET.ImGui.OpenPopup(_id);
|
||||
}
|
||||
const int MaxRows = 12;
|
||||
float rowH = Px(17);
|
||||
int rows = Math.Min(MaxRows, Math.Max(1, _items.Length));
|
||||
ImGuiNET.ImGui.SetNextWindowSize(new Vector2(_w, rows * rowH + Px(4)));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.PopupBg, C(0xF2080808));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Border, Gold);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(Px(2), Px(2)));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.PopupRounding, 0f);
|
||||
bool open = ImGuiNET.ImGui.BeginPopup(_id, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse);
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(2);
|
||||
if (!open) return;
|
||||
try
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
Vector2 o = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
bool scroll = _items.Length > MaxRows;
|
||||
float listW = _w - Px(4) - (scroll ? Px(16) : 0);
|
||||
_first = Wheel(o, o + new Vector2(_w, rows * rowH), _first, _items.Length, rows);
|
||||
for (int r = 0; r < rows && _first + r < _items.Length; r++)
|
||||
{
|
||||
int i = _first + r;
|
||||
var p = new Vector2(o.X, o.Y + r * rowH);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
bool clicked = ImGuiNET.ImGui.InvisibleButton("##row", new Vector2(listW, rowH));
|
||||
bool hot = ImGuiNET.ImGui.IsItemHovered();
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (i == _selected || hot)
|
||||
{
|
||||
if (!HSlice(dl, i == _selected ? Art.ListPick : Art.ListBack, p, p + new Vector2(listW, rowH), 191, 20, 20))
|
||||
dl.AddRectFilled(p, p + new Vector2(listW, rowH), C(0xFF6A3A18));
|
||||
}
|
||||
TextClip(dl, p.X + Px(i == _selected ? 22 : 6), p.Y, rowH, p.X + listW - Px(4), _items[i], i == _selected ? White : Text, 10);
|
||||
if (clicked)
|
||||
{
|
||||
_onPick?.Invoke(i);
|
||||
ImGuiNET.ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
if (scroll)
|
||||
_first = Scrollbar("##popsb", new Vector2(o.X + listW, o.Y), rows * rowH, _items.Length, rows, _first, ref _grab);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
207
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicLootTab.cs
Normal file
207
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicLootTab.cs
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicLootTab.cs
|
||||
// The Classic look's Loot tab, in the retail style:
|
||||
// Looting the subsystem gem and the loot profile RynthAi loots with
|
||||
// (the dashboard's Loot picker)
|
||||
// Rules the loot profile being edited (RynthAi's editing session,
|
||||
// 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.
|
||||
// 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).
|
||||
// Commands are the Loot Editor's (LootEditCommands, each naming the rule it
|
||||
// expects at that index). AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicLootTab : IClassicTab
|
||||
{
|
||||
public string Name => "Loot";
|
||||
|
||||
private const int VisibleRows = 14;
|
||||
|
||||
private int _selected = -1, _first;
|
||||
private float _grab;
|
||||
private LootEditStateDto? _filesFor;
|
||||
private string[] _files = Array.Empty<string>();
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
UiSources.LootEdit.Subscribe();
|
||||
UiSources.LootEdit.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Hidden() => UiSources.LootEdit.Unsubscribe();
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
RynthAiSnapshot raw = ctx.Raw;
|
||||
LootEditView? view = UiSources.LootEdit.Current?.Value;
|
||||
LootEditStateDto? s = view?.State;
|
||||
float y = o.Y;
|
||||
float rowH = Px(22), labelW = Px(52);
|
||||
|
||||
// ── Looting ──
|
||||
Header(dl, new Vector2(o.X, y), w, "Looting", raw.LootingEnabled ? "on" : "off");
|
||||
y += Px(23);
|
||||
{
|
||||
bool on = raw.LootingEnabled;
|
||||
if (Gem("##cl_on", "Looting", new Vector2(o.X, y), w / 2, on))
|
||||
RynthAiCommands.SetSubsystemEnabled(3, !on);
|
||||
SafeImGui.SetItemTooltip(on ? "Looting on. Click to turn it off." : "Looting off. Click to turn it on.");
|
||||
y += Px(20);
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Loot with", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(14), y + (rowH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(14);
|
||||
if (Dropdown("##cl_use", ctx.View?.LootText ?? "None", ddPos, ddW, ctx.Popup.IsOpen) && raw.LootProfiles.Length > 0)
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, raw.LootProfiles, raw.SelectedLootIdx, i => RynthAiCommands.SelectProfile(1, i));
|
||||
SafeImGui.SetItemTooltip("The loot profile RynthAi loots with");
|
||||
y += rowH;
|
||||
}
|
||||
|
||||
// ── The profile being edited ──
|
||||
y += Px(8);
|
||||
string right = view == null ? "waiting for RynthAi" : view.Unavailable ? "needs a newer RynthAi"
|
||||
: s == null ? "loading" : s.ReadOnly ? "read only" : s.Dirty ? "unsaved changes" : s.Rules.Count + " rules";
|
||||
Header(dl, new Vector2(o.X, y), w, "Rules", right);
|
||||
y += Px(23);
|
||||
{
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Editing", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(14), y + (rowH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(14) - Px(52);
|
||||
string[] files = Files(s);
|
||||
int cur = -1;
|
||||
if (s != null) for (int i = 0; i < s.Files.Count; i++) if (SamePath(s.Files[i].Path, s.Path)) { cur = i; break; }
|
||||
string shown = s == null || s.FileName.Length == 0 ? "None" : s.FileName;
|
||||
if (Dropdown("##cl_file", shown, ddPos, ddW, ctx.Popup.IsOpen) && s != null && !s.Dirty)
|
||||
{
|
||||
LootEditStateDto st = s;
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, files, cur, i =>
|
||||
{
|
||||
if (i < st.Files.Count) { _selected = -1; LootEditCommands.Simple("open", path: st.Files[i].Path); }
|
||||
});
|
||||
}
|
||||
SafeImGui.SetItemTooltip(s != null && s.Dirty ? "Save or reload this file before opening another." : "The loot profile to edit");
|
||||
if (Plate("##cl_editor", "Editor", new Vector2(o.X + w - Px(46), y + (rowH - Px(17)) * 0.5f)))
|
||||
LootEditorFace.ToggleFor(s?.Path.Length > 0 ? s.Path : raw.CurrentLootPath);
|
||||
SafeImGui.SetItemTooltip("The Loot Editor: write a rule's conditions");
|
||||
y += rowH + Px(2);
|
||||
}
|
||||
|
||||
// The rules.
|
||||
float listW = w - Px(16), rh = Px(17), listH = rh * VisibleRows;
|
||||
float badgeW = Px(58), nameW = Px(130);
|
||||
var listMin = new Vector2(o.X, y);
|
||||
dl.AddRectFilled(listMin, listMin + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
int count = s?.Rules.Count ?? 0;
|
||||
_first = Wheel(listMin, listMin + new Vector2(w, listH), _first, count, VisibleRows);
|
||||
bool editable = s != null && !s.ReadOnly;
|
||||
for (int r = 0; r < VisibleRows && _first + r < count; r++)
|
||||
{
|
||||
int i = _first + r;
|
||||
LootEditRowDto rule = s!.Rules[i];
|
||||
var p = new Vector2(o.X, y + r * rh);
|
||||
bool sel = i == _selected;
|
||||
if (sel) RowSelected(dl, p, p + new Vector2(listW, rh));
|
||||
else if ((i & 1) == 1) dl.AddRectFilled(p, p + new Vector2(listW, rh), AltRow);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
// The gem: the rule on or off.
|
||||
var gp = new Vector2(p.X + Px(3), p.Y);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(gp);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##en", new Vector2(Px(18), rh)) && editable)
|
||||
LootEditCommands.Simple("set_enabled", i, rule.Enabled ? "false" : "true", expect: rule.Name);
|
||||
SafeImGui.SetItemTooltip(rule.Enabled ? "On. Click to turn this rule off." : "Off. Click to turn this rule on.");
|
||||
GemPicture(dl, new Vector2(gp.X + Px(2), p.Y + (rh - Px(13)) * 0.5f), rule.Enabled);
|
||||
// The rest of the row selects it.
|
||||
var rp = new Vector2(p.X + Px(22), p.Y);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(rp);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##row", new Vector2(listW - Px(22), rh))) _selected = i;
|
||||
if (ImGuiNET.ImGui.IsItemHovered() && !sel) dl.AddRectFilled(rp, p + new Vector2(listW, rh), Hover);
|
||||
SafeImGui.SetItemTooltip(rule.Name + "\n" + rule.Summary + (rule.Conditions > 0 ? $"\n{rule.Conditions} conditions" : ""));
|
||||
ImGuiNET.ImGui.PopID();
|
||||
float x = rp.X;
|
||||
uint badge = RynthTheme.Argb(LootEditVocabulary.BadgeArgb(rule.Action));
|
||||
dl.AddRectFilled(new Vector2(x, p.Y + Px(2)), new Vector2(x + badgeW - Px(4), p.Y + rh - Px(2)), badge, Px(2));
|
||||
TextClip(dl, x + Px(4), p.Y, rh, x + badgeW - Px(6), LootEditVocabulary.Badge(rule.Action, rule.KeepCount), White, 9);
|
||||
x += badgeW;
|
||||
TextClip(dl, x, p.Y, rh, x + nameW - Px(4), rule.Name, rule.Enabled ? White : Faint, 10);
|
||||
x += nameW;
|
||||
TextClip(dl, x, p.Y, rh, p.X + listW - Px(4), rule.Summary, Dim, 10);
|
||||
}
|
||||
if (count == 0)
|
||||
TextMid(dl, o.X + Px(6), y, rh, s == null ? (view?.Unavailable == true ? "This RynthAi has no loot editor." : "Waiting for RynthAi…")
|
||||
: "No rules. Add one, then write it in the Loot Editor.", Dim, 10);
|
||||
_first = Scrollbar("##cl_sb", new Vector2(o.X + listW, y), listH, count, VisibleRows, _first, ref _grab);
|
||||
if (_selected >= count) _selected = count - 1;
|
||||
y += listH + Px(4);
|
||||
|
||||
// Rule tools: up, down, duplicate, delete, add.
|
||||
{
|
||||
bool has = editable && _selected >= 0 && _selected < count;
|
||||
string name = has ? s!.Rules[_selected].Name : "";
|
||||
float x = o.X;
|
||||
if (Plate("##cl_up", "Up", new Vector2(x, y)) && has && _selected > 0)
|
||||
{ LootEditCommands.Simple("move", _selected, to: _selected - 1, expect: name); _selected--; }
|
||||
SafeImGui.SetItemTooltip("Move the selected rule up (rules are checked top to bottom)");
|
||||
x += Px(50);
|
||||
if (Plate("##cl_down", "Down", new Vector2(x, y)) && has && _selected < count - 1)
|
||||
{ LootEditCommands.Simple("move", _selected, to: _selected + 1, expect: name); _selected++; }
|
||||
SafeImGui.SetItemTooltip("Move the selected rule down");
|
||||
x += Px(50);
|
||||
if (Plate("##cl_dup", "Copy", new Vector2(x, y)) && has)
|
||||
LootEditCommands.Simple("duplicate", _selected, expect: name);
|
||||
SafeImGui.SetItemTooltip("Duplicate the selected rule");
|
||||
x += Px(50);
|
||||
if (Plate("##cl_del", "Delete", new Vector2(x, y)) && has)
|
||||
{ LootEditCommands.Simple("delete", _selected, expect: name); _selected = -1; }
|
||||
SafeImGui.SetItemTooltip("Delete the selected rule");
|
||||
x += Px(50);
|
||||
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)");
|
||||
y += Px(21);
|
||||
}
|
||||
|
||||
// Save / reload, and RynthAi's last message.
|
||||
{
|
||||
float bw = Px(96);
|
||||
bool dirty = s != null && s.Dirty;
|
||||
if (Button("##cl_save", "Save", new Vector2(o.X, y), bw, ButtonColor.Blue, editable && dirty))
|
||||
LootEditCommands.Simple("save");
|
||||
SafeImGui.SetItemTooltip(dirty ? "Save the changes to " + s!.FileName : "Nothing to save");
|
||||
if (Button("##cl_reload", "Reload", new Vector2(o.X + bw + Px(6), y), bw, ButtonColor.Red, s != null))
|
||||
{ _selected = -1; LootEditCommands.Simple("reload", force: true); }
|
||||
SafeImGui.SetItemTooltip(dirty ? "Throw away the unsaved changes and read the file again" : "Read the file again");
|
||||
if (s != null && s.Message.Length > 0)
|
||||
TextClip(dl, o.X + 2 * bw + Px(18), y, Px(32), o.X + w, s.Message, s.MessageOk ? Green : Down, 10);
|
||||
y += Px(32);
|
||||
}
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
private string[] Files(LootEditStateDto? s)
|
||||
{
|
||||
if (s == null) return Array.Empty<string>();
|
||||
if (!ReferenceEquals(s, _filesFor))
|
||||
{
|
||||
_filesFor = s;
|
||||
_files = new string[s.Files.Count];
|
||||
for (int i = 0; i < s.Files.Count; i++)
|
||||
_files[i] = s.Files[i].Display + (SamePath(s.Files[i].Path, s.InUsePath) ? " (in use)" : "");
|
||||
}
|
||||
return _files;
|
||||
}
|
||||
|
||||
private static bool SamePath(string a, string b) => a.Length > 0 && string.Equals(a, b, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
272
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicMainTab.cs
Normal file
272
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicMainTab.cs
Normal file
|
|
@ -0,0 +1,272 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicMainTab.cs
|
||||
// The Classic look's Main tab: everything on VTank's options page, in our own
|
||||
// groups and words, plus what the bot is doing. Top to bottom:
|
||||
// Macro Stop/Start, Rebuff all, Cancel; what the bot is doing and
|
||||
// the meta state; the settings profile picker
|
||||
// Systems combat, buffing, navigation, looting, meta: a gem each
|
||||
// (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,
|
||||
// manage fellowship
|
||||
// Magic and pets dispel items / self, M. charges when off, summon pets,
|
||||
// pet range, pet min monsters
|
||||
// Recharge health, stamina and mana meters with the heal / restam /
|
||||
// get-mana trigger marked (drag it) and the top-off level
|
||||
// Settings are the Settings panel's rows (ClassicSettings), saved the same
|
||||
// way; the macro, subsystems, rebuff and profile go through RynthAiCommands.
|
||||
// AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicMainTab : IClassicTab
|
||||
{
|
||||
public string Name => "Main";
|
||||
|
||||
private readonly ClassicSettings _settings = new();
|
||||
|
||||
private readonly ClassicSettings.NumberRow[] _ranges =
|
||||
{
|
||||
new("Monster Range", "Monster range"),
|
||||
new("Ring Range", "Ring range"),
|
||||
new("Approach Range", "Approach"),
|
||||
new(SettingsSchema.NavPointReachLabel, "Follow/nav min"),
|
||||
};
|
||||
|
||||
private static readonly (string Schema, string Label)[] BehaviorLeft =
|
||||
{
|
||||
("Enable Autostack", "Autostack"), ("Auto Cram", "Autocram"),
|
||||
("Peace Mode When Idle", "Peace mode when idle"), ("Rebuff When Idle", "Rebuff when idle"),
|
||||
};
|
||||
|
||||
private static readonly (string Schema, string Label)[] BehaviorRight =
|
||||
{
|
||||
("Boost Nav Priority", "Navigation first"), ("Boost Loot Priority", "Looting first"),
|
||||
("Loot Only Rare Corpses", "Rare corpses only"), ("Auto Fellowship Management", "Manage fellowship"),
|
||||
};
|
||||
|
||||
private static readonly (string Schema, string Label)[] MagicLeft =
|
||||
{
|
||||
("Use Dispel Items", "Dispel items"), ("Cast Dispel Self", "Dispel self"), ("M. Charges When Off", "M. charges when off"),
|
||||
};
|
||||
|
||||
private readonly ClassicSettings.NumberRow _petRange = new("Pet Range", "Pet range");
|
||||
private readonly ClassicSettings.NumberRow _petMin = new("Pet Min Monsters", "Min. monsters");
|
||||
|
||||
// Recharge: (trigger row, top-off row, label).
|
||||
private static readonly (string At, string Top, string Label, Vital Vital)[] Recharge =
|
||||
{
|
||||
("Heal At", "Top HP", "Heal at", Vital.Health),
|
||||
("Re-stam At", "Top Stam", "Stam at", Vital.Stamina),
|
||||
("Get Mana At", "Top Mana", "Mana at", Vital.Mana),
|
||||
};
|
||||
|
||||
// Schema rows, looked up once (SettingsSchema.Find isn't for per-frame use).
|
||||
private readonly SettingRow?[] _behaviorLeft = Rows(BehaviorLeft), _behaviorRight = Rows(BehaviorRight), _magicLeft = Rows(MagicLeft);
|
||||
private readonly SettingRow? _summonPets = ClassicSettings.Row("Summon Pets");
|
||||
private readonly SettingRow?[] _rechargeAt = Array.ConvertAll(Recharge, r => ClassicSettings.Row(r.At));
|
||||
private readonly SettingRow?[] _rechargeTop = Array.ConvertAll(Recharge, r => ClassicSettings.Row(r.Top));
|
||||
|
||||
private static SettingRow?[] Rows((string Schema, string Label)[] list) => Array.ConvertAll(list, x => ClassicSettings.Row(x.Schema));
|
||||
|
||||
private int _dragging = -1;
|
||||
private double _dragValue;
|
||||
|
||||
public void Shown() => _settings.Subscribe();
|
||||
|
||||
public void Hidden() => _settings.Unsubscribe();
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
_settings.Sync();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
RynthAiSnapshot raw = ctx.Raw;
|
||||
RynthAiView? view = ctx.View;
|
||||
float y = o.Y;
|
||||
bool busy = false;
|
||||
|
||||
// ── Macro ──
|
||||
Header(dl, new Vector2(o.X, y), w, "Macro", view?.BotActivityText ?? "Idle");
|
||||
y += Px(23);
|
||||
{
|
||||
float runW = Px(118), rebuffW = Px(104);
|
||||
bool run = raw.MacroRunning;
|
||||
if (Button("##cm_run", run ? "Stop macro" : "Start macro", new Vector2(o.X, y), runW, run ? ButtonColor.Red : ButtonColor.Blue))
|
||||
RynthAiCommands.ToggleMacro();
|
||||
SafeImGui.SetItemTooltip(run ? "Macro running. Click to stop it." : "Macro stopped. Click to start it.");
|
||||
float x = o.X + runW + Px(6);
|
||||
if (Button("##cm_rebuff", "Rebuff all", new Vector2(x, y), rebuffW, ButtonColor.Blue))
|
||||
RynthAiCommands.ForceRebuff();
|
||||
SafeImGui.SetItemTooltip("Force rebuff: recast every buff now.");
|
||||
x += rebuffW + Px(6);
|
||||
if (Plate("##cm_cancel", "Cancel", new Vector2(x, y + Px(7.5f))))
|
||||
RynthAiCommands.CancelForceRebuff();
|
||||
SafeImGui.SetItemTooltip("Cancel a force rebuff");
|
||||
x += Px(52);
|
||||
float lineH = Px(14);
|
||||
Print(dl, new Vector2(x, y + Px(2)), "Doing", Dim, 10);
|
||||
TextClip(dl, x + Measure("Doing ", 10).X, y + Px(2) - Px(1), lineH, o.X + w, view?.BotActivityText ?? "Idle",
|
||||
run ? Red : Dim, 10);
|
||||
Print(dl, new Vector2(x, y + Px(17)), "Meta", Dim, 10);
|
||||
TextClip(dl, x + Measure("Meta ", 10).X, y + Px(17) - Px(1), lineH, o.X + w, view?.MetaStateText ?? "Default", Gold, 10);
|
||||
}
|
||||
y += Px(36);
|
||||
{
|
||||
float rowH = Px(22), labelW = Px(52);
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Profile", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(6), y + (rowH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(6);
|
||||
if (Dropdown("##cm_profile", view?.ProfileText ?? raw.SelectedProfile, ddPos, ddW, ctx.Popup.IsOpen))
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, raw.Profiles, raw.SelectedProfileIdx,
|
||||
i => RynthAiCommands.SelectProfile(3, i));
|
||||
SafeImGui.SetItemTooltip("Settings profile");
|
||||
y += rowH;
|
||||
}
|
||||
|
||||
// ── Systems ──
|
||||
y += Px(10);
|
||||
Header(dl, new Vector2(o.X, y), w, "Systems");
|
||||
y += Px(23);
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
bool on = ClassicDashboard.SubsystemOn(raw, i);
|
||||
var pos = new Vector2(o.X, y);
|
||||
if (Gem("##cm_sys" + i, ClassicDashboard.SubsystemNames[i], pos, w, on))
|
||||
RynthAiCommands.SetSubsystemEnabled(i, !on);
|
||||
SafeImGui.SetItemTooltip(ClassicDashboard.SubsystemNames[i] + (on ? " on. Click to turn it off." : " off. Click to turn it on."));
|
||||
TextRight(dl, o.X + w - Px(3), y, Px(18), on ? SystemLine(i, view, raw) : "off", on ? Amber : Faint, 10);
|
||||
y += Px(18);
|
||||
}
|
||||
|
||||
if (_settings.Data == null)
|
||||
{
|
||||
y += Px(10);
|
||||
TextMid(dl, o.X + Px(3), y, Px(20), UiSources.Settings.Current == null ? "Waiting for RynthAi…" : "Loading…", Dim);
|
||||
return y + Px(20) - o.Y;
|
||||
}
|
||||
|
||||
// ── Ranges ──
|
||||
y += Px(10);
|
||||
Header(dl, new Vector2(o.X, y), w, "Ranges");
|
||||
y += Px(23);
|
||||
float colW = (w - Px(8)) / 2;
|
||||
for (int i = 0; i < _ranges.Length; i++)
|
||||
{
|
||||
var pos = new Vector2(o.X + (i % 2) * (colW + Px(8)), y + (i / 2) * Px(20));
|
||||
busy |= _settings.DrawNumber(_ranges[i], pos, colW);
|
||||
}
|
||||
y += Px(40);
|
||||
|
||||
// ── Behavior ──
|
||||
y += Px(10);
|
||||
Header(dl, new Vector2(o.X, y), w, "Behavior");
|
||||
y += Px(23);
|
||||
for (int i = 0; i < BehaviorLeft.Length; i++)
|
||||
{
|
||||
_settings.DrawGem(_behaviorLeft[i], BehaviorLeft[i].Label, new Vector2(o.X, y + i * Px(18)), colW);
|
||||
_settings.DrawGem(_behaviorRight[i], BehaviorRight[i].Label, new Vector2(o.X + colW + Px(8), y + i * Px(18)), colW);
|
||||
}
|
||||
y += Px(18) * BehaviorLeft.Length;
|
||||
|
||||
// ── Magic and pets ──
|
||||
y += Px(10);
|
||||
Header(dl, new Vector2(o.X, y), w, "Magic and pets");
|
||||
y += Px(23);
|
||||
for (int i = 0; i < MagicLeft.Length; i++)
|
||||
_settings.DrawGem(_magicLeft[i], MagicLeft[i].Label, new Vector2(o.X, y + i * Px(19)), colW, 19);
|
||||
float rx = o.X + colW + Px(8);
|
||||
_settings.DrawGem(_summonPets, "Summon pets", new Vector2(rx, y), colW, 19);
|
||||
busy |= _settings.DrawNumber(_petRange, new Vector2(rx, y + Px(19)), colW, 32, 19);
|
||||
busy |= _settings.DrawNumber(_petMin, new Vector2(rx, y + Px(38)), colW, 32, 19);
|
||||
y += Px(19) * 3;
|
||||
|
||||
// ── Recharge ──
|
||||
y += Px(10);
|
||||
Header(dl, new Vector2(o.X, y), w, "Recharge", "drag a bar to move its trigger");
|
||||
y += Px(23);
|
||||
VitalView[] vitals = { view?.Health ?? default, view?.Stamina ?? default, view?.Mana ?? default };
|
||||
for (int i = 0; i < Recharge.Length; i++)
|
||||
{
|
||||
busy |= RechargeRow(i, vitals[i], new Vector2(o.X, y), w);
|
||||
y += Px(25);
|
||||
}
|
||||
|
||||
// ── More ──
|
||||
y += Px(6);
|
||||
if (Plate("##cm_more", "More", new Vector2(o.X + w - Px(46), y)))
|
||||
ctx.OpenTab(7);
|
||||
SafeImGui.SetItemTooltip("Every setting, in the Tuning tab");
|
||||
TextMid(dl, o.X + Px(3), y, Px(17), "Every other setting is in Tuning.", Faint, 10);
|
||||
y += Px(17);
|
||||
|
||||
_settings.Busy = busy;
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
/// <summary>A system's live line: what it's working on, from the dashboard snapshot.</summary>
|
||||
private static string SystemLine(int i, RynthAiView? view, RynthAiSnapshot raw) => i switch
|
||||
{
|
||||
0 => raw.CurrentTargetId != 0 ? (view?.TargetHeadline ?? raw.TargetLabel) + " · " + (int)MathF.Round(Math.Clamp(raw.TargetHealthPercent, 0, 1) * 100) + "%" : "no target",
|
||||
1 => "profile " + (view?.BuffText ?? "Built-in"),
|
||||
2 => view?.NavText is { } nav && nav != "None" ? nav : "no route loaded",
|
||||
3 => view?.LootText is { } loot && loot != "None" ? loot : "no loot profile",
|
||||
_ => "state " + (view?.MetaStateText ?? "Default"),
|
||||
};
|
||||
|
||||
/// <summary>One recharge row: heart, meter with the trigger (drag) and top-off marks, "Heal at 60%". True while dragged.</summary>
|
||||
private bool RechargeRow(int i, VitalView v, Vector2 o, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
var (atLabel, topLabel, label, vital) = Recharge[i];
|
||||
SettingRow? at = _rechargeAt[i], top = _rechargeTop[i];
|
||||
float rowH = Px(25), labW = Px(70);
|
||||
Heart(dl, o, vital);
|
||||
float mx = o.X + Px(31), mw = w - Px(31) - labW - Px(6), my = o.Y + (rowH - Px(16)) * 0.5f;
|
||||
Meter(dl, new Vector2(mx, my), mw, vital, v.Fraction);
|
||||
TextMid(dl, mx + mw * 0.5f - Measure("100%", 10).X * 0.5f, my, Px(16), (int)MathF.Round(v.Fraction * 100) + "%", White, 10);
|
||||
|
||||
bool dragging = false;
|
||||
double atValue = at != null ? _settings.Get(at) : 0;
|
||||
if (at != null)
|
||||
{
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(mx, my - Px(3)));
|
||||
ImGuiNET.ImGui.InvisibleButton("##cm_trig" + i, new Vector2(mw, Px(22)));
|
||||
if (ImGuiNET.ImGui.IsItemActive())
|
||||
{
|
||||
float f = Math.Clamp((ImGuiNET.ImGui.GetMousePos().X - mx) / Math.Max(1, mw), 0f, 1f);
|
||||
_dragValue = Math.Clamp(Math.Round(f * 100 / 5) * 5, Math.Max(at.Min, 5), Math.Min(at.Max, 95));
|
||||
_dragging = i;
|
||||
dragging = true;
|
||||
atValue = _dragValue;
|
||||
}
|
||||
if (ImGuiNET.ImGui.IsItemDeactivated() && _dragging == i)
|
||||
{
|
||||
_dragging = -1;
|
||||
if (_dragValue != _settings.Get(at)) _settings.Set(at, _dragValue);
|
||||
atValue = _dragValue;
|
||||
}
|
||||
SafeImGui.SetItemTooltip(label + " " + (int)atValue + "%: drag along the bar to move it.");
|
||||
float tx = mx + mw * (float)(atValue / 100);
|
||||
dl.AddRectFilled(new Vector2(tx - Px(1), my - Px(3)), new Vector2(tx + Px(1), my + Px(19)), Gold);
|
||||
dl.AddRect(new Vector2(tx - Px(2), my - Px(3)), new Vector2(tx + Px(2), my + Px(19)), Black);
|
||||
}
|
||||
if (top != null)
|
||||
{
|
||||
float tx = mx + mw * (float)(_settings.Get(top) / 100);
|
||||
dl.AddRectFilled(new Vector2(tx - Px(0.75f), my - Px(1)), new Vector2(tx + Px(0.75f), my + Px(17)), FaceKit.Faded(White));
|
||||
}
|
||||
float lx = o.X + w - labW;
|
||||
TextMid(dl, lx, o.Y, rowH, label, Text, 10);
|
||||
TextMid(dl, lx + Measure(label + " ", 10).X, o.Y, rowH, (int)atValue + "%", Gold, 10);
|
||||
return dragging;
|
||||
}
|
||||
}
|
||||
164
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicMetaTab.cs
Normal file
164
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicMetaTab.cs
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicMetaTab.cs
|
||||
// The Classic look's Meta tab: RynthAi's meta (UiSources.Meta, the Meta
|
||||
// panel's source) in the retail style. Meta on/off, the meta file (loads it),
|
||||
// the current state (sets it), and the loaded meta's rules grouped by state
|
||||
// (the current state's group in gold): each rule's condition and action,
|
||||
// dimmed when the rule is off. Writing rules (the condition and action
|
||||
// editors, the source view, the Meta Manager) is the Meta panel's: Edit opens
|
||||
// it. Commands are the Meta panel's (MetaCommands). AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicMetaTab : IClassicTab
|
||||
{
|
||||
public string Name => "Meta";
|
||||
|
||||
private const int VisibleRows = 17;
|
||||
|
||||
// The list rows: a state heading (Rule < 0) or a rule (its index).
|
||||
private readonly struct ListRow
|
||||
{
|
||||
public readonly string State;
|
||||
public readonly int Rule;
|
||||
public readonly string Cond, Act;
|
||||
public ListRow(string state, int rule, string cond, string act) { State = state; Rule = rule; Cond = cond; Act = act; }
|
||||
}
|
||||
|
||||
private MetaPayload? _builtFor;
|
||||
private readonly List<ListRow> _rows = new();
|
||||
private string[] _fileNames = Array.Empty<string>();
|
||||
private string[] _states = Array.Empty<string>();
|
||||
private int _first;
|
||||
private float _grab;
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
UiSources.Meta.Subscribe();
|
||||
UiSources.Meta.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Hidden() => UiSources.Meta.Unsubscribe();
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
MetaPayload? d = UiSources.Meta.Current?.Value;
|
||||
if (d != null && !ReferenceEquals(d, _builtFor)) Build(d);
|
||||
float y = o.Y;
|
||||
|
||||
string right = d == null ? "waiting for RynthAi" : "state " + d.CurrentState
|
||||
+ (d.Snapshot is { } snap && snap.SecondsInState > 0 ? $" · {(int)snap.SecondsInState}s" : "");
|
||||
Header(dl, new Vector2(o.X, y), w, "Meta", right);
|
||||
y += Px(23);
|
||||
|
||||
// On / off.
|
||||
{
|
||||
bool on = d?.EnableMeta ?? ctx.Raw.MetaEnabled;
|
||||
if (Gem("##cme_on", "Meta on", new Vector2(o.X, y), w / 2, on) && d != null)
|
||||
MetaCommands.Simple("set_enabled", value: on ? "false" : "true");
|
||||
SafeImGui.SetItemTooltip(on ? "The meta's rules run. Click to pause them." : "The meta's rules are paused. Click to run them.");
|
||||
y += Px(20);
|
||||
}
|
||||
|
||||
// File and state.
|
||||
float rowH = Px(22), labelW = Px(52);
|
||||
{
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Meta", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(6), y + (rowH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(6) - Px(52);
|
||||
int cur = d != null ? MetaVocabulary.CurrentFileIndex(d) : -1;
|
||||
if (Dropdown("##cme_file", d != null ? MetaVocabulary.CurrentFileDisplay(d) : "None", ddPos, ddW, ctx.Popup.IsOpen) && d != null)
|
||||
{
|
||||
MetaPayload data = d;
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, _fileNames, cur, i =>
|
||||
{
|
||||
if (i < data.Files.Count) MetaCommands.Simple("load_file", path: data.Files[i].Path);
|
||||
});
|
||||
}
|
||||
SafeImGui.SetItemTooltip("Load a meta");
|
||||
if (Plate("##cme_edit", "Edit", new Vector2(o.X + w - Px(46), y + (rowH - Px(17)) * 0.5f)))
|
||||
PanelRouter.Toggle("Meta");
|
||||
SafeImGui.SetItemTooltip("The Meta panel: write and edit rules, the source view, the Meta Manager");
|
||||
y += rowH;
|
||||
}
|
||||
{
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "State", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(6), y + (rowH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(6);
|
||||
string state = d?.CurrentState ?? ctx.Raw.CurrentState;
|
||||
if (Dropdown("##cme_state", state.Length > 0 ? state : "Default", ddPos, ddW, ctx.Popup.IsOpen) && d != null)
|
||||
{
|
||||
string[] states = _states;
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, states, Array.IndexOf(states, state),
|
||||
i => MetaCommands.Simple("set_state", value: states[i]));
|
||||
}
|
||||
SafeImGui.SetItemTooltip("Set the meta's state now");
|
||||
y += rowH;
|
||||
}
|
||||
|
||||
// Rules by state.
|
||||
y += Px(8);
|
||||
Header(dl, new Vector2(o.X, y), w, "Rules", d == null ? null : d.Rules.Count + " rules · " + Math.Max(0, _states.Length) + " states");
|
||||
y += Px(23);
|
||||
float listW = w - Px(16), rh = Px(17), listH = rh * VisibleRows;
|
||||
float condW = (listW - Px(26)) * 0.5f;
|
||||
var listMin = new Vector2(o.X, y);
|
||||
dl.AddRectFilled(listMin, listMin + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
_first = Wheel(listMin, listMin + new Vector2(w, listH), _first, _rows.Count, VisibleRows);
|
||||
string current = d?.CurrentState ?? "";
|
||||
for (int r = 0; r < VisibleRows && _first + r < _rows.Count; r++)
|
||||
{
|
||||
ListRow row = _rows[_first + r];
|
||||
var p = new Vector2(o.X, y + r * rh);
|
||||
if (row.Rule < 0)
|
||||
{
|
||||
bool isCur = row.State.Equals(current, StringComparison.OrdinalIgnoreCase);
|
||||
dl.AddRectFilled(p, p + new Vector2(listW, rh), RynthTheme.Argb(isCur ? 0x40F0C850u : 0x22FFFFFFu));
|
||||
TextClip(dl, p.X + Px(4), p.Y, rh, p.X + listW - Px(4), row.State + (isCur ? " (now)" : ""), isCur ? Gold : GoldDim, 10, bold: true);
|
||||
continue;
|
||||
}
|
||||
MetaRuleDto rule = d!.Rules[row.Rule];
|
||||
bool on = rule.Enabled;
|
||||
GemPicture(dl, new Vector2(p.X + Px(6), p.Y + (rh - Px(13)) * 0.5f), on);
|
||||
float cx = p.X + Px(24);
|
||||
TextClip(dl, cx, p.Y, rh, cx + condW - Px(4), row.Cond, on ? White : Faint, 10);
|
||||
TextClip(dl, cx + condW, p.Y, rh, p.X + listW - Px(4), row.Act, on ? Amber : Faint, 10);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(_first + r);
|
||||
ImGuiNET.ImGui.InvisibleButton("##rule", new Vector2(listW, rh));
|
||||
SafeImGui.SetItemTooltip((rule.Name.Length > 0 ? rule.Name + "\n" : "") + "When: " + row.Cond + "\nDo: " + row.Act
|
||||
+ (on ? "" : "\n(off)") + "\nEdit rules on the Meta panel.");
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
if (_rows.Count == 0)
|
||||
TextMid(dl, o.X + Px(6), y, rh, d == null ? "Waiting for RynthAi…" : "No rules. Load a meta, or write one on the Meta panel.", Dim, 10);
|
||||
_first = Scrollbar("##cme_sb", new Vector2(o.X + listW, y), listH, _rows.Count, VisibleRows, _first, ref _grab);
|
||||
y += listH;
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
private void Build(MetaPayload d)
|
||||
{
|
||||
_builtFor = d;
|
||||
_rows.Clear();
|
||||
foreach (var (state, rules) in MetaVocabulary.GroupByState(d.Rules))
|
||||
{
|
||||
_rows.Add(new ListRow(state, -1, "", ""));
|
||||
foreach (int i in rules)
|
||||
_rows.Add(new ListRow(state, i, MetaVocabulary.RowConditionText(d.Rules[i]), MetaVocabulary.RowActionText(d.Rules[i])));
|
||||
}
|
||||
_fileNames = new string[d.Files.Count];
|
||||
for (int i = 0; i < d.Files.Count; i++) _fileNames[i] = d.Files[i].Display;
|
||||
_states = MetaVocabulary.StatePicks(d);
|
||||
}
|
||||
}
|
||||
264
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicMonstersTab.cs
Normal file
264
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicMonstersTab.cs
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicMonstersTab.cs
|
||||
// The Classic look's Monsters tab: RynthAi's monster rules (UiSources.
|
||||
// MonsterRules, the Damage panel's source) in the retail style. The list
|
||||
// (Default first): monster, weapon, damage, priority, debuff marks; a click
|
||||
// selects. The selected rule: what RynthAi has learned about it (max health,
|
||||
// armour, weakest damage), its weapon, damage and priority, the six debuffs
|
||||
// and the six spell shapes as gems. Add target makes a rule for the monster
|
||||
// selected in game; Remove drops a rule (it follows Default again). Edits go
|
||||
// through DamageCommands.EditRule, which re-reads the latest rules on the
|
||||
// pump thread first, like the Damage panel; the rest (off hand, pet, kite,
|
||||
// attack power, match expressions) is on the Damage panel (the plate).
|
||||
// AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using RynthCore.Engine.UI.Panels;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicMonstersTab : IClassicTab
|
||||
{
|
||||
public string Name => "Monsters";
|
||||
|
||||
private const int VisibleRows = 10;
|
||||
|
||||
private string _selName = "Default";
|
||||
private int _first;
|
||||
private float _grab;
|
||||
private readonly byte[] _priority = new byte[8];
|
||||
private int _priorityShown = int.MinValue;
|
||||
private string _priorityFor = string.Empty;
|
||||
private bool _typingPriority;
|
||||
|
||||
// Weapon picker items, rebuilt when the rules snapshot changes.
|
||||
private MonsterRulesSnapshot? _itemsFor;
|
||||
private string[] _weaponNames = Array.Empty<string>();
|
||||
private int[] _weaponIds = Array.Empty<int>();
|
||||
private readonly Dictionary<int, string> _weaponById = new();
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
UiSources.MonsterRules.Subscribe();
|
||||
UiSources.MonsterRules.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Hidden() => UiSources.MonsterRules.Unsubscribe();
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
MonsterRulesSnapshot? snap = UiSources.MonsterRules.Current?.Value;
|
||||
MonstersPanel.Payload? data = snap?.Parsed;
|
||||
List<MonstersPanel.Rule> rules = data?.Rules ?? new List<MonstersPanel.Rule>();
|
||||
if (snap != null && !ReferenceEquals(snap, _itemsFor)) BuildWeapons(snap);
|
||||
float y = o.Y;
|
||||
|
||||
Header(dl, new Vector2(o.X, y), w, "Monster rules",
|
||||
data == null ? "waiting for RynthAi" : rules.Count + " rules · Default catches the rest");
|
||||
y += Px(23);
|
||||
|
||||
// Columns and the list.
|
||||
float listW = w - Px(16);
|
||||
float cWeapon = Px(118), cDmg = Px(56), cPri = Px(26), cMarks = Px(40);
|
||||
float cName = listW - cWeapon - cDmg - cPri - cMarks - Px(8);
|
||||
{
|
||||
float hh = Px(14);
|
||||
float x = o.X + Px(4);
|
||||
TextMid(dl, x, y, hh, "Monster", Dim, 10); x += cName;
|
||||
TextMid(dl, x, y, hh, "Weapon", Dim, 10); x += cWeapon;
|
||||
TextMid(dl, x, y, hh, "Damage", Dim, 10); x += cDmg;
|
||||
TextMid(dl, x, y, hh, "Pri", Dim, 10); x += cPri;
|
||||
TextMid(dl, x, y, hh, "Debuffs", Dim, 10);
|
||||
y += hh;
|
||||
}
|
||||
float rowH = Px(17), listH = rowH * VisibleRows;
|
||||
var listMin = new Vector2(o.X, y);
|
||||
dl.AddRectFilled(listMin, listMin + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
_first = Wheel(listMin, listMin + new Vector2(w, listH), _first, rules.Count, VisibleRows);
|
||||
MonstersPanel.Rule? sel = null;
|
||||
foreach (MonstersPanel.Rule r in rules)
|
||||
if (r.Name.Equals(_selName, StringComparison.OrdinalIgnoreCase)) { sel = r; break; }
|
||||
if (sel == null && rules.Count > 0) { sel = rules[0]; _selName = sel.Name; }
|
||||
for (int row = 0; row < VisibleRows && _first + row < rules.Count; row++)
|
||||
{
|
||||
int i = _first + row;
|
||||
MonstersPanel.Rule r = rules[i];
|
||||
var p = new Vector2(o.X, y + row * rowH);
|
||||
bool isSel = ReferenceEquals(r, sel);
|
||||
if (isSel) RowSelected(dl, p, p + new Vector2(listW, rowH));
|
||||
else if ((i & 1) == 1) dl.AddRectFilled(p, p + new Vector2(listW, rowH), AltRow);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##rule", new Vector2(listW, rowH))) { _selName = r.Name; _priorityShown = int.MinValue; }
|
||||
if (ImGuiNET.ImGui.IsItemHovered() && !isSel) dl.AddRectFilled(p, p + new Vector2(listW, rowH), Hover);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
float x = p.X + Px(4);
|
||||
bool isDefault = r.Name.Equals("Default", StringComparison.OrdinalIgnoreCase);
|
||||
TextClip(dl, x, p.Y, rowH, x + cName - Px(4), r.Name, isDefault ? Gold : White, 10); x += cName;
|
||||
TextClip(dl, x, p.Y, rowH, x + cWeapon - Px(4), WeaponName(r.WeaponId), Text, 10); x += cWeapon;
|
||||
TextClip(dl, x, p.Y, rowH, x + cDmg - Px(4), r.DamageType, Amber, 10); x += cDmg;
|
||||
TextClip(dl, x, p.Y, rowH, x + cPri - Px(4), r.Priority.ToString(CultureInfo.InvariantCulture), Text, 10); x += cPri;
|
||||
TextClip(dl, x, p.Y, rowH, x + cMarks, DamageCommands.DebuffMarks(r), Dim, 10);
|
||||
}
|
||||
if (rules.Count == 0)
|
||||
TextMid(dl, o.X + Px(6), y, rowH, data == null ? "Waiting for RynthAi…" : "No rules.", Dim, 10);
|
||||
_first = Scrollbar("##cmo_sb", new Vector2(o.X + listW, y), listH, rules.Count, VisibleRows, _first, ref _grab);
|
||||
y += listH;
|
||||
|
||||
// The selected rule.
|
||||
if (sel != null && data != null)
|
||||
{
|
||||
y += Px(8);
|
||||
string learned = Learned(data, sel.Name);
|
||||
Header(dl, new Vector2(o.X, y), w, sel.Name, learned);
|
||||
y += Px(23);
|
||||
y = RuleEditor(ctx, sel, new Vector2(o.X, y), w);
|
||||
}
|
||||
|
||||
// Add / remove / the Damage panel.
|
||||
y += Px(6);
|
||||
{
|
||||
string target = data?.CurrentTargetName ?? string.Empty;
|
||||
float addW = Px(118), remW = Px(90);
|
||||
bool canAdd = target.Length > 0 && snap != null && !snap.HasCustomRule(target);
|
||||
if (Button("##cmo_add", "Add target", new Vector2(o.X, y), addW, ButtonColor.Blue, canAdd))
|
||||
{
|
||||
DamageCommands.AddRule(target, string.Empty);
|
||||
_selName = target;
|
||||
}
|
||||
SafeImGui.SetItemTooltip(target.Length == 0 ? "Select a monster in game to make a rule for it."
|
||||
: canAdd ? "Make a rule for " + target + " (a copy of Default)." : target + " already has a rule.");
|
||||
bool canRemove = sel != null && !sel.Name.Equals("Default", StringComparison.OrdinalIgnoreCase);
|
||||
if (Button("##cmo_remove", "Remove", new Vector2(o.X + addW + Px(6), y), remW, ButtonColor.Red, canRemove) && sel != null)
|
||||
{
|
||||
DamageCommands.ResetRule(sel.Name);
|
||||
_selName = "Default";
|
||||
}
|
||||
SafeImGui.SetItemTooltip(canRemove ? "Remove " + sel!.Name + "'s rule: it follows Default again." : "Default can't be removed.");
|
||||
var plate = new Vector2(o.X + w - Px(46), y + Px(7.5f));
|
||||
if (Plate("##cmo_damage", "More", plate))
|
||||
PanelRouter.ToggleMonsters();
|
||||
SafeImGui.SetItemTooltip("The Damage panel: off hand, pet, kite, attack power, match expressions, learned damage");
|
||||
TextClip(dl, o.X + addW + remW + Px(18), y, Px(32), plate.X - Px(6),
|
||||
target.Length > 0 ? "Target: " + target : "No target", target.Length > 0 ? Gold : Faint, 10);
|
||||
y += Px(32);
|
||||
}
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
private float RuleEditor(ClassicContext ctx, MonstersPanel.Rule sel, Vector2 o, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float y = o.Y, rowH = Px(22), labelW = Px(56);
|
||||
string name = sel.Name;
|
||||
|
||||
// Weapon.
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Weapon", Text);
|
||||
var wPos = new Vector2(o.X + labelW, y + (rowH - Px(19)) * 0.5f);
|
||||
float wW = w - labelW;
|
||||
int wIdx = Array.IndexOf(_weaponIds, sel.WeaponId);
|
||||
if (Dropdown("##cmo_weapon", WeaponName(sel.WeaponId), wPos, wW))
|
||||
{
|
||||
int[] ids = _weaponIds;
|
||||
ctx.Popup.Open(wPos + new Vector2(0, Px(19)), wW, _weaponNames, wIdx, k =>
|
||||
DamageCommands.EditRule(name, r => r.WeaponId = ids[k]));
|
||||
}
|
||||
SafeImGui.SetItemTooltip("The weapon or caster RynthAi fights this monster with (the Gear tab's weapons).");
|
||||
y += rowH;
|
||||
|
||||
// Damage | priority.
|
||||
TextMid(dl, o.X + Px(3), y, rowH, "Damage", Text);
|
||||
float dW = Px(120);
|
||||
var dPos = new Vector2(o.X + labelW, y + (rowH - Px(19)) * 0.5f);
|
||||
int dIdx = Math.Max(0, Array.IndexOf(DamageCommands.DamageTypes, sel.DamageType));
|
||||
if (Dropdown("##cmo_dmg", DamageCommands.DamageTypes[dIdx], dPos, dW))
|
||||
ctx.Popup.Open(dPos + new Vector2(0, Px(19)), dW, DamageCommands.DamageTypes, dIdx, k =>
|
||||
DamageCommands.EditRule(name, r => r.DamageType = DamageCommands.DamageTypes[k]));
|
||||
SafeImGui.SetItemTooltip("Auto: picked from what the monster is weakest to.");
|
||||
float px = dPos.X + dW + Px(16);
|
||||
TextMid(dl, px, y, rowH, "Priority", Text);
|
||||
if (!_typingPriority && (_priorityShown != sel.Priority || _priorityFor != name))
|
||||
{
|
||||
WriteInt(_priority, sel.Priority);
|
||||
_priorityShown = sel.Priority;
|
||||
_priorityFor = name;
|
||||
}
|
||||
float boxW = Px(40);
|
||||
bool done = NumberBox("##cmo_pri", _priority, new Vector2(o.X + w - boxW, y + (rowH - Px(17)) * 0.5f), boxW, out bool typing);
|
||||
_typingPriority = typing;
|
||||
SafeImGui.SetItemTooltip("Higher priority monsters are attacked first.");
|
||||
if (done && ClassicSettings.TryParse(_priority, out double pv))
|
||||
{
|
||||
int v = (int)Math.Clamp(Math.Round(pv), 0, 99);
|
||||
WriteInt(_priority, v);
|
||||
if (v != sel.Priority) DamageCommands.EditRule(name, r => r.Priority = v);
|
||||
}
|
||||
y += rowH + Px(2);
|
||||
|
||||
// Debuffs and shapes: three gems a row.
|
||||
float gw = w / 3;
|
||||
y = GemGrid("Debuffs", DamageCommands.DebuffDefs, sel, name, new Vector2(o.X, y), gw);
|
||||
y = GemGrid("Spells", DamageCommands.ShapeDefs, sel, name, new Vector2(o.X, y), gw);
|
||||
return y;
|
||||
}
|
||||
|
||||
private static float GemGrid(string title, (string Field, string Label, string Tip)[] defs, MonstersPanel.Rule sel, string name, Vector2 o, float gw)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
TextMid(dl, o.X + Px(3), o.Y, Px(14), title, GoldDim, 10);
|
||||
float y = o.Y + Px(14);
|
||||
for (int i = 0; i < defs.Length; i++)
|
||||
{
|
||||
var (field, label, tip) = defs[i];
|
||||
bool on = sel.GetToggle(field);
|
||||
if (Gem("##g_" + field, label, new Vector2(o.X + (i % 3) * gw, y + (i / 3) * Px(18)), gw, on))
|
||||
DamageCommands.EditRule(name, r => DamageCommands.FlipToggle(r, field));
|
||||
SafeImGui.SetItemTooltip(tip);
|
||||
}
|
||||
return y + ((defs.Length + 2) / 3) * Px(18) + Px(2);
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────
|
||||
|
||||
private void BuildWeapons(MonsterRulesSnapshot snap)
|
||||
{
|
||||
_itemsFor = snap;
|
||||
List<MonstersPanel.ItemRef> items = snap.Parsed.Items;
|
||||
_weaponNames = new string[items.Count + 1];
|
||||
_weaponIds = new int[items.Count + 1];
|
||||
_weaponNames[0] = "None (Default's)";
|
||||
_weaponById.Clear();
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
_weaponNames[i + 1] = items[i].Name;
|
||||
_weaponIds[i + 1] = items[i].Id;
|
||||
_weaponById[items[i].Id] = items[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
// A weapon id the Gear list doesn't have (sold, traded, or listed on another character).
|
||||
private string WeaponName(int id) => id == 0 ? "—" : _weaponById.TryGetValue(id, out string? n) ? n : "not on the Gear list";
|
||||
|
||||
private static string Learned(MonstersPanel.Payload data, string name)
|
||||
{
|
||||
if (!data.Captured.TryGetValue(name, out MonstersPanel.CapturedInfo? c) || c.Samples == 0) return "nothing learned yet";
|
||||
string weak = c.WeakestType.Length > 0 ? " · weak to " + c.WeakestType.ToLowerInvariant() : "";
|
||||
return $"HP {c.MaxHealth:N0} · armor {c.ArmorLevel}{weak}";
|
||||
}
|
||||
|
||||
private static void WriteInt(byte[] buffer, int value)
|
||||
{
|
||||
string text = value.ToString(CultureInfo.InvariantCulture);
|
||||
int n = System.Text.Encoding.UTF8.GetBytes(text, 0, text.Length, buffer, 0);
|
||||
buffer[Math.Min(n, buffer.Length - 1)] = 0;
|
||||
}
|
||||
}
|
||||
220
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicRouteTab.cs
Normal file
220
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicRouteTab.cs
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicRouteTab.cs
|
||||
// The Classic look's Route tab: RynthAi's nav route (UiSources.Nav, the Nav
|
||||
// panel's source) in the retail style. The route picker loads a route; the
|
||||
// four gems set the route type; the list shows each point (kind, where, and
|
||||
// how far it is from you) with the point being walked to in gold; a click
|
||||
// selects a point, a double-click makes it the one to walk to. Add here (a
|
||||
// point, a portal or a pause, at the end or around the selected point),
|
||||
// Remove, and the overlay switches. Recalls, chat points, editing and the
|
||||
// trail tools are on the Nav panel (the "Nav panel" plate).
|
||||
// Commands are the Nav panel's (NavCommands). AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicRouteTab : IClassicTab
|
||||
{
|
||||
public string Name => "Route";
|
||||
|
||||
private const int VisibleRows = 14;
|
||||
private static readonly string[] AddKinds = { "Point", "Portal", "Pause 5 s" };
|
||||
private static readonly string[] AddWhere = { "At the end", "Above selected", "Below selected" };
|
||||
|
||||
private int _selected = -1, _first, _addKind, _addMode;
|
||||
private float _grab;
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
UiSources.Nav.Subscribe();
|
||||
UiSources.Nav.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Hidden() => UiSources.Nav.Unsubscribe();
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
NavPayload? nav = UiSources.Nav.Current?.Value;
|
||||
float y = o.Y;
|
||||
List<NavPoint> points = nav?.Points ?? new List<NavPoint>();
|
||||
int typeIdx = NavCommands.RouteIndex(nav?.RouteType ?? 0);
|
||||
|
||||
string right = nav == null ? "waiting for RynthAi"
|
||||
: points.Count == 0 ? "no points"
|
||||
: $"{points.Count} points · {NavCommands.RouteTypes[typeIdx].ToLowerInvariant()} · at {nav.ActiveNavIndex + 1}";
|
||||
Header(dl, new Vector2(o.X, y), w, "Route", right);
|
||||
y += Px(23);
|
||||
|
||||
// Route file.
|
||||
{
|
||||
float fileH = Px(22), labelW = Px(52);
|
||||
TextMid(dl, o.X + Px(3), y, fileH, "Route", Text);
|
||||
var ddPos = new Vector2(o.X + labelW + Px(6), y + (fileH - Px(19)) * 0.5f);
|
||||
float ddW = w - labelW - Px(6) - Px(52);
|
||||
string[] files = Files(nav);
|
||||
string current = nav == null || nav.ActiveNavName.Length == 0 ? "None" : nav.ActiveNavName;
|
||||
if (Dropdown("##cr_file", current, ddPos, ddW, ctx.Popup.IsOpen))
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, files, Array.IndexOf(files, current),
|
||||
i => NavCommands.Send(new NavCmd { Cmd = "loadNav", NavName = files[i] }));
|
||||
SafeImGui.SetItemTooltip("Load a route");
|
||||
if (Plate("##cr_navpanel", "Nav", new Vector2(o.X + w - Px(46), y + (fileH - Px(17)) * 0.5f)))
|
||||
PanelRouter.Toggle("Nav");
|
||||
SafeImGui.SetItemTooltip("The Nav panel: recalls, chat points, editing points, the trail tools");
|
||||
y += fileH;
|
||||
}
|
||||
|
||||
// Route type.
|
||||
{
|
||||
float gw = w / 4;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (Gem("##cr_type" + i, NavCommands.RouteTypes[i], new Vector2(o.X + i * gw, y), gw, i == typeIdx, 20) && nav != null)
|
||||
NavCommands.Send(new NavCmd { Cmd = "setRouteType", RouteType = NavCommands.RouteTypeFor(i) });
|
||||
SafeImGui.SetItemTooltip(RouteTypeTip(i));
|
||||
}
|
||||
y += Px(22);
|
||||
}
|
||||
|
||||
// Columns and the list.
|
||||
float listW = w - Px(16);
|
||||
float cn = Px(24), ck = Px(62), cd = Px(58);
|
||||
float cw = listW - cn - ck - cd - Px(8);
|
||||
{
|
||||
float hh = Px(14);
|
||||
TextMid(dl, o.X + Px(4), y, hh, "#", Dim, 10);
|
||||
TextMid(dl, o.X + Px(4) + cn, y, hh, "Kind", Dim, 10);
|
||||
TextMid(dl, o.X + Px(4) + cn + ck, y, hh, "Where", Dim, 10);
|
||||
TextRight(dl, o.X + listW - Px(4), y, hh, "Distance", Dim, 10);
|
||||
y += hh;
|
||||
}
|
||||
float rowH = Px(17), listH = rowH * VisibleRows;
|
||||
var listMin = new Vector2(o.X, y);
|
||||
dl.AddRectFilled(listMin, listMin + new Vector2(listW, listH), RynthTheme.Argb(0x8C000000));
|
||||
_first = Wheel(listMin, listMin + new Vector2(w, listH), _first, points.Count, VisibleRows);
|
||||
bool havePos = TryPlayerCoords(out double myNs, out double myEw);
|
||||
for (int r = 0; r < VisibleRows; r++)
|
||||
{
|
||||
int i = _first + r;
|
||||
var p = new Vector2(o.X, y + r * rowH);
|
||||
if (i >= points.Count) break;
|
||||
NavPoint pt = points[i];
|
||||
bool sel = i == _selected, cur = nav != null && i == nav.ActiveNavIndex;
|
||||
if (sel) RowSelected(dl, p, p + new Vector2(listW, rowH));
|
||||
else if ((i & 1) == 1) dl.AddRectFilled(p, p + new Vector2(listW, rowH), AltRow);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(p);
|
||||
ImGuiNET.ImGui.PushID(i);
|
||||
if (ImGuiNET.ImGui.InvisibleButton("##pt", new Vector2(listW, rowH))) _selected = i;
|
||||
if (ImGuiNET.ImGui.IsItemHovered() && ImGuiNET.ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
|
||||
NavCommands.Send(new NavCmd { Cmd = "setActive", Index = i });
|
||||
if (ImGuiNET.ImGui.IsItemHovered()) dl.AddRectFilled(p, p + new Vector2(listW, rowH), Hover);
|
||||
SafeImGui.SetItemTooltip(NavCommands.PointText(pt, i + 1) + "\nDouble-click: walk to this point next.");
|
||||
ImGuiNET.ImGui.PopID();
|
||||
uint col = cur ? Gold : Text;
|
||||
TextRight(dl, p.X + cn - Px(4), p.Y, rowH, (i + 1).ToString(), cur ? Gold : Dim, 10);
|
||||
TextClip(dl, p.X + Px(4) + cn, p.Y, rowH, p.X + cn + ck, pt.Type, col, 10);
|
||||
string where = pt.Desc.Length > 0 ? pt.Desc : pt.Text.Length > 0 ? pt.Text : $"{Fmt(pt.NS, 'N', 'S')}, {Fmt(pt.EW, 'E', 'W')}";
|
||||
TextClip(dl, p.X + Px(4) + cn + ck, p.Y, rowH, p.X + cn + ck + cw, where, col, 10);
|
||||
if (havePos && HasPosition(pt))
|
||||
{
|
||||
double yd = Math.Sqrt((pt.NS - myNs) * (pt.NS - myNs) + (pt.EW - myEw) * (pt.EW - myEw)) * 240.0;
|
||||
TextRight(dl, p.X + listW - Px(4), p.Y, rowH, cur && yd < 1 ? "here" : yd < 1000 ? $"{yd:0} yd" : $"{yd / 1000:0.0}k yd", col, 10);
|
||||
}
|
||||
}
|
||||
if (points.Count == 0)
|
||||
TextMid(dl, o.X + Px(6), y, rowH, nav == null ? "Waiting for RynthAi…" : "No points. Load a route, or Add here.", Dim, 10);
|
||||
_first = Scrollbar("##cr_sb", new Vector2(o.X + listW, y), listH, points.Count, VisibleRows, _first, ref _grab);
|
||||
if (_selected >= points.Count) _selected = points.Count - 1;
|
||||
y += listH + Px(6);
|
||||
|
||||
// Add here / kind / where / Remove.
|
||||
{
|
||||
float addW = Px(96), remW = Px(86);
|
||||
if (Button("##cr_add", "Add here", new Vector2(o.X, y), addW, ButtonColor.Blue, nav != null))
|
||||
Add();
|
||||
SafeImGui.SetItemTooltip("Add a " + AddKinds[_addKind].ToLowerInvariant() + " where you stand, " + AddWhere[_addMode].ToLowerInvariant() + ".");
|
||||
float ddW = (w - addW - remW - Px(18)) / 2;
|
||||
var kindPos = new Vector2(o.X + addW + Px(6), y + Px(6.5f));
|
||||
if (Dropdown("##cr_kind", AddKinds[_addKind], kindPos, ddW, false))
|
||||
ctx.Popup.Open(kindPos + new Vector2(0, Px(19)), ddW, AddKinds, _addKind, i => _addKind = i);
|
||||
var wherePos = new Vector2(kindPos.X + ddW + Px(6), kindPos.Y);
|
||||
if (Dropdown("##cr_where", AddWhere[_addMode], wherePos, ddW, false))
|
||||
ctx.Popup.Open(wherePos + new Vector2(0, Px(19)), ddW, AddWhere, _addMode, i => _addMode = i);
|
||||
if (Button("##cr_remove", "Remove", new Vector2(o.X + w - remW, y), remW, ButtonColor.Red, _selected >= 0 && _selected < points.Count))
|
||||
NavCommands.Send(new NavCmd { Cmd = "deletePoint", Index = _selected });
|
||||
SafeImGui.SetItemTooltip(_selected >= 0 ? $"Remove point {_selected + 1}" : "Select a point to remove it");
|
||||
y += Px(36);
|
||||
}
|
||||
|
||||
// Overlay switches.
|
||||
if (nav != null)
|
||||
{
|
||||
float gw = w / 3;
|
||||
if (Gem("##cr_path", "Show path", new Vector2(o.X, y), gw, nav.ShowRouteOverlay))
|
||||
NavCommands.Send(new NavCmd { Cmd = "setRouteOverlay", On = !nav.ShowRouteOverlay });
|
||||
SafeImGui.SetItemTooltip(SettingsSchema.RouteOverlayTip);
|
||||
if (Gem("##cr_trail", "Trail", new Vector2(o.X + gw, y), gw, nav.TrackBreadcrumbs))
|
||||
NavCommands.Send(new NavCmd { Cmd = "setBreadcrumbs", On = !nav.TrackBreadcrumbs });
|
||||
SafeImGui.SetItemTooltip(SettingsSchema.BreadcrumbsTip);
|
||||
if (Gem("##cr_rec", "Record", new Vector2(o.X + 2 * gw, y), gw, nav.IsRecording))
|
||||
NavCommands.Send(new NavCmd { Cmd = "setRecording", On = !nav.IsRecording });
|
||||
SafeImGui.SetItemTooltip("Add a point as you walk.");
|
||||
y += Px(18);
|
||||
}
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
private NavPayload? _filesFor;
|
||||
private string[] _files = Array.Empty<string>();
|
||||
|
||||
/// <summary>The route files as an array, rebuilt only when a new payload arrives.</summary>
|
||||
private string[] Files(NavPayload? nav)
|
||||
{
|
||||
if (nav == null) return Array.Empty<string>();
|
||||
if (!ReferenceEquals(nav, _filesFor)) { _filesFor = nav; _files = nav.NavFiles.ToArray(); }
|
||||
return _files;
|
||||
}
|
||||
|
||||
private void Add()
|
||||
{
|
||||
int at = _addMode == 0 ? -1 : _selected;
|
||||
switch (_addKind)
|
||||
{
|
||||
case 0: NavCommands.Send(new NavCmd { Cmd = "addWaypoint", AddMode = _addMode, InsertAt = at }); break;
|
||||
case 1: NavCommands.Send(new NavCmd { Cmd = "addPortal", AddMode = _addMode, InsertAt = at }); break;
|
||||
default: NavCommands.Send(new NavCmd { Cmd = "addPause", Seconds = 5, AddMode = _addMode, InsertAt = at }); break;
|
||||
}
|
||||
}
|
||||
|
||||
private static string RouteTypeTip(int i) => i switch
|
||||
{
|
||||
1 => "Circular: walk the route round and round.",
|
||||
2 => "Linear: walk to the end, then back.",
|
||||
3 => "Follow: follow a player.",
|
||||
_ => "Once: walk the route one time.",
|
||||
};
|
||||
|
||||
private static string Fmt(double v, char pos, char neg) => $"{Math.Abs(v):0.00}{(v >= 0 ? pos : neg)}";
|
||||
|
||||
private static bool HasPosition(NavPoint pt) => pt.NS != 0 || pt.EW != 0;
|
||||
|
||||
/// <summary>Your map coordinates, from the per-frame pose copy (RynthAi's NavCoordinateHelper formula).</summary>
|
||||
private static bool TryPlayerCoords(out double ns, out double ew)
|
||||
{
|
||||
ns = ew = 0;
|
||||
if (!PlayerPhysicsHooks.TryGetPlayerPoseSnapshot(out uint cell, out float x, out float y, out _, out _, out _, out _, out _)
|
||||
|| (cell >> 16) == 0) return false;
|
||||
ew = (((cell >> 24) & 0xFF) * 8.0 + x / 24.0 - 1019.5) / 10.0;
|
||||
ns = (((cell >> 16) & 0xFF) * 8.0 + y / 24.0 - 1019.5) / 10.0;
|
||||
return double.IsFinite(ns) && double.IsFinite(ew);
|
||||
}
|
||||
}
|
||||
172
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicSettings.cs
Normal file
172
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicSettings.cs
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicSettings.cs
|
||||
// The Classic tabs' copy of RynthAi's settings, kept and saved the way the
|
||||
// Settings face and the Ranges drawer do it: a private clone of
|
||||
// UiSources.Settings, a schema row's Set on the clone, SettingsCommands.Save
|
||||
// of the whole copy (RynthAi saves it to the profile). A newer fetch replaces
|
||||
// the copy unless a control is being typed in or dragged.
|
||||
//
|
||||
// Also the number-box rows (label | box) and gem rows the Main tab draws for
|
||||
// schema rows. AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicSettings
|
||||
{
|
||||
private RynthAiSettings? _data;
|
||||
private long _seenVersion = -1;
|
||||
private bool _subscribed;
|
||||
|
||||
/// <summary>A control was typed in or dragged this frame: hold the copy.</summary>
|
||||
public bool Busy;
|
||||
|
||||
public RynthAiSettings? Data => _data;
|
||||
|
||||
public void Subscribe()
|
||||
{
|
||||
if (_subscribed) return;
|
||||
_subscribed = true;
|
||||
UiSources.Settings.Subscribe();
|
||||
UiSources.Settings.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Unsubscribe()
|
||||
{
|
||||
if (!_subscribed) return;
|
||||
_subscribed = false;
|
||||
UiSources.Settings.Unsubscribe();
|
||||
}
|
||||
|
||||
/// <summary>Start of a frame: take a newer fetch unless a control is in use.</summary>
|
||||
public void Sync(bool force = false)
|
||||
{
|
||||
var snap = UiSources.Settings.Current;
|
||||
if (snap == null || snap.Version == _seenVersion || (Busy && !force)) return;
|
||||
_seenVersion = snap.Version;
|
||||
_data = snap.Value.Clone();
|
||||
}
|
||||
|
||||
/// <summary>Sets <paramref name="row"/> to <paramref name="value"/> and saves the whole copy.</summary>
|
||||
public void Set(SettingRow row, double value)
|
||||
{
|
||||
Sync(force: true);
|
||||
if (_data == null || row.Set == null) return;
|
||||
row.Set(_data, value);
|
||||
SettingsCommands.Save(_data.Clone());
|
||||
}
|
||||
|
||||
public double Get(SettingRow row) => _data != null && row.Get != null ? row.Get(_data) : 0;
|
||||
|
||||
/// <summary>A schema row by its Settings label; null when the schema doesn't have it (left out of the tab).</summary>
|
||||
public static SettingRow? Row(string label)
|
||||
{
|
||||
SettingRow? r = SettingsSchema.Find(label);
|
||||
return r?.Get != null && r.Set != null ? r : null;
|
||||
}
|
||||
|
||||
// ── A number row: label | retail number box ─────────────────────────
|
||||
|
||||
internal sealed class NumberRow
|
||||
{
|
||||
public readonly SettingRow? Setting;
|
||||
public readonly string Label;
|
||||
public readonly byte[] Buffer = new byte[24];
|
||||
public double Shown = double.NaN;
|
||||
public bool Typing;
|
||||
|
||||
public NumberRow(string schemaLabel, string label)
|
||||
{
|
||||
Setting = Row(schemaLabel);
|
||||
Label = label;
|
||||
}
|
||||
|
||||
public bool IsInt => Setting?.Kind == SettingKind.Int;
|
||||
}
|
||||
|
||||
/// <summary>Draws a number row (h retail px high); true while it's typed in.</summary>
|
||||
public bool DrawNumber(NumberRow r, Vector2 pos, float w, float boxW = 40, float h = 20)
|
||||
{
|
||||
if (r.Setting == null || _data == null) return false;
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
SettingRow s = r.Setting;
|
||||
float rh = Px(h);
|
||||
if (!s.IsVisible(_data))
|
||||
{
|
||||
// A setting this RynthAi doesn't send yet (older plugin): shown, not editable.
|
||||
TextClip(dl, pos.X + Px(3), pos.Y, rh, pos.X + w, r.Label, Faint);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
ImGuiNET.ImGui.InvisibleButton("##na_" + r.Label, new Vector2(Math.Max(1, w), rh));
|
||||
SafeImGui.SetItemTooltip(NeedsNewer);
|
||||
return false;
|
||||
}
|
||||
double value = Math.Clamp(Get(s), s.Min, s.Max);
|
||||
TextClip(dl, pos.X + Px(3), pos.Y, rh, pos.X + w - Px(boxW) - Px(6), r.Label, Text);
|
||||
if (!r.Typing && r.Shown != value) Write(r, value);
|
||||
ImGuiNET.ImGui.PushID(r.Label);
|
||||
var boxPos = new Vector2(pos.X + w - Px(boxW), pos.Y + (rh - Px(17)) * 0.5f);
|
||||
bool done = NumberBox("##n", r.Buffer, boxPos, Px(boxW), out bool active);
|
||||
r.Typing = active;
|
||||
SafeImGui.SetItemTooltip(s.Tooltip ?? r.Label);
|
||||
ImGuiNET.ImGui.PopID();
|
||||
if (done)
|
||||
{
|
||||
if (TryParse(r.Buffer, out double typed))
|
||||
{
|
||||
double v = Math.Clamp(r.IsInt ? Math.Round(typed) : typed, s.Min, s.Max);
|
||||
Set(s, v);
|
||||
Write(r, v);
|
||||
}
|
||||
else Write(r, value); // bad input reverts
|
||||
}
|
||||
return r.Typing;
|
||||
}
|
||||
|
||||
/// <summary>Draws a schema bool row as a gem (h retail px high).</summary>
|
||||
public void DrawGem(SettingRow? row, string label, Vector2 pos, float w, float h = 18)
|
||||
{
|
||||
if (row == null || _data == null) return;
|
||||
if (!row.IsVisible(_data))
|
||||
{
|
||||
// A setting this RynthAi doesn't send yet (older plugin): shown dimmed, not clickable.
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float rh = Px(h);
|
||||
GemPicture(dl, new Vector2(pos.X + Px(3), pos.Y + (rh - Px(13)) * 0.5f), false);
|
||||
TextClip(dl, pos.X + Px(22), pos.Y, rh, pos.X + w, label, Faint);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
ImGuiNET.ImGui.InvisibleButton("##na_" + label, new Vector2(Math.Max(1, w), rh));
|
||||
SafeImGui.SetItemTooltip(NeedsNewer);
|
||||
return;
|
||||
}
|
||||
bool on = Get(row) != 0;
|
||||
if (Gem("##g_" + label, label, pos, w, on, h))
|
||||
Set(row, on ? 0 : 1);
|
||||
SafeImGui.SetItemTooltip(row.Tooltip ?? label);
|
||||
}
|
||||
|
||||
private const string NeedsNewer = "This setting needs a newer RynthAi (from 2026-10-19).";
|
||||
|
||||
public static void Write(NumberRow r, double value)
|
||||
{
|
||||
string text = r.IsInt ? ((long)Math.Round(value)).ToString(CultureInfo.InvariantCulture)
|
||||
: value.ToString("G4", CultureInfo.InvariantCulture);
|
||||
int n = Encoding.UTF8.GetBytes(text, 0, text.Length, r.Buffer, 0);
|
||||
r.Buffer[Math.Min(n, r.Buffer.Length - 1)] = 0;
|
||||
r.Shown = value;
|
||||
}
|
||||
|
||||
public static bool TryParse(byte[] buffer, out double value)
|
||||
{
|
||||
int len = Array.IndexOf(buffer, (byte)0);
|
||||
if (len < 0) len = buffer.Length;
|
||||
return double.TryParse(Encoding.UTF8.GetString(buffer, 0, len), NumberStyles.Float, CultureInfo.InvariantCulture, out value);
|
||||
}
|
||||
}
|
||||
320
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicTuningTab.cs
Normal file
320
src/RynthCore.Engine/ImGui/Panels/Classic/ClassicTuningTab.cs
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/Panels/Classic/ClassicTuningTab.cs
|
||||
// The Classic look's Tuning tab: every setting of the Settings panel, one of
|
||||
// its tabs at a time (the green drop-down) or all of them filtered by a
|
||||
// search. Rows are the Settings schema's (UI/Data/SettingsData.cs) on
|
||||
// SettingsRows' copy of the settings, so a change here is the same change
|
||||
// the Settings panel makes and saves the same way. Toggles, numbers, choices,
|
||||
// section headers and notes are drawn retail (gems, number boxes, drop-downs,
|
||||
// header bars); the few special rows (buttons, hotkeys, colours, the server
|
||||
// picker, status lines) use the Settings panel's own drawing.
|
||||
// AC's render thread only.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using ImGuiNET;
|
||||
using RynthCore.Engine.UI;
|
||||
using RynthCore.Engine.UI.Data;
|
||||
using static RynthCore.Engine.ImGuiBackend.Panels.Classic.ClassicKit;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Panels.Classic;
|
||||
|
||||
internal sealed class ClassicTuningTab : IClassicTab
|
||||
{
|
||||
public string Name => "Tuning";
|
||||
|
||||
private const float ListH = 440;
|
||||
|
||||
private readonly SettingsRows _rows = new();
|
||||
private readonly Dictionary<SettingRow, ClassicSettings.NumberRow> _numbers = new();
|
||||
private readonly byte[] _search = new byte[64];
|
||||
private string _query = string.Empty;
|
||||
private int _tab;
|
||||
private string[]? _tabNames;
|
||||
private bool _busy;
|
||||
|
||||
public void Shown()
|
||||
{
|
||||
UiSources.Settings.Subscribe();
|
||||
UiSources.Settings.RequestRefresh();
|
||||
}
|
||||
|
||||
public void Hidden()
|
||||
{
|
||||
UiSources.Settings.Unsubscribe();
|
||||
_rows.LeaveHotkeys();
|
||||
}
|
||||
|
||||
private string[] TabNames
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tabNames != null) return _tabNames;
|
||||
var t = SettingsSchema.Tabs;
|
||||
_tabNames = new string[t.Length];
|
||||
for (int i = 0; i < t.Length; i++) _tabNames[i] = t[i].Name;
|
||||
return _tabNames;
|
||||
}
|
||||
}
|
||||
|
||||
public float Draw(ClassicContext ctx, Vector2 o, float w)
|
||||
{
|
||||
if (!_busy) _rows.Sync();
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float y = o.Y;
|
||||
string[] names = TabNames;
|
||||
_tab = Math.Clamp(_tab, 0, Math.Max(0, names.Length - 1));
|
||||
|
||||
// ── Tab picker | search ──
|
||||
float rowH = Px(22), ddW = Px(150);
|
||||
var ddPos = new Vector2(o.X, y + (rowH - Px(19)) * 0.5f);
|
||||
bool searching = _query.Length > 0;
|
||||
if (Dropdown("##ct_tab", searching ? "All (search)" : names.Length > 0 ? names[_tab] : "", ddPos, ddW, ctx.Popup.IsOpen))
|
||||
ctx.Popup.Open(ddPos + new Vector2(0, Px(19)), ddW, names, _tab, i => { _tab = i; ClearSearch(); });
|
||||
SafeImGui.SetItemTooltip("Which group of settings (the Settings panel's tabs)");
|
||||
SearchBox(new Vector2(o.X + ddW + Px(8), y + (rowH - Px(17)) * 0.5f), w - ddW - Px(8));
|
||||
y += rowH + Px(6);
|
||||
|
||||
// ── The rows: a scrolling area with a gold scrollbar ──
|
||||
float listH = Px(ListH);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(o.X, y));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ChildBg, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ScrollbarBg, RynthTheme.Argb(0x80000000));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ScrollbarGrab, RynthTheme.Argb(0xFF7A6230));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ScrollbarGrabHovered, RynthTheme.Argb(0xFFB08A3C));
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.ScrollbarGrabActive, Gold);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.ScrollbarSize, Px(12));
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
|
||||
bool visible = ImGuiNET.ImGui.BeginChild("##ct_rows", new Vector2(w, listH), ImGuiChildFlags.None, ImGuiWindowFlags.None);
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(5);
|
||||
bool busy = false;
|
||||
if (visible)
|
||||
{
|
||||
float cw = ImGuiNET.ImGui.GetContentRegionAvail().X - Px(4);
|
||||
RynthAiSettings data = _rows.Data;
|
||||
if (UiSources.Settings.Current == null)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
TextMid(ImGuiNET.ImGui.GetWindowDrawList(), p.X + Px(3), p.Y, Px(20), "Waiting for RynthAi…", Dim);
|
||||
}
|
||||
else if (searching)
|
||||
{
|
||||
int found = 0;
|
||||
var tabs = SettingsSchema.Tabs;
|
||||
for (int t = 0; t < tabs.Length; t++)
|
||||
{
|
||||
bool shownHeader = false;
|
||||
foreach (SettingRow row in tabs[t].Rows)
|
||||
{
|
||||
if (!Matches(row) || !row.IsVisible(data)) continue;
|
||||
if (!shownHeader)
|
||||
{
|
||||
shownHeader = true;
|
||||
SectionRow(tabs[t].Name, cw);
|
||||
}
|
||||
busy |= DrawRow(ctx, row, cw, t);
|
||||
found++;
|
||||
}
|
||||
}
|
||||
if (found == 0)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
TextMid(ImGuiNET.ImGui.GetWindowDrawList(), p.X + Px(3), p.Y, Px(20), "No setting matches \"" + _query + "\".", Dim);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(cw, Px(20)));
|
||||
}
|
||||
}
|
||||
else if (names.Length > 0)
|
||||
{
|
||||
SettingRow[] rows = SettingsSchema.Tabs[_tab].Rows;
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
if (rows[i].IsVisible(data))
|
||||
busy |= DrawRow(ctx, rows[i], cw, i);
|
||||
}
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(cw, Px(6)));
|
||||
}
|
||||
ImGuiNET.ImGui.EndChild();
|
||||
_busy = busy;
|
||||
y += listH;
|
||||
return y - o.Y;
|
||||
}
|
||||
|
||||
// ── Search ──────────────────────────────────────────────────────────
|
||||
|
||||
private void SearchBox(Vector2 pos, float w)
|
||||
{
|
||||
float h = Px(17);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
FieldFrame(dl, pos, pos + new Vector2(w, h));
|
||||
ImFontPtr f = Font();
|
||||
ImGuiNET.ImGui.PushFont(f);
|
||||
ImGuiNET.ImGui.SetWindowFontScale(Px(10) / f.FontSize);
|
||||
float fs = ImGuiNET.ImGui.GetFontSize();
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBg, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.FrameBgActive, 0u);
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, White);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 0f);
|
||||
ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(Px(5), Math.Max(0, (h - fs) * 0.5f)));
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(pos);
|
||||
ImGuiNET.ImGui.SetNextItemWidth(w);
|
||||
if (ImGuiNET.ImGui.InputText("##ct_search", _search, (uint)_search.Length))
|
||||
_query = FaceKit.Utf8(_search).Trim();
|
||||
bool active = ImGuiNET.ImGui.IsItemActive();
|
||||
if (active) ImGuiTextFocus.NoteActive("##ct_search");
|
||||
ImGuiNET.ImGui.PopStyleVar(2);
|
||||
ImGuiNET.ImGui.PopStyleColor(4);
|
||||
ImGuiNET.ImGui.SetWindowFontScale(1f);
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
if (_search[0] == 0 && !active)
|
||||
TextMid(dl, pos.X + Px(6), pos.Y, h, "Search every setting", Faint, 10);
|
||||
SafeImGui.SetItemTooltip("Type part of a setting's name or description: every tab is searched.");
|
||||
}
|
||||
|
||||
private void ClearSearch()
|
||||
{
|
||||
_search[0] = 0;
|
||||
_query = string.Empty;
|
||||
}
|
||||
|
||||
private bool Matches(SettingRow row)
|
||||
{
|
||||
if (row.Kind is SettingKind.Section or SettingKind.Spacer) return false;
|
||||
return row.Label.Contains(_query, StringComparison.OrdinalIgnoreCase)
|
||||
|| (row.Tooltip != null && row.Tooltip.Contains(_query, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
// ── Rows ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>One schema row at the child's cursor; true while it's typed in.</summary>
|
||||
private bool DrawRow(ClassicContext ctx, SettingRow row, float w, int index)
|
||||
{
|
||||
ImGuiNET.ImGui.PushID(row.Label + "#" + index);
|
||||
try
|
||||
{
|
||||
switch (row.Kind)
|
||||
{
|
||||
case SettingKind.Section: SectionRow(row.Label, w); return false;
|
||||
case SettingKind.Spacer: ImGuiNET.ImGui.Dummy(new Vector2(w, Px(6))); return false;
|
||||
case SettingKind.Note: NoteRow(row.Label, w); return false;
|
||||
case SettingKind.Bool: BoolRow(row, w); return false;
|
||||
case SettingKind.Int:
|
||||
case SettingKind.Float:
|
||||
case SettingKind.Double: return NumberRow(row, w);
|
||||
case SettingKind.Combo when row.Items is { Length: > 0 }: ComboRow(ctx, row, w); return false;
|
||||
default:
|
||||
// The special rows (buttons, hotkeys, colours, server picker, status): the Settings panel's drawing.
|
||||
_rows.DrawRow(row, w);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
}
|
||||
|
||||
private static void SectionRow(string title, float w)
|
||||
{
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, Px(4)));
|
||||
Header(ImGuiNET.ImGui.GetWindowDrawList(), new Vector2(p.X, p.Y + Px(4)), w, title);
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, Px(23)));
|
||||
}
|
||||
|
||||
private static void NoteRow(string text, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.PushStyleColor(ImGuiCol.Text, Dim);
|
||||
ImGuiNET.ImGui.PushTextWrapPos(ImGuiNET.ImGui.GetCursorPosX() + w);
|
||||
ImGuiNET.ImGui.TextUnformatted(text);
|
||||
ImGuiNET.ImGui.PopTextWrapPos();
|
||||
ImGuiNET.ImGui.PopStyleColor();
|
||||
}
|
||||
|
||||
private void BoolRow(SettingRow row, float w)
|
||||
{
|
||||
RynthAiSettings data = _rows.Data;
|
||||
bool on = row.Get != null && row.Get(data) != 0;
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
if (Gem("##b", row.Label, p, w, on, 20) && row.Set != null)
|
||||
{
|
||||
row.Set(data, on ? 0 : 1);
|
||||
SettingsCommands.Save(data.Clone());
|
||||
}
|
||||
SafeImGui.SetItemTooltip(row.Tooltip ?? row.Label);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + Px(20)));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, 0));
|
||||
}
|
||||
|
||||
private bool NumberRow(SettingRow row, float w)
|
||||
{
|
||||
RynthAiSettings data = _rows.Data;
|
||||
if (!_numbers.TryGetValue(row, out ClassicSettings.NumberRow? n))
|
||||
{
|
||||
n = new ClassicSettings.NumberRow(row.Label, row.Label);
|
||||
_numbers[row] = n;
|
||||
}
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float rh = Px(22), boxW = Px(64);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
double value = row.Get != null ? Math.Clamp(row.Get(data), row.Min, row.Max) : 0;
|
||||
TextClip(dl, p.X + Px(3), p.Y, rh, p.X + w - boxW - Px(8), row.Label, Text);
|
||||
if (!n.Typing && n.Shown != value) WriteNumber(n, row, value);
|
||||
bool done = NumberBox("##n", n.Buffer, new Vector2(p.X + w - boxW, p.Y + (rh - Px(17)) * 0.5f), boxW, out bool active);
|
||||
n.Typing = active;
|
||||
SafeImGui.SetItemTooltip((row.Tooltip ?? row.Label) + $"\n({Fmt(row, row.Min)} to {Fmt(row, row.Max)})");
|
||||
if (done)
|
||||
{
|
||||
if (ClassicSettings.TryParse(n.Buffer, out double typed) && row.Set != null)
|
||||
{
|
||||
double v = Math.Clamp(row.Kind == SettingKind.Int ? Math.Round(typed) : typed, row.Min, row.Max);
|
||||
row.Set(data, v);
|
||||
SettingsCommands.Save(data.Clone());
|
||||
WriteNumber(n, row, v);
|
||||
}
|
||||
else WriteNumber(n, row, value);
|
||||
}
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + rh));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, 0));
|
||||
return n.Typing;
|
||||
}
|
||||
|
||||
private static string Fmt(SettingRow row, double v) =>
|
||||
row.Kind == SettingKind.Int ? ((long)Math.Round(v)).ToString() : v.ToString("G4", System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
private static void WriteNumber(ClassicSettings.NumberRow n, SettingRow row, double value)
|
||||
{
|
||||
string text = Fmt(row, value);
|
||||
int len = Encoding.UTF8.GetBytes(text, 0, text.Length, n.Buffer, 0);
|
||||
n.Buffer[Math.Min(len, n.Buffer.Length - 1)] = 0;
|
||||
n.Shown = value;
|
||||
}
|
||||
|
||||
private void ComboRow(ClassicContext ctx, SettingRow row, float w)
|
||||
{
|
||||
RynthAiSettings data = _rows.Data;
|
||||
string[] items = row.Items!;
|
||||
int cur = row.Get != null ? Math.Clamp((int)Math.Round(row.Get(data)), 0, items.Length - 1) : 0;
|
||||
Vector2 p = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float rh = Px(22), ddW = Math.Min(Px(170), w * 0.55f);
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
TextClip(dl, p.X + Px(3), p.Y, rh, p.X + w - ddW - Px(8), row.Label, Text);
|
||||
var ddPos = new Vector2(p.X + w - ddW, p.Y + (rh - Px(19)) * 0.5f);
|
||||
if (Dropdown("##c", items[cur], ddPos, ddW))
|
||||
{
|
||||
Vector2 screen = ddPos + new Vector2(0, Px(19));
|
||||
ctx.Popup.Open(screen, ddW, items, cur, i =>
|
||||
{
|
||||
if (row.Set == null) return;
|
||||
row.Set(_rows.Data, i);
|
||||
SettingsCommands.Save(_rows.Data.Clone());
|
||||
});
|
||||
}
|
||||
SafeImGui.SetItemTooltip(row.Tooltip ?? row.Label);
|
||||
ImGuiNET.ImGui.SetCursorScreenPos(new Vector2(p.X, p.Y + rh));
|
||||
ImGuiNET.ImGui.Dummy(new Vector2(w, 0));
|
||||
}
|
||||
}
|
||||
|
|
@ -143,6 +143,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
get
|
||||
{
|
||||
float k = SizeFactor();
|
||||
if (RynthAiDashboardState.Classic) return _classic.MinSize(k);
|
||||
return new Vector2(MinWidth * k, _contentHeight > 0 ? _contentHeight
|
||||
: (RynthAiDashboardState.Minimized ? 54 : 180) * k);
|
||||
}
|
||||
|
|
@ -154,6 +155,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
UiSources.RynthSortWatch.Subscribe(); // the Sort toggle, while RynthSort is loaded
|
||||
UiSources.RynthAi.RequestRefresh();
|
||||
_fit = true; // drop the empty space a taller saved size leaves under the content
|
||||
_drewClassic = false;
|
||||
}
|
||||
|
||||
public void OnHidden()
|
||||
|
|
@ -162,12 +164,55 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
UiSources.RynthSortWatch.Unsubscribe();
|
||||
if (_patrolOpen) { UiSources.Patrol.Unsubscribe(); _patrolOpen = false; }
|
||||
_drawers.Detach();
|
||||
if (_drewClassic) _classic.OnHidden();
|
||||
_drewClassic = false;
|
||||
}
|
||||
|
||||
// ── The Classic look (ImGui/Panels/Classic): drawn instead of the dashboard while it's on ──
|
||||
private readonly Classic.ClassicDashboard _classic = new();
|
||||
private bool _drewClassic;
|
||||
// The dashboard's own size (logical px) while the Classic look is showing, put back when it ends.
|
||||
private static Vector2 _modernSize;
|
||||
|
||||
/// <summary>
|
||||
/// Switches the dashboard between its Modern (compact) and Classic (retail) looks: the title bar
|
||||
/// buttons of either look and Settings > Display. The window refits on the next frame. AC thread.
|
||||
/// </summary>
|
||||
internal static void SwitchLook(bool classic) => RynthAiDashboardState.SetClassic(classic);
|
||||
|
||||
/// <summary>The Classic look's frame; false when the Modern dashboard draws.</summary>
|
||||
private bool DrawClassic(RynthAiView? view, RynthAiSnapshot raw)
|
||||
{
|
||||
if (!RynthAiDashboardState.Classic)
|
||||
{
|
||||
if (_drewClassic)
|
||||
{
|
||||
// Back from Classic: the dashboard's size as it was, then fit to its content.
|
||||
_drewClassic = false;
|
||||
_classic.OnHidden();
|
||||
if (_modernSize.X > 0 && !ImGuiPopOuts.InPopOutFrame) ImGuiPanelHost.RequestSize(Title, _modernSize);
|
||||
_fit = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!_drewClassic)
|
||||
{
|
||||
_drewClassic = true;
|
||||
_drawers.Detach();
|
||||
float place = Math.Max(0.01f, ImGuiPanelHost.PlacementScale());
|
||||
_modernSize = ImGuiNET.ImGui.GetWindowSize() / place;
|
||||
_classic.OnShown();
|
||||
}
|
||||
_k = PanelTextScale.Factor(ImGuiFonts.CurrentStep);
|
||||
_classic.Draw(view, raw, _k);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
RynthAiView? view = UiSources.RynthAi.Current?.Value;
|
||||
RynthAiSnapshot raw = view?.Raw ?? Empty;
|
||||
if (DrawClassic(view, raw)) return;
|
||||
bool minimized = RynthAiDashboardState.Minimized;
|
||||
bool popped = ImGuiPopOuts.InPopOutFrame;
|
||||
_view = view;
|
||||
|
|
@ -271,7 +316,7 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
{
|
||||
var dl = ImGuiNET.ImGui.GetWindowDrawList();
|
||||
float y = ImGuiNET.ImGui.GetCursorScreenPos().Y;
|
||||
const int chips = 7;
|
||||
const int chips = 8;
|
||||
float chipW = Px(18), chipH = Px(16), chipGap = Px(2), chipRound = Px(2);
|
||||
float chipsW = chips * chipW + (chips - 1) * chipGap;
|
||||
float rowH = Px(20);
|
||||
|
|
@ -341,6 +386,10 @@ internal sealed partial class RynthAiFace : IImGuiPanel
|
|||
RynthAiCommands.AdjustOpacity(0.1f);
|
||||
ImGuiNET.ImGui.SetItemTooltip("More opaque");
|
||||
cx += chipW + chipGap;
|
||||
if (IconButton("##chip_classic", new Vector2(cx, cy), chip, PhosphorIcons.Scroll, chipFont, BtnFill, Mute, BtnBord, chipRound))
|
||||
SwitchLook(classic: true);
|
||||
SafeImGui.SetItemTooltip("Classic look: the retail-style window with tabs\n(Main, Monsters, Gear, Buffs, Route, Loot, Meta, Tuning).");
|
||||
cx += chipW + chipGap;
|
||||
if (IconButton("##chip_min", new Vector2(cx, cy), chip,
|
||||
minimized ? PhosphorIcons.ArrowsOutLineVertical : PhosphorIcons.ArrowsInLineVertical, chipFont, BtnFill, Mute, BtnBord, chipRound))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ internal sealed class ArrowReadout
|
|||
_distKey = key;
|
||||
Line2 = RynthNavStatus.Yards(Distance) + " " + _compass;
|
||||
}
|
||||
if (TryHeading(out float heading))
|
||||
if (PlayerPhysicsHooks.TryGetPlayerCompassSnapshot(out float heading))
|
||||
{
|
||||
Relative = (float)bearing - heading;
|
||||
Pointing = true;
|
||||
|
|
@ -355,16 +355,4 @@ internal sealed class ArrowReadout
|
|||
|
||||
private static Vector2 Rot(Vector2 c, float x, float y, float s, float co) =>
|
||||
new(c.X + x * co - y * s, c.Y + x * s + y * co);
|
||||
|
||||
/// <summary>Your heading this frame (compass degrees) from the pose snapshot; no AC call (SenseFace's way).</summary>
|
||||
private static bool TryHeading(out float heading)
|
||||
{
|
||||
heading = 0;
|
||||
if (!PlayerPhysicsHooks.TryGetPlayerPoseSnapshot(out _, out _, out _, out _, out float qw, out float qz, out bool valid, out float h))
|
||||
return false;
|
||||
if (valid) { heading = h; return true; }
|
||||
double yaw = 2.0 * Math.Atan2(qz, qw) * (180.0 / Math.PI);
|
||||
heading = (float)((-yaw % 360.0 + 720.0) % 360.0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -369,16 +369,11 @@ internal sealed class SenseFace : IImGuiPanel
|
|||
private static Vector2 Rot(Vector2 c, float x, float y, float s, float co) =>
|
||||
new(c.X + x * co - y * s, c.Y + x * s + y * co);
|
||||
|
||||
/// <summary>Your heading this frame (compass degrees) from the pose snapshot; no AC call.</summary>
|
||||
/// <summary>Your compass heading this frame from the pose snapshot's quaternion; no AC call.</summary>
|
||||
private static float PlayerHeading(out bool ok)
|
||||
{
|
||||
ok = PlayerPhysicsHooks.TryGetPlayerPoseSnapshot(out _, out _, out _, out _, out float qw, out float qz,
|
||||
out bool headingValid, out float heading);
|
||||
if (!ok) return 0;
|
||||
if (headingValid) return heading;
|
||||
// AC's get_heading not bound yet: the yaw quaternion (ClientObjectHooks' formula).
|
||||
double yaw = 2.0 * Math.Atan2(qz, qw) * (180.0 / Math.PI);
|
||||
return (float)((-yaw % 360.0 + 720.0) % 360.0);
|
||||
ok = PlayerPhysicsHooks.TryGetPlayerCompassSnapshot(out float heading);
|
||||
return heading;
|
||||
}
|
||||
|
||||
private static uint KindColor(SenseKind kind) => kind switch
|
||||
|
|
|
|||
|
|
@ -427,6 +427,8 @@ internal static class ChatModel
|
|||
public static volatile string MentionWords = "";
|
||||
/// <summary>How many lines the scrollback keeps, all tabs together (ChatHistory; "Chat history" in the gear menu).</summary>
|
||||
public static volatile int HistoryLines = ChatHistory.DefaultLines;
|
||||
/// <summary>The tabs in a row across the top (wrapping), as before 2026-10-09, instead of the channels drawer.</summary>
|
||||
public static volatile bool TabsAcross;
|
||||
|
||||
public static void SetHistoryLines(int lines)
|
||||
{
|
||||
|
|
@ -1411,6 +1413,7 @@ internal static class ChatModel
|
|||
MentionSound = dto.MentionSound;
|
||||
MentionWords = dto.MentionWords ?? "";
|
||||
HistoryLines = ChatHistory.Clamp(dto.HistoryLines ?? 0); // absent before 2026-10-11: the default
|
||||
TabsAcross = dto.TabsAcross ?? false; // absent before 2026-10-20 (and while off): the drawer
|
||||
ChatLineColors.Load(dto.LineColors); // absent before 2026-10-08: nothing set
|
||||
|
||||
var tabs = new List<string>();
|
||||
|
|
@ -1499,6 +1502,7 @@ internal static class ChatModel
|
|||
MentionWords = MentionWords,
|
||||
// Left out at the default, so a file follows the default if it ever changes.
|
||||
HistoryLines = HistoryLines == ChatHistory.DefaultLines ? null : HistoryLines,
|
||||
TabsAcross = TabsAcross ? true : null,
|
||||
LineColors = ChatLineColors.ToJson(), // null (left out) until a colour is set
|
||||
CustomTabs = Volatile.Read(ref _customTabs),
|
||||
Filters = Filters.Select(ToDto).ToArray(),
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ internal sealed class RynthChatSettingsDto
|
|||
[JsonPropertyName("lineColors")] public Dictionary<string, string>? LineColors { get; set; }
|
||||
// 2026-10-11: how many lines the scrollback keeps (ChatHistory); absent at the default (2000).
|
||||
[JsonPropertyName("historyLines")] public int? HistoryLines { get; set; }
|
||||
// 2026-10-20: the tabs in a row across the top instead of the channels drawer; absent while off.
|
||||
[JsonPropertyName("tabsAcross")] public bool? TabsAcross { get; set; }
|
||||
[JsonPropertyName("customTabs")] public string[]? CustomTabs { get; set; }
|
||||
[JsonPropertyName("filters")] public RynthChatFilterDto[]? Filters { get; set; }
|
||||
/// <summary>Standard filters' user state (RynthChatPresets); absent while none was changed.</summary>
|
||||
|
|
|
|||
|
|
@ -291,6 +291,15 @@ internal sealed class RynthAiSettings
|
|||
public string DiagFolder { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>A private copy for a face to edit (all members are values or strings).</summary>
|
||||
// VTank's options page (the Classic dashboard's Main tab): RynthAi stores them with the profile and metas
|
||||
// read them (UseDispelItems, AutoFellowMgmt); CustomPetRange is the pet manager's range. Nullable, like
|
||||
// EnableVaultedDungeons: a RynthAi that predates them (before 2026-10-19) omits them, their rows stay
|
||||
// hidden, and a save sends null, which RynthAi leaves alone.
|
||||
public bool? UseDispelItems { get; set; }
|
||||
public bool? AutoFellowMgmt { get; set; }
|
||||
public bool? MChargesWhenOff { get; set; }
|
||||
public int? CustomPetRange { get; set; }
|
||||
|
||||
public RynthAiSettings Clone() => (RynthAiSettings)MemberwiseClone();
|
||||
}
|
||||
|
||||
|
|
@ -492,6 +501,7 @@ internal static class SettingsSchema
|
|||
{
|
||||
// Also drawn on the Nav panel (ImGui/Panels/NavFace.cs).
|
||||
public const string NavPointReachLabel = "Nav point reach (yd)";
|
||||
private static readonly string[] DashboardLooks = { "Modern (compact)", "Classic (retail)" };
|
||||
/// <summary>The Navigation row of RynthAi's Vaulted Dungeons master switch (<see cref="RynthAiSettings.EnableVaultedDungeons"/>).</summary>
|
||||
public const string VaultedDungeonsLabel = "Vaulted Dungeons";
|
||||
public const string NavPointReachTip =
|
||||
|
|
@ -683,6 +693,10 @@ internal static class SettingsSchema
|
|||
{
|
||||
Bool("Show Target Stamina / Mana", s => s.ShowTargetStaminaMana, (s, v) => s.ShowTargetStaminaMana = v,
|
||||
"When enabled, displays stamina and mana bars for the selected target (requires appraisal data)."),
|
||||
// Stored with the dashboard's state (RynthAiDashboardState), not in the RynthAi profile.
|
||||
Combo("RynthAi Dashboard Look", DashboardLooks, _ => RynthAiDashboardState.Classic ? 1 : 0,
|
||||
(_, v) => ImGuiBackend.Panels.RynthAiFace.SwitchLook(v == 1),
|
||||
"Modern: the compact dashboard. Classic: a retail-style window with tabs (Main, Monsters, Gear, Buffs,\nRoute, Loot, Meta, Tuning), drawn with the game's own pictures. Also: the button on either look's title bar."),
|
||||
// Stored in engine.json for every client (EngineSettings), not in the RynthAi profile.
|
||||
Bool("Insert Key Releases the UI", _ => Plugins.EngineSettings.InsertReleasesUi,
|
||||
(_, v) => { Plugins.EngineSettings.InsertReleasesUi = v; if (!v) ImGuiBackend.Win32Backend.ReclaimUi(); },
|
||||
|
|
@ -1027,6 +1041,10 @@ internal static class SettingsSchema
|
|||
Spacer(),
|
||||
Bool("Summon Pets", s => s.SummonPets, (s, v) => s.SummonPets = v),
|
||||
Int("Pet Min Monsters", s => s.PetMinMonsters, (s, v) => s.PetMinMonsters = v, 1, 20, 1),
|
||||
new(SettingKind.Int, "Pet Range",
|
||||
"A pet is summoned when at least Pet Min Monsters attackable monsters are this close (yards).",
|
||||
s => s.CustomPetRange ?? 5, (s, v) => s.CustomPetRange = (int)Math.Round(v), 1, 50, 1,
|
||||
VisibleWhen: s => s.CustomPetRange.HasValue),
|
||||
}),
|
||||
|
||||
new("Spell Combat", Concat(
|
||||
|
|
@ -1036,6 +1054,15 @@ internal static class SettingsSchema
|
|||
Int("Attack Spell Delay (ms)", s => s.AttackSpellIntervalMs, (s, v) => s.AttackSpellIntervalMs = v, 0, 5000, 50,
|
||||
"Least time between offensive (war/void) COMBAT casts at one target.\nThe next cast also waits until the last one is finished (the server's\nanswer and the casting animation), so 0 = cast again as soon as it is.\nDoes NOT affect buffing speed."),
|
||||
Bool("Cast Dispel Self", s => s.CastDispelSelf, (s, v) => s.CastDispelSelf = v),
|
||||
Bool("Use Dispel Items", s => s.UseDispelItems ?? false, (s, v) => s.UseDispelItems = v,
|
||||
"VTank's Use Dispel Items, saved with the profile. Metas read it (UseDispelItems).",
|
||||
when: s => s.UseDispelItems.HasValue),
|
||||
Bool("Auto Fellowship Management", s => s.AutoFellowMgmt ?? false, (s, v) => s.AutoFellowMgmt = v,
|
||||
"VTank's Auto Fellow Mgmt., saved with the profile. Metas read it (AutoFellowMgmt).",
|
||||
when: s => s.AutoFellowMgmt.HasValue),
|
||||
Bool("M. Charges When Off", s => s.MChargesWhenOff ?? false, (s, v) => s.MChargesWhenOff = v,
|
||||
"VTank's option of this name, saved with the profile for VTank users. RynthAi doesn't act on it yet.",
|
||||
when: s => s.MChargesWhenOff.HasValue),
|
||||
Spacer(),
|
||||
Section("Ring Spell Override"),
|
||||
Int("Min Ring Targets", s => s.MinRingTargets, (s, v) => s.MinRingTargets = v, 1, 20, 1,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@
|
|||
// drawer; line 11 remote|noremote, the Mini Remote drawer; line 12 the
|
||||
// drawers moved to the side they don't start on, "moved:key,key"; line 13
|
||||
// quick|noquick, the My settings drawer: the drawers on the dashboard's
|
||||
// edges, ImGui/Panels/DashboardDrawers.cs). Line 2
|
||||
// edges, ImGui/Panels/DashboardDrawers.cs; line 14 classic|modern, the
|
||||
// dashboard's look, and line 15 the Classic look's open tab,
|
||||
// ImGui/Panels/Classic). Line 2
|
||||
// was the Monsters button's Simple/Advanced mode, retired 2026-10-01 with the
|
||||
// basic Monsters panel: it is still written ("advanced") so the lines after
|
||||
// it keep their places, and ignored on read. Lines 7 and 8 (the dashboard's
|
||||
|
|
@ -42,6 +44,8 @@ internal static class RynthAiDashboardState
|
|||
private static volatile bool _patrolOpen; // the Patrol drawer beside the dashboard is open
|
||||
private static volatile bool _remoteOpen; // the Mini Remote drawer beside the dashboard is open
|
||||
private static volatile bool _quickOpen; // the My settings drawer beside the dashboard is open
|
||||
private static volatile bool _classic; // the Classic (retail) look instead of the dashboard
|
||||
private static volatile int _classicTab; // the Classic look's open tab
|
||||
// Drawer keys on the side they don't start on (a tab's right-click moves it). Copy-on-write.
|
||||
private static volatile string[] _moved = Array.Empty<string>();
|
||||
// Lines 7 and 8, unused since 2026-10-05: written back as read.
|
||||
|
|
@ -173,6 +177,34 @@ internal static class RynthAiDashboardState
|
|||
UiBackgroundWriter.Enqueue("rynthai dashboard state", Save);
|
||||
}
|
||||
|
||||
/// <summary>The dashboard draws its Classic (retail) look: the tabbed window of ImGui/Panels/Classic. Any thread.</summary>
|
||||
public static bool Classic
|
||||
{
|
||||
get { EnsureLoaded(); return _classic; }
|
||||
}
|
||||
|
||||
public static void SetClassic(bool classic)
|
||||
{
|
||||
EnsureLoaded();
|
||||
if (_classic == classic) return;
|
||||
_classic = classic;
|
||||
UiBackgroundWriter.Enqueue("rynthai dashboard state", Save);
|
||||
}
|
||||
|
||||
/// <summary>The Classic look's open tab (0 = Main). Any thread.</summary>
|
||||
public static int ClassicTab
|
||||
{
|
||||
get { EnsureLoaded(); return _classicTab; }
|
||||
}
|
||||
|
||||
public static void SetClassicTab(int tab)
|
||||
{
|
||||
EnsureLoaded();
|
||||
if (_classicTab == tab) return;
|
||||
_classicTab = tab;
|
||||
UiBackgroundWriter.Enqueue("rynthai dashboard state", Save);
|
||||
}
|
||||
|
||||
/// <summary>The drawer <paramref name="key"/> sits on the side it doesn't start on. Any thread.</summary>
|
||||
public static bool DrawerMoved(string key)
|
||||
{
|
||||
|
|
@ -219,6 +251,8 @@ internal static class RynthAiDashboardState
|
|||
if (lines.Length >= 12 && lines[11].Trim().StartsWith("moved:", StringComparison.OrdinalIgnoreCase))
|
||||
_moved = lines[11].Trim().Substring(6).Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
_quickOpen = lines.Length >= 13 && lines[12].Trim().Equals("quick", StringComparison.OrdinalIgnoreCase);
|
||||
_classic = lines.Length >= 14 && lines[13].Trim().Equals("classic", StringComparison.OrdinalIgnoreCase);
|
||||
if (lines.Length >= 15 && int.TryParse(lines[14].Trim(), out int tab)) _classicTab = Math.Max(0, tab);
|
||||
}
|
||||
}
|
||||
catch { /* corrupt cache: start expanded */ }
|
||||
|
|
@ -238,7 +272,8 @@ internal static class RynthAiDashboardState
|
|||
+ _line7 + "\n" + _line8 + "\n"
|
||||
+ (_rangesOpen ? "ranges" : "noranges") + "\n" + (_patrolOpen ? "patrol" : "nopatrol") + "\n"
|
||||
+ (_remoteOpen ? "remote" : "noremote") + "\n"
|
||||
+ "moved:" + string.Join(",", _moved) + "\n" + (_quickOpen ? "quick" : "noquick") + "\n");
|
||||
+ "moved:" + string.Join(",", _moved) + "\n" + (_quickOpen ? "quick" : "noquick") + "\n"
|
||||
+ (_classic ? "classic" : "modern") + "\n" + _classicTab + "\n");
|
||||
}
|
||||
catch { /* best-effort */ }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue