/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.scape.FrameEvent; /* */ import java.awt.Container; /* */ import java.awt.Dimension; /* */ import java.awt.Event; /* */ import java.awt.Graphics; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class AnimationButton /* */ extends ImageCanvas /* */ implements MainCallback, FramePart, DialogDisabled /* */ { /* */ private static final long serialVersionUID = 5605353426438467905L; /* */ private static final int frameInterval = 33; /* */ private String movieName; /* */ private int frameCount; /* */ private int curFrame; /* */ private int width; /* */ private int height; /* */ private boolean playVideoNext; /* 29 */ private int videoHandle = -1; /* */ private boolean isDialogDisabled; /* */ /* */ public AnimationButton(String imageName, int frameCount, String movieName) { /* 33 */ super(imageName); /* 34 */ this.frameCount = frameCount; /* 35 */ this.movieName = movieName; /* */ } /* */ /* */ public void paint(Graphics g) /* */ { /* 40 */ g.clipRect(0, 0, this.width, this.height); /* 41 */ g.drawImage(this.image_, -this.width * this.curFrame, 0, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Dimension getPreferredSize() /* */ { /* 60 */ Dimension d = super.getPreferredSize(); /* 61 */ return new Dimension(this.width = d.width / this.frameCount, this.height = d.height); /* */ } /* */ /* */ public Dimension getMinimumSize() /* */ { /* 66 */ return getPreferredSize(); /* */ } /* */ /* */ public void mainCallback() { /* 70 */ if (this.videoHandle == -1) { /* 71 */ this.videoHandle = Window.playVideoClip(this, this.movieName); /* 72 */ if (this.videoHandle == -1) { /* 73 */ this.videoHandle = Window.playVideoClip(this, "..\\" + this.movieName); /* 74 */ if (this.videoHandle == -1) /* 75 */ Main.unregister(this); /* */ } /* 77 */ } else if (!Window.isVideoPlaying(this.videoHandle)) { /* 78 */ Main.unregister(this); /* 79 */ this.videoHandle = -1; /* 80 */ repaint(); /* */ } /* */ } /* */ /* */ public boolean mouseDown(Event e, int x, int y) /* */ { /* 86 */ if (this.isDialogDisabled) { /* 87 */ return false; /* */ } /* 89 */ if (this.playVideoNext) { /* 90 */ Main.register(this); /* 91 */ this.playVideoNext = false; /* 92 */ } else if (this.videoHandle == -1) { /* 93 */ Graphics g = getGraphics(); /* 94 */ g.clipRect(0, 0, this.width, this.height); /* 95 */ int nextFrameIncr = this.curFrame == 0 ? 1 : -1; /* 96 */ long startTime = System.currentTimeMillis(); /* 97 */ long frameTime = 0L; /* 98 */ for (int i = 1; i < this.frameCount; i++) { /* 99 */ this.curFrame += nextFrameIncr; /* 100 */ g.drawImage(this.image_, -this.width * this.curFrame, 0, null); /* 101 */ long elapsedTime = System.currentTimeMillis() - startTime; /* 102 */ frameTime += 33L; /* 103 */ long sleepTime = frameTime - elapsedTime; /* 104 */ if (sleepTime > 0L) { /* */ try { /* 106 */ Thread.sleep(sleepTime); /* */ } /* */ catch (InterruptedException localInterruptedException) {} /* */ } /* */ } /* 111 */ if (this.curFrame == this.frameCount - 1) /* 112 */ this.playVideoNext = true; /* 113 */ g.dispose(); /* */ } /* 115 */ return true; /* */ } /* */ /* */ /* */ /* */ public void activate(Console c, Container f, Console prev) {} /* */ /* */ /* */ public void deactivate() {} /* */ /* */ /* */ public boolean action(Event event, Object what) /* */ { /* 128 */ return false; /* */ } /* */ /* */ public boolean handle(FrameEvent f) { /* 132 */ return false; /* */ } /* */ /* */ /* */ public void dialogDisable(boolean disable) /* */ { /* 138 */ this.isDialogDisabled = disable; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\AnimationButton.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */