Issue #453 Update definetext only when the current font is used by that tag

This commit is contained in:
Honfika
2013-12-28 18:35:18 +01:00
parent 0cc9a0c1b2
commit 22ee2cce32
5 changed files with 38 additions and 2 deletions
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.tags.DefineTextTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
@@ -259,12 +260,15 @@ public class FontPanel extends JPanel implements ActionListener {
oldchars += c;
}
int fontId = ft.getFontId();
if (updateTextsCheckBox.isSelected()) {
for (Tag tag : swf.tags) {
if (tag instanceof TextTag) {
TextTag textTag = (TextTag) tag;
String text = textTag.getFormattedText(textTag.getSwf().tags);
mainPanel.saveText(textTag, text);
if (textTag.getFontIds(swf.tags).contains(fontId)) {
String text = textTag.getFormattedText(textTag.getSwf().tags);
mainPanel.saveText(textTag, text);
}
}
}
}
@@ -34,6 +34,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -139,6 +140,13 @@ public class DefineEditTextTag extends TextTag {
return ret;
}
@Override
public List<Integer> getFontIds(List<Tag> tags) {
List<Integer> ret = new ArrayList<>();
ret.add(fontId);
return ret;
}
@Override
public String getFormattedText(List<Tag> tags) {
String ret = "";
@@ -102,6 +102,17 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
return ret;
}
@Override
public List<Integer> getFontIds(List<Tag> tags) {
List<Integer> ret = new ArrayList<>();
for (TEXTRECORD rec : textRecords) {
if (rec.styleFlagsHasFont) {
ret.add(rec.fontId);
}
}
return ret;
}
@Override
public String getFormattedText(List<Tag> tags) {
FontTag fnt = null;
@@ -102,6 +102,17 @@ public class DefineTextTag extends TextTag implements DrawableTag {
return ret;
}
@Override
public List<Integer> getFontIds(List<Tag> tags) {
List<Integer> ret = new ArrayList<>();
for (TEXTRECORD rec : textRecords) {
if (rec.styleFlagsHasFont) {
ret.add(rec.fontId);
}
}
return ret;
}
@Override
public String getFormattedText(List<Tag> tags) {
FontTag fnt = null;
@@ -54,6 +54,8 @@ public abstract class TextTag extends CharacterTag implements BoundedTag {
public abstract String getText(List<Tag> tags);
public abstract List<Integer> getFontIds(List<Tag> tags);
public abstract String getFormattedText(List<Tag> tags);
public abstract boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text) throws ParseException;