this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

copy/paste for sprite command list

clover 2d184de1 9339cb4e

+137 -27
+4 -1
CHANGELOG.md
··· 4 4 5 5 ## Next Release 6 6 7 + ### Added 8 + - (Sprite Editor) Copy/paste/duplicate for commands/keyframes 9 + - Nix compatibility 10 + 7 11 ### Changed 8 12 - Main config and logs moved to system user directory (%AppData% on Windows, etc) 9 - - Added nix compatibility 10 13 11 14 ### Fixed 12 15 - (Map Editor) Fixed crash when fusing vertices
+64 -13
src/main/java/game/sprite/editor/animators/CommandAnimatorEditor.java
··· 2 2 3 3 import java.awt.Container; 4 4 import java.awt.Dimension; 5 + import java.awt.Toolkit; 5 6 import java.awt.event.ActionEvent; 6 7 import java.awt.event.ActionListener; 8 + import java.awt.event.InputEvent; 7 9 import java.awt.event.KeyEvent; 8 10 import java.awt.event.MouseAdapter; 9 11 import java.awt.event.MouseEvent; ··· 11 13 12 14 import javax.swing.AbstractAction; 13 15 import javax.swing.AbstractButton; 16 + import javax.swing.ActionMap; 14 17 import javax.swing.BorderFactory; 15 18 import javax.swing.ButtonGroup; 16 19 import javax.swing.ComboBoxModel; 17 20 import javax.swing.DefaultComboBoxModel; 18 21 import javax.swing.DefaultListModel; 22 + import javax.swing.InputMap; 19 23 import javax.swing.JCheckBox; 20 24 import javax.swing.JComboBox; 25 + import javax.swing.JComponent; 21 26 import javax.swing.JMenuItem; 22 27 import javax.swing.JPanel; 23 28 import javax.swing.JPopupMenu; ··· 80 85 private SpriteEditor editor; 81 86 private CommandAnimator animator; 82 87 88 + private AnimCommand clipboard; 89 + 83 90 public static void bind(SpriteEditor editor, CommandAnimator animator, Container commandListContainer, Container commandEditContainer) 84 91 { 85 92 instance().editor = editor; ··· 150 157 commandEditPanel.repaint(); 151 158 }); 152 159 153 - commandList.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DeleteCommands"); 154 - commandList.getActionMap().put("DeleteCommands", new AbstractAction() { 160 + InputMap im = commandList.getInputMap(JComponent.WHEN_FOCUSED); 161 + ActionMap am = commandList.getActionMap(); 162 + 163 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK), "copy"); 164 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK), "paste"); 165 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), "duplicate"); 166 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); 167 + 168 + am.put("copy", new AbstractAction() { 169 + @Override 170 + public void actionPerformed(ActionEvent e) 171 + { 172 + AnimCommand cmd = commandList.getSelectedValue(); 173 + if (cmd == null) { 174 + Toolkit.getDefaultToolkit().beep(); 175 + return; 176 + } 177 + clipboard = (AnimCommand) cmd.copy(); 178 + } 179 + }); 180 + 181 + am.put("paste", new AbstractAction() { 182 + @Override 183 + public void actionPerformed(ActionEvent e) 184 + { 185 + int i = commandList.getSelectedIndex(); 186 + if (i == -1 || clipboard == null) { 187 + Toolkit.getDefaultToolkit().beep(); 188 + return; 189 + } 190 + AnimCommand copy = (AnimCommand) clipboard.copy(); 191 + commandList.getDefaultModel().add(i + 1, copy); 192 + } 193 + }); 194 + 195 + am.put("duplicate", new AbstractAction() { 155 196 @Override 156 197 public void actionPerformed(ActionEvent e) 157 198 { 158 - if (!commandList.isSelectionEmpty()) { 159 - int i = commandList.getSelectedIndex(); 160 - DefaultListModel<?> model = (DefaultListModel<?>) commandList.getModel(); 161 - model.remove(i); 199 + AnimCommand cmd = commandList.getSelectedValue(); 200 + if (cmd == null) { 201 + Toolkit.getDefaultToolkit().beep(); 202 + return; 162 203 } 204 + int i = commandList.getSelectedIndex(); 205 + AnimCommand copy = (AnimCommand) cmd.copy(); 206 + commandList.getDefaultModel().add(i + 1, copy); 207 + } 208 + }); 209 + 210 + am.put("delete", new AbstractAction() { 211 + @Override 212 + public void actionPerformed(ActionEvent e) 213 + { 214 + int i = commandList.getSelectedIndex(); 215 + if (i == -1) { 216 + Toolkit.getDefaultToolkit().beep(); 217 + return; 218 + } 219 + commandList.getDefaultModel().remove(i); 163 220 } 164 221 }); 165 222 ··· 173 230 AnimElement elem = commandList.getModel().getElementAt(row); 174 231 175 232 switch (e.getButton()) { 176 - case MouseEvent.BUTTON1: // left-click 177 - if (e.isControlDown()) { 178 - DefaultListModel<AnimCommand> model = (DefaultListModel<AnimCommand>) instance().commandList.getModel(); 179 - model.addElement((AnimCommand) elem.copy()); 180 - } 181 - break; 182 233 case MouseEvent.BUTTON3: // right click 183 234 animator.advanceTo(elem); 184 235 commandListPanel.repaint(); ··· 272 323 273 324 private static void create(AnimCommand cmd) 274 325 { 275 - DefaultListModel<AnimCommand> model = (DefaultListModel<AnimCommand>) instance().commandList.getModel(); 326 + DefaultListModel<AnimCommand> model = instance().commandList.getDefaultModel(); 276 327 277 328 if (instance().commandList.isSelectionEmpty()) 278 329 model.addElement(cmd);
+64 -13
src/main/java/game/sprite/editor/animators/KeyframeAnimatorEditor.java
··· 2 2 3 3 import java.awt.Container; 4 4 import java.awt.Dimension; 5 + import java.awt.Toolkit; 5 6 import java.awt.event.ActionEvent; 7 + import java.awt.event.InputEvent; 6 8 import java.awt.event.KeyEvent; 7 9 import java.awt.event.MouseAdapter; 8 10 import java.awt.event.MouseEvent; 9 11 10 12 import javax.swing.AbstractAction; 13 + import javax.swing.ActionMap; 11 14 import javax.swing.BorderFactory; 12 15 import javax.swing.ComboBoxModel; 13 16 import javax.swing.DefaultComboBoxModel; 14 17 import javax.swing.DefaultListModel; 18 + import javax.swing.InputMap; 15 19 import javax.swing.JCheckBox; 16 20 import javax.swing.JComboBox; 21 + import javax.swing.JComponent; 17 22 import javax.swing.JLabel; 18 23 import javax.swing.JMenuItem; 19 24 import javax.swing.JPanel; ··· 60 65 61 66 private SpriteEditor editor; 62 67 private KeyframeAnimator animator; 68 + 69 + private AnimKeyframe clipboard; 63 70 64 71 public static void bind(SpriteEditor editor, KeyframeAnimator animator, Container commandListContainer, Container commandEditContainer) 65 72 { ··· 130 137 commandEditPanel.repaint(); 131 138 }); 132 139 133 - commandList.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DeleteCommands"); 134 - commandList.getActionMap().put("DeleteCommands", new AbstractAction() { 140 + InputMap im = commandList.getInputMap(JComponent.WHEN_FOCUSED); 141 + ActionMap am = commandList.getActionMap(); 142 + 143 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK), "copy"); 144 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK), "paste"); 145 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK), "duplicate"); 146 + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); 147 + 148 + am.put("copy", new AbstractAction() { 149 + @Override 150 + public void actionPerformed(ActionEvent e) 151 + { 152 + AnimKeyframe cmd = commandList.getSelectedValue(); 153 + if (cmd == null) { 154 + Toolkit.getDefaultToolkit().beep(); 155 + return; 156 + } 157 + clipboard = (AnimKeyframe) cmd.copy(); 158 + } 159 + }); 160 + 161 + am.put("paste", new AbstractAction() { 162 + @Override 163 + public void actionPerformed(ActionEvent e) 164 + { 165 + int i = commandList.getSelectedIndex(); 166 + if (i == -1 || clipboard == null) { 167 + Toolkit.getDefaultToolkit().beep(); 168 + return; 169 + } 170 + AnimKeyframe copy = (AnimKeyframe) clipboard.copy(); 171 + commandList.getDefaultModel().add(i + 1, copy); 172 + } 173 + }); 174 + 175 + am.put("duplicate", new AbstractAction() { 135 176 @Override 136 177 public void actionPerformed(ActionEvent e) 137 178 { 138 - if (!commandList.isSelectionEmpty()) { 139 - int i = commandList.getSelectedIndex(); 140 - DefaultListModel<?> model = (DefaultListModel<?>) commandList.getModel(); 141 - model.remove(i); 179 + AnimKeyframe cmd = commandList.getSelectedValue(); 180 + if (cmd == null) { 181 + Toolkit.getDefaultToolkit().beep(); 182 + return; 142 183 } 184 + int i = commandList.getSelectedIndex(); 185 + AnimKeyframe copy = (AnimKeyframe) cmd.copy(); 186 + commandList.getDefaultModel().add(i + 1, copy); 187 + } 188 + }); 189 + 190 + am.put("delete", new AbstractAction() { 191 + @Override 192 + public void actionPerformed(ActionEvent e) 193 + { 194 + int i = commandList.getSelectedIndex(); 195 + if (i == -1) { 196 + Toolkit.getDefaultToolkit().beep(); 197 + return; 198 + } 199 + commandList.getDefaultModel().remove(i); 143 200 } 144 201 }); 145 202 ··· 153 210 AnimElement elem = commandList.getModel().getElementAt(row); 154 211 155 212 switch (e.getButton()) { 156 - case MouseEvent.BUTTON1: // left-click 157 - if (e.isControlDown()) { 158 - DefaultListModel<AnimKeyframe> model = (DefaultListModel<AnimKeyframe>) instance().commandList.getModel(); 159 - model.addElement((AnimKeyframe) elem.copy()); 160 - } 161 - break; 162 213 case MouseEvent.BUTTON3: // right click 163 214 animator.advanceTo(elem); 164 215 commandListPanel.repaint(); ··· 220 271 221 272 private static void create(AnimKeyframe cmd) 222 273 { 223 - DefaultListModel<AnimKeyframe> model = (DefaultListModel<AnimKeyframe>) instance().commandList.getModel(); 274 + DefaultListModel<AnimKeyframe> model = instance().commandList.getDefaultModel(); 224 275 225 276 if (instance().commandList.isSelectionEmpty()) 226 277 model.addElement(cmd);
+5
src/main/java/util/ui/DragReorderList.java
··· 39 39 } 40 40 } 41 41 42 + public DefaultListModel<T> getDefaultModel() 43 + { 44 + return (DefaultListModel<T>) getModel(); 45 + } 46 + 42 47 private class ReorderingTransferHandler extends TransferHandler 43 48 { 44 49 private DataFlavor dummyFlavor;