Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Unity/SpaceCraft/Assets/Resources/Prefabs/GroundPlane.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1019336410923223640}
m_Enabled: 0
m_CastShadows: 1
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
Expand Down
14 changes: 7 additions & 7 deletions Unity/SpaceCraft/Assets/Scripts/Core/Brewster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void LoadContentFromJson(JObject content)
return;
}

Debug.Log("Brewster: Starting to load content from JSON");
// Debug.Log("Brewster: Starting to load content from JSON");
//Debug.Log($"Brewster: Content JSON structure: {content}");

// Clear existing content first
Expand Down Expand Up @@ -144,24 +144,24 @@ public void LoadContentFromJson(JObject content)
Collection collection = ScriptableObject.CreateInstance<Collection>();

// Debug the JSON before import
Debug.Log($"Brewster: About to import collection '{collectionId}' from JSON: {collectionJson}");
// Debug.Log($"Brewster: About to import collection '{collectionId}' from JSON: {collectionJson}");

// Import from the nested collection object
collection.ImportFromJToken(collectionJson);

// Debug the collection after import
Debug.Log($"Brewster: After import - collection ID='{collection.Id}', Title='{collection.Title}'");
// Debug.Log($"Brewster: After import - collection ID='{collection.Id}', Title='{collection.Title}'");

// Collection should already have ID from ImportFromJToken,
// but if not, use the collection ID from the JSON key
if (string.IsNullOrEmpty(collection.Id))
{
Debug.Log($"Brewster: Setting explicit ID for collection '{collectionId}' as it was not found in metadata");
// Debug.Log($"Brewster: Setting explicit ID for collection '{collectionId}' as it was not found in metadata");
collection.Id = collectionId;
}

_collections[collectionId] = collection;
Debug.Log($"Brewster: Successfully added collection '{collectionId}' with ID '{collection.Id}'");
// Debug.Log($"Brewster: Successfully added collection '{collectionId}' with ID '{collection.Id}'");

// Check for itemsIndex in the collection
JArray itemsIndex = collectionDir["itemsIndex"] as JArray;
Expand Down Expand Up @@ -238,7 +238,7 @@ public void LoadContentFromJson(JObject content)
// If no ID from JSON, use the key as ID
if (string.IsNullOrEmpty(item.Id))
{
Debug.Log($"Brewster: Setting explicit ID for item '{itemId}' as it was not found in metadata");
// Debug.Log($"Brewster: Setting explicit ID for item '{itemId}' as it was not found in metadata");
item.Id = itemId;
}

Expand All @@ -256,7 +256,7 @@ public void LoadContentFromJson(JObject content)
}

// Notify that content is loaded
Debug.Log($"Brewster: Content loading complete. Loaded {_collections.Count} collections and {_items.Count} items from provided JSON.");
// Debug.Log($"Brewster: Content loading complete. Loaded {_collections.Count} collections and {_items.Count} items from provided JSON.");

