Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.event.FocusEvent;
- import java.awt.event.FocusListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.io.PrintStream;
- public class RSApplet extends Applet
- implements Runnable, MouseListener, MouseMotionListener, KeyListener, FocusListener, WindowListener
- {
- public static int hotKey = 508;
- private int anInt4;
- private int delayTime;
- int minDelay;
- private final long[] aLongArray7;
- int fps;
- boolean shouldDebug;
- int myWidth;
- int myHeight;
- Graphics graphics;
- RSImageProducer fullGameScreen;
- RSFrame gameFrame;
- private boolean shouldClearScreen;
- boolean awtFocus;
- int idleTime;
- int clickMode2;
- public int mouseX;
- public int mouseY;
- private int clickMode1;
- private int clickX;
- private int clickY;
- private long clickTime;
- int clickMode3;
- int saveClickX;
- int saveClickY;
- long aLong29;
- final int[] keyArray;
- private final int[] charQueue;
- private int readIndex;
- private int writeIndex;
- public static int anInt34;
- final void createClientFrame(int paramInt1, int paramInt2)
- {
- this.myWidth = paramInt2;
- this.myHeight = paramInt1;
- this.gameFrame = new RSFrame(this, this.myWidth, this.myHeight);
- this.graphics = getGameComponent().getGraphics();
- this.fullGameScreen = new RSImageProducer(this.myWidth, this.myHeight, getGameComponent());
- startRunnable(this, 1);
- }
- final void initClientFrame(int paramInt1, int paramInt2) {
- this.myWidth = paramInt2;
- this.myHeight = paramInt1;
- this.graphics = getGameComponent().getGraphics();
- this.fullGameScreen = new RSImageProducer(this.myWidth, this.myHeight, getGameComponent());
- startRunnable(this, 1);
- }
- public void run()
- {
- getGameComponent().addMouseListener(this);
- getGameComponent().addMouseMotionListener(this);
- getGameComponent().addKeyListener(this);
- getGameComponent().addFocusListener(this);
- if (this.gameFrame != null)
- this.gameFrame.addWindowListener(this);
- drawLoadingText(0, "Loading...");
- startUp();
- int i = 0;
- int j = 256;
- int k = 1;
- int m = 0;
- int n = 0;
- for (int i1 = 0; i1 < 10; i1++) {
- this.aLongArray7[i1] = System.currentTimeMillis();
- }
- long l1 = System.currentTimeMillis();
- while (this.anInt4 >= 0)
- {
- if (this.anInt4 > 0)
- {
- this.anInt4 -= 1;
- if (this.anInt4 == 0)
- {
- exit();
- return;
- }
- }
- int i2 = j;
- int i3 = k;
- j = 300;
- k = 1;
- long l2 = System.currentTimeMillis();
- if (this.aLongArray7[i] == 0L)
- {
- j = i2;
- k = i3;
- }
- else if (l2 > this.aLongArray7[i]) {
- j = (int)(2560 * this.delayTime / (l2 - this.aLongArray7[i]));
- }if (j < 25)
- j = 25;
- if (j > 256)
- {
- j = 256;
- k = (int)(this.delayTime - (l2 - this.aLongArray7[i]) / 10L);
- }
- if (k > this.delayTime)
- k = this.delayTime;
- this.aLongArray7[i] = l2;
- i = (i + 1) % 10;
- if (k > 1)
- {
- for (int i4 = 0; i4 < 10; i4++) {
- if (this.aLongArray7[i4] != 0L)
- this.aLongArray7[i4] += k;
- }
- }
- if (k < this.minDelay)
- k = this.minDelay;
- try
- {
- Thread.sleep(k);
- }
- catch (InterruptedException localInterruptedException)
- {
- n++;
- }
- for (; m < 256; m += j)
- {
- this.clickMode3 = this.clickMode1;
- this.saveClickX = this.clickX;
- this.saveClickY = this.clickY;
- this.aLong29 = this.clickTime;
- this.clickMode1 = 0;
- processGameLoop();
- this.readIndex = this.writeIndex;
- }
- m &= 255;
- if (this.delayTime > 0)
- this.fps = (1000 * j / (this.delayTime * 256));
- processDrawing();
- if (this.shouldDebug)
- {
- System.out.println("ntime:" + l2);
- for (int i5 = 0; i5 < 10; i5++)
- {
- int i6 = (i - i5 - 1 + 20) % 10;
- System.out.println("otim" + i6 + ":" + this.aLongArray7[i6]);
- }
- System.out.println("fps:" + this.fps + " ratio:" + j + " count:" + m);
- System.out.println("del:" + k + " deltime:" + this.delayTime + " mindel:" + this.minDelay);
- System.out.println("intex:" + n + " opos:" + i);
- this.shouldDebug = false;
- n = 0;
- }
- }
- if (this.anInt4 == -1)
- exit();
- }
- private void exit()
- {
- this.anInt4 = -2;
- cleanUpForQuit();
- if (this.gameFrame != null)
- {
- try
- {
- Thread.sleep(1000L);
- }
- catch (Exception localException) {
- }
- try {
- System.exit(0);
- }
- catch (Throwable localThrowable) {
- }
- }
- }
- final void method4(int paramInt) {
- this.delayTime = (1000 / paramInt);
- }
- public final void start()
- {
- if (this.anInt4 >= 0)
- this.anInt4 = 0;
- }
- public final void stop()
- {
- if (this.anInt4 >= 0)
- this.anInt4 = (4000 / this.delayTime);
- }
- public final void destroy()
- {
- this.anInt4 = -1;
- try
- {
- Thread.sleep(5000L);
- } catch (Exception localException) {
- }
- if (this.anInt4 == -1)
- exit();
- }
- public final void update(Graphics paramGraphics)
- {
- if (this.graphics == null)
- this.graphics = paramGraphics;
- this.shouldClearScreen = true;
- raiseWelcomeScreen();
- }
- public final void paint(Graphics paramGraphics)
- {
- if (this.graphics == null)
- this.graphics = paramGraphics;
- this.shouldClearScreen = true;
- raiseWelcomeScreen();
- }
- public final void mousePressed(MouseEvent paramMouseEvent)
- {
- int i = paramMouseEvent.getX();
- int j = paramMouseEvent.getY();
- if (this.gameFrame != null)
- {
- i -= 4;
- j -= 22;
- }
- this.idleTime = 0;
- this.clickX = i;
- this.clickY = j;
- this.clickTime = System.currentTimeMillis();
- if (paramMouseEvent.isMetaDown())
- {
- this.clickMode1 = 2;
- this.clickMode2 = 2;
- }
- else {
- this.clickMode1 = 1;
- this.clickMode2 = 1;
- }
- }
- public final void mouseReleased(MouseEvent paramMouseEvent)
- {
- this.idleTime = 0;
- this.clickMode2 = 0;
- }
- public final void mouseClicked(MouseEvent paramMouseEvent)
- {
- }
- public final void mouseEntered(MouseEvent paramMouseEvent)
- {
- }
- public final void mouseExited(MouseEvent paramMouseEvent)
- {
- this.idleTime = 0;
- this.mouseX = -1;
- this.mouseY = -1;
- }
- public final void mouseDragged(MouseEvent paramMouseEvent)
- {
- int i = paramMouseEvent.getX();
- int j = paramMouseEvent.getY();
- if (this.gameFrame != null)
- {
- i -= 4;
- j -= 22;
- }
- this.idleTime = 0;
- this.mouseX = i;
- this.mouseY = j;
- }
- public final void mouseMoved(MouseEvent paramMouseEvent)
- {
- int i = paramMouseEvent.getX();
- int j = paramMouseEvent.getY();
- if (this.gameFrame != null)
- {
- i -= 4;
- j -= 22;
- }
- this.idleTime = 0;
- this.mouseX = i;
- this.mouseY = j;
- }
- public final void keyPressed(KeyEvent paramKeyEvent)
- {
- this.idleTime = 0;
- int i = paramKeyEvent.getKeyCode();
- int j = paramKeyEvent.getKeyChar();
- if (hotKey == 508)
- {
- if (i == 112)
- client.setTab(3);
- else if (i == 113)
- client.setTab(4);
- else if (i == 114)
- client.setTab(5);
- else if (i == 115)
- client.setTab(6);
- else if (i == 116) {
- client.setTab(0);
- }
- }
- else if (i == 27)
- client.setTab(0);
- else if (i == 112)
- client.setTab(3);
- else if (i == 113)
- client.setTab(1);
- else if (i == 114)
- client.setTab(2);
- else if (i == 115)
- client.setTab(3);
- else if (i == 116)
- client.setTab(4);
- else if (i == 117)
- client.setTab(5);
- else if (i == 118)
- client.setTab(6);
- else if (i == 119)
- client.setTab(7);
- else if (i == 120)
- client.setTab(8);
- else if (i == 121)
- client.setTab(9);
- else if (i == 122)
- client.setTab(10);
- else if (i == 123) {
- client.setTab(11);
- }
- if (j < 30)
- j = 0;
- if (i == 37)
- j = 1;
- if (i == 39)
- j = 2;
- if (i == 38)
- j = 3;
- if (i == 40)
- j = 4;
- if (i == 17)
- j = 5;
- if (i == 8)
- j = 8;
- if (i == 127)
- j = 8;
- if (i == 9)
- j = 9;
- if (i == 10)
- j = 10;
- if ((i >= 112) && (i <= 123))
- j = 1008 + i - 112;
- if (i == 36)
- j = 1000;
- if (i == 35)
- j = 1001;
- if (i == 33)
- j = 1002;
- if (i == 34)
- j = 1003;
- if ((j > 0) && (j < 128))
- this.keyArray[j] = 1;
- if (j > 4)
- {
- this.charQueue[this.writeIndex] = j;
- this.writeIndex = (this.writeIndex + 1 & 0x7F);
- }
- }
- public final void keyReleased(KeyEvent paramKeyEvent)
- {
- this.idleTime = 0;
- int i = paramKeyEvent.getKeyCode();
- int j = paramKeyEvent.getKeyChar();
- if (j < 30)
- j = 0;
- if (i == 37)
- j = 1;
- if (i == 39)
- j = 2;
- if (i == 38)
- j = 3;
- if (i == 40)
- j = 4;
- if (i == 17)
- j = 5;
- if (i == 8)
- j = 8;
- if (i == 127)
- j = 8;
- if (i == 9)
- j = 9;
- if (i == 10)
- j = 10;
- if ((j > 0) && (j < 128))
- this.keyArray[j] = 0;
- }
- public final void keyTyped(KeyEvent paramKeyEvent)
- {
- }
- final int readChar(int paramInt)
- {
- while (paramInt >= 0) {
- for (i = 1; i > 0; i++);
- }
- int i = -1;
- if (this.writeIndex != this.readIndex)
- {
- i = this.charQueue[this.readIndex];
- this.readIndex = (this.readIndex + 1 & 0x7F);
- }
- return i;
- }
- public final void focusGained(FocusEvent paramFocusEvent)
- {
- this.awtFocus = true;
- this.shouldClearScreen = true;
- raiseWelcomeScreen();
- }
- public final void focusLost(FocusEvent paramFocusEvent)
- {
- this.awtFocus = false;
- for (int i = 0; i < 128; i++)
- this.keyArray[i] = 0;
- }
- public final void windowActivated(WindowEvent paramWindowEvent)
- {
- }
- public final void windowClosed(WindowEvent paramWindowEvent)
- {
- }
- public final void windowClosing(WindowEvent paramWindowEvent)
- {
- destroy();
- }
- public final void windowDeactivated(WindowEvent paramWindowEvent)
- {
- }
- public final void windowDeiconified(WindowEvent paramWindowEvent)
- {
- }
- public final void windowIconified(WindowEvent paramWindowEvent)
- {
- }
- public final void windowOpened(WindowEvent paramWindowEvent)
- {
- }
- void startUp()
- {
- }
- void processGameLoop()
- {
- }
- void cleanUpForQuit()
- {
- }
- void processDrawing()
- {
- }
- void raiseWelcomeScreen()
- {
- }
- Component getGameComponent()
- {
- if (this.gameFrame != null) {
- return this.gameFrame;
- }
- return this;
- }
- public void startRunnable(Runnable paramRunnable, int paramInt)
- {
- Thread localThread = new Thread(paramRunnable);
- localThread.start();
- localThread.setPriority(paramInt);
- }
- void drawLoadingText(int paramInt, String paramString)
- {
- while (this.graphics == null)
- {
- this.graphics = getGameComponent().getGraphics();
- try
- {
- getGameComponent().repaint();
- }
- catch (Exception localException1) {
- }
- try {
- Thread.sleep(1000L);
- } catch (Exception localException2) {
- }
- }
- Font localFont1 = new Font("Helvetica", 1, 13);
- FontMetrics localFontMetrics = getGameComponent().getFontMetrics(localFont1);
- Font localFont2 = new Font("Helvetica", 0, 13);
- getGameComponent().getFontMetrics(localFont2);
- if (this.shouldClearScreen)
- {
- this.graphics.setColor(Color.black);
- this.graphics.fillRect(0, 0, this.myWidth, this.myHeight);
- this.shouldClearScreen = false;
- }
- Color localColor = new Color(140, 17, 17);
- int i = this.myHeight / 2 - 18;
- this.graphics.setColor(localColor);
- this.graphics.drawRect(this.myWidth / 2 - 152, i, 304, 34);
- this.graphics.fillRect(this.myWidth / 2 - 150, i + 2, paramInt * 3, 30);
- this.graphics.setColor(Color.black);
- this.graphics.fillRect(this.myWidth / 2 - 150 + paramInt * 3, i + 2, 300 - paramInt * 3, 30);
- this.graphics.setFont(localFont1);
- this.graphics.setColor(Color.white);
- this.graphics.drawString(paramString, (this.myWidth - localFontMetrics.stringWidth(paramString)) / 2, i + 22);
- }
- RSApplet()
- {
- this.delayTime = 20;
- this.minDelay = 1;
- this.aLongArray7 = new long[10];
- this.shouldDebug = false;
- this.shouldClearScreen = true;
- this.awtFocus = true;
- this.keyArray = new int[''];
- this.charQueue = new int[''];
- }
- }
Add Comment
Please, Sign In to add comment