Skip to content

Commit 16fbd8b

Browse files
committed
chore(release): merge dev into main for v0.0.32
2 parents d518bbb + 000b898 commit 16fbd8b

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

Const.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class Const
1818
/// <summary>
1919
/// Assembly / manifest version string.
2020
/// </summary>
21-
public const string Version = "0.0.31";
21+
public const string Version = "0.0.32";
2222

2323
/// <summary>
2424
/// Root key for RitsuLib JSON settings under the mod’s user folder.

STS2-RitsuLib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<NoWarn>$(NoWarn);CS0436</NoWarn>
1313
<IsPackable>true</IsPackable>
1414
<PackageId>STS2.RitsuLib</PackageId>
15-
<Version>0.0.31</Version>
15+
<Version>0.0.32</Version>
1616
<Authors>OLC</Authors>
1717
<Description>Shared framework library for Slay the Spire 2 mods.</Description>
1818
<PackageReadmeFile>README.md</PackageReadmeFile>

Scaffolding/Characters/Patches/CardLibraryCompendiumPatch.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace STS2RitsuLib.Scaffolding.Characters.Patches
1515
/// Adds a pool-filter button for each registered mod character in the card library compendium.
1616
/// Without this patch, mod character cards are not visible in any filter category, and opening
1717
/// the card library during a run with a mod character causes a KeyNotFoundException crash.
18+
/// Buttons are inserted before the colorless pool filter when possible (then ancients, misc),
19+
/// so they stay with playable-character filters rather than after misc/token-style pools.
1820
/// </summary>
1921
public class CardLibraryCompendiumPatch : IPatchMethod
2022
{
@@ -53,6 +55,8 @@ public static void Postfix(
5355
var filterParent = referenceFilter.GetParent();
5456
if (filterParent == null) return;
5557

58+
var useOrderedInsert = TryGetModFilterInsertIndex(__instance, filterParent, out var insertIndex);
59+
5660
ShaderMaterial? referenceMat = null;
5761
if (referenceFilter.GetNodeOrNull<Control>("Image") is { Material: ShaderMaterial refMat })
5862
referenceMat = refMat;
@@ -61,6 +65,7 @@ public static void Postfix(
6165
var updateCallable = Callable.From<NCardPoolFilter>(f => updateMethod.Invoke(__instance, [f]));
6266
var lastHoveredField = AccessTools.Field(typeof(NCardLibrary), "_lastHoveredControl");
6367

68+
var nextIndex = insertIndex;
6469
foreach (var character in modCharacters)
6570
{
6671
string? iconTexturePath = null;
@@ -69,6 +74,11 @@ public static void Postfix(
6974

7075
var filter = CreateFilter(character, iconTexturePath, referenceMat);
7176
filterParent.AddChild(filter, true);
77+
if (useOrderedInsert)
78+
{
79+
filterParent.MoveChild(filter, nextIndex);
80+
nextIndex++;
81+
}
7282

7383
var pool = character.CardPool;
7484
____poolFilters.Add(filter, c => pool.AllCardIds.Contains(c.Id));
@@ -80,6 +90,38 @@ public static void Postfix(
8090
}
8191
}
8292

93+
/// <summary>
94+
/// Prefer inserting mod character filters immediately before non-character pool toggles: colorless, then
95+
/// ancients, then misc (vanilla has no separate token node; those pools follow). Falls back when no anchor
96+
/// resolves under <paramref name="expectedParent" />.
97+
/// </summary>
98+
private static bool TryGetModFilterInsertIndex(
99+
NCardLibrary library,
100+
Node expectedParent,
101+
out int insertIndex)
102+
{
103+
ReadOnlySpan<string> anchorNames =
104+
[
105+
"%ColorlessPool",
106+
"%AncientsPool",
107+
"%MiscPool",
108+
];
109+
110+
foreach (var name in anchorNames)
111+
{
112+
if (library.GetNodeOrNull<NCardPoolFilter>(name) is not { } anchor)
113+
continue;
114+
if (anchor.GetParent() != expectedParent)
115+
continue;
116+
117+
insertIndex = anchor.GetIndex();
118+
return true;
119+
}
120+
121+
insertIndex = 0;
122+
return false;
123+
}
124+
83125
private static NCardPoolFilter CreateFilter(
84126
CharacterModel character,
85127
string? iconTexturePath,

mod_manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "RitsuLib",
55
"author": "OLC",
66
"description": "A shared Slay the Spire 2 mod framework library providing reusable patching, persistence, lifecycle, localization, and utility APIs for other mods.",
7-
"version": "0.0.31",
7+
"version": "0.0.32",
88
"has_pck": false,
99
"has_dll": true,
1010
"affects_gameplay": false,

0 commit comments

Comments
 (0)