gt:                 final boolean found = isSaveAvailable();
context: /*
   * Copyright 2008-present, David Karnok & Contributors
   * The file is part of the Open Imperium Galactica project.
   *
   * The code should be distributed under the LGPL license.
   * See http://www.gnu.org/licenses/lgpl.html for details.
   */
  
  package hu.openig.screen.items;
  
  import java.awt.AlphaComposite;
  import java.awt.Color;
  import java.awt.Composite;
  import java.awt.GradientPaint;
  import java.awt.Graphics2D;
  import java.awt.Paint;
  import java.awt.Point;
  import java.awt.Rectangle;
  import java.awt.event.KeyEvent;
  import java.awt.geom.AffineTransform;
  import java.awt.image.BufferedImage;
  import java.io.File;
  import java.io.FileFilter;
  import java.io.IOException;
  import java.net.URL;
  import java.util.Arrays;
  import java.util.Random;
  
  import javax.imageio.ImageIO;
  import javax.swing.SwingUtilities;
  
  import hu.openig.core.Action0;
  import hu.openig.core.Pair;
  import hu.openig.model.Configuration;
  import hu.openig.model.Screens;
  import hu.openig.model.SoundType;
  import hu.openig.render.RenderTools;
  import hu.openig.render.TextRenderer;
  import hu.openig.screen.ScreenBase;
  import hu.openig.screen.api.SettingsPage;
  import hu.openig.ui.UIComponent;
  import hu.openig.ui.UIImage;
  import hu.openig.ui.UIMouse;
  import hu.openig.ui.UIMouse.Type;
  import hu.openig.ui.UIPanel;
  import hu.openig.utils.Exceptions;
  
  /**
   * The main menu rendering and actions.
   * @author akarnokd, 2009.12.25.
   */
  public class MainScreen extends ScreenBase {
      /**
       * The click label.
       * @author akarnokd, 2009.12.26.
       */
      class ClickLabel extends UIComponent {
          /** The action to invoke. */
          public Action0 action;
          /** The text size. */
          public int size;
          /** The text label. */
          public String label;
          /** The selected state. */
          public boolean selected;
          /** The pressed state. */
          public boolean pressed;
          /**
           * Constructor.
           * @param size the text size
           * @param label the label
           */
          ClickLabel(int size, String label) {
              this.height = size + 10;
              this.size = size;
              this.label = label;
              this.width = preferredWidth();
          }
          /** @return the preferred width. */
          public int preferredWidth() {
              return commons.text().getTextWidth(size, get(label)) + 20;
          }
          /** Sizes the label to the preferred text width. */
          public void sizeToContent() {
              this.width = preferredWidth();
          }
          /** Invoke the associated action. */
          public void invoke() {
              if (action != null) {
                  action.invoke();
              }
          }
          @Override
          public void draw(Graphics2D g2) {
              int color = 0xFFFFCC00;
              if (!enabled) {
                  color = 0xFFC0C0C0;
              } else
              if (pressed) {
                  color = 0xFFFF0000;
              } else
              if (selected) {
                  color = 0xFFFFFFFF;
              }
              Composite save0 = g2.getComposite();
              g2.setComposite(AlphaComposite.SrcOver.derive(0.5f));
              if (selected) {
                  g2.setColor(new Color(224, 0, 0));
                  g2.fillRoundRect(0, 0, width, height, 10, 10);
              } else {
                  g2.setColor(Color.BLACK);
                  g2.fillRoundRect(0, 0, width, height, 10, 10);
              }
              g2.setComposite(save0);
  
              String s = get(label);
  
              int dx = (width - commons.text().getTextWidth(size, s)) / 2;
  
              commons.text().paintTo(g2, dx + 2, 7, size, 0xFF000000, s);
              commons.text().paintTo(g2, dx + 1, 6, size, 0xFF000000, s);
              commons.text().paintTo(g2, dx + 0, 5, size, color, s);
          }
          @Override
          public boolean mouse(UIMouse e) {
              if (e.has(Type.ENTER)) {
                  selected = true;
                  return true;
              } else
              if (e.has(Type.LEAVE)) {
                  selected = false;
                  pressed = false;
                  return true;
              } else
              if (e.has(Type.DOWN)) {
                  pressed = true;
                  return true;
              } else
              if (e.has(Type.UP)) {
                  if (pressed) {
                      pressed = false;
                      action.invoke();
                      return true;
                  }
              }
              return false;
          }
      }
      /** The screen base. */
      Rectangle base = new Rectangle(0, 0, 640, 442);
      /** The background image. */
      BufferedImage background;
      /** The random used for background selection. */
      Random rnd = new Random();
      /** The continue label. */
      ClickLabel continueLabel;
      /** The achievements screen. */
      ClickLabel achievements;
      /** The campaign click label. */
      ClickLabel campaign;
      /** The skirmish click label. */
      ClickLabel skirmish;
      /** Label button. */
      ClickLabel load;
      /** Label button. */
      ClickLabel multiplayer;
      /** Label button. */
      ClickLabel settings;
      /** Label button. */
      ClickLabel videosLabel;
      /** Label button. */
      ClickLabel introLabel;
      /** Label button. */
      ClickLabel titleLabel;
      /** Label button. */
      ClickLabel exit;
      /** Label button. */
      ClickLabel creditsLabel;
      /** Label button. */
      ClickLabel profileLabel;
      /** The language selector panel. */
      UIPanel languagePanel;
      /** The language changer. */
      UIImage changeLanguage;
      /** Resume the last gameplay. */
      void doContinue() {
          continueLabel.enabled(isSaveAvailable());
          if (continueLabel.enabled()) {
              load(null);
          }
      }
      /** Perform the exit. */
      void doExit() {
          effectSound(SoundType.GOOD_BYE);
          try {
              Thread.sleep(1500);
          } catch (InterruptedException ex) {
              // ignored
          }
          exit();
      }
      /**
       * Play the intro videos.
       */
      protected void doPlayIntro() {
          commons.control().playVideos("intro/intro_1", "intro/intro_2", "intro/intro_3");
      }
      /**
       * Play the title video.
       */
      protected void doPlayTitle() {
          commons.control().playVideos("intro/gt_interactive_intro");
      }
      /** Display the settings video. */
      void doSettings() {
          // reload global configuration
          config.load();
          commons.control().displayOptions();
          LoadSaveScreen scr = commons.control().getScreen(Screens.LOAD_SAVE);
          scr.maySave(false);
          scr.displayPage(SettingsPage.AUDIO);
      }
  
      @Override
      public void draw(Graphics2D g2) {
          onResize(); // repaint might come before an onResize
  
          int w = background.getWidth();
          g2.setColor(Color.BLACK);
          g2.fillRect(0, 0, getInnerWidth(), getInnerHeight());
  
          AffineTransform save0 = scaleDraw(g2, base, margin());
  
          g2.translate(base.x, base.y);
          g2.drawImage(background, 0, 0, null);
  
          RenderTools.setInterpolation(g2, true);
          BufferedImage tli = commons.background().openigTextLogo;
          int tliw = tli.getWidth() * 3 / 4;
          int tlih = tli.getHeight() * 3 / 4;
          int tlw = (w - tliw) / 2;
          g2.drawImage(tli, tlw, 8, tliw, tlih, null);
          RenderTools.setInterpolation(g2, false);
  
          int vx = 70;
          int vy = 428;
          int vs = 10;
          String vstr = "v" + Configuration.VERSION + " - " + config.language;
          int w1 = commons.text().getTextWidth(vs, vstr);
          g2.setColor(new Color(0, 0, 0, 128));
          g2.fillRect(vx - 3, vy - 3, w1 + 6, vs + 6);
          commons.text().paintTo(g2, vx + 1, vy + 1, vs, 0xFF000000, vstr);
          commons.text().paintTo(g2, vx, vy, vs, 0xFFFF0000, vstr);
  
          g2.translate(-base.x, -base.y);
  
          // draw profile
          String pn = commons.profile.name;
          int pnw = commons.text().getTextWidth(14, pn);
  
          int profw = pnw + profileLabel.width + 40 + achievements.width;
  
          int dx = (w - profw) / 2;
          profileLabel.x = base.x + dx;
          profileLabel.enabled(true);
  
          achievements.x = base.x + dx + 40 + pnw + profileLabel.width;
  
          g2.setColor(new Color(0, 0, 0, 128));
          g2.fillRect(base.x + dx + profileLabel.width + 15, profileLabel.y + 2, pnw + 10, 20);
          commons.text().paintTo(g2, base.x + dx + profileLabel.width + 20, profileLabel.y + 5, 14, TextRenderer.GREEN, pn);
  
          Paint savep = g2.getPaint();
  
          int gx1 = profileLabel.x;
          int gx2 = profileLabel.x + profw / 2;
          int gx3 = achievements.x + achievements.width;
          int gy = profileLabel.y + profileLabel.size + 13;
  
          g2.setPaint(new GradientPaint(gx1, gy, new Color(255, 255, 255, 192), gx2, gy, new Color(255, 255, 0, 255)));
          g2.fillRect(gx1, gy, gx2 - gx1, 2);
          g2.setPaint(new GradientPaint(gx3, gy, new Color(255, 255, 255, 192), gx2, gy, new Color(255, 255, 0, 255)));
          g2.fillRect(gx2, gy, gx3 - gx2, 2);
  //        g2.setColor(Color.YELLOW);
  //        g2.drawLine(gx1, gy, gx3, gy);
  
          g2.setPaint(savep);
          // draw other labels
  
          super.draw(g2);
  
          g2.setTransform(save0);
  
      }
      @Override
      public boolean mouse(UIMouse e) {
          scaleMouse(e, base, margin());
          if (e.has(Type.DOWN) && languagePanel.visible()
                  && !languagePanel.within(e)) {
              languagePanel.visible(false);
              if (changeLanguage.within(e)) {
                  return true;
              }
          }
          return super.mouse(e);
      }
      @Override
      public void onEndGame() {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void onEnter(Screens mode) {
          // if returned to main menu, allow new aggregation of exceptions
          Exceptions.clear();
  
          selectRandomBackground();
          onResize();
  
          checkExistingSave();
      }
      /**
       * Search for previous saves to continue.
       */
      public void checkExistingSave() {
          continueLabel.enabled(false);
          Thread t = new Thread(new Runnable() {
              @Override
              public void run() {
  