diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
index 06dad89..076bbea 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/CombatManager.cs
@@ -1373,6 +1373,13 @@ public partial class CombatManager : IDisposable
{ "Yield", new[] { "Magic Yield Other", "Yield" } },
};
+ // The Void debuffs (2026-10-27): "{base} I".."VII" and "Incantation of {base}" in SpellData.txt,
+ // cast with Void Magic. Corrosion and Corruption are projectiles that put their Nether damage
+ // over time on what they hit (Corruption flies as a blast); Destructive Curse, Weakening Curse
+ // and Festering Curse land directly. Keyed "Void:{base}" in the debuff list.
+ internal static readonly string[] VoidDebuffBases =
+ { "Corrosion", "Corruption", "Destructive Curse", "Weakening Curse", "Festering Curse" };
+
// Shape index into the SpellShapes / VoidSpellShapes rows. ShapeWall (2026-10-08) has no row:
// walls have no tiered base names and are found by spell category (WallCategories).
internal const int ShapeArc = 0, ShapeRing = 1, ShapeStreak = 2, ShapeBolt = 3, ShapeBlast = 4, ShapeWall = 5;
@@ -7056,6 +7063,8 @@ public partial class CombatManager : IDisposable
spellId = FindBestVulnSpellWithTier(debuffKey.Substring(5), out castTier);
else if (debuffKey.StartsWith("Custom:"))
spellId = FindBestCustomDebuffWithTier(debuffKey.Substring(7), out castTier);
+ else if (debuffKey.StartsWith("Void:"))
+ spellId = FindBestVoidDebuffWithTier(debuffKey.Substring(5), out castTier);
else
spellId = FindBestDebuffSpellWithTier(debuffKey, out castTier);
@@ -7342,6 +7351,11 @@ public partial class CombatManager : IDisposable
if (rule.Yield) list.Add("Yield");
if (rule.Broadside) list.Add("Broadside");
if (rule.GravityWell) list.Add("Gravity");
+ if (rule.Corrosion) list.Add("Void:Corrosion");
+ if (rule.Corruption) list.Add("Void:Corruption");
+ if (rule.DestructiveCurse) list.Add("Void:Destructive Curse");
+ if (rule.WeakeningCurse) list.Add("Void:Weakening Curse");
+ if (rule.FesteringCurse) list.Add("Void:Festering Curse");
if (!string.IsNullOrWhiteSpace(rule.CustomDebuffs))
foreach (string part in rule.CustomDebuffs.Split(new[] { ',', ';', '\n' }, StringSplitOptions.RemoveEmptyEntries))
{
@@ -7376,6 +7390,24 @@ public partial class CombatManager : IDisposable
return 0;
}
+ ///
+ /// The best level of a Void debuff the character knows ("Incantation of X", then X VII..I),
+ /// capped by Void Magic alone: a character without it gets 0 and the debuff is passed over.
+ ///
+ private int FindBestVoidDebuffWithTier(string baseName, out int tier)
+ {
+ tier = 0;
+ if (_spellManager == null) return 0;
+ int maxTier = EffectiveMaxTier(AcSkillType.VoidMagic);
+ if (maxTier >= 8) { int id = TrySpellByName($"Incantation of {baseName}"); if (id != 0) { tier = 8; return id; } }
+ for (int t = Math.Min(maxTier, 7); t >= 1; t--)
+ {
+ int id = TrySpellByName($"{baseName} {GetRomanNumeral(t)}");
+ if (id != 0) { tier = t; return id; }
+ }
+ return 0;
+ }
+
private int FindBestDebuffSpellWithTier(string debuffType, out int tier)
{
tier = 0;
diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/DebuffTimers.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/DebuffTimers.cs
index 7a7cc1d..3cd8e6b 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/Combat/DebuffTimers.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/DebuffTimers.cs
@@ -5,7 +5,7 @@ namespace RynthCore.Plugin.RynthAi;
///
/// Which of a monster rule's debuffs (Imperil, the vulns, Fester, Yield, Broadside, Gravity
-/// Well, custom ones) are on which target, and when each is due again. A landed debuff with a
+/// Well, the Void ones, custom ones) are on which target, and when each is due again. A landed debuff with a
/// known duration is renewed a little before it wears off (2026-10-20: they were cast once
/// per target, so a long fight with a high-HP monster lost them after 4-5 minutes). One with
/// no known duration, or given up on after fizzles or resists, is
diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs
index b054a7e..e563a44 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs
@@ -1065,6 +1065,10 @@ internal sealed partial class LegacyDashboardRenderer
// Same for kite (2026-10-16): an older Monsters panel omits Kite and would wipe PullAway.
if (json.IndexOf("\"Kite\"", StringComparison.OrdinalIgnoreCase) < 0)
CarryKite(_settings.MonsterRules, incoming);
+ // And the Void debuffs (2026-10-27): an engine without them would turn them all off.
+ // The colon makes it the key: a typed-in debuff "Corrosion" is a value.
+ if (json.IndexOf("\"Corrosion\":", StringComparison.OrdinalIgnoreCase) < 0)
+ CarryVoidDebuffs(_settings.MonsterRules, incoming);
_settings.MonsterRules = incoming;
SaveMonstersFile();
@@ -1098,6 +1102,24 @@ internal sealed partial class LegacyDashboardRenderer
}
}
+ /// Copies the five Void debuff switches from onto the
+ /// matching rules of (same Name and MatchExpression, case-insensitive).
+ internal static void CarryVoidDebuffs(List current, List incoming)
+ {
+ foreach (var r in incoming)
+ {
+ var old = current.FirstOrDefault(o =>
+ string.Equals(o.Name, r.Name, StringComparison.OrdinalIgnoreCase)
+ && string.Equals(o.MatchExpression ?? "", r.MatchExpression ?? "", StringComparison.OrdinalIgnoreCase));
+ if (old == null) continue;
+ r.Corrosion = old.Corrosion;
+ r.Corruption = old.Corruption;
+ r.DestructiveCurse = old.DestructiveCurse;
+ r.WeakeningCurse = old.WeakeningCurse;
+ r.FesteringCurse = old.FesteringCurse;
+ }
+ }
+
// ── Settings bridge (engine-side Avalonia SettingsPanel) ─────────────────
///
diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs
index 9224b6f..79bc551 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs
@@ -871,6 +871,15 @@ public sealed class MonsterRule
public bool Imperil { get; set; }
public bool Yield { get; set; }
public bool Vuln { get; set; }
+ /// The Void debuffs (VTank's Cs, Cp, DC, WC and FC columns), cast with Void Magic:
+ /// the Nether damage-over-time spells Corrosion, Corruption and Destructive Curse, then
+ /// Weakening Curse (less damage from the monster) and Festering Curse (less healing on it).
+ /// Off in files from before 2026-10-27.
+ public bool Corrosion { get; set; }
+ public bool Corruption { get; set; }
+ public bool DestructiveCurse { get; set; }
+ public bool WeakeningCurse { get; set; }
+ public bool FesteringCurse { get; set; }
public bool UseArc { get; set; }
public bool UseRing { get; set; }
public bool UseStreak { get; set; }
diff --git a/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs
index 9d10fca..92f5d5d 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankProfileImporter.cs
@@ -235,6 +235,11 @@ public static class VirindiTankProfileImporter
dst.Imperil = src.Imperil;
dst.Yield = src.Yield;
dst.Vuln = src.Vuln;
+ dst.Corrosion = src.Corrosion;
+ dst.Corruption = src.Corruption;
+ dst.DestructiveCurse = src.DestructiveCurse;
+ dst.WeakeningCurse = src.WeakeningCurse;
+ dst.FesteringCurse = src.FesteringCurse;
dst.UseArc = src.UseArc;
dst.UseBolt = src.UseBolt;
dst.UseRing = src.UseRing;
@@ -262,6 +267,11 @@ public static class VirindiTankProfileImporter
Imperil = row.Imperil,
Yield = row.Yield,
Vuln = row.Vuln,
+ Corrosion = row.Corrosion,
+ Corruption = row.Corruption,
+ DestructiveCurse = row.DestructiveCurse,
+ WeakeningCurse = row.WeakeningCurse,
+ FesteringCurse = row.FesteringCurse,
UseArc = row.UseArc,
UseBolt = row.UseBolt,
UseRing = row.UseRing,
diff --git a/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs
index cd73ec1..1370e54 100644
--- a/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs
+++ b/Plugins/RynthCore.Plugin.RynthAi/ProfileImport/VirindiTankUsdMyMonstersScfParser.cs
@@ -268,6 +268,12 @@ internal static class VirindiTankUsdMyMonstersScfParser
Broadside = broad,
Fester = fest,
UseStreak = strk,
+ // b[8..12]: VT's Void columns WC, FC, Cp, DC, Cs.
+ WeakeningCurse = b[8],
+ FesteringCurse = b[9],
+ Corruption = b[10],
+ DestructiveCurse = b[11],
+ Corrosion = b[12],
ExVuln = "None",
OffhandId = WepId(ofh),
PetDamage = MapPet(pet, sev),
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/DefSession.cs b/Plugins/RynthCore.Plugin.RynthDefective/DefSession.cs
index a21fa50..403681a 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/DefSession.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/DefSession.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using RynthCore.Plugin.RynthDefective.Items;
using RynthCore.Plugin.RynthDefective.Model;
+using RynthCore.Plugin.RynthDefective.ShortcutBar;
using RynthCore.Plugin.RynthDefective.Use;
namespace RynthCore.Plugin.RynthDefective;
@@ -25,6 +26,14 @@ internal sealed class DefSession
public Func RunChat = _ => false;
/// Asks for the character's file to be written soon.
public Action Save = () => { };
+ /// AC's 18 shortcut slots now (object ids, spell ids; slot 1 first); false when they can't be read (out of the world, an older engine).
+ public Func ReadRetail = (_, _) => false;
+ /// An object's name as the client knows it (an item in one of AC's slots that the pack read missed); null = unknown.
+ public Func ObjectName = _ => null;
+ /// The keys the engine's hotkeys give a chat command ("/rdef use 3"): "F9, Ctrl+1"; "" = none.
+ public Func CommandKeys = _ => string.Empty;
+ /// Gives own slot N the key (it comes off whatever had it): the plugin's BindOwnSlotKey. False when it can't.
+ public Func BindOwnKey = (_, _) => false;
/// The pictures and bar buttons need op level 2 script windows.
public bool IconsAvailable;
public bool LoggedIn;
@@ -66,6 +75,21 @@ internal sealed class DefSession
return null;
}
+ ///
+ /// A click on AC's own shortcut slot (1-18, the usual bar) holding
+ /// : a healing kit is used on yourself here, through the use controller
+ /// (one touch, nothing selected, as a RynthDefective slot does it), and true is returned. Anything
+ /// else returns false and the click goes to AC's own toolbar use. Only the bar's click comes here:
+ /// the slot's own key (AC's UseQuickSlot_N in AC's keymap) is AC's, and still goes straight to AC.
+ ///
+ public bool UseRetailSlot(int number, uint objectId)
+ {
+ CarriedItem? kit = BarMapping.RetailKit(objectId, Items());
+ if (kit == null) return false;
+ Use.Request(new UseRequest(ItemRef.From(kit), null, UseMode.OnSelf, "game slot " + number, Now()));
+ return true;
+ }
+
/// /rdef use <name>: an item by what the player typed.
public void UseByName(string name) =>
Use.Request(new UseRequest(null, name, UseMode.Auto, "name '" + name + "'", Now()));
@@ -137,7 +161,7 @@ internal sealed class DefSession
public void SetSlotCount(int count)
{
- Settings.SlotCount = Math.Clamp(count, DefSettings.SlotsMin, DefSettings.SlotsMax);
+ Settings.SlotCount = Math.Clamp(count, DefSettings.SlotsMin, DefSettings.SlotCountMax);
Save();
}
@@ -216,6 +240,86 @@ internal sealed class DefSession
return combo;
}
+ // ── Independent bar ─────────────────────────────────────────────────────
+
+ ///
+ /// How many items in AC's slots the settings window offers to copy into the bar's own slots, after
+ /// the bar was made independent (0 = no offer). Nothing is copied until the player says so.
+ ///
+ public int CopyOffer;
+
+ /// Turns the independent bar on or off (DefSettings.IndependentBar). Returns what to tell the player.
+ public string SetIndependent(bool on)
+ {
+ CopyOffer = 0;
+ if (Settings.IndependentBar != on)
+ {
+ Settings.IndependentBar = on;
+ Save();
+ }
+ if (!on)
+ return "The Shortcuts bar shows the game's 18 slots first again; RynthDefective's own slots follow them from slot 19 (its slot 1 there).";
+ var ids = new uint[DefSettings.RetailSlots];
+ var spells = new uint[DefSettings.RetailSlots];
+ int items = ReadRetail(ids, spells) ? BarMapping.RetailItems(ids) : 0;
+ CopyOffer = items;
+ const string what = "The Shortcuts bar is independent of the game's toolbar now: every slot is RynthDefective's own "
+ + "(clicks one-touch, keys RynthCore hotkeys). The game's toolbar and its keys are unchanged.";
+ return items == 0 ? what
+ : what + $" The game's 18 slots hold {items} item{(items == 1 ? "" : "s")}: Defective Settings offers to copy them in.";
+ }
+
+ /// The player said no to the copy.
+ public void DeclineCopy() => CopyOffer = 0;
+
+ ///
+ /// The copy the settings window offers: AC's 18 slots into the own slots 1-18, the own slots that
+ /// followed them moved to 19 and on with their keys (BarMapping.CopyRetail), so the independent bar
+ /// looks as the usual one did. Returns what to tell the player.
+ ///
+ public string CopyRetailSlots()
+ {
+ CopyOffer = 0;
+ if (!Settings.IndependentBar) return "The bar uses the game's slots itself: make it independent first (Defective Settings).";
+ var ids = new uint[DefSettings.RetailSlots];
+ var spells = new uint[DefSettings.RetailSlots];
+ if (!ReadRetail(ids, spells)) return "The game's shortcut slots can't be read right now (in the world, on RynthCore with the Shortcuts bar).";
+
+ // The moving slots' keys, read before anything is bound (a bind can land at once).
+ var keysOf = new Dictionary();
+ for (int n = 1; n <= DefSettings.SlotsMax - DefSettings.RetailSlots; n++)
+ if (!Data.Slots[n - 1].Empty)
+ keysOf[n] = BarMapping.SplitKeys(CommandKeys(DefCommandParser.UseCommand(n)));
+
+ BarCopyResult r = BarMapping.CopyRetail(Data.Slots, ids, spells, ResolveRetail);
+ if (r.Refused != null) return r.Refused;
+ Save();
+ int keysMoved = 0, keysFailed = 0;
+ foreach ((int from, int to) in r.Moved)
+ if (keysOf.TryGetValue(from, out string[]? keys))
+ foreach (string key in keys)
+ if (BindOwnKey(to, key)) keysMoved++; else keysFailed++;
+ Keys.Invalidate();
+
+ string msg = r.Copied == 0 ? "None of the game's slots held an item to copy." : $"Copied {r.Copied} of the game's slots into this bar (slots 1-18).";
+ if (r.Skipped > 0) msg += $" {r.Skipped} couldn't be (a spell, or an item not in your pack).";
+ if (r.Moved.Count > 0)
+ msg += $" Your own {r.Moved.Count} slot{(r.Moved.Count == 1 ? "" : "s")} moved after them, to 19 and on"
+ + (keysMoved > 0 ? $", {keysMoved} key{(keysMoved == 1 ? "" : "s")} with them" : "") + ".";
+ if (keysFailed > 0) msg += $" {keysFailed} key{(keysFailed == 1 ? "" : "s")} couldn't be moved: bind {(keysFailed == 1 ? "it" : "them")} again (right-click a slot).";
+ if (r.Copied > 0) msg += " The game's keys still use the game's toolbar: give these slots keys with right-click > Add a key.";
+ return msg;
+ }
+
+ /// An item in one of AC's slots as a slot reference: from the pack read, else by the name the client knows.
+ private ItemRef? ResolveRetail(uint id)
+ {
+ CarriedItem? it = FindById(id);
+ if (it != null) return ItemRef.From(it);
+ string? name = ObjectName(id);
+ return string.IsNullOrWhiteSpace(name) ? null : new ItemRef { Id = id, Name = name.Trim() };
+ }
+
// ── Favourites ──────────────────────────────────────────────────────────
public string ToggleFavourite(ItemRef r)
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefCommand.cs b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefCommand.cs
index 32e2537..1d37e47 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefCommand.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefCommand.cs
@@ -2,7 +2,7 @@ using System;
namespace RynthCore.Plugin.RynthDefective.Model;
-internal enum DefVerb { Toggle, Help, Use, Set, Clear, Bind, Unbind, Weapons, Favourite, Slots, List, Status, Error, Panels, Selection }
+internal enum DefVerb { Toggle, Help, Use, Set, Clear, Bind, Unbind, Weapons, Favourite, Slots, List, Status, Error, Panels, Selection, Settings }
/// A parsed "/rdef ..." line. Use: (1-based) or (an item name).
internal sealed record DefCommand(DefVerb Verb, int Slot = 0, string Text = "", string Error = "");
@@ -11,7 +11,7 @@ internal static class DefCommandParser
{
public const string Usage =
"/rdef [use | set [item name] | clear | bind | unbind | "
- + "weapons [search] | fav | slots | list | status | panels (the game panel buttons) | selection]";
+ + "weapons [search] | fav | slots | list | status | settings | panels (the game panel buttons) | selection]";
/// Parses the arguments after "/rdef" (blank = show or hide the bar).
public static DefCommand Parse(string? args)
@@ -28,6 +28,7 @@ internal static class DefCommandParser
case "list": case "ls": return new DefCommand(DefVerb.List);
case "status": return new DefCommand(DefVerb.Status);
case "panels": case "panel": return new DefCommand(DefVerb.Panels);
+ case "settings": case "options": case "setup": return new DefCommand(DefVerb.Settings);
case "selection": case "target":
// "/rdef selection 0x80001234": select that object (a test hook for the Selection window).
return new DefCommand(DefVerb.Selection, Text: rest);
@@ -56,9 +57,9 @@ internal static class DefCommandParser
case "unbind":
return TrySlot(rest, out int us) ? new DefCommand(DefVerb.Unbind, us) : Fail("Which slot? e.g. /rdef unbind 3");
case "slots":
- return int.TryParse(rest, out int count) && count >= DefSettings.SlotsMin && count <= DefSettings.SlotsMax
+ return int.TryParse(rest, out int count) && count >= DefSettings.SlotsMin && count <= DefSettings.SlotCountMax
? new DefCommand(DefVerb.Slots, count)
- : Fail($"How many slots? {DefSettings.SlotsMin} to {DefSettings.SlotsMax}, e.g. /rdef slots 10");
+ : Fail($"How many slots? {DefSettings.SlotsMin} to {DefSettings.SlotCountMax}, e.g. /rdef slots 10");
default:
// "/rdef Stamina Kit" is a shorthand for use.
return new DefCommand(DefVerb.Use, Text: a);
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs
index 6c4a7b0..3bf6f83 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefData.cs
@@ -52,17 +52,34 @@ internal enum KindFilter { All, Melee, Missile, War, Void }
/// RynthDefective's settings for one character.
internal sealed class DefSettings
{
- public const int SlotsMin = 1, SlotsMax = 24, PerRowMin = 1, PerRowMax = 12, ButtonMin = 20, ButtonMax = 64,
- PickerIconMin = 20, PickerIconMax = 48;
-
///
/// The shortcut bar (2026-10-22, plugin API v90): its first 18 slots are AC's own (the retail
/// toolbar's, its keys AC's keymap), the rest this plugin's own slots (Slots, keys the engine's
- /// hotkeys). The player picks how many it shows.
+ /// hotkeys). The player picks how many it shows. With every slot
+ /// is this plugin's own (ShortcutBar/BarMapping.cs).
///
- public const int RetailSlots = 18, BarSlotsMin = 1, BarSlotsMax = RetailSlots + SlotsMax;
+ public const int RetailSlots = 18, BarSlotsMin = 1, BarSlotsMax = 42;
+
+ ///
+ /// RynthDefective's own slots (DefData.Slots, "/rdef use 1..42"): as many as the bar can show, so
+ /// an independent bar is as long as the usual one (which shows own slots 1-24 after the game's 18).
+ /// The old script-window bar shows the first of them.
+ ///
+ public const int SlotsMin = 1, SlotsMax = BarSlotsMax, SlotCountMax = 24, PerRowMin = 1, PerRowMax = 12, ButtonMin = 20, ButtonMax = 64,
+ PickerIconMin = 20, PickerIconMax = 48;
public int BarSlots = RetailSlots;
+ ///
+ /// The shortcut bar is independent of AC's toolbar (2026-10-27): AC's 18 slots are not on it, every
+ /// slot is RynthDefective's own (bar slot N = own slot N, clicks through the use controller, keys
+ /// the engine's hotkeys running /rdef use N). Per character, like the slots it decides about: AC
+ /// keeps its 18 shortcut slots per character on the server, and the own slots are per character
+ /// here, so one character can keep the game's toolbar on the bar while another goes independent.
+ /// Off (the default, and what a file from before reads as): slots 1-18 are AC's.
+ ///
+ public bool IndependentBar;
+
+ /// The old script-window bar's slot count (engines without the shortcut bar).
public int SlotCount = 8;
public int SlotsPerRow = 8;
/// Icon size of the slot buttons, in logical units.
@@ -81,7 +98,7 @@ internal sealed class DefSettings
public void Clamp()
{
- SlotCount = Math.Clamp(SlotCount, SlotsMin, SlotsMax);
+ SlotCount = Math.Clamp(SlotCount, SlotsMin, SlotCountMax);
BarSlots = Math.Clamp(BarSlots, BarSlotsMin, BarSlotsMax);
SlotsPerRow = Math.Clamp(SlotsPerRow, PerRowMin, PerRowMax);
ButtonSize = Math.Clamp(ButtonSize, ButtonMin, ButtonMax);
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs
index 2b6fc87..611bffe 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/Model/DefStore.cs
@@ -66,6 +66,7 @@ internal sealed class DefStore
st.ShowCounts = Bool(s, "showCounts", st.ShowCounts);
st.PreferredKind = (KindFilter)Int(s, "preferredKind", (int)st.PreferredKind);
st.SwapWhileBotRuns = Bool(s, "swapWhileBotRuns", st.SwapWhileBotRuns);
+ st.IndependentBar = Bool(s, "independentBar", st.IndependentBar); // missing (a file from before 2026-10-27): off
st.BarOpen = Bool(s, "barOpen", st.BarOpen);
st.PickerOpen = Bool(s, "pickerOpen", st.PickerOpen);
st.Clamp();
@@ -156,6 +157,7 @@ internal sealed class DefStore
w.WriteBoolean("showCounts", s.ShowCounts);
w.WriteNumber("preferredKind", (int)s.PreferredKind);
w.WriteBoolean("swapWhileBotRuns", s.SwapWhileBotRuns);
+ w.WriteBoolean("independentBar", s.IndependentBar);
w.WriteBoolean("barOpen", s.BarOpen);
w.WriteBoolean("pickerOpen", s.PickerOpen);
w.WriteEndObject();
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/README.md b/Plugins/RynthCore.Plugin.RynthDefective/README.md
index 63827a0..406a17e 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/README.md
+++ b/Plugins/RynthCore.Plugin.RynthDefective/README.md
@@ -8,6 +8,35 @@ contains no code from it: it was written from the plugin's public feature descri
against RynthCore's own APIs. (Defective's repository states no licence; ask Aun if you want a
literal port or shared code.)
+## The Shortcuts bar, Game Panels and Selection
+
+On a RynthCore engine with plugin API v90, **RynthDefective is what draws the Shortcuts
+bar** (its RynthCore bar button is the lightning bolt; `/rdef` shows or hides it), **the Game Panels
+buttons** (pack, spellbook, map ... in the bottom-right corner; `/rdef panels`) and **the Selection
+window** (what is selected and its health, at the top; `/rdef selection`). Turn RynthDefective off and
+all three go.
+
+* **Settings**: the gear on the bar's title, *Settings...* in its right-click menu, or `/rdef settings`
+ open RynthDefective's settings window: which of the three windows show, *Independent of the game's
+ toolbar*, the slot picture size, *Allow weapon swaps while RynthAi's macro runs* and the weapon picker's
+ icon size.
+* **Right-click the bar's title** (or the end of any slot's menu) for *Settings...* and to show or hide
+ *Game panel buttons* and *Selection* (they have no RynthCore bar button of their own).
+* **Slots 1-18 are the game's own** shortcut slots (the retail toolbar's items, saved on the server, and
+ AC's own keys); slots 19 and on are RynthDefective's. Click a slot to use it. A **healing kit** in one of
+ the game's slots is used **on you, one touch**, by RynthDefective when you click it on the bar; other
+ items are used as the game's toolbar would. The slot's game key (UseQuickSlot_N in Configure Keyboard)
+ is the game's own and goes straight to the game, as before.
+* **Independent of the game's toolbar** (per character, off by default): every slot on the bar is
+ RynthDefective's own. The game's 18 slots are not on it; clicks are one-touch (a kit on yourself, a
+ potion used, a weapon wielded) and keys are RynthCore hotkeys (`/rdef use N` for bar slot N). Turning it
+ on offers to copy the items in the game's 18 slots into the bar's slots 1-18 (nothing is copied unless you
+ say so); your own slots move after them, to 19 and on, with their keys, so the bar looks as it did. The
+ game's toolbar and its keys are not changed. Turning it off shows the game's 18 first again, RynthDefective's
+ slot 1 at 19.
+
+On an older engine the bar below is a script window, with its settings under its *Settings* button.
+
## What it does
**Slots.** The bar is a row (or grid) of slots, each holding one item: a healing kit, a stamina kit,
@@ -66,20 +95,27 @@ weapons you wielded are listed first (they are also in their kind's group).
```
/rdef show / hide the bar
+/rdef settings RynthDefective's settings window
+/rdef panels | selection show / hide the Game Panels buttons, the Selection window
/rdef use use the slot's item, or the carried item with that name
/rdef set [item name] put the selected item (or the named one) in a slot
/rdef clear empty a slot
/rdef bind bind a key (F9, Ctrl+1 ...) to the slot; /rdef unbind
/rdef weapons [search] show the weapon picker
/rdef fav make the selected weapon a favourite (or take it out)
-/rdef slots how many slots (1-24)
+/rdef slots how many slots the script-window bar shows (1-24)
/rdef list | status | help
```
+`/rdef use`, `set`, `clear`, `bind` take RynthDefective's own slot numbers (1-42): on the Shortcuts bar own
+slot N is bar slot 18+N, or bar slot N when the bar is independent of the game's toolbar.
+
## Settings
-Slots (1-24), slots per row, button size, picker row icon size, item icons on/off, counts and keys on/off,
-allow weapon swaps under RynthAi. Kept per character with the slots, favourites and recent weapons in
+Shortcuts bar: the windows shown, independent of the game's toolbar, slot picture size, allow weapon swaps
+under RynthAi, picker row icon size. Script-window bar: slots (1-24), slots per row, button size, picker row
+icon size, item icons on/off, counts and keys on/off, allow weapon swaps under RynthAi. Kept per character
+with the slots, favourites and recent weapons in
`\RynthDefective\characters\_.json`.
## Not in 0.1
@@ -89,5 +125,5 @@ changer (Defective has them).
## Needs
-RynthCore engine API 71 with ImGui for the windows (op level 2 for pictures; text buttons without it).
-`/rdef use` works on any engine with UseObject.
+RynthCore engine API 71 with ImGui for the windows (op level 2 for pictures; text buttons without it);
+API 90 for the Shortcuts bar, Game Panels and Selection. `/rdef use` works on any engine with UseObject.
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/RynthCore.Plugin.RynthDefective.csproj b/Plugins/RynthCore.Plugin.RynthDefective/RynthCore.Plugin.RynthDefective.csproj
index 9cff94c..bbeb96c 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/RynthCore.Plugin.RynthDefective.csproj
+++ b/Plugins/RynthCore.Plugin.RynthDefective/RynthCore.Plugin.RynthDefective.csproj
@@ -31,7 +31,7 @@
pictures) are checked first; so are the UseDone count (v63), wield/refusal info (v70) and
the chat parser the key binding goes through. Below v71 it still uses items (/rdef use). -->
66
- Item bar: one-touch use of kits, potions and weapons by slot or key, and a fast weapon picker.
+ Draws the Shortcuts bar (the game's 18 slots and its own), the Game Panels buttons and the Selection window: one-touch kits, potions and weapons by slot or key, and a fast weapon picker. Settings: the bar's gear or /rdef settings.
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.Bar.cs b/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.Bar.cs
index ef3b673..480a172 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.Bar.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.Bar.cs
@@ -7,6 +7,11 @@
// this plugin's slots. On an engine without v90's shortcuts the old script
// window bar stays.
//
+// Independent bar (DefSettings.IndependentBar, 2026-10-27): every slot is this
+// plugin's own (ShortcutBar/BarMapping.cs): AC's 18 aren't shown or mapped.
+// A healing kit in one of AC's slots is used on yourself by this plugin when
+// the slot is clicked (DefSession.UseRetailSlot).
+//
// The tick: the window's clicks (queued from the render thread), the snapshot
// it draws (4 times a second while it shows).
// ============================================================================
@@ -122,7 +127,58 @@ public sealed partial class RynthDefectivePlugin : IBarActions
if (_barActions.Count < 32) _barActions.Enqueue(action);
}
- private static bool IsRetail(int number) => number <= DefSettings.RetailSlots;
+ /// Bar slot is one of AC's 18 (never on an independent bar).
+ private bool IsRetail(int number) => BarMapping.IsRetail(number, _session.Settings.IndependentBar);
+
+ /// RynthDefective's own slot bar slot is (BarMapping).
+ private int OwnOf(int number) => BarMapping.OwnSlot(number, _session.Settings.IndependentBar);
+
+ private readonly uint[] _retailIds = new uint[DefSettings.RetailSlots], _retailSpells = new uint[DefSettings.RetailSlots];
+
+ /// The object in AC's slot (1-18) now; 0 = empty, a spell, or out of the world.
+ private uint RetailObject(int number) =>
+ Host.GetShortcuts(_retailIds, _retailSpells) >= number && number >= 1 ? _retailIds[number - 1] : 0;
+
+ /// AC's 18 slots for the session (the independent bar's copy).
+ private bool ReadRetail(uint[] ids, uint[] spells) => Host.GetShortcuts(ids, spells) >= DefSettings.RetailSlots;
+
+ // ── Keys of RynthDefective's own slots: the one seam ─────────────────────
+ //
+ // Every key bound to or taken off one of RynthDefective's own slots from the bar goes through
+ // these three: the bar's "Add a key" / "Remove" (usual bar slots past 18, every slot of an
+ // independent bar) and the keys the independent bar's copy moves with their slots. On the usual
+ // bar they are BindActionKey's command keys: the key also comes off AC's own actions in AC's
+ // keymap (so no key shows on two slots), which rewrites the keymap file and every client follows.
+ // An independent bar's keys are engine hotkeys only (BindCommandKeyOnly, plugin API v92): AC's
+ // keymap is never touched and no client changes its keys; the engine's hotkey takes the key
+ // before AC sees it. (/rdef bind and /rdef unbind type "/rc hotkey add|remove", unchanged.)
+
+ /// What binding to own slot would take from others.
+ /// On an independent bar AC's actions keep the key in AC's keymap, but the hotkey still takes it
+ /// first, so naming them is still the right warning.
+ private RynthKeyCheck CheckOwnSlotKey(int own, string key, out string message) =>
+ Host.CheckActionKey(DefCommandParser.UseCommand(own), key, out message);
+
+ /// Gives own slot ("/rdef use N") the key ; it comes off whatever had it.
+ private bool BindOwnSlotKey(int own, string key, out string message) =>
+ _session.Settings.IndependentBar
+ ? Host.BindCommandKeyOnly(DefCommandParser.UseCommand(own), key, out message)
+ : Host.BindActionKey(DefCommandParser.UseCommand(own), key, out message);
+
+ /// Takes off own slot .
+ private bool UnbindOwnSlotKey(int own, string key, out string message) =>
+ _session.Settings.IndependentBar
+ ? Host.UnbindCommandKeyOnly(DefCommandParser.UseCommand(own), key, out message)
+ : Host.UnbindActionKey(DefCommandParser.UseCommand(own), key, out message);
+
+ RynthKeyCheck IBarActions.CheckKey(BarSlot slot, string key, out string message) =>
+ slot.Retail ? Host.CheckActionKey("UseQuickSlot_" + slot.Number, key, out message) : CheckOwnSlotKey(slot.Own, key, out message);
+
+ bool IBarActions.BindKey(BarSlot slot, string key, out string message) =>
+ slot.Retail ? Host.BindActionKey("UseQuickSlot_" + slot.Number, key, out message) : BindOwnSlotKey(slot.Own, key, out message);
+
+ bool IBarActions.UnbindKey(BarSlot slot, string key, out string message) =>
+ slot.Retail ? Host.UnbindActionKey("UseQuickSlot_" + slot.Number, key, out message) : UnbindOwnSlotKey(slot.Own, key, out message);
// ── IBarActions (render thread: queue only) ─────────────────────────────
@@ -130,10 +186,15 @@ public sealed partial class RynthDefectivePlugin : IBarActions
{
if (IsRetail(number))
{
+ // A healing kit in AC's slot: used on yourself here (the use controller, one touch, nothing
+ // selected), not handed to AC. Everything else is AC's own toolbar use. This is the bar's
+ // click only: the slot's key (AC's UseQuickSlot_N) is read by AC itself and still goes
+ // straight to AC, unchanged.
+ if (_session.UseRetailSlot(number, RetailObject(number))) return;
if (!Host.ShortcutAction(RynthShortcutOp.Use, number - 1)) _session.SetStatus($"Slot {number} can't be used now.", warning: true);
return;
}
- string? problem = _session.UseSlot(number - DefSettings.RetailSlots);
+ string? problem = _session.UseSlot(OwnOf(number));
if (problem != null) { _session.SetStatus(problem, warning: true); Print(problem); }
});
@@ -147,7 +208,7 @@ public sealed partial class RynthDefectivePlugin : IBarActions
_nextBarBuildMs = 0;
return;
}
- Print(_session.SetFromSelected(number - DefSettings.RetailSlots));
+ Print(_session.SetFromSelected(OwnOf(number)));
_nextBarBuildMs = 0;
});
@@ -159,7 +220,7 @@ public sealed partial class RynthDefectivePlugin : IBarActions
_nextBarBuildMs = 0;
return;
}
- Print(_session.ClearSlot(number - DefSettings.RetailSlots));
+ Print(_session.ClearSlot(OwnOf(number)));
_nextBarBuildMs = 0;
});
@@ -170,7 +231,7 @@ public sealed partial class RynthDefectivePlugin : IBarActions
// The retail toolbar's own "make a shortcut": AC checks the item (and says why not).
if (!Host.ShortcutAction(RynthShortcutOp.Set, number - 1, objectId)) Print($"Slot {number} can't be changed now.");
}
- else Print(_session.SetFromId(number - DefSettings.RetailSlots, objectId));
+ else Print(_session.SetFromId(OwnOf(number), objectId));
_nextBarBuildMs = 0;
});
@@ -191,5 +252,7 @@ public sealed partial class RynthDefectivePlugin : IBarActions
public void ShowWeapons() => QueueBar(() => ShowPicker(true));
+ public void ShowSettings() => QueueBar(() => ShowSettingsWindow(true));
+
public void Hide() => QueueBar(() => Host.SetPanelOpen(ShortcutBarWindow.Title, RynthPanelOpen.Close));
}
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs b/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs
index 006fa75..51ed19a 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/RynthDefectivePlugin.cs
@@ -42,7 +42,8 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
private HostDefWorld? _world;
private BarView? _bar;
private PickerView? _picker;
- private UiWindow? _barWindow, _pickerWindow;
+ private BarSettingsView? _settingsView;
+ private UiWindow? _barWindow, _pickerWindow, _settingsWindow;
private bool _inWorld;
private bool _identityKnown;
@@ -69,6 +70,10 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
_session.SelectedId = () => Host.HasGetSelectedItemId ? Host.GetSelectedItemId() : 0;
_session.RunChat = line => Host.HasInvokeChatParser && Host.InvokeChatParser(line);
_session.Save = RequestSave;
+ _session.ReadRetail = ReadRetail;
+ _session.ObjectName = id => Host.TryGetObjectName(id, out string n) && n.Length > 0 ? n : null;
+ _session.CommandKeys = command => Host.HasKeyBinding ? Host.GetActionKeys(command) : string.Empty;
+ _session.BindOwnKey = (own, key) => Host.HasKeyBinding && BindOwnSlotKey(own, key, out _);
_session.Use.Say = text => { _session.SetStatus(text); Host.Log("[RynthDefective] " + text); };
_session.Use.Warn = text => { _session.SetStatus(text, warning: true); Print(text); };
@@ -81,6 +86,18 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
_pickerWindow = _ui.Add(new UiWindow("RynthDefective/Weapons", "Defective Weapons") { DefaultWidth = 360f, DefaultHeight = 480f, MinWidth = 260f, MinHeight = 160f });
_bar.RequestFit = FitBar;
_bar.ShowPicker = () => ShowPicker(true);
+ // The settings for the Shortcuts bar: the old bar that held them stays shut while it is used.
+ // No RynthBar button or Scripts menu line: the bar's gear and right-click menu, and /rdef settings.
+ _settingsView = new BarSettingsView(_session)
+ {
+ WindowShown = PanelShown,
+ ShowWindow = (title, show) => Host.SetPanelOpen(title, show ? RynthPanelOpen.Open : RynthPanelOpen.Close),
+ Tell = text => { _session.SetStatus(text); Print(text); _nextBarBuildMs = 0; },
+ };
+ _settingsWindow = _ui.Add(new UiWindow("RynthDefective/Settings", "Defective Settings")
+ {
+ DefaultWidth = 380f, DefaultHeight = 470f, MinWidth = 280f, MinHeight = 200f, ShowInBar = false,
+ });
Host.Log($"[RynthDefective] {Version} initialized. /rdef shows or hides the bar; /rdef use ; /rdef help. Files: {_store.Root}");
return 0;
}
@@ -104,8 +121,9 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
_session.Use.Reset();
_world?.Reset();
_barView = RynthCore.Plugin.RynthDefective.ShortcutBar.BarSnapshot.NotReady;
- foreach (UiWindow? w in new[] { _barWindow, _pickerWindow })
+ foreach (UiWindow? w in new[] { _barWindow, _pickerWindow, _settingsWindow })
if (w != null) { w.Visible = false; w.NeedsPass = true; }
+ _session.DeclineCopy();
_ui.SubmitEmpty(Host);
}
@@ -169,6 +187,9 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
if (UsesShortcutBar) Host.SetPanelOpen(RynthCore.Plugin.RynthDefective.ShortcutBar.SelectionWindow.Title, RynthPanelOpen.Toggle);
else Print("This RynthCore can't show the selection window (it needs plugin API v90).");
break;
+ case DefVerb.Settings:
+ ShowSettingsWindow(true);
+ break;
case DefVerb.Panels:
if (UsesPanelButtons) Host.SetPanelOpen(RynthCore.Plugin.RynthDefective.ShortcutBar.PanelButtonsWindow.Title, RynthPanelOpen.Toggle);
else Print("This RynthCore can't open the game's panels from buttons (it needs plugin API v90).");
@@ -218,6 +239,9 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
private void PrintHelp()
{
Print(DefCommandParser.Usage);
+ if (UsesShortcutBar)
+ Print("RynthDefective draws the Shortcuts bar, the Game Panels buttons and the Selection window. Its settings: /rdef settings, "
+ + "or the gear on the bar; right-click the bar's title to show or hide Game Panels and Selection.");
Print("A key for a slot: /rdef bind 1 F9 (or Edit slots in the bar). Any item by name from Settings > Hotkeys: /rc hotkey add F9 /rdef use Stamina Kit.");
}
@@ -264,6 +288,35 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
// ── Windows ─────────────────────────────────────────────────────────────
+ ///
+ /// RynthDefective's settings: their own window with the Shortcuts bar; on an engine without it, the
+ /// old bar's Settings section (that bar is the one in use there).
+ ///
+ private void ShowSettingsWindow(bool visible)
+ {
+ if (!UsesShortcutBar)
+ {
+ if (_barWindow == null || _bar == null) return;
+ _barWindow.Visible = visible;
+ _bar.SettingsOpen = visible;
+ FitBar();
+ NoteNoUi(visible);
+ return;
+ }
+ if (_settingsWindow == null) return;
+ _settingsWindow.Visible = visible;
+ _settingsWindow.NeedsPass = true;
+ NoteNoUi(visible);
+ }
+
+ /// Whether one of the windows RynthDefective draws shows (by its title); null = not on this engine.
+ private bool? PanelShown(string title)
+ {
+ if (!UsesShortcutBar || (title == ShortcutBar.PanelButtonsWindow.Title && !UsesPanelButtons)) return null;
+ int state = Host.SetPanelOpen(title, RynthPanelOpen.Ask);
+ return state < 0 ? null : state == 1;
+ }
+
private void ShowPicker(bool visible)
{
if (_pickerWindow == null) return;
@@ -285,6 +338,7 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
{
if (_barWindow != null) _barWindow.NeedsPass = true;
if (_pickerWindow != null) _pickerWindow.NeedsPass = true;
+ if (_settingsWindow != null) _settingsWindow.NeedsPass = true;
}
/// A weapon (or shield) went into the hands: first in the picker's recent list.
@@ -328,14 +382,21 @@ public sealed partial class RynthDefectivePlugin : RynthPluginBase
TickBar(now);
TickSelection(now);
- // With the shortcut bar the old script-window bar stays shut (the weapon picker is still one).
- if (UsesShortcutBar && _barWindow != null && _barWindow.Visible) { _barWindow.Visible = false; _barWindow.NeedsPass = true; }
+ // With the shortcut bar the old script-window bar stays shut (the weapon picker is still one), and
+ // has no RynthBar button (one that opened a window shut again at once). Its settings have their
+ // own window then (_settingsWindow).
+ if (_barWindow != null)
+ {
+ if (UsesShortcutBar && _barWindow.Visible) { _barWindow.Visible = false; _barWindow.NeedsPass = true; }
+ _barWindow.ShowInBar = !UsesShortcutBar;
+ }
if (!Host.HasUi || _barWindow == null || _pickerWindow == null || _bar == null || _picker == null) return;
if (_session.Use.HasPending || _session.Use.InFlight) _barWindow.NeedsPass = _pickerWindow.NeedsPass = true;
if (!_session.IconsAvailable) RefreshIconSupport();
Record(_barWindow, now, _bar.Draw);
Record(_pickerWindow, now, _picker.Draw);
+ if (_settingsWindow != null && _settingsView != null) Record(_settingsWindow, now, _settingsView.Draw);
_ui.Submit(Host, now);
if (_identityKnown)
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarMapping.cs b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarMapping.cs
new file mode 100644
index 0000000..999e24f
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarMapping.cs
@@ -0,0 +1,111 @@
+// ============================================================================
+// RynthDefective - ShortcutBar/BarMapping.cs
+// Which slot a shortcut bar slot stands for, pure (the tests run it offline).
+//
+// usual bar slots 1-18 are AC's own shortcut slots (the retail
+// toolbar's, saved on the server; keys AC's UseQuickSlot_N),
+// bar slot 18+N is RynthDefective's own slot N.
+// independent (DefSettings.IndependentBar) every bar slot N is
+// RynthDefective's own slot N: AC's 18 are not on the bar,
+// clicks go through the use controller, keys are the engine's
+// hotkeys running /rdef use N.
+//
+// Also: the healing kit in one of AC's slots that a click uses on yourself
+// (RetailKit), and copying AC's 18 slots into the own ones (CopyRetail).
+// ============================================================================
+
+using System;
+using System.Collections.Generic;
+using RynthCore.Plugin.RynthDefective.Items;
+using RynthCore.Plugin.RynthDefective.Model;
+
+namespace RynthCore.Plugin.RynthDefective.ShortcutBar;
+
+/// What copying AC's 18 slots into RynthDefective's own did ().
+internal sealed record BarCopyResult(int Copied, int Skipped, IReadOnlyList<(int From, int To)> Moved, string? Refused);
+
+internal static class BarMapping
+{
+ /// Bar slot (1-based) is one of AC's own shortcut slots.
+ public static bool IsRetail(int number, bool independent) =>
+ !independent && number >= 1 && number <= DefSettings.RetailSlots;
+
+ /// RynthDefective's own slot (1-based) bar slot is; 0 for one of AC's.
+ public static int OwnSlot(int number, bool independent) =>
+ IsRetail(number, independent) ? 0 : independent ? number : number - DefSettings.RetailSlots;
+
+ /// The bar slot RynthDefective's own slot shows in.
+ public static int BarNumber(int own, bool independent) => independent ? own : own + DefSettings.RetailSlots;
+
+ /// What a bar slot's keys run: AC's keymap action for one of AC's slots, the engine command for an own one.
+ public static string KeyAction(int number, bool independent) =>
+ IsRetail(number, independent) ? "UseQuickSlot_" + number : DefCommandParser.UseCommand(OwnSlot(number, independent));
+
+ ///
+ /// A click on one of AC's slots holding : the healing (or stamina, mana)
+ /// kit to use on yourself through the use controller, or null for AC's own use of the slot (a potion,
+ /// a weapon, a spell, an item not in the pack). The kit test is the use controller's own
+ /// (ItemKinds.Classify: the healer bit, else RynthAi's " Kit" name test).
+ ///
+ public static CarriedItem? RetailKit(uint objectId, IReadOnlyList items)
+ {
+ if (objectId == 0) return null;
+ foreach (CarriedItem it in items)
+ if (it.Id == objectId) return ItemKinds.Classify(it) == ItemKind.Kit ? it : null;
+ return null;
+ }
+
+ ///
+ /// Copies AC's 18 slots (, , slot 1 first) into the own
+ /// slots 1-18, so an independent bar looks as the usual one did: the own slots that were after AC's
+ /// (own N at bar 18+N) move to own 18+N, where an independent bar shows them.
+ /// lists the moves of the slots that held something (their "/rdef use N" keys go with them). A spell, or
+ /// an item can't name, can't go in an own slot: that slot stays empty (Skipped).
+ /// Refused (nothing changed) when an own slot past 24 holds something: there is no room to move it.
+ ///
+ public static BarCopyResult CopyRetail(List own, ReadOnlySpan ids, ReadOnlySpan spells, Func resolve)
+ {
+ const int retail = DefSettings.RetailSlots, room = DefSettings.SlotsMax - DefSettings.RetailSlots;
+ for (int n = room + 1; n <= own.Count; n++)
+ if (!own[n - 1].Empty)
+ return new BarCopyResult(0, 0, Array.Empty<(int, int)>(), $"Your slot {n} holds {own[n - 1].Item!.FullName}: there is no room to move "
+ + $"slots {room + 1}-{DefSettings.SlotsMax} after the game's {retail}. Empty them (or copy by hand) first.");
+
+ var next = DefData.NewSlots();
+ var moved = new List<(int, int)>();
+ for (int n = 1; n <= Math.Min(room, own.Count); n++)
+ {
+ if (own[n - 1].Empty) continue;
+ next[retail + n - 1] = own[n - 1];
+ moved.Add((n, retail + n));
+ }
+ int copied = 0, skipped = 0;
+ for (int i = 0; i < retail; i++)
+ {
+ uint id = i < ids.Length ? ids[i] : 0, spell = i < spells.Length ? spells[i] : 0;
+ if (id == 0)
+ {
+ if (spell != 0) skipped++;
+ continue;
+ }
+ ItemRef? r = resolve(id);
+ if (r == null || string.IsNullOrWhiteSpace(r.Name)) { skipped++; continue; }
+ next[i] = new DefSlot { Item = r, Mode = UseMode.Auto };
+ copied++;
+ }
+ for (int i = 0; i < own.Count && i < next.Count; i++) own[i] = next[i];
+ return new BarCopyResult(copied, skipped, moved, null);
+ }
+
+ /// How many of AC's slots hold an item (spells can't be copied, so they don't count).
+ public static int RetailItems(ReadOnlySpan ids)
+ {
+ int n = 0;
+ foreach (uint id in ids) if (id != 0) n++;
+ return n;
+ }
+
+ /// "F9, Ctrl+1" as its keys.
+ public static string[] SplitKeys(string keys) =>
+ string.IsNullOrEmpty(keys) ? Array.Empty() : keys.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+}
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs
index 113974c..2ebccf0 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/BarSnapshot.cs
@@ -9,6 +9,8 @@
// UseQuickSlot_1-18. Slots 19 and on are this plugin's own (DefData.Slots),
// their keys the engine's hotkeys (/rdef use N). The player chooses how many
// the bar shows (DefSettings.BarSlots).
+// An independent bar (DefSettings.IndependentBar) has no AC slots: every slot
+// N is own slot N (BarMapping), and AC's toolbar isn't read at all.
// ============================================================================
using System;
@@ -24,10 +26,11 @@ namespace RynthCore.Plugin.RynthDefective.ShortcutBar;
/// How a slot's count line reads: plain, in hand / worn, or nothing carried.
internal enum CountTone { Plain, InHand, Missing }
-/// One slot as drawn.
+/// One slot as drawn. Own: RynthDefective's own slot number it is (0 for one of AC's).
internal sealed record BarSlot(
int Number,
bool Retail,
+ int Own,
uint ObjectId,
uint SpellId,
string Name,
@@ -40,7 +43,8 @@ internal sealed record BarSlot(
public bool Empty => ObjectId == 0 && SpellId == 0 && Name.Length == 0;
}
-internal sealed record BarSnapshot(BarSlot[] Slots, bool Ready, int IconSize)
+/// The bar as drawn. Independent: every slot is RynthDefective's own (DefSettings.IndependentBar).
+internal sealed record BarSnapshot(BarSlot[] Slots, bool Ready, int IconSize, bool Independent = false)
{
public static readonly BarSnapshot NotReady = new(Array.Empty(), false, 36);
}
@@ -76,15 +80,23 @@ internal sealed class BarSnapshotBuilder
public BarSnapshot Build(DefSession session, IReadOnlyList items, long now)
{
- if (!_host.HasShortcuts || _host.GetShortcuts(_ids, _spells) == 0) return BarSnapshot.NotReady;
- RefreshKeys(now);
+ if (!_host.HasShortcuts) return BarSnapshot.NotReady;
DefSettings st = session.Settings;
+ if (st.IndependentBar)
+ {
+ // Every slot is RynthDefective's own: AC's toolbar isn't read or shown (BarMapping).
+ var own = new BarSlot[st.BarSlots];
+ for (int n = 1; n <= st.BarSlots; n++) own[n - 1] = Own(n, BarMapping.OwnSlot(n, true), true, session, items, _host);
+ return new BarSnapshot(own, true, st.ButtonSize, true);
+ }
+ if (_host.GetShortcuts(_ids, _spells) == 0) return BarSnapshot.NotReady;
+ RefreshKeys(now);
var byId = new Dictionary(items.Count);
foreach (CarriedItem it in items) byId[it.Id] = it;
var slots = new BarSlot[st.BarSlots];
for (int n = 1; n <= st.BarSlots; n++)
- slots[n - 1] = n <= DefSettings.RetailSlots ? Retail(n, byId) : Own(n, session, items, _host);
+ slots[n - 1] = BarMapping.IsRetail(n, false) ? Retail(n, byId) : Own(n, BarMapping.OwnSlot(n, false), false, session, items, _host);
return new BarSnapshot(slots, true, st.ButtonSize);
}
@@ -94,7 +106,7 @@ internal sealed class BarSnapshotBuilder
string allKeys = _keys[n - 1];
string key = FirstKey(allKeys);
if (id == 0 && spell == 0)
- return new BarSlot(n, true, 0, 0, string.Empty, string.Empty, CountTone.Plain, key, allKeys,
+ return new BarSlot(n, true, 0, 0, 0, string.Empty, string.Empty, CountTone.Plain, key, allKeys,
$"Slot {n} (the game's own): empty.{KeysLine(allKeys)}\nRight-click: put the selected item here, or change its keys.");
string name;
string count = string.Empty;
@@ -114,26 +126,26 @@ internal sealed class BarSnapshotBuilder
else name = $"Spell {spell}";
string tip = $"Slot {n} (the game's own): {name}{(count.Length > 0 ? " - " + count : "")}.{KeysLine(allKeys)}\n" +
"Click: use it, as its key does. Right-click: change the slot or its keys.";
- return new BarSlot(n, true, id, id == 0 ? spell : 0, name, count, tone, key, allKeys, tip);
+ return new BarSlot(n, true, 0, id, id == 0 ? spell : 0, name, count, tone, key, allKeys, tip);
}
- private static BarSlot Own(int n, DefSession session, IReadOnlyList items, RynthCoreHost host)
+ private static BarSlot Own(int n, int own, bool independent, DefSession session, IReadOnlyList items, RynthCoreHost host)
{
- int own = n - DefSettings.RetailSlots;
- DefSlot slot = own <= session.Data.Slots.Count ? session.Data.Slots[own - 1] : new DefSlot();
+ DefSlot slot = own >= 1 && own <= session.Data.Slots.Count ? session.Data.Slots[own - 1] : new DefSlot();
// Every key of "/rdef use N" (the engine's hotkeys), else the one bound to the item by name.
string all = host.HasKeyBinding ? host.GetActionKeys(DefCommandParser.UseCommand(own)) : string.Empty;
string key = all.Length > 0 ? FirstKey(all) : session.KeyOfSlot(own) ?? string.Empty;
if (all.Length == 0) all = key;
+ string whose = independent ? "RynthCore's: this bar is independent of the game's toolbar" : "RynthCore's: the game holds 18";
if (slot.Item == null)
- return new BarSlot(n, false, 0, 0, string.Empty, string.Empty, CountTone.Plain, SlotText.ShortKey(key), all,
- $"Slot {n} (RynthCore's: the game holds 18): empty.{KeysLine(all)}\nRight-click: put the selected item here, or change its keys.");
+ return new BarSlot(n, false, own, 0, 0, string.Empty, string.Empty, CountTone.Plain, SlotText.ShortKey(key), all,
+ $"Slot {n} ({whose}): empty.{KeysLine(all)}\nRight-click: put the selected item here, or change its keys.");
SlotStatus s = ItemMatcher.Status(slot.Item, items);
string count = SlotText.Count(s, out uint color);
CountTone tone = color == SlotText.InHand ? CountTone.InHand : color == SlotText.Missing ? CountTone.Missing : CountTone.Plain;
string tip = SlotText.Tooltip(n, slot.Item, s, slot.Mode, key.Length > 0 ? key : null)
- + "\n(RynthCore's slot: the game's toolbar holds 18.)";
- return new BarSlot(n, false, s.Item?.Id ?? 0, 0, s.Item?.FullName ?? slot.Item.FullName, count, tone,
+ + $"\n({whose}.)";
+ return new BarSlot(n, false, own, s.Item?.Id ?? 0, 0, s.Item?.FullName ?? slot.Item.FullName, count, tone,
SlotText.ShortKey(key), all, tip);
}
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs
index 2869207..f04c5e5 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/ShortcutBar/ShortcutBarWindow.cs
@@ -5,7 +5,12 @@
// the instrument look of RynthAi's dashboard and the player's colour theme.
//
// header SHORTCUTS and the slot count (the drag handle; Ctrl+wheel: the
-// size), then Edit, Weapons (the weapon picker) and Hide.
+// size; right-click: the bar's menu), then Edit, Weapons (the
+// weapon picker), Settings (RynthDefective's settings window) and
+// Hide.
+// menu right-click the header, or the end of a slot's menu: Settings...,
+// and show / hide the Game Panels buttons and the Selection window
+// (they have no RynthBar button of their own).
// slots the item's picture, its key in the top-left corner (AC's keymap
// for slots 1-18, the engine's hotkeys after), the count or "in
// hand" under it. They fill the window's width and wrap: drag the
@@ -18,6 +23,8 @@
// it. A slot 1-18 key is AC's own (its keymap, so the retail toolbar answers
// to it too, in every client); a key past 18 is an engine hotkey running
// /rdef use N. A key comes off whatever had it, after the player says so.
+// An independent bar (DefSettings.IndependentBar) has only RynthDefective's
+// own slots: every key is an engine hotkey (BarMapping, BarSlot.Own).
//
// AC's render thread. Reads the snapshot the tick built; every click is
// queued for the tick (IBarActions).
@@ -46,7 +53,15 @@ internal interface IBarActions
/// A key was bound or removed: the bar asks for its keys again.
void KeysChanged();
void ShowWeapons();
+ /// RynthDefective's settings window (the weapon swap switch, the independent bar ...).
+ void ShowSettings();
void Hide();
+
+ // A slot's keys (any thread: the engine queues the change). AC's slot: AC's keymap action
+ // UseQuickSlot_N; one of RynthDefective's own: its seam for own-slot keys (BindOwnSlotKey).
+ RynthKeyCheck CheckKey(BarSlot slot, string key, out string message);
+ bool BindKey(BarSlot slot, string key, out string message);
+ bool UnbindKey(BarSlot slot, string key, out string message);
}
internal sealed class ShortcutBarWindow
@@ -133,6 +148,7 @@ internal sealed class ShortcutBarWindow
ImGui.SetCursorScreenPos(origin);
ImGui.Dummy(new Vector2(width, height));
SlotMenu(view);
+ BarMenu();
if (_openKeyPopup)
{
_openKeyPopup = false;
@@ -156,13 +172,16 @@ internal sealed class ShortcutBarWindow
private float Header(ImDrawListPtr dl, BarSnapshot view, float x0, float y, float w)
{
float h = Px(HeaderH), chip = Px(ChipSize);
- const int chips = 3;
+ const int chips = 4;
float chipsW = chips * chip + (chips - 1) * Px(1);
ImGui.SetCursorScreenPos(new Vector2(x0, y));
ImGui.InvisibleButton("##sb_drag", new Vector2(Math.Max(1, w - chipsW - Px(4)), h));
+ bool menu = ImGui.IsItemClicked(ImGuiMouseButton.Right);
_host.PanelDragWithLastItem();
- SafeImGui.SetItemTooltip("Drag to move the bar. Ctrl+wheel here: bigger or smaller.\nDrag the window's edge to change how many slots fit in a row.");
+ if (menu) ImGui.OpenPopup(BarMenuId);
+ SafeImGui.SetItemTooltip("Drag to move the bar. Ctrl+wheel here: bigger or smaller. Right-click: settings, Game Panels, Selection.\n"
+ + "Drag the window's edge to change how many slots fit in a row.");
ImFontPtr tf = Font(RynthUiFont.NarrowBold11);
float size = Fs(tf) * 10f / 11f;
@@ -179,6 +198,10 @@ internal sealed class ShortcutBarWindow
if (Chip("##sb_weapons", RynthIcons.Sword, new Vector2(cx, cy), _faint, "Weapons: every weapon and wand you carry, wield one with a click."))
_act.ShowWeapons();
cx += chip + Px(1);
+ if (Chip("##sb_settings", RynthIcons.Gear, new Vector2(cx, cy), _faint,
+ "Settings (/rdef settings): weapon swaps under RynthAi, a bar independent of the game's toolbar,\nand showing the Game Panels buttons and the Selection window."))
+ _act.ShowSettings();
+ cx += chip + Px(1);
if (Chip("##sb_hide", RynthIcons.X, new Vector2(cx, cy), _faint, "Hide the bar (/rdef shows it again). Its keys keep working."))
_act.Hide();
return y + h;
@@ -227,7 +250,7 @@ internal sealed class ShortcutBarWindow
int col = i % perRow, row = i / perRow;
Vector2 p = new(MathF.Round(x0 + col * (cell + gap)), MathF.Round(y + row * (cell + gap)));
if (i < view.Slots.Length) Slot(dl, view.Slots[i], p, cell);
- else EditButton(dl, i == view.Slots.Length ? -1 : 1, p, cell, view.Slots.Length);
+ else EditButton(dl, i == view.Slots.Length ? -1 : 1, p, cell, view.Slots.Length, view.Independent);
}
return y + rows * (cell + gap) - gap;
}
@@ -306,7 +329,7 @@ internal sealed class ShortcutBarWindow
}
}
- private void EditButton(ImDrawListPtr dl, int delta, Vector2 p, float cell, int count)
+ private void EditButton(ImDrawListPtr dl, int delta, Vector2 p, float cell, int count, bool independent)
{
Vector2 size = new(cell, cell);
bool can = delta < 0 ? count > DefSettings.BarSlotsMin : count < DefSettings.BarSlotsMax;
@@ -315,6 +338,7 @@ internal sealed class ShortcutBarWindow
bool hot = can && ImGui.IsItemHovered();
SafeImGui.SetItemTooltip(delta < 0
? "One slot fewer (the last one's item stays: add the slot back and it is there)."
+ : independent ? "One more slot (RynthCore's: this bar is independent of the game's toolbar)."
: count < DefSettings.RetailSlots ? "One more slot (the game's own, up to 18)."
: "One more slot (RynthCore's: the game's toolbar holds 18).");
float r = Px(3);
@@ -348,55 +372,100 @@ internal sealed class ShortcutBarWindow
if (!_host.HasKeyBinding)
{
ImGui.TextDisabled(s.AllKeys.Length > 0 ? "Keys: " + s.AllKeys
- : s.Retail ? "No key: bind UseQuickSlot_" + s.Number + " in Configure Keyboard." : "No key: /rdef bind " + (s.Number - DefSettings.RetailSlots) + " F9");
- return;
+ : s.Retail ? "No key: bind UseQuickSlot_" + s.Number + " in Configure Keyboard." : "No key: /rdef bind " + s.Own + " F9");
}
- string[] keys = SplitKeys(s.AllKeys);
- ImGui.TextDisabled(keys.Length == 0 ? "No key yet" : keys.Length == 1 ? "Key" : "Keys");
- foreach (string key in keys)
+ else
{
- if (!ImGui.MenuItem("Remove " + key)) continue;
- if (_host.UnbindActionKey(KeyAction(s.Number), key, out string why)) _act.KeysChanged();
- else ShowKeyMessage(s.Number, why);
+ string[] keys = SplitKeys(s.AllKeys);
+ ImGui.TextDisabled(keys.Length == 0 ? "No key yet" : keys.Length == 1 ? "Key" : "Keys");
+ foreach (string key in keys)
+ {
+ if (!ImGui.MenuItem("Remove " + key)) continue;
+ if (_act.UnbindKey(s, key, out string why)) _act.KeysChanged();
+ else ShowKeyMessage(s, why);
+ }
+ if (ImGui.MenuItem(keys.Length == 0 ? "Add a key..." : "Add another key..."))
+ StartKeyCapture(s);
+ SafeImGui.SetItemTooltip(s.Retail
+ ? "Press the key: it becomes this slot's in the game's own keymap, so the retail toolbar and every client use it too."
+ : "Press the key: a RynthCore hotkey for this slot (/rdef use " + s.Own + ").");
}
- if (ImGui.MenuItem(keys.Length == 0 ? "Add a key..." : "Add another key..."))
- StartKeyCapture(s.Number);
- SafeImGui.SetItemTooltip(s.Retail
- ? "Press the key: it becomes this slot's in the game's own keymap, so the retail toolbar and every client use it too."
- : "Press the key: a RynthCore hotkey for this slot (the game's toolbar holds 18).");
+ ImGui.Separator();
+ BarMenuItems();
}
finally { ImGui.EndPopup(); }
}
+ // ── The bar's menu (right-click the header; also at the end of a slot's menu) ──
+
+ private const string BarMenuId = "##sb_bar_menu";
+
+ private void BarMenu()
+ {
+ if (!ImGui.IsPopupOpen(BarMenuId)) return;
+ ImGui.PushStyleColor(ImGuiCol.PopupBg, WithAlpha(_bg, 0xFA));
+ ImGui.PushStyleColor(ImGuiCol.Border, _line);
+ ImGui.PushStyleVar(ImGuiStyleVar.PopupRounding, Px(4));
+ ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(Px(6), Px(5)));
+ bool open = ImGui.BeginPopup(BarMenuId);
+ ImGui.PopStyleVar(2);
+ ImGui.PopStyleColor(2);
+ if (!open) return;
+ try
+ {
+ ImGui.TextDisabled("RynthDefective's Shortcuts bar");
+ ImGui.Separator();
+ BarMenuItems();
+ ImGui.Separator();
+ if (ImGui.MenuItem("Weapons...")) _act.ShowWeapons();
+ if (ImGui.MenuItem("Hide the bar")) _act.Hide();
+ SafeImGui.SetItemTooltip("/rdef, or the lightning button on the RynthCore bar, shows it again. Its keys keep working.");
+ }
+ finally { ImGui.EndPopup(); }
+ }
+
+ /// Settings..., and the two windows RynthDefective draws besides the bar (no RynthBar buttons of their own).
+ private void BarMenuItems()
+ {
+ if (ImGui.MenuItem("Settings...")) _act.ShowSettings();
+ SafeImGui.SetItemTooltip("RynthDefective's settings (/rdef settings): weapon swaps under RynthAi, a bar independent of the game's toolbar.");
+ if (_host.HasAcPanels) PanelToggle(PanelButtonsWindow.Title, "Game panel buttons",
+ "The buttons for the game's own panels (pack, spellbook, map ...), first in the bottom-right corner (/rdef panels).");
+ PanelToggle(SelectionWindow.Title, "Selection", "What is selected, how far and which way, and a creature's health (/rdef selection).");
+ }
+
+ private void PanelToggle(string title, string label, string tip)
+ {
+ int state = _host.SetPanelOpen(title, RynthPanelOpen.Ask);
+ if (ImGui.MenuItem(label, null, state == 1, state >= 0)) _host.SetPanelOpen(title, RynthPanelOpen.Toggle);
+ SafeImGui.SetItemTooltip(tip);
+ }
+
// ── Keys: "press a key" ───────────────────────────────────────────────
private enum KeyStep { Waiting, Confirm, Message }
private const string KeyPopupId = "##sb_key_popup";
private bool _openKeyPopup;
- private int _keySlot;
+ private BarSlot? _keySlot; // the slot as it was drawn when the key was asked for (its mapping: Retail / Own)
private KeyStep _keyStep;
private string _keyName = string.Empty, _keyText = string.Empty;
- /// The action a slot's keys run: AC's UseQuickSlot_N for 1-18, the engine command for the rest.
- public static string KeyAction(int number) =>
- number <= DefSettings.RetailSlots ? "UseQuickSlot_" + number : DefCommandParser.UseCommand(number - DefSettings.RetailSlots);
-
private static string[] SplitKeys(string keys) =>
keys.Length == 0 ? Array.Empty() : keys.Split(", ", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
- private void StartKeyCapture(int number)
+ private void StartKeyCapture(BarSlot slot)
{
- _keySlot = number;
+ _keySlot = slot;
_keyStep = KeyStep.Waiting;
_keyName = _keyText = string.Empty;
_host.BeginKeyCapture();
_openKeyPopup = true;
}
- private void ShowKeyMessage(int number, string text)
+ private void ShowKeyMessage(BarSlot slot, string text)
{
- _keySlot = number;
+ _keySlot = slot;
_keyStep = KeyStep.Message;
_keyText = text;
_openKeyPopup = true;
@@ -406,7 +475,7 @@ internal sealed class ShortcutBarWindow
{
if (!ImGui.IsPopupOpen(KeyPopupId))
{
- if (_keyStep == KeyStep.Waiting && _keySlot != 0) { _host.CancelKeyCapture(); _keySlot = 0; } // clicked away
+ if (_keyStep == KeyStep.Waiting && _keySlot != null) { _host.CancelKeyCapture(); _keySlot = null; } // clicked away
return;
}
ImGui.PushStyleColor(ImGuiCol.PopupBg, WithAlpha(_bg, 0xFA));
@@ -419,8 +488,10 @@ internal sealed class ShortcutBarWindow
if (!open) return;
try
{
+ BarSlot? ks = _keySlot;
+ if (ks == null) { ImGui.CloseCurrentPopup(); return; }
ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + Px(230));
- ImGui.TextDisabled($"Slot {_keySlot}{(_keySlot <= DefSettings.RetailSlots ? " (the game's own)" : " (RynthCore's)")}");
+ ImGui.TextDisabled($"Slot {ks.Number}{(ks.Retail ? " (the game's own)" : " (RynthCore's)")}");
switch (_keyStep)
{
case KeyStep.Waiting:
@@ -432,10 +503,10 @@ internal sealed class ShortcutBarWindow
if (text.Length > 0) ImGui.TextColored(new Vector4(0.98f, 0.5f, 0.46f, 1f), text);
break;
}
- if (got == RynthKeyCapture.Cancelled) { _keySlot = 0; ImGui.CloseCurrentPopup(); break; }
+ if (got == RynthKeyCapture.Cancelled) { _keySlot = null; ImGui.CloseCurrentPopup(); break; }
_keyName = text;
- RynthKeyCheck check = _host.CheckActionKey(KeyAction(_keySlot), _keyName, out string msg);
- if (check == RynthKeyCheck.Free) Bind();
+ RynthKeyCheck check = _act.CheckKey(ks, _keyName, out string msg);
+ if (check == RynthKeyCheck.Free) Bind(ks);
else
{
_keyStep = check == RynthKeyCheck.Taken ? KeyStep.Confirm : KeyStep.Message;
@@ -444,18 +515,18 @@ internal sealed class ShortcutBarWindow
break;
case KeyStep.Confirm:
SafeImGui.Text(_keyText);
- ImGui.TextDisabled($"Use it for slot {_keySlot} instead? It comes off those.");
- if (ImGui.Button($"Use {_keyName} here")) Bind();
+ ImGui.TextDisabled($"Use it for slot {ks.Number} instead? It comes off those.");
+ if (ImGui.Button($"Use {_keyName} here")) Bind(ks);
ImGui.SameLine();
- if (ImGui.Button("Another key")) StartKeyCapture(_keySlot);
+ if (ImGui.Button("Another key")) StartKeyCapture(ks);
ImGui.SameLine();
- if (ImGui.Button("Cancel")) { _keySlot = 0; ImGui.CloseCurrentPopup(); }
+ if (ImGui.Button("Cancel")) { _keySlot = null; ImGui.CloseCurrentPopup(); }
break;
case KeyStep.Message:
SafeImGui.Text(_keyText);
- if (ImGui.Button("Another key")) StartKeyCapture(_keySlot);
+ if (ImGui.Button("Another key")) StartKeyCapture(ks);
ImGui.SameLine();
- if (ImGui.Button("Close")) { _keySlot = 0; ImGui.CloseCurrentPopup(); }
+ if (ImGui.Button("Close")) { _keySlot = null; ImGui.CloseCurrentPopup(); }
break;
}
ImGui.PopTextWrapPos();
@@ -463,12 +534,12 @@ internal sealed class ShortcutBarWindow
finally { ImGui.EndPopup(); }
}
- private void Bind()
+ private void Bind(BarSlot slot)
{
- if (_host.BindActionKey(KeyAction(_keySlot), _keyName, out string why))
+ if (_act.BindKey(slot, _keyName, out string why))
{
_act.KeysChanged();
- _keySlot = 0;
+ _keySlot = null;
ImGui.CloseCurrentPopup();
return;
}
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs b/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs
new file mode 100644
index 0000000..b5bd917
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthDefective/Views/BarSettingsView.cs
@@ -0,0 +1,93 @@
+using System;
+using RynthCore.Plugin.RynthDefective.Model;
+using RynthCore.Plugin.RynthDefective.Ui;
+
+namespace RynthCore.Plugin.RynthDefective.Views;
+
+///
+/// RynthDefective's settings in a window of their own (2026-10-27), for the Shortcuts bar: the old
+/// script-window bar that held them (SettingsPanel) stays shut while the new bar is used. Opened from
+/// the bar (its gear, its right-click menu) and /rdef settings. Which of RynthDefective's windows show
+/// (the bar, the Game Panels buttons, Selection), the independent bar and its copy offer, the slot
+/// picture size, and the weapon switches. Recorded on the pump thread; the host parts are delegates,
+/// so the tests draw it offline.
+///
+internal sealed class BarSettingsView
+{
+ public const string BarTitle = ShortcutBar.ShortcutBarWindow.Title;
+ public const string PanelsTitle = ShortcutBar.PanelButtonsWindow.Title;
+ public const string SelectionTitle = ShortcutBar.SelectionWindow.Title;
+
+ private readonly DefSession _s;
+
+ /// Whether one of RynthDefective's windows (by its title) shows: true, false, null = this engine has no such window.
+ public Func WindowShown = _ => null;
+ /// Shows or hides one of them.
+ public Action ShowWindow = (_, _) => { };
+ /// A message for the player (the chat, and the status line).
+ public Action Tell = _ => { };
+
+ public BarSettingsView(DefSession session) => _s = session;
+
+ public void Draw(UiWindow w)
+ {
+ if (!_s.LoggedIn)
+ {
+ w.TextDisabled("Log in to change RynthDefective's settings.");
+ return;
+ }
+ DefSettings st = _s.Settings;
+ void Changed()
+ {
+ st.Clamp();
+ _s.Save();
+ }
+
+ w.SeparatorText("Windows");
+ w.TextWrapped("RynthDefective draws the Shortcuts bar, the Game Panels buttons and the Selection window. "
+ + "Right-click the bar's title for this window and to show or hide the other two.");
+ WindowBox(w, BarTitle, "Shortcuts bar", "set.win.bar", "The item bar (/rdef). Its RynthCore bar button is the lightning bolt.");
+ WindowBox(w, PanelsTitle, "Game panel buttons", "set.win.panels", "Buttons for the game's own panels: pack, spellbook, map ... (/rdef panels).");
+ WindowBox(w, SelectionTitle, "Selection", "set.win.sel", "What is selected, how far and which way, and a creature's health (/rdef selection).");
+
+ w.SeparatorText("Shortcuts bar");
+ w.Checkbox("Independent of the game's toolbar", "set.indep", st.IndependentBar, v => Tell(_s.SetIndependent(v)));
+ w.Tooltip("On: every slot on the bar is RynthDefective's own. The game's 18 shortcut slots are not on it; a click uses the item "
+ + "one-touch (a kit on yourself, a weapon wielded), and its keys are RynthCore hotkeys (/rdef use N).\n"
+ + "Off (the default): slots 1-18 are the game's own toolbar slots and keys; RynthDefective's slots follow from 19.\n"
+ + "Kept for this character.");
+ if (st.IndependentBar && _s.CopyOffer > 0)
+ {
+ int n = _s.CopyOffer;
+ w.TextColored(SlotText.Waiting, $"The game's 18 slots hold {n} item{(n == 1 ? "" : "s")}. Copy {(n == 1 ? "it" : "them")} into this bar's slots 1-18?");
+ w.TextWrapped("Your own slots move after them, to 19 and on, with their keys, so the bar looks as before. "
+ + "The game's toolbar and its keys stay as they are.");
+ w.SmallButton("Copy them", "set.copy", () => Tell(_s.CopyRetailSlots()));
+ w.SameLine();
+ w.SmallButton("No thanks", "set.nocopy", () => _s.DeclineCopy());
+ }
+ else if (!st.IndependentBar)
+ {
+ w.TextDisabled("A healing kit in one of the game's slots is used on you when you click it on the bar (its game key is the game's own).");
+ }
+ w.SliderInt("Slot picture size", "set.button", st.ButtonSize, DefSettings.ButtonMin, DefSettings.ButtonMax, v => { st.ButtonSize = v; Changed(); });
+ w.Tooltip("Ctrl+wheel over the bar's title makes the whole bar bigger or smaller.");
+
+ w.SeparatorText("Weapons");
+ w.Checkbox("Allow weapon swaps while RynthAi's macro runs", "set.swap", st.SwapWhileBotRuns, v => { st.SwapWhileBotRuns = v; Changed(); });
+ w.Tooltip("Off (the default): a weapon, wand or shield is not wielded while the RynthAi macro runs - it picks the weapon itself and would swap back. Kits, potions and other items always work.");
+ w.SliderInt("Weapon picker row icon", "set.picker", st.PickerIconSize, DefSettings.PickerIconMin, DefSettings.PickerIconMax, v => { st.PickerIconSize = v; Changed(); });
+
+ w.SeparatorText("About");
+ w.TextWrapped(SettingsPanel.Credit);
+ w.TextDisabled("Commands: /rdef (show or hide the bar), /rdef settings, /rdef panels, /rdef selection, /rdef weapons, /rdef use , /rdef help.");
+ }
+
+ private void WindowBox(UiWindow w, string title, string label, string id, string tip)
+ {
+ bool? shown = WindowShown(title);
+ if (shown == null) return; // not on this engine (the Game Panels buttons need plugin API v90's AcPanel)
+ w.Checkbox(label, id, shown.Value, v => ShowWindow(title, v));
+ w.Tooltip(tip);
+ }
+}
diff --git a/Plugins/RynthCore.Plugin.RynthDefective/Views/SettingsPanel.cs b/Plugins/RynthCore.Plugin.RynthDefective/Views/SettingsPanel.cs
index 070a84e..050f01d 100644
--- a/Plugins/RynthCore.Plugin.RynthDefective/Views/SettingsPanel.cs
+++ b/Plugins/RynthCore.Plugin.RynthDefective/Views/SettingsPanel.cs
@@ -32,7 +32,7 @@ internal sealed class SettingsPanel
}
w.SeparatorText("Settings");
- w.SliderInt("Slots", "set.slots", st.SlotCount, DefSettings.SlotsMin, DefSettings.SlotsMax, v => { st.SlotCount = v; Changed(true); });
+ w.SliderInt("Slots", "set.slots", st.SlotCount, DefSettings.SlotsMin, DefSettings.SlotCountMax, v => { st.SlotCount = v; Changed(true); });
w.SliderInt("Slots per row", "set.perrow", st.SlotsPerRow, DefSettings.PerRowMin, DefSettings.PerRowMax, v => { st.SlotsPerRow = v; Changed(true); });
w.SliderInt("Button size", "set.button", st.ButtonSize, DefSettings.ButtonMin, DefSettings.ButtonMax, v => { st.ButtonSize = v; Changed(true); });
w.SliderInt("Picker row icon", "set.picker", st.PickerIconSize, DefSettings.PickerIconMin, DefSettings.PickerIconMax, v => { st.PickerIconSize = v; Changed(false); });
diff --git a/Plugins/RynthCore.Plugin.RynthVision/Light/DungeonLight.cs b/Plugins/RynthCore.Plugin.RynthVision/Light/DungeonLight.cs
new file mode 100644
index 0000000..d1fc072
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthVision/Light/DungeonLight.cs
@@ -0,0 +1,215 @@
+// ============================================================================
+// RynthVision - Light/DungeonLight.cs
+// The dungeon light's rules (2026-10-27), pure: where it lights and how
+// brightly, the /rv light words, and the status line. A player asked for
+// SkunkVision's "Dungeon Light" (problem report R-20261027-141534-6a2b:
+// the dark TOR dungeons). Tools/RynthVision.Tests compiles this file as is.
+//
+// How it lights: RynthCore's ambient light floor (plugin API v91,
+// RynthCore D3D9/AmbientLight.cs) raises the ambient light AC draws the
+// world with, per channel, never below AC's own. Drawing only, in this
+// client: nothing goes to the server and nobody else sees a difference.
+// AC itself lights every dungeon cell with a flat 20 % white ambient
+// (CellManager::ChangePosition -> SmartBox::SetWorldAmbientLight(0.2,
+// white)); torches are baked into the walls on top of that. Strength 0..100
+// maps onto 20 %..100 %: 0 is AC's own dungeon, 100 lights every wall fully
+// (flat, no shading); the default 40 gives 52 %, about an overcast day.
+//
+// Where, as AC decides it: an outdoor cell (cell id low word below 0x100)
+// is outdoors; an EnvCell whose dat entry says it sees outside
+// (EnvCellSeenOutside, a building's room) is a building, lit by AC from the
+// sky; every other EnvCell is a dungeon. Unknown (no cell dat) counts as a
+// dungeon: the light then reaches buildings too, harmlessly.
+// ============================================================================
+
+using System;
+using System.Globalization;
+
+namespace RynthCore.Plugin.RynthVision.Light;
+
+/// Where the player is, the way AC picks its ambient light.
+internal enum LightPlace { NotInWorld = 0, Outdoors = 1, Building = 2, Dungeon = 3 }
+
+/// Where the dungeon light lights (setting "lightScope").
+internal enum LightScope { Dungeons = 0, Indoors = 1, Everywhere = 2 }
+
+internal enum LightCommandKind { Toggle, On, Off, Strength, Scope, Color, Show, Status, Help, Error }
+
+/// One parsed "/rv light ..." command.
+internal readonly record struct LightCommand(LightCommandKind Kind, int Strength = 0, LightScope Scope = LightScope.Dungeons,
+ uint ColorArgb = 0, string Error = "");
+
+/// What the tick knows, for the status line and the window.
+internal readonly record struct LightStatus(bool On, LightScope Scope, int Strength, LightPlace Place, bool EngineHasApi,
+ bool HookLive, uint ClientAmbient, uint AppliedAmbient);
+
+///
+/// What the Vision window's Light tab draws (published by the tick, read on AC's render thread): the settings and the
+/// status line. : the line says why it can't light.
+///
+internal sealed record LightView(bool On, int Strength, LightScope Scope, uint ColorArgb, string Status, bool Warn)
+{
+ public static readonly LightView Empty =
+ new(false, DungeonLight.DefaultStrength, LightScope.Dungeons, DungeonLight.DefaultColor, "Waiting for RynthVision...", false);
+}
+
+internal static class DungeonLight
+{
+ public const int DefaultStrength = 40;
+ public const uint DefaultColor = 0xFFFFFFFF;
+
+ /// AC's own dungeon ambient (SetWorldAmbientLight(0.2, white)).
+ public const float AcDungeonLevel = 0.2f;
+
+ /// Colour presets for the window and /rv light color: name, ARGB.
+ public static readonly (string Name, uint Argb)[] Presets =
+ {
+ ("white", 0xFFFFFFFF),
+ ("torch", 0xFFFFD8A8), // warm, like AC's torches
+ ("moon", 0xFFC8D8FF), // cool blue-white
+ };
+
+ public static string ScopeWord(LightScope s) => s switch
+ {
+ LightScope.Indoors => "indoors",
+ LightScope.Everywhere => "everywhere",
+ _ => "dungeons",
+ };
+
+ public static string PlaceWord(LightPlace p) => p switch
+ {
+ LightPlace.Outdoors => "outdoors",
+ LightPlace.Building => "in a building",
+ LightPlace.Dungeon => "in a dungeon",
+ _ => "not in the world",
+ };
+
+ /// Where is: is the EnvCell's flag (null = unknown).
+ public static LightPlace Classify(uint cellId, bool? seenOutside)
+ {
+ if ((cellId >> 16) == 0) return LightPlace.NotInWorld;
+ if ((cellId & 0xFFFF) < 0x100) return LightPlace.Outdoors;
+ return seenOutside == true ? LightPlace.Building : LightPlace.Dungeon;
+ }
+
+ /// True when the light lights under .
+ public static bool Applies(LightScope scope, LightPlace place) => place switch
+ {
+ LightPlace.Dungeon => true,
+ LightPlace.Building => scope != LightScope.Dungeons,
+ LightPlace.Outdoors => scope == LightScope.Everywhere,
+ _ => false,
+ };
+
+ /// The ambient level (0.2..1) for a strength (0..100, clamped).
+ public static float Level(int strength) =>
+ AcDungeonLevel + (1f - AcDungeonLevel) * Math.Clamp(strength, 0, 100) / 100f;
+
+ ///
+ /// The floor for RynthCore (0x00RRGGBB): 's channels times the level.
+ /// 0 (no floor) for strength 0 or less: AC's own dungeon.
+ ///
+ public static uint FloorRgb(uint colorArgb, int strength)
+ {
+ if (strength <= 0) return 0;
+ float level = Level(strength);
+ uint Ch(int shift) => (uint)Math.Clamp((int)MathF.Round(((colorArgb >> shift) & 0xFF) * level), 0, 255);
+ return (Ch(16) << 16) | (Ch(8) << 8) | Ch(0);
+ }
+
+ /// The floor to set now: 0 when off or when isn't in the scope.
+ public static uint FloorFor(bool on, LightScope scope, int strength, uint colorArgb, LightPlace place) =>
+ on && Applies(scope, place) ? FloorRgb(colorArgb, strength) : 0u;
+
+ /// An ARGB colour's brightest channel as a percentage (the ambient level a person reads).
+ public static int Percent(uint argb)
+ {
+ uint m = Math.Max((argb >> 16) & 0xFF, Math.Max((argb >> 8) & 0xFF, argb & 0xFF));
+ return (int)MathF.Round(m * 100f / 255f);
+ }
+
+ /// "RRGGBB", "AARRGGBB" (alpha dropped) with or without '#', or a preset name; opaque ARGB.
+ public static bool TryParseColor(string? text, out uint argb)
+ {
+ argb = 0;
+ if (string.IsNullOrWhiteSpace(text)) return false;
+ string s = text.Trim().TrimStart('#');
+ foreach (var (name, value) in Presets)
+ if (string.Equals(s, name, StringComparison.OrdinalIgnoreCase)) { argb = value; return true; }
+ if (s.Length == 8) s = s.Substring(2);
+ if (s.Length != 6 || !uint.TryParse(s, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out uint rgb)) return false;
+ argb = 0xFF000000u | rgb;
+ return true;
+ }
+
+ /// The preset name for , or its hex ("FFE0C0").
+ public static string ColorName(uint argb)
+ {
+ foreach (var (name, value) in Presets)
+ if ((value & 0xFFFFFF) == (argb & 0xFFFFFF)) return name;
+ return (argb & 0xFFFFFF).ToString("X6", CultureInfo.InvariantCulture);
+ }
+
+ ///
+ /// "/rv light" and its words ( is what follows "light"): nothing = toggle;
+ /// on | off | toggle; 0-100 (a trailing % is fine) = strength, and on; dungeons | indoors | everywhere;
+ /// color <RRGGBB | white | torch | moon>; show (the Vision window's Light tab); status; help.
+ ///
+ public static LightCommand ParseCommand(string? args)
+ {
+ string a = (args ?? string.Empty).Trim();
+ if (a.Length == 0) return new LightCommand(LightCommandKind.Toggle);
+ string[] words = a.Split((char[]?)null, 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+ string w = words[0].ToLowerInvariant();
+ string rest = words.Length > 1 ? words[1] : string.Empty;
+ switch (w)
+ {
+ case "on": return new LightCommand(LightCommandKind.On);
+ case "off": return new LightCommand(LightCommandKind.Off);
+ case "toggle": return new LightCommand(LightCommandKind.Toggle);
+ case "dungeon": case "dungeons": return new LightCommand(LightCommandKind.Scope, Scope: LightScope.Dungeons);
+ case "indoor": case "indoors": case "inside": return new LightCommand(LightCommandKind.Scope, Scope: LightScope.Indoors);
+ case "everywhere": case "all": case "always": return new LightCommand(LightCommandKind.Scope, Scope: LightScope.Everywhere);
+ case "show": case "window": case "settings": return new LightCommand(LightCommandKind.Show);
+ case "status": case "?": return new LightCommand(LightCommandKind.Status);
+ case "help": return new LightCommand(LightCommandKind.Help);
+ case "color": case "colour":
+ if (rest.Length == 0)
+ return new LightCommand(LightCommandKind.Error, Error: "Give a colour: RRGGBB (hex), white, torch or moon.");
+ return TryParseColor(rest, out uint c)
+ ? new LightCommand(LightCommandKind.Color, ColorArgb: c)
+ : new LightCommand(LightCommandKind.Error, Error: $"'{rest}' isn't a colour: RRGGBB (hex), white, torch or moon.");
+ }
+ string num = w.EndsWith('%') ? w[..^1] : w;
+ if (int.TryParse(num, NumberStyles.Integer, CultureInfo.InvariantCulture, out int n))
+ return n is >= 0 and <= 100
+ ? new LightCommand(LightCommandKind.Strength, Strength: n)
+ : new LightCommand(LightCommandKind.Error, Error: $"Strength {n} is outside 0-100.");
+ return new LightCommand(LightCommandKind.Error, Error: $"Unknown '/rv light {a}'.");
+ }
+
+ public const string Usage =
+ "/rv light [on|off] | 0-100 (strength) | dungeons|indoors|everywhere | color RRGGBB|white|torch|moon | show | status";
+
+ /// One line for chat and the Light tab: what the light is doing here and why.
+ public static string StatusLine(in LightStatus s)
+ {
+ if (!s.EngineHasApi)
+ return "Needs a newer RynthCore (plugin API 91): update RynthCore in the launcher.";
+ if (!s.On)
+ return $"Off. Strength {s.Strength}%, {ScopeWord(s.Scope)}.";
+ if (!s.HookLive)
+ return "On, but RynthCore's light hook is off or unavailable (/rc hooks; switch: AmbientLight).";
+ if (s.Place == LightPlace.NotInWorld)
+ return "On; waiting to be in the world.";
+ if (!Applies(s.Scope, s.Place))
+ return $"On for {ScopeWord(s.Scope)}; not lighting here ({PlaceWord(s.Place)}).";
+ string levels = s.ClientAmbient != 0 || s.AppliedAmbient != 0
+ ? $": ambient {Percent(s.ClientAmbient)}% -> {Percent(s.AppliedAmbient)}%"
+ : string.Empty;
+ return $"Lighting {PlaceWord(s.Place)}{levels}.";
+ }
+
+ /// True when the status line says the light can't work (an old engine, the hook off).
+ public static bool IsWarning(in LightStatus s) => !s.EngineHasApi || (s.On && !s.HookLive);
+}
diff --git a/Plugins/RynthCore.Plugin.RynthVision/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthVision/PluginExports.cs
index c79d1b0..3dc6aa7 100644
--- a/Plugins/RynthCore.Plugin.RynthVision/PluginExports.cs
+++ b/Plugins/RynthCore.Plugin.RynthVision/PluginExports.cs
@@ -34,6 +34,60 @@ public static unsafe class PluginExports
Marshal.FreeHGlobal(old);
}
catch { }
+ try { ReleaseSections(); }
+ catch { }
+ }
+
+ // ── The Vision window (2026-10-27; RynthCore hosts it in its Vision panel's place, docs/PLUGIN_WINDOWS.md) ──
+
+ private static string? _sectionsJson;
+ private static IntPtr _sectionsPtr;
+
+ /// The sections manifest: just the Vision window, on an engine that hosts it (Ui/VisionManifest.cs).
+ [UnmanagedCallersOnly(EntryPoint = "RynthPluginGetSectionsJson", CallConvs = new[] { typeof(CallConvCdecl) })]
+ public static IntPtr GetSectionsJson()
+ {
+ try
+ {
+ RynthVisionPlugin? plugin = Runtime.Plugin;
+ if (plugin == null) return IntPtr.Zero;
+ string json = plugin.SectionsJson;
+ if (json == _sectionsJson && _sectionsPtr != IntPtr.Zero) return _sectionsPtr;
+ _sectionsJson = json;
+ IntPtr fresh = Marshal.StringToCoTaskMemUTF8(json);
+ IntPtr old = Interlocked.Exchange(ref _sectionsPtr, fresh);
+ if (old != IntPtr.Zero) Marshal.FreeCoTaskMem(old);
+ return fresh;
+ }
+ catch { return IntPtr.Zero; }
+ }
+
+ private static void ReleaseSections()
+ {
+ IntPtr old = Interlocked.Exchange(ref _sectionsPtr, IntPtr.Zero);
+ if (old != IntPtr.Zero) Marshal.FreeCoTaskMem(old);
+ _sectionsJson = null;
+ }
+
+ ///
+ /// A window's body (AC's render thread): 1 drawn, 0 not this plugin's surface or not ready, -2 the
+ /// draw failed (RynthCore then says the window couldn't draw; docs/PLUGIN_WINDOWS.md).
+ ///
+ [UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderEmbed", CallConvs = new[] { typeof(CallConvCdecl) })]
+ public static int RenderEmbed(byte* surface, float width, float height, float* wantWidth, float* wantHeight)
+ {
+ try
+ {
+ if (surface == null) return 0;
+ string name = Marshal.PtrToStringUTF8((IntPtr)surface) ?? string.Empty;
+ if (name.EndsWith(":popout", StringComparison.Ordinal)) name = name[..^":popout".Length];
+ RynthVisionPlugin? plugin = Runtime.Plugin;
+ if (plugin == null || !plugin.RenderEmbed(name)) return 0;
+ if (wantWidth != null) *wantWidth = width;
+ if (wantHeight != null) *wantHeight = height;
+ return 1;
+ }
+ catch { return -2; }
}
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnLoginComplete", CallConvs = new[] { typeof(CallConvCdecl) })]
@@ -73,6 +127,9 @@ public static unsafe class PluginExports
public static void OnChatBarEnter(IntPtr textUtf16, IntPtr eatFlag) => Runtime.OnChatBarEnter(textUtf16, eatFlag);
// ── Settings bridge for the engine's Vision panels (UI/Data/VisionData.cs) ──
+ // Still used: the engine's own Vision panel on an engine that doesn't host
+ // RynthVision's window, and the Avalonia twin. RynthVision's own window
+ // doesn't go through here (RynthVisionPlugin.Ui.cs).
// The engine calls these on the plugin pump thread (UiDataHub). The
// pointer swap (alloc-new → swap → free-old) keeps the previous buffer
// alive until the next call; the engine copies it immediately.
diff --git a/Plugins/RynthCore.Plugin.RynthVision/RynthCore.Plugin.RynthVision.csproj b/Plugins/RynthCore.Plugin.RynthVision/RynthCore.Plugin.RynthVision.csproj
index cd236a2..66a95a3 100644
--- a/Plugins/RynthCore.Plugin.RynthVision/RynthCore.Plugin.RynthVision.csproj
+++ b/Plugins/RynthCore.Plugin.RynthVision/RynthCore.Plugin.RynthVision.csproj
@@ -16,9 +16,11 @@
RynthCore.Plugin.RynthVision
x86
+ highest API use NOT behind a Has*/version check. Only the v60/v61 Nav3D calls, behind HasNav3DTriangle;
+ the Vision window (2026-10-27: declared only on v91, Ui/VisionManifest.HostsWindow; older engines keep
+ their own Vision panel) and the light itself (v91, HasAmbientLight) are checked too. -->
66
- Shows unclimbable slopes, impassable water and your radar range in the world.
+ Shows unclimbable slopes, impassable water and your radar range in the world, and lights dark dungeons.
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.Light.cs b/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.Light.cs
new file mode 100644
index 0000000..55d891f
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.Light.cs
@@ -0,0 +1,201 @@
+// ============================================================================
+// RynthVision - RynthVisionPlugin.Light.cs
+// The dungeon light (2026-10-27; rules in Light/DungeonLight.cs): every tick
+// it works out where the player is the way AC does (outdoors, a building's
+// room, a dungeon cell) and hands RynthCore the ambient light floor for it
+// (RynthCoreHost.SetAmbientLightFloor, plugin API v91): the light's colour
+// times its level where the light applies, 0 everywhere else, out of the
+// world, and when it is off. Drawing only, in this client.
+//
+// Where: an EnvCell's "sees outside" flag comes from the cell dat (the
+// TerrainSampler the overlays use, opened the first time the light is on in
+// an EnvCell; a cell is read once, when the player enters it). While the
+// light is off nothing is opened and no floor is ever sent.
+//
+// Threads: /rv light (AC's thread) and the Vision window's Light tab (AC's
+// render thread; Ui/VisionWindow.cs since 2026-10-27, the separate Dungeon
+// Light window is gone) queue their changes (RynthVisionPlugin.Ui.cs); the
+// tick (the plugin pump) applies them, saves the settings, sends the floor and
+// publishes the LightView the tab draws. The floor is sent on every change and
+// again every 2 s while it is set (an /rc hooks switch shows), and cleared on
+// Shutdown (RynthCore also clears it when plugins unload).
+// ============================================================================
+
+using System;
+using System.Collections.Generic;
+using RynthCore.Plugin.RynthVision.Light;
+using RynthCore.Plugin.RynthVision.Ui;
+using RynthCore.PluginSdk;
+using RynthCore.TerrainData;
+
+namespace RynthCore.Plugin.RynthVision;
+
+public sealed partial class RynthVisionPlugin
+{
+ private const long LightResendMs = 2000;
+ private const long LightViewMs = 500;
+ private const int SeenOutsideCacheCap = 1024;
+
+ private uint _lightCell = uint.MaxValue; // the cell _lightPlace is for (MaxValue: none yet)
+ private bool _lightPlaceExact; // _lightPlace came from the dat (else "unknown EnvCell")
+ private LightPlace _lightPlace;
+ private readonly Dictionary _seenOutside = new();
+ private bool _lightTerrainTried; // once per login: the light opened (or tried) the dats
+ private uint _floorSent; // the floor RynthCore has from us (0 = none)
+ private long _floorSentMs;
+ private long _nextLightViewMs;
+ private bool _lightViewDirty = true;
+ private volatile LightView _lightView = LightView.Empty;
+
+ ///
+ /// Plugin tick (pump thread), in the world or not, after TickUi applied the queued changes:
+ /// 0 = not in the world.
+ ///
+ private void TickLight(uint cellId)
+ {
+ bool on = _settings.LightOn;
+ if (cellId != _lightCell || (on && !_lightPlaceExact))
+ ClassifyCell(cellId, on);
+
+ bool hasApi = Host.HasAmbientLight;
+ uint floor = DungeonLight.FloorFor(on, (LightScope)_settings.LightScope, _settings.LightStrength,
+ _settings.LightColorArgb, _lightPlace);
+ long now = Environment.TickCount64;
+ if (hasApi && (floor != _floorSent || (floor != 0 && now - _floorSentMs >= LightResendMs)))
+ {
+ Host.SetAmbientLightFloor(floor);
+ if (floor != _floorSent) _lightViewDirty = true;
+ _floorSent = floor;
+ _floorSentMs = now;
+ }
+
+ if (_lightViewDirty || now >= _nextLightViewMs)
+ {
+ _lightViewDirty = false;
+ _nextLightViewMs = now + LightViewMs;
+ LightStatus status = CurrentLightStatus(hasApi);
+ _lightView = new LightView(on, _settings.LightStrength, (LightScope)_settings.LightScope, _settings.LightColorArgb,
+ DungeonLight.StatusLine(status), DungeonLight.IsWarning(status));
+ }
+ }
+
+ private LightStatus CurrentLightStatus(bool hasApi)
+ {
+ uint client = 0, applied = 0;
+ bool live = hasApi && Host.TryGetAmbientLight(out client, out applied);
+ return new LightStatus(_settings.LightOn, (LightScope)_settings.LightScope, _settings.LightStrength, _lightPlace,
+ hasApi, live, client, applied);
+ }
+
+ ///
+ /// Where is. An EnvCell is read from the cell dat only while the light is
+ /// on (); otherwise it stays "unknown" (a dungeon) until it is needed.
+ ///
+ private void ClassifyCell(uint cellId, bool exact)
+ {
+ bool envCell = (cellId >> 16) != 0 && (cellId & 0xFFFF) >= 0x100;
+ bool? seenOutside = null;
+ bool known = true;
+ if (envCell)
+ {
+ if (exact) seenOutside = SeenOutside(cellId);
+ known = exact && seenOutside != null;
+ }
+ LightPlace place = DungeonLight.Classify(cellId, seenOutside);
+ if (place != _lightPlace) _lightViewDirty = true;
+ _lightPlace = place;
+ _lightCell = cellId;
+ // A cell the dat couldn't answer for stays "exact" too: asking again every tick won't help.
+ _lightPlaceExact = known || (exact && (_lightTerrainTried || _terrain.IsReady));
+ }
+
+ /// The EnvCell's "sees outside" flag from the cell dat (cached per cell); null when unknown.
+ private bool? SeenOutside(uint cellId)
+ {
+ if (_seenOutside.TryGetValue(cellId, out bool cached)) return cached;
+ if (!_terrain.IsReady && !_lightTerrainTried)
+ {
+ _lightTerrainTried = true;
+ InitTerrain();
+ }
+ if (!_terrain.IsReady || !_terrain.TryGetEnvCellFlags(cellId, out uint flags)) return null;
+ bool seen = (flags & TerrainSampler.EnvCellSeenOutside) != 0;
+ if (_seenOutside.Count >= SeenOutsideCacheCap) _seenOutside.Clear();
+ _seenOutside[cellId] = seen;
+ return seen;
+ }
+
+ /// A new login: where the player is gets worked out again; the dats may be tried again.
+ private void ResetLightPlace()
+ {
+ _lightCell = uint.MaxValue;
+ _lightPlaceExact = false;
+ _lightTerrainTried = false;
+ _lightViewDirty = true;
+ }
+
+ /// Shutdown: RynthCore's floor back to none (RynthCore clears it on unload too).
+ private void ClearLightFloor()
+ {
+ try
+ {
+ if (_floorSent != 0 && Host.HasAmbientLight) Host.SetAmbientLightFloor(0);
+ }
+ catch { }
+ _floorSent = 0;
+ }
+
+ // ── /rv light (queued; the tick applies it) ──────────────────────────
+
+ /// "/rv light ..." (AC's thread): parsed here, applied and answered on the tick.
+ private void QueueLightCommand(string args)
+ {
+ LightCommand cmd = DungeonLight.ParseCommand(args);
+ _uiActions.Enqueue(() => RunLightCommand(cmd));
+ }
+
+ private void RunLightCommand(LightCommand cmd)
+ {
+ VisionSettings s = _settings;
+ switch (cmd.Kind)
+ {
+ case LightCommandKind.Toggle: s.LightOn = !s.LightOn; break;
+ case LightCommandKind.On: s.LightOn = true; break;
+ case LightCommandKind.Off: s.LightOn = false; break;
+ case LightCommandKind.Strength: s.LightStrength = cmd.Strength; s.LightOn = true; break;
+ case LightCommandKind.Scope: s.LightScope = (int)cmd.Scope; break;
+ case LightCommandKind.Color: s.LightColorArgb = cmd.ColorArgb; break;
+ case LightCommandKind.Show:
+ // The Vision window, on its Light tab (2026-10-27: the light lives in the Vision window).
+ if (_hostsWindow && Host.SetPanelOpen(VisionManifest.Title, RynthPanelOpen.Open) >= 0)
+ {
+ RequestTab(VisionTab.Light);
+ return;
+ }
+ LightChat("The Vision window's Light tab needs a newer RynthCore (plugin API 91); " + DungeonLight.Usage);
+ return;
+ case LightCommandKind.Status:
+ LightChat("Dungeon light: " + DungeonLight.StatusLine(CurrentLightStatus(Host.HasAmbientLight)));
+ return;
+ case LightCommandKind.Help:
+ LightChat(DungeonLight.Usage);
+ return;
+ default:
+ LightChat(cmd.Error + " " + DungeonLight.Usage);
+ return;
+ }
+ s.Save();
+ MarkSettingsChanged();
+ string summary = $"Dungeon light {(s.LightOn ? "on" : "off")}: strength {s.LightStrength}%, " +
+ $"{DungeonLight.ScopeWord((LightScope)s.LightScope)}, {DungeonLight.ColorName(s.LightColorArgb)}.";
+ if (!Host.HasAmbientLight)
+ summary += " Needs a newer RynthCore (plugin API 91) to light anything.";
+ LightChat(summary);
+ }
+
+ private void LightChat(string text)
+ {
+ Host.Log("[RynthVision] " + text);
+ if (Host.HasWriteToChat) Host.WriteToChat("[RynthVision] " + text, 1);
+ }
+}
diff --git a/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.Ui.cs b/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.Ui.cs
new file mode 100644
index 0000000..b3bb55c
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.Ui.cs
@@ -0,0 +1,93 @@
+// ============================================================================
+// RynthVision - RynthVisionPlugin.Ui.cs
+// The Vision window's side of the plugin (2026-10-27; Ui/VisionWindow.cs,
+// Ui/VisionManifest.cs): RynthVision draws the whole Vision window, in the
+// engine's Vision panel's place, on an engine with plugin API v91 (_hostsWindow,
+// decided once in Initialize; an older engine keeps its own panel).
+//
+// Threads: the window (AC's render thread), /rv (AC's thread) and the light's
+// commands queue their changes here; the tick (the plugin pump) applies them
+// first thing, saves rynthvision.json and publishes a fresh copy of the
+// settings for the window (SettingsView) whenever anything changed them (a
+// change here, or the engine's panels through PluginExports, on the pump too).
+// /rv light show asks the window for its Light tab (_tabRequest).
+// ============================================================================
+
+using System;
+using System.Collections.Concurrent;
+using System.Threading;
+using RynthCore.Plugin.RynthVision.Light;
+using RynthCore.Plugin.RynthVision.Ui;
+
+namespace RynthCore.Plugin.RynthVision;
+
+public sealed partial class RynthVisionPlugin
+{
+ private readonly ConcurrentQueue _uiActions = new();
+ private volatile SettingsView? _settingsView;
+ private int _settingsVersion;
+ private bool _settingsDirty = true; // pump thread
+ private bool _hostsWindow; // Initialize: the engine hosts the Vision window
+ private int _tabRequest = -1; // a VisionTab the window should show (-1 none)
+ private VisionWindow? _visionWindow; // render thread
+
+ /// The manifest RynthCore hosts the Vision window from (no window on an older engine).
+ internal string SectionsJson => VisionManifest.Json(_hostsWindow);
+
+ /// The settings as the tick last published them (the window's copy source). Any thread.
+ internal SettingsView? Settings => _settingsView;
+
+ /// The dungeon light's state and status line, as the tick last published them. Any thread.
+ internal LightView LightState => _lightView;
+
+ /// Tick, first thing: the queued changes, then a fresh copy for the window if anything changed.
+ private void TickUi()
+ {
+ while (_uiActions.TryDequeue(out Action? act))
+ {
+ try { act(); }
+ catch (Exception ex) { Host.Log("[RynthVision] Settings change: " + ex.Message); }
+ }
+ if (!_settingsDirty) return;
+ _settingsDirty = false;
+ _settingsView = new SettingsView(++_settingsVersion, _settings.Clone());
+ }
+
+ /// The settings changed (pump thread): republish them, and the light's view.
+ private void MarkSettingsChanged()
+ {
+ _settingsDirty = true;
+ _lightViewDirty = true;
+ }
+
+ /// Applies on the tick and saves when . Any thread.
+ internal void QueueSettingsChange(Action change, bool save = true) => _uiActions.Enqueue(() =>
+ {
+ change(_settings);
+ if (save) _settings.Save();
+ MarkSettingsChanged();
+ });
+
+ /// "Log terrain types here": on the tick (it may open the terrain data). Any thread.
+ internal void QueueInspectTerrain() => _uiActions.Enqueue(InspectTerrain);
+
+ /// Asks the window to show on its next draw. Any thread.
+ private void RequestTab(VisionTab tab) => Volatile.Write(ref _tabRequest, (int)tab);
+
+ /// The tab /rv light show asked for, once. Render thread.
+ internal bool TakeTabRequest(out VisionTab tab)
+ {
+ int t = Interlocked.Exchange(ref _tabRequest, -1);
+ tab = (VisionTab)Math.Max(0, t);
+ return t >= 0;
+ }
+
+ /// RynthPluginRenderEmbed: draws (":popout" already off). Render thread.
+ internal bool RenderEmbed(string surface)
+ {
+ if (!_hostsWindow || !surface.Equals(VisionManifest.Surface, StringComparison.Ordinal)) return false;
+ _visionWindow ??= new VisionWindow(this, Host);
+ _visionWindow.Draw();
+ return true;
+ }
+}
diff --git a/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.cs b/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.cs
index 26dd52e..1e2a1f2 100644
--- a/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.cs
+++ b/Plugins/RynthCore.Plugin.RynthVision/RynthVisionPlugin.cs
@@ -11,15 +11,20 @@ namespace RynthCore.Plugin.RynthVision;
///
/// World-space visualization plugin (a RynthCore-native take on Decal's
/// SkunkVision): highlights unclimbable slopes, impassable water, and a
-/// radar-range ring using the engine's Nav3D overlay API. Settings come from
-/// the engine's Vision panels (ImGui face and the Avalonia twin, through the
-/// JSON exports in PluginExports) or the /rv chat command, and persist to
-/// %APPDATA%\RynthCore\rynthvision.json.
+/// radar-range ring using the engine's Nav3D overlay API, and lights dark
+/// dungeons (SkunkVision's Dungeon Light; RynthVisionPlugin.Light.cs, through
+/// RynthCore's ambient light floor). Settings come from RynthVision's own
+/// Vision window (2026-10-27, Ui/VisionWindow.cs: it takes the engine's Vision
+/// panel's place on an engine with plugin API v91; RynthVisionPlugin.Ui.cs), the
+/// engine's Vision panels on an older engine (its ImGui face, and the Avalonia
+/// twin, through the JSON exports in PluginExports), or the /rv chat command,
+/// and persist to %APPDATA%\RynthCore\rynthvision.json.
///
/// Terrain data (the portal/cell .dat files) is opened on the first in-world
-/// tick that has slopes or water switched on, never while they're off.
+/// tick that has slopes or water switched on, or the first EnvCell the
+/// dungeon light is on in, never while those are off.
///
-public sealed class RynthVisionPlugin : RynthPluginBase
+public sealed partial class RynthVisionPlugin : RynthPluginBase
{
// An EnvCell pose more than this far below the ground is a dungeon under
// the landscape, not a building interior (see IsOnLandscape).
@@ -46,34 +51,52 @@ public sealed class RynthVisionPlugin : RynthPluginBase
public override int Initialize()
{
+ // The Vision window draws with ImGui.NET bound to the engine's cimgui, in its look.
+ RynthCore.Plugin.Shared.ImGuiNativeBinding.Ensure(msg => Host.Log("[RynthVision] " + msg));
+ RynthCore.Plugin.Shared.RynthUi.RynthUi.Init(Host);
+ _hostsWindow = Ui.VisionManifest.HostsWindow(Host.HasAmbientLight, Host.HasSetPanelOpen, Host.HasSettingsDrawers, Host.HasUiTheme);
_settings.Load();
_window = new LandblockWindow(_terrain);
_radarRing = new RadarRingOverlay(Host, _settings);
_slopes = new SlopeOverlay(Host, _settings);
_water = new WaterOverlay(Host, _settings);
- Host.Log("[RynthVision] Initialized. Use the Vision panel, or /rv [radar|slopes|water|watertypes|debug].");
+ Host.Log("[RynthVision] Initialized" + (_hostsWindow ? " (draws the Vision window)" : " (RynthCore's own Vision panel)") +
+ ". Use the Vision panel, or /rv [radar|slopes|water|watertypes|debug|light].");
return 0;
}
- public override void OnLoginComplete() => _terrainAttempted = false;
+ public override void OnLoginComplete()
+ {
+ _terrainAttempted = false;
+ ResetLightPlace();
+ }
public override void OnLogout() => Host.Log("[RynthVision] Logout.");
- public override void Shutdown() => _terrain.Dispose();
+ public override void Shutdown()
+ {
+ ClearLightFloor();
+ _terrain.Dispose();
+ }
// Nav3D geometry is buffered every tick and drawn by the engine at end of
// frame (after the 3D pass). Submitting from OnTick rather than OnRender
// keeps overlays alive even when the ImGui shell is disabled.
public override void OnTick()
{
- if (!Host.HasNav3D)
- return;
+ // The window's, /rv's and the light's changes first: this tick draws with them.
+ TickUi();
- // One pose for every overlay this tick.
- if (!Host.TryGetPlayerPose(out uint cellId, out float x, out float y, out float z,
- out _, out _, out _, out _) || (cellId >> 16) == 0)
- return; // not in the world / portalspace
+ // One pose for the light and every overlay this tick.
+ bool inWorld = Host.TryGetPlayerPose(out uint cellId, out float x, out float y, out float z,
+ out _, out _, out _, out _) && (cellId >> 16) != 0;
+
+ // The dungeon light runs in and out of the world (out of it, it clears the floor).
+ TickLight(inWorld ? cellId : 0);
+
+ if (!Host.HasNav3D || !inWorld)
+ return; // no overlays, or not in the world / portalspace
bool wanted = _settings.ShowUnclimbableSlopes || _settings.ShowImpassableWater;
if (wanted && !_terrainWanted) _terrainAttempted = false; // switched on again: retry
@@ -150,24 +173,40 @@ public sealed class RynthVisionPlugin : RynthPluginBase
eat = 1; // consume — don't send to the server as chat
string arg = text.Length > 3 ? text.Substring(3).Trim().ToLowerInvariant() : string.Empty;
+
+ // "/rv light ..." (Light/DungeonLight.ParseCommand): applied and answered in chat on the tick.
+ if (arg == "light" || arg.StartsWith("light ", StringComparison.Ordinal))
+ {
+ QueueLightCommand(arg.Substring(5));
+ return;
+ }
+
+ // The settings are the tick's (the Vision window reads the copy it publishes): toggles go through
+ // its queue, like the window's own changes.
+ Action? toggle;
switch (arg)
{
- case "radar": _settings.ShowRadarRing = !_settings.ShowRadarRing; break;
- case "slopes": _settings.ShowUnclimbableSlopes = !_settings.ShowUnclimbableSlopes; break;
- case "water": _settings.ShowImpassableWater = !_settings.ShowImpassableWater; break;
- case "watertypes": InspectTerrain(); return;
+ case "radar": toggle = static st => st.ShowRadarRing = !st.ShowRadarRing; break;
+ case "slopes": toggle = static st => st.ShowUnclimbableSlopes = !st.ShowUnclimbableSlopes; break;
+ case "water": toggle = static st => st.ShowImpassableWater = !st.ShowImpassableWater; break;
+ case "watertypes": QueueInspectTerrain(); return;
case "debug": _debug = !_debug; Host.Log($"[RynthVision] debug = {_debug}"); return;
- case "": break;
+ case "": toggle = null; break;
default:
- Host.Log($"[RynthVision] Unknown option '{arg}'. Use radar | slopes | water | watertypes | debug.");
+ Host.Log($"[RynthVision] Unknown option '{arg}'. Use radar | slopes | water | watertypes | debug | light.");
return;
}
- _settings.Save();
- Host.Log($"[RynthVision] radar={_settings.ShowRadarRing} slopes={_settings.ShowUnclimbableSlopes} water={_settings.ShowImpassableWater}");
+ _uiActions.Enqueue(() =>
+ {
+ toggle?.Invoke(_settings);
+ _settings.Save();
+ MarkSettingsChanged();
+ Host.Log($"[RynthVision] radar={_settings.ShowRadarRing} slopes={_settings.ShowUnclimbableSlopes} water={_settings.ShowImpassableWater}");
+ });
}
- // ── Bridge methods called from PluginExports (engine Vision panels) ───────
+ // ── Bridge methods called from PluginExports (engine Vision panels; pump thread, as the tick) ──
internal string BuildSettingsJson() => _settings.ToJson();
@@ -176,6 +215,7 @@ public sealed class RynthVisionPlugin : RynthPluginBase
{
_settings.ApplyJson(json);
_settings.Save();
+ MarkSettingsChanged();
}
// Streams pose + the terrain height under the player + the screen projection
diff --git a/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionFields.cs b/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionFields.cs
new file mode 100644
index 0000000..a9133c5
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionFields.cs
@@ -0,0 +1,63 @@
+// ============================================================================
+// RynthVision - Ui/VisionFields.cs
+// The Vision window's pure parts (2026-10-27), the same rules the engine's
+// VisionFace used (UI/Data/VisionData.cs, ArgbOpacity.cs) so a player's
+// colours and lists read and write exactly as before: the tabs, a colour's
+// alpha byte as an opacity percentage, AARRGGBB / RRGGBB hex, and the water
+// terrain types as "18,19,20". Tools/RynthVision.Tests compiles this file.
+// ============================================================================
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace RynthCore.Plugin.RynthVision.Ui;
+
+/// The Vision window's tabs, in strip order (the engine's three, then the light).
+internal enum VisionTab { Terrain = 0, Nameplates = 1, CombatText = 2, Light = 3 }
+
+internal static class VisionFields
+{
+ public static readonly string[] TabNames = { "Terrain", "Nameplates", "Combat text", "Light" };
+
+ /// The engine's tab body for a tab it still owns (RenderSettingsDrawer key), or null.
+ public static string? EngineTabKey(VisionTab tab) => tab switch
+ {
+ VisionTab.Nameplates => "nameplates",
+ VisionTab.CombatText => "combattext",
+ _ => null,
+ };
+
+ /// The colour's alpha as 0..100 %.
+ public static float OpacityPercent(uint argb) => (argb >> 24) * 100f / 255f;
+
+ /// The colour with its alpha set from (clamped to 0..100); RGB kept.
+ public static uint WithOpacity(uint argb, float percent)
+ {
+ float p = float.IsNaN(percent) ? 0f : Math.Clamp(percent, 0f, 100f);
+ uint a = (uint)Math.Clamp((int)MathF.Round(p * 255f / 100f), 0, 255);
+ return (argb & 0x00FFFFFFu) | (a << 24);
+ }
+
+ /// "AARRGGBB" or "RRGGBB" (opaque), with or without '#'.
+ public static bool TryParseHex(string? s, out uint argb)
+ {
+ argb = 0;
+ if (string.IsNullOrWhiteSpace(s)) return false;
+ s = s.Trim().TrimStart('#');
+ if (s.Length == 6) s = "FF" + s;
+ return s.Length == 8 && uint.TryParse(s, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out argb);
+ }
+
+ /// "18,19,20" -> the numbers in it (anything else is dropped).
+ public static List ParseCsv(string? csv)
+ {
+ var list = new List();
+ if (string.IsNullOrWhiteSpace(csv)) return list;
+ foreach (string part in csv.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
+ if (int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out int n)) list.Add(n);
+ return list;
+ }
+
+ public static string Csv(int[] types) => string.Join(",", types);
+}
diff --git a/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionManifest.cs b/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionManifest.cs
new file mode 100644
index 0000000..cd92142
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionManifest.cs
@@ -0,0 +1,48 @@
+// ============================================================================
+// RynthVision - Ui/VisionManifest.cs
+// RynthVision's sections manifest (RynthPluginGetSectionsJson), 2026-10-27:
+// the "Vision" window, which takes the engine's Vision panel's place
+// ("takeOver": its saved spot and size, open state, bar button, hotkeys and
+// /rc commands carry over) and RynthVision draws whole (Ui/VisionWindow.cs:
+// Terrain, Nameplates, Combat text and the Dungeon light). Owner's layer rule
+// (CLAUDE.md in both repos): the plugin owns its screens; the engine hosts the
+// window and stops drawing its own VisionFace while this one is declared, and
+// brings it back when RynthVision unloads.
+//
+// Declared only on an engine with plugin API v91 (HostsWindow): that release
+// has the light hook and draws the Nameplates and Combat text tabs into this
+// window (RenderSettingsDrawer "nameplates" / "combattext"; those settings are
+// still RynthCore's). An older engine gets no window and keeps its own Vision
+// panel, all of it; /rv light still answers there. No bar icon of its own: ""
+// takes the engine bar's icon for "Vision" (the eye). Replaces the separate
+// "Dungeon Light" window of c769ab1 (its saved place is simply unused). Pure.
+// ============================================================================
+
+namespace RynthCore.Plugin.RynthVision.Ui;
+
+internal static class VisionManifest
+{
+ /// The window's title: the engine's Vision panel's key (saved place, hotkeys, SetPanelOpen).
+ public const string Title = "Vision";
+ public const string Surface = "window:vision";
+
+ /// The engine's VisionFace sizes (PanelSpec 320 x 560, at least 280 x 240).
+ public const int Width = 320, Height = 560, MinWidth = 280, MinHeight = 240;
+
+ /// The manifest with the Vision window (an engine that hosts it).
+ public const string WithWindow =
+ "{\"version\":1,\"windows\":[{\"id\":\"vision\",\"title\":\"Vision\",\"surface\":\"window:vision\",\"icon\":\"\"," +
+ "\"width\":320,\"height\":560,\"minWidth\":280,\"minHeight\":240,\"bar\":true,\"edgeToEdge\":true,\"takeOver\":true}]}";
+
+ /// No windows: an older engine keeps its own Vision panel.
+ public const string NoWindow = "{\"version\":1}";
+
+ ///
+ /// True when the engine can host the window: plugin API v91 (the light hook, and the Nameplates and
+ /// Combat text tab bodies), plugin windows with take-over (v89/v90) and the engine's drawers (v90).
+ ///
+ public static bool HostsWindow(bool hasAmbientLight, bool hasSetPanelOpen, bool hasSettingsDrawers, bool hasUiTheme) =>
+ hasAmbientLight && hasSetPanelOpen && hasSettingsDrawers && hasUiTheme;
+
+ public static string Json(bool hostsWindow) => hostsWindow ? WithWindow : NoWindow;
+}
diff --git a/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionWindow.cs b/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionWindow.cs
new file mode 100644
index 0000000..afb51ed
--- /dev/null
+++ b/Plugins/RynthCore.Plugin.RynthVision/Ui/VisionWindow.cs
@@ -0,0 +1,480 @@
+// ============================================================================
+// RynthVision - Ui/VisionWindow.cs
+// The Vision window, drawn whole by RynthVision (2026-10-27; it takes the
+// engine's Vision panel's place, Ui/VisionManifest.cs). Owner's layer rule:
+// the plugin owns its screens. Four tabs, the engine's three as they were
+// (RynthCore ImGui/Panels/VisionFace.cs: same rows, sizes, colours, fonts and
+// saving) and the dungeon light:
+// Terrain the overlays (radar ring, unclimbable slopes, impassable
+// water), colours (AARRGGBB hex + swatch) each with an opacity
+// slider (the colour's alpha byte), tuning sliders (Ctrl+click
+// to type a value), water terrain types, "Log terrain types here";
+// Nameplates } still RynthCore's settings (the engine draws the plates):
+// Combat text } the engine draws these two bodies into this window
+// (RenderSettingsDrawer "nameplates" / "combattext");
+// Light the dungeon light (Light/DungeonLight.cs, c769ab1's Dungeon
+// Light window moved in here): on/off, what it does here
+// ("Lighting in a dungeon: ambient 20% -> 52%."), strength,
+// where, colour. /rv light show opens the window on this tab.
+//
+// Threads: AC's render thread. Terrain edits a private copy of the settings
+// the tick published (SettingsView) and queues just the changed field for the
+// tick (which applies it, saves rynthvision.json and republishes), when a
+// control finishes changing (a slider on release); a newer copy replaces it
+// unless a control is in use. The Light tab reads the LightView the tick
+// publishes; its strength slider lights as it moves and saves when let go.
+// The same file and keys as the engine's panel saved through the plugin's
+// exports, so players keep their choices.
+// Sizes are the engine face's at the default text size, scaled with it.
+// ============================================================================
+
+using System;
+using System.Numerics;
+using ImGuiNET;
+using RynthCore.Plugin.RynthVision.Light;
+using RynthCore.Plugin.Shared;
+using RynthCore.Plugin.Shared.RynthUi;
+using RynthCore.PluginSdk;
+using static RynthCore.Plugin.Shared.RynthUi.RynthUi;
+
+namespace RynthCore.Plugin.RynthVision.Ui;
+
+/// The settings the tick published for the window (a copy; bumps on every change).
+internal sealed record SettingsView(int Version, VisionSettings Settings);
+
+internal sealed class VisionWindow
+{
+ private readonly RynthVisionPlugin _plugin;
+ private readonly RynthCoreHost _host;
+
+ // The engine face's section header colour (ARGB 0xFF7AB8F5).
+ private static readonly Vector4 HeaderColor = Vec(Argb(0xFF7AB8F5));
+ private static readonly string[] TabIds = { "##vtab0", "##vtab1", "##vtab2", "##vtab3" };
+
+ private VisionTab _tab;
+ private VisionSettings? _s;
+ private int _seenVersion = -1;
+ private bool _busy;
+ private string _slopeHex = "", _waterHex = "", _radarHex = "", _waterTypes = "";
+ private float _k = 1f;
+
+ // Light tab.
+ private int? _dragStrength; // the slider's value while it is held
+ private string _lightHex = "FFFFFF";
+ private bool _lightHexEditing;
+
+ public VisionWindow(RynthVisionPlugin plugin, RynthCoreHost host)
+ {
+ _plugin = plugin;
+ _host = host;
+ }
+
+ private float Px(float v) => v * _k;
+
+ /// Draws the window body into the current ImGui window. Render thread.
+ public void Draw()
+ {
+ if (_plugin.TakeTabRequest(out VisionTab asked)) _tab = asked;
+ TakeSnapshot();
+ Vector2 origin = ImGui.GetCursorScreenPos();
+ Vector2 size = ImGui.GetContentRegionAvail();
+ if (size.X < 40 || size.Y < 40) return;
+ ImDrawListPtr frame = ImGui.GetWindowDrawList();
+ frame.AddRectFilled(origin, origin + size, Background, 4);
+ using (PushFont(RynthUiFont.Ui10))
+ {
+ _k = Math.Max(0.5f, ImGui.GetFontSize() / 10f);
+ ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 4));
+ ImGui.SetCursorScreenPos(origin + new Vector2(6, 6));
+ ImGui.Indent(6);
+ float w = size.X - 12;
+ TabStrip(w);
+ // Down to the body's bottom (6 px margin), clear of the host's resize grip in the corner.
+ float room = Math.Max(60, origin.Y + size.Y - 6 - Px(10) - ImGui.GetCursorScreenPos().Y);
+ switch (_tab)
+ {
+ case VisionTab.Terrain: _busy = DrawTerrain(w, room); break;
+ case VisionTab.Light: _busy = false; DrawLight(w, room); break;
+ default: _busy = false; DrawEngineTab(VisionFields.EngineTabKey(_tab)!, w, room); break;
+ }
+ ImGui.Unindent(6);
+ ImGui.PopStyleVar();
+ }
+ frame.AddRect(origin, origin + size, Border, 4);
+ }
+
+ /// Terrain | Nameplates | Combat text | Light, as a row of flat buttons.
+ private void TabStrip(float w)
+ {
+ Vector2 p = ImGui.GetCursorScreenPos();
+ float x = p.X;
+ int n = VisionFields.TabNames.Length;
+ float bw = MathF.Floor((w - 4 * (n - 1)) / n);
+ for (int i = 0; i < n; i++)
+ {
+ bool sel = i == (int)_tab;
+ if (Button(TabIds[i], VisionFields.TabNames[i], new Vector2(x, p.Y), new Vector2(bw, Px(24)), sel ? Accent : Mute,
+ sel ? Selected : ButtonFill, border: sel ? Accent : 0))
+ _tab = (VisionTab)i;
+ if (i == (int)VisionTab.Light) SafeImGui.SetItemTooltip("Dungeon light: lights up dark dungeons (/rv light).");
+ x += bw + 4;
+ }
+ NextLine(p, Px(30));
+ }
+
+ // ── Nameplates, Combat text (the engine's rows) ──────────────────────
+
+ private void DrawEngineTab(string key, float w, float room)
+ {
+ ImGui.BeginChild("##vision_overlays", new Vector2(w, room));
+ float cw = ImGui.GetContentRegionAvail().X - 4;
+ float drawn = _host.RenderSettingsDrawer(key, cw, 0f);
+ if (drawn < 0)
+ {
+ ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + cw);
+ ImGui.PushStyleColor(ImGuiCol.Text, Mute);
+ ImGui.TextUnformatted("This RynthCore can't show these settings here: update RynthCore in the launcher. " +
+ "Chat still sets them: /rv plates.");
+ ImGui.PopStyleColor();
+ ImGui.PopTextWrapPos();
+ }
+ ImGui.EndChild();
+ }
+
+ // ── Terrain (RynthVision's own settings) ─────────────────────────────
+
+ /// The overlays' settings. True while a control is in use.
+ private bool DrawTerrain(float w, float room)
+ {
+ if (_s == null)
+ {
+ Label("Waiting for RynthVision...", Mute);
+ return false;
+ }
+ VisionSettings s = _s;
+ bool busy = false;
+
+ ImGui.BeginChild("##vision_body", new Vector2(w, room));
+ ImGui.PushStyleColor(ImGuiCol.Text, Text);
+ ImGui.PushStyleColor(ImGuiCol.FrameBg, ButtonFill);
+ ImGui.PushStyleColor(ImGuiCol.CheckMark, Accent);
+ ImGui.PushStyleColor(ImGuiCol.SliderGrab, Accent);
+ ImGui.PushStyleColor(ImGuiCol.SliderGrabActive, Highlight);
+
+ Header("Overlays");
+ if (ImGui.Checkbox("Radar range ring", ref s.ShowRadarRing)) { bool v = s.ShowRadarRing; Change(st => st.ShowRadarRing = v); }
+ if (ImGui.Checkbox("Unclimbable slopes", ref s.ShowUnclimbableSlopes)) { bool v = s.ShowUnclimbableSlopes; Change(st => st.ShowUnclimbableSlopes = v); }
+ if (ImGui.Checkbox("Impassable water", ref s.ShowImpassableWater)) { bool v = s.ShowImpassableWater; Change(st => st.ShowImpassableWater = v); }
+
+ Header("Colors (hex AARRGGBB) and opacity");
+ ImGui.PushItemWidth(Math.Max(120, ImGui.GetContentRegionAvail().X - 8));
+ busy |= ColorRow("Slope", "##hex_Slope", ref _slopeHex, ref s.SlopeColorArgb, static (st, c) => st.SlopeColorArgb = c);
+ busy |= OpacitySlider("Slope opacity:", "##Slope opacity", ref _slopeHex, ref s.SlopeColorArgb, static (st, c) => st.SlopeColorArgb = c);
+ busy |= ColorRow("Water", "##hex_Water", ref _waterHex, ref s.WaterColorArgb, static (st, c) => st.WaterColorArgb = c);
+ busy |= OpacitySlider("Water opacity:", "##Water opacity", ref _waterHex, ref s.WaterColorArgb, static (st, c) => st.WaterColorArgb = c);
+ busy |= ColorRow("Radar", "##hex_Radar", ref _radarHex, ref s.RadarRingColorArgb, static (st, c) => st.RadarRingColorArgb = c);
+ busy |= OpacitySlider("Radar ring opacity:", "##Radar ring opacity", ref _radarHex, ref s.RadarRingColorArgb, static (st, c) => st.RadarRingColorArgb = c);
+ ImGui.PopItemWidth();
+
+ Header("Tuning");
+ ImGui.PushItemWidth(Math.Max(120, ImGui.GetContentRegionAvail().X - 8));
+ busy |= Slider("Radar range:", "##Radar range", ref s.RadarRangeWorld, 24, 300, "%.0f", static (st, v) => st.RadarRangeWorld = v);
+ busy |= Slider("Ring thickness:", "##Ring thickness", ref s.RadarRingThickness, 0.5f, 6, "%.1f", static (st, v) => st.RadarRingThickness = v);
+ busy |= Slider("Ring height (m):", "##Ring height (m)", ref s.RadarRingHeight, 0.5f, 30, "%.1f", static (st, v) => st.RadarRingHeight = v);
+ busy |= IntSlider("Slope radius (cells):", "##Slope radius (cells)", ref s.SlopeRenderRadius, 1, VisionSettings.MaxRenderRadius,
+ static (st, v) => st.SlopeRenderRadius = v);
+ busy |= Slider("Slope floor Z:", "##Slope floor Z", ref s.SlopeFloorZ, 0.30f, 0.95f, "%.3f", static (st, v) => st.SlopeFloorZ = v);
+ busy |= Slider("Slope height bias (m):", "##Slope height bias (m)", ref s.SlopeHeightBias, 0.00f, 1.00f, "%.2f",
+ static (st, v) => st.SlopeHeightBias = v);
+ busy |= IntSlider("Water radius (cells):", "##Water radius (cells)", ref s.WaterRenderRadius, 1, VisionSettings.MaxRenderRadius,
+ static (st, v) => st.WaterRenderRadius = v);
+ ImGui.PopItemWidth();
+
+ Header("Water terrain types");
+ if (ImGui.Checkbox("Highlight cell if ANY corner is water (else all four)", ref s.WaterAnyCorner))
+ { bool v = s.WaterAnyCorner; Change(st => st.WaterAnyCorner = v); }
+ if (ImGui.Checkbox("Only paint water cells with an unwalkable triangle (real impassable)", ref s.WaterImpassableOnly))
+ { bool v = s.WaterImpassableOnly; Change(st => st.WaterImpassableOnly = v); }
+ Vector2 p = ImGui.GetCursorScreenPos();
+ bool enter = TextBox("##water_types", ref _waterTypes, p, Px(160), "18,19,20", out bool typing,
+ ImGuiInputTextFlags.EnterReturnsTrue);
+ bool done = ImGui.IsItemDeactivatedAfterEdit();
+ busy |= typing;
+ bool apply = Button("##water_apply", "Apply", new Vector2(p.X + Px(164), p.Y), new Vector2(Px(56), Px(22)), Text, ButtonFill);
+ if (enter || done || apply)
+ {
+ // An empty list resets to the defaults (VisionSettings.NormalizeWaterTypes); the box shows them.
+ int[] types = VisionSettings.NormalizeWaterTypes(VisionFields.ParseCsv(_waterTypes));
+ s.WaterTerrainTypes = types;
+ _waterTypes = VisionFields.Csv(types);
+ Change(st => st.WaterTerrainTypes = types);
+ }
+ NextLine(p, Px(26));
+
+ p = ImGui.GetCursorScreenPos();
+ if (Button("##inspect", "Log terrain types here", p, new Vector2(ButtonWidth("Log terrain types here") + 8, Px(24)), Text, ButtonFill))
+ _plugin.QueueInspectTerrain();
+ SafeImGui.SetItemTooltip("Writes the terrain types under you (stand outdoors) to the RynthCore log (/rv watertypes).");
+ NextLine(p, Px(28));
+
+ ImGui.PopStyleColor(5);
+ ImGui.EndChild();
+ return busy;
+ }
+
+ private void TakeSnapshot()
+ {
+ SettingsView? view = _plugin.Settings;
+ if (view == null || view.Version == _seenVersion || _busy) return;
+ _seenVersion = view.Version;
+ _s = view.Settings.Clone();
+ _slopeHex = _s.SlopeColorArgb.ToString("X8");
+ _waterHex = _s.WaterColorArgb.ToString("X8");
+ _radarHex = _s.RadarRingColorArgb.ToString("X8");
+ _waterTypes = VisionFields.Csv(_s.WaterTerrainTypes);
+ }
+
+ /// Queues one field's change for the tick (applied, saved, republished).
+ private void Change(Action change) => _plugin.QueueSettingsChange(change);
+
+ private void Header(string text)
+ {
+ ImGui.Dummy(new Vector2(0, Px(4)));
+ using (PushFont(RynthUiFont.UiBold11))
+ SafeImGui.TextColored(HeaderColor, text);
+ }
+
+ /// Name | hex box | swatch. Commits on Enter or focus loss; bad input reverts. True while typing.
+ private bool ColorRow(string label, string id, ref string hex, ref uint argb, Action set)
+ {
+ Vector2 p = ImGui.GetCursorScreenPos();
+ ImDrawListPtr dl = ImGui.GetWindowDrawList();
+ float h = Px(22);
+ dl.AddText(new Vector2(p.X, p.Y + (h - ImGui.GetFontSize()) * 0.5f), Text, label);
+ bool enter = TextBox(id, ref hex, new Vector2(p.X + Px(48), p.Y), Px(92), "", out bool typing,
+ ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CharsHexadecimal | ImGuiInputTextFlags.CharsUppercase);
+ bool done = ImGui.IsItemDeactivatedAfterEdit();
+ if (enter || done)
+ {
+ if (VisionFields.TryParseHex(hex, out uint c))
+ {
+ argb = c;
+ Change(st => set(st, c));
+ }
+ hex = argb.ToString("X8");
+ }
+ Vector2 sw = new(p.X + Px(146), p.Y + Px(3));
+ Vector2 swSize = new(Px(22), Px(16));
+ dl.AddRectFilled(sw, sw + swSize, Argb(argb));
+ dl.AddRect(sw, sw + swSize, Mute);
+ NextLine(p, Px(26));
+ return typing;
+ }
+
+ ///
+ /// The colour's alpha as 0-100 %: label, then the slider. Rewrites the alpha byte (RGB kept) and the hex
+ /// box as it moves, saves the colour on release. Untouched, the colour is never rewritten. True while in use.
+ ///
+ private bool OpacitySlider(string label, string id, ref string hex, ref uint argb, Action set)
+ {
+ ImGui.TextUnformatted(label);
+ float pct = VisionFields.OpacityPercent(argb);
+ if (ImGui.SliderFloat(id, ref pct, 0f, 100f, "%.0f%%", ImGuiSliderFlags.AlwaysClamp))
+ {
+ argb = VisionFields.WithOpacity(argb, pct);
+ hex = argb.ToString("X8");
+ }
+ if (ImGui.IsItemDeactivatedAfterEdit()) { uint c = argb; Change(st => set(st, c)); }
+ SafeImGui.SetItemTooltip("0% = invisible, 100% = solid. Ctrl+click to type a value");
+ return ImGui.IsItemActive();
+ }
+
+ /// Label, then the slider; saves on release (or after Ctrl+click typing). True while in use.
+ private bool Slider(string label, string id, ref float value, float min, float max, string format, Action set)
+ {
+ ImGui.TextUnformatted(label);
+ ImGui.SliderFloat(id, ref value, min, max, format, ImGuiSliderFlags.AlwaysClamp);
+ if (ImGui.IsItemDeactivatedAfterEdit()) { float v = value; Change(st => set(st, v)); }
+ ImGui.SetItemTooltip("Ctrl+click to type a value");
+ return ImGui.IsItemActive();
+ }
+
+ private bool IntSlider(string label, string id, ref int value, int min, int max, Action set)
+ {
+ ImGui.TextUnformatted(label);
+ ImGui.SliderInt(id, ref value, min, max, "%d", ImGuiSliderFlags.AlwaysClamp);
+ if (ImGui.IsItemDeactivatedAfterEdit()) { int v = value; Change(st => set(st, v)); }
+ ImGui.SetItemTooltip("Ctrl+click to type a value");
+ return ImGui.IsItemActive();
+ }
+
+ // ── Light (the dungeon light) ────────────────────────────────────────
+
+ private static readonly string[] ScopeLabels = { "Dungeons", "Indoors", "Everywhere" };
+ private static readonly string[] ScopeIds = { "##light_scope0", "##light_scope1", "##light_scope2" };
+ private static readonly string[] ScopeTips =
+ {
+ "Only dungeons: the cells AC itself lights with its dark 20 % dungeon ambient.",
+ "Dungeons and building interiors.",
+ "Everywhere, outdoors too (dark nights). Never darker than AC's own light.",
+ };
+ private static readonly string[] PresetIds = { "##light_white", "##light_torch", "##light_moon" };
+ private static readonly string[] PresetLabels = { "White", "Torch", "Moon" };
+
+ private const string LightHelp =
+ "Lights up dark dungeons, like SkunkVision's Dungeon Light.\n\n" +
+ "It raises the ambient light this client draws the world with: walls, floors, monsters and items " +
+ "all get brighter, torches and the fog stay as they are. It is drawing only: nothing is sent to the " +
+ "server and nobody else sees a difference.\n\n" +
+ "Strength 0 is AC's own dungeon (20 % ambient), 100 lights everything fully (flat, no shading).\n\n" +
+ "Chat: /rv light (on/off), /rv light 0-100, /rv light dungeons|indoors|everywhere, " +
+ "/rv light color RRGGBB|white|torch|moon, /rv light status, /rv light show (this tab).";
+
+ private void DrawLight(float w, float room)
+ {
+ LightView view = _plugin.LightState;
+ ImGui.BeginChild("##vision_light", new Vector2(w, room));
+ float cw = ImGui.GetContentRegionAvail().X - Px(4);
+
+ Header("Dungeon light");
+ Vector2 p = ImGui.GetCursorScreenPos();
+ float h = Px(26), iconW = Px(24);
+ string label = view.On ? "Dungeon light: ON" : "Dungeon light: OFF";
+ if (Button("##light_toggle", label, p, new Vector2(cw - iconW - Px(4), h), Text, view.On ? AccentFill : ButtonFill,
+ border: view.On ? Accent : 0))
+ {
+ bool on = !view.On;
+ _plugin.QueueSettingsChange(st => st.LightOn = on);
+ }
+ // Tooltips go through SafeImGui: ImGui reads them as printf formats ("20 %" would read an argument).
+ SafeImGui.SetItemTooltip("Switch the dungeon light on or off (/rv light).");
+ IconButton("##light_help", RynthIcons.Info, new Vector2(p.X + cw - iconW, p.Y), new Vector2(iconW, h), Mute, ButtonFill,
+ font: RynthUiFont.Ui11);
+ if (ImGui.IsItemHovered())
+ {
+ ImGui.BeginTooltip();
+ ImGui.PushTextWrapPos(ImGui.GetFontSize() * 28);
+ ImGui.TextUnformatted(LightHelp);
+ ImGui.PopTextWrapPos();
+ ImGui.EndTooltip();
+ }
+ NextLine(p, h + Px(6));
+
+ // What it does here: "Lighting in a dungeon: ambient 20% -> 52%." (or why it can't).
+ ImGui.PushTextWrapPos(ImGui.GetCursorPosX() + cw);
+ ImGui.PushStyleColor(ImGuiCol.Text, view.Warn ? Highlight : Mute);
+ SafeImGui.TextWrapped(view.Status);
+ ImGui.PopStyleColor();
+ ImGui.PopTextWrapPos();
+
+ Header("Strength");
+ int v = _dragStrength ?? view.Strength;
+ ImGui.PushStyleColor(ImGuiCol.FrameBg, ButtonFill);
+ ImGui.PushStyleColor(ImGuiCol.SliderGrab, Accent);
+ ImGui.PushStyleColor(ImGuiCol.SliderGrabActive, Highlight);
+ ImGui.SetNextItemWidth(cw);
+ bool changed = ImGui.SliderInt("##light_strength", ref v, 0, 100, "%d%%", ImGuiSliderFlags.AlwaysClamp);
+ bool active = ImGui.IsItemActive();
+ bool released = ImGui.IsItemDeactivatedAfterEdit();
+ ImGui.PopStyleColor(3);
+ SafeImGui.SetItemTooltip("0 = AC's own dungeon (20 % ambient), 100 = fully lit. Ctrl+click to type a value.");
+ int strength = v;
+ if (changed) _plugin.QueueSettingsChange(st => st.LightStrength = Math.Clamp(strength, 0, 100), save: false); // lights as it moves
+ if (released) _plugin.QueueSettingsChange(st => st.LightStrength = Math.Clamp(strength, 0, 100)); // saved when let go
+ _dragStrength = active ? v : null;
+
+ Header("Where");
+ p = ImGui.GetCursorScreenPos();
+ float bh = Px(22), gap = Px(4);
+ float bw = MathF.Floor((cw - 2 * gap) / 3f);
+ for (int i = 0; i < 3; i++)
+ {
+ bool sel = (int)view.Scope == i;
+ if (Button(ScopeIds[i], ScopeLabels[i], new Vector2(p.X + i * (bw + gap), p.Y), new Vector2(bw, bh),
+ sel ? Accent : Text, sel ? Selected : ButtonFill, border: sel ? Accent : 0))
+ {
+ int scope = i;
+ _plugin.QueueSettingsChange(st => st.LightScope = scope);
+ }
+ SafeImGui.SetItemTooltip(ScopeTips[i]);
+ }
+ NextLine(p, bh + Px(4));
+
+ Header("Colour");
+ DrawLightColor(view, cw);
+
+ ImGui.EndChild();
+ }
+
+ /// Swatch, the presets (white, torch, moon), then any colour as RRGGBB hex.
+ private void DrawLightColor(LightView view, float cw)
+ {
+ Vector2 p = ImGui.GetCursorScreenPos();
+ ImDrawListPtr dl = ImGui.GetWindowDrawList();
+ float h = Px(22), gap = Px(4);
+ dl.AddRectFilled(p, p + new Vector2(h, h), Argb(view.ColorArgb | 0xFF000000u), 3);
+ dl.AddRect(p, p + new Vector2(h, h), Border, 3);
+
+ float x = p.X + h + gap;
+ float hexW = Px(70);
+ float bw = MathF.Floor((cw - h - hexW - 4 * gap) / 3f);
+ for (int i = 0; i < 3; i++)
+ {
+ uint preset = DungeonLight.Presets[i].Argb;
+ bool sel = (view.ColorArgb & 0xFFFFFF) == (preset & 0xFFFFFF);
+ if (Button(PresetIds[i], PresetLabels[i], new Vector2(x, p.Y), new Vector2(bw, h),
+ sel ? Accent : Text, sel ? Selected : ButtonFill, border: sel ? Accent : 0))
+ SetLightColor(preset);
+ x += bw + gap;
+ }
+
+ if (!_lightHexEditing) _lightHex = (view.ColorArgb & 0xFFFFFF).ToString("X6");
+ bool enter = TextBox("##light_hex", ref _lightHex, new Vector2(x, p.Y), p.X + cw - x, "", out _lightHexEditing,
+ ImGuiInputTextFlags.CharsHexadecimal | ImGuiInputTextFlags.CharsUppercase | ImGuiInputTextFlags.EnterReturnsTrue, 7);
+ bool done = ImGui.IsItemDeactivatedAfterEdit();
+ SafeImGui.SetItemTooltip("Any colour as RRGGBB hex; Enter to use it.");
+ if ((enter || done) && DungeonLight.TryParseColor(_lightHex, out uint c))
+ SetLightColor(c);
+ NextLine(p, h + Px(6));
+ }
+
+ private void SetLightColor(uint argb)
+ {
+ uint c = 0xFF000000u | (argb & 0x00FFFFFFu);
+ _plugin.QueueSettingsChange(st => st.LightColorArgb = c);
+ }
+
+ // ── Layout and the engine faces' text box ────────────────────────────
+
+ /// Moves the layout cursor to the start of the line below a row drawn at .
+ private static void NextLine(Vector2 rowStart, float rowHeight)
+ {
+ ImGui.SetCursorScreenPos(new Vector2(rowStart.X, rowStart.Y + rowHeight));
+ ImGui.Dummy(Vector2.Zero);
+ }
+
+ ///
+ /// FaceKit's bordered text box with a grey while empty. True when Enter was
+ /// pressed (with EnterReturnsTrue) or the text changed; while it is typed in.
+ ///
+ private bool TextBox(string id, ref string text, Vector2 pos, float width, string hint, out bool active,
+ ImGuiInputTextFlags flags = ImGuiInputTextFlags.None, uint maxLength = 128)
+ {
+ float height = Px(22);
+ ImGui.SetCursorScreenPos(pos);
+ ImGui.SetNextItemWidth(width);
+ ImGui.PushStyleColor(ImGuiCol.FrameBg, ButtonFill);
+ ImGui.PushStyleColor(ImGuiCol.Text, Text);
+ ImGui.PushStyleColor(ImGuiCol.Border, Border);
+ ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1f);
+ ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(4, (height - ImGui.GetFontSize()) * 0.5f));
+ ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 3f);
+ bool result = ImGui.InputText(id, ref text, maxLength, flags);
+ active = ImGui.IsItemActive();
+ ImGui.PopStyleVar(3);
+ ImGui.PopStyleColor(3);
+ if (text.Length == 0 && !active && hint.Length > 0)
+ ImGui.GetWindowDrawList().AddText(pos + new Vector2(5, (height - ImGui.GetFontSize()) * 0.5f), Faded(Mute), hint);
+ return result;
+ }
+}
diff --git a/Plugins/RynthCore.Plugin.RynthVision/VisionSettings.cs b/Plugins/RynthCore.Plugin.RynthVision/VisionSettings.cs
index c41d458..fe57ba1 100644
--- a/Plugins/RynthCore.Plugin.RynthVision/VisionSettings.cs
+++ b/Plugins/RynthCore.Plugin.RynthVision/VisionSettings.cs
@@ -9,8 +9,11 @@ namespace RynthCore.Plugin.RynthVision;
///
/// Feature toggles and colours for RynthVision overlays. Colours are ARGB
/// (0xAARRGGBB) to match the engine's Nav3D API. Persists to
-/// %APPDATA%\RynthCore\rynthvision.json; the engine's Vision panels (ImGui face
-/// and Avalonia twin) read and write these through the plugin's JSON exports.
+/// %APPDATA%\RynthCore\rynthvision.json. RynthVision's own Vision window
+/// (Ui/VisionWindow.cs, 2026-10-27) edits a copy () and queues
+/// each change for the tick; the engine's Vision panels (its ImGui face on an
+/// older engine, the Avalonia twin) still read and write these through the
+/// plugin's JSON exports. Same file and keys either way, so nothing to migrate.
///
internal sealed class VisionSettings
{
@@ -81,6 +84,17 @@ internal sealed class VisionSettings
// water" view that doesn't signal impassability.
public bool WaterImpassableOnly = true;
+ // Dungeon light (2026-10-27; Light/DungeonLight.cs): raises the ambient light AC draws
+ // dungeons with (RynthCore's ambient light floor, plugin API v91). Off by default. Strength
+ // 0-100 maps onto an ambient of 20 % (AC's own dungeon) to 100 %; the colour tints it (ARGB,
+ // alpha always FF); the scope is where it lights (LightScope: 0 dungeons, 1 also buildings,
+ // 2 also outdoors). The engine's Vision panel doesn't show these (plugin screens move out
+ // of the engine, RynthCore CLAUDE.md): the Light tab of RynthVision's own Vision window and /rv light.
+ public bool LightOn = false;
+ public int LightStrength = Light.DungeonLight.DefaultStrength;
+ public uint LightColorArgb = Light.DungeonLight.DefaultColor;
+ public int LightScope = (int)Light.LightScope.Dungeons;
+
// ── JSON bridge (manual build + JsonDocument parse — both AOT-safe) ───────
///
@@ -106,7 +120,11 @@ internal sealed class VisionSettings
+ $"\"waterRadius\":{WaterRenderRadius},"
+ $"\"waterAnyCorner\":{(WaterAnyCorner ? 1 : 0)},"
+ $"\"waterImpassableOnly\":{(WaterImpassableOnly ? 1 : 0)},"
- + $"\"waterTypes\":[{string.Join(",", WaterTerrainTypes)}]"
+ + $"\"waterTypes\":[{string.Join(",", WaterTerrainTypes)}],"
+ + $"\"light\":{(LightOn ? 1 : 0)},"
+ + $"\"lightStrength\":{LightStrength},"
+ + $"\"lightColor\":{LightColorArgb},"
+ + $"\"lightScope\":{LightScope}"
+ "}";
}
@@ -133,14 +151,35 @@ internal sealed class VisionSettings
{
var list = new List();
foreach (var e in v.EnumerateArray())
- if (e.TryGetInt32(out int n) && n >= 0 && n <= 31 && !list.Contains(n)) list.Add(n);
- // An empty (or all-invalid) list would match nothing and paint no
- // water ever, so it means "back to the defaults". The panels then
- // re-read the settings and show the defaults.
- WaterTerrainTypes = list.Count > 0 ? list.ToArray() : (int[])DefaultWaterTerrainTypes.Clone();
+ if (e.TryGetInt32(out int n)) list.Add(n);
+ WaterTerrainTypes = NormalizeWaterTypes(list);
}
+ // Out-of-range light values are pulled into range (a hand-edited file, an older panel).
+ if (r.TryGetProperty("light", out v)) LightOn = v.GetInt32() != 0;
+ if (r.TryGetProperty("lightStrength", out v)) LightStrength = Math.Clamp(v.GetInt32(), 0, 100);
+ if (r.TryGetProperty("lightColor", out v)) LightColorArgb = 0xFF000000u | (v.GetUInt32() & 0x00FFFFFFu);
+ if (r.TryGetProperty("lightScope", out v)) LightScope = Math.Clamp(v.GetInt32(), 0, 2);
}
+ ///
+ /// The water types to keep from : 0..31, each once, in order. An empty
+ /// (or all-invalid) list would match nothing and paint no water ever, so it means "back to the
+ /// defaults"; the window (or a panel) then shows the defaults.
+ ///
+ public static int[] NormalizeWaterTypes(IEnumerable types)
+ {
+ var list = new List();
+ foreach (int n in types)
+ if (n >= 0 && n <= 31 && !list.Contains(n)) list.Add(n);
+ return list.Count > 0 ? list.ToArray() : (int[])DefaultWaterTerrainTypes.Clone();
+ }
+
+ ///
+ /// A copy for the window (published by the tick, read on AC's render thread). The water list is
+ /// shared: it is replaced, never changed in place.
+ ///
+ public VisionSettings Clone() => (VisionSettings)MemberwiseClone();
+
// ── Persistence ───────────────────────────────────────────────────────────
private static string FilePath => Path.Combine(
diff --git a/Shared/RynthCore.TerrainData/TerrainSampler.cs b/Shared/RynthCore.TerrainData/TerrainSampler.cs
index 7da909d..1e5d68e 100644
--- a/Shared/RynthCore.TerrainData/TerrainSampler.cs
+++ b/Shared/RynthCore.TerrainData/TerrainSampler.cs
@@ -259,6 +259,27 @@ public sealed class TerrainSampler : IDisposable
return (words[idx] >> 2) & 0x1F;
}
+ /// EnvCell flag: the cell sees outside (a building's room), from the cell's dat entry.
+ public const uint EnvCellSeenOutside = 0x01;
+
+ ///
+ /// The flags word of EnvCell (0xLLLLCCCC, CCCC 0x0100 and up) from the
+ /// cell dat: the uint after the cell's id ( = 0x01, static objects
+ /// 0x02, weenies 0x04, restriction 0x08; the same read as RynthNav.Baker's AppendCells). AC itself
+ /// lights an EnvCell from the sky when SeenOutside is set and with its flat dungeon ambient when
+ /// not (CellManager::ChangePosition). False for an outdoor cell id, before
+ /// , or when the cell isn't in the dat. Any thread (the dat reader locks).
+ ///
+ public bool TryGetEnvCellFlags(uint cellId, out uint flags)
+ {
+ flags = 0;
+ if (!_ready || (cellId & 0xFFFF) < 0x100 || (cellId & 0xFFFF) >= 0xFFFE) return false;
+ byte[]? data = _cellDat.GetFileData(cellId);
+ if (data == null || data.Length < 8) return false;
+ flags = BitConverter.ToUInt32(data, 4);
+ return true;
+ }
+
private static string? FindDat(string folder, params string[] names)
{
foreach (var n in names)
diff --git a/Tools/RynthCore.RynthAiHostTests/Program.cs b/Tools/RynthCore.RynthAiHostTests/Program.cs
index c85bae4..16c0797 100644
--- a/Tools/RynthCore.RynthAiHostTests/Program.cs
+++ b/Tools/RynthCore.RynthAiHostTests/Program.cs
@@ -122,6 +122,7 @@ internal static class Program
ManaStoneChoiceTests.Register(runner);
CustomDebuffTests.Register(runner);
DebuffRenewTests.Register(runner);
+ VoidDebuffTests.Register(runner);
ProfileLoadTests.Register(runner);
ActivityInterfaceTests.Register(runner);
CastNoDamageTests.Register(runner);
diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/MonsterEditorTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/MonsterEditorTests.cs
index 0fe6df4..f3204f9 100644
--- a/Tools/RynthCore.RynthAiHostTests/Tests/MonsterEditorTests.cs
+++ b/Tools/RynthCore.RynthAiHostTests/Tests/MonsterEditorTests.cs
@@ -42,7 +42,9 @@ internal static class MonsterEditorTests
{
Name = "Olthoi", Category = "Olthoi nest", MatchExpression = "getcharintprop[25]>=200",
Priority = 3, DamageType = "Acid", WeaponId = 0x50001234, Fester = true, Broadside = true,
- GravityWell = true, Imperil = true, Yield = true, Vuln = true, UseArc = true, UseRing = true,
+ GravityWell = true, Imperil = true, Yield = true, Vuln = true,
+ Corrosion = true, Corruption = true, DestructiveCurse = true, WeakeningCurse = true, FesteringCurse = true,
+ UseArc = true, UseRing = true,
UseStreak = true, UseBolt = false, UseBlast = true, UseWall = true, ExVuln = "Fire", OffhandId = 2,
PetDamage = "Cold", CustomDebuffs = "Corrosion Vulnerability Other, Fire Vulnerability Other VII",
Kite = "PullAway",
diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/VoidDebuffTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/VoidDebuffTests.cs
new file mode 100644
index 0000000..897e097
--- /dev/null
+++ b/Tools/RynthCore.RynthAiHostTests/Tests/VoidDebuffTests.cs
@@ -0,0 +1,113 @@
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text.Json;
+using RynthCore.Plugin.RynthAi;
+using RynthCore.Plugin.RynthAi.LegacyUi;
+using RynthCore.RynthAiHostTests.Fakes;
+using RynthCore.RynthAiTests.Harness;
+
+namespace RynthCore.RynthAiHostTests.Tests;
+
+// 2026-10-27: the Void debuffs as Monsters-rule switches (VTank's Cs, Cp, DC, WC and FC columns):
+// Corrosion, Corruption and Destructive Curse (Nether damage over time), Weakening Curse and
+// Festering Curse. They were only castable as typed-in custom debuffs.
+internal static class VoidDebuffTests
+{
+ private const uint Player = 0x50000181;
+ private const uint STypeCreature = 31, STypeLife = 33, STypeVoid = 43;
+
+ public static void Register(Runner r)
+ {
+ r.Add("void debuffs: every one has levels I-VII and an Incantation in the spell data, with its duration", SpellData);
+ r.Add("void debuffs: a rule's switches go in the debuff list after the Creature ones", DebuffList);
+ r.Add("void debuffs: the level is capped by Void Magic alone", VoidCap);
+ r.Add("void debuffs: an engine that doesn't send them can't turn them off", Carried);
+ }
+
+ private static void SpellData()
+ {
+ var seconds = new Dictionary
+ {
+ ["Corrosion"] = 16, ["Corruption"] = 31, ["Destructive Curse"] = 31, ["Weakening Curse"] = 15, ["Festering Curse"] = 30,
+ };
+ Check.Eq(CombatManager.VoidDebuffBases.Length, 5, "five Void debuffs");
+ string[] numerals = { "I", "II", "III", "IV", "V", "VI", "VII" };
+ foreach (string b in CombatManager.VoidDebuffBases)
+ {
+ foreach (string n in numerals)
+ Check.True(SpellDatabase.GetIdByName($"{b} {n}") > 0, $"{b} {n} exists");
+ int top = SpellDatabase.GetIdByName($"Incantation of {b}");
+ Check.True(top > 0, $"Incantation of {b} exists");
+ Check.Eq(SpellDatabase.DurationSeconds(top), seconds[b], $"{b} lasts {seconds[b]} s");
+ }
+ }
+
+ private static void DebuffList()
+ {
+ MethodInfo build = typeof(CombatManager).GetMethod("BuildDebuffList", BindingFlags.NonPublic | BindingFlags.Static)!;
+ var rule = new MonsterRule { Name = "Mosswart", Imperil = true, Corrosion = true, DestructiveCurse = true, FesteringCurse = true, CustomDebuffs = "Corrosion Vulnerability Other" };
+ var list = (List)build.Invoke(null, new object[] { rule, "Fire" })!;
+ Check.Eq(string.Join("|", list), "Imperil|Void:Corrosion|Void:Destructive Curse|Void:Festering Curse|Custom:Corrosion Vulnerability Other",
+ "Creature first, then Void, then the typed-in ones");
+ var none = (List)build.Invoke(null, new object[] { new MonsterRule { Name = "Drudge" }, "Fire" })!;
+ Check.Eq(none.Count, 0, "a new rule (and an old file) has none on");
+ }
+
+ private static void VoidCap()
+ {
+ FakeHost.Reset();
+ foreach (string n in new[] { "Corrosion I", "Corrosion II", "Corrosion VII", "Weakening Curse VII" })
+ foreach (var row in SpellTable.Named(n)) FakeHost.Spellbook.Add((uint)row.Id);
+ FakeHost.Skills[(Player, STypeCreature)] = (400, 3); // tier 7 by the thresholds below
+ FakeHost.Skills[(Player, STypeLife)] = (400, 3);
+ FakeHost.Skills[(Player, STypeVoid)] = (60, 2); // tier 2
+ var s = new LegacyUiSettings
+ {
+ MinSkillLevelTier1 = 0, MinSkillLevelTier2 = 50, MinSkillLevelTier3 = 100, MinSkillLevelTier4 = 150,
+ MinSkillLevelTier5 = 200, MinSkillLevelTier6 = 300, MinSkillLevelTier7 = 350, MinSkillLevelTier8 = 10000,
+ };
+ var host = FakeHost.Create(Player);
+ var cache = FakeHost.MakeCache(host, Player, System.Array.Empty());
+ var c = new CombatManager(host, s, cache);
+ c.SetPlayerId(Player);
+ var skills = new CharacterSkills(host);
+ skills.SetPlayerId(Player);
+ var sm = new SpellManager(host, s);
+ sm.InitializeNatively();
+ sm.SetCharacterSkills(skills);
+ sm.RefreshKnownSpells();
+ c.SetSpellManager(sm);
+
+ MethodInfo find = typeof(CombatManager).GetMethod("FindBestVoidDebuffWithTier", BindingFlags.NonPublic | BindingFlags.Instance)!;
+ object[] args = { "Corrosion", 0 };
+ int id = (int)find.Invoke(c, args)!;
+ Check.Eq(SpellTableStub.GetById(id)?.Name, "Corrosion II", "Void at tier 2 casts II, though Creature and Life reach VII");
+ Check.Eq((int)args[1], 2, "tier 2");
+
+ object[] curse = { "Weakening Curse", 0 };
+ Check.Eq((int)find.Invoke(c, curse)!, 0, "only VII known, above the Void cap: nothing to cast");
+ object[] unknown = { "Corruption", 0 };
+ Check.Eq((int)find.Invoke(c, unknown)!, 0, "a debuff the character doesn't know: nothing");
+ }
+
+ private static void Carried()
+ {
+ var current = new List
+ {
+ new() { Name = "Default", Corrosion = true, WeakeningCurse = true },
+ new() { Name = "Drudge", Corruption = true, DestructiveCurse = true, FesteringCurse = true },
+ };
+ var incoming = new List { new() { Name = "Default" }, new() { Name = "drudge" }, new() { Name = "Mosswart" } };
+ LegacyDashboardRenderer.CarryVoidDebuffs(current, incoming);
+ Check.True(incoming[0].Corrosion && incoming[0].WeakeningCurse && !incoming[0].Corruption, "Default keeps its own");
+ Check.True(incoming[1].Corruption && incoming[1].DestructiveCurse && incoming[1].FesteringCurse, "matched by name, any case");
+ Check.False(incoming[2].Corrosion, "a new rule stays off");
+
+ // The bridge looks for the key "Corrosion": a rule saved with it has it, and a typed-in
+ // debuff named Corrosion is a value, not the key.
+ string json = JsonSerializer.Serialize(new List { new() { Name = "X", CustomDebuffs = "Corrosion" } }, RynthAiJsonContext.Default.MonsterRuleList);
+ Check.True(json.Contains("\"Corrosion\":"), "the plugin writes the key with a colon after it");
+ string old = "[{\"Name\":\"X\",\"CustomDebuffs\":\"Corrosion\"}]";
+ Check.False(old.Contains("\"Corrosion\":"), "a typed-in Corrosion doesn't look like the key");
+ }
+}
diff --git a/Tools/RynthDefective.Tests/BarTests.cs b/Tools/RynthDefective.Tests/BarTests.cs
new file mode 100644
index 0000000..715873c
--- /dev/null
+++ b/Tools/RynthDefective.Tests/BarTests.cs
@@ -0,0 +1,266 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using RynthCore.Plugin.RynthDefective;
+using RynthCore.Plugin.RynthDefective.Items;
+using RynthCore.Plugin.RynthDefective.Model;
+using RynthCore.Plugin.RynthDefective.ShortcutBar;
+using RynthCore.Plugin.RynthDefective.Ui;
+using RynthCore.Plugin.RynthDefective.Use;
+using RynthCore.Plugin.RynthDefective.Views;
+
+namespace RynthDefective.Tests
+{
+ // The Shortcuts bar's own logic (2026-10-27): which slot a bar slot is (usual / independent),
+ // a healing kit in one of AC's slots used on yourself, copying AC's 18 slots into an independent
+ // bar, the setting in the character's file, and the settings window.
+ internal static partial class Program
+ {
+ /// A session with AC's 18 slots scripted and every own-slot key bind recorded.
+ private sealed class BarRig
+ {
+ public readonly Rig R;
+ public DefSession S => R.S;
+ public uint[] RetailIds = new uint[DefSettings.RetailSlots], RetailSpells = new uint[DefSettings.RetailSlots];
+ public bool RetailReadable = true;
+ public readonly Dictionary CommandKeys = new();
+ public readonly Dictionary Names = new();
+ public readonly List<(int Own, string Key)> Bound = new();
+
+ public BarRig(string name)
+ {
+ R = new Rig(name);
+ S.ReadRetail = (ids, spells) =>
+ {
+ if (!RetailReadable) return false;
+ RetailIds.CopyTo(ids, 0);
+ RetailSpells.CopyTo(spells, 0);
+ return true;
+ };
+ S.ObjectName = id => Names.TryGetValue(id, out string? n) ? n : null;
+ S.CommandKeys = c => CommandKeys.TryGetValue(c, out string? k) ? k : string.Empty;
+ S.BindOwnKey = (own, key) => { Bound.Add((own, key)); return true; };
+ }
+ }
+
+ private static void BarMappingUsualAndIndependent()
+ {
+ // The usual bar: 1-18 AC's, 18+N own N.
+ Check(BarMapping.IsRetail(1, false) && BarMapping.IsRetail(18, false) && !BarMapping.IsRetail(19, false), "usual: 1-18 are the game's");
+ Eq(BarMapping.OwnSlot(5, false), 0, "usual: a game slot is no own slot");
+ Eq(BarMapping.OwnSlot(19, false), 1, "usual: bar 19 is own 1");
+ Eq(BarMapping.OwnSlot(DefSettings.BarSlotsMax, false), DefSettings.BarSlotsMax - DefSettings.RetailSlots, "usual: the last bar slot");
+ Eq(BarMapping.KeyAction(3, false), "UseQuickSlot_3", "usual: a game slot's keys are AC's keymap action");
+ Eq(BarMapping.KeyAction(20, false), "/rdef use 2", "usual: bar 20's keys run /rdef use 2");
+ Eq(BarMapping.BarNumber(1, false), 19, "usual: own 1 shows at 19");
+
+ // Independent: no AC slot is mapped; bar N is own N, keys /rdef use N.
+ for (int n = 1; n <= DefSettings.BarSlotsMax; n++)
+ {
+ if (BarMapping.IsRetail(n, true)) { Check(false, $"independent: bar {n} must not be a game slot"); break; }
+ if (BarMapping.OwnSlot(n, true) != n || BarMapping.BarNumber(n, true) != n) { Check(false, $"independent: bar {n} is own {n}"); break; }
+ }
+ Eq(BarMapping.KeyAction(1, true), "/rdef use 1", "independent: bar 1's keys are an engine hotkey");
+ Eq(BarMapping.KeyAction(18, true), "/rdef use 18", "independent: bar 18 too");
+ Check(DefSettings.SlotsMax >= DefSettings.BarSlotsMax, "an independent bar as long as the usual one has an own slot for every bar slot");
+ for (int own = 1; own <= DefSettings.BarSlotsMax - DefSettings.RetailSlots; own++)
+ if (BarMapping.OwnSlot(BarMapping.BarNumber(own, false), false) != own) { Check(false, "usual: own -> bar -> own round trip " + own); break; }
+ Check(true, "mapping round trips");
+ }
+
+ private static void BarRetailKit()
+ {
+ var kit = Kit(0x7100_0001u);
+ var potion = Potion(0x7100_0002u);
+ var sword = Melee(0x7100_0003u, "Sword");
+ var nameKit = Item(0x7100_0004u, "Greater Stamina Kit"); // the engine couldn't read the bitfield: RynthAi's name test
+ var items = new List { kit, potion, sword, nameKit };
+
+ Check(BarMapping.RetailKit(kit.Id, items) == kit, "a healing kit in a game slot is the use-on-self path");
+ Check(BarMapping.RetailKit(nameKit.Id, items) == nameKit, "a kit known by its name only, too");
+ Check(BarMapping.RetailKit(potion.Id, items) == null, "a potion stays AC's");
+ Check(BarMapping.RetailKit(sword.Id, items) == null, "a weapon stays AC's");
+ Check(BarMapping.RetailKit(0x7100_00FFu, items) == null, "an object not in the pack stays AC's");
+ Check(BarMapping.RetailKit(0, items) == null, "an empty slot (or a spell) stays AC's");
+
+ // Through the session: the click becomes a use on yourself in the use controller.
+ var rig = new Rig("retail-kit");
+ rig.Inv = items;
+ Check(!rig.S.UseRetailSlot(2, potion.Id) && !rig.S.Use.HasPending, "a potion click is handed to AC (nothing queued here)");
+ Check(rig.S.UseRetailSlot(1, kit.Id), "a kit click is taken");
+ UseRequest? req = rig.S.Use.Pending;
+ Check(req != null && req.Mode == UseMode.OnSelf && req.Item!.Id == kit.Id && req.Source.Contains("game slot 1"), "queued as a use on yourself");
+
+ var world = new FakeWorld { Inventory = items };
+ rig.S.Use.Tick(world);
+ Check(world.Sent.Count == 1 && world.Sent[0] == $"useon {kit.Id:X} me", "sent as UseObjectOn(kit, you): " + string.Join(";", world.Sent));
+ }
+
+ private static void BarIndependentCopy()
+ {
+ var b = new BarRig("copy");
+ var kit = Kit(0x7200_0001u);
+ var potion = Potion(0x7200_0002u);
+ var sword = Melee(0x7200_0003u, "Sword");
+ var own1 = Potion(0x7200_0010u, "Mana Potion", 3);
+ var own2 = Melee(0x7200_0011u, "Axe");
+ b.R.Inv = new List { kit, potion, sword, own1, own2 };
+ // The usual bar: AC's slots 1, 2, 5 hold items, 7 a spell, 9 an item not in the pack (named), 10 one nobody can name.
+ b.RetailIds[0] = kit.Id; b.RetailIds[1] = potion.Id; b.RetailIds[4] = sword.Id;
+ b.RetailSpells[6] = 1234;
+ b.RetailIds[8] = 0x7200_0099u; b.Names[0x7200_0099u] = "Lucky Gold Letter";
+ b.RetailIds[9] = 0x7200_00AAu;
+ // Own slots 1 and 2 (bar 19 and 20), with keys on own 1.
+ b.S.SetSlot(1, own1);
+ b.S.SetSlot(2, own2);
+ b.S.Data.Slots[1].Mode = UseMode.Equip;
+ b.CommandKeys["/rdef use 1"] = "F9, Ctrl+F9";
+ DefData before = DefStore.Parse(System.Text.Json.JsonDocument.Parse(DefStore.ToJson(b.S.Data)).RootElement);
+
+ // Not independent yet: no copy.
+ Check(b.S.CopyRetailSlots().Contains("independent first") && b.S.Data.Slots[0].Item!.Id == own1.Id, "the copy needs the independent bar");
+
+ int saves = b.R.Saves;
+ string m = b.S.SetIndependent(true);
+ Check(b.S.Settings.IndependentBar && b.R.Saves > saves, "turned on, saved");
+ Eq(b.S.CopyOffer, 5, "the offer counts the game's slots with an item (not the spell)");
+ Check(m.Contains("independent") && m.Contains("5 items") && m.Contains("offers to copy"), "and says so: " + m);
+ Check(b.S.Data.Slots[0].Item!.Id == own1.Id && b.S.Data.Slots[1].Item!.Id == own2.Id && b.S.Data.Slots[2].Empty,
+ "turning it on copies nothing by itself");
+
+ m = b.S.CopyRetailSlots();
+ Eq(b.S.CopyOffer, 0, "the offer is answered");
+ List s = b.S.Data.Slots;
+ Check(s[0].Item?.Id == kit.Id && s[1].Item?.Id == potion.Id && s[4].Item?.Id == sword.Id, "the game's items are in own 1, 2, 5");
+ Check(s[0].Mode == UseMode.Auto && s[0].Item!.Name == "Peerless Healing Kit" && s[0].Item!.Wcid == 628, "copied with their identity, automatic use");
+ Check(s[6].Empty, "a spell can't be copied: the slot stays empty");
+ Check(s[8].Item?.Name == "Lucky Gold Letter" && s[8].Item!.Id == 0x7200_0099u, "an item the pack read missed goes by the name the client knows");
+ Check(s[9].Empty, "one nobody can name stays empty");
+ Check(s[2].Empty && s[3].Empty && s[17].Empty, "the game's empty slots stay empty");
+ Check(s[18].Item?.Id == own1.Id && s[19].Item?.Id == own2.Id && s[19].Mode == UseMode.Equip, "the own slots moved to 19 and 20, modes and all");
+ Check(s.Skip(20).All(x => x.Empty), "nothing past them");
+ Eq(s.Count, DefSettings.SlotsMax, "still 42 own slots");
+ Check(b.Bound.Count == 2 && b.Bound.Contains((19, "F9")) && b.Bound.Contains((19, "Ctrl+F9")), "own 1's keys follow it to 19: " + string.Join(";", b.Bound));
+ Check(m.Contains("Copied 4") && m.Contains("2 couldn't") && m.Contains("2 slots moved") && m.Contains("2 keys"), "and it says what it did: " + m);
+ for (int n = 1; n <= 20; n++)
+ {
+ // The independent bar shows what the usual one did: bar N is own N.
+ ItemRef? shown = s[BarMapping.OwnSlot(n, true) - 1].Item;
+ ItemRef? was = n <= DefSettings.RetailSlots ? null : before.Slots[BarMapping.OwnSlot(n, false) - 1].Item;
+ if (n > DefSettings.RetailSlots && shown?.Id != was?.Id) { Check(false, $"bar {n} keeps its item"); break; }
+ }
+
+ // Declining, turning off, refusing.
+ b.S.SetIndependent(false);
+ b.S.SetIndependent(true);
+ b.S.DeclineCopy();
+ Eq(b.S.CopyOffer, 0, "no thanks clears the offer");
+ m = b.S.SetIndependent(false);
+ Check(!b.S.Settings.IndependentBar && b.S.CopyOffer == 0 && m.Contains("19"), "turned off: no offer, and says where the own slots are");
+ Check(s[0].Item?.Id == kit.Id && s[18].Item?.Id == own1.Id, "turning off changes no slot");
+
+ var full = new BarRig("copy-full");
+ full.R.Inv = new List { kit, own1 };
+ full.RetailIds[0] = kit.Id;
+ full.S.SetSlot(30, own1);
+ full.S.SetIndependent(true);
+ m = full.S.CopyRetailSlots();
+ Check(m.Contains("slot 30") && m.Contains("no room") && full.S.Data.Slots[0].Empty && full.S.Data.Slots[29].Item?.Id == own1.Id,
+ "an own slot past 24 in use: refused, nothing changed: " + m);
+
+ var unread = new BarRig("copy-unread") { RetailReadable = false };
+ m = unread.S.SetIndependent(true);
+ Check(unread.S.CopyOffer == 0 && !m.Contains("offers"), "AC's slots unreadable: no offer");
+ Check(unread.S.CopyRetailSlots().Contains("can't be read"), "and no copy");
+
+ // The pure copy on its own: an empty bar gets the game's items only.
+ var own = DefData.NewSlots();
+ BarCopyResult r = BarMapping.CopyRetail(own, new uint[] { kit.Id }, new uint[1], id => id == kit.Id ? ItemRef.From(kit) : null);
+ Check(r.Refused == null && r.Copied == 1 && r.Moved.Count == 0 && own[0].Item?.Id == kit.Id && own.Skip(1).All(x => x.Empty), "an empty bar: just the copy");
+ }
+
+ private static void BarStoreIndependent()
+ {
+ var st = new DefStore(Path.Combine(_temp, "indep"));
+ var d = new DefData();
+ Check(!d.Settings.IndependentBar, "off by default");
+ d.Settings.IndependentBar = true;
+ Check(st.Save("S", "Indie", d) == null, "saved");
+ string json = File.ReadAllText(st.PathFor("S", "Indie"));
+ Check(json.Contains("\"independentBar\": true"), "written in the file");
+ Check(st.Load("S", "Indie", out string? problem).Settings.IndependentBar && problem == null, "read back on");
+
+ // A file from before the setting existed: off, everything else as it was.
+ string old = st.PathFor("S", "Old");
+ Directory.CreateDirectory(Path.GetDirectoryName(old)!);
+ File.WriteAllText(old, "{\"version\":1,\"settings\":{\"slotCount\":8,\"barSlots\":20,\"swapWhileBotRuns\":true},"
+ + "\"slots\":[{\"item\":{\"id\":5,\"name\":\"Kit\"},\"mode\":0}]}");
+ DefData o = st.Load("S", "Old", out problem);
+ Check(problem == null && !o.Settings.IndependentBar && o.Settings.BarSlots == 20 && o.Settings.SwapWhileBotRuns && o.Slots[0].Item?.Name == "Kit",
+ "an old file loads with the independent bar off");
+ File.WriteAllText(old, "{\"settings\":{\"independentBar\":\"yes\"}}");
+ Check(!st.Load("S", "Old", out _).Settings.IndependentBar, "a string is not a bool: off");
+ }
+
+ private static void BarSettingsWindow()
+ {
+ var b = new BarRig("settings-window");
+ var kit = Kit(0x7300_0001u);
+ b.R.Inv = new List { kit };
+ b.RetailIds[0] = kit.Id;
+ var host = new UiHost();
+ UiWindow win = host.Add(new UiWindow("RynthDefective/Settings", "Defective Settings") { Visible = true, ShowInBar = false });
+ var view = new BarSettingsView(b.S);
+ var shown = new Dictionary { [BarSettingsView.BarTitle] = true, [BarSettingsView.SelectionTitle] = false };
+ var told = new List();
+ view.WindowShown = t => shown.TryGetValue(t, out bool v) ? v : null; // no Game Panels on this "engine"
+ view.ShowWindow = (t, v) => shown[t] = v;
+ view.Tell = told.Add;
+ void Draw() { win.Begin(); view.Draw(win); win.End(); }
+ string Text() => Encoding.UTF8.GetString(win.Body);
+
+ // The test window helpers send events by widget id.
+ var w = new Windows("settings-window-events");
+ w.Host.Add(win);
+ void Click(string id) => w.Click(win, id);
+ void SetBool(string id, bool v) => w.SetBool(win, id, v);
+
+ Draw();
+ ParseAll(host, "settings window", out int ops);
+ Check(ops < 1500, "inside the engine's limits");
+ Check(Text().Contains("Allow weapon swaps while RynthAi's macro runs"), "the weapon swap switch is reachable");
+ Check(Text().Contains("Shortcuts bar") && Text().Contains("Selection") && !Text().Contains("Game panel buttons"),
+ "the windows RynthDefective draws (Game Panels only where the engine has it)");
+ Check(Text().Contains("RynthDefective draws the Shortcuts bar, the Game Panels buttons and the Selection window"), "it says what draws them");
+
+ SetBool("set.win.sel", true);
+ Check(shown[BarSettingsView.SelectionTitle], "the Selection box shows the window");
+ SetBool("set.swap", true);
+ Check(b.S.Settings.SwapWhileBotRuns, "the swap switch");
+
+ SetBool("set.indep", true);
+ Check(b.S.Settings.IndependentBar && told.Count == 1 && told[0].Contains("independent"), "the independent switch, told in chat");
+ Eq(b.S.CopyOffer, 1, "the copy is offered");
+ Draw();
+ ParseAll(host, "settings window with the offer", out _);
+ Check(Text().Contains("Copy them") && Text().Contains("No thanks"), "the offer shows");
+ Click("set.copy");
+ Check(b.S.Data.Slots[0].Item?.Id == kit.Id && b.S.CopyOffer == 0 && told.Count == 2 && told[1].Contains("Copied 1"), "Copy them copies");
+ Draw();
+ Check(!Text().Contains("Copy them"), "and the offer is gone");
+
+ SetBool("set.indep", false);
+ SetBool("set.indep", true);
+ Draw();
+ Click("set.nocopy");
+ Eq(b.S.CopyOffer, 0, "No thanks declines");
+
+ b.S.LoggedIn = false;
+ Draw();
+ ParseAll(host, "settings window logged out", out _);
+ Check(Text().Contains("Log in"), "logged out it says so");
+ }
+ }
+}
diff --git a/Tools/RynthDefective.Tests/ModelTests.cs b/Tools/RynthDefective.Tests/ModelTests.cs
index 477aef7..3d43206 100644
--- a/Tools/RynthDefective.Tests/ModelTests.cs
+++ b/Tools/RynthDefective.Tests/ModelTests.cs
@@ -367,7 +367,7 @@ namespace RynthDefective.Tests
DefSettings s = r.Settings;
Check(s.SlotCount == 12 && s.SlotsPerRow == 6 && s.ButtonSize == 44 && s.PickerIconSize == 28, "sizes");
Check(!s.ShowIcons && !s.ShowCounts && s.SwapWhileBotRuns && s.BarOpen && s.PickerOpen && s.PreferredKind == KindFilter.War, "switches");
- Check(r.Slots.Count == DefSettings.SlotsMax, "all 24 slots");
+ Check(r.Slots.Count == DefSettings.SlotsMax, "all 42 slots");
ItemRef a = r.Slots[0].Item!;
Check(a.Id == 0x7000_0001u && a.Name == "Peerless Healing Kit" && a.Wcid == 628 && a.Icon == 0x06001234 && a.Underlay == 0x06000FFF && a.Overlay == 0x06000EEE, "a slot's item with its identity and picture");
Check(r.Slots[0].Mode == UseMode.OnSelf && r.Slots[1].Item == null && r.Slots[1].Mode == UseMode.Auto, "modes and empty slots");
@@ -398,28 +398,37 @@ namespace RynthDefective.Tests
File.WriteAllText(own, "{}");
d = st.Load("S", "A", out problem);
- Check(problem == null && d.Settings.SlotCount == 8 && d.Slots.Count == 24, "{} = defaults");
+ Check(problem == null && d.Settings.SlotCount == 8 && d.Slots.Count == DefSettings.SlotsMax, "{} = defaults");
File.WriteAllText(own, "{\"settings\":{\"slotCount\":99,\"slotsPerRow\":0,\"buttonSize\":1000,\"pickerIconSize\":-5,\"preferredKind\":42,\"showIcons\":\"yes\"},"
+ "\"slots\":[7,{\"item\":{\"id\":5.0,\"name\":\"Kit\"},\"mode\":9},{\"item\":{\"id\":1}},{\"item\":{\"name\":\" \"}},{\"item\":\"x\"},null],"
+ "\"favourites\":[\"x\",{\"name\":\"Sword\"},{\"id\":3}],\"recent\":5}");
d = st.Load("S", "A", out problem);
Check(problem == null, "odd values are not a problem");
- Check(d.Settings.SlotCount == DefSettings.SlotsMax && d.Settings.SlotsPerRow == DefSettings.PerRowMin && d.Settings.ButtonSize == DefSettings.ButtonMax
+ Check(d.Settings.SlotCount == DefSettings.SlotCountMax && d.Settings.SlotsPerRow == DefSettings.PerRowMin && d.Settings.ButtonSize == DefSettings.ButtonMax
&& d.Settings.PickerIconSize == DefSettings.PickerIconMin && d.Settings.PreferredKind == KindFilter.All && d.Settings.ShowIcons, "clamped, a string is not a bool");
Check(d.Slots[0].Empty, "a non-object slot is empty");
Check(d.Slots[1].Item?.Name == "Kit" && d.Slots[1].Item!.Id == 5 && d.Slots[1].Mode == UseMode.Auto, "2.0 is 2; an unknown mode is automatic");
Check(d.Slots[2].Empty && d.Slots[3].Empty && d.Slots[4].Empty, "an item with no name can't be found again: empty");
Check(d.Favourites.Count == 1 && d.Favourites[0].Name == "Sword" && d.Recent.Count == 0, "bad favourites are skipped; recent that isn't a list is none");
- Eq(d.Slots.Count, DefSettings.SlotsMax, "still 24 slots");
+ Eq(d.Slots.Count, DefSettings.SlotsMax, "still 42 slots");
// More slots than the maximum in a file are cut.
var sb = new StringBuilder("{\"slots\":[");
- for (int i = 0; i < 40; i++) sb.Append(i > 0 ? "," : "").Append("{\"item\":{\"id\":").Append(i + 1).Append(",\"name\":\"N").Append(i).Append("\"}}");
+ for (int i = 0; i < DefSettings.SlotsMax + 10; i++) sb.Append(i > 0 ? "," : "").Append("{\"item\":{\"id\":").Append(i + 1).Append(",\"name\":\"N").Append(i).Append("\"}}");
sb.Append("]}");
File.WriteAllText(own, sb.ToString());
d = st.Load("S", "A", out _);
- Check(d.Slots.Count == 24 && d.Slots[23].Item!.Name == "N23", "slots past the 24th are dropped");
+ Check(d.Slots.Count == DefSettings.SlotsMax && d.Slots[DefSettings.SlotsMax - 1].Item!.Name == "N" + (DefSettings.SlotsMax - 1), "slots past the 42nd are dropped");
+
+ // A file from before 2026-10-27 (24 slots): its slots load, the rest are empty.
+ sb.Clear().Append("{\"slots\":[");
+ for (int i = 0; i < 24; i++) sb.Append(i > 0 ? "," : "").Append("{\"item\":{\"id\":").Append(i + 1).Append(",\"name\":\"Old").Append(i).Append("\"}}");
+ sb.Append("]}");
+ File.WriteAllText(own, sb.ToString());
+ d = st.Load("S", "A", out _);
+ Check(d.Slots.Count == DefSettings.SlotsMax && d.Slots[23].Item!.Name == "Old23" && d.Slots[24].Empty && d.Slots[DefSettings.SlotsMax - 1].Empty,
+ "a 24-slot file loads into the first 24 of 42");
Eq(DefStore.SafeFileName("CON"), "_CON", "reserved names");
Eq(DefStore.FileStem("Dream Weave", "Ana:Lee"), "Dream Weave_Ana_Lee", "illegal characters become underscores");
@@ -505,7 +514,7 @@ namespace RynthDefective.Tests
m = rig.S.SetFromName(3, "health");
Check(rig.S.Data.Slots[2].Item?.Name == "Health Potion" && m.Contains("Slot 3"), "set by name");
Check(rig.S.SetFromName(3, "elixir").Contains("No item named"), "a name that matches nothing");
- Check(rig.S.SetFromSelected(0).Contains("no slot") && rig.S.SetFromSelected(25).Contains("no slot"), "slot numbers are checked");
+ Check(rig.S.SetFromSelected(0).Contains("no slot") && rig.S.SetFromSelected(DefSettings.SlotsMax + 1).Contains("no slot"), "slot numbers are checked");
rig.S.SetSlotMode(1, UseMode.Use);
Eq(rig.S.Data.Slots[0].Mode, UseMode.Use, "mode");
@@ -527,7 +536,7 @@ namespace RynthDefective.Tests
// Pressing a slot.
rig.S.SetSlotCount(8);
Check(rig.S.UseSlot(2)!.Contains("empty"), "an empty slot says so");
- Check(rig.S.UseSlot(40)!.Contains("no slot"), "a slot that doesn't exist");
+ Check(rig.S.UseSlot(DefSettings.SlotsMax + 1)!.Contains("no slot"), "a slot that doesn't exist");
Check(rig.S.UseSlot(1) == null && rig.S.Use.HasPending, "a set slot queues its item");
}
@@ -569,7 +578,7 @@ namespace RynthDefective.Tests
Check(rig.S.BindKey(3, "", false).Contains("Type the key"), "a blank key");
Check(rig.S.BindKey(3, "Ctrl + F9", false).Contains("no spaces"), "spaces in a key");
Check(rig.S.BindKey(4, "F9", true).Contains("empty"), "by name needs an item");
- Check(rig.S.BindKey(30, "F9", false).Contains("no slot"), "slot checked");
+ Check(rig.S.BindKey(DefSettings.SlotsMax + 1, "F9", false).Contains("no slot"), "slot checked");
rig.S.RunChat = _ => false;
Check(rig.S.BindKey(3, "F11", false).Contains("/rc hotkey add F11 /rdef use 3"), "an engine that can't: the exact line to type");
diff --git a/Tools/RynthDefective.Tests/Program.cs b/Tools/RynthDefective.Tests/Program.cs
index b22273e..2950793 100644
--- a/Tools/RynthDefective.Tests/Program.cs
+++ b/Tools/RynthDefective.Tests/Program.cs
@@ -79,6 +79,11 @@ namespace RynthDefective.Tests
Run("window: a bar button of its own, one-shot size request", WindowHeader);
Run("window: slot clicks and editor events reach their code", WindowEvents);
Run("window: lists stay inside the engine's limits", WindowLimits);
+ Run("bar: the game's slots and own slots, usual and independent", BarMappingUsualAndIndependent);
+ Run("bar: a healing kit in one of the game's slots is used on you here", BarRetailKit);
+ Run("bar: making it independent offers to copy the game's 18 slots", BarIndependentCopy);
+ Run("store: the independent bar setting; files from before read it off", BarStoreIndependent);
+ Run("window: the settings window parses and its switches reach their code", BarSettingsWindow);
}
finally
{
diff --git a/Tools/RynthVision.Tests/Program.cs b/Tools/RynthVision.Tests/Program.cs
new file mode 100644
index 0000000..252c6ce
--- /dev/null
+++ b/Tools/RynthVision.Tests/Program.cs
@@ -0,0 +1,325 @@
+using System.Text.Json;
+using RynthCore.Plugin.RynthVision;
+using RynthCore.Plugin.RynthVision.Light;
+using RynthCore.Plugin.RynthVision.Ui;
+
+namespace RynthVision.Tests;
+
+///
+/// RynthVision's dungeon light (2026-10-27): where it lights, how brightly, its chat words and status
+/// line, its settings keys; and the Vision window RynthVision draws in the engine's Vision panel's
+/// place (its manifest, its pure rules, the settings it edits and saves).
+///
+internal static class Program
+{
+ private static int _checks, _failed;
+
+ // An outdoor cell (Holtburg), a building room and a dungeon cell (ids only; the flag is the test's).
+ private const uint Outdoor = 0xA9B40019, Room = 0xA9B40105, DungeonCell = 0x01D9012A;
+
+ private static int Main()
+ {
+ Places();
+ Scopes();
+ Levels();
+ Floors();
+ Percents();
+ Colours();
+ Commands();
+ Status();
+ SettingsJson();
+ Manifest();
+ WindowFields();
+ WaterTypes();
+ EngineKeys();
+
+ Console.WriteLine($"{_checks} checks, {_failed} failed");
+ return _failed == 0 ? 0 : 1;
+ }
+
+ private static void Check(bool ok, string what)
+ {
+ _checks++;
+ if (ok) return;
+ _failed++;
+ Console.WriteLine("FAIL: " + what);
+ }
+
+ private static void Eq(T got, T want, string what) =>
+ Check(EqualityComparer.Default.Equals(got, want), $"{what}: got {got}, want {want}");
+
+ private static void Places()
+ {
+ Eq(DungeonLight.Classify(Outdoor, null), LightPlace.Outdoors, "an outdoor cell");
+ Eq(DungeonLight.Classify(Outdoor, true), LightPlace.Outdoors, "an outdoor cell whatever the flag says");
+ Eq(DungeonLight.Classify(Room, true), LightPlace.Building, "an EnvCell that sees outside is a building");
+ Eq(DungeonLight.Classify(DungeonCell, false), LightPlace.Dungeon, "an EnvCell that doesn't is a dungeon");
+ Eq(DungeonLight.Classify(DungeonCell, null), LightPlace.Dungeon, "an EnvCell nobody could read counts as a dungeon");
+ Eq(DungeonLight.Classify(0, null), LightPlace.NotInWorld, "cell 0: not in the world");
+ Eq(DungeonLight.Classify(0x0000012A, false), LightPlace.NotInWorld, "landblock 0: not in the world (portal space)");
+ Eq(DungeonLight.Classify(0xA9B400FF, null), LightPlace.Outdoors, "0xFF is still an outdoor cell");
+ Eq(DungeonLight.Classify(0xA9B40100, null), LightPlace.Dungeon, "0x100 is the first EnvCell");
+ }
+
+ private static void Scopes()
+ {
+ foreach (LightScope s in Enum.GetValues())
+ {
+ Check(DungeonLight.Applies(s, LightPlace.Dungeon), $"{s}: lights dungeons");
+ Check(!DungeonLight.Applies(s, LightPlace.NotInWorld), $"{s}: nothing out of the world");
+ }
+ Check(!DungeonLight.Applies(LightScope.Dungeons, LightPlace.Building), "dungeons: not buildings");
+ Check(!DungeonLight.Applies(LightScope.Dungeons, LightPlace.Outdoors), "dungeons: not outdoors");
+ Check(DungeonLight.Applies(LightScope.Indoors, LightPlace.Building), "indoors: buildings");
+ Check(!DungeonLight.Applies(LightScope.Indoors, LightPlace.Outdoors), "indoors: not outdoors");
+ Check(DungeonLight.Applies(LightScope.Everywhere, LightPlace.Building), "everywhere: buildings");
+ Check(DungeonLight.Applies(LightScope.Everywhere, LightPlace.Outdoors), "everywhere: outdoors");
+ }
+
+ private static void Levels()
+ {
+ Check(Math.Abs(DungeonLight.Level(0) - 0.2f) < 1e-6, "strength 0 = AC's own 20 %");
+ Check(Math.Abs(DungeonLight.Level(100) - 1f) < 1e-6, "strength 100 = 100 %");
+ Check(Math.Abs(DungeonLight.Level(DungeonLight.DefaultStrength) - 0.52f) < 1e-6, "the default 40 = 52 %");
+ Check(Math.Abs(DungeonLight.Level(-20) - 0.2f) < 1e-6 && Math.Abs(DungeonLight.Level(500) - 1f) < 1e-6, "clamped");
+ }
+
+ private static void Floors()
+ {
+ Eq(DungeonLight.FloorRgb(0xFFFFFFFF, 0), 0u, "strength 0 sends no floor");
+ Eq(DungeonLight.FloorRgb(0xFFFFFFFF, -3), 0u, "below 0 sends no floor");
+ Eq(DungeonLight.FloorRgb(0xFFFFFFFF, 100), 0xFFFFFFu, "100 % white");
+ Eq(DungeonLight.FloorRgb(0xFFFFFFFF, 40), 0x858585u, "the default: 52 % white (133)");
+ Eq(DungeonLight.FloorRgb(0xFFFFD8A8, 40), 0x857057u, "torch at 40");
+ Check((DungeonLight.FloorRgb(0xFFFFFFFF, 1) & 0xFF) > 0x33, "any strength above 0 is brighter than AC's dungeon (0x33)");
+ Check((DungeonLight.FloorRgb(0xFFFFFFFF, 100) & 0xFF000000) == 0, "the floor has no alpha byte");
+ Eq(DungeonLight.FloorFor(false, LightScope.Everywhere, 40, 0xFFFFFFFF, LightPlace.Dungeon), 0u, "off: no floor");
+ Eq(DungeonLight.FloorFor(true, LightScope.Dungeons, 40, 0xFFFFFFFF, LightPlace.Outdoors), 0u, "dungeons only: none outdoors");
+ Eq(DungeonLight.FloorFor(true, LightScope.Dungeons, 40, 0xFFFFFFFF, LightPlace.NotInWorld), 0u, "none out of the world");
+ Eq(DungeonLight.FloorFor(true, LightScope.Dungeons, 40, 0xFFFFFFFF, LightPlace.Dungeon), 0x858585u, "on in a dungeon");
+ }
+
+ private static void Percents()
+ {
+ Eq(DungeonLight.Percent(0xFF333333), 20, "AC's dungeon ambient reads 20 %");
+ Eq(DungeonLight.Percent(0xFF858585), 52, "the default floor reads 52 %");
+ Eq(DungeonLight.Percent(0x00FF0000), 100, "the brightest channel");
+ Eq(DungeonLight.Percent(0), 0, "black");
+ }
+
+ private static void Colours()
+ {
+ Check(DungeonLight.TryParseColor("FFE0C0", out uint c) && c == 0xFFFFE0C0, "RRGGBB, made opaque");
+ Check(DungeonLight.TryParseColor("#ffe0c0", out c) && c == 0xFFFFE0C0, "lower case with '#'");
+ Check(DungeonLight.TryParseColor("80FFE0C0", out c) && c == 0xFFFFE0C0, "AARRGGBB: the alpha is dropped");
+ Check(DungeonLight.TryParseColor(" Torch ", out c) && c == 0xFFFFD8A8, "a preset by name");
+ Check(!DungeonLight.TryParseColor("nope", out _), "a word that isn't a preset");
+ Check(!DungeonLight.TryParseColor("12345", out _), "five hex digits");
+ Check(!DungeonLight.TryParseColor("", out _) && !DungeonLight.TryParseColor(null, out _), "nothing");
+ Eq(DungeonLight.ColorName(0xFFFFFFFF), "white", "white by name");
+ Eq(DungeonLight.ColorName(0xFFC8D8FF), "moon", "moon by name");
+ Eq(DungeonLight.ColorName(0xFF102030), "102030", "any other colour as hex");
+ }
+
+ private static void Commands()
+ {
+ Eq(DungeonLight.ParseCommand("").Kind, LightCommandKind.Toggle, "/rv light alone toggles");
+ Eq(DungeonLight.ParseCommand(null).Kind, LightCommandKind.Toggle, "null toggles");
+ Eq(DungeonLight.ParseCommand(" on ").Kind, LightCommandKind.On, "on");
+ Eq(DungeonLight.ParseCommand("off").Kind, LightCommandKind.Off, "off");
+ Eq(DungeonLight.ParseCommand("toggle").Kind, LightCommandKind.Toggle, "toggle");
+ LightCommand n = DungeonLight.ParseCommand("60");
+ Check(n.Kind == LightCommandKind.Strength && n.Strength == 60, "a number is the strength");
+ n = DungeonLight.ParseCommand("75%");
+ Check(n.Kind == LightCommandKind.Strength && n.Strength == 75, "with a %");
+ Check(DungeonLight.ParseCommand("0").Kind == LightCommandKind.Strength && DungeonLight.ParseCommand("100").Strength == 100, "the ends");
+ Eq(DungeonLight.ParseCommand("101").Kind, LightCommandKind.Error, "above 100");
+ Eq(DungeonLight.ParseCommand("-5").Kind, LightCommandKind.Error, "below 0");
+ Eq(DungeonLight.ParseCommand("dungeons").Scope, LightScope.Dungeons, "dungeons");
+ Eq(DungeonLight.ParseCommand("indoors").Scope, LightScope.Indoors, "indoors");
+ Eq(DungeonLight.ParseCommand("everywhere").Scope, LightScope.Everywhere, "everywhere");
+ Eq(DungeonLight.ParseCommand("all").Kind, LightCommandKind.Scope, "all = everywhere");
+ LightCommand col = DungeonLight.ParseCommand("color torch");
+ Check(col.Kind == LightCommandKind.Color && col.ColorArgb == 0xFFFFD8A8, "color torch");
+ col = DungeonLight.ParseCommand("colour 00ff00");
+ Check(col.Kind == LightCommandKind.Color && col.ColorArgb == 0xFF00FF00, "colour 00ff00");
+ Eq(DungeonLight.ParseCommand("color").Kind, LightCommandKind.Error, "color without one");
+ Eq(DungeonLight.ParseCommand("color xyz").Kind, LightCommandKind.Error, "a bad colour");
+ Eq(DungeonLight.ParseCommand("show").Kind, LightCommandKind.Show, "show");
+ Eq(DungeonLight.ParseCommand("window").Kind, LightCommandKind.Show, "window");
+ Eq(DungeonLight.ParseCommand("status").Kind, LightCommandKind.Status, "status");
+ Eq(DungeonLight.ParseCommand("help").Kind, LightCommandKind.Help, "help");
+ LightCommand bad = DungeonLight.ParseCommand("brighter please");
+ Check(bad.Kind == LightCommandKind.Error && bad.Error.Contains("brighter please"), "an unknown word names itself");
+ }
+
+ private static LightStatus S(bool on = true, LightScope scope = LightScope.Dungeons, LightPlace place = LightPlace.Dungeon,
+ bool api = true, bool live = true, uint client = 0xFF333333, uint applied = 0xFF858585) =>
+ new(on, scope, 40, place, api, live, client, applied);
+
+ private static void Status()
+ {
+ string line = DungeonLight.StatusLine(S());
+ Check(line.Contains("dungeon") && line.Contains("20%") && line.Contains("52%"), "lighting a dungeon names the levels: " + line);
+ Check(DungeonLight.StatusLine(S(api: false)).Contains("newer RynthCore"), "an older engine");
+ Check(DungeonLight.IsWarning(S(api: false)), "an older engine is a warning");
+ Check(DungeonLight.StatusLine(S(on: false)).StartsWith("Off"), "off");
+ Check(!DungeonLight.IsWarning(S(on: false, live: false)), "off with the hook off isn't a warning");
+ Check(DungeonLight.StatusLine(S(live: false)).Contains("/rc hooks"), "the hook off");
+ Check(DungeonLight.IsWarning(S(live: false)), "the hook off is a warning");
+ Check(DungeonLight.StatusLine(S(place: LightPlace.Outdoors)).Contains("not lighting here"), "outdoors with dungeons only");
+ Check(DungeonLight.StatusLine(S(place: LightPlace.NotInWorld)).Contains("waiting"), "out of the world");
+ Check(DungeonLight.StatusLine(S(scope: LightScope.Everywhere, place: LightPlace.Outdoors)).StartsWith("Lighting outdoors"), "everywhere, outdoors");
+ Check(!DungeonLight.StatusLine(S(client: 0, applied: 0)).Contains("->"), "no levels before the first frame");
+ }
+
+ private static void SettingsJson()
+ {
+ var d = new VisionSettings();
+ Check(!d.LightOn && d.LightStrength == 40 && d.LightColorArgb == 0xFFFFFFFF && d.LightScope == 0,
+ "defaults: off, 40, white, dungeons");
+ using (JsonDocument doc = JsonDocument.Parse(d.ToJson()))
+ {
+ JsonElement r = doc.RootElement;
+ Check(r.GetProperty("light").GetInt32() == 0 && r.GetProperty("lightStrength").GetInt32() == 40
+ && r.GetProperty("lightColor").GetUInt32() == 0xFFFFFFFF && r.GetProperty("lightScope").GetInt32() == 0,
+ "ToJson carries the light keys");
+ Check(r.TryGetProperty("radar", out _) && r.TryGetProperty("waterTypes", out _), "and still the old ones");
+ }
+
+ var s = new VisionSettings();
+ s.ApplyJson("{\"light\":1,\"lightStrength\":65,\"lightColor\":4294957216,\"lightScope\":2}");
+ Check(s.LightOn && s.LightStrength == 65 && s.LightColorArgb == 4294957216u && s.LightScope == 2, "ApplyJson reads them");
+ var back = new VisionSettings();
+ back.ApplyJson(s.ToJson());
+ Check(back.LightOn && back.LightStrength == 65 && back.LightColorArgb == s.LightColorArgb && back.LightScope == 2, "round trip");
+
+ var c = new VisionSettings();
+ c.ApplyJson("{\"lightStrength\":250,\"lightColor\":16777215,\"lightScope\":9}");
+ Check(c.LightStrength == 100 && c.LightColorArgb == 0xFFFFFFFF && c.LightScope == 2, "pulled into range; the colour made opaque");
+ c.ApplyJson("{\"lightStrength\":-4,\"lightScope\":-1}");
+ Check(c.LightStrength == 0 && c.LightScope == 0, "low values pulled up");
+
+ // One field at a time (what the engine's Vision panel sends) leaves the light alone.
+ s.ApplyJson("{\"radar\":0}");
+ Check(s.LightOn && s.LightStrength == 65 && !s.ShowRadarRing, "another key leaves the light as it was");
+ }
+
+ private static void Manifest()
+ {
+ using JsonDocument doc = JsonDocument.Parse(VisionManifest.Json(true));
+ Check(doc.RootElement.GetProperty("version").GetInt32() == 1, "manifest version 1");
+ Check(!doc.RootElement.TryGetProperty("sections", out _) && !doc.RootElement.TryGetProperty("contributions", out _),
+ "nothing for the Mini Remote's sections");
+ JsonElement ws = doc.RootElement.GetProperty("windows");
+ Eq(ws.GetArrayLength(), 1, "one window: Vision (the separate Dungeon Light window is gone)");
+ JsonElement w = ws[0];
+ // The engine panel's key (RynthCore ImGui/Panels/VisionFace.Title): the take-over keeps its saved place.
+ Check(w.GetProperty("id").GetString() == "vision" && w.GetProperty("title").GetString() == "Vision"
+ && VisionManifest.Title == "Vision", "the window's id and title: the engine's Vision panel's key");
+ Check(w.GetProperty("surface").GetString() == VisionManifest.Surface && VisionManifest.Surface == "window:vision", "its surface");
+ Check(w.GetProperty("takeOver").GetBoolean(), "it takes the engine's Vision panel's place");
+ Eq(w.GetProperty("icon").GetString(), "", "no icon of its own: the engine bar's eye for Vision");
+ Check(w.GetProperty("bar").GetBoolean() && w.GetProperty("edgeToEdge").GetBoolean(), "a bar button (the engine's steps aside); edge to edge");
+ Check(!w.TryGetProperty("chrome", out _) && !w.TryGetProperty("fitHeight", out _), "the engine's header and frame, sized by the player");
+ Check(w.GetProperty("width").GetInt32() == VisionManifest.Width && w.GetProperty("height").GetInt32() == VisionManifest.Height
+ && w.GetProperty("minWidth").GetInt32() == VisionManifest.MinWidth && w.GetProperty("minHeight").GetInt32() == VisionManifest.MinHeight,
+ "the constants are the JSON's");
+ Check(VisionManifest.Width == 320 && VisionManifest.Height == 560 && VisionManifest.MinWidth == 280 && VisionManifest.MinHeight == 240,
+ "the engine face's sizes (PanelSpec 320 x 560, at least 280 x 240)");
+
+ using JsonDocument none = JsonDocument.Parse(VisionManifest.Json(false));
+ Check(!none.RootElement.TryGetProperty("windows", out _), "an older engine: no window, its own Vision panel stays");
+ Check(VisionManifest.HostsWindow(true, true, true, true), "v91 with plugin windows: hosted");
+ Check(!VisionManifest.HostsWindow(false, true, true, true), "no light hook (before v91): not hosted");
+ Check(!VisionManifest.HostsWindow(true, false, true, true), "no SetPanelOpen: not hosted");
+ Check(!VisionManifest.HostsWindow(true, true, false, true), "no engine drawers (Nameplates, Combat text): not hosted");
+ Check(!VisionManifest.HostsWindow(true, true, true, false), "no engine look: not hosted");
+ }
+
+ private static void WindowFields()
+ {
+ Eq(VisionFields.TabNames.Length, Enum.GetValues().Length, "a name per tab");
+ Check(VisionFields.TabNames[0] == "Terrain" && VisionFields.TabNames[1] == "Nameplates" && VisionFields.TabNames[2] == "Combat text"
+ && VisionFields.TabNames[3] == "Light", "the engine's three tabs, then Light");
+ Eq(VisionFields.EngineTabKey(VisionTab.Nameplates), "nameplates", "Nameplates: the engine's body");
+ Eq(VisionFields.EngineTabKey(VisionTab.CombatText), "combattext", "Combat text: the engine's body");
+ Check(VisionFields.EngineTabKey(VisionTab.Terrain) == null && VisionFields.EngineTabKey(VisionTab.Light) == null,
+ "Terrain and Light are RynthVision's own");
+
+ Check(Math.Abs(VisionFields.OpacityPercent(0x80FFD000) - 50.196f) < 0.01f, "0x80 = 50 %");
+ Eq(VisionFields.WithOpacity(0x60FF2020, 100f), 0xFFFF2020u, "100 %: alpha FF, RGB kept");
+ Eq(VisionFields.WithOpacity(0x60FF2020, 0f), 0x00FF2020u, "0 %: alpha 00");
+ Eq(VisionFields.WithOpacity(0x60FF2020, 250f), 0xFFFF2020u, "clamped high");
+ Eq(VisionFields.WithOpacity(0x60FF2020, float.NaN), 0x00FF2020u, "NaN reads 0");
+ Eq(VisionFields.WithOpacity(0x60FF2020, VisionFields.OpacityPercent(0x60FF2020)), 0x60FF2020u, "untouched it round-trips");
+
+ Check(VisionFields.TryParseHex("80FFD000", out uint c) && c == 0x80FFD000, "AARRGGBB");
+ Check(VisionFields.TryParseHex("#ff2020", out c) && c == 0xFFFF2020, "RRGGBB with '#': opaque");
+ Check(!VisionFields.TryParseHex("FF20", out _) && !VisionFields.TryParseHex("", out _) && !VisionFields.TryParseHex("GG000000", out _),
+ "bad hex");
+
+ Check(VisionFields.ParseCsv("18, 19,x,20").SequenceEqual(new[] { 18, 19, 20 }), "csv: numbers kept, words dropped");
+ Check(VisionFields.ParseCsv(" ").Count == 0 && VisionFields.ParseCsv(null).Count == 0, "csv: nothing");
+ Eq(VisionFields.Csv(new[] { 16, 17, 18 }), "16,17,18", "csv out");
+ }
+
+ private static void WaterTypes()
+ {
+ int[] defaults = new VisionSettings().WaterTerrainTypes;
+ Check(defaults.SequenceEqual(new[] { 16, 17, 18, 19, 20 }), "the defaults: ACE's water types 16-20");
+ Check(VisionSettings.NormalizeWaterTypes(Array.Empty()).SequenceEqual(defaults), "empty: back to the defaults");
+ Check(VisionSettings.NormalizeWaterTypes(new[] { 40, -1 }).SequenceEqual(defaults), "all invalid: the defaults");
+ Check(VisionSettings.NormalizeWaterTypes(new[] { 19, 18, 19, 99 }).SequenceEqual(new[] { 19, 18 }), "in range, each once, in order");
+ Check(!ReferenceEquals(VisionSettings.NormalizeWaterTypes(Array.Empty()), VisionSettings.NormalizeWaterTypes(Array.Empty())),
+ "the defaults are a fresh array each time (never shared, never changed in place)");
+
+ // ApplyJson (the engine's panels, the file) still normalises the same way.
+ var s = new VisionSettings();
+ s.ApplyJson("{\"waterTypes\":[18,18,33]}");
+ Check(s.WaterTerrainTypes.SequenceEqual(new[] { 18 }), "ApplyJson: 33 dropped, 18 once");
+ s.ApplyJson("{\"waterTypes\":[]}");
+ Check(s.WaterTerrainTypes.SequenceEqual(defaults), "ApplyJson: empty is the defaults");
+
+ // Clone: the window's copy. Changing it leaves the tick's settings alone.
+ var a = new VisionSettings { ShowRadarRing = true, SlopeRenderRadius = 9 };
+ VisionSettings b = a.Clone();
+ b.ShowRadarRing = false;
+ b.SlopeRenderRadius = 3;
+ b.WaterTerrainTypes = new[] { 18 };
+ Check(a.ShowRadarRing && a.SlopeRenderRadius == 9 && a.WaterTerrainTypes.SequenceEqual(defaults), "a clone is a copy");
+ Check(new VisionSettings { LightStrength = 77 }.Clone().LightStrength == 77, "the light's settings are copied too");
+ }
+
+ ///
+ /// Every key the engine's Vision panel saved (RynthCore UI/Data/VisionKeys) is still written and read: the
+ /// window edits the same settings in the same file, so a player's choices carry over.
+ ///
+ private static void EngineKeys()
+ {
+ string[] keys =
+ {
+ "radar", "slopes", "water", "waterAnyCorner", "waterImpassableOnly", "slopeColor", "waterColor", "radarColor",
+ "radarRange", "ringThick", "ringHeight", "slopeRadius", "slopeFloorZ", "slopeBias", "waterRadius", "waterTypes",
+ };
+ var src = new VisionSettings
+ {
+ ShowRadarRing = false, ShowUnclimbableSlopes = true, ShowImpassableWater = true, WaterAnyCorner = false,
+ WaterImpassableOnly = false, SlopeColorArgb = 0x11223344, WaterColorArgb = 0x55667788, RadarRingColorArgb = 0x99AABBCC,
+ RadarRangeWorld = 120f, RadarRingThickness = 3.5f, RadarRingHeight = 7f, SlopeRenderRadius = 5, SlopeFloorZ = 0.5f,
+ SlopeHeightBias = 0.25f, WaterRenderRadius = 6, WaterTerrainTypes = new[] { 17, 19 },
+ };
+ string json = src.ToJson();
+ using (JsonDocument doc = JsonDocument.Parse(json))
+ foreach (string k in keys)
+ Check(doc.RootElement.TryGetProperty(k, out _), $"ToJson writes \"{k}\"");
+ var back = new VisionSettings();
+ back.ApplyJson(json);
+ Check(!back.ShowRadarRing && back.ShowUnclimbableSlopes && back.ShowImpassableWater && !back.WaterAnyCorner && !back.WaterImpassableOnly,
+ "the toggles round-trip");
+ Check(back.SlopeColorArgb == 0x11223344 && back.WaterColorArgb == 0x55667788 && back.RadarRingColorArgb == 0x99AABBCC, "the colours");
+ Check(back.RadarRangeWorld == 120f && back.RadarRingThickness == 3.5f && back.RadarRingHeight == 7f && back.SlopeRenderRadius == 5
+ && back.SlopeFloorZ == 0.5f && back.SlopeHeightBias == 0.25f && back.WaterRenderRadius == 6, "the tuning");
+ Check(back.WaterTerrainTypes.SequenceEqual(new[] { 17, 19 }), "the water types");
+ }
+}
diff --git a/Tools/RynthVision.Tests/RynthVision.Tests.csproj b/Tools/RynthVision.Tests/RynthVision.Tests.csproj
new file mode 100644
index 0000000..0da207f
--- /dev/null
+++ b/Tools/RynthVision.Tests/RynthVision.Tests.csproj
@@ -0,0 +1,32 @@
+
+
+
+
+ Exe
+ net10.0
+ enable
+ enable
+ true
+ RynthVision.Tests
+
+
+
+
+
+
+
+
+
+