Fix bug with mapping tool and library bugfixes
[SugarCubes.git] / TestPatterns.pde
index bdaa78ac563b916aacd84974cb4a79c2c4d973c3..e47651af4271f4cdf8618190fb2ac8326e142816 100644 (file)
@@ -256,7 +256,7 @@ class MappingTool extends TestPattern {
     if (activeChannel.mode == ChannelMapping.MODE_CUBES) {
       int i = 1;
       for (int index : activeChannel.objectIndices) {
-        if (c == model.getCubeByRawIndex(index)) {
+        if ((index >= 0) && (c == model.getCubeByRawIndex(index))) {
           return i;
         }
         ++i;
@@ -359,10 +359,7 @@ class MappingTool extends TestPattern {
   }
   
   public void decChannel() {
-    --channelIndex;
-    if (channelIndex < 0) {
-      channelIndex += numChannels;
-    }
+    channelIndex = (channelIndex + numChannels - 1) % numChannels;
     setChannel();    
   }
   
@@ -371,10 +368,7 @@ class MappingTool extends TestPattern {
   }
   
   public void decStrip() {
-    --stripIndex;
-    if (stripIndex < 0) {
-      stripIndex += Cube.STRIPS_PER_CUBE;
-    }
+    stripIndex = (stripIndex + Cube.STRIPS_PER_CUBE - 1) % Cube.STRIPS_PER_CUBE;
   }
   
   public void keyPressed() {