示例#1
0
  public boolean updateRoom() {
    if (!validateRoom()) return false;

    room.setStud(isStud.isSelected());

    if (jrBooty[0].isSelected()) {
      room.setChest(null);
    } else if (jrBooty[1].isSelected() || jrBooty[2].isSelected()) {
      Chest chest = new Chest();
      chest.setGold(Integer.parseInt(tfChestGold.getText().trim()));
      chest.setTrapType(Trap.type(cmbChestTrap.getSelectedIndex()));
      chest.setLockLevel(Byte.parseByte(tfChestTrapLevel.getText().trim()));

      chest.setItems(getChestItems());
      chest.setMagicLock(isMagicLock.isSelected());
      room.setChest(chest);
    }

    room.setItem(getItem(true, 0));

    for (byte i = 0; i < Util.MON_MAXSTACKSIZE; i++) {
      Monster tMon = getMonster(tfLairedMonsterName[i]);
      if (tMon != null) room.setLairedMonster(tMon, i);
    }

    LinkedList<LinkedList<MonsterInstance>> monStacks =
        new LinkedList<LinkedList<MonsterInstance>>();

    for (byte i = 0; i < tfMonsters.length; i++) {
      Monster tMon = getMonster(tfMonsters[i]);
      if (tMon != null) {
        LinkedList<MonsterInstance> monList = new LinkedList<MonsterInstance>();

        for (int j = 0; j < Byte.parseByte(tfMonsterCounts[i].getText().trim()); i++)
          monList.insert(tMon.createInstance());

        monStacks.insert(monList);
      }
    }

    for (MonsterClass mc : MonsterClass.values())
      room.setMonsterType(mc, monsterTypes[mc.value()].isSelected());

    return true;
  }
示例#2
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == jrBooty[0]) {
      if (jrBooty[0].isSelected()) {
        room.setChest(null);
        tfChestGold.setEnabled(false);
        for (int i = 0; i < tfChestItems.length; i++) {
          tfChestItems[i].setEnabled(false);
          jbVerifyCItem[i].setEnabled(false);
          jbBrowseCItem[i].setEnabled(false);
        }
        cmbChestTrap.setEnabled(false);
        tfChestTrapLevel.setEnabled(false);
        isMagicLock.setEnabled(false);
      }
    } else if (e.getSource() == jrBooty[1] || e.getSource() == jrBooty[2]) {
      if (jrBooty[1].isSelected() || jrBooty[2].isSelected()) {
        room.setChest(new Chest());
        tfChestGold.setEnabled(true);
        for (int i = 0; i < tfChestItems.length; i++) {
          tfChestItems[i].setEnabled(true);
          jbVerifyCItem[i].setEnabled(true);
          jbBrowseCItem[i].setEnabled(true);
        }
        cmbChestTrap.setEnabled(true);
        tfChestTrapLevel.setEnabled(true);
        isMagicLock.setEnabled(true);
      }
    } else if (e.getSource() == jbBrowseRItem) {
      JFrame itemBrowse = new JFrame();

      itemBrowse.add(
          new ListChooserPanel(
              itemBrowse, tfRoomItem, dataBank, ListChooserPanel.BrowseTypes.items));
      itemBrowse.pack();
      itemBrowse.setVisible(true);
    } else if (e.getSource() == jbVerifyRItem) findItem(true, 0);
    else if (e.getSource() == jbOK) {
      updateRoom();
      parent.dispose();
    } else if (e.getSource() == jbCancel) parent.dispose();
    else if (e.getSource() == jbMTNone)
      for (int i = 0; i < monsterTypes.length; i++) monsterTypes[i].setSelected(false);
    else if (e.getSource() == jbMTAll)
      for (int i = 0; i < monsterTypes.length; i++) monsterTypes[i].setSelected(true);
    else if (e.getSource() == jbMTInvert)
      for (int i = 0; i < monsterTypes.length; i++)
        monsterTypes[i].setSelected(!(monsterTypes[i].isSelected()));
    else {
      for (byte i = 0; i < jbVerify.length; i++) {
        if (e.getSource() == jbVerify[i]) findMonster(tfMonsters[i]);
        else if (e.getSource() == jbBrowse[i]) {
          JFrame monBrowse = new JFrame();

          monBrowse.add(
              new ListChooserPanel(
                  monBrowse, tfMonsters[i], dataBank, ListChooserPanel.BrowseTypes.monster));
          monBrowse.pack();
          monBrowse.setVisible(true);
        }
      }

      for (int i = 0; i < jbBrowseCItem.length; i++) {
        if (e.getSource() == jbBrowseCItem[i]) {
          JFrame itemBrowse = new JFrame();

          itemBrowse.add(
              new ListChooserPanel(
                  itemBrowse, tfChestItems[i], dataBank, ListChooserPanel.BrowseTypes.items));
          itemBrowse.pack();
          itemBrowse.setVisible(true);
        } else if (e.getSource() == jbVerifyCItem[i]) findItem(false, i);
      }

      for (byte i = 0; i < jbLairBrowse.length; i++) {
        if (e.getSource() == jbLairBrowse[i]) {
          JFrame monBrowse = new JFrame();

          monBrowse.add(
              new ListChooserPanel(
                  monBrowse,
                  tfLairedMonsterName[i],
                  dataBank,
                  ListChooserPanel.BrowseTypes.monster));
          monBrowse.pack();
          monBrowse.setVisible(true);
        } else if (e.getSource() == jbLairVerify[i]) findMonster(tfLairedMonsterName[i]);
      }
    }
  }
