Skip to content

Commit 63ffcf8

Browse files
committed
Normalize solution to file-scoped namespaces
1 parent bd0457b commit 63ffcf8

10 files changed

Lines changed: 846 additions & 856 deletions

InscryptionAPI/AscensionScreens/AscensionRunSetupScreenBase.cs

Lines changed: 343 additions & 344 deletions
Large diffs are not rendered by default.

InscryptionAPI/AscensionScreens/AscensionScreenManager.cs

Lines changed: 114 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -3,154 +3,153 @@
33
using UnityEngine;
44
using System.Collections;
55

6-
namespace InscryptionAPI.AscensionScreens
6+
namespace InscryptionAPI.AscensionScreens;
7+
8+
[HarmonyPatch]
9+
public static class AscensionScreenManager
710
{
8-
[HarmonyPatch]
9-
public static class AscensionScreenManager
10-
{
11-
internal static List<Type> registeredScreens = new List<Type>();
11+
internal static List<Type> registeredScreens = new List<Type>();
1212

13-
internal static Dictionary<AscensionMenuScreens.Screen, AscensionRunSetupScreenBase> screens;
13+
internal static Dictionary<AscensionMenuScreens.Screen, AscensionRunSetupScreenBase> screens;
1414

15-
internal static AscensionMenuScreens.Screen initialScreen = AscensionMenuScreens.Screen.JournalSummary;
15+
internal static AscensionMenuScreens.Screen initialScreen = AscensionMenuScreens.Screen.JournalSummary;
1616

17-
internal const int CUSTOM_SCREEN_START = 100;
17+
internal const int CUSTOM_SCREEN_START = 100;
1818

19-
private static string challengeScreenHoverText = "START RUN";
19+
private static string challengeScreenHoverText = "START RUN";
2020

21-
public static void RegisterScreen<T>() where T : AscensionRunSetupScreenBase
22-
{
23-
registeredScreens.Add(typeof(T));
24-
}
21+
public static void RegisterScreen<T>() where T : AscensionRunSetupScreenBase
22+
{
23+
registeredScreens.Add(typeof(T));
24+
}
2525

26-
private static AscensionScreenSort.Direction GetPreferredDirection(Type t)
27-
{
28-
AscensionScreenSort sortAttr = Attribute.GetCustomAttribute(t, typeof(AscensionScreenSort)) as AscensionScreenSort;
29-
if (sortAttr == null)
30-
return AscensionScreenSort.Direction.NoPreference;
31-
else
32-
return sortAttr.preferredDirection;
33-
}
26+
private static AscensionScreenSort.Direction GetPreferredDirection(Type t)
27+
{
28+
AscensionScreenSort sortAttr = Attribute.GetCustomAttribute(t, typeof(AscensionScreenSort)) as AscensionScreenSort;
29+
if (sortAttr == null)
30+
return AscensionScreenSort.Direction.NoPreference;
31+
else
32+
return sortAttr.preferredDirection;
33+
}
3434

35-
public static void InitializeAllScreens()
36-
{
37-
// Sort the screens
38-
registeredScreens.Sort((a, b) => (int)GetPreferredDirection(a) - (int)GetPreferredDirection(b));
35+
public static void InitializeAllScreens()
36+
{
37+
// Sort the screens
38+
registeredScreens.Sort((a, b) => (int)GetPreferredDirection(a) - (int)GetPreferredDirection(b));
3939

40-
// Build screens
41-
screens = new Dictionary<AscensionMenuScreens.Screen, AscensionRunSetupScreenBase>();
40+
// Build screens
41+
screens = new Dictionary<AscensionMenuScreens.Screen, AscensionRunSetupScreenBase>();
4242

43-
AscensionMenuScreens.Screen previousScreen = AscensionMenuScreens.Screen.SelectChallenges;
44-
AscensionMenuScreens.Screen currentScreen = (AscensionMenuScreens.Screen)CUSTOM_SCREEN_START;
45-
AscensionMenuScreens.Screen nextScreen = (AscensionMenuScreens.Screen)(CUSTOM_SCREEN_START + 1);
46-
initialScreen = currentScreen;
47-
for (int i = 0; i < registeredScreens.Count; i++)
48-
{
49-
Type screenType = registeredScreens[i];
43+
AscensionMenuScreens.Screen previousScreen = AscensionMenuScreens.Screen.SelectChallenges;
44+
AscensionMenuScreens.Screen currentScreen = (AscensionMenuScreens.Screen)CUSTOM_SCREEN_START;
45+
AscensionMenuScreens.Screen nextScreen = (AscensionMenuScreens.Screen)(CUSTOM_SCREEN_START + 1);
46+
initialScreen = currentScreen;
47+
for (int i = 0; i < registeredScreens.Count; i++)
48+
{
49+
Type screenType = registeredScreens[i];
5050

51-
if (i == registeredScreens.Count - 1) // the last one
52-
nextScreen = AscensionMenuScreens.Screen.SelectChallengesConfirm;
51+
if (i == registeredScreens.Count - 1) // the last one
52+
nextScreen = AscensionMenuScreens.Screen.SelectChallengesConfirm;
5353

54-
try
55-
{
56-
AscensionRunSetupScreenBase screen = AscensionRunSetupScreenBase.BuildScreen(screenType, previousScreen, nextScreen);
54+
try
55+
{
56+
AscensionRunSetupScreenBase screen = AscensionRunSetupScreenBase.BuildScreen(screenType, previousScreen, nextScreen);
5757

58-
screens.Add(currentScreen, screen);
58+
screens.Add(currentScreen, screen);
5959

60-
previousScreen = currentScreen;
61-
currentScreen = nextScreen;
62-
nextScreen = (AscensionMenuScreens.Screen)((int)nextScreen + 1);
63-
} catch (Exception ex)
64-
{
65-
InscryptionAPIPlugin.Logger.LogError(ex);
66-
}
60+
previousScreen = currentScreen;
61+
currentScreen = nextScreen;
62+
nextScreen = (AscensionMenuScreens.Screen)((int)nextScreen + 1);
63+
} catch (Exception ex)
64+
{
65+
InscryptionAPIPlugin.Logger.LogError(ex);
6766
}
67+
}
6868

69-
if (screens.Count == 0)
70-
return;
69+
if (screens.Count == 0)
70+
return;
7171

72-
// Now make another pass through the screens and set the behavior of hovering over the continue and back buttons
72+
// Now make another pass through the screens and set the behavior of hovering over the continue and back buttons
7373

74-
previousScreen = AscensionMenuScreens.Screen.SelectChallenges;
75-
currentScreen = (AscensionMenuScreens.Screen)CUSTOM_SCREEN_START;
76-
nextScreen = (AscensionMenuScreens.Screen)(CUSTOM_SCREEN_START + 1);
74+
previousScreen = AscensionMenuScreens.Screen.SelectChallenges;
75+
currentScreen = (AscensionMenuScreens.Screen)CUSTOM_SCREEN_START;
76+
nextScreen = (AscensionMenuScreens.Screen)(CUSTOM_SCREEN_START + 1);
7777

78-
// Set the hover text of the challenge screen to be the title of the first custom screen
79-
challengeScreenHoverText = screens[currentScreen].headerText;
78+
// Set the hover text of the challenge screen to be the title of the first custom screen
79+
challengeScreenHoverText = screens[currentScreen].headerText;
8080

81-
for (int i = 0; i < screens.Count; i++)
82-
{
83-
AscensionRunSetupScreenBase cur = screens[currentScreen];
81+
for (int i = 0; i < screens.Count; i++)
82+
{
83+
AscensionRunSetupScreenBase cur = screens[currentScreen];
8484

85-
string prevText = screens.ContainsKey(previousScreen) ? screens[previousScreen].headerText : "SELECT CHALLENGES";
86-
string nextText = screens.ContainsKey(nextScreen) ? screens[nextScreen].headerText : "START RUN";
85+
string prevText = screens.ContainsKey(previousScreen) ? screens[previousScreen].headerText : "SELECT CHALLENGES";
86+
string nextText = screens.ContainsKey(nextScreen) ? screens[nextScreen].headerText : "START RUN";
8787

88-
Action<MainInputInteractable> prevHoverAction = (MainInputInteractable i) => cur.DisplayMessage(Localization.ToUpper(Localization.Translate(prevText)));
89-
Action<MainInputInteractable> nextHoverAction = (MainInputInteractable i) => cur.DisplayMessage(Localization.ToUpper(Localization.Translate(nextText)));
90-
Action<MainInputInteractable> unHoverAction = (MainInputInteractable i) => cur.ClearMessage();
88+
Action<MainInputInteractable> prevHoverAction = (MainInputInteractable i) => cur.DisplayMessage(Localization.ToUpper(Localization.Translate(prevText)));
89+
Action<MainInputInteractable> nextHoverAction = (MainInputInteractable i) => cur.DisplayMessage(Localization.ToUpper(Localization.Translate(nextText)));
90+
Action<MainInputInteractable> unHoverAction = (MainInputInteractable i) => cur.ClearMessage();
9191

92-
cur.backButton.CursorEntered = (Action<MainInputInteractable>)Delegate.Combine(cur.backButton.CursorEntered, prevHoverAction);
93-
cur.backButton.CursorExited = (Action<MainInputInteractable>)Delegate.Combine(cur.backButton.CursorExited, unHoverAction);
94-
cur.continueButton.CursorEntered = (Action<MainInputInteractable>)Delegate.Combine(cur.continueButton.CursorEntered, nextHoverAction);
95-
cur.continueButton.CursorExited = (Action<MainInputInteractable>)Delegate.Combine(cur.continueButton.CursorExited, unHoverAction);
92+
cur.backButton.CursorEntered = (Action<MainInputInteractable>)Delegate.Combine(cur.backButton.CursorEntered, prevHoverAction);
93+
cur.backButton.CursorExited = (Action<MainInputInteractable>)Delegate.Combine(cur.backButton.CursorExited, unHoverAction);
94+
cur.continueButton.CursorEntered = (Action<MainInputInteractable>)Delegate.Combine(cur.continueButton.CursorEntered, nextHoverAction);
95+
cur.continueButton.CursorExited = (Action<MainInputInteractable>)Delegate.Combine(cur.continueButton.CursorExited, unHoverAction);
9696

97-
previousScreen = currentScreen;
98-
currentScreen = nextScreen;
99-
nextScreen = (AscensionMenuScreens.Screen)((int)nextScreen + 1);
100-
}
97+
previousScreen = currentScreen;
98+
currentScreen = nextScreen;
99+
nextScreen = (AscensionMenuScreens.Screen)((int)nextScreen + 1);
101100
}
101+
}
102102

103-
// This patches the confirmation button of the challenge screen to ensure it starts the queue
104-
[HarmonyPatch(typeof(AscensionChallengeScreen), "OnContinuePressed")]
105-
[HarmonyPrefix]
106-
public static bool TransitionToSideDeckScreen(ref AscensionChallengeScreen __instance)
107-
{
108-
if (screens == null || screens.Count == 0)
109-
return true; // No custom screens; execute the original method
103+
// This patches the confirmation button of the challenge screen to ensure it starts the queue
104+
[HarmonyPatch(typeof(AscensionChallengeScreen), "OnContinuePressed")]
105+
[HarmonyPrefix]
106+
public static bool TransitionToSideDeckScreen(ref AscensionChallengeScreen __instance)
107+
{
108+
if (screens == null || screens.Count == 0)
109+
return true; // No custom screens; execute the original method
110110

111-
AscensionMenuScreens.Instance.SwitchToScreen(initialScreen);
112-
return false;
113-
}
111+
AscensionMenuScreens.Instance.SwitchToScreen(initialScreen);
112+
return false;
113+
}
114114

115-
[HarmonyPatch(typeof(AscensionMenuScreens), "ScreenSwitchSequence")]
116-
[HarmonyPostfix]
117-
public static IEnumerator SwitchToScreen(IEnumerator sequenceEvent, AscensionMenuScreens.Screen screen)
118-
{
119-
while (sequenceEvent.MoveNext())
120-
yield return sequenceEvent.Current;
115+
[HarmonyPatch(typeof(AscensionMenuScreens), "ScreenSwitchSequence")]
116+
[HarmonyPostfix]
117+
public static IEnumerator SwitchToScreen(IEnumerator sequenceEvent, AscensionMenuScreens.Screen screen)
118+
{
119+
while (sequenceEvent.MoveNext())
120+
yield return sequenceEvent.Current;
121121

122-
yield return new WaitForSeconds(0.05f);
122+
yield return new WaitForSeconds(0.05f);
123123

124-
if (AscensionScreenManager.screens.ContainsKey(screen))
125-
AscensionScreenManager.screens[screen].gameObject.SetActive(true);
124+
if (AscensionScreenManager.screens.ContainsKey(screen))
125+
AscensionScreenManager.screens[screen].gameObject.SetActive(true);
126126

127-
yield break;
128-
}
127+
yield break;
128+
}
129129

130-
[HarmonyPatch(typeof(AscensionMenuScreens), "ConfigurePostGameScreens")]
131-
[HarmonyPostfix]
132-
public static void InitializeScreensOnStart()
133-
{
134-
InitializeAllScreens();
135-
}
130+
[HarmonyPatch(typeof(AscensionMenuScreens), "ConfigurePostGameScreens")]
131+
[HarmonyPostfix]
132+
public static void InitializeScreensOnStart()
133+
{
134+
InitializeAllScreens();
135+
}
136136

137-
[HarmonyPatch(typeof(AscensionMenuScreens), "DeactivateAllScreens")]
138-
[HarmonyPostfix]
139-
public static void DeactivateAllCustomScreens()
140-
{
141-
if (screens != null && screens.Count > 0)
142-
foreach (AscensionRunSetupScreenBase screenbase in screens.Values)
143-
if (screenbase != null && screenbase.gameObject != null)
144-
screenbase.gameObject.SetActive(false);
145-
}
137+
[HarmonyPatch(typeof(AscensionMenuScreens), "DeactivateAllScreens")]
138+
[HarmonyPostfix]
139+
public static void DeactivateAllCustomScreens()
140+
{
141+
if (screens != null && screens.Count > 0)
142+
foreach (AscensionRunSetupScreenBase screenbase in screens.Values)
143+
if (screenbase != null && screenbase.gameObject != null)
144+
screenbase.gameObject.SetActive(false);
145+
}
146146

147-
[HarmonyPatch(typeof(AscensionChallengeScreen), "OnContinueCursorEnter")]
148-
[HarmonyPrefix]
149-
public static bool HoverTextFirstCustomScreen(ref AscensionChallengeScreen __instance)
150-
{
151-
string line = Localization.Translate(challengeScreenHoverText);
152-
__instance.challengeDisplayer.DisplayText("", line, "", false);
153-
return false;
154-
}
147+
[HarmonyPatch(typeof(AscensionChallengeScreen), "OnContinueCursorEnter")]
148+
[HarmonyPrefix]
149+
public static bool HoverTextFirstCustomScreen(ref AscensionChallengeScreen __instance)
150+
{
151+
string line = Localization.Translate(challengeScreenHoverText);
152+
__instance.challengeDisplayer.DisplayText("", line, "", false);
153+
return false;
155154
}
156155
}
Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
namespace InscryptionAPI.AscensionScreens
1+
namespace InscryptionAPI.AscensionScreens;
2+
3+
// Decorates a custom screen and marks how it should be sorted
4+
public class AscensionScreenSort : System.Attribute
25
{
3-
// Decorates a custom screen and marks how it should be sorted
4-
public class AscensionScreenSort : System.Attribute
6+
public enum Direction : int
57
{
6-
public enum Direction : int
7-
{
8-
RequiresStart = 1,
9-
PrefersStart = 2,
10-
NoPreference = 3,
11-
PrefersEnd = 4,
12-
RequiresEnd = 5,
13-
}
8+
RequiresStart = 1,
9+
PrefersStart = 2,
10+
NoPreference = 3,
11+
PrefersEnd = 4,
12+
RequiresEnd = 5,
13+
}
1414

15-
public Direction preferredDirection;
15+
public Direction preferredDirection;
1616

17-
public AscensionScreenSort(Direction preferredDirection = Direction.NoPreference)
18-
{
19-
this.preferredDirection = preferredDirection;
20-
}
21-
}
17+
public AscensionScreenSort(Direction preferredDirection = Direction.NoPreference)
18+
{
19+
this.preferredDirection = preferredDirection;
20+
}
2221
}

InscryptionAPI/Card/CardManager.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ public static class CardManager
1717

1818
static CardManager()
1919
{
20-
AllCards = BaseGameCards.ToList();
2120
NewCards.CollectionChanged += static (_, _) =>
2221
{
2322
var cards = BaseGameCards.Append(NewCards).ToList();
2423
AllCards = ModifyCardList?.Invoke(cards) ?? cards;
2524
};
2625
}
2726

28-
public static List<CardInfo> AllCards { get; private set; }
27+
public static List<CardInfo> AllCards { get; private set; } = BaseGameCards.ToList();
2928

3029
public static void Add(CardInfo newCard) => NewCards.Add(newCard);
3130
public static void Remove(CardInfo card) => NewCards.Remove(card);

0 commit comments

Comments
 (0)