tag editor fixes

This commit is contained in:
Honfika
2014-02-08 21:35:54 +01:00
parent 2e3893313d
commit 9f20bd9f8c
21 changed files with 90 additions and 18 deletions

View File

@@ -706,6 +706,7 @@ public class Action implements GraphSourceItem {
/**
* Converts list of actions to ActionScript source code
*
* @param asm
* @param actions List of actions
* @param version SWF version
* @param path

View File

@@ -529,6 +529,7 @@ public class ActionListReader {
*
* @param actions
* @param index
* @param version
* @param removeWhenLast
* @return
*/

View File

@@ -37,6 +37,7 @@ public class FontPreviewDialog extends AppDialog {
/**
* Creates new form FontPreviewDialog
* @param parent
* @param font
* @param modal
*/

View File

@@ -23,10 +23,7 @@ import com.jpexs.decompiler.flash.gui.generictageditors.StringEditor;
import com.jpexs.decompiler.flash.gui.helpers.SpringUtilities;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.ZONEDATA;
import com.jpexs.decompiler.flash.types.ZONERECORD;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import java.awt.BorderLayout;
import java.awt.Component;
@@ -40,7 +37,6 @@ import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SpringLayout;
/**
@@ -133,6 +129,9 @@ public class GenericTagPanel extends JPanel {
}
private int generateEditControlsRecursive(Object obj, String parent) {
if (obj == null) {
return 0;
}
Field[] fields = obj.getClass().getDeclaredFields();
int propCount = 0;
for (Field field : fields) {
@@ -169,8 +168,12 @@ public class GenericTagPanel extends JPanel {
}
private int addEditor(String name, Object obj, Field field, int index, Class<?> type, Object value) throws IllegalArgumentException, IllegalAccessException {
Component editor;
Calculated calculated = field.getAnnotation(Calculated.class);
if (calculated != null) {
return 0;
}
SWFType swfType = field.getAnnotation(SWFType.class);
Component editor;
if (type.equals(int.class) || type.equals(Integer.class) ||
type.equals(short.class) || type.equals(Short.class) ||
type.equals(long.class) || type.equals(Long.class) ||
@@ -181,17 +184,13 @@ public class GenericTagPanel extends JPanel {
editor = new BooleanEditor(obj, field, index, type);
} else if (type.equals(String.class)) {
editor = new StringEditor(obj, field, index, type);
} else if (type.equals(RECT.class)
|| type.equals(RGB.class)
|| type.equals(ZONERECORD.class)
|| type.equals(ZONEDATA.class)) {
// todo: add other swf releated classes
return generateEditControlsRecursive(value, field.getName() + ".");
} else {
JTextArea textArea = new JTextArea(value.toString());
return generateEditControlsRecursive(value, field.getName() + ".");
/*} else {
JTextArea textArea = new JTextArea(value == null ? "" : value.toString());
textArea.setLineWrap(true);
textArea.setEditable(false);
editor = textArea;
editor = textArea;*/
}
JLabel label = new JLabel(name + ":", JLabel.TRAILING);
@@ -215,7 +214,7 @@ public class GenericTagPanel extends JPanel {
}
result += "]";
} else if (!swfType.countField().equals("")) {
result += "[" + swfType.count();
result += "[" + swfType.countField();
if (swfType.countAdd() > 0) {
result += " + " + swfType.countAdd();
}

View File

@@ -90,7 +90,9 @@ public class NumberEditor extends JSpinner implements GenericTagEditor {
case UB: {
long max = 1;
if (swfType.count() > 0) {
max <<= (swfType.count());
max <<= swfType.count();
} else {
max <<= 31;
}
m = new SpinnerNumberModel((Number) toLong(value), 0L, (long) max - 1, 1L);
}
@@ -104,12 +106,16 @@ public class NumberEditor extends JSpinner implements GenericTagEditor {
m = new SpinnerNumberModel(toInt(value), -0x80, 0x7f, 1);
break;
case SI16:
case FLOAT16:
m = new SpinnerNumberModel(toInt(value), -0x8000, 0x7fff, 1);
break;
case FB:
case SB: {
long max = 1;
if (swfType.count() > 0) {
max <<= (swfType.count() - 1);
} else {
max <<= 30;
}
m = new SpinnerNumberModel((Number) toLong(value), (long) (-max), (long) max - 1, 1L);
}
@@ -117,9 +123,7 @@ public class NumberEditor extends JSpinner implements GenericTagEditor {
case SI32:
m = new SpinnerNumberModel(toDouble(value), -0x80000000, 0x7fffffff, 1);
break;
case FB:
case FLOAT:
case FLOAT16:
case FIXED:
case FIXED8:
m = new SpinnerNumberModel(toDouble(value), -0x80000000, 0x7fffffff, 0.01);
@@ -149,6 +153,12 @@ public class NumberEditor extends JSpinner implements GenericTagEditor {
}
private long toLong(Object value) {
if (value instanceof Short) {
return (long) (Short) value;
}
if (value instanceof Integer) {
return (long) (Integer) value;
}
if (value instanceof Long) {
return (long) (Long) value;
}

View File

@@ -144,6 +144,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/

View File

@@ -76,6 +76,7 @@ public class DoActionTag extends Tag implements ASMSource {
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/

View File

@@ -106,6 +106,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/

View File

@@ -35,6 +35,7 @@ public interface ASMSource extends TreeItem {
*
* @param version SWF version
* @param exportMode PCode or hex?
* @param writer
* @param actions
* @return ASM source
* @throws java.lang.InterruptedException

View File

@@ -160,6 +160,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem {
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/

View File

@@ -166,6 +166,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem {
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.filters.Filtering;
import com.jpexs.helpers.SerializableImage;
@@ -36,6 +37,7 @@ public class CXFORM {
* Has color multiply values
*/
public boolean hasMultTerms;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int nbits;
/**

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.filters.Filtering;
@@ -86,6 +87,7 @@ public class CXFORMWITHALPHA {
@SWFType(value = BasicType.SB, countField = "nbits")
public int alphaAddTerm;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int nbits;

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import java.awt.Point;
@@ -72,12 +73,15 @@ public class MATRIX implements Serializable {
@SWFType(value = BasicType.SB, countField = "nTranslateBits")
public int translateY;
@Calculated
@SWFType(value = BasicType.UB, count = 5)
public int nTranslateBits;
@Calculated
@SWFType(value = BasicType.UB, count = 5)
public int nRotateBits;
@Calculated
@SWFType(value = BasicType.UB, count = 5)
public int nScaleBits;

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import java.awt.Point;
import java.io.Serializable;
@@ -51,6 +52,7 @@ public class RECT implements Serializable {
@SWFType(value = BasicType.SB, countField = "nbits")
public int Ymax;
@Calculated
@SWFType(value = BasicType.UB, count = 5)
public int nbits;

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2014 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.types.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Field is internal
*
* @author JPEXS
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Calculated {
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.types.shaperecords;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
/**
@@ -29,6 +30,7 @@ public class CurvedEdgeRecord extends SHAPERECORD {
public boolean typeFlag = true;
public boolean straightFlag = false;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int numBits;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.types.shaperecords;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -40,6 +41,8 @@ public class StraightEdgeRecord extends SHAPERECORD {
*/
public int typeFlag = 1;
public int straightFlag = 1;
@Calculated
@SWFType(value = BasicType.UB, count = 4)
public int numBits;
public boolean generalLineFlag;

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY;
import com.jpexs.decompiler.flash.types.LINESTYLEARRAY;
import com.jpexs.decompiler.flash.types.annotations.Calculated;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import java.util.Set;
@@ -39,6 +40,7 @@ public class StyleChangeRecord extends SHAPERECORD implements Cloneable {
public boolean stateFillStyle0;
public boolean stateMoveTo;
@Calculated
@SWFType(value = BasicType.UB, count = 5)
@Conditional("stateMoveTo")
public int moveBits;
@@ -69,9 +71,11 @@ public class StyleChangeRecord extends SHAPERECORD implements Cloneable {
@Conditional("stateNewStyles")
public LINESTYLEARRAY lineStyles;
@Calculated
@Conditional("stateNewStyles")
public int numFillBits;
@Calculated
@Conditional("stateNewStyles")
public int numLineBits;

View File

@@ -787,6 +787,7 @@ public interface WinNT extends WinError, WinDef, WinBase, BaseTSD {
/**
* Override to the appropriate object for INVALID_HANDLE_VALUE.
* @param nativeValue
* @param context
* @return
*/

View File

@@ -195,6 +195,7 @@ public interface WinUser extends StdCallLibrary, WinDef {
/**
* Return whether to continue enumeration.
* @param hWnd
* @param data
* @return
*/