Guest User

Untitled

a guest
Jun 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.27 KB | None | 0 0
  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Font;
  5. import java.awt.FontMetrics;
  6. import java.awt.Graphics;
  7. import java.awt.event.FocusEvent;
  8. import java.awt.event.FocusListener;
  9. import java.awt.event.KeyEvent;
  10. import java.awt.event.KeyListener;
  11. import java.awt.event.MouseEvent;
  12. import java.awt.event.MouseListener;
  13. import java.awt.event.MouseMotionListener;
  14. import java.awt.event.WindowEvent;
  15. import java.awt.event.WindowListener;
  16. import java.io.PrintStream;
  17.  
  18. public class RSApplet extends Applet
  19. implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener
  20. {
  21. public static int hotKey = 508;
  22. private int anInt4;
  23. private int delayTime;
  24. int minDelay;
  25. private final long[] aLongArray7;
  26. int fps;
  27. boolean shouldDebug;
  28. int myWidth;
  29. int myHeight;
  30. Graphics graphics;
  31. RSImageProducer fullGameScreen;
  32. RSFrame gameFrame;
  33. private boolean shouldClearScreen;
  34. boolean awtFocus;
  35. int idleTime;
  36. int clickMode2;
  37. public int mouseX;
  38. public int mouseY;
  39. private int clickMode1;
  40. private int clickX;
  41. private int clickY;
  42. private long clickTime;
  43. int clickMode3;
  44. int saveClickX;
  45. int saveClickY;
  46. long aLong29;
  47. final int[] keyArray;
  48. private final int[] charQueue;
  49. private int readIndex;
  50. private int writeIndex;
  51. public static int anInt34;
  52.  
  53. final void createClientFrame(int paramInt1, int paramInt2)
  54. {
  55. this.myWidth = paramInt2;
  56. this.myHeight = paramInt1;
  57. this.gameFrame = new RSFrame(this, this.myWidth, this.myHeight);
  58. this.graphics = getGameComponent().getGraphics();
  59. this.fullGameScreen = new RSImageProducer(this.myWidth, this.myHeight, getGameComponent());
  60. startRunnable(this, 1);
  61. }
  62.  
  63. final void initClientFrame(int paramInt1, int paramInt2) {
  64. this.myWidth = paramInt2;
  65. this.myHeight = paramInt1;
  66. this.graphics = getGameComponent().getGraphics();
  67. this.fullGameScreen = new RSImageProducer(this.myWidth, this.myHeight, getGameComponent());
  68. startRunnable(this, 1);
  69. }
  70.  
  71. public void run()
  72. {
  73. getGameComponent().addMouseListener(this);
  74. getGameComponent().addMouseMotionListener(this);
  75. getGameComponent().addKeyListener(this);
  76. getGameComponent().addFocusListener(this);
  77. if (this.gameFrame != null)
  78. this.gameFrame.addWindowListener(this);
  79. drawLoadingText(0, "Loading...");
  80. startUp();
  81. int i = 0;
  82. int j = 256;
  83. int k = 1;
  84. int m = 0;
  85. int n = 0;
  86. for (int i1 = 0; i1 < 10; i1++) {
  87. this.aLongArray7[i1] = System.currentTimeMillis();
  88. }
  89. long l1 = System.currentTimeMillis();
  90. while (this.anInt4 >= 0)
  91. {
  92. if (this.anInt4 > 0)
  93. {
  94. this.anInt4 -= 1;
  95. if (this.anInt4 == 0)
  96. {
  97. exit();
  98. return;
  99. }
  100. }
  101. int i2 = j;
  102. int i3 = k;
  103. j = 300;
  104. k = 1;
  105. long l2 = System.currentTimeMillis();
  106. if (this.aLongArray7[i] == 0L)
  107. {
  108. j = i2;
  109. k = i3;
  110. }
  111. else if (l2 > this.aLongArray7[i]) {
  112. j = (int)(2560 * this.delayTime / (l2 - this.aLongArray7[i]));
  113. }if (j < 25)
  114. j = 25;
  115. if (j > 256)
  116. {
  117. j = 256;
  118. k = (int)(this.delayTime - (l2 - this.aLongArray7[i]) / 10L);
  119. }
  120. if (k > this.delayTime)
  121. k = this.delayTime;
  122. this.aLongArray7[i] = l2;
  123. i = (i + 1) % 10;
  124. if (k > 1)
  125. {
  126. for (int i4 = 0; i4 < 10; i4++) {
  127. if (this.aLongArray7[i4] != 0L)
  128. this.aLongArray7[i4] += k;
  129. }
  130. }
  131. if (k < this.minDelay)
  132. k = this.minDelay;
  133. try
  134. {
  135. Thread.sleep(k);
  136. }
  137. catch (InterruptedException localInterruptedException)
  138. {
  139. n++;
  140. }
  141. for (; m < 256; m += j)
  142. {
  143. this.clickMode3 = this.clickMode1;
  144. this.saveClickX = this.clickX;
  145. this.saveClickY = this.clickY;
  146. this.aLong29 = this.clickTime;
  147. this.clickMode1 = 0;
  148. processGameLoop();
  149. this.readIndex = this.writeIndex;
  150. }
  151.  
  152. m &= 255;
  153. if (this.delayTime > 0)
  154. this.fps = (1000 * j / (this.delayTime * 256));
  155. processDrawing();
  156. if (this.shouldDebug)
  157. {
  158. System.out.println("ntime:" + l2);
  159. for (int i5 = 0; i5 < 10; i5++)
  160. {
  161. int i6 = (i - i5 - 1 + 20) % 10;
  162. System.out.println("otim" + i6 + ":" + this.aLongArray7[i6]);
  163. }
  164.  
  165. System.out.println("fps:" + this.fps + " ratio:" + j + " count:" + m);
  166. System.out.println("del:" + k + " deltime:" + this.delayTime + " mindel:" + this.minDelay);
  167. System.out.println("intex:" + n + " opos:" + i);
  168. this.shouldDebug = false;
  169. n = 0;
  170. }
  171. }
  172. if (this.anInt4 == -1)
  173. exit();
  174. }
  175.  
  176. private void exit()
  177. {
  178. this.anInt4 = -2;
  179. cleanUpForQuit();
  180. if (this.gameFrame != null)
  181. {
  182. try
  183. {
  184. Thread.sleep(1000L);
  185. }
  186. catch (Exception localException) {
  187. }
  188. try {
  189. System.exit(0);
  190. }
  191. catch (Throwable localThrowable) {
  192. }
  193. }
  194. }
  195.  
  196. final void method4(int paramInt) {
  197. this.delayTime = (1000 / paramInt);
  198. }
  199.  
  200. public final void start()
  201. {
  202. if (this.anInt4 >= 0)
  203. this.anInt4 = 0;
  204. }
  205.  
  206. public final void stop()
  207. {
  208. if (this.anInt4 >= 0)
  209. this.anInt4 = (4000 / this.delayTime);
  210. }
  211.  
  212. public final void destroy()
  213. {
  214. this.anInt4 = -1;
  215. try
  216. {
  217. Thread.sleep(5000L);
  218. } catch (Exception localException) {
  219. }
  220. if (this.anInt4 == -1)
  221. exit();
  222. }
  223.  
  224. public final void update(Graphics paramGraphics)
  225. {
  226. if (this.graphics == null)
  227. this.graphics = paramGraphics;
  228. this.shouldClearScreen = true;
  229. raiseWelcomeScreen();
  230. }
  231.  
  232. public final void paint(Graphics paramGraphics)
  233. {
  234. if (this.graphics == null)
  235. this.graphics = paramGraphics;
  236. this.shouldClearScreen = true;
  237. raiseWelcomeScreen();
  238. }
  239.  
  240. public final void mousePressed(MouseEvent paramMouseEvent)
  241. {
  242. int i = paramMouseEvent.getX();
  243. int j = paramMouseEvent.getY();
  244. if (this.gameFrame != null)
  245. {
  246. i -= 4;
  247. j -= 22;
  248. }
  249. this.idleTime = 0;
  250. this.clickX = i;
  251. this.clickY = j;
  252. this.clickTime = System.currentTimeMillis();
  253. if (paramMouseEvent.isMetaDown())
  254. {
  255. this.clickMode1 = 2;
  256. this.clickMode2 = 2;
  257. }
  258. else {
  259. this.clickMode1 = 1;
  260. this.clickMode2 = 1;
  261. }
  262. }
  263.  
  264. public final void mouseReleased(MouseEvent paramMouseEvent)
  265. {
  266. this.idleTime = 0;
  267. this.clickMode2 = 0;
  268. }
  269.  
  270. public final void mouseClicked(MouseEvent paramMouseEvent)
  271. {
  272. }
  273.  
  274. public final void mouseEntered(MouseEvent paramMouseEvent)
  275. {
  276. }
  277.  
  278. public final void mouseExited(MouseEvent paramMouseEvent)
  279. {
  280. this.idleTime = 0;
  281. this.mouseX = -1;
  282. this.mouseY = -1;
  283. }
  284.  
  285. public final void mouseDragged(MouseEvent paramMouseEvent)
  286. {
  287. int i = paramMouseEvent.getX();
  288. int j = paramMouseEvent.getY();
  289. if (this.gameFrame != null)
  290. {
  291. i -= 4;
  292. j -= 22;
  293. }
  294. this.idleTime = 0;
  295. this.mouseX = i;
  296. this.mouseY = j;
  297. }
  298.  
  299. public final void mouseMoved(MouseEvent paramMouseEvent)
  300. {
  301. int i = paramMouseEvent.getX();
  302. int j = paramMouseEvent.getY();
  303. if (this.gameFrame != null)
  304. {
  305. i -= 4;
  306. j -= 22;
  307. }
  308. this.idleTime = 0;
  309. this.mouseX = i;
  310. this.mouseY = j;
  311. }
  312.  
  313. public final void keyPressed(KeyEvent paramKeyEvent)
  314. {
  315. this.idleTime = 0;
  316. int i = paramKeyEvent.getKeyCode();
  317. int j = paramKeyEvent.getKeyChar();
  318.  
  319. if (hotKey == 508)
  320. {
  321. if (i == 112)
  322. client.setTab(3);
  323. else if (i == 113)
  324. client.setTab(4);
  325. else if (i == 114)
  326. client.setTab(5);
  327. else if (i == 115)
  328. client.setTab(6);
  329. else if (i == 116) {
  330. client.setTab(0);
  331. }
  332. }
  333. else if (i == 27)
  334. client.setTab(0);
  335. else if (i == 112)
  336. client.setTab(3);
  337. else if (i == 113)
  338. client.setTab(1);
  339. else if (i == 114)
  340. client.setTab(2);
  341. else if (i == 115)
  342. client.setTab(3);
  343. else if (i == 116)
  344. client.setTab(4);
  345. else if (i == 117)
  346. client.setTab(5);
  347. else if (i == 118)
  348. client.setTab(6);
  349. else if (i == 119)
  350. client.setTab(7);
  351. else if (i == 120)
  352. client.setTab(8);
  353. else if (i == 121)
  354. client.setTab(9);
  355. else if (i == 122)
  356. client.setTab(10);
  357. else if (i == 123) {
  358. client.setTab(11);
  359. }
  360.  
  361. if (j < 30)
  362. j = 0;
  363. if (i == 37)
  364. j = 1;
  365. if (i == 39)
  366. j = 2;
  367. if (i == 38)
  368. j = 3;
  369. if (i == 40)
  370. j = 4;
  371. if (i == 17)
  372. j = 5;
  373. if (i == 8)
  374. j = 8;
  375. if (i == 127)
  376. j = 8;
  377. if (i == 9)
  378. j = 9;
  379. if (i == 10)
  380. j = 10;
  381. if ((i >= 112) && (i <= 123))
  382. j = 1008 + i - 112;
  383. if (i == 36)
  384. j = 1000;
  385. if (i == 35)
  386. j = 1001;
  387. if (i == 33)
  388. j = 1002;
  389. if (i == 34)
  390. j = 1003;
  391. if ((j > 0) && (j < 128))
  392. this.keyArray[j] = 1;
  393. if (j > 4)
  394. {
  395. this.charQueue[this.writeIndex] = j;
  396. this.writeIndex = (this.writeIndex + 1 & 0x7F);
  397. }
  398. }
  399.  
  400. public final void keyReleased(KeyEvent paramKeyEvent)
  401. {
  402. this.idleTime = 0;
  403. int i = paramKeyEvent.getKeyCode();
  404. int j = paramKeyEvent.getKeyChar();
  405. if (j < 30)
  406. j = 0;
  407. if (i == 37)
  408. j = 1;
  409. if (i == 39)
  410. j = 2;
  411. if (i == 38)
  412. j = 3;
  413. if (i == 40)
  414. j = 4;
  415. if (i == 17)
  416. j = 5;
  417. if (i == 8)
  418. j = 8;
  419. if (i == 127)
  420. j = 8;
  421. if (i == 9)
  422. j = 9;
  423. if (i == 10)
  424. j = 10;
  425. if ((j > 0) && (j < 128))
  426. this.keyArray[j] = 0;
  427. }
  428.  
  429. public final void keyTyped(KeyEvent paramKeyEvent)
  430. {
  431. }
  432.  
  433. final int readChar(int paramInt)
  434. {
  435. while (paramInt >= 0) {
  436. for (i = 1; i > 0; i++);
  437. }
  438. int i = -1;
  439. if (this.writeIndex != this.readIndex)
  440. {
  441. i = this.charQueue[this.readIndex];
  442. this.readIndex = (this.readIndex + 1 & 0x7F);
  443. }
  444. return i;
  445. }
  446.  
  447. public final void focusGained(FocusEvent paramFocusEvent)
  448. {
  449. this.awtFocus = true;
  450. this.shouldClearScreen = true;
  451. raiseWelcomeScreen();
  452. }
  453.  
  454. public final void focusLost(FocusEvent paramFocusEvent)
  455. {
  456. this.awtFocus = false;
  457. for (int i = 0; i < 128; i++)
  458. this.keyArray[i] = 0;
  459. }
  460.  
  461. public final void windowActivated(WindowEvent paramWindowEvent)
  462. {
  463. }
  464.  
  465. public final void windowClosed(WindowEvent paramWindowEvent)
  466. {
  467. }
  468.  
  469. public final void windowClosing(WindowEvent paramWindowEvent)
  470. {
  471. destroy();
  472. }
  473.  
  474. public final void windowDeactivated(WindowEvent paramWindowEvent)
  475. {
  476. }
  477.  
  478. public final void windowDeiconified(WindowEvent paramWindowEvent)
  479. {
  480. }
  481.  
  482. public final void windowIconified(WindowEvent paramWindowEvent)
  483. {
  484. }
  485.  
  486. public final void windowOpened(WindowEvent paramWindowEvent)
  487. {
  488. }
  489.  
  490. void startUp()
  491. {
  492. }
  493.  
  494. void processGameLoop()
  495. {
  496. }
  497.  
  498. void cleanUpForQuit()
  499. {
  500. }
  501.  
  502. void processDrawing()
  503. {
  504. }
  505.  
  506. void raiseWelcomeScreen()
  507. {
  508. }
  509.  
  510. Component getGameComponent()
  511. {
  512. if (this.gameFrame != null) {
  513. return this.gameFrame;
  514. }
  515. return this;
  516. }
  517.  
  518. public void startRunnable(Runnable paramRunnable, int paramInt)
  519. {
  520. Thread localThread = new Thread(paramRunnable);
  521. localThread.start();
  522. localThread.setPriority(paramInt);
  523. }
  524.  
  525. void drawLoadingText(int paramInt, String paramString)
  526. {
  527. while (this.graphics == null)
  528. {
  529. this.graphics = getGameComponent().getGraphics();
  530. try
  531. {
  532. getGameComponent().repaint();
  533. }
  534. catch (Exception localException1) {
  535. }
  536. try {
  537. Thread.sleep(1000L);
  538. } catch (Exception localException2) {
  539. }
  540. }
  541. Font localFont1 = new Font("Helvetica", 1, 13);
  542. FontMetrics localFontMetrics = getGameComponent().getFontMetrics(localFont1);
  543. Font localFont2 = new Font("Helvetica", 0, 13);
  544. getGameComponent().getFontMetrics(localFont2);
  545. if (this.shouldClearScreen)
  546. {
  547. this.graphics.setColor(Color.black);
  548. this.graphics.fillRect(0, 0, this.myWidth, this.myHeight);
  549. this.shouldClearScreen = false;
  550. }
  551. Color localColor = new Color(140, 17, 17);
  552. int i = this.myHeight / 2 - 18;
  553. this.graphics.setColor(localColor);
  554. this.graphics.drawRect(this.myWidth / 2 - 152, i, 304, 34);
  555. this.graphics.fillRect(this.myWidth / 2 - 150, i + 2, paramInt * 3, 30);
  556. this.graphics.setColor(Color.black);
  557. this.graphics.fillRect(this.myWidth / 2 - 150 + paramInt * 3, i + 2, 300 - paramInt * 3, 30);
  558. this.graphics.setFont(localFont1);
  559. this.graphics.setColor(Color.white);
  560. this.graphics.drawString(paramString, (this.myWidth - localFontMetrics.stringWidth(paramString)) / 2, i + 22);
  561. }
  562.  
  563. RSApplet()
  564. {
  565. this.delayTime = 20;
  566. this.minDelay = 1;
  567. this.aLongArray7 = new long[10];
  568. this.shouldDebug = false;
  569. this.shouldClearScreen = true;
  570. this.awtFocus = true;
  571. this.keyArray = new int['€'];
  572. this.charQueue = new int['€'];
  573. }
  574. }
Add Comment
Please, Sign In to add comment