added red label for duplicate cubes in mapping + list of unused cubes
[SugarCubes.git] / _Overlay.pde
index b07112811f11c2f512518363c1f07a62e1df5de6..2623e8276fb668135acc5a4f039fc0a8cb92e35f 100644 (file)
@@ -75,6 +75,14 @@ abstract class OverlayUI {
     text("Tap 'u' to restore UI", width-4, height-6);
   }
 
+  public void drawDanText() {
+    textFont(itemFont);
+    textAlign(LEFT);
+    fill(#FFFFFF);
+    text(DanTextLine1, 4, height-50);
+    text(DanTextLine2, 4, height-30);
+  }
+
   public void drawFPS() {
     textFont(titleFont);
     textAlign(LEFT);
@@ -630,6 +638,7 @@ class MappingUI extends OverlayUI {
   
   public void draw() {
     drawLogoAndBackground();
+    
     int yPos = 0;
     firstMappingY = yPos + lineHeight + 6;    
     yPos = drawObjectList(yPos, "MAPPING MODE", mappingModes, mappingModes, mappingModeStateMethod);
@@ -762,6 +771,13 @@ class DebugUI {
   final int debugXSpacing = 28;
   final int debugYSpacing = 21;
   final int[][] debugState;
+  final int[] indexState;
+  
+  final int ERROR_STATE_USED = 0;
+  final int ERROR_STATE_DUPLICATED = 1;
+  
+  final int CUBE_STATE_UNUSED = 0;
+  final int CUBE_STATE_USED = 1;
   
   final int DEBUG_STATE_ANIM = 0;
   final int DEBUG_STATE_WHITE = 1;
@@ -770,6 +786,7 @@ class DebugUI {
   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;
@@ -783,6 +800,16 @@ 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() {    
@@ -813,7 +840,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;            
           }
@@ -837,12 +864,41 @@ class DebugUI {
       ++channelNum;
     }
     drawNumBox(xBase, yPos, "A", debugState[channelNum][0]);
+    yPos += debugYSpacing * 2;
+   
+    noFill();
+    stroke(#CCCCCC);
+    rect(xBase, yPos, 100, 16);
+    fill(#CCCCCC);
+    text("Unused Cubes",  xBase + 5, yPos + 12);
+    yPos += debugYSpacing;
+    
+    int x_index = 0;
+    for (int rawIndex = 1; rawIndex < glucose.model.cubes.size()+1; rawIndex++) {
+      if (indexState[rawIndex] == 0) {
+        drawNumBox(xBase + (x_index * debugXSpacing), yPos, rawIndex, 0, 2);
+        x_index++;
+        if (x_index > 4) {
+          x_index = 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, int label, int state, int cube_state) {
+    if (cube_state > 1) {
+      fill(#FF0000);
+      rect(xPos-2, yPos-2, 20, 20);
+    }
+    drawNumBox(xPos, yPos, label, state);
+  }
+  
   void drawNumBox(int xPos, int yPos, String label, int state) {
     noFill();
     color textColor = #cccccc;