bugfix,design

This commit is contained in:
2026-01-20 17:17:16 +09:00
parent 1a896a85fe
commit b8fe7b1d50
43 changed files with 5898 additions and 1157 deletions

View File

@@ -35,6 +35,14 @@ IPointerEnterHandler, IPointerClickHandler
public void SetSelecting(bool on)
{
if (plusIcon != null) plusIcon.SetActive(on);
if (on)
{
background.color = new Color(0, 1f, 0, 0.6f);
}
else
{
background.color = new Color(1, 1, 1, 1);
}
}
public void SetOccupied(bool on)

View File

@@ -14,7 +14,7 @@ public class InitRow : MonoBehaviour
public int EntryId { get; private set; }
public bool IsSelected => toggle != null && toggle.isOn;
public void Bind(int entryId, string typeName, int count, Vector3Int from, Vector3Int to, UnityAction<int> onClickRow)
public void Bind(int entryId,string typeName,int count,Vector3Int from,Vector3Int to,UnityAction<int> onClickRow,UnityAction<bool> onSelectionChanged)
{
EntryId = entryId;
@@ -23,13 +23,20 @@ public class InitRow : MonoBehaviour
if (fromText != null) fromText.text = $"{from.x}, {from.y}, {from.z}";
if (toText != null) toText.text = $"{to.x}, {to.y}, {to.z}";
// Row 클릭 시 선택 처리(원하면 버튼/이벤트로 바꿔도 됩니다)
// Row 클릭 시 선택 처리
var btn = GetComponent<Button>();
if (btn != null)
{
btn.onClick.RemoveAllListeners();
btn.onClick.AddListener(() => onClickRow?.Invoke(entryId));
}
// ✅ 토글 변경 시 Window로 알림
if (toggle != null)
{
toggle.onValueChanged.RemoveAllListeners();
toggle.onValueChanged.AddListener(onSelectionChanged);
}
}
public void SetSelected(bool on)

View File

@@ -5,11 +5,14 @@ using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.Rendering.DebugUI.Table;
public class InitialInventoryWindow : MonoBehaviour
{
[Header("Top/Left")]
[SerializeField] private TMP_Text dimLabel;
[SerializeField] private TMP_Text xLabel;
[SerializeField] private TMP_Text yLabel;
[SerializeField] private TMP_Text zLabel;
[SerializeField] private Transform rackContainer; // ScrollRect Content
[SerializeField] private GridView rackSectionPrefab; // Rack 섹션 프리팹
@@ -18,6 +21,8 @@ public class InitialInventoryWindow : MonoBehaviour
[SerializeField] private TMP_Text countText;
[Header("Table")]
[SerializeField] private Toggle toggleSelectAll;
[SerializeField] private Button btnDeleteSelected;
[SerializeField] private Transform tableContent; // ScrollRect Content
[SerializeField] private InitRow rowPrefab;
@@ -97,15 +102,15 @@ public class InitialInventoryWindow : MonoBehaviour
// ===== Build UI =====
private void BuildDimLabel()
{
if (dimLabel == null || asrs?.asrs_layout == null) return;
var l = asrs.asrs_layout;
float xM = l.x * l.x_length;
float yM = l.z * l.z_length;
float zM = l.y * l.y_length;
dimLabel.text = $"{xM:0.##} m (x) × {yM:0.##} m (y) × {zM:0.##} m (z)";
xLabel.text = $"{xM:0.##} m (x)";
yLabel.text = $"{yM:0.##} m (y)";
zLabel.text = $"{zM:0.##} m (z)";
}
private void BuildPrefabDropdown()
@@ -168,6 +173,17 @@ public class InitialInventoryWindow : MonoBehaviour
RefreshAll();
});
}
if (toggleSelectAll != null)
{
toggleSelectAll.onValueChanged.RemoveAllListeners();
toggleSelectAll.onValueChanged.AddListener(OnToggleSelectAllChanged);
}
if (btnDeleteSelected != null)
{
btnDeleteSelected.onClick.RemoveAllListeners();
btnDeleteSelected.onClick.AddListener(DeleteSelectedRows);
}
}
private void SetCount(int newCount)
@@ -187,6 +203,60 @@ public class InitialInventoryWindow : MonoBehaviour
private string ResolvePrefabDisplayName(string prefabId)
=> PrefabCatalogFromManager.ResolveDisplayName(prefabId);
private void OnToggleSelectAllChanged(bool on)
{
var rows = tableContent.GetComponentsInChildren<InitRow>(true);
foreach (var r in rows)
r.SetSelected(on);
RefreshDeleteSelectedButtonState();
}
private void DeleteSelectedRows()
{
var rows = tableContent.GetComponentsInChildren<InitRow>(true);
var ids = rows.Where(r => r.IsSelected).Select(r => r.EntryId).ToHashSet();
if (ids.Count == 0) return;
// entries에서 id에 해당하는 것들을 삭제
for (int i = entries.Count - 1; i >= 0; i--)
{
if (!ids.Contains(entries[i].id)) continue;
var e = entries[i];
MarkOccupancy(e.id, e.from, e.to, false);
entries.RemoveAt(i);
}
// 선택 상태/토글 상태 정리
selectedEntryId = null;
if (toggleSelectAll != null) toggleSelectAll.isOn = false;
RefreshAll();
}
private void RefreshDeleteSelectedButtonState()
{
if (btnDeleteSelected == null || tableContent == null) return;
var rows = tableContent.GetComponentsInChildren<InitRow>(true);
bool anySelected = rows.Any(r => r.IsSelected);
btnDeleteSelected.interactable = anySelected;
// ✅ 추가: 전체 선택 토글 상태 동기화
if (toggleSelectAll != null)
{
bool allOff = rows.Length > 0 && rows.All(r => !r.IsSelected);
bool allOn = rows.Length > 0 && rows.All(r => r.IsSelected);
if (allOff) toggleSelectAll.SetIsOnWithoutNotify(false);
else if (allOn) toggleSelectAll.SetIsOnWithoutNotify(true);
// 일부만 선택된 경우는 toggleSelectAll 상태를 유지 (원하시면 false로 내리도록 변경 가능)
}
}
// ===== initialize load (기존 데이터 반영) =====
private void LoadInitialize(List<InitializeEntry> initList)
{
@@ -392,6 +462,7 @@ public class InitialInventoryWindow : MonoBehaviour
RefreshOccupiedVisuals();
RefreshTable();
RefreshTableSelection();
RefreshDeleteSelectedButtonState();
}
private void RefreshSelectionVisuals()
@@ -430,7 +501,8 @@ public class InitialInventoryWindow : MonoBehaviour
e.count,
e.from,
e.to,
onClickRow: OnClickRow
onClickRow: OnClickRow,
onSelectionChanged: _ => RefreshDeleteSelectedButtonState()
);
if (selectedEntryId.HasValue && selectedEntryId.Value == e.id)