diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/ScapePicTexture.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/ScapePicTexture.java')
| -rw-r--r-- | NET/worlds/scape/ScapePicTexture.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/NET/worlds/scape/ScapePicTexture.java b/NET/worlds/scape/ScapePicTexture.java new file mode 100644 index 0000000..b2dd1ed --- /dev/null +++ b/NET/worlds/scape/ScapePicTexture.java @@ -0,0 +1,94 @@ +package NET.worlds.scape; + +import NET.worlds.console.Console; +import java.io.IOException; +import java.text.MessageFormat; + +public class ScapePicTexture extends Texture implements Persister { + private int w; + private int h; + private String _urlName; + private ScapePicMovie _movie; + private int _movieFrame; + private static Object classCookie = new Object(); + + static { + nativeInit(); + } + + public ScapePicTexture(String urlName, String filename) { + this._urlName = urlName; + this.makeTexture(urlName, filename); + } + + public ScapePicTexture() { + } + + public static native void nativeInit(); + + @Override + public int getW() { + return this.w; + } + + @Override + public int getH() { + return this.h; + } + + private native void makeTexture(String var1, String var2); + + @Override + public String getName() { + return this._urlName; + } + + @Override + public void saveState(Saver s) throws IOException { + s.saveVersion(1, classCookie); + super.saveState(s); + if (this._movie != null) { + s.saveBoolean(true); + s.save(this._movie); + s.saveInt(this._movieFrame); + } else { + s.saveBoolean(false); + s.saveString(this._urlName); + } + } + + @Override + public void restoreState(Restorer r) throws IOException, TooNewException { + switch (r.restoreVersion(classCookie)) { + case 0: + super.restoreState(r); + r.restoreBoolean(); + break; + case 1: + super.restoreState(r); + break; + default: + throw new TooNewException(); + } + + if (r.restoreBoolean()) { + this._movie = (ScapePicMovie)r.restore(); + this._movieFrame = r.restoreInt(); + ScapePicTexture t = this._movie.getTexture(this._movieFrame); + if (t == null) { + Object[] arguments = new Object[]{new String("" + this._movieFrame), new String("" + this._movie)}; + Console.println(MessageFormat.format(Console.message("Error-frame"), arguments)); + } else { + this.textureID = t.textureID; + } + } else { + this._urlName = r.restoreString(); + this.makeTexture(this._urlName, this._urlName); + } + } + + @Override + public String toString() { + return this._movie == null ? this._urlName : this._movie.toString(); + } +} |