카테고리 초기화 및 찾는 로직 수정
This commit is contained in:
parent
1b039ea8c8
commit
627b0aedf5
@ -65,7 +65,6 @@ protected override void OnCreatedInitializePopup()
|
||||
{
|
||||
InitializeViews();
|
||||
InitializeTabGroups();
|
||||
SetupCategoryTabs();
|
||||
SetupBindings();
|
||||
}
|
||||
|
||||
@ -173,12 +172,6 @@ private void InitializeViews()
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupCategoryTabs()
|
||||
{
|
||||
_menuCategoryTabs.UseDefaultAllowedValues();
|
||||
_cookwareCategoryTabs.UseDefaultAllowedValues();
|
||||
}
|
||||
|
||||
private void InitializeTabGroups()
|
||||
{
|
||||
_sectionTabs.Initialize(OnSectionTabSelected);
|
||||
@ -189,7 +182,7 @@ private void InitializeTabGroups()
|
||||
private void UpdateSectionTabs()
|
||||
{
|
||||
if (_viewModel == null) return;
|
||||
_sectionTabs.SelectTab((int)_viewModel.CurrentSection);
|
||||
_sectionTabs.TrySelectTab((int)_viewModel.CurrentSection);
|
||||
}
|
||||
|
||||
private void UpdateCategoryTabs()
|
||||
@ -199,10 +192,10 @@ private void UpdateCategoryTabs()
|
||||
switch (_viewModel.CurrentSection)
|
||||
{
|
||||
case SectionButtonType.Menu:
|
||||
_menuCategoryTabs.SelectTab((int)_viewModel.CurrentCategory);
|
||||
_menuCategoryTabs.TrySelectTab((int)_viewModel.CurrentCategory);
|
||||
break;
|
||||
case SectionButtonType.Cookware:
|
||||
_cookwareCategoryTabs.SelectTab((int)_viewModel.CurrentCategory);
|
||||
_cookwareCategoryTabs.TrySelectTab((int)_viewModel.CurrentCategory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -264,7 +257,8 @@ private void HandleCloseRequested()
|
||||
|
||||
private void HandleMenuCategorySelected(InventoryCategoryType category)
|
||||
{
|
||||
_menuCategoryTabs.SelectTab((int)category);
|
||||
if (_menuCategoryTabs.TrySelectTab((int)category)) return;
|
||||
if (_cookwareCategoryTabs.TrySelectTab((int)category)) return;
|
||||
}
|
||||
|
||||
private void OnSectionTabSelected(int sectionValue)
|
||||
|
@ -76,22 +76,6 @@ public void Initialize(Action<int> onTabSelected)
|
||||
InitializeTabs();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 기본 허용 값들을 사용하여 탭을 초기화합니다.
|
||||
/// </summary>
|
||||
public void UseDefaultAllowedValues()
|
||||
{
|
||||
if (TabButtonConfig.TryGetValue(_tabButtonType, out List<int> defaultValues))
|
||||
{
|
||||
// 기본값을 바로 사용하여 탭 초기화
|
||||
InitializeTabsWithValues(defaultValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"TabButtonType {_tabButtonType}에 대한 설정이 정의되지 않았습니다.", this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 지정된 값들로 탭들을 초기화합니다.
|
||||
/// </summary>
|
||||
@ -144,24 +128,23 @@ private void InitializeTabs()
|
||||
/// </summary>
|
||||
private void HandleTabButtonClicked(int tabValue)
|
||||
{
|
||||
SelectTab(tabValue);
|
||||
TrySelectTab(tabValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 지정된 값을 가진 탭을 선택합니다.
|
||||
/// </summary>
|
||||
public void SelectTab(int tabValue)
|
||||
public bool TrySelectTab(int tabValue)
|
||||
{
|
||||
if (_tabLookup == null || _tabLookup.Count == 0)
|
||||
{
|
||||
Debug.LogWarning("탭 룩업이 초기화되지 않았습니다.", this);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_tabLookup.ContainsKey(tabValue))
|
||||
if (_tabLookup.ContainsKey(tabValue) == false)
|
||||
{
|
||||
Debug.LogWarning($"탭 값 {tabValue}에 해당하는 탭을 찾을 수 없습니다.", this);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
CurrentTabValue = tabValue;
|
||||
@ -174,6 +157,7 @@ public void SelectTab(int tabValue)
|
||||
|
||||
// 이벤트 호출
|
||||
OnTabSelected?.Invoke(tabValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -185,7 +169,7 @@ public void SelectFirstTab()
|
||||
if (_tabButtons[0] != null)
|
||||
{
|
||||
var firstTabValue = _tabButtons[0].TabValue;
|
||||
SelectTab(firstTabValue);
|
||||
TrySelectTab(firstTabValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +207,7 @@ public void Move(int direction)
|
||||
// 상호작용 가능한 탭을 찾았으면 이동
|
||||
if (IsTabInteractable(tabValues[newIndex]))
|
||||
{
|
||||
SelectTab(tabValues[newIndex]);
|
||||
TrySelectTab(tabValues[newIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user