Esempio n. 1
0
  public int CalculateValidPortraits() {
    int portraitnum = 0;
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    File tmpfile = new File(directory);
    if (!tmpfile.exists()) {
      JOptionPane.showMessageDialog(
          null,
          "Fatal Error - No portraits directory. Please create a new portraits directory in your NWN directory.",
          "Error",
          0);
      System.exit(0);
    }

    String filenames[] = (tmpfile.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)) {
          portraitnum++;
        }
      }
    }

    for (int i = 0; i < filenames.length; ++i) ++portraitnum;

    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    ScreenCount = roundup(portraitnum, 50);

    return portraitnum;
  }
Esempio n. 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();
  }