コード例 #1
0
    private void PicButtonActionPerformed(ActionEvent evt) {
      OKButton.setEnabled(true);
      javax.swing.Icon test = PicButton.getIcon();
      if (test instanceof ImageIcon) {
        if (isBIFpic) {
          String BIFFILENAME = "po_" + tmpname + "l.tga";
          try {
            InfoText.setText(BIFFILENAME);

            File tempImage = RESFAC.TempImageFile(BIFFILENAME);
            if (tempImage != null) {
              TargaImage curtga = new TargaImage(tempImage);
              CurrentPortrait.setIcon(new ImageIcon(curtga.getImage()));
              BICPortraitname = "po_" + tmpname;
              CURRENTPORTRAIT = tempImage.getParent() + FileDelim + baseFilename;
              OKButton.setEnabled(true);
            }
          } catch (IOException err) {
            JOptionPane.showMessageDialog(
                null,
                "Fatal Error - " + BIFFILENAME + " not found. Your data files might be corrupt.",
                "Error",
                0);
            System.exit(0);
          }
        } else {
          String PORTRAIT = qualifiedName;
          if (qualifiedName.toUpperCase().endsWith("M.TGA")) {
            CURRENTPORTRAIT = PORTRAIT;
            PORTRAIT = qualifiedName.substring(0, qualifiedName.length() - 5) + "l.tga";
          }

          ImageIcon icon = null;
          try {
            icon = new ImageIcon(new TargaImage(new File(PORTRAIT)).getImage());
          } catch (IOException e) {
            System.out.println("Invalid Icon: " + PORTRAIT);
            icon = null;
          }

          CurrentPortrait.setIcon(icon);
          BICPortraitname = baseFilename.substring(0, baseFilename.length() - 4);
          InfoText.setText(PORTRAIT.substring(PORTRAIT.lastIndexOf(FileDelim) + 1));
          if (BICPortraitname.toLowerCase().endsWith("m")
              || BICPortraitname.toLowerCase().endsWith("l")
              || BICPortraitname.toLowerCase().endsWith("h")
              || BICPortraitname.toLowerCase().endsWith("s")
              || BICPortraitname.toLowerCase().endsWith("t")) {
            BICPortraitname = BICPortraitname.substring(0, BICPortraitname.length() - 1);
          }
          OKButton.setEnabled(true);
        }
      }
    }
コード例 #2
0
  public void RedoPortraits(int screen) {
    // PortraitObjects = new LinkedList();
    if (screen == -1) {
      ScreenNum = 0;
      screen = 0;
      TotalPortrait = CalculateValidPortraits();
    }

    int CurrentNum = 0;
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    PortraitsWindow.removeAll();
    PortraitsWindow.repaint();
    String filenames[] = (new File(directory)).list(new ImageFilter());
    String sexstr = "";
    int sex = ((Integer) menucreate.MainCharData[0].get(new Integer(0))).intValue();
    int race = Integer.parseInt(menucreate.MainCharDataAux[1][0]);
    int numbif = 0;

    for (int p = 0; p < portraitmap.length; p++) {
      String basepicfilename = portraitmap[p][1];
      if (basepicfilename != null && portraitmap[p][2] != null && portraitmap[p][3] != null) {
        basepicfilename = basepicfilename.toLowerCase();
        if (!basepicfilename.startsWith("plc")
            && !basepicfilename.equalsIgnoreCase("door01_")
            && (Integer.parseInt(portraitmap[p][2]) == sex && sexlock || !sexlock)
            && (Integer.parseInt(portraitmap[p][3]) == race && racelock || !racelock)
            && CheckPortrait(directory, "po_" + basepicfilename)) {
          String picFilename = "po_" + basepicfilename + "m.tga";
          CurrentNum++;
          if ((CurrentNum <= (50 * (screen + 1))) && (CurrentNum > (50 * screen))) {
            try {
              File tempImage = RESFAC.TempImageFile(picFilename);
              if (tempImage != null) {
                Portrait port =
                    new Portrait(
                        tempImage.getParent() + FileDelim,
                        tempImage.getName(),
                        true,
                        basepicfilename);
                port.getComponent(0).setSize(64, 100);
                PortraitsWindow.add(port, -1);
                numbif++;
              }
            } catch (IOException err) {
              JOptionPane.showMessageDialog(
                  null,
                  "Error reading " + picFilename + ". Out of Memory. Error: " + err,
                  "Error",
                  0);
              System.exit(0);
            }
          }
        }
      }
    }

    for (int i = 0; i < filenames.length; ++i) {
      ++CurrentNum;
      if ((CurrentNum <= (50 * (screen + 1))) && (CurrentNum > (50 * screen))) {
        Portrait port = new Portrait(directory, filenames[i], false, "");
        port.getComponent(0).setSize(64, 100);
        PortraitsWindow.add(port, -1);
      }
    }

    FirstButton.setEnabled(screen != 0);
    BackButton.setEnabled(screen != 0);
    LastButton.setEnabled(screen < (ScreenCount - 1));
    ForwardButton.setEnabled(screen < (ScreenCount - 1));

    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    Runtime r = Runtime.getRuntime();
    r.gc();
  }