コード例 #1
0
  /** Updates the information displayed in the fields. */
  public void update() {
    super.update(); // update the common fields

    InteractiveEntity interactiveEntity = (InteractiveEntity) entity;
    String sprite = interactiveEntity.getProperty("sprite");
    String behavior = interactiveEntity.getProperty("behavior");
    EntitySubtype subtype = interactiveEntity.getSubtype();

    boolean hasSprite = (!sprite.equals("_none"));

    withSpriteField.setSelected(hasSprite);
    spriteField.setSelectedId(hasSprite ? sprite : "");

    spriteField.setEnabled(hasSprite);

    if (behavior.equals("map")) {
      behaviorField.setSelectedIndex(1);
      messageField.setEnabled(false);
      itemField.setEnabled(false);
    } else if (behavior.substring(0, 5).equals("item#")) {
      behaviorField.setSelectedIndex(2);
      messageField.setEnabled(false);
      itemField.setEnabled(true);
      itemField.setSelectedId(behavior.substring(5));
    } else if (behavior.substring(0, 7).equals("dialog#")) {
      behaviorField.setSelectedIndex(0);
      messageField.setEnabled(true);
      itemField.setEnabled(false);
      messageField.setText(behavior.substring(7));
    }
  }
コード例 #2
0
  /**
   * Returns the specific part of the action made on the entity.
   *
   * @return the specific part of the action made on the entity
   */
  protected ActionEditEntitySpecific getSpecificAction() {

    String sprite = spriteField.getSelectedId();
    if (!withSpriteField.isSelected()) {
      sprite = "_none";
    }

    String behavior = "map";
    if (messageField.isEnabled()) {
      behavior = "dialog#" + messageField.getText();
    } else if (itemField.isEnabled()) {
      behavior = "item#" + itemField.getSelectedId();
    }

    return new ActionEditEntitySpecific(entity, sprite, behavior);
  }