Added: #1644 Save all button - has priority over standard Save button

Changed: Save to EXE moved to tools tab
Changed: Save (not save as) button are now available only when there's anything to save when the selected SWF is modified. Similar for Save all button.
This commit is contained in:
Jindra Petřík
2024-08-02 19:33:53 +02:00
parent 449f96942e
commit cbcc2dc88a
9 changed files with 97 additions and 18 deletions

View File

@@ -1244,6 +1244,31 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
os.write(newCompressedData);
}
}
public void saveNestedDefineBinaryData() {
Map<Integer, CharacterTag> chtags = getCharacters(false);
for (CharacterTag t : chtags.values()) {
if (t instanceof DefineBinaryDataTag) {
DefineBinaryDataTag dbd = (DefineBinaryDataTag) t;
if (dbd.innerSwf != null && dbd.innerSwf.isModified()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
SWF swf = (SWF) dbd.innerSwf;
swf.saveNestedDefineBinaryData();
swf.saveTo(baos);
byte[] data = baos.toByteArray();
swf.binaryData.setDataBytes(new ByteArrayRange(data));
swf.binaryData.setModified(true);
swf.binaryData.getTopLevelBinaryData().pack();
dbd.innerSwf.clearModified();
} catch (IOException ex) {
Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex);
}
dbd.setModified(true);
}
}
}
}
public byte[] getHeaderBytes() {
return getHeaderBytes(compression, gfx, encrypted);