Fixed #2175 Removing DefineButtonSound, warning about incorrect sound character type in FLA export

This commit is contained in:
Jindra Petřík
2024-01-04 20:07:59 +01:00
parent 3b9e8b9c30
commit 8951ff5155
4 changed files with 89 additions and 6 deletions

View File

@@ -162,4 +162,66 @@ public class DefineButtonSoundTag extends Tag implements CharacterIdTag {
public String toString() {
return super.toString() + " (" + buttonId + ")";
}
@Override
public boolean removeCharacter(int characterId) {
boolean modified = false;
if (buttonSoundChar0 == characterId) {
buttonSoundChar0 = 0;
buttonSoundInfo0 = null;
modified = true;
}
if (buttonSoundChar1 == characterId) {
buttonSoundChar1 = 0;
buttonSoundInfo1 = null;
modified = true;
}
if (buttonSoundChar2 == characterId) {
buttonSoundChar2 = 0;
buttonSoundInfo2 = null;
modified = true;
}
if (buttonSoundChar3 == characterId) {
buttonSoundChar3 = 0;
buttonSoundInfo3 = null;
modified = true;
}
if (modified) {
setModified(true);
}
return modified;
}
@Override
public boolean replaceCharacter(int oldCharacterId, int newCharacterId) {
boolean modified = false;
if (buttonId == oldCharacterId) {
buttonId = newCharacterId;
modified = true;
}
if (buttonSoundChar0 == oldCharacterId) {
buttonSoundChar0 = newCharacterId;
modified = true;
}
if (buttonSoundChar1 == oldCharacterId) {
buttonSoundChar1 = newCharacterId;
modified = true;
}
if (buttonSoundChar2 == oldCharacterId) {
buttonSoundChar2 = newCharacterId;
modified = true;
}
if (buttonSoundChar3 == oldCharacterId) {
buttonSoundChar3 = newCharacterId;
modified = true;
}
if (modified) {
setModified(true);
}
return modified;
}
}

View File

@@ -1811,8 +1811,15 @@ public class XFLConverter {
"index", Integer.toString(frame - 1),
"keyMode", Integer.toString(KEY_MODE_NORMAL)});
if (soundChar > 0) {
DefineSoundTag sound = (DefineSoundTag) swf.getCharacter(soundChar);
convertSoundUsage(symbolStr, sound, soundInfo);
CharacterTag soundCharTag = swf.getCharacter(soundChar);
if (soundCharTag == null) {
logger.log(Level.WARNING, "Sound tag (ID={0}) was not found", soundChar);
} else if (soundCharTag instanceof DefineSoundTag) {
DefineSoundTag sound = (DefineSoundTag) soundCharTag;
convertSoundUsage(symbolStr, sound, soundInfo);
} else {
logger.log(Level.WARNING, "Tag (ID={0}) expected to be DefineSound, {1} found. It is referenced from DefineButtonSound({2}).", new Object[] {soundChar, soundCharTag.getClass().getSimpleName(), defineButtonSound.buttonId});
}
}
symbolStr.writeStartElement("elements");
symbolStr.writeEndElement(); //elements