home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Memory / Memory.jar / MemoryGame / MemoryCanvas.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-01-04  |  14.8 KB  |  746 lines

  1. package MemoryGame;
  2.  
  3. import java.io.ByteArrayInputStream;
  4. import java.io.ByteArrayOutputStream;
  5. import java.io.DataInputStream;
  6. import java.io.DataOutputStream;
  7. import java.util.Random;
  8. import java.util.Timer;
  9. import javax.microedition.lcdui.Canvas;
  10. import javax.microedition.lcdui.Display;
  11. import javax.microedition.lcdui.Font;
  12. import javax.microedition.lcdui.Graphics;
  13. import javax.microedition.lcdui.Image;
  14. import javax.microedition.rms.RecordStore;
  15.  
  16. public class MemoryCanvas extends Canvas implements Runnable {
  17.    private Display display;
  18.    private Display BackBuff;
  19.    // $FF: renamed from: h int
  20.    private int field_0 = 0;
  21.    // $FF: renamed from: w int
  22.    private int field_1 = 0;
  23.    private Image[] Card;
  24.    public int[] XPos;
  25.    public int[] YPos;
  26.    public int[] CardId;
  27.    public boolean[] CardVis;
  28.    public boolean[] CardCleard;
  29.    long time1;
  30.    long time2;
  31.    long wait1;
  32.    long wait2;
  33.    long Level;
  34.    long RestTime;
  35.    boolean ShowGetTimeBonus;
  36.    boolean ShowPerfect;
  37.    boolean ShowHighScore;
  38.    boolean StartGame;
  39.    boolean EndGame;
  40.    boolean Begin;
  41.    boolean ShowTitel;
  42.    boolean NoPaintBorad;
  43.    boolean RoundClear;
  44.    boolean Perfect;
  45.    boolean BreakWhile;
  46.    boolean GetTimeBonusActive;
  47.    boolean CanBreak;
  48.    boolean NoCheckTwice;
  49.    int score;
  50.    Font font;
  51.    Timer timer = new Timer();
  52.    Thread thread;
  53.    public String[] names = new String[]{"Mem", "Mem", "Mem", "Mem"};
  54.    public int[] values = new int[]{2000, 1700, 1500, 100};
  55.    public static int TitX1;
  56.    public static int TitX2;
  57.    public static int TitX3;
  58.    public static int TitX4;
  59.    public static int TitX5;
  60.    public static int TitY1;
  61.    public static int TitY2;
  62.    public static int TitY3;
  63.    public static int TitY4;
  64.    public static int TitY5;
  65.    private Image _buffer;
  66.  
  67.    public MemoryCanvas(Display var1) {
  68.       this.GetHighScores();
  69.       this.InitGraphics();
  70.       this.SetCardPos();
  71.       this.display = var1;
  72.       this.thread = new Thread(this);
  73.       this.thread.start();
  74.    }
  75.  
  76.    protected void keyPressed(int var1) {
  77.       if (this.CardsVisible() < 3) {
  78.          if (this.CardsVisible() == 2) {
  79.             this.NoCheckTwice = true;
  80.             this.CheckForGoed();
  81.  
  82.             for(int var2 = 0; var2 < 13; ++var2) {
  83.                this.CardVis[var2] = false;
  84.             }
  85.  
  86.             ((Canvas)this).repaint();
  87.             Thread.yield();
  88.             this.NoCheckTwice = true;
  89.          }
  90.  
  91.          if (this.CanBreak) {
  92.             this.BreakWhile = true;
  93.          }
  94.  
  95.          if (this.ShowGetTimeBonus || this.ShowPerfect) {
  96.             var1 = 0;
  97.          }
  98.  
  99.          if (this.StartGame) {
  100.             if (var1 == 49 & !this.CardVis[1] & !this.CardCleard[1]) {
  101.                this.CardVis[1] = true;
  102.             }
  103.  
  104.             if (var1 == 50 & !this.CardVis[2] & !this.CardCleard[2]) {
  105.                this.CardVis[2] = true;
  106.             }
  107.  
  108.             if (var1 == 51 & !this.CardVis[3] & !this.CardCleard[3]) {
  109.                this.CardVis[3] = true;
  110.             }
  111.  
  112.             if (var1 == 52 & !this.CardVis[4] & !this.CardCleard[4]) {
  113.                this.CardVis[4] = true;
  114.             }
  115.  
  116.             if (var1 == 53 & !this.CardVis[5] & !this.CardCleard[5]) {
  117.                this.CardVis[5] = true;
  118.                this.StartGame = true;
  119.             }
  120.  
  121.             if (var1 == 54 & !this.CardVis[6] & !this.CardCleard[6]) {
  122.                this.CardVis[6] = true;
  123.             }
  124.  
  125.             if (var1 == 55 & !this.CardVis[7] & !this.CardCleard[7]) {
  126.                this.CardVis[7] = true;
  127.             }
  128.  
  129.             if (var1 == 56 & !this.CardVis[8] & !this.CardCleard[8]) {
  130.                this.CardVis[8] = true;
  131.             }
  132.  
  133.             if (var1 == 57 & !this.CardVis[9] & !this.CardCleard[9]) {
  134.                this.CardVis[9] = true;
  135.             }
  136.  
  137.             if (var1 == 42 & !this.CardVis[10] & !this.CardCleard[10]) {
  138.                this.CardVis[10] = true;
  139.             }
  140.  
  141.             if (var1 == 48 & !this.CardVis[11] & !this.CardCleard[11]) {
  142.                this.CardVis[11] = true;
  143.             }
  144.  
  145.             if (var1 == 35 & !this.CardVis[12] & !this.CardCleard[12]) {
  146.                this.CardVis[12] = true;
  147.             }
  148.          } else if (var1 == 53) {
  149.             this.StartGame = true;
  150.          }
  151.       }
  152.  
  153.       ((Canvas)this).repaint();
  154.    }
  155.  
  156.    protected void keyRepeated(int var1) {
  157.    }
  158.  
  159.    protected void keyReleased(int var1) {
  160.    }
  161.  
  162.    protected void pointerPressed(int var1, int var2) {
  163.    }
  164.  
  165.    protected void pointerReleased(int var1, int var2) {
  166.    }
  167.  
  168.    protected void pointerDragged(int var1, int var2) {
  169.    }
  170.  
  171.    public void run() {
  172.       this.Begin = true;
  173.       this.StartGame = false;
  174.       this.ShowTitel = false;
  175.  
  176.       for(this.EndGame = true; this.Begin; this.StartGame = false) {
  177.          TitX1 = 100;
  178.          TitY2 = 80;
  179.          TitX3 = -100;
  180.          TitX4 = 100;
  181.          int var1 = 850;
  182.          int var2 = 50000;
  183.          this.Level = 1L;
  184.          this.score = 0;
  185.          this.EndGame = true;
  186.          this.NoPaintBorad = true;
  187.          this.ShowTitel = true;
  188.          ((Canvas)this).repaint();
  189.          Thread.yield();
  190.          this.CanBreak = true;
  191.          this.wait(10000);
  192.          this.ShowTitel = false;
  193.          ((Canvas)this).repaint();
  194.          Thread.yield();
  195.          this.ShowHighScore = true;
  196.          ((Canvas)this).repaint();
  197.          Thread.yield();
  198.          this.CanBreak = true;
  199.          this.wait(7000);
  200.          this.ShowHighScore = false;
  201.          ((Canvas)this).repaint();
  202.          Thread.yield();
  203.          if (this.StartGame) {
  204.             this.EndGame = false;
  205.          }
  206.  
  207.          while(!this.EndGame) {
  208.             this.RestTime = (long)(var2 / 1000);
  209.             this.NoPaintBorad = false;
  210.             this.ResetAllCards();
  211.             this.MixCards();
  212.             this.wait(2000);
  213.             this.ShowCards(var1);
  214.             this.ShowBackCards();
  215.             this.time1 = System.currentTimeMillis();
  216.             this.time2 = System.currentTimeMillis() + (long)var2;
  217.             this.Perfect = true;
  218.             this.RoundClear = false;
  219.  
  220.             while(!this.RoundClear) {
  221.                this.time1 = System.currentTimeMillis();
  222.                this.RestTime = (this.time2 - this.time1) / 1000L;
  223.                if (this.CardsVisible() >= 2) {
  224.                   this.wait(700);
  225.                   if (this.CardsVisible() == 2) {
  226.                      this.NoCheckTwice = false;
  227.                   }
  228.  
  229.                   if (!this.NoCheckTwice) {
  230.                      this.CheckForGoed();
  231.  
  232.                      for(int var3 = 0; var3 < 13; ++var3) {
  233.                         this.CardVis[var3] = false;
  234.                      }
  235.                   }
  236.                }
  237.  
  238.                ((Canvas)this).repaint();
  239.                Thread.yield();
  240.                if (this.CheckEndRound()) {
  241.                   if (var1 > 200) {
  242.                      var1 -= 40;
  243.                   }
  244.  
  245.                   if (var2 > 15000) {
  246.                      var2 -= 3000;
  247.                   }
  248.  
  249.                   ++this.Level;
  250.  
  251.                   for(int var10 = 1; var10 < 13; ++var10) {
  252.                      this.CardCleard[var10] = false;
  253.                   }
  254.  
  255.                   if (this.Perfect) {
  256.                      this.ShowPerfect = true;
  257.                      this.score += 100;
  258.                      ((Canvas)this).repaint();
  259.                      Thread.yield();
  260.  
  261.                      try {
  262.                         Thread.sleep(1000L);
  263.                      } catch (Exception var9) {
  264.                      }
  265.  
  266.                      this.ShowPerfect = false;
  267.                   }
  268.  
  269.                   try {
  270.                      Thread.sleep(500L);
  271.                   } catch (Exception var8) {
  272.                   }
  273.  
  274.                   this.ShowGetTimeBonus = true;
  275.  
  276.                   try {
  277.                      Thread.sleep(1000L);
  278.                   } catch (Exception var7) {
  279.                   }
  280.  
  281.                   ((Canvas)this).repaint();
  282.                   Thread.yield();
  283.                   this.wait(900);
  284.  
  285.                   while(this.RestTime > 0L) {
  286.                      --this.RestTime;
  287.                      this.score += 4;
  288.                      ((Canvas)this).repaint();
  289.  
  290.                      try {
  291.                         Thread.sleep(5L);
  292.                      } catch (Exception var6) {
  293.                      }
  294.                   }
  295.  
  296.                   try {
  297.                      Thread.sleep(1000L);
  298.                   } catch (Exception var5) {
  299.                   }
  300.  
  301.                   this.ShowGetTimeBonus = false;
  302.                   this.RoundClear = true;
  303.                }
  304.  
  305.                if (this.RestTime < 0L) {
  306.                   this.RoundClear = true;
  307.                   this.EndGame = true;
  308.                }
  309.             }
  310.          }
  311.  
  312.          if (this.isHighScore(this.score)) {
  313.             MemoryMIDlet.HiScoreOk = false;
  314.             MemoryMIDlet.enterHighScore();
  315.  
  316.             while(!MemoryMIDlet.HiScoreOk) {
  317.                Thread.yield();
  318.             }
  319.  
  320.             String var11 = MemoryMIDlet._scoreField.getString();
  321.             this.addHighScore(this.score, var11);
  322.             this.NoPaintBorad = true;
  323.             this.ShowHighScore = true;
  324.             ((Canvas)this).repaint();
  325.             Thread.yield();
  326.             this.CanBreak = true;
  327.             this.wait(7000);
  328.             this.ShowHighScore = false;
  329.             ((Canvas)this).repaint();
  330.             Thread.yield();
  331.          }
  332.       }
  333.  
  334.    }
  335.  
  336.    public void wait(int var1) {
  337.       this.BreakWhile = false;
  338.       this.wait1 = System.currentTimeMillis();
  339.       this.wait2 = System.currentTimeMillis() + (long)var1;
  340.  
  341.       while(this.wait1 < this.wait2 && !this.BreakWhile) {
  342.          this.wait1 = System.currentTimeMillis();
  343.          ((Canvas)this).repaint();
  344.          Thread.yield();
  345.       }
  346.  
  347.       this.CanBreak = false;
  348.    }
  349.  
  350.    public void ResetAllCards() {
  351.       for(int var1 = 0; var1 < 13; ++var1) {
  352.          this.CardCleard[var1] = false;
  353.          this.CardVis[var1] = false;
  354.       }
  355.  
  356.    }
  357.  
  358.    public boolean CheckEndRound() {
  359.       boolean var1 = true;
  360.  
  361.       for(int var2 = 1; var2 < 13; ++var2) {
  362.          if (!this.CardCleard[var2]) {
  363.             var1 = false;
  364.          }
  365.       }
  366.  
  367.       return var1;
  368.    }
  369.  
  370.    public void CheckForGoed() {
  371.       int var1 = 0;
  372.       int var2 = 0;
  373.  
  374.       for(int var3 = 1; var3 < 13; ++var3) {
  375.          if (this.CardVis[var3]) {
  376.             if (var1 == 0) {
  377.                var1 = var3;
  378.             } else {
  379.                var2 = var3;
  380.             }
  381.          }
  382.       }
  383.  
  384.       if (var1 > 0 & var2 > 0) {
  385.          if (this.CardId[var1] == this.CardId[var2]) {
  386.             this.CardCleard[var1] = true;
  387.             this.CardCleard[var2] = true;
  388.             this.score += 10;
  389.          } else {
  390.             this.Perfect = false;
  391.          }
  392.       }
  393.  
  394.    }
  395.  
  396.    public int CardsVisible() {
  397.       int var1 = 0;
  398.  
  399.       for(int var2 = 1; var2 < 13; ++var2) {
  400.          if (this.CardVis[var2]) {
  401.             ++var1;
  402.          }
  403.       }
  404.  
  405.       return var1;
  406.    }
  407.  
  408.    public void paint(Graphics var1) {
  409.       Graphics var2 = this._buffer.getGraphics();
  410.       var2.setColor(16777215);
  411.       var2.fillRect(0, 0, this.field_1, this.field_0);
  412.       var2.setColor(0);
  413.       Font.getFont(0, 1, 8);
  414.       var2.setFont(this.font);
  415.       if (this.ShowHighScore) {
  416.          this.DisplayHighScore(var2);
  417.       }
  418.  
  419.       if (this.ShowTitel) {
  420.          this.DisplayTitle(var2);
  421.       }
  422.  
  423.       if (!this.ShowHighScore && !this.ShowTitel && !this.NoPaintBorad) {
  424.          this.DrawLevelBackGround(var2);
  425.          this.PaintCards(var2);
  426.          var2.drawString("T:" + this.RestTime, 62, 10, 20);
  427.          var2.drawString("L:" + this.Level, 62, 20, 20);
  428.          var2.drawString("S:" + this.score, 62, 40, 20);
  429.       }
  430.  
  431.       if (this.ShowGetTimeBonus) {
  432.          this.GetTimeBonus(var2, this.RestTime);
  433.       }
  434.  
  435.       if (this.ShowPerfect) {
  436.          this.GetPerfect(var2);
  437.       }
  438.  
  439.       if (this._buffer != null) {
  440.          var1.drawImage(this._buffer, 0, 0, 20);
  441.       }
  442.  
  443.    }
  444.  
  445.    public void GetTimeBonus(Graphics var1, long var2) {
  446.       var1.setColor(16777215);
  447.       var1.fillRect(0, 15, 100, 40);
  448.       var1.setColor(0);
  449.       var1.drawString("Time Bonus", 30, 20, 20);
  450.       var1.drawString("Time  " + this.RestTime + " X 4 =", 10, 36, 20);
  451.       var1.drawString("" + this.score, 80, 36, 20);
  452.    }
  453.  
  454.    public void GetPerfect(Graphics var1) {
  455.       var1.setColor(16777215);
  456.       var1.fillRect(0, 15, 100, 40);
  457.       var1.setColor(0);
  458.       var1.drawString(" Perfect", 40, 20, 20);
  459.       var1.drawString("100 Points", 40, 36, 20);
  460.    }
  461.  
  462.    public void ShowCards(int var1) {
  463.       for(int var2 = 1; var2 < 13; ++var2) {
  464.          this.CardVis[var2] = true;
  465.       }
  466.  
  467.       ((Canvas)this).repaint();
  468.       this.CanBreak = true;
  469.       this.wait(var1 * 10);
  470.    }
  471.  
  472.    public void ShowBackCards() {
  473.       for(int var1 = 0; var1 < 13; ++var1) {
  474.          this.CardVis[var1] = false;
  475.       }
  476.  
  477.       ((Canvas)this).repaint();
  478.  
  479.       try {
  480.          Thread.sleep(100L);
  481.       } catch (Exception var3) {
  482.       }
  483.  
  484.    }
  485.  
  486.    public void ShowTimerLine(Graphics var1) {
  487.    }
  488.  
  489.    public void SetCardPos() {
  490.       boolean var1 = false;
  491.       boolean var2 = false;
  492.       int var3 = 0;
  493.       int var4 = 0;
  494.       int var5 = 0;
  495.  
  496.       for(int var7 = 0; var7 < 4; ++var7) {
  497.          for(int var6 = 0; var6 < 3; ++var6) {
  498.             ++var5;
  499.             var4 = 6 + var7 * this.Card[0].getHeight();
  500.             var3 = 6 + var6 * (this.Card[0].getWidth() + 2);
  501.             this.XPos[var5] = var3;
  502.             this.YPos[var5] = var4;
  503.          }
  504.       }
  505.  
  506.    }
  507.  
  508.    public void PaintCards(Graphics var1) {
  509.       for(int var2 = 1; var2 < 13; ++var2) {
  510.          if (!this.CardCleard[var2]) {
  511.             if (this.CardVis[var2]) {
  512.                this.DrawCard(var1, this.Card[this.CardId[var2]], this.XPos[var2], this.YPos[var2]);
  513.             } else {
  514.                this.DrawCard(var1, this.Card[0], this.XPos[var2], this.YPos[var2]);
  515.             }
  516.          }
  517.       }
  518.  
  519.    }
  520.  
  521.    public void DrawCard(Graphics var1, Image var2, int var3, int var4) {
  522.       var1.drawImage(var2, var3, var4, 16 | 4);
  523.    }
  524.  
  525.    public void DrawLevelBackGround(Graphics var1) {
  526.       var1.drawLine(1, 1, this.field_1 - 1, 1);
  527.       var1.drawLine(1, this.field_0 - 1, this.field_1 - 1, this.field_0 - 1);
  528.       var1.drawLine(1, 1, 1, this.field_0 - 1);
  529.       var1.drawLine(this.field_1 - 1, 1, this.field_1 - 1, this.field_0 - 1);
  530.       var1.drawLine(this.field_1 / 2 + 10, 1, this.field_1 / 2 + 10, this.field_0 - 1);
  531.    }
  532.  
  533.    public void InitGraphics() {
  534.       this.field_1 = 100;
  535.       this.field_0 = 74;
  536.       this.XPos = new int[13];
  537.       this.YPos = new int[13];
  538.       this.Card = new Image[13];
  539.       this.CardId = new int[13];
  540.       this.CardVis = new boolean[13];
  541.       this.CardCleard = new boolean[13];
  542.  
  543.       for(int var1 = 0; var1 < 13; ++var1) {
  544.          this.CardVis[var1] = false;
  545.          this.CardCleard[var1] = false;
  546.       }
  547.  
  548.       this._buffer = Image.createImage(this.field_1, this.field_0);
  549.  
  550.       try {
  551.          this.Card[0] = Image.createImage("/MemoryGame/CardBack.png");
  552.          this.Card[1] = Image.createImage("/MemoryGame/Card1.png");
  553.          this.Card[2] = Image.createImage("/MemoryGame/Card2.png");
  554.          this.Card[3] = Image.createImage("/MemoryGame/Card3.png");
  555.          this.Card[4] = Image.createImage("/MemoryGame/Card4.png");
  556.          this.Card[5] = Image.createImage("/MemoryGame/Card5.png");
  557.          this.Card[6] = Image.createImage("/MemoryGame/Card6.png");
  558.       } catch (Exception var3) {
  559.          System.out.print(var3);
  560.       }
  561.  
  562.    }
  563.  
  564.    public int GetRandom(int var1) {
  565.       int var2 = 0;
  566.  
  567.       for(Random var3 = new Random(); var2 < 1; var2 = var3.nextInt() % var1 + 1) {
  568.       }
  569.  
  570.       return var2;
  571.    }
  572.  
  573.    public void MixCards() {
  574.       int[] var4 = new int[13];
  575.  
  576.       for(int var5 = 1; var5 < 13; ++var5) {
  577.          var4[var5] = 0;
  578.          this.CardId[var5] = 0;
  579.       }
  580.  
  581.       for(int var6 = 1; var6 < 7; ++var6) {
  582.          for(int var7 = 1; var7 < 3; ++var7) {
  583.             int var2 = this.GetRandom(12);
  584.  
  585.             while(this.CardId[var2] > 0) {
  586.                var2 = this.GetRandom(12);
  587.                boolean var3 = false;
  588.  
  589.                for(int var8 = 1; var8 < 13; ++var8) {
  590.                   if (this.CardId[var8] == 0) {
  591.                      var3 = true;
  592.                   }
  593.                }
  594.  
  595.                if (!var3) {
  596.                   break;
  597.                }
  598.             }
  599.  
  600.             if (this.CardId[var2] == 0) {
  601.                this.CardId[var2] = var6;
  602.             }
  603.          }
  604.       }
  605.  
  606.    }
  607.  
  608.    public boolean isHighScore(int var1) {
  609.       for(int var2 = 0; var2 < this.names.length; ++var2) {
  610.          if (var1 >= this.values[var2]) {
  611.             return true;
  612.          }
  613.       }
  614.  
  615.       return false;
  616.    }
  617.  
  618.    public void DisplayHighScore(Graphics var1) {
  619.       this.DrawLevelBackGround(var1);
  620.       var1.drawString("HighScore", 5, 5, 20);
  621.  
  622.       for(int var2 = 0; var2 < 4; ++var2) {
  623.          var1.drawString(this.names[var2], 3, 20 + 12 * var2, 20);
  624.          var1.drawString("" + this.values[var2], 35, 20 + 12 * var2, 20);
  625.       }
  626.  
  627.    }
  628.  
  629.    public void DisplayTitle(Graphics var1) {
  630.       Font.getFont(0, 1, 16);
  631.       var1.setFont(this.font);
  632.       var1.drawString("Arcade Memory", TitX1, 5, 20);
  633.       Font.getFont(0, 0, 8);
  634.       var1.setFont(this.font);
  635.       var1.drawString("Press '5' to Start", 9, TitY2, 20);
  636.       var1.drawString("Programming by", TitX3, 45, 20);
  637.       var1.drawString("N.Akpolat", TitX4, 60, 20);
  638.       if (TitX1 > 10) {
  639.          TitX1 -= 12;
  640.       } else {
  641.          TitX1 = 10;
  642.       }
  643.  
  644.       if (TitY2 > 25) {
  645.          TitY2 -= 10;
  646.       } else {
  647.          TitY2 = 25;
  648.       }
  649.  
  650.       if (TitX1 <= 11 & TitY2 <= 25) {
  651.          if (TitX3 < 8) {
  652.             TitX3 += 16;
  653.          } else {
  654.             TitX3 = 8;
  655.          }
  656.  
  657.          if (TitX4 > 25) {
  658.             TitX4 -= 16;
  659.          } else {
  660.             TitX4 = 25;
  661.          }
  662.       }
  663.  
  664.    }
  665.  
  666.    public void GetHighScores() {
  667.       RecordStore var1 = null;
  668.  
  669.       try {
  670.          var1 = RecordStore.openRecordStore("HighSscores", true);
  671.          if (var1.getNumRecords() > 0) {
  672.             for(int var2 = 0; var2 < this.names.length; ++var2) {
  673.                byte[] var3 = var1.getRecord(var2 + 1);
  674.                DataInputStream var4 = new DataInputStream(new ByteArrayInputStream(var3, 0, var3.length));
  675.                this.values[var2] = var4.readInt();
  676.                this.names[var2] = var4.readUTF();
  677.             }
  678.          } else {
  679.             for(int var17 = 0; var17 < this.names.length; ++var17) {
  680.                ByteArrayOutputStream var18 = new ByteArrayOutputStream(12);
  681.                DataOutputStream var19 = new DataOutputStream(var18);
  682.                var19.writeInt(this.values[var17]);
  683.                var19.writeUTF(this.names[var17]);
  684.                var19.flush();
  685.                var19.close();
  686.                byte[] var5 = var18.toByteArray();
  687.                var1.addRecord(var5, 0, var5.length);
  688.             }
  689.          }
  690.       } catch (Exception var15) {
  691.       } finally {
  692.          if (var1 != null) {
  693.             try {
  694.                var1.closeRecordStore();
  695.             } catch (Exception var14) {
  696.             }
  697.          }
  698.  
  699.       }
  700.  
  701.    }
  702.  
  703.    public void addHighScore(int var1, String var2) {
  704.       for(int var3 = 0; var3 < this.names.length; ++var3) {
  705.          if (var1 >= this.values[var3]) {
  706.             for(int var4 = this.names.length - 1; var4 > var3; --var4) {
  707.                this.values[var4] = this.values[var4 - 1];
  708.                this.names[var4] = this.names[var4 - 1];
  709.             }
  710.  
  711.             this.values[var3] = var1;
  712.             this.names[var3] = var2;
  713.             RecordStore var5 = null;
  714.  
  715.             try {
  716.                try {
  717.                   var5 = RecordStore.openRecordStore("HighSscores", true);
  718.  
  719.                   for(int var6 = 0; var6 < this.names.length; ++var6) {
  720.                      ByteArrayOutputStream var7 = new ByteArrayOutputStream(12);
  721.                      DataOutputStream var8 = new DataOutputStream(var7);
  722.                      var8.writeInt(this.values[var6]);
  723.                      var8.writeUTF(this.names[var6]);
  724.                      var8.flush();
  725.                      var8.close();
  726.                      byte[] var9 = var7.toByteArray();
  727.                      var5.setRecord(var6 + 1, var9, 0, var9.length);
  728.                   }
  729.                } catch (Exception var19) {
  730.                }
  731.                break;
  732.             } finally {
  733.                if (var5 != null) {
  734.                   try {
  735.                      var5.closeRecordStore();
  736.                   } catch (Exception var18) {
  737.                   }
  738.                }
  739.  
  740.             }
  741.          }
  742.       }
  743.  
  744.    }
  745. }
  746.