// Fire the event to notify all listeners
OnAllContentLoaded?.Invoke();
Expand Down
62 changes: 31 additions & 31 deletions Unity/SpaceCraft/Assets/Scripts/Core/SpaceCraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public List<string> SelectedItemIds
HashSet<string> newSet = new HashSet<string>(value ?? new List<string>()); // Handle null input
if (!currentSet.SetEquals(newSet))
{
Debug.Log($"[SpaceCraft] Setter: Updating SelectedItemIds (Count: {newSet.Count})");
// Debug.Log($"[SpaceCraft] Setter: Updating SelectedItemIds (Count: {newSet.Count})");
_selectedItemIds = new List<string>(newSet); // Store a copy defensively
selectedItemsChanged = true; // Set flag because state list changed
Debug.Log($"[SpaceCraft] Setter: SelectedItemIds updated to {string.Join(", ", _selectedItemIds)}");
// Debug.Log($"[SpaceCraft] Setter: SelectedItemIds updated to {string.Join(", ", _selectedItemIds)}");
UpdateSelectionVisuals();
}
}
Expand All @@ -95,10 +95,10 @@ public List<string> HighlightedItemIds
var newValue = value ?? new List<string>();
if (!AreEquivalentHighlightLists(_highlightedItemIds, newValue))
{
Debug.Log($"[SpaceCraft] Setter: Updating HighlightedItemIds (Count: {newValue.Count})");
// Debug.Log($"[SpaceCraft] Setter: Updating HighlightedItemIds (Count: {newValue.Count})");
_highlightedItemIds = new List<string>(newValue); // Store a copy
highlightedItemsChanged = true; // Set flag because state list changed
Debug.Log($"[SpaceCraft] Setter: HighlightedItemIds updated to {string.Join(", ", _highlightedItemIds)}");
// Debug.Log($"[SpaceCraft] Setter: HighlightedItemIds updated to {string.Join(", ", _highlightedItemIds)}");
UpdateHighlightVisuals();
}
}
Expand Down Expand Up @@ -340,18 +340,18 @@ private void FixedUpdate()
string firstItemId = collectionsView.GetFirstDisplayedItemId();
if (!string.IsNullOrEmpty(firstItemId))
{
Debug.Log($"[SpaceCraft] Automatically selecting first item: {firstItemId}");
// Debug.Log($"[SpaceCraft] Automatically selecting first item: {firstItemId}");
if (SelectedItemIds.Count > 0)
{
SelectedItemIds.Clear();
selectedItemsChanged = true;
Debug.Log($"[SpaceCraft] Setter: SelectedItemIds cleared to {string.Join(", ", SelectedItemIds)}");
// Debug.Log($"[SpaceCraft] Setter: SelectedItemIds cleared to {string.Join(", ", SelectedItemIds)}");
}
SelectItem("auto_select", "System", firstItemId);
}
else
{
Debug.Log("[SpaceCraft] No first item found to select automatically.");
// Debug.Log("[SpaceCraft] No first item found to select automatically.");
}
}

