Пример #1
0
 /**
  * Set the current actor's default attack
  *
  * @param row the model row to set as default
  */
 public void setDefaultAttack(int row) {
   if (row < 0 || row >= currentActor.getNumAttacks()) {
     if (LOG.isLoggable(Level.INFO)) {
       LOG.info("Row out of range! " + row);
     }
     return;
   }
   // int oldDefault = currentActor.getDefaultAttack();
   currentActor.setDefaultAttack(row);
   // fireTableRowsUpdated(oldDefault, oldDefault);
   // fireTableRowsUpdated(row, row);
 }
Пример #2
0
  /**
   * Set the value at the row/col specified For cloned actors, this will update all clones (and fire
   * table updated events)
   *
   * @param value : Must be either int (for hp/damage/health) or String (for name/State/Type)
   * @param row : The row where the actor lives. Any clones will be updated also.
   * @param col : The column of the value to edit: use 'columns' enum to address.
   */
  @Override
  public void setValueAt(Object value, int row, int col) {
    if (LOG.isLoggable(Level.FINER)) {
      LOG.finer(
          "Setting value at "
              + row
              + ","
              + col
              + " to "
              + value
              + " (an instance of "
              + value.getClass()
              + ")");
    }

    // Check if there is any actual change
    if (getValueAt(row, col).equals(value)) {
      if (LOG.isLoggable(Level.FINER)) {
        LOG.finer("Values are identical. Exiting.");
      }
      return;
    }

    Attack a = currentActor.getAttack(row);
    switch (columns.values()[col]) {
      case Name:
        a.name = (String) value;
        break;
      case Skill:
        a.skill = (Integer) value;
        break;
      case Damage:
        a.damage = (String) value;
        break;
      case Unbalanced:
        a.unbalanced = (Boolean) value;
    }
    currentActor.setAttack(a, row);
    // Update the entire row, since changing state or type may affect formatting for all cells in
    // the row.
    fireTableRowsUpdated(row, row);
  }
Пример #3
0
 /** Remove all selected rows */
 public void removeAttacks(int[] rows) {
   if (currentActor != null && rows.length > 0) {
     for (int i = rows.length - 1; i >= 0; i--) { // Go from bottom up to preserve numbering
       if (LOG.isLoggable(Level.FINE)) {
         LOG.fine("Deleting row: " + rows[i]);
       }
       currentActor.removeAttack(
           rows[i]); // Just remove the rows indicated: not all instances of clones
     }
     // fireTableRowsDeleted(rows[0], rows[rows.length-1]);
   }
 }
Пример #4
0
 public Object getValueAt(int rowIndex, int columnIndex) {
   if (currentActor == null) return null;
   Attack attack = currentActor.getAttack(rowIndex);
   switch (columns.values()[columnIndex]) {
     case Name:
       return attack.name;
     case Skill:
       return attack.skill;
     case Damage:
       return attack.damage;
     case Unbalanced:
       return attack.unbalanced;
     default:
       return null;
   }
 }
Пример #5
0
 public int getRowCount() {
   if (currentActor == null) return 0;
   return currentActor.getNumAttacks();
 }
Пример #6
0
 /** Add new attack row */
 public void addAttack() {
   if (currentActor != null) {
     currentActor.addAttack(new Attack());
     // fireTableRowsInserted(getRowCount()-1, getRowCount()-1);
   }
 }