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/VideoWall.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/VideoWall.java')
| -rw-r--r-- | NET/worlds/scape/VideoWall.java | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/NET/worlds/scape/VideoWall.java b/NET/worlds/scape/VideoWall.java new file mode 100644 index 0000000..9969c71 --- /dev/null +++ b/NET/worlds/scape/VideoWall.java @@ -0,0 +1,191 @@ +package NET.worlds.scape; + +import NET.worlds.core.IniFile; +import NET.worlds.network.URL; +import java.io.IOException; + +public class VideoWall extends Rect { + VideoSurface _surface = null; + Texture[] _textures; + Material _material = null; + String _textureURL = "http://dev.worlds.net/rr-worlds/video/fatboy.asf"; + String _defTextureURL = IniFile.override().getIniString("defaultAd", "adworlds.cmp"); + int _xSurface = 140; + int _ySurface = 104; + boolean _autoPlay = true; + int _autoPlayRepeats = 1; + int _rows = 1; + private static Object classCookie = new Object(); + + private void rebuild() { + this.unbuild(); + int xTex = this._xSurface / 128 + 1; + int yTex = this._ySurface / 128 + 1; + this._surface = null; + this._rows = yTex; + this._material = new Material(URL.make(this._defTextureURL), xTex, yTex); + this.setMaterial(this._material); + this._textures = this._material.getTextures(); + this._surface = VideoManager.get(this._textureURL, yTex, this._xSurface, this._ySurface); + if (this._autoPlay) { + this._surface.play(1); + } + } + + @Override + public void finalize() { + this.unbuild(); + super.finalize(); + } + + @Override + public void detach() { + this.unbuild(); + super.detach(); + } + + private void unbuild() { + if (this._surface != null) { + this._surface.stop(); + VideoManager.release(this._surface); + this._surface = null; + } + } + + public void changeURL(String newURL, int width, int height) { + this._textureURL = new String(newURL); + this._xSurface = width; + this._ySurface = height; + this.rebuild(); + } + + @Override + public boolean handle(FrameEvent f) { + this.getState(); + if (this.visible) { + this.draw(); + } + + return false; + } + + @Override + public void prerender(Camera cam) { + Point3Temp p = this.inCamSpace(cam); + boolean v = p != null && p.z > 1.0F && p.x < p.z && -p.x < p.z; + if (v) { + this.visible = true; + } + } + + public VideoSurface getVideoSurface() { + return this._surface; + } + + public synchronized void draw() { + if (this._surface != null) { + this._surface.draw(this._material.getTextures(), this._rows); + } + } + + public int getState() { + return this._surface != null ? this._surface.tick() : 0; + } + + @Override + public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException { + Object ret = null; + switch (index - offset) { + case 0: + if (mode == 0) { + ret = StringPropertyEditor.make(new Property(this, index, "Video URL")); + } else if (mode == 1) { + ret = this._textureURL; + } else if (mode == 2) { + this._textureURL = (String)value; + this.rebuild(); + } + break; + case 1: + if (mode == 0) { + ret = IntegerPropertyEditor.make(new Property(this, index, "Video Width (pixels)"), 0, 1024); + } else if (mode == 1) { + ret = new Integer(this._xSurface); + } else if (mode == 2) { + this._xSurface = (Integer)value; + this.rebuild(); + } + break; + case 2: + if (mode == 0) { + ret = IntegerPropertyEditor.make(new Property(this, index, "Video Height (pixels)"), 0, 1024); + } else if (mode == 1) { + ret = new Integer(this._ySurface); + } else if (mode == 2) { + this._ySurface = (Integer)value; + this.rebuild(); + } + break; + case 3: + if (mode == 0) { + ret = BooleanPropertyEditor.make(new Property(this, index, "Auto-play?"), "No", "Yes"); + } else if (mode == 1) { + ret = new Boolean(this._autoPlay); + } else if (mode == 2) { + this._autoPlay = (Boolean)value; + this.rebuild(); + } + break; + case 4: + if (mode == 0) { + ret = IntegerPropertyEditor.make(new Property(this, index, "Repeats for Autoplay (-1 = infinite)"), -1, 1024); + } else if (mode == 1) { + ret = new Integer(this._autoPlayRepeats); + } else if (mode == 2) { + this._autoPlayRepeats = (Integer)value; + this.rebuild(); + } + break; + default: + ret = super.properties(index, offset + 5, mode, value); + } + + return ret; + } + + @Override + public void saveState(Saver s) throws IOException { + s.saveVersion(1, classCookie); + super.saveState(s); + s.saveString(this._textureURL); + s.saveInt(this._xSurface); + s.saveInt(this._ySurface); + s.saveBoolean(this._autoPlay); + s.saveInt(this._autoPlayRepeats); + } + + @Override + public void restoreState(Restorer r) throws IOException, TooNewException { + switch (r.restoreVersion(classCookie)) { + case 0: + super.restoreState(r); + this._textureURL = r.restoreString(); + this._xSurface = r.restoreInt(); + this._ySurface = r.restoreInt(); + this._autoPlay = r.restoreBoolean(); + break; + case 1: + super.restoreState(r); + this._textureURL = r.restoreString(); + this._xSurface = r.restoreInt(); + this._ySurface = r.restoreInt(); + this._autoPlay = r.restoreBoolean(); + this._autoPlayRepeats = r.restoreInt(); + break; + default: + throw new TooNewException(); + } + + this.rebuild(); + } +} |