mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-09 14:09:31 +00:00
show some basic tag info
This commit is contained in:
@@ -36,7 +36,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.TagInfo;
|
||||
import com.jpexs.decompiler.flash.tags.TagTypeInfo;
|
||||
import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA;
|
||||
import com.jpexs.decompiler.flash.types.ALPHACOLORMAPDATA;
|
||||
import com.jpexs.decompiler.flash.types.ARGB;
|
||||
@@ -241,7 +241,7 @@ public class SwfXmlImporter {
|
||||
private Object createObject(String type, SWF swf, Tag tag) throws NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
if (swfTags == null) {
|
||||
Map<String, Class> tags = new HashMap<>();
|
||||
Map<Integer, TagInfo> knownTags = Tag.getKnownClasses();
|
||||
Map<Integer, TagTypeInfo> knownTags = Tag.getKnownClasses();
|
||||
for (Integer key : knownTags.keySet()) {
|
||||
Class cls = knownTags.get(key).getCls();
|
||||
if (!ReflectionTools.canInstantiate(cls)) {
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.Exportable;
|
||||
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
|
||||
@@ -32,8 +34,10 @@ import com.jpexs.decompiler.flash.tags.gfx.DefineSubImage;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.ExporterInfo;
|
||||
import com.jpexs.decompiler.flash.tags.gfx.FontTextureInfo;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Internal;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
@@ -161,9 +165,9 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
|
||||
|
||||
private volatile static Integer[] knownTagIds;
|
||||
|
||||
private volatile static Map<Integer, TagInfo> knownTagInfosById;
|
||||
private volatile static Map<Integer, TagTypeInfo> knownTagInfosById;
|
||||
|
||||
private volatile static Map<String, TagInfo> knownTagInfosByName;
|
||||
private volatile static Map<String, TagTypeInfo> knownTagInfosByName;
|
||||
|
||||
private volatile static List<Integer> requiredTagIds;
|
||||
|
||||
@@ -180,12 +184,12 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
|
||||
return knownTagIds;
|
||||
}
|
||||
|
||||
public static Map<Integer, TagInfo> getKnownClasses() {
|
||||
public static Map<Integer, TagTypeInfo> getKnownClasses() {
|
||||
if (knownTagInfosById == null) {
|
||||
synchronized (lockObject) {
|
||||
if (knownTagInfosById == null) {
|
||||
Map<Integer, TagInfo> map = new HashMap<>();
|
||||
Map<String, TagInfo> map2 = new HashMap<>();
|
||||
Map<Integer, TagTypeInfo> map = new HashMap<>();
|
||||
Map<String, TagTypeInfo> map2 = new HashMap<>();
|
||||
addTagInfo(map, map2, CSMTextSettingsTag.ID, CSMTextSettingsTag.class, CSMTextSettingsTag.NAME);
|
||||
addTagInfo(map, map2, DebugIDTag.ID, DebugIDTag.class, DebugIDTag.NAME);
|
||||
addTagInfo(map, map2, DefineBinaryDataTag.ID, DefineBinaryDataTag.class, DefineBinaryDataTag.NAME);
|
||||
@@ -273,7 +277,7 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
|
||||
return knownTagInfosById;
|
||||
}
|
||||
|
||||
public static Map<String, TagInfo> getKnownClassesByName() {
|
||||
public static Map<String, TagTypeInfo> getKnownClassesByName() {
|
||||
// map is filled together with knownTagInfosById
|
||||
if (knownTagInfosByName == null) {
|
||||
getKnownClasses();
|
||||
@@ -282,9 +286,9 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
|
||||
return knownTagInfosByName;
|
||||
}
|
||||
|
||||
private static void addTagInfo(Map<Integer, TagInfo> map, Map<String, TagInfo> map2, int id, Class cls, String name) {
|
||||
map.put(id, new TagInfo(id, cls, name));
|
||||
map2.put(name, new TagInfo(id, cls, name));
|
||||
private static void addTagInfo(Map<Integer, TagTypeInfo> map, Map<String, TagTypeInfo> map2, int id, Class cls, String name) {
|
||||
map.put(id, new TagTypeInfo(id, cls, name));
|
||||
map2.put(name, new TagTypeInfo(id, cls, name));
|
||||
}
|
||||
|
||||
public static List<Integer> getRequiredTags() {
|
||||
@@ -561,4 +565,37 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getTagInfo(TagInfo tagInfo) {
|
||||
|
||||
tagInfo.addInfo("general", "tagType", String.format("%s (%d)", tagName, id));
|
||||
if (this instanceof CharacterIdTag) {
|
||||
CharacterIdTag characterIdTag = (CharacterIdTag) this;
|
||||
tagInfo.addInfo("general", "characterId", characterIdTag.getCharacterId());
|
||||
}
|
||||
|
||||
if (originalRange != null) {
|
||||
int pos = originalRange.getPos();
|
||||
int length = originalRange.getLength();
|
||||
tagInfo.addInfo("general", "offset", String.format("%d (0x%x)", pos, pos));
|
||||
tagInfo.addInfo("general", "length", String.format("%d (0x%x)", length, length));
|
||||
}
|
||||
|
||||
if (this instanceof BoundedTag) {
|
||||
BoundedTag boundedIdTag = (BoundedTag) this;
|
||||
RECT bounds = boundedIdTag.getRect();
|
||||
tagInfo.addInfo("general", "bounds",
|
||||
String.format("(%.2f, %.2f)[%.2f x %.2f]", bounds.Xmin / SWF.unitDivisor,
|
||||
bounds.Ymin / SWF.unitDivisor,
|
||||
bounds.getWidth() / SWF.unitDivisor,
|
||||
bounds.getHeight() / SWF.unitDivisor));
|
||||
}
|
||||
|
||||
Set<Integer> needed = new LinkedHashSet<>();
|
||||
getNeededCharactersDeep(needed);
|
||||
|
||||
if (needed.size() > 0) {
|
||||
tagInfo.addInfo("general", "neededCharacters", Helper.joinStrings(needed, ", "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,33 +16,55 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagInfo {
|
||||
|
||||
private final int id;
|
||||
private final Map<String, List<TagInfoItem>> infos = new LinkedHashMap<>();
|
||||
|
||||
private final Class cls;
|
||||
public void addInfo(String categoryName, String name, Object value) {
|
||||
categoryName = "general"; // temporary add everything to general catagory
|
||||
List<TagInfoItem> category = infos.get(categoryName);
|
||||
if (category == null) {
|
||||
category = new ArrayList<>();
|
||||
infos.put(categoryName, category);
|
||||
}
|
||||
|
||||
private final String name;
|
||||
|
||||
public TagInfo(int id, Class cls, String name) {
|
||||
this.id = id;
|
||||
this.cls = cls;
|
||||
this.name = name;
|
||||
category.add(new TagInfoItem(name, value));
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
public Map<String, List<TagInfoItem>> getInfos() {
|
||||
return infos;
|
||||
}
|
||||
|
||||
public Class getCls() {
|
||||
return cls;
|
||||
public boolean isEmpty() {
|
||||
return infos.isEmpty();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public class TagInfoItem {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Object value;
|
||||
|
||||
public TagInfoItem(String name, Object value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagTypeInfo {
|
||||
|
||||
private final int id;
|
||||
|
||||
private final Class cls;
|
||||
|
||||
private final String name;
|
||||
|
||||
public TagTypeInfo(int id, Class cls, String name) {
|
||||
this.id = id;
|
||||
this.cls = cls;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Class getCls() {
|
||||
return cls;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter;
|
||||
import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter;
|
||||
import com.jpexs.decompiler.flash.tags.TagInfo;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.decompiler.flash.types.BasicType;
|
||||
import com.jpexs.decompiler.flash.types.ColorTransform;
|
||||
@@ -264,6 +265,14 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag {
|
||||
cachedImage = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTagInfo(TagInfo tagInfo) {
|
||||
super.getTagInfo(tagInfo);
|
||||
SerializableImage image = getImage();
|
||||
tagInfo.addInfo("general", "width", image.getWidth());
|
||||
tagInfo.addInfo("general", "height", image.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCharacterId() {
|
||||
return characterID;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 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/>.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ import org.pushingpixels.flamingo.api.ribbon.JRibbonFrame;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class AppRibbonFrame extends JRibbonFrame {
|
||||
public abstract class AppRibbonFrame extends JRibbonFrame implements MainFrame {
|
||||
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
@@ -35,6 +35,7 @@ public abstract class AppRibbonFrame extends JRibbonFrame {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String translate(String key) {
|
||||
return resourceBundle.getString(key);
|
||||
}
|
||||
|
||||
@@ -1,185 +1,185 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 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.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
|
||||
import com.jpexs.decompiler.flash.treeitems.SWFList;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowStateListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.tree.TreePath;
|
||||
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
|
||||
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
|
||||
|
||||
private final MainPanel panel;
|
||||
|
||||
private final MainFrameMenu mainMenu;
|
||||
|
||||
public MainFrameRibbon() {
|
||||
super();
|
||||
|
||||
FlashPlayerPanel flashPanel = null;
|
||||
try {
|
||||
flashPanel = new FlashPlayerPanel(this);
|
||||
} catch (FlashUnsupportedException fue) {
|
||||
}
|
||||
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
JRibbon ribbon = getRibbon();
|
||||
cnt.add(ribbon, BorderLayout.NORTH);
|
||||
|
||||
boolean externalFlashPlayerUnavailable = flashPanel == null;
|
||||
mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable);
|
||||
|
||||
panel = new MainPanel(this, mainMenu, flashPanel);
|
||||
panel.setBackground(Color.yellow);
|
||||
cnt.add(panel, BorderLayout.CENTER);
|
||||
|
||||
int w = Configuration.guiWindowWidth.get();
|
||||
int h = Configuration.guiWindowHeight.get();
|
||||
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
if (w > dim.width) {
|
||||
w = dim.width;
|
||||
}
|
||||
if (h > dim.height) {
|
||||
h = dim.height;
|
||||
}
|
||||
setSize(w, h);
|
||||
|
||||
boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get();
|
||||
boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get();
|
||||
|
||||
int state = 0;
|
||||
if (maximizedHorizontal) {
|
||||
state |= JFrame.MAXIMIZED_HORIZ;
|
||||
}
|
||||
if (maximizedVertical) {
|
||||
state |= JFrame.MAXIMIZED_VERT;
|
||||
}
|
||||
setExtendedState(state);
|
||||
|
||||
View.setWindowIcon(this);
|
||||
addWindowStateListener(new WindowStateListener() {
|
||||
@Override
|
||||
public void windowStateChanged(WindowEvent e) {
|
||||
int state = e.getNewState();
|
||||
Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ);
|
||||
Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT);
|
||||
}
|
||||
});
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
int state = getExtendedState();
|
||||
if ((state & JFrame.MAXIMIZED_HORIZ) == 0) {
|
||||
Configuration.guiWindowWidth.set(getWidth());
|
||||
}
|
||||
if ((state & JFrame.MAXIMIZED_VERT) == 0) {
|
||||
Configuration.guiWindowHeight.set(getHeight());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
if (Configuration.saveSessionOnExit.get()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (SWFList swf : panel.getSwfs()) {
|
||||
String file = swf.sourceInfo.getFile();
|
||||
if (file != null) {
|
||||
sb.append(file);
|
||||
sb.append(File.pathSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
TreePath path = panel.tagTree.getLeadSelectionPath();
|
||||
if (path != null) {
|
||||
boolean first = true;
|
||||
for (Object p : path.getPath()) {
|
||||
if (!first) {
|
||||
sb.append("|");
|
||||
}
|
||||
|
||||
first = false;
|
||||
sb.append(p.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Configuration.lastSessionData.set(sb.toString());
|
||||
}
|
||||
|
||||
boolean closeResult = panel.closeAll();
|
||||
if (closeResult) {
|
||||
Main.exit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
View.centerScreen(this);
|
||||
|
||||
}
|
||||
|
||||
private static void getApplicationMenuButtons(Component comp, List<JRibbonApplicationMenuButton> ret) {
|
||||
if (comp instanceof JRibbonApplicationMenuButton) {
|
||||
ret.add((JRibbonApplicationMenuButton) comp);
|
||||
return;
|
||||
}
|
||||
if (comp instanceof Container) {
|
||||
Container cont = (Container) comp;
|
||||
for (int i = 0; i < cont.getComponentCount(); i++) {
|
||||
getApplicationMenuButtons(cont.getComponent(i), ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
super.setVisible(b);
|
||||
panel.setVisible(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MainPanel getPanel() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindow() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2015 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.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
|
||||
import com.jpexs.decompiler.flash.treeitems.SWFList;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowStateListener;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.tree.TreePath;
|
||||
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
|
||||
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public final class MainFrameRibbon extends AppRibbonFrame {
|
||||
|
||||
private final MainPanel panel;
|
||||
|
||||
private final MainFrameMenu mainMenu;
|
||||
|
||||
public MainFrameRibbon() {
|
||||
super();
|
||||
|
||||
FlashPlayerPanel flashPanel = null;
|
||||
try {
|
||||
flashPanel = new FlashPlayerPanel(this);
|
||||
} catch (FlashUnsupportedException fue) {
|
||||
}
|
||||
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
JRibbon ribbon = getRibbon();
|
||||
cnt.add(ribbon, BorderLayout.NORTH);
|
||||
|
||||
boolean externalFlashPlayerUnavailable = flashPanel == null;
|
||||
mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable);
|
||||
|
||||
panel = new MainPanel(this, mainMenu, flashPanel);
|
||||
panel.setBackground(Color.yellow);
|
||||
cnt.add(panel, BorderLayout.CENTER);
|
||||
|
||||
int w = Configuration.guiWindowWidth.get();
|
||||
int h = Configuration.guiWindowHeight.get();
|
||||
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
if (w > dim.width) {
|
||||
w = dim.width;
|
||||
}
|
||||
if (h > dim.height) {
|
||||
h = dim.height;
|
||||
}
|
||||
setSize(w, h);
|
||||
|
||||
boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get();
|
||||
boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get();
|
||||
|
||||
int state = 0;
|
||||
if (maximizedHorizontal) {
|
||||
state |= JFrame.MAXIMIZED_HORIZ;
|
||||
}
|
||||
if (maximizedVertical) {
|
||||
state |= JFrame.MAXIMIZED_VERT;
|
||||
}
|
||||
setExtendedState(state);
|
||||
|
||||
View.setWindowIcon(this);
|
||||
addWindowStateListener(new WindowStateListener() {
|
||||
@Override
|
||||
public void windowStateChanged(WindowEvent e) {
|
||||
int state = e.getNewState();
|
||||
Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ);
|
||||
Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT);
|
||||
}
|
||||
});
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
int state = getExtendedState();
|
||||
if ((state & JFrame.MAXIMIZED_HORIZ) == 0) {
|
||||
Configuration.guiWindowWidth.set(getWidth());
|
||||
}
|
||||
if ((state & JFrame.MAXIMIZED_VERT) == 0) {
|
||||
Configuration.guiWindowHeight.set(getHeight());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
if (Configuration.saveSessionOnExit.get()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (SWFList swf : panel.getSwfs()) {
|
||||
String file = swf.sourceInfo.getFile();
|
||||
if (file != null) {
|
||||
sb.append(file);
|
||||
sb.append(File.pathSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
TreePath path = panel.tagTree.getLeadSelectionPath();
|
||||
if (path != null) {
|
||||
boolean first = true;
|
||||
for (Object p : path.getPath()) {
|
||||
if (!first) {
|
||||
sb.append("|");
|
||||
}
|
||||
|
||||
first = false;
|
||||
sb.append(p.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Configuration.lastSessionData.set(sb.toString());
|
||||
}
|
||||
|
||||
boolean closeResult = panel.closeAll();
|
||||
if (closeResult) {
|
||||
Main.exit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
View.centerScreen(this);
|
||||
|
||||
}
|
||||
|
||||
private static void getApplicationMenuButtons(Component comp, List<JRibbonApplicationMenuButton> ret) {
|
||||
if (comp instanceof JRibbonApplicationMenuButton) {
|
||||
ret.add((JRibbonApplicationMenuButton) comp);
|
||||
return;
|
||||
}
|
||||
if (comp instanceof Container) {
|
||||
Container cont = (Container) comp;
|
||||
for (int i = 0; i < cont.getComponentCount(); i++) {
|
||||
getApplicationMenuButtons(cont.getComponent(i), ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
super.setVisible(b);
|
||||
panel.setVisible(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MainPanel getPanel() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindow() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ import com.jpexs.decompiler.flash.tags.DoInitActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
|
||||
import com.jpexs.decompiler.flash.tags.MetadataTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.TagInfo;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
|
||||
@@ -424,7 +425,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
whitePanel.setBackground(Color.white);
|
||||
detailPanel.add(whitePanel, DETAILCARDEMPTYPANEL);
|
||||
|
||||
tagInfoPanel = new TagInfoPanel();
|
||||
tagInfoPanel = new TagInfoPanel(this);
|
||||
detailPanel.add(tagInfoPanel, DETAILCARDTAGINFO);
|
||||
|
||||
UIManager.getDefaults().put("TreeUI", BasicTreeUI.class.getName());
|
||||
@@ -2881,10 +2882,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
|
||||
if (treeItem instanceof Tag) {
|
||||
Tag tag = (Tag) treeItem;
|
||||
Set<Integer> needed = new HashSet<>();
|
||||
tag.getNeededCharactersDeep(needed);
|
||||
if (needed.size() > 0) {
|
||||
tagInfoPanel.setNeededCharacters(needed);
|
||||
TagInfo tagInfo = new TagInfo();
|
||||
tag.getTagInfo(tagInfo);
|
||||
if (!tagInfo.isEmpty()) {
|
||||
tagInfoPanel.setTagInfos(tagInfo);
|
||||
showDetail(DETAILCARDTAGINFO);
|
||||
} else {
|
||||
showDetail(DETAILCARDEMPTYPANEL);
|
||||
|
||||
@@ -1,44 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2015 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.helpers.Helper;
|
||||
import java.util.Set;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagInfoPanel extends JPanel {
|
||||
|
||||
private final JLabel neededCharactersLabel;
|
||||
|
||||
public TagInfoPanel() {
|
||||
neededCharactersLabel = new JLabel();
|
||||
add(new JLabel("Needed characters:"));
|
||||
add(neededCharactersLabel);
|
||||
|
||||
// todo: add other information
|
||||
}
|
||||
|
||||
public void setNeededCharacters(Set<Integer> needed) {
|
||||
String neededStr = Helper.joinStrings(needed, ", ");
|
||||
neededCharactersLabel.setText(neededStr);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2015 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.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.tags.TagInfo;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TagInfoPanel extends JPanel {
|
||||
|
||||
private final MainPanel mainPanel;
|
||||
|
||||
private final JTable infoTable = new JTable();
|
||||
|
||||
private TagInfo tagInfo = new TagInfo();
|
||||
|
||||
public TagInfoPanel(MainPanel mainPanel) {
|
||||
this.mainPanel = mainPanel;
|
||||
infoTable.setModel(new InfoTableModel("general"));
|
||||
setLayout(new BorderLayout());
|
||||
infoTable.setAutoCreateRowSorter(true);
|
||||
add(new JScrollPane(infoTable), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public void setTagInfos(TagInfo tagInfo) {
|
||||
this.tagInfo = tagInfo;
|
||||
infoTable.setBackground(Color.WHITE);
|
||||
infoTable.setModel(new InfoTableModel("general"));
|
||||
}
|
||||
|
||||
private class InfoTableModel implements TableModel {
|
||||
|
||||
private final String categoryName;
|
||||
|
||||
public InfoTableModel(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
List<TagInfo.TagInfoItem> category = tagInfo.getInfos().get(categoryName);
|
||||
if (category != null) {
|
||||
return category.size();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return mainPanel.translate("tagInfo.header.name");
|
||||
case 1:
|
||||
return mainPanel.translate("tagInfo.header.value");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
List<TagInfo.TagInfoItem> category = tagInfo.getInfos().get(categoryName);
|
||||
if (category != null) {
|
||||
TagInfo.TagInfoItem item = category.get(rowIndex);
|
||||
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
String name = item.getName();
|
||||
String key = "tagInfo." + name;
|
||||
try {
|
||||
name = mainPanel.translate(key);
|
||||
} catch (MissingResourceException mes) {
|
||||
if (Configuration.debugMode.get()) {
|
||||
Logger.getLogger(TagInfoPanel.class.getName()).log(Level.WARNING, "Resource not found: {0}", key);
|
||||
}
|
||||
}
|
||||
|
||||
return name;
|
||||
case 1:
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTableModelListener(TableModelListener l) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTableModelListener(TableModelListener l) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,3 +589,16 @@ button.resolveConstants = Resolve constants
|
||||
button.viewConstants = View Constants
|
||||
work.exported = Exported
|
||||
button.replaceAlphaChannel = Replace alpha channel...
|
||||
|
||||
tagInfo.header.name = Name
|
||||
tagInfo.header.value = Value
|
||||
tagInfo.tagType = Tag Type
|
||||
tagInfo.characterId = Character Id
|
||||
tagInfo.offset = Offset
|
||||
tagInfo.length = Length
|
||||
tagInfo.bounds = Bounds
|
||||
tagInfo.width = Width
|
||||
tagInfo.height = Height
|
||||
tagInfo.neededCharacters = Needed Characters
|
||||
|
||||
|
||||
|
||||
@@ -529,7 +529,7 @@ public class TagTreeContextMenu extends JPopupMenu {
|
||||
for (TreeItem item : items) {
|
||||
Set<Tag> copiedTags = new HashSet<>();
|
||||
Set<Tag> newTags = new HashSet<>();
|
||||
LinkedHashSet<Integer> needed = new LinkedHashSet<>();
|
||||
Set<Integer> needed = new LinkedHashSet<>();
|
||||
Map<Integer, Integer> changedCharacterIds = new HashMap<>();
|
||||
|
||||
Tag tag = (Tag) item;
|
||||
|
||||
Reference in New Issue
Block a user