mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-21 17:23:56 +01:00
TU46 Test content and patches
TU46 Test content, added missing commits by amending commit and cherry-picking to new branch, ready for iggy guis and tu46 bug fixes
This commit is contained in:
1 parent
8d6b69f599
commit
ff562d1644
497 files changed
+11187
-771
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.tags.*;
|
||||
import com.jpexs.decompiler.flash.tags.base.*;
|
||||
import com.jpexs.decompiler.flash.types.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class AddDeathMessageLabel {
|
||||
private static final float SCALE = 0.5f;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
System.out.println("Usage: AddDeathMessageLabel <swf_file> [output_file]");
|
||||
System.exit(1);
|
||||
}
|
||||
String inputPath = args[0];
|
||||
String outputPath = args.length > 1 ? args[1] : inputPath;
|
||||
|
||||
SWF swf = new SWF(new FileInputStream(inputPath), false);
|
||||
|
||||
PlaceObject3Tag title = null;
|
||||
Integer respawnY = null;
|
||||
int maxDepth = 0;
|
||||
for (Tag tag : swf.getTags()) {
|
||||
if (tag instanceof PlaceObjectTypeTag) {
|
||||
PlaceObjectTypeTag po = (PlaceObjectTypeTag) tag;
|
||||
if ("DeathMessage".equals(po.getInstanceName())) {
|
||||
System.out.println("DeathMessage already exists in " + inputPath + ", skipping.");
|
||||
return;
|
||||
}
|
||||
if ("Title".equals(po.getInstanceName()) && tag instanceof PlaceObject3Tag) title = (PlaceObject3Tag) tag;
|
||||
if ("Respawn".equals(po.getInstanceName())) respawnY = po.getMatrix().translateY;
|
||||
if (po.getDepth() > maxDepth) maxDepth = po.getDepth();
|
||||
}
|
||||
}
|
||||
if (title == null || respawnY == null) {
|
||||
System.err.println("ERROR: Title or Respawn not found in " + inputPath);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
int centreX = (swf.displayRect.Xmax + swf.displayRect.Xmin) / 2;
|
||||
int titleX = title.matrix.translateX;
|
||||
int titleY = title.matrix.translateY;
|
||||
|
||||
PlaceObject3Tag label = new PlaceObject3Tag(swf);
|
||||
label.placeFlagHasClassName = title.placeFlagHasClassName;
|
||||
label.placeFlagHasName = true;
|
||||
label.placeFlagHasMatrix = true;
|
||||
label.placeFlagHasImage = title.placeFlagHasImage;
|
||||
label.placeFlagHasCharacter = title.placeFlagHasCharacter;
|
||||
label.placeFlagMove = title.placeFlagMove;
|
||||
label.className = title.className;
|
||||
label.characterId = title.characterId;
|
||||
label.name = "DeathMessage";
|
||||
label.depth = maxDepth + 1;
|
||||
MATRIX m = new MATRIX(title.matrix);
|
||||
m.hasScale = true;
|
||||
m.scaleX = title.matrix.scaleX * SCALE;
|
||||
m.scaleY = title.matrix.scaleY * SCALE;
|
||||
m.translateX = centreX - Math.round((centreX - titleX) * SCALE);
|
||||
m.translateY = titleY + Math.round((respawnY - titleY) * 0.4f);
|
||||
label.matrix = m;
|
||||
label.setModified(true);
|
||||
|
||||
List<Tag> tags = swf.getTags().toArrayList();
|
||||
swf.addTag(tags.indexOf(title) + 1, label);
|
||||
|
||||
System.out.println(inputPath + ": DeathMessage at " + m.translateX + "," + m.translateY + " depth=" + label.depth);
|
||||
try (FileOutputStream fos = new FileOutputStream(outputPath)) {
|
||||
swf.saveTo(fos);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user