Fix library hero battle tab panel
This commit is contained in:
parent
19cbaaa048
commit
3debce2f96
File diff suppressed because it is too large
Load Diff
@ -44,6 +44,7 @@ namespace TH1_UI.View.Outside
|
||||
|
||||
private GiantType _currentGiantType = GiantType.None;
|
||||
private HeroHintPanel _battlePanel;
|
||||
private RectTransform _infoRoot;
|
||||
|
||||
private enum HeroPanelTab
|
||||
{
|
||||
@ -110,6 +111,7 @@ namespace TH1_UI.View.Outside
|
||||
{
|
||||
var infoRoot = ResolveInfoRoot();
|
||||
if (infoRoot == null) return;
|
||||
_infoRoot = infoRoot;
|
||||
|
||||
var tabRoot = infoRoot.Find("TabRoot");
|
||||
if (tabRoot != null)
|
||||
@ -158,7 +160,9 @@ namespace TH1_UI.View.Outside
|
||||
|
||||
private void SelectTab(HeroPanelTab tab)
|
||||
{
|
||||
if (SettingContentRoot != null) SettingContentRoot.gameObject.SetActive(tab == HeroPanelTab.Setting);
|
||||
var isSettingTab = tab == HeroPanelTab.Setting;
|
||||
if (SettingContentRoot != null) SettingContentRoot.gameObject.SetActive(isSettingTab);
|
||||
else SetLegacySettingContentActive(isSettingTab);
|
||||
if (BattleContentRoot != null) BattleContentRoot.gameObject.SetActive(tab == HeroPanelTab.Battle);
|
||||
|
||||
SetTabVisual(SettingTabBG, tab == HeroPanelTab.Setting);
|
||||
@ -169,6 +173,36 @@ namespace TH1_UI.View.Outside
|
||||
if (tab == HeroPanelTab.Battle) RefreshBattlePanel();
|
||||
}
|
||||
|
||||
private void SetLegacySettingContentActive(bool active)
|
||||
{
|
||||
SetGameObjectActive(Name, active);
|
||||
SetGameObjectActive(CivRect != null && CivRect.parent != null ? CivRect.parent.gameObject : null, active);
|
||||
SetGameObjectActive(Desc, active);
|
||||
SetNamedInfoChildActive("DescTitle", active);
|
||||
SetGameObjectActive(DialogueAvatar != null && DialogueAvatar.transform.parent != null
|
||||
? DialogueAvatar.transform.parent.gameObject
|
||||
: null, active);
|
||||
if (active) SetAchieveItems(_currentGiantType);
|
||||
else SetAchievementSectionActive(false);
|
||||
}
|
||||
|
||||
private void SetNamedInfoChildActive(string childName, bool active)
|
||||
{
|
||||
if (_infoRoot == null || string.IsNullOrEmpty(childName)) return;
|
||||
var child = _infoRoot.Find(childName);
|
||||
if (child != null) child.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
private static void SetGameObjectActive(Component component, bool active)
|
||||
{
|
||||
if (component != null) component.gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
private static void SetGameObjectActive(GameObject gameObject, bool active)
|
||||
{
|
||||
if (gameObject != null) gameObject.SetActive(active);
|
||||
}
|
||||
|
||||
private static void SetTabVisual(Image image, bool selected)
|
||||
{
|
||||
if (image == null) return;
|
||||
@ -201,10 +235,11 @@ namespace TH1_UI.View.Outside
|
||||
var rect = go.GetComponent<RectTransform>();
|
||||
if (rect != null)
|
||||
{
|
||||
rect.anchorMin = new Vector2(0f, 1f);
|
||||
rect.anchorMax = new Vector2(0f, 1f);
|
||||
rect.pivot = new Vector2(0f, 1f);
|
||||
rect.anchoredPosition = Vector2.zero;
|
||||
rect.anchorMin = Vector2.zero;
|
||||
rect.anchorMax = Vector2.one;
|
||||
rect.pivot = new Vector2(0.5f, 0.5f);
|
||||
rect.offsetMin = Vector2.zero;
|
||||
rect.offsetMax = Vector2.zero;
|
||||
rect.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user