Skip to content

Commit 63819ee

Browse files
Added OpenToCustomPage
1 parent 67d56f7 commit 63819ee

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
- Added additional methods to RuleBookManager: ItemShouldBeAdded, BoonShouldBeAdded, SlotModShouldBeAdded, GetUnformattedPageId
1010
- Added GetFullBoon and GetFullConsumableItemData extension methods
1111
- Added extension methods for adding text redirects to abilities, stat icons, items, boons, slot modifications, and rulebook pages
12+
- Added ModificationType.SetSharedRulebook - used for slot modifications that should share their rulebook entry with other slot modifications
13+
- Added support for multiple rulebook sprites for slot modifications (SetRulebookP03Sprite, SetRulebookGrimoraSprite, SetRulebookMagnificusSprite)
14+
- Added RuleBookController.Instance.OpenToCustomPage
1215
- Fixed RuleBook construction patches having lower patch priority than intended
16+
- Fixed slot modification interactable being enabled when no rulebook entry exists
17+
- Fixed slot modification rulebook pages not working in Act 3
18+
- Fixed rulebook sprites being smaller than normal after flipping to a slot modification rulebook page
1319
- Moved ConsumableItemManager patches to a separate ConsumableItemPatches class
1420
- Modified implementation of rulebook fill page logic to let modders patch the API logic
1521
- Patch 'RuleBookManagerPatches.FillPage' to do this
1622
- Tweaked how custom rulebook pages are added and detected
17-
- Tweaked wiki page for adding custom rulebook sections
18-
- Added wiki section on adding text redirects
23+
- Wiki: Tweaked page for adding custom rulebook sections
24+
- Wiki: Added section on adding text redirects
1925

2026
# 2.21.1
2127
- Fixed RuleBookManager not syncing when playing with no custom rulebook sections

InscryptionAPI/Rulebook/RuleBookManager.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,25 @@ public static string GetUnformattedPageId(string pageId)
299299
return pageId;
300300
}
301301

302+
/// <summary>
303+
/// Opens the rulebook to the page with the given pageId.
304+
/// </summary>
305+
/// <param name="instance">RuleBookController.Instance.</param>
306+
/// <param name="pageId">The value to compare each rulebook pages' id against. If this starts with "[API_" then it will check against a page's unformatted id.</param>
307+
/// <param name="offsetView">Whether to offset the camera view down when opening the rulebook.</param>
308+
public static void OpenToCustomPage(this RuleBookController instance, string pageId, bool offsetView = false)
309+
{
310+
instance.SetShown(shown: true, offsetView);
311+
int pageIndex = -1;
312+
if (pageId.StartsWith(RuleBookManagerPatches.API_ID))
313+
pageIndex = instance.PageData.IndexOf(instance.PageData.Find(x => !string.IsNullOrEmpty(x.pageId) && x.pageId == pageId));
314+
else
315+
pageIndex = instance.PageData.IndexOf(instance.PageData.Find(x => !string.IsNullOrEmpty(x.pageId) && GetUnformattedPageId(x.pageId) == pageId));
316+
317+
instance.StopAllCoroutines();
318+
instance.StartCoroutine(instance.flipper.FlipToPage(pageIndex, 0.2f));
319+
}
320+
302321
public static bool ItemShouldBeAdded(ConsumableItemData item, AbilityMetaCategory metaCategory)
303322
{
304323
return item.rulebookCategory == metaCategory || item.GetFullConsumableItemData()?.rulebookMetaCategories.Contains(metaCategory) == true;

InscryptionAPI/Rulebook/RuleBookManagerPatches.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using System.Reflection;
99
using System.Reflection.Emit;
1010
using TMPro;
11-
using UnityEngine;
11+
1212
using static InscryptionAPI.RuleBook.RuleBookManager;
1313

1414
namespace InscryptionAPI.RuleBook;
@@ -112,7 +112,7 @@ private static void SyncRuleBookRedirectsForEachPage(List<RuleBookPageInfo> __re
112112
[HarmonyPatch(typeof(ItemPage), "FillPage")]
113113
private static bool FixFillPage(RuleBookPage __instance, string headerText, params object[] otherArgs)
114114
{
115-
if (otherArgs?.Length > 0 && otherArgs.Last() is string pageId && pageId.StartsWith(API_ID))
115+
if (otherArgs?.Length > 0 && otherArgs.LastOrDefault() is string pageId && pageId.StartsWith(API_ID))
116116
{
117117
string sectionId = pageId.Replace(API_ID, "");
118118
FullRuleBookRangeInfo fullInfo = AllRuleBookInfos.Find(x => sectionId.StartsWith(x.SubSectionName));

0 commit comments

Comments
 (0)