Merge rynth/main (2026.10.8.1) into sk/features-on-rynth-main
Resolves the conflicts that kept PR #2 from merging. Where rynth/main already ships the same feature, its version wins: the shared read-only RynthInstallPaths, /ra iteminfo (PR #2's Mag-Tools item info window is dropped), pet essence refill trust, object filing, spell metadata and the Monster Editor's Category / MatchExpression. See Changelog/2026-10-08-merge-rynth-main-into-pr2.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
2e54796b15
160 changed files with 15447 additions and 2566 deletions
|
|
@ -7,5 +7,6 @@ namespace RynthCore.MonsterEditor;
|
|||
[JsonSerializable(typeof(EditorSettings))]
|
||||
// UB damage-insights seed written for the RynthAi plugin (see UbMobSeedImport).
|
||||
[JsonSerializable(typeof(RynthCore.CreatureSeed.UbMobSeedFile))]
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, IncludeFields = true)]
|
||||
// Case-insensitive like the plugin's RynthAiJsonContext, which reads the same files.
|
||||
[JsonSourceGenerationOptions(WriteIndented = true, IncludeFields = true, PropertyNameCaseInsensitive = true)]
|
||||
internal partial class EditorJsonContext : JsonSerializerContext { }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:local="clr-namespace:RynthCore.MonsterEditor"
|
||||
x:Class="RynthCore.MonsterEditor.MainWindow"
|
||||
Title="RynthAi — Monster Rules Editor"
|
||||
Width="1060" Height="520" MinWidth="800" MinHeight="300">
|
||||
Width="1300" Height="520" MinWidth="800" MinHeight="300">
|
||||
|
||||
<DockPanel LastChildFill="True">
|
||||
|
||||
|
|
@ -124,6 +124,14 @@
|
|||
</DataTemplate></DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header="Wl" Width="26" CanUserResize="False" CanUserSort="False">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
<ToggleButton Classes="light" Content="Wl"
|
||||
IsChecked="{Binding UseWall, Mode=TwoWay}"
|
||||
ToolTip.Tip="Wall — War wall spells (a row of projectiles straight ahead; turns to face the target first). Needs Wall Range in the settings."/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Name -->
|
||||
<DataGridTemplateColumn Header="Name" Width="*" MinWidth="100">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
|
|
@ -138,6 +146,28 @@
|
|||
</DataTemplate></DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Category (the plugin's rule group label) -->
|
||||
<DataGridTemplateColumn Header="Category" Width="90" MinWidth="60">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
<TextBlock Text="{Binding Category}" Padding="3,1" VerticalAlignment="Center"/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate><DataTemplate>
|
||||
<TextBox Text="{Binding Category, Mode=TwoWay}" Padding="3,1"/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Match expression (empty = match by name only) -->
|
||||
<DataGridTemplateColumn Header="Match" Width="150" MinWidth="80">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
<TextBlock Text="{Binding MatchExpression}" Padding="3,1" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
ToolTip.Tip="Match expression: when set, the rule matches when it is true (and the name, if any, is in the target's name). Empty = by name only."/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.CellEditingTemplate><DataTemplate>
|
||||
<TextBox Text="{Binding MatchExpression, Mode=TwoWay}" Padding="3,1"/>
|
||||
</DataTemplate></DataGridTemplateColumn.CellEditingTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Priority -->
|
||||
<DataGridTemplateColumn Header="P" Width="32" MinWidth="30">
|
||||
<DataGridTemplateColumn.CellTemplate><DataTemplate>
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public partial class MainWindow : Window
|
|||
private string _charFolder = string.Empty;
|
||||
private string _monstersPath = string.Empty;
|
||||
private bool _initialized;
|
||||
// Set when the monsters file couldn't be read: saving would replace it with what's on screen.
|
||||
private bool _loadFailed;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
|
|
@ -51,7 +53,7 @@ public partial class MainWindow : Window
|
|||
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
if (args.Length > 1)
|
||||
OpenCharFolder(args[1].Trim('"'));
|
||||
Open(args[1].Trim('"'));
|
||||
else
|
||||
await PromptOpenFileAsync();
|
||||
}
|
||||
|
|
@ -65,11 +67,11 @@ public partial class MainWindow : Window
|
|||
|
||||
var pick = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = "Open monsters.json",
|
||||
Title = "Open a monster rules file (RynthAi > MonsterProfiles > character.json)",
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new[]
|
||||
{
|
||||
new FilePickerFileType("Monster Rules") { Patterns = new[] { "monsters.json" } },
|
||||
new FilePickerFileType("Monster Rules") { Patterns = new[] { "*.json" } },
|
||||
new FilePickerFileType("All Files") { Patterns = new[] { "*" } },
|
||||
}
|
||||
});
|
||||
|
|
@ -83,14 +85,21 @@ public partial class MainWindow : Window
|
|||
|
||||
string? path = file.TryGetLocalPath();
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
OpenCharFolder(Path.GetDirectoryName(path)!);
|
||||
Open(path);
|
||||
}
|
||||
|
||||
private void OpenCharFolder(string charFolder)
|
||||
/// <summary>Opens a monsters file, or a character's settings folder (what the plugin passes):
|
||||
/// the folder maps to the file the plugin reads, MonsterProfiles\(server)\(character).json
|
||||
/// (MonsterRulesFile.ResolveRulesPath). Before 2026-10-05 the editor always used
|
||||
/// monsters.json in that folder, which the plugin now moves to MonsterProfiles at load, so the
|
||||
/// editor opened empty and its saves were never read once the plugin's own file existed.</summary>
|
||||
private void Open(string pathOrFolder)
|
||||
{
|
||||
_charFolder = charFolder;
|
||||
_monstersPath = Path.Combine(charFolder, "monsters.json");
|
||||
Title = $"RynthAi — Monster Rules — {Path.GetFileName(charFolder)}";
|
||||
_monstersPath = MonsterRulesFile.ResolveRulesPath(pathOrFolder);
|
||||
_charFolder = Directory.Exists(pathOrFolder) ? pathOrFolder : MonsterRulesFile.CharFolderForRulesPath(_monstersPath);
|
||||
string who = Path.GetFileNameWithoutExtension(_monstersPath);
|
||||
if (who.Equals("monsters", StringComparison.OrdinalIgnoreCase)) who = Path.GetFileName(_charFolder);
|
||||
Title = $"RynthAi — Monster Rules — {who}";
|
||||
|
||||
LoadWeaponOptions();
|
||||
LoadRules();
|
||||
|
|
@ -128,17 +137,17 @@ public partial class MainWindow : Window
|
|||
{
|
||||
foreach (var r in Rules) r.PropertyChanged -= Rule_Changed;
|
||||
Rules.Clear();
|
||||
_loadFailed = false;
|
||||
|
||||
if (File.Exists(_monstersPath))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(_monstersPath);
|
||||
var rules = JsonSerializer.Deserialize(json, EditorJsonContext.Default.ListMonsterRule);
|
||||
if (rules != null)
|
||||
foreach (var r in rules) AddRule(r);
|
||||
}
|
||||
catch (Exception ex) { SetStatus($"Load error: {ex.Message}", error: true); return; }
|
||||
foreach (var r in MonsterRulesFile.Load(_monstersPath)) AddRule(r);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_loadFailed = true;
|
||||
SetStatus($"Load error: {ex.Message} - not saving over {_monstersPath}; fix the file and reopen it.", error: true);
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureDefault();
|
||||
|
|
@ -187,12 +196,10 @@ public partial class MainWindow : Window
|
|||
|
||||
private void Save()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_monstersPath)) return;
|
||||
if (string.IsNullOrEmpty(_monstersPath) || _loadFailed) return;
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(_charFolder);
|
||||
string json = JsonSerializer.Serialize(new List<MonsterRule>(Rules), EditorJsonContext.Default.ListMonsterRule);
|
||||
File.WriteAllText(_monstersPath, json);
|
||||
MonsterRulesFile.Save(_monstersPath, Rules);
|
||||
SetStatus($"Saved {Rules.Count} rule(s) — {DateTime.Now:HH:mm:ss}");
|
||||
}
|
||||
catch (Exception ex) { SetStatus($"Save error: {ex.Message}", error: true); }
|
||||
|
|
|
|||
|
|
@ -1,36 +1,39 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RynthCore.MonsterEditor;
|
||||
|
||||
/// <summary>The editor's copy of RynthAi's MonsterRule (Plugins/RynthCore.Plugin.RynthAi/LegacyUi/
|
||||
/// LegacyUiSettings.cs), read from and saved to the same monsters file. A field the plugin has and
|
||||
/// this class doesn't still survives a save, through <see cref="ExtraFields"/>.</summary>
|
||||
public class MonsterRule : INotifyPropertyChanged
|
||||
{
|
||||
private string _name = "New Monster";
|
||||
private string _category = "";
|
||||
private string _matchExpression = "";
|
||||
private int _priority = 1;
|
||||
private string _damageType = "Auto";
|
||||
private int _weaponId;
|
||||
private bool _fester, _broadside, _gravityWell, _imperil, _yield, _vuln;
|
||||
private bool _useArc, _useBolt = true, _useRing, _useStreak, _useBlast;
|
||||
private bool _useArc, _useBolt = true, _useRing, _useStreak, _useBlast, _useWall;
|
||||
private string _exVuln = "None";
|
||||
private int _offhandId;
|
||||
private int _preferredAmmoItemId;
|
||||
private string _petDamage = "PAuto";
|
||||
/// <summary>Dashboard-only label; optional (empty shows as "Default" in the game UI).</summary>
|
||||
private string _category = string.Empty;
|
||||
/// <summary>vTank-style match expression. Empty = for named rules, match on Name substring; for the Default row, it is the global fallback when nothing else matches.</summary>
|
||||
private string _matchExpression = string.Empty;
|
||||
|
||||
public string Name { get => _name; set { _name = value; OnPropertyChanged(); } }
|
||||
/// <summary>The plugin's rule group label. Kept and editable here (before 2026-10-05 an
|
||||
/// editor save dropped it).</summary>
|
||||
public string Category { get => _category; set { _category = value ?? ""; OnPropertyChanged(); } }
|
||||
/// <summary>The plugin's match expression (CombatManager.GetRuleForTarget): when set, the
|
||||
/// rule matches when the expression is true (and the name, if any, is in the target's).
|
||||
/// Empty = match by name only. Kept and editable here (before 2026-10-05 an editor save
|
||||
/// dropped it, so expression rules fell back to name-only).</summary>
|
||||
public string MatchExpression { get => _matchExpression; set { _matchExpression = value ?? ""; OnPropertyChanged(); } }
|
||||
public int Priority { get => _priority; set { _priority = value; OnPropertyChanged(); } }
|
||||
public string Category { get => _category; set { _category = value ?? string.Empty; OnPropertyChanged(); } }
|
||||
/// <summary>vTank-style match expression. Empty matches on the rule name.</summary>
|
||||
public string MatchExpression
|
||||
{
|
||||
get => _matchExpression;
|
||||
set { _matchExpression = value ?? string.Empty; OnPropertyChanged(); }
|
||||
}
|
||||
public string DamageType { get => _damageType; set { _damageType = value; OnPropertyChanged(); } }
|
||||
public int WeaponId { get => _weaponId; set { _weaponId = value; OnPropertyChanged(); } }
|
||||
public bool Fester { get => _fester; set { _fester = value; OnPropertyChanged(); } }
|
||||
|
|
@ -44,12 +47,18 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
public bool UseRing { get => _useRing; set { _useRing = value; OnPropertyChanged(); } }
|
||||
public bool UseStreak { get => _useStreak; set { _useStreak = value; OnPropertyChanged(); } }
|
||||
public bool UseBlast { get => _useBlast; set { _useBlast = value; OnPropertyChanged(); } }
|
||||
public bool UseWall { get => _useWall; set { _useWall = value; OnPropertyChanged(); } }
|
||||
public string ExVuln { get => _exVuln; set { _exVuln = value; OnPropertyChanged(); } }
|
||||
public int OffhandId { get => _offhandId; set { _offhandId = value; OnPropertyChanged(); } }
|
||||
/// <summary>Optional loose ammo stack id for missile combat while this rule matches (0 = auto).</summary>
|
||||
public int PreferredAmmoItemId { get => _preferredAmmoItemId; set { _preferredAmmoItemId = value; OnPropertyChanged(); } }
|
||||
public string PetDamage { get => _petDamage; set { _petDamage = value; OnPropertyChanged(); } }
|
||||
|
||||
/// <summary>Every field in the file this class doesn't know (e.g. the plugin's CustomDebuffs,
|
||||
/// or one added later), written back unchanged.</summary>
|
||||
[JsonExtensionData]
|
||||
public Dictionary<string, JsonElement>? ExtraFields { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
/// <summary>True for the special row named "Default" — the catch-all when no other rule matches.</summary>
|
||||
public bool IsDefault => string.Equals(_name, "Default", System.StringComparison.OrdinalIgnoreCase);
|
||||
|
|
@ -76,10 +85,13 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
UseRing = _useRing,
|
||||
UseStreak = _useStreak,
|
||||
UseBlast = _useBlast,
|
||||
UseWall = _useWall,
|
||||
ExVuln = _exVuln,
|
||||
OffhandId = _offhandId,
|
||||
PreferredAmmoItemId = _preferredAmmoItemId,
|
||||
PetDamage = _petDamage,
|
||||
// JsonElements are immutable, so a new dictionary over the same values is a full copy.
|
||||
ExtraFields = ExtraFields == null ? null : new Dictionary<string, JsonElement>(ExtraFields),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +116,7 @@ public class MonsterRule : INotifyPropertyChanged
|
|||
UseRing = src.UseRing;
|
||||
UseStreak = src.UseStreak;
|
||||
UseBlast = src.UseBlast;
|
||||
UseWall = src.UseWall;
|
||||
ExVuln = src.ExVuln;
|
||||
OffhandId = src.OffhandId;
|
||||
PreferredAmmoItemId = src.PreferredAmmoItemId;
|
||||
|
|
|
|||
99
Tools/RynthCore.MonsterEditor/MonsterRulesFile.cs
Normal file
99
Tools/RynthCore.MonsterEditor/MonsterRulesFile.cs
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace RynthCore.MonsterEditor;
|
||||
|
||||
/// <summary>
|
||||
/// Reading and writing a monsters file (a JSON array of MonsterRule, the format RynthAi's
|
||||
/// LegacyDashboardRenderer reads and writes), and finding the file the plugin uses. No UI:
|
||||
/// Tools/RynthCore.RynthAiHostTests compiles this file in and round-trips a file through it and
|
||||
/// the plugin's own serializer.
|
||||
/// </summary>
|
||||
public static class MonsterRulesFile
|
||||
{
|
||||
private const string SettingsProfilesDir = "SettingsProfiles";
|
||||
private const string MonsterProfilesDir = "MonsterProfiles";
|
||||
// RynthAi's LegacyServerFolder: its monsters live straight in MonsterProfiles\.
|
||||
private const string LegacyServerFolder = "ACEmulator";
|
||||
private const string LegacyFileName = "monsters.json";
|
||||
|
||||
/// <summary>The rules in <paramref name="path"/>; empty when the file doesn't exist.
|
||||
/// Throws on a file that isn't a JSON array of rules (the caller shows the error and
|
||||
/// doesn't save over it).</summary>
|
||||
public static List<MonsterRule> Load(string path)
|
||||
{
|
||||
if (!File.Exists(path)) return new List<MonsterRule>();
|
||||
string json = File.ReadAllText(path);
|
||||
return JsonSerializer.Deserialize(json, EditorJsonContext.Default.ListMonsterRule) ?? new List<MonsterRule>();
|
||||
}
|
||||
|
||||
/// <summary>Writes <paramref name="rules"/> in place (File.WriteAllText, as before: the
|
||||
/// plugin's FileSystemWatcher reloads on a LastWrite change).</summary>
|
||||
public static void Save(string path, IEnumerable<MonsterRule> rules)
|
||||
{
|
||||
string? dir = Path.GetDirectoryName(path);
|
||||
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
|
||||
File.WriteAllText(path, JsonSerializer.Serialize(new List<MonsterRule>(rules), EditorJsonContext.Default.ListMonsterRule));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The monsters file for what the editor was given: a .json file is edited as is. A
|
||||
/// character's settings folder (RynthAi\SettingsProfiles\<server>\<character>, what the
|
||||
/// plugin passes) maps to the plugin's file, RynthAi\MonsterProfiles\<server>\<character>.json
|
||||
/// (MonsterProfiles\<character>.json for the ACEmulator folder). The old
|
||||
/// <folder>\monsters.json is used only when that file doesn't exist and the old one does
|
||||
/// (the plugin moves it across at its next load).
|
||||
/// </summary>
|
||||
public static string ResolveRulesPath(string pathOrFolder)
|
||||
{
|
||||
string p = pathOrFolder.Trim().Trim('"').TrimEnd('\\', '/');
|
||||
if (File.Exists(p) || p.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
|
||||
return p;
|
||||
|
||||
string legacy = Path.Combine(p, LegacyFileName);
|
||||
string? current = PluginRulesPathForCharFolder(p);
|
||||
if (current == null) return legacy;
|
||||
if (File.Exists(current)) return current;
|
||||
return File.Exists(legacy) ? legacy : current;
|
||||
}
|
||||
|
||||
/// <summary>RynthAi's MonsterProfiles file for a SettingsProfiles character folder; null when
|
||||
/// the folder isn't laid out that way.</summary>
|
||||
public static string? PluginRulesPathForCharFolder(string charFolder)
|
||||
{
|
||||
var character = new DirectoryInfo(charFolder.TrimEnd('\\', '/'));
|
||||
DirectoryInfo? server = character.Parent;
|
||||
DirectoryInfo? profiles = server?.Parent;
|
||||
DirectoryInfo? root = profiles?.Parent;
|
||||
if (server == null || profiles == null || root == null) return null;
|
||||
if (!profiles.Name.Equals(SettingsProfilesDir, StringComparison.OrdinalIgnoreCase)) return null;
|
||||
|
||||
string monsters = Path.Combine(root.FullName, MonsterProfilesDir);
|
||||
return server.Name.Equals(LegacyServerFolder, StringComparison.OrdinalIgnoreCase)
|
||||
? Path.Combine(monsters, character.Name + ".json")
|
||||
: Path.Combine(monsters, server.Name, character.Name + ".json");
|
||||
}
|
||||
|
||||
/// <summary>The character's settings folder (where active_profile.txt and the profile with
|
||||
/// the weapon list live) for a monsters file: the file's own folder for an old
|
||||
/// monsters.json, the matching SettingsProfiles folder for a MonsterProfiles file, else the
|
||||
/// file's own folder.</summary>
|
||||
public static string CharFolderForRulesPath(string rulesPath)
|
||||
{
|
||||
var file = new FileInfo(rulesPath);
|
||||
string folder = file.DirectoryName ?? "";
|
||||
if (file.Name.Equals(LegacyFileName, StringComparison.OrdinalIgnoreCase))
|
||||
return folder;
|
||||
|
||||
string character = Path.GetFileNameWithoutExtension(file.Name);
|
||||
DirectoryInfo? dir = file.Directory;
|
||||
if (dir == null) return folder;
|
||||
if (dir.Name.Equals(MonsterProfilesDir, StringComparison.OrdinalIgnoreCase) && dir.Parent != null)
|
||||
return Path.Combine(dir.Parent.FullName, SettingsProfilesDir, LegacyServerFolder, character);
|
||||
if (dir.Parent is { } monsters && monsters.Name.Equals(MonsterProfilesDir, StringComparison.OrdinalIgnoreCase) && monsters.Parent != null)
|
||||
return Path.Combine(monsters.Parent.FullName, SettingsProfilesDir, dir.Name, character);
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,8 +24,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Install-location resolver (installer-chosen RynthCore / RynthSuite folders). -->
|
||||
<Compile Include="..\..\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
|
||||
<!-- Install-folder resolver (env, HKCU, HKLM, default C:\Games). Read only; same file as RynthCore src\Shared. -->
|
||||
<Compile Include="..\..\Plugins\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
|
||||
<!-- UB damage-insights seed schema, shared with the RynthAi plugin. -->
|
||||
<Compile Include="..\..\Shared\UbMobSeed.cs" Link="Shared\UbMobSeed.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue