mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-31 19:54:37 +00:00
#825 hot keys (and maybe new buttons on new panel) to switch to next or previous DefineText
This commit is contained in:
@@ -121,7 +121,7 @@ public class TextExporter {
|
||||
public void run() throws IOException {
|
||||
fos.write(Utf8Helper.getBytes("ID: " + textTag.getCharacterId() + Helper.newLine));
|
||||
if (settings.mode == TextExportMode.FORMATTED) {
|
||||
fos.write(Utf8Helper.getBytes(textTag.getFormattedText()));
|
||||
fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text));
|
||||
} else {
|
||||
String separator = Configuration.textExportSingleFileRecordSeparator.get();
|
||||
separator = Helper.newLine + separator + Helper.newLine;
|
||||
@@ -149,7 +149,7 @@ public class TextExporter {
|
||||
public void run() throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
if (settings.mode == TextExportMode.FORMATTED) {
|
||||
fos.write(Utf8Helper.getBytes(textTag.getFormattedText()));
|
||||
fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text));
|
||||
} else {
|
||||
String separator = Configuration.textExportSingleFileRecordSeparator.get();
|
||||
separator = Helper.newLine + separator + Helper.newLine;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.helpers.hilight;
|
||||
|
||||
/**
|
||||
@@ -27,5 +28,6 @@ public enum HighlightSpecialType {
|
||||
SLOT_ID, DISP_ID,
|
||||
FLAG_NEED_REST, FLAG_EXPLICIT, FLAG_HAS_OPTIONAL, FLAG_HAS_PARAM_NAMES,
|
||||
FLAG_IGNORE_REST, FLAG_NEED_ACTIVATION, FLAG_NEED_ARGUMENTS, FLAG_SET_DXNS,
|
||||
FLAG_IGNORE_REST, FLAG_NEED_ACTIVATION, FLAG_NEED_ARGUMENTS, FLAG_SET_DXNS,
|
||||
TRY_TYPE, TRY_NAME,
|
||||
TEXT
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TextImporter {
|
||||
TextTag textTag = (TextTag) tag;
|
||||
if (textTag.getCharacterId() == characterId) {
|
||||
String[] currentRecords = records.get(characterId);
|
||||
String text = textTag.getFormattedText();
|
||||
String text = textTag.getFormattedText().text;
|
||||
if (!saveText(textTag, text, currentRecords)) {
|
||||
return;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class TextImporter {
|
||||
if (tag instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) tag;
|
||||
if (textTag.getCharacterId() == characterId) {
|
||||
String text = textTag.getFormattedText();
|
||||
String text = textTag.getFormattedText().text;
|
||||
if (!saveText(textTag, text, records)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,13 @@ 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.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
@@ -357,9 +361,9 @@ public class DefineEditTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText() {
|
||||
String ret = "";
|
||||
ret += "[";
|
||||
public HighlightedText getFormattedText() {
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
writer.append("[");
|
||||
String[] alignNames = {"left", "right", "center", "justify"};
|
||||
String alignment;
|
||||
if (align < alignNames.length) {
|
||||
@@ -367,22 +371,70 @@ public class DefineEditTextTag extends TextTag {
|
||||
} else {
|
||||
alignment = "unknown";
|
||||
}
|
||||
ret += "\r\nxmin " + bounds.Xmin + "\r\nymin " + bounds.Ymin + "\r\nxmax " + bounds.Xmax + "\r\nymax " + bounds.Ymax + "\r\n";
|
||||
ret += (wordWrap ? "wordwrap 1\r\n" : "") + (multiline ? "multiline 1\r\n" : "")
|
||||
+ (password ? "password 1\r\n" : "") + (readOnly ? "readonly 1\r\n" : "")
|
||||
+ (autoSize ? "autosize 1\r\n" : "") + (noSelect ? "noselect 1\r\n" : "")
|
||||
+ (border ? "border 1\r\n" : "") + (wasStatic ? "wasstatic 1\r\n" : "")
|
||||
+ (html ? "html 1\r\n" : "") + (useOutlines ? "useoutlines 1\r\n" : "")
|
||||
+ (hasFont ? "font " + fontId + "\r\n" + "height " + fontHeight + "\r\n" : "") + (hasTextColor ? "color " + textColor.toHexARGB() + "\r\n" : "")
|
||||
+ (hasFontClass ? "fontclass " + fontClass + "\r\n" : "") + (hasMaxLength ? "maxlength " + maxLength + "\r\n" : "")
|
||||
+ "align " + alignment + "\r\n"
|
||||
+ (hasLayout ? "leftmargin " + leftMargin + "\r\nrightmargin " + rightMargin + "\r\nindent " + indent + "\r\nleading " + leading + "\r\n" : "")
|
||||
+ (!variableName.isEmpty() ? "variablename " + variableName + "\r\n" : "");
|
||||
ret += "]";
|
||||
if (hasText) {
|
||||
ret += initialText.replace("\\", "\\\\").replace("[", "\\[").replace("]", "\\]");
|
||||
writer.newLine();
|
||||
writer.append("xmin " + bounds.Xmin).newLine();
|
||||
writer.append("ymin " + bounds.Ymin).newLine();
|
||||
writer.append("xmax " + bounds.Xmax).newLine();
|
||||
writer.append("ymax " + bounds.Ymax).newLine();
|
||||
if (wordWrap) {
|
||||
writer.append("wordwrap 1").newLine();
|
||||
}
|
||||
return ret;
|
||||
if (multiline) {
|
||||
writer.append("multiline 1").newLine();
|
||||
}
|
||||
if (password) {
|
||||
writer.append("password 1").newLine();
|
||||
}
|
||||
if (readOnly) {
|
||||
writer.append("readonly 1").newLine();
|
||||
}
|
||||
if (autoSize) {
|
||||
writer.append("autosize 1").newLine();
|
||||
}
|
||||
if (noSelect) {
|
||||
writer.append("noselect 1").newLine();
|
||||
}
|
||||
if (border) {
|
||||
writer.append("border 1").newLine();
|
||||
}
|
||||
if (wasStatic) {
|
||||
writer.append("wasstatic 1").newLine();
|
||||
}
|
||||
if (html) {
|
||||
writer.append("html 1").newLine();
|
||||
}
|
||||
if (useOutlines) {
|
||||
writer.append("useoutlines 1").newLine();
|
||||
}
|
||||
if (hasFont) {
|
||||
writer.append("font " + fontId).newLine();
|
||||
writer.append("height " + fontHeight).newLine();
|
||||
}
|
||||
if (hasTextColor) {
|
||||
writer.append("color " + textColor.toHexARGB()).newLine();
|
||||
}
|
||||
if (hasFontClass) {
|
||||
writer.append("fontclass " + fontClass).newLine();
|
||||
}
|
||||
if (hasMaxLength) {
|
||||
writer.append("maxlength " + maxLength).newLine();
|
||||
}
|
||||
writer.append("align " + alignment).newLine();
|
||||
if (hasLayout) {
|
||||
writer.append("leftmargin " + leftMargin).newLine();
|
||||
writer.append("rightmargin " + rightMargin).newLine();
|
||||
writer.append("indent " + indent).newLine();
|
||||
writer.append("leading " + leading).newLine();
|
||||
}
|
||||
if (!variableName.isEmpty()) {
|
||||
writer.append("variablename " + variableName).newLine();
|
||||
}
|
||||
writer.append("]");
|
||||
if (hasText) {
|
||||
String text = initialText.replace("\\", "\\\\").replace("[", "\\[").replace("]", "\\]");
|
||||
writer.hilightSpecial(text, HighlightSpecialType.TEXT);
|
||||
}
|
||||
return new HighlightedText(writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,9 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
@@ -127,56 +130,58 @@ public class DefineText2Tag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText() {
|
||||
public HighlightedText getFormattedText() {
|
||||
FontTag fnt = null;
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("[\r\nxmin ").append(textBounds.Xmin).
|
||||
append("\r\nymin ").append(textBounds.Ymin).
|
||||
append("\r\nxmax ").append(textBounds.Xmax).
|
||||
append("\r\nymax ").append(textBounds.Ymax);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
writer.append("[").newLine();
|
||||
writer.append("xmin " + textBounds.Xmin).newLine();
|
||||
writer.append("ymin " + textBounds.Ymin).newLine();
|
||||
writer.append("xmax " + textBounds.Xmax).newLine();
|
||||
writer.append("ymax " + textBounds.Ymax).newLine();
|
||||
if (textMatrix.translateX != 0) {
|
||||
ret.append("\r\ntranslatex ").append(textMatrix.translateX);
|
||||
writer.append("translatex " + textMatrix.translateX).newLine();
|
||||
}
|
||||
if (textMatrix.translateY != 0) {
|
||||
ret.append("\r\ntranslatey ").append(textMatrix.translateY);
|
||||
writer.append("translatey " + textMatrix.translateY).newLine();
|
||||
}
|
||||
if (textMatrix.hasScale) {
|
||||
ret.append("\r\nscalex ").append(textMatrix.scaleX);
|
||||
ret.append("\r\nscaley ").append(textMatrix.scaleY);
|
||||
writer.append("scalex " + textMatrix.scaleX).newLine();
|
||||
writer.append("scaley " + textMatrix.scaleY).newLine();
|
||||
}
|
||||
if (textMatrix.hasRotate) {
|
||||
ret.append("\r\nrotateskew0 ").append(textMatrix.rotateSkew0);
|
||||
ret.append("\r\nrotateskew1 ").append(textMatrix.rotateSkew1);
|
||||
writer.append("rotateskew0 " + textMatrix.rotateSkew0).newLine();
|
||||
writer.append("rotateskew1 " + textMatrix.rotateSkew1).newLine();
|
||||
}
|
||||
ret.append("\r\n]");
|
||||
writer.append("]");
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
String params = "";
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
break;
|
||||
if (rec.styleFlagsHasFont || rec.styleFlagsHasColor || rec.styleFlagsHasXOffset || rec.styleFlagsHasYOffset) {
|
||||
writer.append("[").newLine();
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.append("font " + rec.fontId).newLine();
|
||||
writer.append("height " + rec.textHeight).newLine();
|
||||
}
|
||||
params += "\r\nfont " + rec.fontId + "\r\nheight " + rec.textHeight;
|
||||
if (rec.styleFlagsHasColor) {
|
||||
writer.append("color " + rec.textColorA.toHexARGB()).newLine();
|
||||
}
|
||||
if (rec.styleFlagsHasXOffset) {
|
||||
writer.append("x " + rec.xOffset).newLine();
|
||||
}
|
||||
if (rec.styleFlagsHasYOffset) {
|
||||
writer.append("y " + rec.yOffset).newLine();
|
||||
}
|
||||
writer.append("]");
|
||||
}
|
||||
if (rec.styleFlagsHasColor) {
|
||||
params += "\r\ncolor " + rec.textColorA.toHexARGB();
|
||||
}
|
||||
if (rec.styleFlagsHasXOffset) {
|
||||
params += "\r\nx " + rec.xOffset;
|
||||
}
|
||||
if (rec.styleFlagsHasYOffset) {
|
||||
params += "\r\ny " + rec.yOffset;
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
ret.append("[").append(params).append("\r\n]");
|
||||
}
|
||||
ret.append(Helper.escapeString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"));
|
||||
writer.hilightSpecial(Helper.escapeString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"), HighlightSpecialType.TEXT);
|
||||
}
|
||||
return ret.toString();
|
||||
return new HighlightedText(writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,9 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
|
||||
import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.HighlightSpecialType;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.FontTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
|
||||
@@ -128,61 +131,63 @@ public class DefineTextTag extends TextTag {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText() {
|
||||
public HighlightedText getFormattedText() {
|
||||
FontTag fnt = null;
|
||||
StringBuilder ret = new StringBuilder();
|
||||
ret.append("[\r\nxmin ").append(textBounds.Xmin).
|
||||
append("\r\nymin ").append(textBounds.Ymin).
|
||||
append("\r\nxmax ").append(textBounds.Xmax).
|
||||
append("\r\nymax ").append(textBounds.Ymax);
|
||||
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
writer.append("[").newLine();
|
||||
writer.append("xmin " + textBounds.Xmin).newLine();
|
||||
writer.append("ymin " + textBounds.Ymin).newLine();
|
||||
writer.append("xmax " + textBounds.Xmax).newLine();
|
||||
writer.append("ymax " + textBounds.Ymax).newLine();
|
||||
if (textMatrix.translateX != 0) {
|
||||
ret.append("\r\ntranslatex ").append(textMatrix.translateX);
|
||||
writer.append("translatex " + textMatrix.translateX).newLine();
|
||||
}
|
||||
if (textMatrix.translateY != 0) {
|
||||
ret.append("\r\ntranslatey ").append(textMatrix.translateY);
|
||||
writer.append("translatey " + textMatrix.translateY).newLine();
|
||||
}
|
||||
if (textMatrix.hasScale) {
|
||||
ret.append("\r\nscalex ").append(textMatrix.scaleX);
|
||||
ret.append("\r\nscaley ").append(textMatrix.scaleY);
|
||||
writer.append("scalex " + textMatrix.scaleX).newLine();
|
||||
writer.append("scaley " + textMatrix.scaleY).newLine();
|
||||
}
|
||||
if (textMatrix.hasRotate) {
|
||||
ret.append("\r\nrotateskew0 ").append(textMatrix.rotateSkew0);
|
||||
ret.append("\r\nrotateskew1 ").append(textMatrix.rotateSkew1);
|
||||
writer.append("rotateskew0 " + textMatrix.rotateSkew0).newLine();
|
||||
writer.append("rotateskew1 " + textMatrix.rotateSkew1).newLine();
|
||||
}
|
||||
ret.append("\r\n]");
|
||||
writer.append("]");
|
||||
for (TEXTRECORD rec : textRecords) {
|
||||
String params = "";
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
break;
|
||||
if (rec.styleFlagsHasFont || rec.styleFlagsHasColor || rec.styleFlagsHasXOffset || rec.styleFlagsHasYOffset) {
|
||||
writer.append("[").newLine();
|
||||
if (rec.styleFlagsHasFont) {
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof FontTag) {
|
||||
if (((FontTag) t).getFontId() == rec.fontId) {
|
||||
fnt = ((FontTag) t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.append("font " + rec.fontId).newLine();
|
||||
writer.append("height " + rec.textHeight).newLine();
|
||||
}
|
||||
params += "\r\nfont " + rec.fontId + "\r\nheight " + rec.textHeight;
|
||||
}
|
||||
if (rec.styleFlagsHasColor) {
|
||||
params += "\r\ncolor " + rec.textColor.toHexRGB();
|
||||
}
|
||||
if (rec.styleFlagsHasXOffset) {
|
||||
params += "\r\nx " + rec.xOffset;
|
||||
}
|
||||
if (rec.styleFlagsHasYOffset) {
|
||||
params += "\r\ny " + rec.yOffset;
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
ret.append("[").append(params).append("\r\n]");
|
||||
if (rec.styleFlagsHasColor) {
|
||||
writer.append("color " + rec.textColor.toHexRGB()).newLine();
|
||||
}
|
||||
if (rec.styleFlagsHasXOffset) {
|
||||
writer.append("x " + rec.xOffset).newLine();
|
||||
}
|
||||
if (rec.styleFlagsHasYOffset) {
|
||||
writer.append("y " + rec.yOffset).newLine();
|
||||
}
|
||||
writer.append("]");
|
||||
}
|
||||
|
||||
if (fnt == null) {
|
||||
ret.append(AppResources.translate("fontNotFound").replace("%fontId%", Integer.toString(rec.fontId)));
|
||||
writer.append(AppResources.translate("fontNotFound").replace("%fontId%", Integer.toString(rec.fontId)));
|
||||
} else {
|
||||
ret.append(Helper.escapeString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"));
|
||||
writer.hilightSpecial(Helper.escapeString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"), HighlightSpecialType.TEXT);
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
return new HighlightedText(writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.exporters.modes.FontExportMode;
|
||||
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.helpers.HighlightedText;
|
||||
import com.jpexs.decompiler.flash.importers.TextImportResizeTextBoundsMode;
|
||||
import com.jpexs.decompiler.flash.tags.text.JustifyAlignGlyphEntry;
|
||||
import com.jpexs.decompiler.flash.tags.text.TextAlign;
|
||||
@@ -81,7 +82,7 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
|
||||
|
||||
public abstract List<Integer> getFontIds();
|
||||
|
||||
public abstract String getFormattedText();
|
||||
public abstract HighlightedText getFormattedText();
|
||||
|
||||
// use the texts from the "texts" argument when it is not null
|
||||
public abstract boolean setFormattedText(MissingCharacterHandler missingCharHandler, String formattedText, String[] texts) throws TextParseException;
|
||||
|
||||
Reference in New Issue
Block a user