home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.util.NoSuchElementException;
- import java.util.StringTokenizer;
-
- public class jumpman extends Applet implements Runnable {
- private Thread engineThread;
- private String lbl;
- private char[] label;
- private int stringLen;
- private int count;
- private int loop;
- private int speed;
- private int sleepTime = 50;
- private int jumpheight;
- private Font font;
- private boolean userPause = false;
- private String reguser;
- private String serialid;
- private int passkey;
- private Color fgColor;
- private Color bgColor;
- private int red = 255;
- private int blue;
- private int green;
- private int fade;
- private int jump_char;
- private int movey;
- private boolean yUp = true;
- private boolean readyToPaint;
- private boolean popcorn = false;
- private int height;
- // $FF: renamed from: x int
- private int field_0;
- // $FF: renamed from: y int
- private int field_1;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_2;
- private Image offImage;
- private Graphics offGraphics;
- private boolean matched = false;
- private boolean unreg = true;
- private boolean debug = false;
-
- public String getAppletInfo() {
- return "HotDog3 - jumpman.class v1.0 Copyright Sausage SoftWare 1996";
- }
-
- private void dbg(String var1) {
- if (this.debug) {
- System.out.println(var1);
- }
-
- }
-
- public void init() {
- String var1 = ((Applet)this).getParameter("fontsize");
- int var2 = var1 == null ? 12 : Integer.valueOf(var1);
- int var3 = 0;
- var1 = ((Applet)this).getParameter("style");
- var3 = this.getFontStyle(var1);
- var1 = ((Applet)this).getParameter("font");
- String var4 = this.getFontName(var1);
- this.dbg(var4);
- this.font = new Font(var4, var3, var2);
- var1 = ((Applet)this).getParameter("text");
- this.lbl = var1 == null ? "Sausage Software" : var1;
- this.label = this.lbl.toCharArray();
- this.stringLen = this.lbl.length();
- this.reguser = ((Applet)this).getParameter("reguser");
- if (this.reguser == null) {
- this.NotRegistered();
- }
-
- if (this.reguser.toLowerCase().equals("unregistered")) {
- this.unreg = true;
- } else {
- this.unreg = false;
- }
-
- this.serialid = ((Applet)this).getParameter("serialid");
- if (this.serialid == null) {
- this.NotRegistered();
- }
-
- this.matched = this.verifyUser(this.lbl);
- if (!this.matched) {
- this.NotRegistered();
- }
-
- var1 = ((Applet)this).getParameter("jumpstep");
- this.speed = var1 == null ? 100 : Integer.parseInt(var1);
- var1 = ((Applet)this).getParameter("vertical");
- this.jumpheight = var1 == null ? 10 : Integer.parseInt(var1);
- var1 = ((Applet)this).getParameter("speed");
- this.sleepTime = var1 == null ? 50 : Integer.parseInt(var1);
- var1 = ((Applet)this).getParameter("popcorn");
- if ("yes".equals(var1)) {
- this.popcorn = true;
- }
-
- var1 = ((Applet)this).getParameter("color");
- if (var1 != null) {
- this.fgColor = this.getColor(var1, ",");
- }
-
- var1 = ((Applet)this).getParameter("background");
- if (var1 != null) {
- this.bgColor = this.getColor(var1, ",");
- }
-
- try {
- this.offImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- } catch (Exception var5) {
- this.offGraphics = null;
- }
-
- this.field_1 = ((Component)this).size().height / 2 + var2 / 2;
- this.movey = this.field_1;
- this.height = this.field_1 - this.jumpheight;
- }
-
- private Color getColor(String var1, String var2) {
- StringTokenizer var3 = new StringTokenizer(var1, var2);
-
- try {
- int var5 = Integer.parseInt(var3.nextToken());
- int var6 = Integer.parseInt(var3.nextToken());
- int var7 = Integer.parseInt(var3.nextToken());
- Color var4 = new Color(var5, var6, var7);
- return var4;
- } catch (NoSuchElementException var8) {
- return new Color(255, 0, 0);
- }
- }
-
- private synchronized void prePaint(Graphics var1) {
- var1.setColor(this.bgColor);
- var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- var1.setColor(this.fgColor);
- var1.setFont(this.font);
- this.field_2 = var1.getFontMetrics();
- this.field_0 = ((Component)this).size().width / 2 - this.field_2.stringWidth(this.lbl) / 2;
- this.dbg("movey" + this.movey);
-
- for(int var2 = 0; var2 < this.stringLen; ++var2) {
- if (var2 != this.jump_char) {
- var1.drawChars(this.label, var2, 1, this.field_0, this.field_1);
- } else {
- var1.drawChars(this.label, var2, 1, this.field_0, this.movey);
- }
-
- this.field_0 += this.field_2.charWidth(this.label[var2]);
- }
-
- }
-
- private synchronized void xyUpdate() {
- if (this.yUp) {
- this.movey -= this.speed;
- } else {
- this.movey += this.speed;
- }
-
- if (this.movey < this.height) {
- this.yUp = false;
- } else if (this.movey > this.field_1) {
- if (this.popcorn) {
- this.jump_char = (int)(Math.random() * (double)100.0F % (double)this.stringLen);
- } else {
- ++this.jump_char;
- }
-
- this.movey = this.field_1;
- this.yUp = true;
-
- try {
- while(Character.isSpace(this.label[this.jump_char])) {
- ++this.jump_char;
- }
- } catch (ArrayIndexOutOfBoundsException var1) {
- }
- }
-
- if (this.jump_char > this.stringLen) {
- this.jump_char = 0;
- }
-
- }
-
- public void paint(Graphics var1) {
- if (this.engineThread != null) {
- if (this.matched) {
- this.offGraphics = this.offImage.getGraphics();
- this.prePaint(this.offGraphics);
- this.offGraphics.dispose();
- var1.drawImage(this.offImage, 0, 0, this);
- return;
- }
-
- var1.setColor(this.fgColor);
- var1.drawString("Applet parameters have changed, please recompile with HotDog", 2, ((Component)this).size().height - 2);
- ((Applet)this).showStatus("jumpman.class: Applet parameters have changed, please recompile with HotDog");
- }
-
- }
-
- public void start() {
- if (this.engineThread == null) {
- this.engineThread = new Thread(this);
- }
-
- this.engineThread.start();
- }
-
- public void stop() {
- if (this.engineThread != null && this.engineThread.isAlive()) {
- this.engineThread.stop();
- }
-
- this.engineThread = null;
- }
-
- public void update(Graphics var1) {
- if (this.readyToPaint) {
- this.paint(var1);
- }
-
- }
-
- public void run() {
- while(true) {
- if (this.unreg && this.matched) {
- ((Applet)this).getAppletContext().showStatus("Unregistered version. Copyright (c) Sausage Software 1996");
- }
-
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)(this.sleepTime + 10));
- } catch (Exception var1) {
- }
-
- this.readyToPaint = false;
- this.xyUpdate();
- this.readyToPaint = true;
- }
- }
-
- public boolean handleEvent(Event var1) {
- if (var1.id == 501) {
- if (this.userPause) {
- this.engineThread.resume();
- } else {
- this.engineThread.suspend();
- }
-
- this.userPause = !this.userPause;
- } else if (var1.id == 201) {
- this.stop();
- System.exit(0);
- }
-
- return true;
- }
-
- private boolean verifyUser(String var1) {
- this.passkey = this.decryption(var1);
- this.passkey += this.decryption(this.reguser);
- String var2 = this.intoLetters(Long.toString((long)this.passkey));
- this.matched = this.serialid.regionMatches(true, 0, var2, 0, var2.length());
- return this.matched;
- }
-
- private void NotRegistered() {
- System.out.println("Applet not registered");
- this.matched = false;
- }
-
- private int decryption(String var1) {
- int var2 = 0;
- long var3 = 345L;
- long var5 = 56L;
- long var7 = 345L;
- long var9 = 49L;
-
- for(int var11 = 0; var11 < var1.length(); ++var11) {
- var2 += var1.charAt(var11);
- var3 = (long)((double)(var5 * 23L) / (double)2.5F + (double)var7);
- var9 = 34L / var7;
- var5 = var3 + var5 + (long)var2;
- }
-
- return var2;
- }
-
- private String intoLetters(String var1) {
- char[] var2 = new char[var1.length()];
-
- for(int var3 = 0; var3 < var1.length(); ++var3) {
- var2[var3] = (char)(Character.digit(var1.charAt(var3), 10) + 65);
- }
-
- return String.valueOf(var2);
- }
-
- public String getFontName(String var1) {
- if (var1 == null) {
- return new String("Helvetica");
- } else {
- Object var2 = null;
- String var3 = var1.toLowerCase();
- String var4;
- if (var3.equals("courier")) {
- var4 = "Courier";
- } else if (var3.equals("helvetica")) {
- var4 = "Helvetica";
- } else if (var3.equals("dialog")) {
- var4 = "Dialog";
- } else if (var3.equals("timesroman")) {
- var4 = "TimesRoman";
- } else if (var3.equals("times roman")) {
- var4 = "TimesRoman";
- } else if (var3.equals("symbol")) {
- var4 = "Symbol";
- } else if (var3.equals("dialoginput")) {
- var4 = "DialogInput";
- } else if (var3.equals("zapfdingbats")) {
- var4 = "ZapfDingbats";
- } else {
- var4 = "Helvetica";
- }
-
- return new String(var4);
- }
- }
-
- public int getFontStyle(String var1) {
- if (var1 == null) {
- return 0;
- } else {
- String var2 = var1.toLowerCase();
- if ("italic".equals(var2)) {
- return 2;
- } else if ("bold".equals(var2)) {
- return 1;
- } else {
- return !"bold+italic".equals(var2) && !"italic+bold".equals(var2) ? 0 : 3;
- }
- }
- }
- }
-