Skip to content

Commit 2d896d6

Browse files
committed
Fix CardManager
1 parent 215e2ab commit 2d896d6

5 files changed

Lines changed: 63 additions & 43 deletions

File tree

InscryptionAPI/AscensionScreens/AscensionRunSetupScreenBase.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ public virtual void InitializeScreen(GameObject partialScreen)
5252
public static AscensionRunSetupScreenBase BuildScreen(Type screenType, AscensionMenuScreens.Screen previousScreen, AscensionMenuScreens.Screen nextScreen)
5353
{
5454
// Create the new screen
55-
InscryptionAPIPlugin.Log.LogDebug($"Creating screen for {screenType.Name}");
55+
InscryptionAPIPlugin.Logger.LogDebug($"Creating screen for {screenType.Name}");
5656

5757
GameObject pseudoPrefab = AscensionMenuScreens.Instance.cardUnlockSummaryScreen;
5858
GameObject screenObject = GameObject.Instantiate(pseudoPrefab, pseudoPrefab.transform.parent);
5959
screenObject.name = screenType.Name;
6060

61-
InscryptionAPIPlugin.Log.LogDebug($"Getting old logic");
61+
InscryptionAPIPlugin.Logger.LogDebug($"Getting old logic");
6262
AscensionCardsSummaryScreen oldController = screenObject.GetComponent<AscensionCardsSummaryScreen>();
6363

64-
InscryptionAPIPlugin.Log.LogDebug($"Adding new logic");
64+
InscryptionAPIPlugin.Logger.LogDebug($"Adding new logic");
6565
AscensionRunSetupScreenBase controller = screenObject.AddComponent(screenType) as AscensionRunSetupScreenBase;
6666

6767
// Update the title of the screen
68-
InscryptionAPIPlugin.Log.LogDebug($"Updating screen title");
68+
InscryptionAPIPlugin.Logger.LogDebug($"Updating screen title");
6969
GameObject textHeader = screenObject.transform.Find("Header/Mid").gameObject;
7070
textHeader.transform.localPosition = new Vector3(0f, -0.575f, 0f);
7171
controller.screenTitle = textHeader.GetComponent<PixelText>();
@@ -79,7 +79,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
7979
GameObject footerLowline = screenObject.transform.Find("Footer/PixelTextLine_DIV").gameObject;
8080
if (controller.showCardDisplayer)
8181
{
82-
InscryptionAPIPlugin.Log.LogDebug($"Resetting card information displayer");
82+
InscryptionAPIPlugin.Logger.LogDebug($"Resetting card information displayer");
8383

8484
// Move the stuff
8585
cardTextDisplayer.transform.localPosition = new Vector3(2.38f, 0.27f, 0f);
@@ -97,12 +97,12 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
9797
}
9898
else
9999
{
100-
InscryptionAPIPlugin.Log.LogDebug($"Destroying unwanted card information displayer");
100+
InscryptionAPIPlugin.Logger.LogDebug($"Destroying unwanted card information displayer");
101101
// Destroy the card text displayer and footer low line
102102
GameObject.Destroy(cardTextDisplayer);
103103
GameObject.Destroy(footerLowline);
104104

105-
InscryptionAPIPlugin.Log.LogDebug($"Creating new information displayer");
105+
InscryptionAPIPlugin.Logger.LogDebug($"Creating new information displayer");
106106
GameObject newInfoDisplayer = GameObject.Instantiate(textHeader);
107107
controller.secondaryInfoDisplayer = newInfoDisplayer.GetComponent<PixelText>();
108108
controller.secondaryInfoDisplayer.SetColor(GameColors.Instance.nearWhite);
@@ -111,24 +111,24 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
111111

112112
if (controller.showCardPanel)
113113
{
114-
InscryptionAPIPlugin.Log.LogDebug($"Transferring ownership of cards");
114+
InscryptionAPIPlugin.Logger.LogDebug($"Transferring ownership of cards");
115115
controller.cards = oldController.cards;
116116
}
117117

118118
// Destroy the old game logic
119-
InscryptionAPIPlugin.Log.LogDebug($"Destroying old game logic");
119+
InscryptionAPIPlugin.Logger.LogDebug($"Destroying old game logic");
120120
Component.Destroy(oldController);
121121

122122
// Sort out the unlocks block
123-
InscryptionAPIPlugin.Log.LogDebug($"Handling card panel");
123+
InscryptionAPIPlugin.Logger.LogDebug($"Handling card panel");
124124
controller.cardPanel = screenObject.transform.Find("Unlocks").gameObject;
125125
if (controller.showCardDisplayer)
126126
controller.cardPanel.transform.localPosition = new Vector3(0f, 0.2f, 0f);
127127
else
128128
GameObject.Destroy(controller.cardPanel);
129129

130130
// Clone the challenge information from a challenge screen
131-
InscryptionAPIPlugin.Log.LogDebug($"Creating challenge text header");
131+
InscryptionAPIPlugin.Logger.LogDebug($"Creating challenge text header");
132132
GameObject header = screenObject.transform.Find("Header").gameObject;
133133
SequentialPixelTextLines headerLines = header.AddComponent<SequentialPixelTextLines>();
134134

@@ -141,19 +141,19 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
141141

142142
// Set the old header lines to the lines of the sequential pixel text lines
143143
// Fundamentally, the old header now controls these new challenge level lines
144-
InscryptionAPIPlugin.Log.LogDebug($"Assigning new lines of text to header");
144+
InscryptionAPIPlugin.Logger.LogDebug($"Assigning new lines of text to header");
145145
headerLines.lines = new List<PixelText>() {
146146
challengeLevel.GetComponent<PixelText>(),
147147
challengePoints.GetComponent<PixelText>()
148148
};
149149

150150
// And add those lines to the new challenge level controller
151-
InscryptionAPIPlugin.Log.LogDebug($"Giving controller access to header");
151+
InscryptionAPIPlugin.Logger.LogDebug($"Giving controller access to header");
152152
ChallengeLevelText challengeLevelController = screenObject.AddComponent<ChallengeLevelText>();
153153
challengeLevelController.headerPointsLines = headerLines;
154154
controller.challengeHeaderDisplay = challengeLevelController;
155155

156-
InscryptionAPIPlugin.Log.LogDebug($"Creating challenge footer text");
156+
InscryptionAPIPlugin.Logger.LogDebug($"Creating challenge footer text");
157157

158158
List<Transform> footerLinePseudos = new List<Transform>();
159159
GameObject challengeFooter = challengeScreen.transform.Find("Footer").gameObject;
@@ -162,7 +162,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
162162
footerLinePseudos.Add(child);
163163
footerLinePseudos.Sort((a, b) => a.localPosition.y < b.localPosition.y ? -1 : 1);
164164

165-
InscryptionAPIPlugin.Log.LogDebug($"Building footer text controller");
165+
InscryptionAPIPlugin.Logger.LogDebug($"Building footer text controller");
166166
List<GameObject> newFooterLines = footerLinePseudos.Select(t => GameObject.Instantiate(t.gameObject, footer.transform)).ToList();
167167
SequentialPixelTextLines footerLines = footer.AddComponent<SequentialPixelTextLines>();
168168
footerLines.lines = newFooterLines.Select(o => o.GetComponent<PixelText>()).ToList();
@@ -174,14 +174,14 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
174174
controller.rightButton = screenObject.transform.Find("Unlocks/ScreenAnchor/PageRightButton").gameObject.GetComponent<MainInputInteractable>();
175175
if (controller.showCardPanel)
176176
{
177-
InscryptionAPIPlugin.Log.LogDebug($"Reassigning left/right scroll buttons");
177+
InscryptionAPIPlugin.Logger.LogDebug($"Reassigning left/right scroll buttons");
178178
controller.leftButton.CursorSelectStarted = controller.LeftButtonClicked;
179179
controller.rightButton.CursorSelectStarted = controller.RightButtonClicked;
180180
controller.leftButton.gameObject.transform.localPosition = controller.leftButton.gameObject.transform.localPosition - (Vector3)BETWEEN_CARD_OFFSET * 1.5f;
181181
controller.rightButton.gameObject.transform.localPosition = controller.rightButton.gameObject.transform.localPosition + (Vector3)BETWEEN_CARD_OFFSET * 1.5f;
182182

183183
// Let's add three more cards to the panel
184-
InscryptionAPIPlugin.Log.LogDebug($"Expanding card panel");
184+
InscryptionAPIPlugin.Logger.LogDebug($"Expanding card panel");
185185
GameObject cardPrefab = Resources.Load<GameObject>("prefabs/gbccardbattle/pixelselectablecard");
186186
Transform cardsParent = screenObject.transform.Find("Unlocks/ScreenAnchor/Cards");
187187
for (int i = 0; i < 3; i++)
@@ -196,7 +196,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
196196
Traverse.Create(newPixelComponent).Field("pixelBorder").SetValue(pixelBorder);
197197
}
198198

199-
InscryptionAPIPlugin.Log.LogDebug($"Assigning click action to cards in card panel");
199+
InscryptionAPIPlugin.Logger.LogDebug($"Assigning click action to cards in card panel");
200200
foreach (PixelSelectableCard card in controller.cards)
201201
{
202202
card.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(card.CursorSelectStarted, new Action<MainInputInteractable>(delegate(MainInputInteractable i)
@@ -215,7 +215,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
215215
}
216216
else
217217
{
218-
InscryptionAPIPlugin.Log.LogDebug($"Destroying scroll buttons");
218+
InscryptionAPIPlugin.Logger.LogDebug($"Destroying scroll buttons");
219219
GameObject.Destroy(controller.leftButton.gameObject);
220220
GameObject.Destroy(controller.rightButton.gameObject);
221221

@@ -225,13 +225,13 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
225225

226226

227227
// Reroute the back button
228-
InscryptionAPIPlugin.Log.LogDebug($"Rerouting back button");
228+
InscryptionAPIPlugin.Logger.LogDebug($"Rerouting back button");
229229
GameObject backButton = screenObject.transform.Find("BackButton").gameObject;
230230
controller.backButton = backButton.GetComponent<AscensionMenuBackButton>();
231231
controller.backButton.screenToReturnTo = previousScreen;
232232

233233
// Add a continue button
234-
InscryptionAPIPlugin.Log.LogDebug($"Adding continue button");
234+
InscryptionAPIPlugin.Logger.LogDebug($"Adding continue button");
235235
GameObject continuePrefab = Resources.Load<GameObject>("prefabs/ui/ascension/ascensionmenucontinuebutton");
236236
GameObject continueButton = GameObject.Instantiate(continuePrefab, screenObject.transform);
237237
continueButton.transform.localPosition = new Vector3(2.08f, 1.15f, 0f);
@@ -248,24 +248,24 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
248248
controller.continueButton.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(controller.continueButton.CursorSelectStarted, clickAction);
249249

250250
// Let the base class do its magic
251-
InscryptionAPIPlugin.Log.LogDebug($"Calling screen implementation to finish creating screen UI elements");
251+
InscryptionAPIPlugin.Logger.LogDebug($"Calling screen implementation to finish creating screen UI elements");
252252
controller.InitializeScreen(screenObject);
253253

254254
// And we're done
255-
InscryptionAPIPlugin.Log.LogDebug($"Done building screen");
255+
InscryptionAPIPlugin.Logger.LogDebug($"Done building screen");
256256
return controller;
257257
}
258258

259259
private static void TransitionToGame()
260260
{
261261
if (!AscensionSaveData.Data.ChallengeLevelIsMet() && AscensionSaveData.Data.challengeLevel <= 12)
262262
{
263-
InscryptionAPIPlugin.Log.LogDebug("Sending the player to the confirmation screen");
263+
InscryptionAPIPlugin.Logger.LogDebug("Sending the player to the confirmation screen");
264264
AscensionMenuScreens.Instance.SwitchToScreen(AscensionMenuScreens.Screen.SelectChallengesConfirm);
265265
}
266266
else
267267
{
268-
InscryptionAPIPlugin.Log.LogDebug("Starting a new run");
268+
InscryptionAPIPlugin.Logger.LogDebug("Starting a new run");
269269
AscensionMenuScreens.Instance.TransitionToGame(true);
270270
}
271271
}

InscryptionAPI/AscensionScreens/AscensionScreenManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static void InitializeAllScreens()
6262
nextScreen = (AscensionMenuScreens.Screen)((int)nextScreen + 1);
6363
} catch (Exception ex)
6464
{
65-
InscryptionAPIPlugin.Log.LogError(ex);
65+
InscryptionAPIPlugin.Logger.LogError(ex);
6666
}
6767
}
6868

InscryptionAPI/Card/CardManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace InscryptionAPI.Card;
1010
[HarmonyPatch]
1111
public static class CardManager
1212
{
13-
public static readonly ReadOnlyCollection<CardInfo> BaseGameCards = new(Resources.LoadAll<CardInfo>("Data/"));
13+
public static readonly ReadOnlyCollection<CardInfo> BaseGameCards = new(Resources.LoadAll<CardInfo>("Data/Cards"));
1414
private static readonly List<CardInfo> NewCards = new();
1515

1616
private static long _counter = 0;
17-
private static long lastBuilt = -1;
17+
private static long _lastBuilt = -1;
1818

1919
public static event Action<List<CardInfo>> ModifyCardList;
2020

@@ -24,9 +24,9 @@ public static List<CardInfo> AllCards
2424
{
2525
get
2626
{
27-
if (_counter != lastBuilt)
27+
if (_counter != _lastBuilt)
2828
{
29-
lastBuilt = _counter;
29+
_lastBuilt = _counter;
3030
_allCards = BaseGameCards.Append(NewCards).ToList();
3131
ModifyCardList?.Invoke(_allCards);
3232
}
@@ -45,7 +45,7 @@ public static void Remove(CardInfo card)
4545
++_counter;
4646
}
4747

48-
[HarmonyPostfix]
48+
[HarmonyPrefix]
4949
[HarmonyPatch(typeof(ScriptableObjectLoader<UnityObject>), nameof(ScriptableObjectLoader<UnityObject>.LoadData))]
5050
[SuppressMessage("Member Access", "Publicizer001")]
5151
private static void CardLoadPrefix()

InscryptionAPI/Challenges/AscensionChallengeScreen.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ public static void AddPaginationToChallengeScreen()
3838
{
3939
if (ChallengeManager.newInfos.Count > 0)
4040
{
41-
InscryptionAPIPlugin.Log.LogInfo($"Creating Paginator");
41+
InscryptionAPIPlugin.Logger.LogDebug($"Creating Paginator");
4242

4343
AscensionChallengePaginator paginator = AscensionMenuScreens.Instance.selectChallengesScreen.GetComponent<AscensionChallengePaginator>();
4444
if (paginator == null)
4545
paginator = AscensionMenuScreens.Instance.selectChallengesScreen.AddComponent<AscensionChallengePaginator>();
4646

47-
InscryptionAPIPlugin.Log.LogInfo($"Getting pseudo prefabs");
47+
InscryptionAPIPlugin.Logger.LogDebug($"Getting pseudo prefabs");
4848

4949
GameObject leftPseudoPrefab = AscensionMenuScreens.Instance.cardUnlockSummaryScreen.transform.Find("Unlocks/ScreenAnchor/PageLeftButton").gameObject;
5050
GameObject rightPseudoPrefab = AscensionMenuScreens.Instance.cardUnlockSummaryScreen.transform.Find("Unlocks/ScreenAnchor/PageRightButton").gameObject;
5151

52-
InscryptionAPIPlugin.Log.LogInfo($"Getting icon grid");
52+
InscryptionAPIPlugin.Logger.LogDebug($"Getting icon grid");
5353

5454
GameObject challengeIconGrid = AscensionMenuScreens.Instance.selectChallengesScreen.transform.Find("Icons/ChallengeIconGrid").gameObject;
5555

5656
GameObject topRow = challengeIconGrid.transform.Find("TopRow").gameObject;
5757
GameObject bottomRow = challengeIconGrid.transform.Find("BottomRow").gameObject;
5858

59-
InscryptionAPIPlugin.Log.LogInfo($"Initializing data");
59+
InscryptionAPIPlugin.Logger.LogDebug($"Initializing data");
6060

6161
paginator.topRow = new List<AscensionIconInteractable>();
6262
paginator.bottomRow = new List<AscensionIconInteractable>();
@@ -66,15 +66,15 @@ public static void AddPaginationToChallengeScreen()
6666
paginator.bottomRow.Add(bottomRow.transform.Find($"Icon_{i+7}").gameObject.GetComponent<AscensionIconInteractable>());
6767
}
6868

69-
InscryptionAPIPlugin.Log.LogInfo($"Original challenge info");
69+
InscryptionAPIPlugin.Logger.LogDebug($"Original challenge info");
7070
paginator.availableChallenges = new List<AscensionChallengeInfo>();
7171
for (int i = 0; i < 7; i++)
7272
{
7373
paginator.availableChallenges.Add(paginator.topRow[i].challengeInfo);
7474
paginator.availableChallenges.Add(paginator.bottomRow[i].challengeInfo);
7575
}
7676

77-
InscryptionAPIPlugin.Log.LogInfo($"Custom challenge info");
77+
InscryptionAPIPlugin.Logger.LogDebug($"Custom challenge info");
7878
foreach (AscensionChallengeInfo info in ChallengeManager.newInfos.Where(i => ChallengeManager.IsStackable(i.challengeType)))
7979
{
8080
paginator.availableChallenges.Add(info); // Add stackables twice
@@ -88,22 +88,22 @@ public static void AddPaginationToChallengeScreen()
8888

8989
paginator.GeneratePages();
9090

91-
InscryptionAPIPlugin.Log.LogInfo($"Creating page turners");
91+
InscryptionAPIPlugin.Logger.LogDebug($"Creating page turners");
9292
GameObject leftIcon = GameObject.Instantiate(leftPseudoPrefab, challengeIconGrid.transform);
9393
GameObject rightIcon = GameObject.Instantiate(rightPseudoPrefab, challengeIconGrid.transform);
9494

95-
InscryptionAPIPlugin.Log.LogInfo($"Positioning page turners");
95+
InscryptionAPIPlugin.Logger.LogDebug($"Positioning page turners");
9696
leftIcon.transform.localPosition = leftIcon.transform.localPosition + (Vector3)(new Vector2(-0.75f, 0.25f));
9797
rightIcon.transform.localPosition = rightIcon.transform.localPosition + (Vector3)(new Vector2(0.75f, 0.25f));;
9898

99-
InscryptionAPIPlugin.Log.LogInfo($"Getting pagination controllers");
99+
InscryptionAPIPlugin.Logger.LogDebug($"Getting pagination controllers");
100100
AscensionMenuInteractable leftController = leftIcon.GetComponent<AscensionMenuInteractable>();
101101
AscensionMenuInteractable rightController = rightIcon.GetComponent<AscensionMenuInteractable>();
102102

103103
Action<MainInputInteractable> leftClickAction = (MainInputInteractable i) => paginator.ChallengePageLeft(i);
104104
Action<MainInputInteractable> rightClickAction = (MainInputInteractable i) => paginator.ChallengePageRight(i);
105105

106-
InscryptionAPIPlugin.Log.LogInfo($"Setting click actions");
106+
InscryptionAPIPlugin.Logger.LogDebug($"Setting click actions");
107107
leftController.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(leftController.CursorSelectStarted, leftClickAction);
108108
rightController.CursorSelectStarted = (Action<MainInputInteractable>)Delegate.Combine(rightController.CursorSelectStarted, rightClickAction);
109109

0 commit comments

Comments
 (0)