Skip to content

Commit 9a37086

Browse files
mcarlsonSimHacker
andauthored
now supports multiple simulators, controller navigation tab has simulator menu, qr code urls set simulator to correspond with each simulator, user can switch controller's simulator with menu, menu updates when new simulators attach and leave. (#53) (#55)
Co-authored-by: Don Hopkins <[email protected]>
1 parent 55a8383 commit 9a37086

27 files changed

+931
-480
lines changed

Unity/SpaceCraft/Assets/Resources/Prefabs/GroundPlane.prefab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ MeshRenderer:
4949
m_PrefabInstance: {fileID: 0}
5050
m_PrefabAsset: {fileID: 0}
5151
m_GameObject: {fileID: 1019336410923223640}
52-
m_Enabled: 0
53-
m_CastShadows: 1
52+
m_Enabled: 1
53+
m_CastShadows: 0
5454
m_ReceiveShadows: 1
5555
m_DynamicOccludee: 1
5656
m_StaticShadowCaster: 0

Unity/SpaceCraft/Assets/Scripts/Core/Brewster.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void LoadContentFromJson(JObject content)
9696
return;
9797
}
9898

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

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

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

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

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

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

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

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

@@ -256,7 +256,7 @@ public void LoadContentFromJson(JObject content)
256256
}
257257

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

261261
// Fire the event to notify all listeners
262262
OnAllContentLoaded?.Invoke();

Unity/SpaceCraft/Assets/Scripts/Core/SpaceCraft.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public List<string> SelectedItemIds
7474
HashSet<string> newSet = new HashSet<string>(value ?? new List<string>()); // Handle null input
7575
if (!currentSet.SetEquals(newSet))
7676
{
77-
Debug.Log($"[SpaceCraft] Setter: Updating SelectedItemIds (Count: {newSet.Count})");
77+
// Debug.Log($"[SpaceCraft] Setter: Updating SelectedItemIds (Count: {newSet.Count})");
7878
_selectedItemIds = new List<string>(newSet); // Store a copy defensively
7979
selectedItemsChanged = true; // Set flag because state list changed
80-
Debug.Log($"[SpaceCraft] Setter: SelectedItemIds updated to {string.Join(", ", _selectedItemIds)}");
80+
// Debug.Log($"[SpaceCraft] Setter: SelectedItemIds updated to {string.Join(", ", _selectedItemIds)}");
8181
UpdateSelectionVisuals();
8282
}
8383
}
@@ -95,10 +95,10 @@ public List<string> HighlightedItemIds
9595
var newValue = value ?? new List<string>();
9696
if (!AreEquivalentHighlightLists(_highlightedItemIds, newValue))
9797
{
98-
Debug.Log($"[SpaceCraft] Setter: Updating HighlightedItemIds (Count: {newValue.Count})");
98+
// Debug.Log($"[SpaceCraft] Setter: Updating HighlightedItemIds (Count: {newValue.Count})");
9999
_highlightedItemIds = new List<string>(newValue); // Store a copy
100100
highlightedItemsChanged = true; // Set flag because state list changed
101-
Debug.Log($"[SpaceCraft] Setter: HighlightedItemIds updated to {string.Join(", ", _highlightedItemIds)}");
101+
// Debug.Log($"[SpaceCraft] Setter: HighlightedItemIds updated to {string.Join(", ", _highlightedItemIds)}");
102102
UpdateHighlightVisuals();
103103
}
104104
}
@@ -340,18 +340,18 @@ private void FixedUpdate()
340340
string firstItemId = collectionsView.GetFirstDisplayedItemId();
341341
if (!string.IsNullOrEmpty(firstItemId))
342342
{
343-
Debug.Log($"[SpaceCraft] Automatically selecting first item: {firstItemId}");
343+
// Debug.Log($"[SpaceCraft] Automatically selecting first item: {firstItemId}");
344344
if (SelectedItemIds.Count > 0)
345345
{
346346
SelectedItemIds.Clear();
347347
selectedItemsChanged = true;
348-
Debug.Log($"[SpaceCraft] Setter: SelectedItemIds cleared to {string.Join(", ", SelectedItemIds)}");
348+
// Debug.Log($"[SpaceCraft] Setter: SelectedItemIds cleared to {string.Join(", ", SelectedItemIds)}");
349349
}
350350
SelectItem("auto_select", "System", firstItemId);
351351
}
352352
else
353353
{
354-
Debug.Log("[SpaceCraft] No first item found to select automatically.");
354+
// Debug.Log("[SpaceCraft] No first item found to select automatically.");
355355
}
356356
}
357357

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

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

