コード例 #1
0
 // TODO: More case twiddling
 public boolean CheckPortrait(String resdir, String basepicname) {
   return RESFAC.FileExists(resdir, basepicname.toLowerCase() + "h.tga")
       && RESFAC.FileExists(resdir, basepicname.toLowerCase() + "l.tga")
       && RESFAC.FileExists(resdir, basepicname.toLowerCase() + "m.tga")
       && RESFAC.FileExists(resdir, basepicname.toLowerCase() + "s.tga")
       && RESFAC.FileExists(resdir, basepicname.toLowerCase() + "t.tga");
 }
コード例 #2
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);
        }
      }
    }
コード例 #3
0
  /** Creates new form RaceMenu1 */
  public RaceMenu() {
    RACENUM = 6;
    initComponents();
    OKButton.setEnabled(false);
    DescriptionContainer.setViewportView(DescriptionText);

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    if ((screenSize.getWidth() > getContentPane().getWidth())
        && (screenSize.getHeight() > getContentPane().getHeight())) {
      int intwidth =
          new Double(((screenSize.getWidth() - getContentPane().getWidth()) / 2)).intValue();
      int intheight =
          new Double(((screenSize.getHeight() - getContentPane().getHeight()) / 2)).intValue();
      setLocation(intwidth, intheight);
    } else {
      setLocation(0, 0);
    }

    menucreate = TLKFactory.getCreateMenu();
    menucreate.BlockWindow(true);
    TLKFAC = menucreate.getTLKFactory();
    RESFAC = menucreate.getResourceFactory();
    String imagestring = "";
    DescriptionText.setText(TLKFAC.getEntry(485));
    try {
      racialmap = RESFAC.getResourceAs2DA("racialtypes");
    } catch (IOException err) {
      JOptionPane.showMessageDialog(
          null,
          "Fatal Error - racialtypes.2da not found. Your data files might be corrupt.",
          "Error",
          0);
      System.exit(0);
    }
    for (int i = 0; i < racialmap.length; i++) {
      String tempispc = racialmap[i][racialtypes.PlayerRace];
      if (tempispc != null && tempispc.equalsIgnoreCase("1")) {
        RaceButton racebutton = new RaceButton();
        descstr = racialmap[i][racialtypes.Name];
        int descnum = ChkHex.ChkHex(descstr);
        racebutton.RaceButton.setText(TLKFAC.getEntry(descnum));
        racebutton.setSize(240, 52);
        racebutton.InfoNum.setText(Integer.toString(i));
        RaceButtonList.add(racebutton, -1);
      }
    }

    pack();
  }
コード例 #4
0
  /** Creates new form PortraitMenu1 */
  public PortraitMenu() {
    menucreate = TLKFactory.getCreateMenu();
    TLKFAC = menucreate.getTLKFactory();
    RESFAC = menucreate.getResourceFactory();
    Preferences prefs = Preferences.userRoot().node("/CharacterCreator");
    String NWNDir = prefs.get("GameDir", null);
    FileDelim = prefs.get("FileDelim", null);
    directory = NWNDir + "portraits" + FileDelim;
    menucreate.BlockWindow(true);
    initComponents();
    PortraitScrollPane.setViewportView(PortraitsWindow);
    OKButton.setEnabled(false);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    if ((screenSize.getWidth() > getContentPane().getWidth())
        && (screenSize.getHeight() > getContentPane().getHeight())) {
      int intwidth =
          new Double(((screenSize.getWidth() - getContentPane().getWidth()) / 2)).intValue();
      int intheight =
          new Double(((screenSize.getHeight() - getContentPane().getHeight()) / 2)).intValue();
      setLocation(intwidth, intheight);
    } else setLocation(0, 0);

    try {
      portraitmap = RESFAC.getResourceAs2DA("portraits");
    } catch (IOException err) {
      JOptionPane.showMessageDialog(
          null,
          "Fatal Error - portraits.2da not found. Your data files might be corrupt.",
          "Error",
          0);
      System.exit(0);
    }

    CURRENTPORTRAIT = "resource/portrait.jpg";
    java.net.URL targurl = getClass().getResource(CURRENTPORTRAIT);
    CurrentPortrait.setIcon(new ImageIcon(targurl));
    menucreate = TLKFactory.getCreateMenu();
    sexlock = true;
    racelock = true;

    RedoPortraits(-1);

    pack();
  }
コード例 #5
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();
  }