@@ -35,78 +35,81 @@ public static void ReassignableIconFixes(ref AscensionIconInteractable __instanc
3535 [ HarmonyPostfix ]
3636 public static void AddPaginationToChallengeScreen ( )
3737 {
38- if ( ChallengeManager . newInfos . Count > 0 )
39- {
40- InscryptionAPIPlugin . Logger . LogDebug ( $ "Creating Paginator") ;
38+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Creating Paginator") ;
4139
42- AscensionChallengePaginator paginator = AscensionMenuScreens . Instance . selectChallengesScreen . GetComponent < AscensionChallengePaginator > ( ) ;
43- if ( paginator == null )
44- paginator = AscensionMenuScreens . Instance . selectChallengesScreen . AddComponent < AscensionChallengePaginator > ( ) ;
40+ AscensionChallengePaginator paginator = AscensionMenuScreens . Instance . selectChallengesScreen . GetComponent < AscensionChallengePaginator > ( ) ;
41+ if ( paginator == null )
42+ paginator = AscensionMenuScreens . Instance . selectChallengesScreen . AddComponent < AscensionChallengePaginator > ( ) ;
4543
46- InscryptionAPIPlugin . Logger . LogDebug ( $ "Getting pseudo prefabs") ;
44+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Getting pseudo prefabs") ;
4745
48- GameObject leftPseudoPrefab = AscensionMenuScreens . Instance . cardUnlockSummaryScreen . transform . Find ( "Unlocks/ScreenAnchor/PageLeftButton" ) . gameObject ;
49- GameObject rightPseudoPrefab = AscensionMenuScreens . Instance . cardUnlockSummaryScreen . transform . Find ( "Unlocks/ScreenAnchor/PageRightButton" ) . gameObject ;
46+ GameObject leftPseudoPrefab = AscensionMenuScreens . Instance . cardUnlockSummaryScreen . transform . Find ( "Unlocks/ScreenAnchor/PageLeftButton" ) . gameObject ;
47+ GameObject rightPseudoPrefab = AscensionMenuScreens . Instance . cardUnlockSummaryScreen . transform . Find ( "Unlocks/ScreenAnchor/PageRightButton" ) . gameObject ;
5048
51- InscryptionAPIPlugin . Logger . LogDebug ( $ "Getting icon grid") ;
49+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Getting icon grid") ;
5250
53- GameObject challengeIconGrid = AscensionMenuScreens . Instance . selectChallengesScreen . transform . Find ( "Icons/ChallengeIconGrid" ) . gameObject ;
51+ GameObject challengeIconGrid = AscensionMenuScreens . Instance . selectChallengesScreen . transform . Find ( "Icons/ChallengeIconGrid" ) . gameObject ;
5452
55- GameObject topRow = challengeIconGrid . transform . Find ( "TopRow" ) . gameObject ;
56- GameObject bottomRow = challengeIconGrid . transform . Find ( "BottomRow" ) . gameObject ;
53+ GameObject topRow = challengeIconGrid . transform . Find ( "TopRow" ) . gameObject ;
54+ GameObject bottomRow = challengeIconGrid . transform . Find ( "BottomRow" ) . gameObject ;
5755
58- InscryptionAPIPlugin . Logger . LogDebug ( $ "Initializing data") ;
56+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Initializing data") ;
5957
60- paginator . topRow = new List < AscensionIconInteractable > ( ) ;
61- paginator . bottomRow = new List < AscensionIconInteractable > ( ) ;
62- for ( int i = 1 ; i <= 7 ; i ++ )
63- {
64- paginator . topRow . Add ( topRow . transform . Find ( $ "Icon_{ i } ") . gameObject . GetComponent < AscensionIconInteractable > ( ) ) ;
65- paginator . bottomRow . Add ( bottomRow . transform . Find ( $ "Icon_{ i + 7 } ") . gameObject . GetComponent < AscensionIconInteractable > ( ) ) ;
66- }
58+ paginator . topRow = new List < AscensionIconInteractable > ( ) ;
59+ paginator . bottomRow = new List < AscensionIconInteractable > ( ) ;
60+ for ( int i = 1 ; i <= 7 ; i ++ )
61+ {
62+ paginator . topRow . Add ( topRow . transform . Find ( $ "Icon_{ i } ") . gameObject . GetComponent < AscensionIconInteractable > ( ) ) ;
63+ paginator . bottomRow . Add ( bottomRow . transform . Find ( $ "Icon_{ i + 7 } ") . gameObject . GetComponent < AscensionIconInteractable > ( ) ) ;
64+ }
6765
68- InscryptionAPIPlugin . Logger . LogDebug ( $ "Original challenge info") ;
69- paginator . availableChallenges = new List < AscensionChallengeInfo > ( ) ;
70- for ( int i = 0 ; i < 7 ; i ++ )
71- {
72- paginator . availableChallenges . Add ( paginator . topRow [ i ] . challengeInfo ) ;
73- paginator . availableChallenges . Add ( paginator . bottomRow [ i ] . challengeInfo ) ;
74- }
66+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Original challenge info") ;
67+ paginator . availableChallenges = new List < AscensionChallengeInfo > ( ) ;
68+ for ( int i = 0 ; i < 7 ; i ++ )
69+ {
70+ paginator . availableChallenges . Add ( paginator . topRow [ i ] . challengeInfo ) ;
71+ paginator . availableChallenges . Add ( paginator . bottomRow [ i ] . challengeInfo ) ;
72+ }
7573
76- InscryptionAPIPlugin . Logger . LogDebug ( $ "Custom challenge info") ;
77- foreach ( AscensionChallengeInfo info in ChallengeManager . newInfos . Where ( i => ChallengeManager . IsStackable ( i . challengeType ) ) )
78- {
79- paginator . availableChallenges . Add ( info ) ; // Add stackables twice
80- paginator . availableChallenges . Add ( info ) ; // Do them first so they stack nice
81- }
74+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Custom challenge info") ;
75+ foreach ( AscensionChallengeInfo info in ChallengeManager . newInfos . Where ( i => ChallengeManager . IsStackable ( i . challengeType ) ) )
76+ {
77+ paginator . availableChallenges . Add ( info ) ; // Add stackables twice
78+ paginator . availableChallenges . Add ( info ) ; // Do them first so they stack nice
79+ }
8280
83- foreach ( AscensionChallengeInfo info in ChallengeManager . newInfos . Where ( i => ! ChallengeManager . IsStackable ( i . challengeType ) ) )
84- {
85- paginator . availableChallenges . Add ( info ) ;
86- }
81+ foreach ( AscensionChallengeInfo info in ChallengeManager . newInfos . Where ( i => ! ChallengeManager . IsStackable ( i . challengeType ) ) )
82+ {
83+ paginator . availableChallenges . Add ( info ) ;
84+ }
8785
88- paginator . GeneratePages ( ) ;
86+ paginator . GeneratePages ( ) ;
8987
90- InscryptionAPIPlugin . Logger . LogDebug ( $ "Creating page turners") ;
91- GameObject leftIcon = GameObject . Instantiate ( leftPseudoPrefab , challengeIconGrid . transform ) ;
92- GameObject rightIcon = GameObject . Instantiate ( rightPseudoPrefab , challengeIconGrid . transform ) ;
88+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Creating page turners") ;
89+ GameObject leftIcon = GameObject . Instantiate ( leftPseudoPrefab , challengeIconGrid . transform ) ;
90+ GameObject rightIcon = GameObject . Instantiate ( rightPseudoPrefab , challengeIconGrid . transform ) ;
9391
94- InscryptionAPIPlugin . Logger . LogDebug ( $ "Positioning page turners") ;
95- leftIcon . transform . localPosition = leftIcon . transform . localPosition + ( Vector3 ) ( new Vector2 ( - 0.75f , 0.25f ) ) ;
96- rightIcon . transform . localPosition = rightIcon . transform . localPosition + ( Vector3 ) ( new Vector2 ( 0.75f , 0.25f ) ) ; ;
92+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Positioning page turners") ;
93+ leftIcon . transform . localPosition = leftIcon . transform . localPosition + ( Vector3 ) ( new Vector2 ( - 0.75f , 0.25f ) ) ;
94+ rightIcon . transform . localPosition = rightIcon . transform . localPosition + ( Vector3 ) ( new Vector2 ( 0.75f , 0.25f ) ) ; ;
9795
98- InscryptionAPIPlugin . Logger . LogDebug ( $ "Getting pagination controllers") ;
99- AscensionMenuInteractable leftController = leftIcon . GetComponent < AscensionMenuInteractable > ( ) ;
100- AscensionMenuInteractable rightController = rightIcon . GetComponent < AscensionMenuInteractable > ( ) ;
96+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Getting pagination controllers") ;
97+ AscensionMenuInteractable leftController = leftIcon . GetComponent < AscensionMenuInteractable > ( ) ;
98+ AscensionMenuInteractable rightController = rightIcon . GetComponent < AscensionMenuInteractable > ( ) ;
10199
102- Action < MainInputInteractable > leftClickAction = ( MainInputInteractable i ) => paginator . ChallengePageLeft ( i ) ;
103- Action < MainInputInteractable > rightClickAction = ( MainInputInteractable i ) => paginator . ChallengePageRight ( i ) ;
100+ Action < MainInputInteractable > leftClickAction = ( MainInputInteractable i ) => paginator . ChallengePageLeft ( i ) ;
101+ Action < MainInputInteractable > rightClickAction = ( MainInputInteractable i ) => paginator . ChallengePageRight ( i ) ;
104102
105- InscryptionAPIPlugin . Logger . LogDebug ( $ "Setting click actions") ;
106- leftController . CursorSelectStarted = ( Action < MainInputInteractable > ) Delegate . Combine ( leftController . CursorSelectStarted , leftClickAction ) ;
107- rightController . CursorSelectStarted = ( Action < MainInputInteractable > ) Delegate . Combine ( rightController . CursorSelectStarted , rightClickAction ) ;
103+ InscryptionAPIPlugin . Logger . LogDebug ( $ "Setting click actions") ;
104+ leftController . CursorSelectStarted = ( Action < MainInputInteractable > ) Delegate . Combine ( leftController . CursorSelectStarted , leftClickAction ) ;
105+ rightController . CursorSelectStarted = ( Action < MainInputInteractable > ) Delegate . Combine ( rightController . CursorSelectStarted , rightClickAction ) ;
108106
109- paginator . challengePageIndex = 0 ;
107+ paginator . challengePageIndex = 0 ;
108+
109+ if ( ChallengeManager . newInfos . Count == 0 )
110+ {
111+ GameObject . Destroy ( leftController . gameObject ) ;
112+ GameObject . Destroy ( rightController . gameObject ) ;
110113 }
111114 }
112115}
0 commit comments