use dropdown control for enum type values in raw editor

This commit is contained in:
honfika@gmail.com
2016-12-18 12:14:38 +01:00
parent 0f406e2a9c
commit fba49bb876
14 changed files with 426 additions and 28 deletions

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.types.ALPHABITMAPDATA;
import com.jpexs.decompiler.flash.types.ALPHACOLORMAPDATA;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -54,6 +55,8 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
public static final String NAME = "DefineBitsLossless2";
@SWFType(BasicType.UI8)
@EnumValue(value = FORMAT_8BIT_COLORMAPPED, text = "8-bit colormapped")
@EnumValue(value = FORMAT_32BIT_ARGB, text = "32-bit ARGB")
public int bitmapFormat;
@SWFType(BasicType.UI16)
@@ -241,10 +244,10 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
ALPHACOLORMAPDATA colorMapData = null;
ALPHABITMAPDATA bitmapData = null;
if (bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED) {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
colorMapData = getColorMapData();
}
if (bitmapFormat == DefineBitsLossless2Tag.FORMAT_32BIT_ARGB) {
if (bitmapFormat == FORMAT_32BIT_ARGB) {
bitmapData = getBitmapData();
}
int pos32aligned = 0;
@@ -252,13 +255,13 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
for (int y = 0; y < bitmapHeight; y++) {
for (int x = 0; x < bitmapWidth; x++) {
int c = 0;
if ((bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED)) {
if ((bitmapFormat == FORMAT_8BIT_COLORMAPPED)) {
int colorTableIndex = colorMapData.colorMapPixelData[pos32aligned] & 0xff;
if (colorTableIndex < colorMapData.colorTableRGB.length) {
c = colorMapData.colorTableRGB[colorTableIndex];
}
}
if ((bitmapFormat == DefineBitsLossless2Tag.FORMAT_32BIT_ARGB)) {
if ((bitmapFormat == FORMAT_32BIT_ARGB)) {
c = bitmapData.bitmapPixelData[pos];
}

View File

@@ -28,6 +28,7 @@ import com.jpexs.decompiler.flash.types.BITMAPDATA;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.COLORMAPDATA;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.HideInRawEdit;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -54,6 +55,9 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
public static final String NAME = "DefineBitsLossless";
@SWFType(BasicType.UI8)
@EnumValue(value = FORMAT_8BIT_COLORMAPPED, text = "8-bit colormapped")
@EnumValue(value = FORMAT_15BIT_RGB, text = "15-bit RGB")
@EnumValue(value = FORMAT_24BIT_RGB, text = "24-bit RGB")
public int bitmapFormat;
@SWFType(BasicType.UI16)
@@ -232,7 +236,7 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
@Override
protected SerializableImage getImage() {
int[] pixels = new int[bitmapWidth * bitmapHeight];
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
if (bitmapFormat == FORMAT_8BIT_COLORMAPPED) {
COLORMAPDATA colorMapData = getColorMapData();
int pos32aligned = 0;
int pos = 0;
@@ -252,13 +256,13 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
pos32aligned++;
}
}
} else if ((bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) || (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB)) {
} else if ((bitmapFormat == FORMAT_15BIT_RGB) || (bitmapFormat == FORMAT_24BIT_RGB)) {
BITMAPDATA bitmapData = getBitmapData();
int pos = 0;
int[] bitmapPixelData = null;
if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
if (bitmapFormat == FORMAT_15BIT_RGB) {
bitmapPixelData = bitmapData.bitmapPixelDataPix15;
} else if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
} else if (bitmapFormat == FORMAT_24BIT_RGB) {
bitmapPixelData = bitmapData.bitmapPixelDataPix24;
}

View File

@@ -52,6 +52,7 @@ import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.RGBA;
import com.jpexs.decompiler.flash.types.TEXTRECORD;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.helpers.ByteArrayRange;
@@ -146,6 +147,10 @@ public class DefineEditTextTag extends TextTag {
@SWFType(BasicType.UI8)
@Conditional("hasLayout")
@EnumValue(value = ALIGN_LEFT, text = "Left")
@EnumValue(value = ALIGN_RIGHT, text = "Right")
@EnumValue(value = ALIGN_CENTER, text = "Center")
@EnumValue(value = ALIGN_JUSTIFY, text = "Justify")
public int align;
@SWFType(BasicType.UI16)
@@ -169,6 +174,14 @@ public class DefineEditTextTag extends TextTag {
@Conditional("hasText")
public String initialText;
public static final int ALIGN_LEFT = 0;
public static final int ALIGN_RIGHT = 1;
public static final int ALIGN_CENTER = 2;
public static final int ALIGN_JUSTIFY = 3;
/**
* Constructor
*
@@ -1103,16 +1116,16 @@ public class DefineEditTextTag extends TextTag {
yOffset += currentOffset;
int alignOffset = 0;
switch (align) {
case 0: // left
case ALIGN_LEFT:
alignOffset = 0;
break;
case 1: // right
case ALIGN_RIGHT:
alignOffset = bounds.getWidth() - width;
break;
case 2: // center
case ALIGN_CENTER:
alignOffset = (bounds.getWidth() - width) / 2;
break;
case 3: // justify
case ALIGN_JUSTIFY:
// todo;
break;
}

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.ZONERECORD;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFArray;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -46,6 +47,9 @@ public class DefineFontAlignZonesTag extends Tag implements CharacterIdTag {
public int fontID;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = 0, text = "Thin")
@EnumValue(value = 1, text = "Medium")
@EnumValue(value = 2, text = "Thick")
public int CSMTableHint;
@Reserved

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.SoundTag;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
import com.jpexs.decompiler.flash.types.sound.MP3FRAME;
@@ -57,9 +58,21 @@ public class DefineSoundTag extends CharacterTag implements SoundTag {
public int soundId;
@SWFType(value = BasicType.UB, count = 4)
@EnumValue(value = SoundFormat.FORMAT_UNCOMPRESSED_NATIVE_ENDIAN, text = "Uncompressed, native-endian")
@EnumValue(value = SoundFormat.FORMAT_ADPCM, text = "ADPCM")
@EnumValue(value = SoundFormat.FORMAT_MP3, text = "MP3", minSwfVersion = 4)
@EnumValue(value = SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN, text = "Uncompressed, little-endian", minSwfVersion = 4)
@EnumValue(value = SoundFormat.FORMAT_NELLYMOSER16KHZ, text = "Nellymoser 16 kHz", minSwfVersion = 10)
@EnumValue(value = SoundFormat.FORMAT_NELLYMOSER8KHZ, text = "Nellymoser 8 kHz", minSwfVersion = 10)
@EnumValue(value = SoundFormat.FORMAT_NELLYMOSER, text = "Nellymoser", minSwfVersion = 6)
@EnumValue(value = SoundFormat.FORMAT_SPEEX, text = "Speex", minSwfVersion = 10)
public int soundFormat;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = 0, text = "5.5 kHz")
@EnumValue(value = 1, text = "11 kHz")
@EnumValue(value = 2, text = "22 kHz")
@EnumValue(value = 3, text = "44 kHz")
public int soundRate;
public boolean soundSize;

View File

@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.timeline.Timeline;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -51,6 +52,10 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
public int reserved;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = 0, text = "5.5 kHz")
@EnumValue(value = 1, text = "11 kHz")
@EnumValue(value = 2, text = "22 kHz")
@EnumValue(value = 3, text = "44 kHz")
public int playBackSoundRate;
public boolean playBackSoundSize;
@@ -58,9 +63,15 @@ public class SoundStreamHeadTag extends Tag implements SoundStreamHeadTypeTag {
public boolean playBackSoundType;
@SWFType(value = BasicType.UB, count = 4)
@EnumValue(value = SoundFormat.FORMAT_ADPCM, text = "ADPCM")
@EnumValue(value = SoundFormat.FORMAT_MP3, text = "MP3", minSwfVersion = 4)
public int streamSoundCompression;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = 0, text = "5.5 kHz")
@EnumValue(value = 1, text = "11 kHz")
@EnumValue(value = 2, text = "22 kHz")
@EnumValue(value = 3, text = "44 kHz")
public int streamSoundRate;
public boolean streamSoundSize;

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.tags.DefineShape3Tag;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.ConditionalType;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
@@ -33,6 +34,14 @@ import java.util.Set;
public class FILLSTYLE implements NeedsCharacters, Serializable {
@SWFType(BasicType.UI8)
@EnumValue(value = SOLID, text = "Solid")
@EnumValue(value = LINEAR_GRADIENT, text = "Linear gradient")
@EnumValue(value = RADIAL_GRADIENT, text = "Radial gradient")
@EnumValue(value = FOCAL_RADIAL_GRADIENT, text = "Focal radial gradient", minSwfVersion = 8)
@EnumValue(value = REPEATING_BITMAP, text = "Repeating bitmap")
@EnumValue(value = CLIPPED_BITMAP, text = "Clipped bitmap")
@EnumValue(value = NON_SMOOTHED_REPEATING_BITMAP, text = "Non smoothed repeating bitmap")
@EnumValue(value = NON_SMOOTHED_CLIPPED_BITMAP, text = "Non smoothed clipped bitmap")
public int fillStyleType;
public static final int SOLID = 0x0;

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.Reserved;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import java.io.Serializable;
@@ -29,9 +30,15 @@ import java.util.Set;
public class LINESTYLE2 extends LINESTYLE implements Serializable {
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = ROUND_CAP, text = "Round cap")
@EnumValue(value = NO_CAP, text = "No cap")
@EnumValue(value = SQUARE_CAP, text = "Square cap")
public int startCapStyle;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = ROUND_JOIN, text = "Round join")
@EnumValue(value = BEVEL_JOIN, text = "Bevel join")
@EnumValue(value = MITER_JOIN, text = "Miter join")
public int joinStyle;
public static final int ROUND_CAP = 0;
@@ -61,10 +68,13 @@ public class LINESTYLE2 extends LINESTYLE implements Serializable {
public boolean noClose;
@SWFType(value = BasicType.UB, count = 2)
@EnumValue(value = ROUND_CAP, text = "Round cap")
@EnumValue(value = NO_CAP, text = "No cap")
@EnumValue(value = SQUARE_CAP, text = "Square cap")
public int endCapStyle;
@SWFType(BasicType.FIXED8)
@Conditional(value = "joinStyle", options = MITER_JOIN)
@Conditional(value = "joinStyle", options = {MITER_JOIN})
public float miterLimitFactor;
public FILLSTYLE fillType;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.tags.base.NeedsCharacters;
import com.jpexs.decompiler.flash.types.annotations.Conditional;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import java.io.Serializable;
import java.util.Set;
@@ -29,6 +30,14 @@ import java.util.Set;
public class MORPHFILLSTYLE implements NeedsCharacters, Serializable {
@SWFType(BasicType.UI8)
@EnumValue(value = SOLID, text = "Solid")
@EnumValue(value = LINEAR_GRADIENT, text = "Linear gradient")
@EnumValue(value = RADIAL_GRADIENT, text = "Radial gradient")
@EnumValue(value = FOCAL_RADIAL_GRADIENT, text = "Focal radial gradient", minSwfVersion = 8)
@EnumValue(value = REPEATING_BITMAP, text = "Repeating bitmap")
@EnumValue(value = CLIPPED_BITMAP, text = "Clipped bitmap")
@EnumValue(value = NON_SMOOTHED_REPEATING_BITMAP, text = "Non smoothed repeating bitmap")
@EnumValue(value = NON_SMOOTHED_CLIPPED_BITMAP, text = "Non smoothed clipped bitmap")
public int fillStyleType;
public static final int SOLID = 0x0;

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2016 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.
* License along with this library.
*/
package com.jpexs.decompiler.flash.types.annotations;
import java.lang.annotation.ElementType;

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2010-2016 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.types.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author JPEXS
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Repeatable(EnumValues.class)
public @interface EnumValue {
int value();
String text();
// todo: check in generic tag editor
int minSwfVersion() default 1;
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2010-2016 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.types.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* @author JPEXS
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface EnumValues {
EnumValue[] value();
}