summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/VideoWall.java
blob: 4b79bde2ffcca9877152a7a97198c6eaaabf08bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import NET.worlds.core.IniFile;
/*     */ import NET.worlds.network.URL;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class VideoWall
/*     */   extends Rect
/*     */ {
/*  17 */   VideoSurface _surface = null;
/*     */   Texture[] _textures;
/*  19 */   Material _material = null;
/*     */   
/*     */ 
/*  22 */   String _textureURL = "http://dev.worlds.net/rr-worlds/video/fatboy.asf";
/*     */   
/*     */ 
/*  25 */   String _defTextureURL = IniFile.override().getIniString("defaultAd", 
/*  26 */     "adworlds.cmp");
/*     */   
/*     */ 
/*  29 */   int _xSurface = 140; int _ySurface = 104;
/*     */   
/*     */ 
/*  32 */   boolean _autoPlay = true;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*  37 */   int _autoPlayRepeats = 1;
/*     */   
/*     */ 
/*  40 */   int _rows = 1;
/*     */   
/*     */ 
/*     */ 
/*     */   private void rebuild()
/*     */   {
/*  46 */     unbuild();
/*  47 */     int xTex = this._xSurface / 128 + 1;
/*     */     
/*  49 */     int yTex = this._ySurface / 128 + 1;
/*     */     
/*     */ 
/*  52 */     this._surface = null;
/*     */     
/*  54 */     this._rows = yTex;
/*     */     
/*  56 */     this._material = new Material(URL.make(this._defTextureURL), 
/*  57 */       xTex, yTex);
/*  58 */     setMaterial(this._material);
/*     */     
/*  60 */     this._textures = this._material.getTextures();
/*  61 */     this._surface = VideoManager.get(this._textureURL, yTex, this._xSurface, 
/*  62 */       this._ySurface);
/*     */     
/*  64 */     if (this._autoPlay) {
/*  65 */       this._surface.play(1);
/*     */     }
/*     */   }
/*     */   
/*     */   public void finalize() {
/*  70 */     unbuild();
/*  71 */     super.finalize();
/*     */   }
/*     */   
/*     */   public void detach()
/*     */   {
/*  76 */     unbuild();
/*  77 */     super.detach();
/*     */   }
/*     */   
/*     */   private void unbuild()
/*     */   {
/*  82 */     if (this._surface != null)
/*     */     {
/*  84 */       this._surface.stop();
/*  85 */       VideoManager.release(this._surface);
/*  86 */       this._surface = null;
/*     */     }
/*     */   }
/*     */   
/*     */   public void changeURL(String newURL, int width, int height)
/*     */   {
/*  92 */     this._textureURL = new String(newURL);
/*  93 */     this._xSurface = width;
/*  94 */     this._ySurface = height;
/*  95 */     rebuild();
/*     */   }
/*     */   
/*     */   public boolean handle(FrameEvent f)
/*     */   {
/* 100 */     getState();
/* 101 */     if (this.visible)
/* 102 */       draw();
/* 103 */     return false;
/*     */   }
/*     */   
/*     */   public void prerender(Camera cam)
/*     */   {
/* 108 */     Point3Temp p = inCamSpace(cam);
/*     */     
/*     */ 
/*     */ 
/* 112 */     boolean v = (p != null) && (p.z > 1.0F) && (p.x < p.z) && (-p.x < p.z);
/*     */     
/* 114 */     if (v) this.visible = true;
/*     */   }
/*     */   
/* 117 */   public VideoSurface getVideoSurface() { return this._surface; }
/*     */   
/*     */   public synchronized void draw()
/*     */   {
/* 121 */     if (this._surface != null)
/*     */     {
/* 123 */       this._surface.draw(this._material.getTextures(), this._rows);
/*     */     }
/*     */   }
/*     */   
/*     */   public int getState()
/*     */   {
/* 129 */     if (this._surface != null) {
/* 130 */       return this._surface.tick();
/*     */     }
/* 132 */     return 0;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/* 141 */     Object ret = null;
/* 142 */     switch (index - offset)
/*     */     {
/*     */     case 0: 
/* 145 */       if (mode == 0) {
/* 146 */         ret = StringPropertyEditor.make(
/* 147 */           new Property(this, index, "Video URL"));
/* 148 */       } else if (mode == 1) {
/* 149 */         ret = this._textureURL;
/* 150 */       } else if (mode == 2)
/*     */       {
/* 152 */         this._textureURL = ((String)value);
/* 153 */         rebuild();
/*     */       }
/* 155 */       break;
/*     */     case 1: 
/* 157 */       if (mode == 0) {
/* 158 */         ret = IntegerPropertyEditor.make(
/* 159 */           new Property(this, index, "Video Width (pixels)"), 
/* 160 */           0, 1024);
/* 161 */       } else if (mode == 1) {
/* 162 */         ret = new Integer(this._xSurface);
/* 163 */       } else if (mode == 2)
/*     */       {
/* 165 */         this._xSurface = ((Integer)value).intValue();
/* 166 */         rebuild();
/*     */       }
/* 168 */       break;
/*     */     case 2: 
/* 170 */       if (mode == 0) {
/* 171 */         ret = IntegerPropertyEditor.make(
/* 172 */           new Property(this, index, "Video Height (pixels)"), 
/* 173 */           0, 1024);
/* 174 */       } else if (mode == 1) {
/* 175 */         ret = new Integer(this._ySurface);
/* 176 */       } else if (mode == 2)
/*     */       {
/* 178 */         this._ySurface = ((Integer)value).intValue();
/* 179 */         rebuild();
/*     */       }
/* 181 */       break;
/*     */     case 3: 
/* 183 */       if (mode == 0) {
/* 184 */         ret = BooleanPropertyEditor.make(
/* 185 */           new Property(this, index, "Auto-play?"), 
/* 186 */           "No", "Yes");
/* 187 */       } else if (mode == 1) {
/* 188 */         ret = new Boolean(this._autoPlay);
/* 189 */       } else if (mode == 2)
/*     */       {
/* 191 */         this._autoPlay = ((Boolean)value).booleanValue();
/* 192 */         rebuild();
/*     */       }
/* 194 */       break;
/*     */     case 4: 
/* 196 */       if (mode == 0) {
/* 197 */         ret = IntegerPropertyEditor.make(
/* 198 */           new Property(this, index, "Repeats for Autoplay (-1 = infinite)"), 
/* 199 */           -1, 1024);
/* 200 */       } else if (mode == 1) {
/* 201 */         ret = new Integer(this._autoPlayRepeats);
/* 202 */       } else if (mode == 2)
/*     */       {
/* 204 */         this._autoPlayRepeats = ((Integer)value).intValue();
/* 205 */         rebuild();
/*     */       }
/* 207 */       break;
/*     */     
/*     */     default: 
/* 210 */       ret = super.properties(index, offset + 5, mode, value);
/*     */     }
/*     */     
/* 213 */     return ret;
/*     */   }
/*     */   
/*     */ 
/* 217 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/* 221 */     s.saveVersion(1, classCookie);
/* 222 */     super.saveState(s);
/*     */     
/* 224 */     s.saveString(this._textureURL);
/* 225 */     s.saveInt(this._xSurface);
/* 226 */     s.saveInt(this._ySurface);
/* 227 */     s.saveBoolean(this._autoPlay);
/* 228 */     s.saveInt(this._autoPlayRepeats);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/* 233 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 0: 
/* 235 */       super.restoreState(r);
/* 236 */       this._textureURL = r.restoreString();
/* 237 */       this._xSurface = r.restoreInt();
/* 238 */       this._ySurface = r.restoreInt();
/* 239 */       this._autoPlay = r.restoreBoolean();
/* 240 */       break;
/*     */     
/*     */     case 1: 
/* 243 */       super.restoreState(r);
/* 244 */       this._textureURL = r.restoreString();
/* 245 */       this._xSurface = r.restoreInt();
/* 246 */       this._ySurface = r.restoreInt();
/* 247 */       this._autoPlay = r.restoreBoolean();
/* 248 */       this._autoPlayRepeats = r.restoreInt();
/* 249 */       break;
/*     */     
/*     */     default: 
/* 252 */       throw new TooNewException();
/*     */     }
/*     */     
/* 255 */     rebuild();
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\VideoWall.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */