diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/Billboard.java | |
| download | worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip | |
Diffstat (limited to 'NET/worlds/scape/Billboard.java')
| -rw-r--r-- | NET/worlds/scape/Billboard.java | 504 |
1 files changed, 504 insertions, 0 deletions
diff --git a/NET/worlds/scape/Billboard.java b/NET/worlds/scape/Billboard.java new file mode 100644 index 0000000..8af9495 --- /dev/null +++ b/NET/worlds/scape/Billboard.java @@ -0,0 +1,504 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import NET.worlds.console.Console; +/* */ import NET.worlds.console.DefaultConsole; +/* */ import NET.worlds.console.NoWebControlException; +/* */ import NET.worlds.console.WebControl; +/* */ import NET.worlds.console.WebControlFactory; +/* */ import NET.worlds.console.WebControlImp; +/* */ import NET.worlds.console.WebControlListener; +/* */ import NET.worlds.core.IniFile; +/* */ import NET.worlds.network.URL; +/* */ import java.io.DataInputStream; +/* */ import java.io.DataOutputStream; +/* */ import java.io.IOException; +/* */ import java.io.PrintStream; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class Billboard +/* */ extends Attribute +/* */ implements WebControlListener +/* */ { +/* */ public Billboard(int attrID) +/* */ { +/* 37 */ super(attrID); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Billboard() {} +/* */ +/* */ +/* */ +/* */ +/* */ public final void noteChange() {} +/* */ +/* */ +/* */ +/* */ +/* */ protected void noteAddingTo(SuperRoot owner) +/* */ { +/* 56 */ Rect s = (Rect)((Sharer)owner).getOwner(); +/* 57 */ s._billboardAttribute = this; +/* */ +/* 59 */ assignMaterial(s); +/* */ } +/* */ +/* */ private void assignMaterial(Rect s) { +/* 63 */ int xTex = this._xSurface / 128; +/* 64 */ if (xTex < 1) +/* 65 */ xTex = 1; +/* 66 */ int yTex = this._ySurface / 128; +/* 67 */ if (yTex < 1) { +/* 68 */ yTex = 1; +/* */ } +/* 70 */ this._surface = null; +/* */ +/* 72 */ if (this._wci != null) +/* 73 */ this._wci.detach(); +/* 74 */ this._wci = null; +/* */ +/* 76 */ this._rows = yTex; +/* */ +/* 78 */ this._material = new Material(URL.make(this._defTextureURL), xTex, yTex); +/* 79 */ s.setMaterial(this._material); +/* */ +/* 81 */ this._textures = this._material.getTextures(); +/* 82 */ this._surface = new TextureSurface(this._textures, yTex, this._xSurface, this._ySurface); +/* */ try +/* */ { +/* 85 */ this._wci = WebControlFactory.createWebControlImp(this._surface.getHwnd(), +/* 86 */ false, this._isAdBanner); +/* */ } catch (NoWebControlException e) { +/* 88 */ System.out.println("Could not create MSIE control for billboard."); +/* */ +/* 90 */ this._wci = null; +/* 91 */ return; +/* */ } +/* 93 */ if (!this._wci.setURL(this._textureURL)) { +/* 94 */ this._retryURL = true; +/* */ } +/* 96 */ this._wci.addListener(this); +/* */ } +/* */ +/* */ private void setTexture() { +/* 100 */ Sharer sh = (Sharer)getOwner(); +/* 101 */ if (sh == null) { +/* 102 */ return; +/* */ } +/* 104 */ Rect s = (Rect)sh.getOwner(); +/* 105 */ assignMaterial(s); +/* */ } +/* */ +/* */ public void detach() +/* */ { +/* 110 */ Rect s = (Rect)((Sharer)getOwner()).getOwner(); +/* 111 */ s._billboardAttribute = null; +/* 112 */ if (this._wci != null) +/* 113 */ this._wci.detach(); +/* 114 */ super.detach(); +/* */ } +/* */ +/* */ public void finalize() +/* */ { +/* 119 */ releaseAuxilaryData(); +/* 120 */ super.finalize(); +/* */ } +/* */ +/* 123 */ WebControlImp _wci = null; +/* */ TextureSurface _surface; +/* */ Texture[] _textures; +/* 126 */ Material _material = null; +/* */ +/* */ +/* 129 */ String _textureURL = "$SCRIPTSERVERgetad.pl?u=$USERNAME"; +/* */ +/* */ +/* 132 */ String _adURL = "http://www.worlds.com/"; +/* */ +/* */ +/* 135 */ String _defTextureURL = IniFile.override().getIniString("defaultAd", +/* 136 */ "adworlds.cmp"); +/* */ +/* */ +/* 139 */ int _xPercent = 100; int _yPercent = 100; +/* */ +/* */ +/* 142 */ int _xSurface = 468; int _ySurface = 60; +/* */ +/* */ +/* 145 */ boolean _hasToolbar = true; +/* */ +/* */ +/* 148 */ boolean _isFixed = false; +/* */ +/* */ +/* 151 */ int _rows = 1; +/* */ +/* */ +/* */ +/* */ +/* 156 */ int _refresh = 5; +/* */ +/* */ +/* 159 */ boolean _passClicks = true; +/* */ +/* */ +/* */ +/* */ +/* */ +/* 165 */ boolean _isAdBanner = true; +/* */ +/* */ public boolean getIsAdBanner() { +/* 168 */ return this._isAdBanner; +/* */ } +/* */ +/* */ +/* */ +/* 173 */ boolean _retryURL = false; +/* */ +/* */ public void billboardClicked(Point2 pt) { +/* 176 */ if (this._passClicks) { +/* 177 */ double realX = pt.x * this._surface.getWidth(); +/* 178 */ double realY = pt.y * this._surface.getHeight(); +/* 179 */ realY = this._surface.getHeight() - realY; +/* */ +/* 181 */ this._surface.sendLeftClick((int)realX, (int)realY); +/* 182 */ return; +/* */ } +/* */ +/* 185 */ Console c = Console.getActive(); +/* 186 */ if ((c != null) && ((c instanceof DefaultConsole))) { +/* 187 */ DefaultConsole dc = (DefaultConsole)c; +/* */ try { +/* 189 */ WebControl wc = new WebControl(dc.getRender(), this._xPercent, +/* 190 */ this._yPercent, this._hasToolbar, this._isFixed, false); +/* 191 */ wc.activate(); +/* 192 */ wc.setURL(this._adURL); +/* */ } +/* */ catch (NoWebControlException e) { +/* 195 */ new SendURLAction(this._adURL).doIt(); +/* */ } +/* */ } +/* */ } +/* */ +/* 200 */ int frameCnt = -1; +/* */ +/* */ public void billboardFrame(FrameEvent f) { +/* 203 */ if ((this._retryURL) && (this._wci != null)) { +/* 204 */ if (this._wci.setURL(this._textureURL)) { +/* 205 */ this._retryURL = false; +/* */ } else { +/* 207 */ return; +/* */ } +/* */ } +/* 210 */ if (this._surface != null) { +/* 211 */ if ((this.frameCnt > this._refresh) || (this.frameCnt == -1)) { +/* 212 */ if ((this.frameCnt != -1) && (this._refresh == -1)) { +/* 213 */ return; +/* */ } +/* 215 */ this.frameCnt = 0; +/* 216 */ draw(); +/* */ } else { +/* 218 */ this.frameCnt += 1; +/* */ } +/* */ } +/* */ } +/* */ +/* */ public synchronized void draw() { +/* 224 */ if ((this._surface != null) && (this._wci != null)) { +/* 225 */ this._surface.setTextures(this._material.getTextures(), this._rows); +/* 226 */ this._surface.draw(this._wci); +/* */ } +/* */ } +/* */ +/* */ public void webControlEvent(int eventID) +/* */ { +/* 232 */ if ((eventID == 1) && (this._refresh == -1)) { +/* 233 */ draw(); +/* */ } +/* */ } +/* */ +/* */ public void generateNetData(DataOutputStream s) throws IOException { +/* 238 */ s.writeUTF(this._adURL); +/* 239 */ s.writeUTF(this._textureURL); +/* 240 */ s.writeInt(this._xPercent); +/* 241 */ s.writeInt(this._yPercent); +/* 242 */ s.writeInt(this._xSurface); +/* 243 */ s.writeInt(this._ySurface); +/* 244 */ s.writeInt(this._refresh); +/* 245 */ s.writeInt(this._hasToolbar ? 1 : 0); +/* 246 */ s.writeInt(this._isFixed ? 1 : 0); +/* 247 */ s.writeInt(this._passClicks ? 1 : 0); +/* 248 */ s.writeInt(this._isAdBanner ? 1 : 0); +/* */ } +/* */ +/* */ public void setFromNetData(DataInputStream ds, int len) throws IOException +/* */ { +/* 253 */ this._adURL = ds.readUTF(); +/* 254 */ this._textureURL = ds.readUTF(); +/* 255 */ this._xPercent = ds.readInt(); +/* 256 */ this._yPercent = ds.readInt(); +/* 257 */ this._xSurface = ds.readInt(); +/* 258 */ this._ySurface = ds.readInt(); +/* 259 */ this._refresh = ds.readInt(); +/* 260 */ this._hasToolbar = (ds.readInt() == 1); +/* 261 */ this._isFixed = (ds.readInt() == 1); +/* 262 */ this._passClicks = (ds.readInt() == 1); +/* 263 */ this._isAdBanner = (ds.readInt() == 1); +/* */ +/* 265 */ noteChange(); +/* 266 */ setTexture(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 275 */ Object ret = null; +/* 276 */ switch (index - offset) { +/* */ case 0: +/* 278 */ if (mode == 0) { +/* 279 */ ret = StringPropertyEditor.make(new Property(this, index, +/* 280 */ "Target URL")); +/* 281 */ } else if (mode == 1) { +/* 282 */ ret = this._adURL; +/* 283 */ } else if (mode == 2) +/* 284 */ this._adURL = ((String)value); +/* 285 */ break; +/* */ case 1: +/* 287 */ if (mode == 0) { +/* 288 */ ret = StringPropertyEditor.make(new Property(this, index, +/* 289 */ "Texture URL")); +/* 290 */ } else if (mode == 1) { +/* 291 */ ret = this._textureURL; +/* 292 */ } else if (mode == 2) { +/* 293 */ this._textureURL = ((String)value); +/* 294 */ setTexture(); +/* */ } +/* 296 */ break; +/* */ case 2: +/* 298 */ if (mode == 0) { +/* 299 */ ret = IntegerPropertyEditor.make(new Property(this, index, +/* 300 */ "X Overlay % or Width"), 0, 1024); +/* 301 */ } else if (mode == 1) { +/* 302 */ ret = new Integer(this._xPercent); +/* 303 */ } else if (mode == 2) +/* 304 */ this._xPercent = ((Integer)value).intValue(); +/* 305 */ break; +/* */ case 3: +/* 307 */ if (mode == 0) { +/* 308 */ ret = IntegerPropertyEditor.make(new Property(this, index, +/* 309 */ "Y Overlay % or Height"), 0, 1024); +/* 310 */ } else if (mode == 1) { +/* 311 */ ret = new Integer(this._yPercent); +/* 312 */ } else if (mode == 2) +/* 313 */ this._yPercent = ((Integer)value).intValue(); +/* 314 */ break; +/* */ case 4: +/* 316 */ if (mode == 0) { +/* 317 */ ret = BooleanPropertyEditor.make(new Property(this, index, +/* 318 */ "Has Toolbar"), "No", "Yes"); +/* 319 */ } else if (mode == 1) { +/* 320 */ ret = new Boolean(this._hasToolbar); +/* 321 */ } else if (mode == 2) +/* 322 */ this._hasToolbar = ((Boolean)value).booleanValue(); +/* 323 */ break; +/* */ case 5: +/* 325 */ if (mode == 0) { +/* 326 */ ret = BooleanPropertyEditor.make(new Property(this, index, +/* 327 */ "Fixed size"), "No - Percentage specified", +/* 328 */ "Yes - Pixels specified"); +/* 329 */ } else if (mode == 1) { +/* 330 */ ret = new Boolean(this._isFixed); +/* 331 */ } else if (mode == 2) +/* 332 */ this._isFixed = ((Boolean)value).booleanValue(); +/* 333 */ break; +/* */ case 6: +/* 335 */ if (mode == 0) { +/* 336 */ ret = IntegerPropertyEditor.make(new Property(this, index, +/* 337 */ "Texture Width"), 0, 1024); +/* 338 */ } else if (mode == 1) { +/* 339 */ ret = new Integer(this._xSurface); +/* 340 */ } else if (mode == 2) { +/* 341 */ this._xSurface = ((Integer)value).intValue(); +/* 342 */ setTexture(); +/* */ } +/* 344 */ break; +/* */ case 7: +/* 346 */ if (mode == 0) { +/* 347 */ ret = IntegerPropertyEditor.make(new Property(this, index, +/* 348 */ "Texture Height"), 0, 1024); +/* 349 */ } else if (mode == 1) { +/* 350 */ ret = new Integer(this._ySurface); +/* 351 */ } else if (mode == 2) { +/* 352 */ this._ySurface = ((Integer)value).intValue(); +/* 353 */ setTexture(); +/* */ } +/* 355 */ break; +/* */ case 8: +/* 357 */ if (mode == 0) { +/* 358 */ ret = IntegerPropertyEditor.make(new Property(this, index, +/* 359 */ "Texture Refresh Rate"), -1, 1024); +/* 360 */ } else if (mode == 1) { +/* 361 */ ret = new Integer(this._refresh); +/* 362 */ } else if (mode == 2) +/* 363 */ this._refresh = ((Integer)value).intValue(); +/* 364 */ break; +/* */ case 9: +/* 366 */ if (mode == 0) { +/* 367 */ ret = BooleanPropertyEditor.make(new Property(this, index, +/* 368 */ "Pass clicks"), "No - Click launches specified page", +/* 369 */ "Yes - Mouse events passed through to texture page"); +/* 370 */ } else if (mode == 1) { +/* 371 */ ret = new Boolean(this._passClicks); +/* 372 */ } else if (mode == 2) +/* 373 */ this._passClicks = ((Boolean)value).booleanValue(); +/* 374 */ break; +/* */ case 10: +/* 376 */ if (mode == 0) { +/* 377 */ ret = BooleanPropertyEditor.make(new Property(this, index, +/* 378 */ "Is Ad Banner"), "No", "Yes"); +/* 379 */ } else if (mode == 1) { +/* 380 */ ret = new Boolean(this._isAdBanner); +/* 381 */ } else if (mode == 2) +/* 382 */ this._isAdBanner = ((Boolean)value).booleanValue(); +/* 383 */ break; +/* */ +/* */ default: +/* 386 */ ret = super.properties(index, offset + 11, mode, value); +/* */ } +/* */ +/* 389 */ if (mode == 2) { +/* 390 */ noteChange(); +/* */ } +/* 392 */ return ret; +/* */ } +/* */ +/* */ +/* 396 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 400 */ s.saveVersion(3, classCookie); +/* 401 */ super.saveState(s); +/* */ +/* 403 */ s.saveString(this._adURL); +/* 404 */ s.saveString(this._textureURL); +/* 405 */ s.saveInt(this._xPercent); +/* 406 */ s.saveInt(this._yPercent); +/* 407 */ s.saveBoolean(this._hasToolbar); +/* 408 */ s.saveBoolean(this._isFixed); +/* 409 */ s.saveInt(this._xSurface); +/* 410 */ s.saveInt(this._ySurface); +/* 411 */ s.saveInt(this._refresh); +/* 412 */ s.saveBoolean(this._passClicks); +/* 413 */ s.saveBoolean(this._isAdBanner); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) throws IOException, TooNewException +/* */ { +/* 418 */ switch (r.restoreVersion(classCookie)) { +/* */ case 0: +/* 420 */ super.restoreState(r); +/* 421 */ this._adURL = r.restoreString(); +/* 422 */ this._textureURL = r.restoreString(); +/* 423 */ this._xPercent = r.restoreInt(); +/* 424 */ this._yPercent = r.restoreInt(); +/* 425 */ this._hasToolbar = r.restoreBoolean(); +/* 426 */ noteChange(); +/* 427 */ break; +/* */ case 1: +/* 429 */ super.restoreState(r); +/* 430 */ this._adURL = r.restoreString(); +/* 431 */ this._textureURL = r.restoreString(); +/* 432 */ this._xPercent = r.restoreInt(); +/* 433 */ this._yPercent = r.restoreInt(); +/* 434 */ this._hasToolbar = r.restoreBoolean(); +/* 435 */ this._isFixed = r.restoreBoolean(); +/* 436 */ noteChange(); +/* 437 */ break; +/* */ case 2: +/* 439 */ super.restoreState(r); +/* 440 */ this._adURL = r.restoreString(); +/* 441 */ this._textureURL = r.restoreString(); +/* 442 */ this._xPercent = r.restoreInt(); +/* 443 */ this._yPercent = r.restoreInt(); +/* 444 */ this._hasToolbar = r.restoreBoolean(); +/* 445 */ this._isFixed = r.restoreBoolean(); +/* 446 */ this._xSurface = r.restoreInt(); +/* 447 */ this._ySurface = r.restoreInt(); +/* 448 */ this._refresh = r.restoreInt(); +/* 449 */ this._passClicks = r.restoreBoolean(); +/* 450 */ noteChange(); +/* 451 */ break; +/* */ case 3: +/* 453 */ super.restoreState(r); +/* 454 */ this._adURL = r.restoreString(); +/* 455 */ this._textureURL = r.restoreString(); +/* 456 */ this._xPercent = r.restoreInt(); +/* 457 */ this._yPercent = r.restoreInt(); +/* 458 */ this._hasToolbar = r.restoreBoolean(); +/* 459 */ this._isFixed = r.restoreBoolean(); +/* 460 */ this._xSurface = r.restoreInt(); +/* 461 */ this._ySurface = r.restoreInt(); +/* 462 */ this._refresh = r.restoreInt(); +/* 463 */ this._passClicks = r.restoreBoolean(); +/* 464 */ this._isAdBanner = r.restoreBoolean(); +/* 465 */ noteChange(); +/* 466 */ break; +/* */ +/* */ default: +/* 469 */ throw new TooNewException(); +/* */ } +/* */ +/* 472 */ setTexture(); +/* */ } +/* */ +/* */ +/* */ +/* */ public void releaseAuxilaryData() +/* */ { +/* 479 */ if (this._wci != null) { +/* 480 */ this._wci.detach(); +/* 481 */ this._wci = null; +/* */ } +/* */ +/* 484 */ if (this._surface != null) { +/* 485 */ this._surface.finalize(); +/* 486 */ this._surface = null; +/* */ } +/* */ +/* 489 */ if (this._material != null) { +/* 490 */ this._material.detach(); +/* 491 */ this._material.finalize(); +/* 492 */ this._material = null; +/* */ } +/* */ +/* */ +/* 496 */ this._textures = null; +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Billboard.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |