Sfoglia il codice sorgente

Fixed frame bugs...

Thomas Buck 12 anni fa
parent
commit
dbfd6d87ef
3 ha cambiato i file con 48 aggiunte e 30 eliminazioni
  1. 4
    1
      Cube Control/cubeWorker.java
  2. 40
    25
      Cube Control/frame.java
  3. 4
    4
      Cube Control/makefile

+ 4
- 1
Cube Control/cubeWorker.java Vedi File

55
   cubeWorker() {
55
   cubeWorker() {
56
   animations.add(new Animation());
56
   animations.add(new Animation());
57
   animations.get(0).setName("Animation 1");
57
   animations.get(0).setName("Animation 1");
58
+  animations.get(0).add(0);
59
+  animations.get(0).get(0).setName("Frame 1");
60
+  framesRemaining--;
58
   }
61
   }
59
 
62
 
60
   cubeWorker(ArrayList<Animation> anims) {
63
   cubeWorker(ArrayList<Animation> anims) {
158
     framesRemaining--;
161
     framesRemaining--;
159
     int s = animations.get(anim).size();
162
     int s = animations.get(anim).size();
160
     animations.get(anim).add(s);
163
     animations.get(anim).add(s);
161
-  animations.get(anim).get(s).setName("Frame " + (2016 - framesRemaining));
164
+  animations.get(anim).get(s).setName("Frame " + animations.get(anim).size());
162
     return s;
165
     return s;
163
     }
166
     }
164
 
167
 

+ 40
- 25
Cube Control/frame.java Vedi File

57
   private JButton frameDown = new JButton();
57
   private JButton frameDown = new JButton();
58
   private JButton frameAdd = new JButton();
58
   private JButton frameAdd = new JButton();
59
   private JButton frameRemove = new JButton();
59
   private JButton frameRemove = new JButton();
60
+  private JButton frameRename = new JButton();
60
   private JButton frame = new JButton();
61
   private JButton frame = new JButton();
61
   private JList animList = new JList();
62
   private JList animList = new JList();
62
   private DefaultListModel animModel = new DefaultListModel();
63
   private DefaultListModel animModel = new DefaultListModel();
91
     }
92
     }
92
   }
93
   }
93
 
94
 
95
+  private String askString(String title, String text) {
96
+	  return JOptionPane.showInputDialog(null, title, text, JOptionPane.QUESTION_MESSAGE);
97
+  }
98
+
94
   private void errorMessage(String s) {
99
   private void errorMessage(String s) {
95
   String[] Optionen = {"OK"};
100
   String[] Optionen = {"OK"};
96
   JOptionPane.showOptionDialog(this, s, "Error!", JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE, null, Optionen, Optionen[0]);
101
   JOptionPane.showOptionDialog(this, s, "Error!", JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE, null, Optionen, Optionen[0]);
97
   }
102
   }
98
 
103
 
99
   public void valueChanged(ListSelectionEvent evt) {
104
   public void valueChanged(ListSelectionEvent evt) {
100
-    if ((!evt.getValueIsAdjusting()) && (evt.getSource() != animList) && (evt.getSource() != frameList)) {
101
-     DefaultListModel model = (DefaultListModel)((JList)evt.getSource()).getModel();
105
+    if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
102
      int anim = animList.getSelectedIndex();
106
      int anim = animList.getSelectedIndex();
103
      int max;
107
      int max;
104
-     if(evt.getSource() == animList){
108
+	 if (anim == -1){
109
+        anim = 0;
110
+     }
111
+     if(evt.getSource() == frameList){
105
        max = worker.numOfAnimations();
112
        max = worker.numOfAnimations();
106
-       System.out.println(max);
107
-
113
+	   animModel.clear();
108
      } else {
114
      } else {
109
-       max = worker.numOfFrames(animList.getSelectedIndex());
110
-
115
+       max = worker.numOfFrames(anim);
116
+	   frameListModel.clear();
111
      }
117
      }
112
 
118
 
113
-     if (anim == -1){
114
-        anim = 0;
115
-     }
116
-     model.clear();
117
-     for (int i = 0; i < max; i++) {
119
+	 // if value changed in anim, rebuild frame, else other way round
120
+	 for (int i = 0; i < max; i++) {
118
        if(evt.getSource() == animList){
121
        if(evt.getSource() == animList){
119
-          model.add(i, worker.getAnimationName(i));
122
+			frameListModel.addElement(worker.getFrameName(anim, i));
123
+			frameList.setModel(frameListModel);
120
        } else {
124
        } else {
121
-         model.add(i, worker.getFrameName(anim, i));
125
+			animModel.addElement(worker.getAnimationName(i));
126
+			animList.setModel(animModel);
122
        }
127
        }
123
-    }
124
-    frameList.setModel(model);
128
+	 }
125
     }
129
     }
126
   }
130
   }
127
 
131
 
272
       }
276
       }
273
     });
277
     });
274
 
278
 
275
-    frameDown.setBounds(544, 152, 107, 33);
279
+    frameDown.setBounds(544, 122, 107, 33);
276
     frameDown.setText("Move down");
280
     frameDown.setText("Move down");
277
     frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
281
     frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
278
     cp.add(frameDown);
282
     cp.add(frameDown);
282
       }
286
       }
283
     });
287
     });
284
 
288
 
285
-    frameAdd.setBounds(544, 56, 107, 33);
289
+	frameRename.setBounds(544, 160, 107, 33);
290
+	frameRename.setText("Rename");
291
+	frameRename.setFont(new Font("Dialog", Font.PLAIN, 13));
292
+	cp.add(frameRename);
293
+	frameRename.addActionListener(new ActionListener() {
294
+		public void actionPerformed(ActionEvent evt) {
295
+			worker.setFrameName(askString("Rename", "Rename " + frameList.getSelectedValue()), animList.getSelectedIndex(), frameList.getSelectedIndex());
296
+			frameListModel.set(frameList.getSelectedIndex(), worker.getFrameName(animList.getSelectedIndex(), frameList.getSelectedIndex()));
297
+			frameList.setModel(frameListModel);
298
+		}
299
+	});
300
+
301
+    frameAdd.setBounds(544, 46, 107, 33);
286
     frameAdd.setText("Add");
302
     frameAdd.setText("Add");
287
     frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
303
     frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
288
     cp.add(frameAdd);
304
     cp.add(frameAdd);
292
       }
308
       }
293
     });
309
     });
294
 
310
 
295
-    frameRemove.setBounds(544, 104, 107, 33);
311
+    frameRemove.setBounds(544, 84, 107, 33);
296
     frameRemove.setText("Remove");
312
     frameRemove.setText("Remove");
297
     frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
313
     frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
298
     cp.add(frameRemove);
314
     cp.add(frameRemove);
410
     cp.add(jLabel4);
426
     cp.add(jLabel4);
411
     frameRemaining.setBounds(536, 232, 113, 24);
427
     frameRemaining.setBounds(536, 232, 113, 24);
412
     frameRemaining.setEditable(false);
428
     frameRemaining.setEditable(false);
413
-    frameRemaining.setText("2048");
429
+    frameRemaining.setText(String.valueOf(worker.framesRemaining()));
414
     frameRemaining.setFont(new Font("Dialog", Font.PLAIN, 13));
430
     frameRemaining.setFont(new Font("Dialog", Font.PLAIN, 13));
415
     cp.add(frameRemaining);
431
     cp.add(frameRemaining);
416
     animList.setFont(new Font("Dialog", Font.PLAIN, 13));
432
     animList.setFont(new Font("Dialog", Font.PLAIN, 13));
528
       errorMessage("Could not add animation!");
544
       errorMessage("Could not add animation!");