Expand Down Expand Up @@ -429,7 +429,7 @@ public void SelectItem(string clientId, string clientName, string itemId)
{
if (string.IsNullOrEmpty(itemId)) return;
// Log client info
Debug.Log($"[SpaceCraft] SelectItem API called by {clientName}({clientId}): {itemId}");
// Debug.Log($"[SpaceCraft] SelectItem API called by {clientName}({clientId}): {itemId}");

List<string> newList;
// Handle single selection mode
Expand Down Expand Up @@ -461,7 +461,7 @@ public void DeselectItem(string clientId, string clientName, string itemId)
{
if (string.IsNullOrEmpty(itemId) || !_selectedItemIds.Contains(itemId)) return;
// Log client info
Debug.Log($"[SpaceCraft] DeselectItem API called by {clientName}({clientId}): {itemId}");
// Debug.Log($"[SpaceCraft] DeselectItem API called by {clientName}({clientId}): {itemId}");

// Create a new list without the item
List<string> newList = new List<string>(_selectedItemIds);
Expand Down Expand Up @@ -489,7 +489,7 @@ public void DeselectItem(string clientId, string clientName, string itemId)
/// </summary>
public void DeselectAllItems()
{
Debug.Log("[SpaceCraft] DeselectAllItems API called");
// Debug.Log("[SpaceCraft] DeselectAllItems API called");
if (_selectedItemIds.Count > 0)
{
// Assign an empty list to the property
Expand Down Expand Up @@ -548,17 +548,17 @@ public void ToggleCurrentItemSelection(string clientId, string clientName, strin
public void ToggleItemSelection(string clientId, string clientName, string screenId, string itemId)
{
if (string.IsNullOrEmpty(itemId)) return;
Debug.Log($"[SpaceCraft] ToggleItemSelection API called by clientId: {clientId}, clientName: {clientName}, screenId: {screenId}, itemId: {itemId}");
// Debug.Log($"[SpaceCraft] ToggleItemSelection API called by clientId: {clientId}, clientName: {clientName}, screenId: {screenId}, itemId: {itemId}");

List<string> newList = new List<string>(_selectedItemIds);
if (newList.Contains(itemId))
{ // Item is selected, so deselect it
Debug.Log($"[SpaceCraft] Toggle: Deselecting {itemId}");
// Debug.Log($"[SpaceCraft] Toggle: Deselecting {itemId}");
newList.Remove(itemId);
}
else
{ // Item is not selected, so select it
Debug.Log($"[SpaceCraft] Toggle: Selecting {itemId}");
// Debug.Log($"[SpaceCraft] Toggle: Selecting {itemId}");
if (!multiSelectEnabled)
{
// Single select mode: clear list before adding
Expand Down Expand Up @@ -591,7 +591,7 @@ public void SetSelectedItems(string clientId, string clientName, List<string> it
{
List<string> newList = itemIds ?? new List<string>();
// Log client info
Debug.Log($"[SpaceCraft] SetSelectedItems API called by {clientName}({clientId}) with {newList.Count} items.");
// Debug.Log($"[SpaceCraft] SetSelectedItems API called by {clientName}({clientId}) with {newList.Count} items.");

// Enforce single selection mode if active
if (!multiSelectEnabled && newList.Count > 1)
Expand Down Expand Up @@ -621,7 +621,7 @@ public void AddSelectedItems(string clientId, string clientName, List<string> it
{
if (itemIds == null || itemIds.Count == 0) return;
// Log client info
Debug.Log($"[SpaceCraft] AddSelectedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");
// Debug.Log($"[SpaceCraft] AddSelectedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");

// Handle single select mode separately
if (!multiSelectEnabled)
Expand Down Expand Up @@ -662,7 +662,7 @@ public void RemoveSelectedItems(string clientId, string clientName, List<string>
{
if (itemIds == null || itemIds.Count == 0 || _selectedItemIds.Count == 0) return;
// Log client info
Debug.Log($"[SpaceCraft] RemoveSelectedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");
// Debug.Log($"[SpaceCraft] RemoveSelectedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");

List<string> newList = new List<string>(_selectedItemIds);
bool changed = false;
Expand Down Expand Up @@ -696,7 +696,7 @@ public void RemoveSelectedItems(string clientId, string clientName, List<string>
public void SetMultiSelectMode(bool enable)
{
if (inputManager == null) return;
Debug.Log($"[SpaceCraft] SetMultiSelectMode called: {enable}");
// Debug.Log($"[SpaceCraft] SetMultiSelectMode called: {enable}");

if (multiSelectEnabled != enable)
{
Expand Down Expand Up @@ -737,7 +737,7 @@ public int GetHighlightCount(string itemId)
/// </summary>
public void SetHighlightedItems(string clientId, string clientName, List<string> itemIds)
{
Debug.Log($"[SpaceCraft] SetHighlightedItems API called by {clientName}({clientId}) with {itemIds?.Count ?? 0} items.");
// Debug.Log($"[SpaceCraft] SetHighlightedItems API called by {clientName}({clientId}) with {itemIds?.Count ?? 0} items.");

// Assign the new list to the property to trigger updates if different
HighlightedItemIds = itemIds ?? new List<string>();
Expand All @@ -749,7 +749,7 @@ public void SetHighlightedItems(string clientId, string clientName, List<string>
public void AddHighlightedItems(string clientId, string clientName, List<string> itemIds)
{
if (itemIds == null || itemIds.Count == 0) return;
Debug.Log($"[SpaceCraft] AddHighlightedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");
// Debug.Log($"[SpaceCraft] AddHighlightedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");

// Create new list, add items, and assign back to property
List<string> newList = new List<string>(HighlightedItemIds);
Expand All @@ -763,7 +763,7 @@ public void AddHighlightedItems(string clientId, string clientName, List<string>
public void RemoveHighlightedItems(string clientId, string clientName, List<string> itemIds)
{
if (itemIds == null || itemIds.Count == 0 || HighlightedItemIds.Count == 0) return;
Debug.Log($"[SpaceCraft] RemoveHighlightedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");
// Debug.Log($"[SpaceCraft] RemoveHighlightedItems API called by {clientName}({clientId}) with {itemIds.Count} items.");

// Create new list and remove one instance of each specified item
List<string> newList = new List<string>(HighlightedItemIds);
Expand Down Expand Up @@ -972,7 +972,7 @@ private ItemView FindItemSafe(string itemId)
ItemView itemView = FindItemViewById(itemId); // Call local method
if (itemView == null)
{
Debug.LogWarning($"[SpaceCraft] FindItemSafe: Item with ID '{itemId}' not found via CollectionsView.");
// Debug.LogWarning($"[SpaceCraft] FindItemSafe: Item with ID '{itemId}' not found via CollectionsView.");
}

return itemView;
Expand All @@ -997,7 +997,7 @@ public void UpdateSelectionVisuals()
{
if (inputManager == null) return;

Debug.Log($"[SpaceCraft] Updating selection visuals for {SelectedItemIds.Count} selected items.");
// Debug.Log($"[SpaceCraft] Updating selection visuals for {SelectedItemIds.Count} selected items.");
List<ItemView> allItemViews = inputManager.GetAllItemViews();

foreach (ItemView view in allItemViews)
Expand Down Expand Up @@ -1051,7 +1051,7 @@ public void UpdateHighlightVisuals()
{
if (inputManager == null) return;

Debug.Log($"[SpaceCraft] Updating highlight visuals for {HighlightedItemIds.Count} total highlights.");
// Debug.Log($"[SpaceCraft] Updating highlight visuals for {HighlightedItemIds.Count} total highlights.");
List<ItemView> allItemViews = inputManager.GetAllItemViews();

// Calculate counts first
Expand Down Expand Up @@ -1082,15 +1082,15 @@ private void SendEvents()
// Send events only when changes have occurred - reduce bridge traffic
if (selectedItemsChanged)
{
Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
// Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
SendEventName("SelectedItemsChanged");
selectedItemsChanged = false; // Reset flag here
Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
// Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
}

if (highlightedItemsChanged)
{
Debug.Log("SpaceCraft: HighlightedItemsChanged: highlightedItemIds: " + string.Join(",", HighlightedItemIds));
// Debug.Log("SpaceCraft: HighlightedItemsChanged: highlightedItemIds: " + string.Join(",", HighlightedItemIds));
SendEventName("HighlightedItemsChanged");
highlightedItemsChanged = false; // Reset flag here
}
Expand Down Expand Up @@ -1129,17 +1129,17 @@ public void OnItemHighlightEnd(ItemView item)
public void ToggleItemHighlight(string controllerId, string controllerName, string screenId, string itemId)
{
if (string.IsNullOrEmpty(itemId)) return;
Debug.Log($"[SpaceCraft] ToggleItemHighlight API called by controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, itemId: {itemId}");
// Debug.Log($"[SpaceCraft] ToggleItemHighlight API called by controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, itemId: {itemId}");

List<string> newList = new List<string>(HighlightedItemIds);
if (newList.Contains(itemId))
{ // Item is highlighted, so unhighlight it
Debug.Log($"[SpaceCraft] Toggle: Unhighlighting {itemId}");
// Debug.Log($"[SpaceCraft] Toggle: Unhighlighting {itemId}");
newList.Remove(itemId);
}
else
{ // Item is not highlighted, so highlight it
Debug.Log($"[SpaceCraft] Toggle: Highlighting {itemId}");
// Debug.Log($"[SpaceCraft] Toggle: Highlighting {itemId}");
newList.Add(itemId);
}
// Assign the potentially modified list back to the property
Expand All @@ -1152,7 +1152,7 @@ public void ToggleItemHighlight(string controllerId, string controllerName, stri
public void MoveSelection(string controllerId, string controllerName, string screenId, string direction, float dx = 0f, float dy = 0f)
{
// Expects "north", "south", "east", "west" from controller
Debug.Log($"[SpaceCraft] MoveSelection called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}, dx: {dx}, dy: {dy}");
// Debug.Log($"[SpaceCraft] MoveSelection called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}, dx: {dx}, dy: {dy}");
// Pass direction and mouse deltas to CollectionsView
collectionsView?.MoveSelection(controllerId, controllerName, direction, dx, dy);
// Note: CollectionsView will call SelectItem which will sync the highlight
Expand All @@ -1164,7 +1164,7 @@ public void MoveSelection(string controllerId, string controllerName, string scr
public void MoveHighlight(string controllerId, string controllerName, string screenId, string direction)
{
// Expects "north", "south", "east", "west" from controller
Debug.Log($"[SpaceCraft] MoveHighlight called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}");
// Debug.Log($"[SpaceCraft] MoveHighlight called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}");
// Pass direction directly to CollectionsView
collectionsView?.MoveHighlight(controllerId, controllerName, direction);
}
Expand Down
Loading