mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-29 17:56:11 +00:00
AS1/2 execution improvements - yet a lot to do
This commit is contained in:
@@ -18,6 +18,24 @@ public class ActionScriptObject implements Cloneable {
|
||||
protected Object extendsObj;
|
||||
protected List<Object> implementsObjs = new ArrayList<>();
|
||||
|
||||
public void clearMembers() {
|
||||
for (Object o : members.values()) {
|
||||
if (o instanceof ActionScriptObject) {
|
||||
((ActionScriptObject) o).clear();
|
||||
}
|
||||
}
|
||||
members.clear();
|
||||
}
|
||||
|
||||
public void clearProperties() {
|
||||
properties.clear();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
clearMembers();
|
||||
clearProperties();
|
||||
}
|
||||
|
||||
public List<Object> getImplementsObjs() {
|
||||
return implementsObjs;
|
||||
}
|
||||
@@ -121,6 +139,10 @@ public class ActionScriptObject implements Cloneable {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Object getThisMember(String name) {
|
||||
return members.get(name);
|
||||
}
|
||||
|
||||
public Object getMember(String path) {
|
||||
String pathParts[];
|
||||
if (path.startsWith("/")) {
|
||||
@@ -131,13 +153,15 @@ public class ActionScriptObject implements Cloneable {
|
||||
ActionScriptObject obj = this;
|
||||
for (int i = 0; i < pathParts.length; i++) {
|
||||
String part = pathParts[i];
|
||||
Object member = obj.getMember(part);
|
||||
if (i == pathParts.length - 1) {
|
||||
return member;
|
||||
} else if (member instanceof ActionScriptObject) {
|
||||
obj = (ActionScriptObject) member;
|
||||
return obj.getThisMember(part);
|
||||
} else {
|
||||
break;
|
||||
Object member = obj.getMember(part);
|
||||
if (member instanceof ActionScriptObject) {
|
||||
obj = (ActionScriptObject) member;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DepthStateObjectAdapter extends ActionScriptObject {
|
||||
|
||||
protected DepthState ds;
|
||||
|
||||
public DepthStateObjectAdapter(DepthState ds) {
|
||||
this.ds = ds;
|
||||
}
|
||||
|
||||
//TODO
|
||||
}
|
||||
@@ -13,8 +13,8 @@ public class DisplayObject extends ActionScriptObject {
|
||||
|
||||
protected Map<Integer, Object> displayList = new HashMap<>();
|
||||
|
||||
protected int totalFrames;
|
||||
protected int currentFrame;
|
||||
protected int totalFrames = 1;
|
||||
protected int currentFrame = 1;
|
||||
protected boolean paused = false;
|
||||
protected boolean dragging = false;
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ public class LocalDataArea {
|
||||
localRegisters.clear();
|
||||
withs.clear();
|
||||
functions.clear();
|
||||
stage.clear();
|
||||
jump = null;
|
||||
returnValue = null;
|
||||
executionException = null;
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
package com.jpexs.decompiler.flash.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.ReadOnlyTagList;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.timeline.DepthState;
|
||||
import com.jpexs.decompiler.flash.timeline.Frame;
|
||||
import com.jpexs.decompiler.flash.timeline.Timeline;
|
||||
import com.jpexs.decompiler.flash.timeline.Timelined;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
@@ -7,15 +19,73 @@ package com.jpexs.decompiler.flash.action;
|
||||
public class Stage extends DisplayObject {
|
||||
|
||||
protected long startTime;
|
||||
protected Timelined timelined;
|
||||
protected Timeline timeline;
|
||||
protected Frame frame;
|
||||
|
||||
public Stage() {
|
||||
public Stage(Timelined timelined) {
|
||||
startTime = System.currentTimeMillis();
|
||||
this.timelined = timelined;
|
||||
this.timeline = timelined != null ? timelined.getTimeline() : null;
|
||||
this.frame = timelined != null ? this.timeline.getFrame(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> enumerate() {
|
||||
List<String> ret = new ArrayList<>();
|
||||
if (frame != null) {
|
||||
for (DepthState ds : frame.layers.values()) {
|
||||
if (ds.instanceName != null) {
|
||||
ret.add(ds.instanceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getThisMember(String name) {
|
||||
if (frame != null) {
|
||||
for (DepthState ds : frame.layers.values()) {
|
||||
if (name.equals(ds.instanceName)) {
|
||||
return new DepthStateObjectAdapter(ds);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return System.currentTimeMillis() - startTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalFrames() {
|
||||
if (timeline == null) {
|
||||
return 1;
|
||||
}
|
||||
return timeline.getFrameCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gotoFrame(int frameNum) {
|
||||
super.gotoFrame(frameNum);
|
||||
if (timeline != null) {
|
||||
this.frame = timeline.getFrame(getCurrentFrame() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gotoLabel(String label) {
|
||||
if (timeline == null) {
|
||||
return;
|
||||
}
|
||||
int f = timeline.getFrameWithLabel(label);
|
||||
if (f != -1) {
|
||||
gotoFrame(f + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSounds() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user