Gridarta Editor
GameObjectAttributesDialog.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.dialog.gameobjectattributes;
21 
22 import java.awt.CardLayout;
23 import java.awt.Color;
24 import java.awt.Component;
25 import java.awt.Container;
26 import java.awt.Dimension;
27 import java.awt.Frame;
28 import java.awt.GridBagConstraints;
29 import java.awt.GridBagLayout;
30 import java.awt.Insets;
31 import java.awt.Point;
32 import java.awt.event.ItemEvent;
33 import java.awt.event.ItemListener;
34 import java.util.Set;
35 import javax.swing.AbstractButton;
36 import javax.swing.Action;
37 import javax.swing.BorderFactory;
38 import javax.swing.Box;
39 import javax.swing.ImageIcon;
40 import javax.swing.JButton;
41 import javax.swing.JComboBox;
42 import javax.swing.JComponent;
43 import javax.swing.JDialog;
44 import javax.swing.JLabel;
45 import javax.swing.JOptionPane;
46 import javax.swing.JPanel;
47 import javax.swing.JScrollPane;
48 import javax.swing.JTextField;
49 import javax.swing.JTextPane;
50 import javax.swing.filechooser.FileFilter;
51 import javax.swing.text.BadLocationException;
52 import javax.swing.text.Document;
53 import javax.swing.text.JTextComponent;
54 import javax.swing.text.Style;
55 import javax.swing.text.StyleConstants;
56 import javax.swing.text.StyleContext;
88 import net.sf.gridarta.utils.Size2D;
90 import net.sf.japi.swing.action.ActionBuilder;
91 import net.sf.japi.swing.action.ActionBuilderFactory;
92 import net.sf.japi.swing.action.ActionMethod;
93 import org.apache.log4j.Category;
94 import org.apache.log4j.Logger;
95 import org.jetbrains.annotations.NotNull;
96 import org.jetbrains.annotations.Nullable;
97 
103 public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> {
104 
108  @NotNull
109  private static final Category LOG = Logger.getLogger(GameObjectAttributesDialog.class);
110 
114  @NotNull
115  private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta");
116 
120  @NotNull
122 
126  @NotNull
128 
133  @NotNull
134  private final Frame parent;
135 
139  @NotNull
141 
145  @NotNull
147 
148  @NotNull
149  private final JOptionPane optionPane = new JOptionPane() {
150 
154  private static final long serialVersionUID = 1;
155 
156  @Override
157  public void setValue(@Nullable final Object newValue) {
158  super.setValue(newValue);
159  if (newValue != UNINITIALIZED_VALUE) {
160  gameObjectAttributesDialogFactory.hideAttributeDialog(gameObject);
164  }
165  }
166 
167  };
168 
173  @NotNull
175 
180  @NotNull
181  private JLabel faceLabel;
182 
187  @NotNull
188  private final G gameObject;
189 
194  @NotNull
196 
201  @NotNull
202  private final Point mapPos;
203 
208  @NotNull
210 
215  @NotNull
216  private final CardLayout cardLayout = new CardLayout();
217 
222  @NotNull
223  private final Action summaryAction = ACTION_BUILDER.createAction(false, "attribSummary", this);
224 
229  @NotNull
230  private final Action editAction = ACTION_BUILDER.createAction(false, "attribEdit", this);
231 
236  @NotNull
237  private AbstractButton summaryEditButton;
238 
243  @NotNull
244  private AbstractButton cancelButton;
245 
250  @NotNull
251  private JButton okButton;
252 
257  @NotNull
258  private final Container centerPanel;
259 
264  @NotNull
265  private final JTextPane summaryTextPane;
266 
267  @NotNull
268  private final Style summaryTextStyle;
269 
273  @NotNull
275 
280  @NotNull
282 
283  @Override
284  public void mapSizeChanged(@NotNull final Size2D newSize) {
285  if (gameObject.getMapSquare() == null) {
286  optionPane.setValue(cancelButton);
287  }
288  }
289 
290  @Override
291  public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) {
292  if (gameObject.getMapSquare() != mapModel.getMapSquare(mapPos)) {
293  optionPane.setValue(cancelButton);
294  }
295  }
296 
297  @Override
298  public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) {
299  if (gameObject.getMapSquare() == null) {
300  optionPane.setValue(cancelButton);
301  }
302  }
303 
304  @Override
305  public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) {
306  // ignore
307  }
308 
309  @Override
310  public void mapFileChanged(@Nullable final MapFile oldMapFile) {
311  // ignore
312  }
313 
314  @Override
315  public void modifiedChanged() {
316  // ignore
317  }
318 
319  };
320 
324  @NotNull
326 
327  @Override
328  public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) {
329  // ignore
330  }
331 
332  @Override
333  public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) {
334  // ignore
335  }
336 
337  @Override
338  public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) {
339  // ignore
340  }
341 
342  @Override
343  public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) {
344  if (mapControl.getMapModel() == mapModel) {
345  optionPane.setValue(cancelButton);
346  }
347  }
348 
349  };
350 
354  @NotNull
356 
357  @Override
358  public void facesReloaded() {
359  faceLabel.setIcon(getFace(gameObject));
360  }
361 
362  };
363 
367  @NotNull
368  private final ItemListener typesBoxItemListener = new ItemListener() {
369 
373  @Nullable
374  private ArchetypeType deselected;
375 
379  private boolean ignoreEvent;
380 
381  @Override
382  public void itemStateChanged(@NotNull final ItemEvent e) {
383  if (ignoreEvent) {
384  return;
385  }
386 
387  if (e.getStateChange() == ItemEvent.DESELECTED) {
388  deselected = (ArchetypeType) e.getItem();
389  } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) {
390  final ArchetypeType newType = (ArchetypeType) e.getItem();
391 
392  final JComboBox<?> typeComboBox = (JComboBox<?>) e.getSource();
393 
394  typeComboBox.hidePopup();
395 
396  if (deselected == null) {
397  deselected = archetypeType;
398  }
399  if (JOptionPane.showConfirmDialog(optionPane, ActionBuilderUtils.format(ACTION_BUILDER, "attribConfirmTypeChange", deselected.getTypeName(), newType.getTypeName()), ActionBuilderUtils.getString(ACTION_BUILDER, "attribConfirmTypeChangeTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) {
400  archetypeType = newType;
401 
402  final MapModel<G, A, R> mapModel = gameObject.getMapSquare().getMapModel();
403  mapModel.beginTransaction("change type to " + newType.getTypeName());
404  try {
405  gameObject.setAttributeInt(BaseObject.TYPE, newType.getTypeNo());
406  } finally {
407  mapModel.endTransaction();
408  }
409 
410  attributesPaneBuilder.buildAttribute(gameObject, archetypeType);
411  } else {
412  ignoreEvent = true;
413  typeComboBox.setSelectedItem(archetypeType);
414  ignoreEvent = false;
415  }
416  }
417  }
418 
419  };
420 
446  public GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final Frame parent, @NotNull final CFTreasureListTree treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ProjectSettings projectSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final TextAreaDefaults textAreaDefaults, @NotNull final MapManager<G, A, R> mapManager) {
447  this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory;
448  this.archetypeTypeSet = archetypeTypeSet;
449  this.gameObject = gameObject;
450  this.parent = parent;
451  this.faceObjectProviders = faceObjectProviders;
452  this.mapManager = mapManager;
453  archetype = gameObject.getArchetype();
454 
455  final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare();
456  if (mapSquare == null) {
457  throw new IllegalArgumentException();
458  }
459  mapModel = mapSquare.getMapModel();
460  mapPos = mapSquare.getMapLocation();
461  mapModel.addMapModelListener(mapModelListener);
462  mapManager.addMapManagerListener(mapManagerListener);
463 
464  // first split top-left and -right
465  archetypeType = archetypeTypeSet.getArchetypeTypeByBaseObject(gameObject);
466  final JComponent leftPane = buildHeader();
467 
468  // Now split horizontally
469  attributesPaneBuilder = new AttributesPaneBuilder<>(gameObject, optionPane, archetypeTypeSet, treasureListTree, faceObjectProviders, animationObjects, projectSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, noFaceSquareIcon, unknownSquareIcon, textAreaDefaults);
470  attributesPaneBuilder.buildAttribute(gameObject, archetypeType);
471  centerPanel = new JPanel(cardLayout);
472  centerPanel.add("edit", attributesPaneBuilder.getTabbedPane());
473  summaryTextPane = new JTextPane();
474  summaryTextPane.setEditable(false);
475  summaryTextPane.setBorder(BorderFactory.createEmptyBorder(3, 15, 0, 0));
476  centerPanel.add("summary", new JScrollPane(summaryTextPane));
477  final Dimension size = centerPanel.getPreferredSize();
478  size.height = 256;
479  centerPanel.setMinimumSize(size);
480  centerPanel.setPreferredSize(size);
481 
482  final Container contentPanel = new JPanel(new GridBagLayout());
483  final GridBagConstraints gbc = new GridBagConstraints();
484  gbc.weightx = 1.0;
485  gbc.fill = GridBagConstraints.BOTH;
486  gbc.gridwidth = GridBagConstraints.REMAINDER;
487  gbc.weighty = 0.0;
488  contentPanel.add(leftPane, gbc);
489  gbc.weighty = 1.0;
490  contentPanel.add(centerPanel, gbc);
491 
492  optionPane.setOptions(buildOptions());
493 
494  summaryTextStyle = summaryTextPane.getStyle(StyleContext.DEFAULT_STYLE);
495  StyleConstants.setForeground(summaryTextStyle, Color.black);
496 
497  faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener);
498 
499  optionPane.setMessage(contentPanel);
500  }
501 
506  @NotNull
507  public JDialog createDialog() {
508  final JDialog dialog = optionPane.createDialog(parent, ActionBuilderUtils.getString(ACTION_BUILDER, "attribTitle"));
509  dialog.getRootPane().setDefaultButton(okButton);
510  dialog.setResizable(true);
511  dialog.setModal(false);
512  dialog.setVisible(true);
513  return dialog;
514  }
515 
520  @NotNull
521  private Component buildTypesBox() {
522  final ArchetypeType[] model = new ArchetypeType[archetypeTypeSet.getArchetypeTypeCount()];
523  int i = 0;
524  for (final ArchetypeType tmp : archetypeTypeSet) {
525  model[i++] = tmp;
526  }
527 
528  final JComboBox<?> typeComboBox = new JComboBox<>(model);
529  typeComboBox.setSelectedItem(archetypeType);
530  typeComboBox.setRenderer(new ArchetypeTypeListCellRenderer());
531  typeComboBox.setName("Types");
532  typeComboBox.addItemListener(typesBoxItemListener);
533  return typeComboBox;
534  }
535 
541  @NotNull
542  private ImageIcon getFace(@NotNull final BaseObject<G, A, R, ?> gameObject) {
543  return faceObjectProviders.getFace(gameObject);
544  }
545 
552  @NotNull
553  private JComponent buildHeader() {
554  final JComponent header = new JPanel(new GridBagLayout()); // the final thing, in a panel
555  final GridBagConstraints gbc = new GridBagConstraints();
556  gbc.fill = GridBagConstraints.BOTH;
557  gbc.insets = new Insets(2, 2, 2, 2);
558  gbc.gridx = 1;
559  gbc.gridy = 1;
560  gbc.weightx = 0.0;
561  gbc.weighty = 3.0;
562  gbc.gridheight = 3;
563  faceLabel = new JLabel(getFace(gameObject));
564  faceLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
565  header.add(faceLabel, gbc);
566  gbc.gridheight = 1;
567  gbc.weighty = 1.0;
568  gbc.fill = GridBagConstraints.HORIZONTAL;
569 
570  gbc.weightx = 0.0;
571  gbc.gridx = 2;
572  gbc.gridy = 1;
573  header.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "attribName"), gbc);
574  gbc.gridy++;
575  header.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "attribType"), gbc);
576  gbc.gridy++;
577  header.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "attribArchetype"), gbc);
578 
579  gbc.gridx = 3;
580  gbc.gridy = 1;
581  gbc.weightx = 1.0;
582  final JTextComponent nameTextField;
583  final String objName = gameObject.getObjName();
584  if (objName.isEmpty()) {
585  final String archObjName = archetype.getObjName();
586  final String nameText = !archObjName.isEmpty() ? archObjName : archetype.getArchetypeName();
587  nameTextField = new JTextField(nameText, 16);
588  } else {
589  nameTextField = new JTextField(objName, 16);
590  }
591  nameTextField.setEditable(false);
592  header.add(nameTextField, gbc);
593  gbc.gridy++;
594  header.add(buildTypesBox(), gbc); // build type-selection box
595  gbc.gridy++;
596  final JTextComponent archetypeTextField = new JTextField(archetype.getArchetypeName(), 16);
597  archetypeTextField.setEditable(false);
598  header.add(archetypeTextField, gbc);
599 
600  return header;
601  }
602 
607  @NotNull
608  private Object[] buildOptions() {
609  summaryEditButton = new JButton(summaryAction);
610  okButton = new JButton(ACTION_BUILDER.createAction(false, "attribOk", this));
611  cancelButton = new JButton(ACTION_BUILDER.createAction(false, "attribCancel", this));
612  return new Object[] { new JButton(ACTION_BUILDER.createAction(false, "attribHelp", this)), summaryEditButton, Box.createHorizontalStrut(32), okButton, new JButton(ACTION_BUILDER.createAction(false, "attribApply", this)), cancelButton, };
613  }
614 
618  @ActionMethod
619  public void attribHelp() {
620  final String helpText = ACTION_BUILDER.format("arcDoc.htmlText", archetypeType.getTypeName(), archetypeType.getDescription(), archetypeType.getUse());
621  new Help(/* XXX */ parent, helpText).setVisible(true);
622  }
623 
627  @ActionMethod
628  public void attribOk() {
629  if (applySettings()) {
630  optionPane.setValue(okButton);
631  }
632  }
633 
637  @ActionMethod
638  public void attribApply() {
639  applySettings();
640  }
641 
645  @ActionMethod
646  public void attribCancel() {
647  optionPane.setValue(cancelButton);
648  }
649 
654  @ActionMethod
655  public void attribSummary() {
656  // interface is displayed, switch to summary
657  final Document doc = summaryTextPane.getDocument();
658 
659  try {
660  // clear document
661  if (doc.getLength() > 0) {
662  doc.remove(0, doc.getLength());
663  }
664 
665  // now loop through all attributes and write out nonzero ones
666  for (final DialogAttribute<?, ?, ?, ?> dialogAttribute : attributesPaneBuilder.getDialogAttributes()) {
667  dialogAttribute.appendSummary(doc, summaryTextStyle);
668  }
669  } catch (final BadLocationException e) {
670  LOG.error("toggleSummary: Bad Location in Document!", e);
671  }
672 
673  summaryTextPane.setCaretPosition(0); // this prevents the document from scrolling down
674  summaryEditButton.setAction(editAction);
675  cardLayout.show(centerPanel, "summary");
676  }
677 
682  @ActionMethod
683  public void attribEdit() {
684  summaryEditButton.setAction(summaryAction);
685  cardLayout.show(centerPanel, "edit");
686  }
687 
693  private boolean applySettings() {
694  final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare();
695  assert mapSquare != null;
696  final MapModel<G, A, R> tmpMapModel = mapSquare.getMapModel();
697  tmpMapModel.beginTransaction("Change object attributes");
698  try {
699  return applySettings2();
700  } finally {
701  tmpMapModel.endTransaction();
702  }
703  }
704 
710  private boolean applySettings2() {
711  final ArchetypeType tmpArchetypeType = archetypeTypeSet.getArchetypeTypeByBaseObject(gameObject); // the type structure for this gameObject
712 
713  final StringBuilder newArchText = new StringBuilder();
714  final String[] newMsg = new String[1];
715  for (final DialogAttribute<G, A, R, ?> dialogAttribute : attributesPaneBuilder.getDialogAttributes()) {
716  final String text;
717  try {
718  text = dialogAttribute.getObjectText(gameObject, archetype, newMsg, tmpArchetypeType);
719  } catch (final InvalidAttributeException ex) {
720  JOptionPane.showMessageDialog(optionPane, ex.getMessage(), "Input Error", JOptionPane.ERROR_MESSAGE);
721  return false;
722  }
723  if (!text.isEmpty()) {
724  newArchText.append(text).append("\n");
725  }
726  }
727 
728  // Also write all the 'fixed' attributes into the archetype text
729  for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) {
730  for (final ArchetypeAttribute archetypeAttribute : archetypeAttributeSection) {
731  // ### TODO: for changed types, copy fixed attributes over default arches ###
732  if (archetypeAttribute instanceof ArchetypeAttributeFixed) {
733  final String defaultValue = archetype.getAttributeString(archetypeAttribute.getArchetypeAttributeName());
734  if (defaultValue.isEmpty() || (gameObject.getTypeNo() != archetype.getTypeNo() && !defaultValue.equalsIgnoreCase(archetypeAttribute.getAttributeName()))) {
735  // usually, fixed attributes are only applied when *not* defined in the archetype.
736  // the reason behind this is: if the default gameObject violates our fixed attribute,
737  // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy.
738  // BUT - if the gameObject has a changed type, the archetype has lost it's credibility.
739  // So, in this special case, the fixed attribute applies always.
740  newArchText.append(archetypeAttribute.getArchetypeAttributeName()).append(" ").append(archetypeAttribute.getAttributeName()).append("\n");
741  }
742  }
743  }
744  }
745 
746  // before we modify the archetype text, we look for errors and save them.
747  // later the user must confirm whether to keep or dump those errors
748  final String errors = GameObjectUtils.getSyntaxErrors(gameObject, tmpArchetypeType);
749 
750  // --- parsing succeeded, now we write it into the gameObject/map ---
751  final int typeNo = gameObject.getTypeNo();
752  gameObject.setObjectText(newArchText.toString());
753  gameObject.setAttributeInt(BaseObject.TYPE, typeNo);
754 
755  if (newMsg[0] != null) {
756  // set new msg text only when it is not equal to Archetype
757  final String msgText = StringUtils.removeTrailingWhitespaceFromLines(newMsg[0]);
758  final String archetypeMsgText = archetype.getMsgText();
759  gameObject.setMsgText(msgText.equals(archetypeMsgText == null ? "" : archetypeMsgText) ? null : msgText);
760  } else {
761  final String archetypeMsgText = archetype.getMsgText();
762  gameObject.setMsgText(archetypeMsgText != null && !archetypeMsgText.isEmpty() ? "" : null);
763  }
764 
765  // now lets assign the visible face - perhaps we have still an animation
766  faceLabel.setIcon(getFace(gameObject));
767 
768  // deal with syntax errors now
769  if (errors != null) {
770  // For the fallback archetype type, all errors are automatically
771  // kept. "Misc" is no real type - it is more a default mask for
772  // unknown types. For all other archetype types, a popup dialog is
773  // opened and the user may decide what to do with his errors.
774  final boolean keepErrors = archetypeTypeSet.isFallbackArchetypeType(tmpArchetypeType) || ConfirmErrorsDialog.askConfirmErrors(errors, optionPane);
775  if (keepErrors) {
776  gameObject.addObjectText(errors.trim());
777  }
778  }
779 
780  return true; // apply succeeded
781  }
782 
783 }
void removeMapManagerListener(@NotNull MapManagerListener< G, A, R > listener)
Removes a MapManagerListener to be notified.
Utility class for displaying a dialog to keep or dump invalid attributes of a game object...
JComponent buildHeader()
Constructs the upper left part of the attribute dialog, containing name, type, archetype name and fac...
Utility class for string manipulation.
A MapModel reflects the data of a map.
Definition: MapModel.java:75
String getObjName()
Returns the name of the object as shown to the player.
A MapManager manages all opened maps.
Definition: MapManager.java:37
Graphical User Interface of Gridarta.
Settings that apply to a project.
JDialog createDialog()
Creates a new JDialog instance for this dialog.
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
Definition: MapSquare.java:99
Manages ArchetypeType instances, list, and bitmask definitions.
This Class contains the data of one archetype attribute.
static String getSyntaxErrors(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final ArchetypeType type)
This method checks the objectText for syntax errors.
This package contains the framework for validating maps.
void endTransaction()
End a transaction.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
ArchetypeType getArchetypeTypeByBaseObject(@NotNull final BaseObject<?, ?, ?, ?> baseObject)
Returns the ArchetypeType for the given BaseObject.
Component getTabbedPane()
Returns the JTabbedPane that contains all attribute tabs.
Contains the data of one Gridarta Object-Type.
Interface for listeners listening on MapModel events.
This packages implements the online help system for the Gridarta editor.
Definition: Help.java:20
An ArchetypeAttribute displaying a fixed string.
static boolean askConfirmErrors(@NotNull final String errors, @NotNull final Component parent)
Open a popup dialog and ask the user to confirm (or modify) the encountered syntax errors...
boolean isFallbackArchetypeType(@NotNull final ArchetypeType archetypeType)
Returns whether a given ArchetypeType is the fallback archetype type used for game objects not matchi...
String getArchetypeName()
Returns the name of this archetype.
Describes a numbered in-game spell.
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Register a map listener.
void buildAttribute(@NotNull final Attributes attributes, @NotNull final Iterable< ArchetypeAttributeSection > archetypeType)
Constructs the central part of the attribute dialog, containing the object&#39;s attributes.
final JTextPane summaryTextPane
The text pane where the summary is displayed.
String getAttributeString(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as String.
String TYPE
The attribute name of the object&#39;s type.
Definition: BaseObject.java:66
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
static String removeTrailingWhitespaceFromLines(@NotNull final CharSequence str)
Removes trailing whitespace from all lines of a string.
Base package of all Gridarta classes.
Common base class for spells and spell lists.
Definition: Spells.java:33
final MapModelListener< G, A, R > mapModelListener
Tracks mapModel&#39;s map for changes: when the gameObject is removed, cancels this dialog.
Reflects a game object (object on a map).
Definition: GameObject.java:36
void hideAttributeDialog(@NotNull final G gameObject)
Hides the game object attributes dialog for a given GameObject instance.
Iterable< DialogAttribute< G, A, R, ?> > getDialogAttributes()
Returns all DialogAttributes in the dialog.
Component buildTypesBox()
Constructs the combo box of the available archetypes.
A ListCellRenderer implementation that displays ArchetypeTypes.
Interface for listeners listening to MapManager changes.
final MapManagerListener< G, A, R > mapManagerListener
The MapManagerListener to detect closed maps.
ImageIcon getFace(@NotNull final BaseObject< G, A, R, ?> gameObject)
Returns the face for a GameObject.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
AnimationObjects is a container for AnimationObjects.
GameObjects are the objects based on Archetypes found on maps.
final GameObjectAttributesDialogFactory< G, A, R > gameObjectAttributesDialogFactory
The associated factory.
Point getMapLocation()
Returns the coordinate on the map.
Definition: MapSquare.java:124
Utility class for GameObject related functions.
The CFTreasureListTree class fully manages treasurelists.
Object [] buildOptions()
Constructs the dialog options: help, default, okay, apply, cancel.
Implements the Help Window is a separate frame with html content.
Definition: Help.java:42
String getDescription()
Returns the description.
final ArchetypeTypeSet archetypeTypeSet
Reference to the ArchetypeTypeSet.
Describes a numbered in-game spell.
This package contains the other part of the script editor.
FaceObjects is a container for FaceObjects.
void removeFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener)
Removes a FaceObjectProvidersListener to be notified about changes.
String getMsgText()
Returns the message bound to this object.
int getArchetypeTypeCount()
Returns the number of ArchetypeTypes in the list.
final Container centerPanel
The central pane, this is the parent component of above tabbed pane.
void removeMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Unregister a map listener.
R getArchetype()
Returns the Archetype this GameObject is based on.
A single Attribute, combining an ArchetypeAttribute with its input component(s).
Utility class for ActionBuilder related functions.
Stores all defined treasure lists.
Interface for listeners interested in FaceObjectProviders related events.
Provider for faces of GameObjects and Archetypes.
The face is the appearance of an object.
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
final AttributesPaneBuilder< G, A, R > attributesPaneBuilder
/he AttributesPaneBuilder for creating (and re-creating) the attribute tabs.
final FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
An interface for classes that collect errors.
final ItemListener typesBoxItemListener
ItemListener for the type-selection box on the attribute dialog.
final FaceObjectProvidersListener faceObjectProvidersListener
The FaceObjectProvidersListener for detecting reloaded faces.
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
void beginTransaction(@NotNull String name)
Starts a new transaction.
boolean applySettings()
This method is called when the "apply"-button has been pressed.
static String format(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final Object... args)
Returns the value of a key.
Defines types of GameObjects with corresponding attributes.
GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory< G, A, R > gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final Frame parent, @NotNull final CFTreasureListTree treasureListTree, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects, @NotNull final ProjectSettings projectSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final FaceObjects faceObjects, @NotNull final Spells< GameObjectSpell< G, A, R >> gameObjectSpells, @NotNull final Spells< NumberSpell > numberSpells, final int undefinedSpellIndex, @NotNull final TreasureTree treasureTree, @NotNull final ImageIcon noFaceSquareIcon, @NotNull final ImageIcon unknownSquareIcon, @NotNull final TextAreaDefaults textAreaDefaults, @NotNull final MapManager< G, A, R > mapManager)
Creates a new instance.
boolean applySettings2()
This method is called when the "apply"-button has been pressed.
The location of a map file with a map directory.
Definition: MapFile.java:31
String getTypeName()
Returns the type name (artificial).
final CardLayout cardLayout
The CardLayout for toggling between edit and summary.
String getUse()
Returns the usage notes.
Encapsulates default settings for a text area.
int getTypeNo()
Returns the type number of this Archetype.
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30