mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-10 18:05:01 +00:00
Fixed Raw editor now checks whether field value can be placed inside this kind of tag
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
* 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;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.DefineButton2Tag;
|
||||
@@ -85,6 +86,7 @@ public class BUTTONRECORD implements Serializable {
|
||||
/**
|
||||
* If within DefineButton2Tag: Character color transform
|
||||
*/
|
||||
@Conditional(tags = {DefineButton2Tag.ID})
|
||||
public CXFORMWITHALPHA colorTransform;
|
||||
|
||||
/**
|
||||
@@ -92,6 +94,7 @@ public class BUTTONRECORD implements Serializable {
|
||||
* this button
|
||||
*/
|
||||
@SWFArray("filter")
|
||||
@Conditional(value = "buttonHasFilterList", tags = {DefineButton2Tag.ID})
|
||||
public List<FILTER> filterList;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.types;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.DefineMorphShape2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineMorphShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.annotations.Conditional;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -24,8 +27,10 @@ import java.io.Serializable;
|
||||
*/
|
||||
public class MORPHLINESTYLEARRAY implements Serializable {
|
||||
|
||||
@Conditional(tags = {DefineMorphShapeTag.ID})
|
||||
public MORPHLINESTYLE[] lineStyles;
|
||||
|
||||
@Conditional(tags = {DefineMorphShape2Tag.ID})
|
||||
public MORPHLINESTYLE2[] lineStyles2;
|
||||
|
||||
public LINESTYLEARRAY getLineStylesAt(int shapeNum, int ratio) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.types.annotations.Conditional;
|
||||
import com.jpexs.decompiler.flash.types.annotations.ConditionalType;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -33,13 +34,19 @@ import java.util.Stack;
|
||||
public class ConditionEvaluator {
|
||||
|
||||
private final String[] values;
|
||||
private final int[] tags;
|
||||
private final boolean revert;
|
||||
|
||||
public ConditionEvaluator(Conditional cond) {
|
||||
values = cond.value();
|
||||
tags = cond.tags();
|
||||
revert = cond.revert();
|
||||
}
|
||||
|
||||
public ConditionEvaluator(ConditionalType cond) {
|
||||
values = cond.value();
|
||||
tags = cond.tags();
|
||||
revert = cond.revert();
|
||||
}
|
||||
|
||||
private void expressionRest(Map<String, Boolean> fields, Stack<Boolean> stack, ConditionLexer lex) throws IOException, AnnotationParseException {
|
||||
@@ -98,7 +105,25 @@ public class ConditionEvaluator {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean eval(Map<String, Boolean> fields) throws AnnotationParseException {
|
||||
public boolean eval(Map<String, Boolean> fields, int parentTagId) throws AnnotationParseException {
|
||||
boolean result;
|
||||
if (tags.length > 0) {
|
||||
boolean tagFound = false;
|
||||
for (int i = 0; i < tags.length; i++) {
|
||||
if (tags[i] == parentTagId) {
|
||||
tagFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tagFound) {
|
||||
result = false;
|
||||
if (revert) {
|
||||
return !result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
ConditionLexer lex = new ConditionLexer(new StringReader(prepareCond()));
|
||||
|
||||
Stack<Boolean> stack = new Stack<>();
|
||||
@@ -109,13 +134,21 @@ public class ConditionEvaluator {
|
||||
throw new AnnotationParseException("Invalid condition:" + prepareCond(), lex.yyline());
|
||||
}
|
||||
if (prepareCond().isEmpty()) {
|
||||
return true;
|
||||
result = true;
|
||||
if (revert) {
|
||||
return !result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (stack.size() != 1) {
|
||||
throw new AnnotationParseException("Invalid condition:" + prepareCond(), lex.yyline());
|
||||
}
|
||||
|
||||
return stack.pop();
|
||||
result = stack.pop();
|
||||
if (revert) {
|
||||
return !result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String prepareCond() {
|
||||
|
||||
Reference in New Issue
Block a user