@@ -38,31 +38,18 @@ public class ShopManager(IntPtr intPtr) : MonoBehaviour(intPtr)
3838 public Il2CppReferenceField < GameObjectGrid > mapBannerGrid ;
3939 public Il2CppReferenceField < PassiveButton > exitButton ;
4040 public Il2CppReferenceField < PassiveButton > openMapsFolderButton ;
41- public Il2CppReferenceField < GameObject > loadingOverlay ;
42- public Il2CppReferenceField < TextMeshPro > loadingText ;
43- public Il2CppReferenceField < GameObject > errorOverlay ;
44- public Il2CppReferenceField < TextMeshPro > errorText ;
41+ public Il2CppReferenceField < LoadingOverlay > loadingOverlay ;
4542
4643 public static ShopManager ? Instance { get ; private set ; }
4744
4845 private const string CONTROLLER_OVERLAY_ID = "LIShop" ;
4946
47+ public LoadingOverlay LoadingOverlay => loadingOverlay . Value ;
48+
5049 /// If true, re-runs the map randomization when the shop is closed
5150 private bool _randomizeMapsOnClose ;
5251 private ShopTab _currentTab = ShopTab . None ;
5352 private ShopTabButton [ ] ? _shopTabButtons ;
54- private readonly string [ ] _funLoadingTexts =
55- [
56- "Searching dropship..." ,
57- "Calibrating engines..." ,
58- "Searching for habitable planets..." ,
59- "Stabilizing reactor..." ,
60- "Scanning for planetary systems..." ,
61- "Aligning telescope..." ,
62- "Navigating asteroids..." ,
63- "Diverting power..." ,
64- "Doing card swipe..."
65- ] ;
6653
6754 public void Awake ( )
6855 {
@@ -104,6 +91,9 @@ private static void OpenMapsFolder()
10491 /// </summary>
10592 public void CloseShop ( )
10693 {
94+ if ( LoadingOverlay . PreventClose )
95+ return ;
96+
10797 if ( _randomizeMapsOnClose )
10898 MapRandomizer . RandomizeMap ( false ) ;
10999
@@ -147,19 +137,19 @@ public void SetTab(ShopTab tab, Sprite? titleSprite = null)
147137 SetMaps ( lobbyMaps ) ;
148138 break ;
149139 case ShopTab . FeaturedWorkshopMaps :
150- SetLoadingVisible ( true ) ;
140+ LoadingOverlay . Show ( ) ;
151141 LevelImposterAPI . GetFeatured (
152142 m => OnWorkshopLoaded ( m , tab ) ,
153143 error => OnError ( tab , error ) ) ;
154144 break ;
155145 case ShopTab . TopWorkshopMaps :
156- SetLoadingVisible ( true ) ;
146+ LoadingOverlay . Show ( ) ;
157147 LevelImposterAPI . GetTop (
158148 m => OnWorkshopLoaded ( m , tab ) ,
159149 error => OnError ( tab , error ) ) ;
160150 break ;
161151 case ShopTab . RecentWorkshopMaps :
162- SetLoadingVisible ( true ) ;
152+ LoadingOverlay . Show ( ) ;
163153 LevelImposterAPI . GetRecent (
164154 m => OnWorkshopLoaded ( m , tab ) ,
165155 error => OnError ( tab , error ) ) ;
@@ -185,17 +175,7 @@ private void OnError(ShopTab tab, string message)
185175 if ( _currentTab != tab )
186176 return ;
187177
188- SetErrorVisible ( true , message ) ;
189- }
190- private void SetErrorVisible ( bool isVisible , string message = "" )
191- {
192- errorOverlay . Value . SetActive ( isVisible ) ;
193- errorText . Value . text = message ;
194- if ( ! isVisible )
195- return ;
196-
197- // Disable loading overlay
198- SetLoadingVisible ( false ) ;
178+ LoadingOverlay . ShowError ( "The impostor sabotaged comms!" , message ) ;
199179 }
200180
201181 /// <summary>
@@ -219,8 +199,7 @@ private void UpdateTabButtonState()
219199 private void SetMaps ( LIMetadata [ ] maps )
220200 {
221201 // Hide Overlays
222- SetLoadingVisible ( false ) ;
223- SetErrorVisible ( false ) ;
202+ LoadingOverlay . Hide ( ) ;
224203
225204 // Clear Existing Banners
226205 mapBannerGrid . Value . DestroyAll ( ) ;
@@ -246,24 +225,6 @@ public void RandomizeMapOnClose()
246225 {
247226 _randomizeMapsOnClose = true ;
248227 }
249-
250- /// <summary>
251- /// Shows or hides the loading overlay
252- /// </summary>
253- /// <param name="isVisible">Whether the loading overlay should be visible</param>
254- public void SetLoadingVisible ( bool isVisible )
255- {
256- loadingOverlay . Value . SetActive ( isVisible ) ;
257- if ( ! isVisible )
258- return ;
259-
260- // Disable error overlay
261- SetErrorVisible ( false ) ;
262-
263- // Randomize loading text
264- var randomIndex = UnityEngine . Random . Range ( 0 , _funLoadingTexts . Length ) ;
265- loadingText . Value . text = _funLoadingTexts [ randomIndex ] ;
266- }
267228
268229 private void AddStarField ( )
269230 {
0 commit comments