2 * DOUBLE BLACK DIAMOND DOUBLE BLACK DIAMOND
5 * ///\\\ ///\\\ ///\\\ ///\\\
6 * \\\/// \\\/// \\\/// \\\///
9 * EXPERTS ONLY!! EXPERTS ONLY!!
11 * Overlay UI that indicates pattern control, etc. This will be moved
12 * into the Processing library once it is stabilized and need not be
18 final ChannelMapping[] channelList;
21 final int debugXSpacing = 28;
22 final int debugYSpacing = 21;
23 final int[][] debugState;
24 final int[] indexState;
26 final int CUBE_STATE_UNUSED = 0;
27 final int CUBE_STATE_USED = 1;
28 final int CUBE_STATE_DUPLICATED = 2;
30 final int DEBUG_STATE_ANIM = 0;
31 final int DEBUG_STATE_WHITE = 1;
32 final int DEBUG_STATE_OFF = 2;
33 final int DEBUG_STATE_UNUSED = 3;
35 DebugUI(PandaMapping[] pandaMappings) {
36 int totalChannels = pandaMappings.length * PandaMapping.CHANNELS_PER_BOARD;
37 debugState = new int[totalChannels+1][ChannelMapping.CUBES_PER_CHANNEL+1];
38 indexState = new int[glucose.model.cubes.size()+1];
40 channelList = new ChannelMapping[totalChannels];
42 for (PandaMapping pm : pandaMappings) {
43 for (ChannelMapping channel : pm.channelList) {
44 channelList[channelIndex++] = channel;
47 for (int i = 0; i < debugState.length; ++i) {
48 for (int j = 0; j < debugState[i].length; ++j) {
49 debugState[i][j] = DEBUG_STATE_ANIM;
53 for (int rawIndex = 0; rawIndex < glucose.model.cubes.size()+1; ++rawIndex) {
54 indexState[rawIndex] = CUBE_STATE_UNUSED;
56 for (ChannelMapping channel : channelList) {
57 for (int rawCubeIndex : channel.objectIndices) {
59 ++indexState[rawCubeIndex];
72 rect(0, 0, debugX + 5*debugXSpacing, height);
75 for (ChannelMapping channel : channelList) {
77 drawNumBox(xPos, yPos, channelNum+1, debugState[channelNum][0]);
78 xPos += debugXSpacing;
80 switch (channel.mode) {
81 case ChannelMapping.MODE_CUBES:
84 for (int rawCubeIndex : channel.objectIndices) {
85 if (rawCubeIndex < 0) {
92 line(xPos - 12, yPos + 8, xPos, yPos + 8);
94 drawNumBox(xPos, yPos, rawCubeIndex, debugState[channelNum][stateIndex+1], indexState[rawCubeIndex]);
96 xPos += debugXSpacing;
99 case ChannelMapping.MODE_BASS:
100 drawNumBox(xPos, yPos, "B", debugState[channelNum][1]);
102 case ChannelMapping.MODE_SPEAKER:
103 drawNumBox(xPos, yPos, "S" + channel.objectIndices[0], debugState[channelNum][1]);
105 case ChannelMapping.MODE_STRUTS_AND_FLOOR:
106 drawNumBox(xPos, yPos, "F", debugState[channelNum][1]);
108 case ChannelMapping.MODE_NULL:
111 throw new RuntimeException("Unhandled channel mapping mode: " + channel.mode);
114 yPos += debugYSpacing;
117 drawNumBox(xBase, yPos, "A", debugState[channelNum][0]);
118 yPos += debugYSpacing * 2;
122 text("Unused Cubes", xBase, yPos + 12);
123 yPos += debugYSpacing;
126 for (int rawIndex = 1; rawIndex <= glucose.model.cubes.size(); ++rawIndex) {
127 if (indexState[rawIndex] == CUBE_STATE_UNUSED) {
128 drawNumBox(xBase + (xIndex * debugXSpacing), yPos, rawIndex, DEBUG_STATE_UNUSED);
132 yPos += debugYSpacing + 2;
139 void drawNumBox(int xPos, int yPos, int label, int state) {
140 drawNumBox(xPos, yPos, "" + label, state);
143 void drawNumBox(int xPos, int yPos, String label, int state) {
144 drawNumBox(xPos, yPos, "" + label, state, CUBE_STATE_USED);
147 void drawNumBox(int xPos, int yPos, int label, int state, int cubeState) {
148 drawNumBox(xPos, yPos, "" + label, state, cubeState);
151 void drawNumBox(int xPos, int yPos, String label, int state, int cubeState) {
153 color textColor = #cccccc;
155 case DEBUG_STATE_ANIM:
158 rect(xPos, yPos, 16, 8);
160 rect(xPos, yPos+8, 16, 8);
164 case DEBUG_STATE_WHITE:
169 case DEBUG_STATE_OFF:
172 case DEBUG_STATE_UNUSED:
178 if (cubeState >= CUBE_STATE_DUPLICATED) {
179 stroke(textColor = #FF0000);
182 rect(xPos, yPos, 16, 16);
185 text(label, xPos + 2, yPos + 12);
188 void maskColors(color[] colors) {
189 color white = #FFFFFF;
191 int channelIndex = 0;
193 for (ChannelMapping channel : channelList) {
194 switch (channel.mode) {
195 case ChannelMapping.MODE_CUBES:
197 for (int rawCubeIndex : channel.objectIndices) {
198 if (rawCubeIndex >= 0) {
199 state = debugState[channelIndex][cubeIndex];
200 if (state != DEBUG_STATE_ANIM) {
201 color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
202 Cube cube = glucose.model.getCubeByRawIndex(rawCubeIndex);
203 for (Point p : cube.points) {
204 colors[p.index] = debugColor;
212 case ChannelMapping.MODE_BASS:
213 state = debugState[channelIndex][1];
214 if (state != DEBUG_STATE_ANIM) {
215 color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
216 for (Strip s : glucose.model.bassBox.boxStrips) {
217 for (Point p : s.points) {
218 colors[p.index] = debugColor;
224 case ChannelMapping.MODE_STRUTS_AND_FLOOR:
225 state = debugState[channelIndex][1];
226 if (state != DEBUG_STATE_ANIM) {
227 color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
228 for (Point p : glucose.model.boothFloor.points) {
229 colors[p.index] = debugColor;
231 for (Strip s : glucose.model.bassBox.struts) {
232 for (Point p : s.points) {
233 colors[p.index] = debugColor;
239 case ChannelMapping.MODE_SPEAKER:
240 state = debugState[channelIndex][1];
241 if (state != DEBUG_STATE_ANIM) {
242 color debugColor = (state == DEBUG_STATE_WHITE) ? white : off;
243 for (Point p : glucose.model.speakers.get(channel.objectIndices[0]).points) {
244 colors[p.index] = debugColor;
249 case ChannelMapping.MODE_NULL:
253 throw new RuntimeException("Unhandled channel mapping mode: " + channel.mode);
259 boolean mousePressed() {
260 int dx = (mouseX - debugX) / debugXSpacing;
261 int dy = (mouseY - debugY) / debugYSpacing;
262 if ((dy < 0) || (dy >= debugState.length)) {
265 if ((dx < 0) || (dx >= debugState[dy].length)) {
268 int newState = debugState[dy][dx] = (debugState[dy][dx] + 1) % 3;
269 if (dy == debugState.length-1) {
270 for (int[] states : debugState) {
271 for (int i = 0; i < states.length; ++i) {
272 states[i] = newState;
275 } else if (dx == 0) {
276 for (int i = 0; i < debugState[dy].length; ++i) {
277 debugState[dy][i] = newState;