mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-14 14:02:00 +00:00
Added: Changing PlaceObject tag type (PlaceObject, PlaceObject2, ...)
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2024 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.converters.ShapeTypeConverter;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JRadioButton;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ConvertPlaceObjectTypeDialog extends AppDialog {
|
||||
|
||||
private List<JRadioButton> radios = new ArrayList<>();
|
||||
|
||||
private int result = 0;
|
||||
|
||||
public ConvertPlaceObjectTypeDialog(Window owner, int currentPlaceObjectNum, int min) {
|
||||
super(owner);
|
||||
setTitle(translate("dialog.title"));
|
||||
JPanel radioPanel = new JPanel();
|
||||
radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
|
||||
ButtonGroup radioGroup = new ButtonGroup();
|
||||
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
String text = "PlaceObject" + (i > 1 ? "" + i : "");
|
||||
if (i == min) {
|
||||
text += " " + translate("minimum");
|
||||
}
|
||||
text += " - " + translate("place" + i);
|
||||
JRadioButton radio = new JRadioButton(text);
|
||||
radio.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
if (i == currentPlaceObjectNum) {
|
||||
radio.setSelected(true);
|
||||
}
|
||||
final int fi = i;
|
||||
radio.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
okButton.setEnabled(fi != currentPlaceObjectNum);
|
||||
}
|
||||
});
|
||||
radioPanel.add(radio);
|
||||
radioGroup.add(radio);
|
||||
radios.add(radio);
|
||||
}
|
||||
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
|
||||
cnt.add(radioPanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
|
||||
|
||||
okButton.setEnabled(false);
|
||||
okButton.addActionListener(this::okButtonActionPerformed);
|
||||
JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
cancelButton.addActionListener(this::cancelButtonActionPerformed);
|
||||
buttonsPanel.add(okButton);
|
||||
buttonsPanel.add(cancelButton);
|
||||
|
||||
cnt.add(buttonsPanel, BorderLayout.SOUTH);
|
||||
pack();
|
||||
View.centerScreen(this);
|
||||
View.setWindowIcon(this, "placeobject");
|
||||
setModal(true);
|
||||
}
|
||||
|
||||
private void okButtonActionPerformed(ActionEvent evt) {
|
||||
result = 0;
|
||||
for (int i = 0; i < radios.size(); i++) {
|
||||
if (radios.get(i).isSelected()) {
|
||||
result = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
private void cancelButtonActionPerformed(ActionEvent evt) {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public int getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public int showDialog() {
|
||||
setVisible(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.converters.ShapeTypeConverter;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
@@ -52,7 +50,6 @@ public class ConvertShapeTypeDialog extends AppDialog {
|
||||
|
||||
JButton okButton = new JButton(translate("button.ok"));
|
||||
|
||||
ShapeTypeConverter converter = new ShapeTypeConverter();
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
String text = "DefineShape" + (i > 1 ? "" + i : "");
|
||||
if (i < minForced) {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2024 JPEXS
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dialog.title = Convert place object type
|
||||
|
||||
place1 = colortransform, depth, character id, matrix
|
||||
place2 = flag move, clip actions, clip depth, colortransform with alpha, name, ratio
|
||||
place3 = class name, background color, bitmap cache, blend mode, filters, visible
|
||||
place4 = AMF data
|
||||
|
||||
minimum = (Minimum)
|
||||
unsupported = (Unsupported)
|
||||
|
||||
button.ok = OK
|
||||
button.cancel = Cancel
|
||||
@@ -0,0 +1,27 @@
|
||||
# Copyright (C) 2024 JPEXS
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
dialog.title = Konvertovat typ place objektu
|
||||
|
||||
place1 = colortransform, depth, character id, matrix
|
||||
place2 = flag move, clip actions, clip depth, colortransform s pr\u016fhlednost\u00ed, name, ratio
|
||||
place3 = class name, background color, bitmap cache, blend mode, filtry, visible
|
||||
place4 = AMF data
|
||||
|
||||
minimum = (Minimum)
|
||||
unsupported = (Nepodporov\u00e1no)
|
||||
|
||||
button.ok = OK
|
||||
button.cancel = Storno
|
||||
@@ -1004,4 +1004,5 @@ work.exporting.vsCode = Exporting VS Code
|
||||
menu.file.export.vsCode = Export to VS Code
|
||||
|
||||
#after 21.1.0
|
||||
contextmenu.convertShapeType = Convert shape type
|
||||
contextmenu.convertShapeType = Convert shape type
|
||||
contextmenu.convertPlaceObjectType = Convert place object type
|
||||
@@ -986,4 +986,5 @@ work.exporting.vsCode = Exportuji VS Code
|
||||
menu.file.export.vsCode = Exportovat do VS Code
|
||||
|
||||
#after 21.1.0
|
||||
contextmenu.convertShapeType = Konvertovat typ tvaru
|
||||
contextmenu.convertShapeType = Konvertovat typ tvaru
|
||||
contextmenu.convertPlaceObjectType = Konvertovat typ place objektu
|
||||
@@ -42,6 +42,7 @@ import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.AsLinkageDialog;
|
||||
import com.jpexs.decompiler.flash.gui.ClipboardType;
|
||||
import com.jpexs.decompiler.flash.gui.CollectDepthAsSpritesDialog;
|
||||
import com.jpexs.decompiler.flash.gui.ConvertPlaceObjectTypeDialog;
|
||||
import com.jpexs.decompiler.flash.gui.ConvertShapeTypeDialog;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
@@ -104,6 +105,7 @@ import com.jpexs.decompiler.flash.tags.base.RemoveTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.SoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.tags.converters.PlaceObjectTypeConverter;
|
||||
import com.jpexs.decompiler.flash.tags.converters.ShapeTypeConverter;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo;
|
||||
import com.jpexs.decompiler.flash.timeline.AS2Package;
|
||||
@@ -340,6 +342,8 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
private JMenuItem collectDepthAsSpritesMenuItem;
|
||||
|
||||
private JMenuItem convertShapeTypeMenuItem;
|
||||
|
||||
private JMenuItem convertPlaceObjectTypeMenuItem;
|
||||
|
||||
private List<TreeItem> items = new ArrayList<>();
|
||||
|
||||
@@ -543,6 +547,11 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
convertShapeTypeMenuItem.addActionListener(this::convertShapeTypeActionPerformed);
|
||||
convertShapeTypeMenuItem.setIcon(View.getIcon("shape16"));
|
||||
add(convertShapeTypeMenuItem);
|
||||
|
||||
convertPlaceObjectTypeMenuItem = new JMenuItem(mainPanel.translate("contextmenu.convertPlaceObjectType"));
|
||||
convertPlaceObjectTypeMenuItem.addActionListener(this::convertPlaceObjectTypeActionPerformed);
|
||||
convertPlaceObjectTypeMenuItem.setIcon(View.getIcon("placeobject16"));
|
||||
add(convertPlaceObjectTypeMenuItem);
|
||||
|
||||
addSeparator();
|
||||
|
||||
@@ -1075,9 +1084,11 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
}
|
||||
|
||||
boolean allSelectedIsShape = true;
|
||||
boolean allSelectedIsPlaceObject = true;
|
||||
|
||||
if (items.isEmpty()) {
|
||||
allSelectedIsShape = false;
|
||||
allSelectedIsPlaceObject = false;
|
||||
}
|
||||
|
||||
for (TreeItem item : items) {
|
||||
@@ -1085,6 +1096,9 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
if (!(item instanceof ShapeTag)) {
|
||||
allSelectedIsShape = false;
|
||||
}
|
||||
if (!(item instanceof PlaceObjectTypeTag)) {
|
||||
allSelectedIsPlaceObject = false;
|
||||
}
|
||||
|
||||
if (item instanceof Tag) {
|
||||
Tag tag = (Tag) item;
|
||||
@@ -1236,6 +1250,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
replaceWithTagMenuItem.setVisible(false);
|
||||
replaceRefsWithTagMenuItem.setVisible(false);
|
||||
convertShapeTypeMenuItem.setVisible(false);
|
||||
convertPlaceObjectTypeMenuItem.setVisible(false);
|
||||
abcExplorerMenuItem.setVisible(false);
|
||||
cleanAbcMenuItem.setVisible(false);
|
||||
rawEditMenuItem.setVisible(false);
|
||||
@@ -1662,6 +1677,10 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
if (allSelectedIsShape) {
|
||||
convertShapeTypeMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (allSelectedIsPlaceObject) {
|
||||
convertPlaceObjectTypeMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
moveTagToMenu.removeAll();
|
||||
moveTagToWithDependenciesMenu.removeAll();
|
||||
@@ -2619,6 +2638,46 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), sh.getSwf().getCharacter(sh.getCharacterId()));
|
||||
}
|
||||
}
|
||||
|
||||
private void convertPlaceObjectTypeActionPerformed(ActionEvent evt) {
|
||||
List<TreeItem> itemr = getSelectedItems();
|
||||
if (itemr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int currentPlaceObjectNum = 0;
|
||||
int min = 0;
|
||||
|
||||
PlaceObjectTypeConverter converter = new PlaceObjectTypeConverter();
|
||||
|
||||
|
||||
if (itemr.size() == 1) {
|
||||
PlaceObjectTypeTag sh = (PlaceObjectTypeTag) itemr.get(0);
|
||||
currentPlaceObjectNum = sh.getPlaceObjectNum();
|
||||
min = converter.getMinPlaceNum(sh);
|
||||
}
|
||||
|
||||
ConvertPlaceObjectTypeDialog dialog = new ConvertPlaceObjectTypeDialog(Main.getDefaultDialogsOwner(), currentPlaceObjectNum, min);
|
||||
|
||||
int placeNum = dialog.showDialog();
|
||||
|
||||
if (placeNum == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlaceObjectTypeTag lastConverted = null;
|
||||
for (TreeItem item : itemr) {
|
||||
PlaceObjectTypeTag pl = (PlaceObjectTypeTag) item;
|
||||
if (pl.getPlaceObjectNum()== placeNum) {
|
||||
continue;
|
||||
}
|
||||
lastConverted = converter.convertTagType(pl, placeNum);
|
||||
}
|
||||
|
||||
mainPanel.refreshTree();
|
||||
if (itemr.size() == 1) {
|
||||
mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentTree(), lastConverted);
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceRefsWithTagActionPerformed(ActionEvent evt) {
|
||||
TreeItem itemr = getCurrentItem();
|
||||
|
||||
Reference in New Issue
Block a user