mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-18 00:01:55 +00:00
pack and sort character id func moved to library
This commit is contained in:
@@ -2885,6 +2885,43 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
}
|
||||
}
|
||||
|
||||
public void packCharacterIds() {
|
||||
int maxId = getNextCharacterId();
|
||||
int id = 1;
|
||||
for (int i = 1; i < maxId; i++) {
|
||||
CharacterTag charactertag = getCharacter(i);
|
||||
if (charactertag != null) {
|
||||
if (i != id) {
|
||||
replaceCharacter(i, id);
|
||||
}
|
||||
id++;
|
||||
} else {
|
||||
// make sure that the id is not referenced in the tags
|
||||
replaceCharacter(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sortCharacterIds() {
|
||||
int maxId = Math.max(tags.size(), getNextCharacterId());
|
||||
int id = maxId;
|
||||
// first set the chatacter ids to surely not used ids
|
||||
for (Tag tag : tags) {
|
||||
if (tag instanceof CharacterTag) {
|
||||
CharacterTag characterTag = (CharacterTag) tag;
|
||||
replaceCharacter(characterTag.getCharacterId(), id++);
|
||||
}
|
||||
}
|
||||
// then set them to 1,2,3...
|
||||
id = 1;
|
||||
for (Tag tag : tags) {
|
||||
if (tag instanceof CharacterTag) {
|
||||
CharacterTag characterTag = (CharacterTag) tag;
|
||||
replaceCharacter(characterTag.getCharacterId(), id++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean replaceCharacter(int oldCharacterId, int newCharacterId) {
|
||||
boolean modified = false;
|
||||
for (Tag tag : tags) {
|
||||
|
||||
@@ -2172,38 +2172,9 @@ public class CommandLineArgumentParser {
|
||||
SWF swf = new SWF(is, Configuration.parallelSpeedUp.get());
|
||||
String arg = args.pop().toLowerCase();
|
||||
if (arg.equals("pack")) {
|
||||
int maxId = swf.getNextCharacterId();
|
||||
int id = 1;
|
||||
for (int i = 1; i < maxId; i += 2) {
|
||||
CharacterTag charactertag = swf.getCharacter(i);
|
||||
if (charactertag != null) {
|
||||
if (i != id) {
|
||||
swf.replaceCharacter(i, id);
|
||||
}
|
||||
id++;
|
||||
} else {
|
||||
// make sure that the id is not referenced in the tags
|
||||
swf.replaceCharacter(i, 0);
|
||||
}
|
||||
}
|
||||
swf.packCharacterIds();
|
||||
} else if (arg.equals("sort")) {
|
||||
int maxId = Math.max(swf.tags.size(), swf.getNextCharacterId());
|
||||
int id = maxId;
|
||||
// first set the chatacter ids to surely not used ids
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof CharacterTag) {
|
||||
CharacterTag characterTag = (CharacterTag) tag;
|
||||
swf.replaceCharacter(characterTag.getCharacterId(), id++);
|
||||
}
|
||||
}
|
||||
// then set them to 1,2,3...
|
||||
id = 1;
|
||||
for (Tag tag : swf.tags) {
|
||||
if (tag instanceof CharacterTag) {
|
||||
CharacterTag characterTag = (CharacterTag) tag;
|
||||
swf.replaceCharacter(characterTag.getCharacterId(), id++);
|
||||
}
|
||||
}
|
||||
swf.sortCharacterIds();
|
||||
} else {
|
||||
String[] characterIdsStr = arg.split(",");
|
||||
if (characterIdsStr.length % 2 != 0) {
|
||||
|
||||
Reference in New Issue
Block a user