mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 16:38:08 +00:00
Added Setting for enabling placing Define tags into DefineSprite
This commit is contained in:
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Keyboard shortcuts for tag clipboard operations
|
||||
- Hilight clipboard panel on copy/cut action for a few seconds
|
||||
- Drag and drop to move/copy tags in the tag list view
|
||||
- Setting for enabling placing Define tags into DefineSprite
|
||||
|
||||
## [16.2.0] - 2022-11-08
|
||||
### Added
|
||||
|
||||
@@ -767,6 +767,10 @@ public final class Configuration {
|
||||
@ConfigurationDefaultBoolean(true)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> expandFirstLevelOfTreeOnLoad = null;
|
||||
|
||||
@ConfigurationDefaultBoolean(false)
|
||||
@ConfigurationCategory("ui")
|
||||
public static ConfigurationItem<Boolean> allowPlacingDefinesIntoSprites = null;
|
||||
|
||||
private enum OSId {
|
||||
WINDOWS, OSX, UNIX
|
||||
|
||||
@@ -583,3 +583,6 @@ config.description.autoPlaySwfs = Automatically play SWF preview on SWF node sel
|
||||
|
||||
config.name.expandFirstLevelOfTreeOnLoad = Expand first level of tree on SWF load
|
||||
config.description.expandFirstLevelOfTreeOnLoad = Automatically expands first level of nodes in the tree on SWF open.
|
||||
|
||||
config.name.allowPlacingDefinesIntoSprites = Allow placing define tags into DefineSprite
|
||||
config.description.allowPlacingDefinesIntoSprites = Allows placing (moving/copying/dragging into) define type tags into DefineSprite.
|
||||
|
||||
@@ -569,4 +569,7 @@ config.name.autoPlaySwfs = Automaticky p\u0159ehr\u00e1vat n\u00e1hledy SWF
|
||||
config.description.autoPlaySwfs = Automaticicky p\u0159ehr\u00e1vat n\u00e1hled SWF p\u0159i v\u00fdb\u011bru SWF polo\u017eky.
|
||||
|
||||
config.name.expandFirstLevelOfTreeOnLoad = Rozbalit prvn\u00ed \u00farove\u0148 stromu p\u0159i na\u010dten\u00ed SWF
|
||||
config.description.expandFirstLevelOfTreeOnLoad = Automaticky rozbal\u00ed prvn\u00ed \u00farove\u0148 polo\u017eek stromu p\u0159i otev\u0159en\u00ed SWF.
|
||||
config.description.expandFirstLevelOfTreeOnLoad = Automaticky rozbal\u00ed prvn\u00ed \u00farove\u0148 polo\u017eek stromu p\u0159i otev\u0159en\u00ed SWF.
|
||||
|
||||
config.name.allowPlacingDefinesIntoSprites = Povolit umis\u0165ov\u00e1n\u00ed defini\u010dn\u00edch tag\u016f do DefineSprite
|
||||
config.description.allowPlacingDefinesIntoSprites = Povol\u00ed umis\u0165ov\u00e1n\u00ed (p\u0159esun/kop\u00edrov\u00e1n\u00ed/ta\u017een\u00ed dovnit\u0159) defini\u010dn\u00edch tag\u016f do DefineSprite.
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.tagtree.AbstractTagTree;
|
||||
import static com.jpexs.decompiler.flash.gui.tagtree.AbstractTagTree.getSelection;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.DoInitActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
@@ -115,7 +116,11 @@ class TreeTransferHandler extends TransferHandler {
|
||||
// Do not allow a drop on the drag source selections.
|
||||
JTree.DropLocation dl = (JTree.DropLocation) support.getDropLocation();
|
||||
|
||||
if ((dl.getPath().getLastPathComponent() instanceof Tag) && dl.getChildIndex() == -1) {
|
||||
if (
|
||||
((dl.getPath().getLastPathComponent() instanceof Tag) &&
|
||||
!(dl.getPath().getLastPathComponent() instanceof DefineSpriteTag)) &&
|
||||
dl.getChildIndex() == -1
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -181,7 +186,10 @@ class TreeTransferHandler extends TransferHandler {
|
||||
Timelined timelined;
|
||||
Tag position;
|
||||
if (childIndex == -1) {
|
||||
if (dest instanceof Tag) {
|
||||
if (dest instanceof DefineSpriteTag) {
|
||||
timelined = (Timelined) dest;
|
||||
position = null;
|
||||
} else if (dest instanceof Tag) {
|
||||
timelined = ((Tag) dest).getTimelined();
|
||||
position = (Tag) dest;
|
||||
} else if (dest instanceof Frame) {
|
||||
|
||||
@@ -359,7 +359,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
add(copyTagToWithDependenciesMenu);
|
||||
|
||||
cutTagToClipboardMenuItem = new JMenuItem(mainPanel.translate("contextmenu.cutTag") + " (CTRL+X)");
|
||||
cutTagToClipboardMenuItem.setIcon(View.getIcon("cut16"));
|
||||
cutTagToClipboardMenuItem.setIcon(View.getIcon("cut16"));
|
||||
cutTagToClipboardMenuItem.addActionListener(this::cutTagToClipboardActionPerformed);
|
||||
add(cutTagToClipboardMenuItem);
|
||||
|
||||
@@ -853,9 +853,9 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
|
||||
if (allSelectedIsTag) {
|
||||
List<TreeItem> tagItems = new ArrayList<>();
|
||||
for(TreeItem item:items) {
|
||||
for (TreeItem item : items) {
|
||||
if (item instanceof TagScript) {
|
||||
tagItems.add(((TagScript)item).getTag());
|
||||
tagItems.add(((TagScript) item).getTag());
|
||||
} else {
|
||||
tagItems.add((Tag) item);
|
||||
}
|
||||
@@ -882,7 +882,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
|
||||
cutTagToClipboardMenuItem.setVisible(true);
|
||||
cutTagToClipboardWithDependenciesMenuItem.setVisible(true);
|
||||
|
||||
|
||||
copyTagToMenu.setVisible(true);
|
||||
copyTagToWithDependenciesMenu.setVisible(true);
|
||||
}
|
||||
@@ -2741,7 +2741,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
ReadOnlyTagList tags = timelined.getTags();
|
||||
position = positionInt < tags.size() ? tags.get(positionInt) : null;
|
||||
copyOrMoveTagsBeforeAfter(mainPanel.getClipboardContents(), mainPanel.isClipboardCut(), timelined, position);
|
||||
|
||||
|
||||
if (mainPanel.isClipboardCut()) {
|
||||
mainPanel.emptyClipboard();
|
||||
}
|
||||
@@ -2763,7 +2763,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
ReadOnlyTagList tags = timelined.getTags();
|
||||
position = positionInt < tags.size() ? tags.get(positionInt) : null;
|
||||
copyOrMoveTagsBeforeAfter(mainPanel.getClipboardContents(), mainPanel.isClipboardCut(), timelined, position);
|
||||
|
||||
|
||||
if (mainPanel.isClipboardCut()) {
|
||||
mainPanel.emptyClipboard();
|
||||
}
|
||||
@@ -2782,69 +2782,72 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
position = null;
|
||||
}
|
||||
copyOrMoveTagsBeforeAfter(mainPanel.getClipboardContents(), mainPanel.isClipboardCut(), timelined, position);
|
||||
|
||||
|
||||
if (mainPanel.isClipboardCut()) {
|
||||
mainPanel.emptyClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
public void copyOrMoveTagsBeforeAfter(Set<TreeItem> items, boolean move, Timelined targetTimelined, Tag position) {
|
||||
//do not move to self
|
||||
if (items.size() == 1 && move) {
|
||||
Tag tag = (Tag) items.iterator().next();
|
||||
if (targetTimelined == tag.getTimelined()) {
|
||||
if (tag == position) {
|
||||
return;
|
||||
}
|
||||
int index = tag.getTimelined().indexOfTag(tag);
|
||||
ReadOnlyTagList tags = tag.getTimelined().getTags();
|
||||
Tag nextPosition;
|
||||
if (index + 1 < tags.size()) {
|
||||
nextPosition = tags.get(index + 1);
|
||||
if (nextPosition == position) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<SWF> sourceSwfs = new LinkedHashSet<>();
|
||||
SWF targetSwf = (targetTimelined instanceof SWF) ? (SWF) targetTimelined : ((DefineSpriteTag) targetTimelined).getSwf();
|
||||
try {
|
||||
List<Tag> newTags = new ArrayList<>();
|
||||
Map<Integer, Integer> changedCharacterIds = new HashMap<>();
|
||||
for (TreeItem item : items) {
|
||||
Tag tag = (Tag) item;
|
||||
Tag tag = (Tag) item;
|
||||
if (tag.getSwf() == null) {
|
||||
continue;
|
||||
}
|
||||
SWF sourceSwf = tag.getSwf();
|
||||
sourceSwfs.add(sourceSwf);
|
||||
|
||||
|
||||
Timelined realTargetTimelined = targetTimelined;
|
||||
Tag realPosition = position;
|
||||
|
||||
if (!Configuration.allowPlacingDefinesIntoSprites.get()) {
|
||||
//do not place Define tags in DefineSprites
|
||||
if ((tag instanceof CharacterTag) && (targetTimelined instanceof DefineSpriteTag)) {
|
||||
Tag spriteTag = ((DefineSpriteTag) targetTimelined);
|
||||
//get to the topmost level DefineSprite
|
||||
while (spriteTag.getTimelined() instanceof DefineSpriteTag) {
|
||||
spriteTag = (DefineSpriteTag) spriteTag.getTimelined();
|
||||
}
|
||||
realTargetTimelined = spriteTag.getTimelined(); //should be SWF
|
||||
realPosition = spriteTag;
|
||||
}
|
||||
}
|
||||
|
||||
//do not move to self
|
||||
if (items.size() == 1 && move) {
|
||||
if (realTargetTimelined == tag.getTimelined()) {
|
||||
if (tag == position) {
|
||||
return;
|
||||
}
|
||||
int index = tag.getTimelined().indexOfTag(tag);
|
||||
ReadOnlyTagList tags = tag.getTimelined().getTags();
|
||||
Tag nextPosition;
|
||||
if (index + 1 < tags.size()) {
|
||||
nextPosition = tags.get(index + 1);
|
||||
if (nextPosition == realPosition) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (move) {
|
||||
if (tag == position) {
|
||||
/*if (tag == position) {
|
||||
int index = tag.getTimelined().indexOfTag(position);
|
||||
if (tag.getTimelined().getTags().size() > index + 1) {
|
||||
position = tag.getTimelined().getTags().get(index + 1);
|
||||
} else {
|
||||
position = null;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
tag.getTimelined().removeTag(tag);
|
||||
}
|
||||
|
||||
Timelined realTargetTimelined = targetTimelined;
|
||||
Tag realPosition = position;
|
||||
|
||||
//do not place Define tags in DefineSprites
|
||||
if ((tag instanceof CharacterTag) && (targetTimelined instanceof DefineSpriteTag)) {
|
||||
Tag spriteTag = ((DefineSpriteTag) targetTimelined);
|
||||
//get to the topmost level DefineSprite
|
||||
while (spriteTag.getTimelined() instanceof DefineSpriteTag) {
|
||||
spriteTag = (DefineSpriteTag) spriteTag.getTimelined();
|
||||
}
|
||||
realTargetTimelined = spriteTag.getTimelined(); //should be SWF
|
||||
realPosition = spriteTag;
|
||||
}
|
||||
if (sourceSwf != targetSwf || !move) {
|
||||
ReadOnlyTagList tags = realTargetTimelined.getTags();
|
||||
int positionInt = realPosition == null ? tags.size() : tags.indexOf(realPosition);
|
||||
@@ -2894,7 +2897,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
targetSwf.clearImageCache();
|
||||
targetSwf.updateCharacters();
|
||||
targetSwf.resetTimelines(targetSwf);
|
||||
|
||||
|
||||
mainPanel.refreshTree(targetSwf);
|
||||
} catch (InterruptedException | IOException ex) {
|
||||
Logger.getLogger(TagTreeContextMenu.class.getName()).log(Level.SEVERE, null, ex);
|
||||
|
||||
Reference in New Issue
Block a user