529
     } else {
545
     } else {
530
     int n = worker.numOfAnimations() - 1;
546
     int n = worker.numOfAnimations() - 1;
531
-    if (n < 0) {
547
+    // would have 0 anims after successfully adding one...
548
+	/*if (n < 0) {
532
       n = 0;
549
       n = 0;
533
-    }
550
+    }*/
534
     animModel.clear();
551
     animModel.clear();
535
-    System.out.println(n);
536
-    //animModel.addElement(worker.getAnimationName(n));
537
-    for (int i = 0; i < n; i++) {
552
+    for (int i = 0; i < (n + 1); i++) {
538
         animModel.add(i, worker.getAnimationName(i));
553
         animModel.add(i, worker.getAnimationName(i));
539
     }
554
     }
540
     animList.setModel(animModel);
555
     animList.setModel(animModel);

+ 4
- 4
Cube Control/makefile Vedi File

1
 JAVAC = javac
1
 JAVAC = javac
2
 CC = gcc
2
 CC = gcc
3
-#TARGET = unix
4
-TARGET = win
3
+TARGET = unix
4
+#TARGET = win
5
 
5
 
6
 JAVAFILES = cubeWorker.java layerEditFrame.java frame.java
6
 JAVAFILES = cubeWorker.java layerEditFrame.java frame.java
7
 
7
 
8
 ifeq ($(TARGET),win)
8
 ifeq ($(TARGET),win)
9
-CLASSES = cubeWorker.class layerEditFrame.class layerEditFrame$$1.class layerEditFrame$$2.class layerEditFrame$$3.class layerEditFrame$$4.class frame.class frame$$1.class frame$$2.class frame$$3.class frame$$4.class frame$$5.class frame$$6.class frame$$7.class frame$$8.class frame$$9.class frame$$10.class frame$$11.class frame$$12.class frame$$13.class frame$$14.class frame$$15.class frame$$16.class frame$$17.class frame$$18.class frame$$19.class frame$$20.class frame$$21.class frame$$22.class AFrame.class Animation.class AnimationUtility.class LEDoff.png LEDon.png
9
+CLASSES = cubeWorker.class layerEditFrame.class layerEditFrame$$1.class layerEditFrame$$2.class layerEditFrame$$3.class layerEditFrame$$4.class frame.class frame$$1.class frame$$2.class frame$$3.class frame$$4.class frame$$5.class frame$$6.class frame$$7.class frame$$8.class frame$$9.class frame$$10.class frame$$11.class frame$$12.class frame$$13.class frame$$14.class frame$$15.class frame$$16.class frame$$17.class frame$$18.class frame$$19.class frame$$20.class frame$$21.class frame$$22.class frame$$23.class AFrame.class Animation.class AnimationUtility.class LEDoff.png LEDon.png
10
 else
10
 else
11
-CLASSES = 'cubeWorker.class' 'layerEditFrame.class' 'layerEditFrame$$1.class' 'layerEditFrame$$2.class' 'layerEditFrame$$3.class' 'layerEditFrame$$4.class' 'frame.class' 'frame$$1.class' 'frame$$2.class' 'frame$$3.class' 'frame$$4.class' 'frame$$5.class' 'frame$$6.class' 'frame$$7.class' 'frame$$8.class' 'frame$$9.class' 'frame$$10.class' 'frame$$11.class' 'frame$$12.class' 'frame$$13.class' 'frame$$14.class' 'frame$$15.class' 'frame$$16.class' 'frame$$17.class' 'frame$$18.class' 'frame$$19.class' 'frame$$20.class' 'frame$$21.class' 'frame$$22.class' 'AFrame.class' 'Animation.class' 'AnimationUtility.class' 'LEDoff.png' 'LEDon.png'
11
+CLASSES = 'cubeWorker.class' 'layerEditFrame.class' 'layerEditFrame$$1.class' 'layerEditFrame$$2.class' 'layerEditFrame$$3.class' 'layerEditFrame$$4.class' 'frame.class' 'frame$$1.class' 'frame$$2.class' 'frame$$3.class' 'frame$$4.class' 'frame$$5.class' 'frame$$6.class' 'frame$$7.class' 'frame$$8.class' 'frame$$9.class' 'frame$$10.class' 'frame$$11.class' 'frame$$12.class' 'frame$$13.class' 'frame$$14.class' 'frame$$15.class' 'frame$$16.class' 'frame$$17.class' 'frame$$18.class' 'frame$$19.class' 'frame$$20.class' 'frame$$21.class' 'frame$$22.class' 'frame$$23.class' 'AFrame.class' 'Animation.class' 'AnimationUtility.class' 'LEDoff.png' 'LEDon.png'
12
 endif
12
 endif
13
 
13
 
14
 all: build clean
14
 all: build clean

Loading…
Annulla
Salva