New Heron and GLucose jars, bring bass box back
[SugarCubes.git] / _Overlay.pde
index f1bc1d4a8a9df06038cb7a924772c98d38fa7373..b59cd5da1f455cb96149a84d921aa9d73e59f097 100644 (file)
@@ -771,14 +771,21 @@ class DebugUI {
   final int debugXSpacing = 28;
   final int debugYSpacing = 21;
   final int[][] debugState;
+  final int[] indexState;
+    
+  final int CUBE_STATE_UNUSED = 0;
+  final int CUBE_STATE_USED = 1;
+  final int CUBE_STATE_DUPLICATED = 2;
   
   final int DEBUG_STATE_ANIM = 0;
   final int DEBUG_STATE_WHITE = 1;
   final int DEBUG_STATE_OFF = 2;
+  final int DEBUG_STATE_UNUSED = 3;  
   
   DebugUI(PandaMapping[] pandaMappings) {
     int totalChannels = pandaMappings.length * PandaMapping.CHANNELS_PER_BOARD;
     debugState = new int[totalChannels+1][ChannelMapping.CUBES_PER_CHANNEL+1];
+    indexState = new int[glucose.model.cubes.size()+1];
     
     channelList = new ChannelMapping[totalChannels];
     int channelIndex = 0;
@@ -792,9 +799,19 @@ class DebugUI {
         debugState[i][j] = DEBUG_STATE_ANIM;
       }
     }
+    
+    for (int rawIndex = 0; rawIndex < glucose.model.cubes.size()+1; ++rawIndex) {
+      indexState[rawIndex] = CUBE_STATE_UNUSED;
+    }
+    for (ChannelMapping channel : channelList) {
+      for (int rawCubeIndex : channel.objectIndices) {
+        if (rawCubeIndex > 0)
+          ++indexState[rawCubeIndex];
+      }
+    }
   }
   
-  void draw() {    
+  void draw() {
     noStroke();
     int xBase = debugX;
     int yPos = debugY;
@@ -822,7 +839,7 @@ class DebugUI {
               stroke(#999999);          
               line(xPos - 12, yPos + 8, xPos, yPos + 8);
             }
-            drawNumBox(xPos, yPos, rawCubeIndex, debugState[channelNum][stateIndex+1]);
+            drawNumBox(xPos, yPos, rawCubeIndex, debugState[channelNum][stateIndex+1], indexState[rawCubeIndex]);
             ++stateIndex;
             xPos += debugXSpacing;            
           }
@@ -846,13 +863,40 @@ class DebugUI {
       ++channelNum;
     }
     drawNumBox(xBase, yPos, "A", debugState[channelNum][0]);
+    yPos += debugYSpacing * 2;
+   
+    noFill();
+    fill(#CCCCCC);
+    text("Unused Cubes",  xBase, yPos + 12);
+    yPos += debugYSpacing;
+    
+    int xIndex = 0;
+    for (int rawIndex = 1; rawIndex <= glucose.model.cubes.size(); ++rawIndex) {
+      if (indexState[rawIndex] == CUBE_STATE_UNUSED) {
+        drawNumBox(xBase + (xIndex * debugXSpacing), yPos, rawIndex, DEBUG_STATE_UNUSED);
+        ++xIndex;
+        if (xIndex > 4) {
+          xIndex = 0;
+          yPos += debugYSpacing + 2;
+        }
+      }
+    }
   }
+
   
   void drawNumBox(int xPos, int yPos, int label, int state) {
     drawNumBox(xPos, yPos, "" + label, state);
   }
   
   void drawNumBox(int xPos, int yPos, String label, int state) {
+    drawNumBox(xPos, yPos, "" + label, state, CUBE_STATE_USED);
+  }
+
+  void drawNumBox(int xPos, int yPos, int label, int state, int cubeState) {
+    drawNumBox(xPos, yPos, "" + label, state, cubeState);
+  }
+  
+  void drawNumBox(int xPos, int yPos, String label, int state, int cubeState) {
     noFill();
     color textColor = #cccccc;
     switch (state) {
@@ -864,24 +908,29 @@ class DebugUI {
         rect(xPos, yPos+8, 16, 8);
         noFill();
         stroke(textColor);
-        rect(xPos, yPos, 16, 16); 
         break;
       case DEBUG_STATE_WHITE:
         stroke(textColor);
         fill(#e9e9e9);
-        rect(xPos, yPos, 16, 16);
         textColor = #333333;
         break;
       case DEBUG_STATE_OFF:
         stroke(textColor);
-        rect(xPos, yPos, 16, 16);
+        break;
+      case DEBUG_STATE_UNUSED:
+        stroke(textColor);
+        fill(#880000);
         break;
     }
     
+    if (cubeState >= CUBE_STATE_DUPLICATED) {
+      stroke(textColor = #FF0000);
+    }
+
+    rect(xPos, yPos, 16, 16);     
     noStroke();
     fill(textColor);
     text(label, xPos + 2, yPos + 12);
-  
   }
   
   void maskColors(color[] colors) {