Moved UIPageController out of the card system and into a dedicated prefab
This commit is contained in:
@@ -25,3 +25,4 @@ MonoBehaviour:
|
|||||||
- {fileID: 2326026072467672024, guid: c8d9eb8c3ca524b4eb67f6364b455b87, type: 3}
|
- {fileID: 2326026072467672024, guid: c8d9eb8c3ca524b4eb67f6364b455b87, type: 3}
|
||||||
- {fileID: 3528960956969533010, guid: 53eea3840d3cde34a9768b8773a3a7e8, type: 3}
|
- {fileID: 3528960956969533010, guid: 53eea3840d3cde34a9768b8773a3a7e8, type: 3}
|
||||||
- {fileID: 6895404274863911569, guid: 840f3d8a936b39a41b5896328a692005, type: 3}
|
- {fileID: 6895404274863911569, guid: 840f3d8a936b39a41b5896328a692005, type: 3}
|
||||||
|
- {fileID: 3863019143023165617, guid: 774e30e3f0b1d0d49bad0c2abf11038a, type: 3}
|
||||||
|
|||||||
@@ -393,9 +393,8 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4224770106652410837}
|
- component: {fileID: 4224770106652410837}
|
||||||
- component: {fileID: 6676772947362202458}
|
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: UIPageController
|
m_Name: MenuPages
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@@ -424,18 +423,6 @@ RectTransform:
|
|||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 100, y: 100}
|
m_SizeDelta: {x: 100, y: 100}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &6676772947362202458
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8561999612656273135}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: b1ae6c1745e44e22a0fa9209ebe45ee3, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier: AppleHillsScripts::AppleHills.UI.CardSystem.UIPageController
|
|
||||||
--- !u!1 &8832204230413470760
|
--- !u!1 &8832204230413470760
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
50
Assets/Prefabs/UI/UIPageController.prefab
Normal file
50
Assets/Prefabs/UI/UIPageController.prefab
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &3863019143023165617
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 272997100784137721}
|
||||||
|
- component: {fileID: 497632815361153787}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: UIPageController
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &272997100784137721
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3863019143023165617}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 100, y: 100}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &497632815361153787
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3863019143023165617}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: b1ae6c1745e44e22a0fa9209ebe45ee3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: AppleHillsScripts::UI.Core.UIPageController
|
||||||
7
Assets/Prefabs/UI/UIPageController.prefab.meta
Normal file
7
Assets/Prefabs/UI/UIPageController.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 774e30e3f0b1d0d49bad0c2abf11038a
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,5 @@
|
|||||||
using AppleHills.Data.CardSystem;
|
using AppleHills.Data.CardSystem;
|
||||||
|
using Bootstrap;
|
||||||
using Core;
|
using Core;
|
||||||
using Data.CardSystem;
|
using Data.CardSystem;
|
||||||
using Input;
|
using Input;
|
||||||
@@ -30,26 +31,13 @@ namespace UI.CardSystem
|
|||||||
|
|
||||||
// Public property to access the backpack icon for animations
|
// Public property to access the backpack icon for animations
|
||||||
public GameObject BackpackIcon => backpackIcon;
|
public GameObject BackpackIcon => backpackIcon;
|
||||||
|
private UIPageController PageController => UIPageController.Instance;
|
||||||
private UIPageController _pageController;
|
|
||||||
private CardSystemManager _cardManager;
|
private CardSystemManager _cardManager;
|
||||||
private bool _isInitialized = false;
|
private bool _isInitialized = false;
|
||||||
private bool _hasUnseenCards = false;
|
private bool _hasUnseenCards = false;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
// Get or create a UI page controller
|
|
||||||
_pageController = FindAnyObjectByType<UIPageController>();
|
|
||||||
if (_pageController == null)
|
|
||||||
{
|
|
||||||
GameObject controllerObj = new GameObject("UIPageController");
|
|
||||||
controllerObj.transform.SetParent(transform);
|
|
||||||
_pageController = controllerObj.AddComponent<UIPageController>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize pages and hide them
|
|
||||||
InitializePages();
|
|
||||||
|
|
||||||
// Set up backpack button
|
// Set up backpack button
|
||||||
if (backpackButton != null)
|
if (backpackButton != null)
|
||||||
{
|
{
|
||||||
@@ -62,8 +50,17 @@ namespace UI.CardSystem
|
|||||||
// Hide notification dot initially
|
// Hide notification dot initially
|
||||||
if (boosterNotificationDot != null)
|
if (boosterNotificationDot != null)
|
||||||
boosterNotificationDot.gameObject.SetActive(false);
|
boosterNotificationDot.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
// Register for post-boot initialization
|
||||||
|
BootCompletionService.RegisterInitAction(InitializePostBoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitializePostBoot()
|
||||||
|
{
|
||||||
|
// Initialize pages and hide them
|
||||||
|
InitializePages();
|
||||||
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
// Get card manager
|
// Get card manager
|
||||||
@@ -102,9 +99,9 @@ namespace UI.CardSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unsubscribe from page controller events
|
// Unsubscribe from page controller events
|
||||||
if (_pageController != null)
|
if (PageController != null)
|
||||||
{
|
{
|
||||||
_pageController.OnPageChanged -= OnPageChanged;
|
PageController.OnPageChanged -= OnPageChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +127,9 @@ namespace UI.CardSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up page changed callback
|
// Set up page changed callback
|
||||||
if (_pageController != null)
|
if (PageController != null)
|
||||||
{
|
{
|
||||||
_pageController.OnPageChanged += OnPageChanged;
|
PageController.OnPageChanged += OnPageChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,9 +147,9 @@ namespace UI.CardSystem
|
|||||||
InputManager.Instance.RegisterOverrideConsumer(backpackInput);
|
InputManager.Instance.RegisterOverrideConsumer(backpackInput);
|
||||||
|
|
||||||
// If no pages are open, push the main menu
|
// If no pages are open, push the main menu
|
||||||
if (_pageController.CurrentPage == null)
|
if (PageController.CurrentPage == null)
|
||||||
{
|
{
|
||||||
_pageController.PushPage(mainMenuPage);
|
PageController.PushPage(mainMenuPage);
|
||||||
|
|
||||||
// Clear notification for unseen cards when opening menu
|
// Clear notification for unseen cards when opening menu
|
||||||
if (_hasUnseenCards)
|
if (_hasUnseenCards)
|
||||||
@@ -166,10 +163,10 @@ namespace UI.CardSystem
|
|||||||
backpackButton.gameObject.SetActive(false);
|
backpackButton.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_pageController.CurrentPage == mainMenuPage)
|
else if (PageController.CurrentPage == mainMenuPage)
|
||||||
{
|
{
|
||||||
// If main menu is open, pop it
|
// If main menu is open, pop it
|
||||||
_pageController.PopPage();
|
PageController.PopPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +221,7 @@ namespace UI.CardSystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OpenAlbumView()
|
public void OpenAlbumView()
|
||||||
{
|
{
|
||||||
_pageController.PushPage(albumViewPage);
|
PageController.PushPage(albumViewPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -234,7 +231,7 @@ namespace UI.CardSystem
|
|||||||
{
|
{
|
||||||
if (_cardManager != null && _cardManager.GetBoosterPackCount() > 0)
|
if (_cardManager != null && _cardManager.GetBoosterPackCount() > 0)
|
||||||
{
|
{
|
||||||
_pageController.PushPage(boosterOpeningPage);
|
PageController.PushPage(boosterOpeningPage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -289,8 +286,8 @@ namespace UI.CardSystem
|
|||||||
{
|
{
|
||||||
// If we're not in the album view or booster opening view,
|
// If we're not in the album view or booster opening view,
|
||||||
// show a notification dot on the backpack
|
// show a notification dot on the backpack
|
||||||
if (_pageController.CurrentPage != albumViewPage &&
|
if (PageController.CurrentPage != albumViewPage &&
|
||||||
_pageController.CurrentPage != boosterOpeningPage)
|
PageController.CurrentPage != boosterOpeningPage)
|
||||||
{
|
{
|
||||||
_hasUnseenCards = true;
|
_hasUnseenCards = true;
|
||||||
UpdateBoosterVisibility();
|
UpdateBoosterVisibility();
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ namespace UI.Core
|
|||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if (_instance != null && _instance != this)
|
|
||||||
{
|
|
||||||
Destroy(gameObject);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_instance = this;
|
_instance = this;
|
||||||
|
|
||||||
// TODO: Handle generic "cancel" action
|
// TODO: Handle generic "cancel" action
|
||||||
|
|||||||
Reference in New Issue
Block a user