示例#3
0
  public boolean updatePanel() {
    if (room == null) return false;

    jlRoomTitle.setText("Room #" + room.getRoomNumber());

    isStud.setSelected(room.isStudRoom());

    if (room.getChest() == null || room.getChest().chestIsEmpty()) {
      jrBooty[0].setSelected(true);
      tfChestGold.setEnabled(false);
      for (int i = 0; i < tfChestItems.length; i++) {
        tfChestItems[i].setEnabled(false);
        jbVerifyCItem[i].setEnabled(false);
        jbBrowseCItem[i].setEnabled(false);
      }
      cmbChestTrap.setEnabled(false);
      tfChestTrapLevel.setEnabled(false);
      isMagicLock.setEnabled(false);
    } else {
      Chest chest = room.getChest();
      if (chest.isBox()) jrBooty[1].setSelected(true);
      else jrBooty[2].setSelected(true);

      tfChestGold.setEnabled(true);
      for (int i = 0; i < tfChestItems.length; i++) {
        tfChestItems[i].setEnabled(true);
        jbVerifyCItem[i].setEnabled(true);
        jbBrowseCItem[i].setEnabled(true);
      }
      cmbChestTrap.setEnabled(true);
      tfChestTrapLevel.setEnabled(true);
      isMagicLock.setEnabled(true);

      ListIter<ItemInstance> iNode = chest.getItems().getIterator();
      int count = 0;
      while (iNode.next()) {
        if (iNode.element() != null)
          tfChestItems[count].setText(iNode.element().getItem().getName());
        else tfChestItems[count].setText("");

        count++;
      }

      tfChestGold.setText("" + chest.getGold());
      cmbChestTrap.setSelectedIndex(chest.getTrapType().value());
      tfChestTrapLevel.setText("" + chest.getLockLevel());
    }

    if (room.getItem() != null) tfRoomItem.setText(room.getItem().getItem().getName());
    else {
      tfRoomItem.setText("");
    }

    cmbPlayersHere.setModel(new DefaultComboBoxModel(room.getPlayerNamesHere()));

    for (byte i = 0; i < Util.MON_MAXSTACKSIZE; i++) {
      Monster tMon = dataBank.getMonsterEden().getMonster(room.getLairedMonsterID(i));
      if (tMon != null) tfLairedMonsterName[i].setText(tMon.getName());
      else tfLairedMonsterName[i].setText("");
    }

    // Update the monsters
    ListIter<LinkedList<MonsterInstance>> mNode = room.getMonsterStacks().getIterator();
    for (byte i = 0; i < tfMonsters.length; i++) {
      if (mNode.next()) {
        tfMonsters[i].setText(mNode.element().getFirst().getMonster().getName());
        tfMonsterCounts[i].setText("" + mNode.element().getSize());
      } else {
        tfMonsters[i].setText("");
        tfMonsterCounts[i].setText("");
      }
    }

    for (MonsterClass mc : MonsterClass.values())
      monsterTypes[mc.value()].setSelected(room.isMonsterTypeAllowed(mc));

    return true;
  }