/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.network.URL; /* */ import java.io.DataInputStream; /* */ import java.io.DataOutputStream; /* */ import java.io.IOException; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class VideoTexture /* */ extends Attribute /* */ { /* */ public VideoTexture(int attrID) /* */ { /* 30 */ super(attrID); /* */ } /* */ /* */ /* */ /* */ public VideoTexture() {} /* */ /* */ /* */ protected void noteAddingTo(SuperRoot owner) /* */ { /* 40 */ Rect s = (Rect)((Sharer)owner).getOwner(); /* 41 */ s._videoAttribute = this; /* */ /* 43 */ assignMaterial(s); /* */ } /* */ /* */ private void assignMaterial(Rect s) { /* 47 */ int xTex = this._xSurface / 128; /* 48 */ if (xTex < 1) /* 49 */ xTex = 1; /* 50 */ int yTex = this._ySurface / 128; /* 51 */ if (yTex < 1) { /* 52 */ yTex = 1; /* */ } /* 54 */ this._surface = null; /* */ /* 56 */ this._ds = null; /* */ /* 58 */ this._rows = yTex; /* */ /* 60 */ this._material = new Material(URL.make(this._defTextureURL), xTex, yTex); /* 61 */ s.setMaterial(this._material); /* */ /* 63 */ this._textures = this._material.getTextures(); /* 64 */ this._surface = new TextureSurface(this._textures, yTex, this._xSurface, this._ySurface); /* */ /* 66 */ this._ds = new DirectShow(this._surface.getHwnd()); /* 67 */ this._ds.nOpen(this._textureURL); /* 68 */ if (this._autoPlay) /* 69 */ this._ds.nPlay(1); /* */ } /* */ /* */ private void setTexture() { /* 73 */ Sharer sh = (Sharer)getOwner(); /* 74 */ if (sh == null) { /* 75 */ return; /* */ } /* 77 */ Rect s = (Rect)sh.getOwner(); /* 78 */ assignMaterial(s); /* */ } /* */ /* */ public void detach() /* */ { /* 83 */ Rect s = (Rect)((Sharer)getOwner()).getOwner(); /* 84 */ s._videoAttribute = null; /* 85 */ if (this._ds != null) { /* 86 */ this._ds.nStop(); /* 87 */ this._ds = null; /* */ } /* 89 */ super.detach(); /* */ } /* */ /* */ public void finalize() /* */ { /* 94 */ releaseAuxilaryData(); /* 95 */ super.finalize(); /* */ } /* */ /* 98 */ DirectShow _ds = null; /* */ TextureSurface _surface; /* */ Texture[] _textures; /* 101 */ Material _material = null; /* */ /* */ /* 104 */ String _textureURL = "http://dev.worlds.net/rr-worlds/video/eminem.asf"; /* */ /* */ /* 107 */ String _defTextureURL = IniFile.override().getIniString("defaultAd", /* 108 */ "adworlds.cmp"); /* */ /* */ /* 111 */ int _xSurface = 128; int _ySurface = 128; /* */ /* */ /* 114 */ boolean _autoPlay = true; /* */ /* */ /* 117 */ int _rows = 1; /* */ /* */ public DirectShow getDirectShow() { /* 120 */ return this._ds; /* */ } /* */ /* */ public void videoFrame(FrameEvent f) { /* 124 */ draw(); /* */ } /* */ /* */ /* */ /* */ /* */ public final void noteChange() {} /* */ /* */ /* */ /* */ /* */ public synchronized void draw() /* */ { /* 137 */ if ((this._surface != null) && (this._ds != null)) { /* 138 */ this._surface.setTextures(this._material.getTextures(), this._rows); /* 139 */ this._surface.draw(this._ds); /* */ } /* */ } /* */ /* */ public void generateNetData(DataOutputStream s) throws IOException /* */ { /* 145 */ s.writeUTF(this._textureURL); /* 146 */ s.writeInt(this._xSurface); /* 147 */ s.writeInt(this._ySurface); /* */ } /* */ /* */ public void setFromNetData(DataInputStream ds, int len) throws IOException /* */ { /* 152 */ this._textureURL = ds.readUTF(); /* 153 */ this._xSurface = ds.readInt(); /* 154 */ this._ySurface = ds.readInt(); /* */ /* 156 */ noteChange(); /* 157 */ setTexture(); /* */ } /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 166 */ Object ret = null; /* 167 */ switch (index - offset) /* */ { /* */ case 0: /* 170 */ if (mode == 0) { /* 171 */ ret = StringPropertyEditor.make(new Property(this, index, /* 172 */ "Texture URL")); /* 173 */ } else if (mode == 1) { /* 174 */ ret = this._textureURL; /* 175 */ } else if (mode == 2) { /* 176 */ this._textureURL = ((String)value); /* 177 */ setTexture(); /* */ } /* 179 */ break; /* */ case 1: /* 181 */ if (mode == 0) { /* 182 */ ret = IntegerPropertyEditor.make(new Property(this, index, /* 183 */ "Texture Width"), 0, 1024); /* 184 */ } else if (mode == 1) { /* 185 */ ret = new Integer(this._xSurface); /* 186 */ } else if (mode == 2) { /* 187 */ this._xSurface = ((Integer)value).intValue(); /* 188 */ setTexture(); /* */ } /* 190 */ break; /* */ case 2: /* 192 */ if (mode == 0) { /* 193 */ ret = IntegerPropertyEditor.make(new Property(this, index, /* 194 */ "Texture Height"), 0, 1024); /* 195 */ } else if (mode == 1) { /* 196 */ ret = new Integer(this._ySurface); /* 197 */ } else if (mode == 2) { /* 198 */ this._ySurface = ((Integer)value).intValue(); /* 199 */ setTexture(); /* */ } /* 201 */ break; /* */ case 3: /* 203 */ if (mode == 0) { /* 204 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 205 */ "Auto-play?"), "No", "Yes"); /* 206 */ } else if (mode == 1) { /* 207 */ ret = new Boolean(this._autoPlay); /* 208 */ } else if (mode == 2) { /* 209 */ this._autoPlay = ((Boolean)value).booleanValue(); /* 210 */ setTexture(); /* */ } /* 212 */ break; /* */ /* */ default: /* 215 */ ret = super.properties(index, offset + 4, mode, value); /* */ } /* */ /* 218 */ if (mode == 2) { /* 219 */ noteChange(); /* */ } /* 221 */ return ret; /* */ } /* */ /* */ /* 225 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 229 */ s.saveVersion(1, classCookie); /* 230 */ super.saveState(s); /* */ /* 232 */ s.saveString(this._textureURL); /* 233 */ s.saveInt(this._xSurface); /* 234 */ s.saveInt(this._ySurface); /* 235 */ s.saveBoolean(this._autoPlay); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 240 */ switch (r.restoreVersion(classCookie)) { /* */ case 0: /* 242 */ super.restoreState(r); /* 243 */ this._textureURL = r.restoreString(); /* 244 */ this._xSurface = r.restoreInt(); /* 245 */ this._ySurface = r.restoreInt(); /* 246 */ noteChange(); /* 247 */ break; /* */ /* */ case 1: /* 250 */ super.restoreState(r); /* 251 */ this._textureURL = r.restoreString(); /* 252 */ this._xSurface = r.restoreInt(); /* 253 */ this._ySurface = r.restoreInt(); /* 254 */ this._autoPlay = r.restoreBoolean(); /* 255 */ noteChange(); /* 256 */ break; /* */ /* */ default: /* 259 */ throw new TooNewException(); /* */ } /* */ /* 262 */ setTexture(); /* */ } /* */ /* */ /* */ /* */ public void releaseAuxilaryData() /* */ { /* 269 */ if (this._ds != null) { /* 270 */ this._ds.nStop(); /* 271 */ this._ds = null; /* */ } /* */ /* 274 */ if (this._surface != null) { /* 275 */ this._surface.finalize(); /* 276 */ this._surface = null; /* */ } /* */ /* 279 */ if (this._material != null) { /* 280 */ this._material.detach(); /* 281 */ this._material.finalize(); /* 282 */ this._material = null; /* */ } /* */ /* */ /* 286 */ this._textures = null; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\VideoTexture.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */