Playing sounds on stage (StartSound tag)

This commit is contained in:
Jindra Pet��k
2014-03-09 21:01:41 +01:00
parent 218b8553f3
commit 45cf740f1f
14 changed files with 563 additions and 322 deletions
@@ -21,8 +21,10 @@ import com.jpexs.decompiler.flash.exporters.Matrix;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag;
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
import com.jpexs.decompiler.flash.tags.StartSoundTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
@@ -79,6 +81,9 @@ public class Timeline {
this.frameRate = swf.frameRate;
Frame frame = new Frame(this);
for (Tag t : tags) {
if (t instanceof StartSoundTag) {
frame.sounds.add(((StartSoundTag) t).soundId);
}
if (t instanceof SetBackgroundColorTag) {
frame.backgroundColor = ((SetBackgroundColorTag) t).backgroundColor;
}
@@ -174,6 +179,34 @@ public class Timeline {
}
public List<Integer> getSounds(int frame, DepthState stateUnderCursor, int mouseButton) {
List<Integer> ret=new ArrayList<>();
Frame fr = this.frames.get(frame);
ret.addAll(fr.sounds);
for (int d = this.getMaxDepth(); d >= 0; d--) {
DepthState ds = fr.layers.get(d);
if (ds != null) {
CharacterTag c = swf.characters.get(ds.characterId);
if (c instanceof Timelined) {
int dframe = ds.time % ((Timelined)c).getTimeline().frames.size();
if (c instanceof ButtonTag) {
ButtonTag bt = (ButtonTag) c;
dframe = ButtonTag.FRAME_UP;
if (stateUnderCursor == ds) {
if (mouseButton > 0) {
dframe = ButtonTag.FRAME_DOWN;
} else {
dframe = ButtonTag.FRAME_OVER;
}
}
}
ret.addAll(((Timelined)c).getTimeline().getSounds(dframe, stateUnderCursor, mouseButton));
}
}
}
return ret;
}
public Shape getOutline(int frame, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation) {
Frame fr = this.frames.get(frame);
Area area = new Area();