From afd2f04f24d85c8dbe048855ece0aa791c24a8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 5 Mar 2021 19:31:05 +0100 Subject: [PATCH] refactoring --- .../decompiler/flash/xfl/XFLConverter.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 7d3bf8b3a..30d24e1db 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -1459,15 +1459,15 @@ public class XFLConverter { return date.getTime() / 1000; } - private void convertLibrary(Map soundExportNames, SWF swf, Map characterVariables, Map characterClasses, Map characterScriptPacks, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion, XFLXmlWriter writer) throws XMLStreamException { + private void convertLibrary(SWF swf, Map characterVariables, Map characterClasses, Map characterScriptPacks, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion, XFLXmlWriter writer) throws XMLStreamException { //TODO: Imported assets //linkageImportForRS="true" linkageIdentifier="xxx" linkageURL="yyy.swf" - convertMedia(soundExportNames, swf, characterVariables, characterClasses, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer); - convertSymbols(soundExportNames, swf, characterVariables, characterClasses, characterScriptPacks, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer); + convertMedia(swf, characterVariables, characterClasses, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer); + convertSymbols(swf, characterVariables, characterClasses, characterScriptPacks, nonLibraryShapes, backgroundColor, tags, characters, files, datfiles, flaVersion, writer); } - private void convertSymbols(Map soundExportNames, SWF swf, Map characterVariables, Map characterClasses, Map characterScriptPacks, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion, XFLXmlWriter writer) throws XMLStreamException { + private void convertSymbols(SWF swf, Map characterVariables, Map characterClasses, Map characterScriptPacks, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion, XFLXmlWriter writer) throws XMLStreamException { boolean hasSymbol = false; for (int ch : characters.keySet()) { CharacterTag symbol = characters.get(ch); @@ -1520,9 +1520,9 @@ public class XFLConverter { } } - DefineButtonSoundTag sound = button.getSounds(); + DefineButtonSoundTag defineButtonSound = button.getSounds(); int soundLayerOffset = 0; - if (sound != null) { + if (defineButtonSound != null) { soundLayerOffset = 1; symbolStr.writeStartElement("DOMLayer", new String[]{"name", "Layer 1"}); symbolStr.writeStartElement("frames"); @@ -1532,27 +1532,29 @@ public class XFLConverter { SOUNDINFO soundInfo = null; switch (frame) { case 1: - soundChar = sound.buttonSoundChar0; - soundInfo = sound.buttonSoundInfo0; + soundChar = defineButtonSound.buttonSoundChar0; + soundInfo = defineButtonSound.buttonSoundInfo0; break; case 2: - soundChar = sound.buttonSoundChar1; - soundInfo = sound.buttonSoundInfo1; + soundChar = defineButtonSound.buttonSoundChar1; + soundInfo = defineButtonSound.buttonSoundInfo1; break; case 3: - soundChar = sound.buttonSoundChar2; - soundInfo = sound.buttonSoundInfo2; + soundChar = defineButtonSound.buttonSoundChar2; + soundInfo = defineButtonSound.buttonSoundInfo2; break; case 4: - soundChar = sound.buttonSoundChar3; - soundInfo = sound.buttonSoundInfo3; + soundChar = defineButtonSound.buttonSoundChar3; + soundInfo = defineButtonSound.buttonSoundInfo3; break; } symbolStr.writeStartElement("DOMFrame", new String[]{ "index", Integer.toString(frame - 1), "keyMode", Integer.toString(KEY_MODE_NORMAL),}); if (soundChar > 0) { - symbolStr.writeAttribute("soundName", soundExportNames.get(soundChar)); + DefineSoundTag sound = (DefineSoundTag) swf.getCharacter(soundChar); + + symbolStr.writeAttribute("soundName", "sound" + soundChar + "." + sound.getExportFormat().toString().toLowerCase()); if (soundInfo.hasLoops) { if (soundInfo.loopCount == 32767) { symbolStr.writeAttribute("soundLoopMode", "loop"); @@ -1716,7 +1718,7 @@ public class XFLConverter { continue; } final ScriptPack spriteScriptPack = characterScriptPacks.containsKey(sprite.spriteId) ? characterScriptPacks.get(sprite.spriteId) : null; - convertTimeline(soundExportNames, sprite.spriteId, nonLibraryShapes, backgroundColor, tags, sprite.getTags(), characters, "Symbol " + symbol.getCharacterId(), flaVersion, files, symbolStr, spriteScriptPack); + convertTimeline(sprite.spriteId, nonLibraryShapes, backgroundColor, tags, sprite.getTags(), characters, "Symbol " + symbol.getCharacterId(), flaVersion, files, symbolStr, spriteScriptPack); } else if (symbol instanceof ShapeTag) { itemIcon = "1"; @@ -1761,7 +1763,7 @@ public class XFLConverter { } } - private void convertMedia(Map soundExportNames, SWF swf, Map characterVariables, Map characterClasses, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion, XFLXmlWriter writer) throws XMLStreamException { + private void convertMedia(SWF swf, Map characterVariables, Map characterClasses, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, HashMap characters, HashMap files, HashMap datfiles, FLAVersion flaVersion, XFLXmlWriter writer) throws XMLStreamException { boolean hasMedia = false; for (int ch : characters.keySet()) { CharacterTag symbol = characters.get(ch); @@ -1994,7 +1996,6 @@ public class XFLConverter { } String symbolFile = "sound" + symbol.getCharacterId() + "." + exportFormat; - soundExportNames.put(symbol.getCharacterId(), symbolFile); files.put(symbolFile, data); writer.writeStartElement("DOMSoundItem", new String[]{ "name", symbolFile, @@ -2862,7 +2863,7 @@ public class XFLConverter { return outlineColor.toHexRGB(); } - private void convertTimeline(Map soundExportNames, int spriteId, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, ReadOnlyTagList timelineTags, HashMap characters, String name, FLAVersion flaVersion, HashMap files, XFLXmlWriter writer, ScriptPack scriptPack) throws XMLStreamException { + private void convertTimeline(int spriteId, List nonLibraryShapes, String backgroundColor, ReadOnlyTagList tags, ReadOnlyTagList timelineTags, HashMap characters, String name, FLAVersion flaVersion, HashMap files, XFLXmlWriter writer, ScriptPack scriptPack) throws XMLStreamException { writer.writeStartElement("DOMTimeline", new String[]{"name", name}); writer.writeStartElement("layers"); @@ -3464,12 +3465,11 @@ public class XFLConverter { } convertFonts(swf.getTags(), domDocument); - Map soundExportNames = new HashMap<>(); - convertLibrary(soundExportNames, swf, characterVariables, characterClasses, characterScriptPacks, nonLibraryShapes, backgroundColor, swf.getTags(), characters, files, datfiles, flaVersion, domDocument); + convertLibrary(swf, characterVariables, characterClasses, characterScriptPacks, nonLibraryShapes, backgroundColor, swf.getTags(), characters, files, datfiles, flaVersion, domDocument); domDocument.writeStartElement("timelines"); ScriptPack documentScriptPack = characterScriptPacks.containsKey(0) ? characterScriptPacks.get(0) : null; - convertTimeline(soundExportNames, 0, nonLibraryShapes, backgroundColor, swf.getTags(), swf.getTags(), characters, "Scene 1", flaVersion, files, domDocument, documentScriptPack); + convertTimeline(0, nonLibraryShapes, backgroundColor, swf.getTags(), swf.getTags(), characters, "Scene 1", flaVersion, files, domDocument, documentScriptPack); domDocument.writeEndElement(); if (hasAmfMetadata) {