466466
// Create a new list without the item
467467
List<string> newList = new List<string>(_selectedItemIds);
@@ -489,7 +489,7 @@ public void DeselectItem(string clientId, string clientName, string itemId)
489489
/// </summary>
490490
public void DeselectAllItems()
491491
{
492-
Debug.Log("[SpaceCraft] DeselectAllItems API called");
492+
// Debug.Log("[SpaceCraft] DeselectAllItems API called");
493493
if (_selectedItemIds.Count > 0)
494494
{
495495
// Assign an empty list to the property
@@ -548,17 +548,17 @@ public void ToggleCurrentItemSelection(string clientId, string clientName, strin
548548
public void ToggleItemSelection(string clientId, string clientName, string screenId, string itemId)
549549
{
550550
if (string.IsNullOrEmpty(itemId)) return;
551-
Debug.Log($"[SpaceCraft] ToggleItemSelection API called by clientId: {clientId}, clientName: {clientName}, screenId: {screenId}, itemId: {itemId}");
551+
// Debug.Log($"[SpaceCraft] ToggleItemSelection API called by clientId: {clientId}, clientName: {clientName}, screenId: {screenId}, itemId: {itemId}");
552552

553553
List<string> newList = new List<string>(_selectedItemIds);
554554
if (newList.Contains(itemId))
555555
{ // Item is selected, so deselect it
556-
Debug.Log($"[SpaceCraft] Toggle: Deselecting {itemId}");
556+
// Debug.Log($"[SpaceCraft] Toggle: Deselecting {itemId}");
557557
newList.Remove(itemId);
558558
}
559559
else
560560
{ // Item is not selected, so select it
561-
Debug.Log($"[SpaceCraft] Toggle: Selecting {itemId}");
561+
// Debug.Log($"[SpaceCraft] Toggle: Selecting {itemId}");
562562
if (!multiSelectEnabled)
563563
{
564564
// Single select mode: clear list before adding
@@ -591,7 +591,7 @@ public void SetSelectedItems(string clientId, string clientName, List<string> it
591591
{
592592
List<string> newList = itemIds ?? new List<string>();
593593
// Log client info
594-
Debug.Log($"[SpaceCraft] SetSelectedItems API called by {clientName}({clientId}) with {newList.Count} items.");
594+
// Debug.Log($"[SpaceCraft] SetSelectedItems API called by {clientName}({clientId}) with {newList.Count} items.");
595595

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

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

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

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

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

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

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

978978
return itemView;
@@ -997,7 +997,7 @@ public void UpdateSelectionVisuals()
997997
{
998998
if (inputManager == null) return;
999999

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

10031003
foreach (ItemView view in allItemViews)
@@ -1051,7 +1051,7 @@ public void UpdateHighlightVisuals()
10511051
{
10521052
if (inputManager == null) return;
10531053

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

10571057
// Calculate counts first
@@ -1082,15 +1082,15 @@ private void SendEvents()
10821082
// Send events only when changes have occurred - reduce bridge traffic
10831083
if (selectedItemsChanged)
10841084
{
1085-
Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
1085+
// Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
10861086
SendEventName("SelectedItemsChanged");
10871087
selectedItemsChanged = false; // Reset flag here
1088-
Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
1088+
// Debug.Log("SpaceCraft: SelectedItemsChanged: selectedItemIds: " + string.Join(",", SelectedItemIds));
10891089
}
10901090

10911091
if (highlightedItemsChanged)
10921092
{
1093-
Debug.Log("SpaceCraft: HighlightedItemsChanged: highlightedItemIds: " + string.Join(",", HighlightedItemIds));
1093+
// Debug.Log("SpaceCraft: HighlightedItemsChanged: highlightedItemIds: " + string.Join(",", HighlightedItemIds));
10941094
SendEventName("HighlightedItemsChanged");
10951095
highlightedItemsChanged = false; // Reset flag here
10961096
}
@@ -1129,17 +1129,17 @@ public void OnItemHighlightEnd(ItemView item)
11291129
public void ToggleItemHighlight(string controllerId, string controllerName, string screenId, string itemId)
11301130
{
11311131
if (string.IsNullOrEmpty(itemId)) return;
1132-
Debug.Log($"[SpaceCraft] ToggleItemHighlight API called by controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, itemId: {itemId}");
1132+
// Debug.Log($"[SpaceCraft] ToggleItemHighlight API called by controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, itemId: {itemId}");
11331133

11341134
List<string> newList = new List<string>(HighlightedItemIds);
11351135
if (newList.Contains(itemId))
11361136
{ // Item is highlighted, so unhighlight it
1137-
Debug.Log($"[SpaceCraft] Toggle: Unhighlighting {itemId}");
1137+
// Debug.Log($"[SpaceCraft] Toggle: Unhighlighting {itemId}");
11381138
newList.Remove(itemId);
11391139
}
11401140
else
11411141
{ // Item is not highlighted, so highlight it
1142-
Debug.Log($"[SpaceCraft] Toggle: Highlighting {itemId}");
1142+
// Debug.Log($"[SpaceCraft] Toggle: Highlighting {itemId}");
11431143
newList.Add(itemId);
11441144
}
11451145
// Assign the potentially modified list back to the property
@@ -1152,7 +1152,7 @@ public void ToggleItemHighlight(string controllerId, string controllerName, stri
11521152
public void MoveSelection(string controllerId, string controllerName, string screenId, string direction, float dx = 0f, float dy = 0f)
11531153
{
11541154
// Expects "north", "south", "east", "west" from controller
1155-
Debug.Log($"[SpaceCraft] MoveSelection called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}, dx: {dx}, dy: {dy}");
1155+
// Debug.Log($"[SpaceCraft] MoveSelection called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}, dx: {dx}, dy: {dy}");
11561156
// Pass direction and mouse deltas to CollectionsView
11571157
collectionsView?.MoveSelection(controllerId, controllerName, direction, dx, dy);
11581158
// Note: CollectionsView will call SelectItem which will sync the highlight
@@ -1164,7 +1164,7 @@ public void MoveSelection(string controllerId, string controllerName, string scr
11641164
public void MoveHighlight(string controllerId, string controllerName, string screenId, string direction)
11651165
{
11661166
// Expects "north", "south", "east", "west" from controller
1167-
Debug.Log($"[SpaceCraft] MoveHighlight called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}");
1167+
// Debug.Log($"[SpaceCraft] MoveHighlight called with controllerId: {controllerId}, controllerName: {controllerName}, screenId: {screenId}, direction: {direction}");
11681168
// Pass direction directly to CollectionsView
11691169
collectionsView?.MoveHighlight(controllerId, controllerName, direction);
11701170
}

0 commit comments

Comments
 (0)