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-2023 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) {
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.getMapSquareOptional() == 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.getMapSquareOptional() != 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.getMapSquareOptional() == 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 {
408  }
409 
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  mapModel = mapSquare.getMapModel();
457  mapPos = mapSquare.getMapLocation();
460 
461  // first split top-left and -right
463  final JComponent leftPane = buildHeader();
464 
465  // Now split horizontally
466  attributesPaneBuilder = new AttributesPaneBuilder<>(gameObject, optionPane, archetypeTypeSet, treasureListTree, faceObjectProviders, animationObjects, projectSettings, mapFileFilter, scriptFileFilter, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, treasureTree, noFaceSquareIcon, unknownSquareIcon, textAreaDefaults);
468  centerPanel = new JPanel(cardLayout);
470  summaryTextPane = new JTextPane();
471  summaryTextPane.setEditable(false);
472  summaryTextPane.setBorder(BorderFactory.createEmptyBorder(3, 15, 0, 0));
473  centerPanel.add("summary", new JScrollPane(summaryTextPane));
474  final Dimension size = centerPanel.getPreferredSize();
475  size.height = 256;
476  centerPanel.setMinimumSize(size);
477  centerPanel.setPreferredSize(size);
478 
479  final Container contentPanel = new JPanel(new GridBagLayout());
480  final GridBagConstraints gbc = new GridBagConstraints();
481  gbc.weightx = 1.0;
482  gbc.fill = GridBagConstraints.BOTH;
483  gbc.gridwidth = GridBagConstraints.REMAINDER;
484  gbc.weighty = 0.0;
485  contentPanel.add(leftPane, gbc);
486  gbc.weighty = 1.0;
487  contentPanel.add(centerPanel, gbc);
488 
489  optionPane.setOptions(buildOptions());
490 
491  summaryTextStyle = summaryTextPane.getStyle(StyleContext.DEFAULT_STYLE);
492  StyleConstants.setForeground(summaryTextStyle, Color.black);
493 
495 
496  optionPane.setMessage(contentPanel);
497  }
498 
503  @NotNull
504  public JDialog createDialog() {
505  final JDialog dialog = optionPane.createDialog(parent, ActionBuilderUtils.getString(ACTION_BUILDER, "attribTitle"));
506  dialog.getRootPane().setDefaultButton(okButton);
507  dialog.setResizable(true);
508  dialog.setModal(false);
509  dialog.setVisible(true);
510  return dialog;
511  }
512 
517  @NotNull
518  private Component buildTypesBox() {
520  int i = 0;
521  for (final ArchetypeType tmp : archetypeTypeSet) {
522  model[i++] = tmp;
523  }
524 
525  final JComboBox<?> typeComboBox = new JComboBox<>(model);
526  typeComboBox.setSelectedItem(archetypeType);
527  typeComboBox.setRenderer(new ArchetypeTypeListCellRenderer());
528  typeComboBox.setName("Types");
529  typeComboBox.addItemListener(typesBoxItemListener);
530  return typeComboBox;
531  }
532 
538  @NotNull
539  private ImageIcon getFace(@NotNull final BaseObject<G, A, R, ?> gameObject) {
541  }
542 
549  @NotNull
550  private JComponent buildHeader() {
551  final JComponent header = new JPanel(new GridBagLayout()); // the final thing, in a panel
552  final GridBagConstraints gbc = new GridBagConstraints();
553  gbc.fill = GridBagConstraints.BOTH;
554  gbc.insets = new Insets(2, 2, 2, 2);
555  gbc.gridx = 1;
556  gbc.gridy = 1;
557  gbc.weightx = 0.0;
558  gbc.weighty = 3.0;
559  gbc.gridheight = 3;
560  faceLabel = new JLabel(getFace(gameObject));
561  faceLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
562  header.add(faceLabel, gbc);
563  gbc.gridheight = 1;
564  gbc.weighty = 1.0;
565  gbc.fill = GridBagConstraints.HORIZONTAL;
566 
567  gbc.weightx = 0.0;
568  gbc.gridx = 2;
569  gbc.gridy = 1;
570  header.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "attribName"), gbc);
571  gbc.gridy++;
572  header.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "attribType"), gbc);
573  gbc.gridy++;
574  header.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "attribArchetype"), gbc);
575 
576  gbc.gridx = 3;
577  gbc.gridy = 1;
578  gbc.weightx = 1.0;
579  final JTextComponent nameTextField;
580  final String objName = gameObject.getObjName();
581  if (objName.isEmpty()) {
582  final String archObjName = archetype.getObjName();
583  final String nameText = archObjName.isEmpty() ? archetype.getArchetypeName() : archObjName;
584  nameTextField = new JTextField(nameText, 16);
585  } else {
586  nameTextField = new JTextField(objName, 16);
587  }
588  nameTextField.setEditable(false);
589  header.add(nameTextField, gbc);
590  gbc.gridy++;
591  header.add(buildTypesBox(), gbc); // build type-selection box
592  gbc.gridy++;
593  final JTextComponent archetypeTextField = new JTextField(archetype.getArchetypeName(), 16);
594  archetypeTextField.setEditable(false);
595  header.add(archetypeTextField, gbc);
596 
597  return header;
598  }
599 
604  @NotNull
605  private Object @NotNull [] buildOptions() {
606  summaryEditButton = new JButton(summaryAction);
607  okButton = new JButton(ACTION_BUILDER.createAction(false, "attribOk", this));
608  cancelButton = new JButton(ACTION_BUILDER.createAction(false, "attribCancel", this));
609  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, };
610  }
611 
615  @ActionMethod
616  public void attribHelp() {
617  final String helpText = ACTION_BUILDER.format("arcDoc.htmlText", archetypeType.getTypeName(), archetypeType.getDescription(), archetypeType.getUse());
618  new Help(/* XXX */ parent, helpText).setVisible(true);
619  }
620 
624  @ActionMethod
625  public void attribOk() {
626  if (applySettings()) {
627  optionPane.setValue(okButton);
628  }
629  }
630 
634  @ActionMethod
635  public void attribApply() {
636  applySettings();
637  }
638 
642  @ActionMethod
643  public void attribCancel() {
644  optionPane.setValue(cancelButton);
645  }
646 
651  @ActionMethod
652  public void attribSummary() {
653  // interface is displayed, switch to summary
654  final Document doc = summaryTextPane.getDocument();
655 
656  try {
657  // clear document
658  if (doc.getLength() > 0) {
659  doc.remove(0, doc.getLength());
660  }
661 
662  // now loop through all attributes and write out nonzero ones
664  dialogAttribute.appendSummary(doc, summaryTextStyle);
665  }
666  } catch (final BadLocationException e) {
667  LOG.error("toggleSummary: Bad Location in Document!", e);
668  }
669 
670  summaryTextPane.setCaretPosition(0); // this prevents the document from scrolling down
671  summaryEditButton.setAction(editAction);
672  cardLayout.show(centerPanel, "summary");
673  }
674 
679  @ActionMethod
680  public void attribEdit() {
681  summaryEditButton.setAction(summaryAction);
682  cardLayout.show(centerPanel, "edit");
683  }
684 
690  private boolean applySettings() {
691  final MapModel<G, A, R> tmpMapModel = gameObject.getMapSquare().getMapModel();
692  tmpMapModel.beginTransaction("Change object attributes");
693  try {
694  return applySettings2();
695  } finally {
696  tmpMapModel.endTransaction();
697  }
698  }
699 
705  private boolean applySettings2() {
706  final ArchetypeType tmpArchetypeType = archetypeTypeSet.getArchetypeTypeByBaseObject(gameObject); // the type structure for this gameObject
707 
708  final StringBuilder newArchText = new StringBuilder();
709  final String[] newMsg = new String[1];
711  final String text;
712  try {
713  text = dialogAttribute.getObjectText(gameObject, archetype, newMsg, tmpArchetypeType);
714  } catch (final InvalidAttributeException ex) {
715  JOptionPane.showMessageDialog(optionPane, ex.getMessage(), "Input Error", JOptionPane.ERROR_MESSAGE);
716  return false;
717  }
718  if (!text.isEmpty()) {
719  newArchText.append(text).append("\n");
720  }
721  }
722 
723  // Also write all the 'fixed' attributes into the archetype text
724  for (final ArchetypeAttributeSection archetypeAttributeSection : archetypeType) {
725  for (final ArchetypeAttribute archetypeAttribute : archetypeAttributeSection) {
726  // ### TODO: for changed types, copy fixed attributes over default arches ###
727  if (archetypeAttribute instanceof ArchetypeAttributeFixed) {
728  final String defaultValue = archetype.getAttributeString(archetypeAttribute.getArchetypeAttributeName());
729  if (defaultValue.isEmpty() || (gameObject.getTypeNo() != archetype.getTypeNo() && !defaultValue.equalsIgnoreCase(archetypeAttribute.getAttributeName()))) {
730  // usually, fixed attributes are only applied when *not* defined in the archetype.
731  // the reason behind this is: if the default gameObject violates our fixed attribute,
732  // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy.
733  // BUT - if the gameObject has a changed type, the archetype has lost it's credibility.
734  // So, in this special case, the fixed attribute applies always.
735  newArchText.append(archetypeAttribute.getArchetypeAttributeName()).append(" ").append(archetypeAttribute.getAttributeName()).append("\n");
736  }
737  }
738  }
739  }
740 
741  // before we modify the archetype text, we look for errors and save them.
742  // later the user must confirm whether to keep or dump those errors
743  final String errors = GameObjectUtils.getSyntaxErrors(gameObject, tmpArchetypeType);
744 
745  // --- parsing succeeded, now we write it into the gameObject/map ---
746  final int typeNo = gameObject.getTypeNo();
747  gameObject.setObjectText(newArchText.toString());
748  gameObject.setAttributeInt(BaseObject.TYPE, typeNo);
749 
750  if (newMsg[0] == null) {
751  final String archetypeMsgText = archetype.getMsgText(false);
752  gameObject.setMsgText(archetypeMsgText != null && !archetypeMsgText.isEmpty() ? "" : null);
753  } else {
754  // set new msg text only when it is not equal to Archetype
755  final String msgText = StringUtils.removeTrailingWhitespaceFromLines(newMsg[0]);
756  final String archetypeMsgText = archetype.getMsgText(false);
757  gameObject.setMsgText(msgText.equals(archetypeMsgText == null ? "" : archetypeMsgText) ? null : msgText);
758  }
759 
760  // now lets assign the visible face - perhaps we have still an animation
761  faceLabel.setIcon(getFace(gameObject));
762 
763  // deal with syntax errors now
764  if (errors != null) {
765  // For the fallback archetype type, all errors are automatically
766  // kept. "Misc" is no real type - it is more a default mask for
767  // unknown types. For all other archetype types, a popup dialog is
768  // opened and the user may decide what to do with his errors.
769  final boolean keepErrors = archetypeTypeSet.isFallbackArchetypeType(tmpArchetypeType) || ConfirmErrorsDialog.askConfirmErrors(errors, optionPane);
770  if (keepErrors) {
771  gameObject.addObjectText(errors.trim());
772  }
773  }
774 
775  return true; // apply succeeded
776  }
777 
778 }
net.sf.gridarta.model.mapmanager
Definition: AbstractMapManager.java:20
net.sf.gridarta.model.archetypetype
Defines types of GameObjects with corresponding attributes.
Definition: AbstractArchetypeAttributeInvSpell.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.ConfirmErrorsDialog.askConfirmErrors
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.
Definition: ConfirmErrorsDialog.java:71
net.sf.gridarta.textedit.textarea.TextAreaDefaults
Encapsulates default settings for a text area.
Definition: TextAreaDefaults.java:26
net.sf.gridarta.model.mapmodel.MapModel
A MapModel reflects the data of a map.
Definition: MapModel.java:75
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.createDialog
JDialog createDialog()
Creates a new JDialog instance for this dialog.
Definition: GameObjectAttributesDialog.java:504
net.sf.gridarta.model.archetype.Archetype.getArchetypeName
String getArchetypeName()
Returns the name of this archetype.
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.editAction
final Action editAction
The Action for switching to the edit.
Definition: GameObjectAttributesDialog.java:230
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.mapManagerListener
final MapManagerListener< G, A, R > mapManagerListener
The MapManagerListener to detect closed maps.
Definition: GameObjectAttributesDialog.java:325
net.sf.gridarta.model.mapmanager.MapManager
A MapManager manages all opened maps.
Definition: MapManager.java:37
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.mapModelListener
final MapModelListener< G, A, R > mapModelListener
Tracks mapModel's map for changes: when the gameObject is removed, cancels this dialog.
Definition: GameObjectAttributesDialog.java:281
net.sf.gridarta.gui.dialog.gameobjectattributes.AttributesPaneBuilder.buildAttribute
void buildAttribute(@NotNull final Attributes attributes, @NotNull final Iterable< ArchetypeAttributeSection > archetypeType)
Constructs the central part of the attribute dialog, containing the object's attributes.
Definition: AttributesPaneBuilder.java:636
net.sf.gridarta.model.mapmodel.MapSquare.getMapLocation
Point getMapLocation()
Returns the coordinate on the map.
Definition: MapSquare.java:124
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attribSummary
void attribSummary()
Action method for summary.
Definition: GameObjectAttributesDialog.java:652
net.sf.gridarta.textedit.textarea
This package contains the other part of the script editor.
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attributesPaneBuilder
final AttributesPaneBuilder< G, A, R > attributesPaneBuilder
/he AttributesPaneBuilder for creating (and re-creating) the attribute tabs.
Definition: GameObjectAttributesDialog.java:174
net.sf.gridarta.model.mapmanager.MapManager.removeMapManagerListener
void removeMapManagerListener(@NotNull MapManagerListener< G, A, R > listener)
Removes a MapManagerListener to be notified.
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.cancelButton
AbstractButton cancelButton
The Button for cancel.
Definition: GameObjectAttributesDialog.java:244
net.sf.gridarta.gui.dialog.gameobjectattributes.InvalidAttributeException
Indicates that an attribute cannot be encoded.
Definition: InvalidAttributeException.java:29
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.summaryTextPane
final JTextPane summaryTextPane
The text pane where the summary is displayed.
Definition: GameObjectAttributesDialog.java:265
net.sf.gridarta.model.mapmodel.MapSquare
A single Map Square.
Definition: MapSquare.java:45
net.sf.gridarta.model.mapmodel.MapModel.endTransaction
void endTransaction()
End a transaction.
net.sf.gridarta.model.anim.AnimationObjects
AnimationObjects is a container for AnimationObjects.
Definition: AnimationObjects.java:30
net.sf.gridarta.gui.dialog.gameobjectattributes.ConfirmErrorsDialog
Utility class for displaying a dialog to keep or dump invalid attributes of a game object.
Definition: ConfirmErrorsDialog.java:50
net.sf.gridarta.model.spells.GameObjectSpell
Describes a numbered in-game spell.
Definition: GameObjectSpell.java:33
net.sf.gridarta.model.archetypetype.ArchetypeType.getTypeName
String getTypeName()
Returns the type name (artificial).
Definition: ArchetypeType.java:160
net.sf.gridarta.model.archetypetype.ArchetypeType.getUse
String getUse()
Returns the usage notes.
Definition: ArchetypeType.java:206
net.sf
net.sf.gridarta.model.mapmodel.MapModel.beginTransaction
void beginTransaction(@NotNull String name)
Starts a new transaction.
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog
Common base class for game object attributes dialogs.
Definition: GameObjectAttributesDialog.java:103
net.sf.gridarta.model.mapmanager.MapManagerListener
Interface for listeners listening to MapManager changes.
Definition: MapManagerListener.java:42
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.applySettings
boolean applySettings()
This method is called when the "apply"-button has been pressed.
Definition: GameObjectAttributesDialog.java:690
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.summaryTextStyle
final Style summaryTextStyle
Definition: GameObjectAttributesDialog.java:268
net.sf.gridarta.model.mapmanager.MapManager.addMapManagerListener
void addMapManagerListener(@NotNull MapManagerListener< G, A, R > listener)
Adds a MapManagerListener to be notified.
net.sf.gridarta.gui.dialog.gameobjectattributes.ArchetypeTypeListCellRenderer
A ListCellRenderer implementation that displays ArchetypeTypes.
Definition: ArchetypeTypeListCellRenderer.java:31
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.parent
final Frame parent
The parent frame for showing dialog boxes.
Definition: GameObjectAttributesDialog.java:134
net.sf.gridarta.model.face.FaceObjectProviders
Provider for faces of GameObjects and Archetypes.
Definition: FaceObjectProviders.java:46
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.mapcontrol
Definition: DefaultMapControl.java:20
net.sf.gridarta.utils.ActionBuilderUtils.newLabel
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
Definition: ActionBuilderUtils.java:117
net.sf.gridarta.model.mapmodel.MapModel.addMapModelListener
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Register a map listener.
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attribApply
void attribApply()
Action method for apply.
Definition: GameObjectAttributesDialog.java:635
net.sf.gridarta.textedit
net.sf.gridarta.model.archetypetype.ArchetypeTypeSet
Manages ArchetypeType instances, list, and bitmask definitions.
Definition: ArchetypeTypeSet.java:40
net.sf.gridarta.gui.dialog.help.Help
Implements the Help Window is a separate frame with html content.
Definition: Help.java:42
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.applySettings2
boolean applySettings2()
This method is called when the "apply"-button has been pressed.
Definition: GameObjectAttributesDialog.java:705
net.sf.gridarta.model.face.FaceObjectProviders.addFaceObjectProvidersListener
void addFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener)
Adds a FaceObjectProvidersListener to be notified about changes.
Definition: FaceObjectProviders.java:197
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net.sf.gridarta.gui.dialog.gameobjectattributes.AttributesPaneBuilder.getTabbedPane
Component getTabbedPane()
Returns the JTabbedPane that contains all attribute tabs.
Definition: AttributesPaneBuilder.java:617
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.summaryAction
final Action summaryAction
The Action for switching to the summary.
Definition: GameObjectAttributesDialog.java:223
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.buildTypesBox
Component buildTypesBox()
Constructs the combo box of the available archetypes.
Definition: GameObjectAttributesDialog.java:518
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.faceLabel
JLabel faceLabel
The panel for object's face (png).
Definition: GameObjectAttributesDialog.java:181
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attribOk
void attribOk()
Action method for ok.
Definition: GameObjectAttributesDialog.java:625
net.sf.gridarta.gui.dialog.gameobjectattributes.AttributesPaneBuilder< G, A, R >
net.sf.gridarta.gui.dialog.gameobjectattributes.DialogAttribute
A single Attribute, combining an ArchetypeAttribute with its input component(s).
Definition: DialogAttribute.java:41
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net.sf.gridarta.model.face.FaceObjectProviders.removeFaceObjectProvidersListener
void removeFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener)
Removes a FaceObjectProvidersListener to be notified about changes.
Definition: FaceObjectProviders.java:206
net
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.cardLayout
final CardLayout cardLayout
The CardLayout for toggling between edit and summary.
Definition: GameObjectAttributesDialog.java:216
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.mapManager
final MapManager< G, A, R > mapManager
The MapManager instance.
Definition: GameObjectAttributesDialog.java:146
net.sf.gridarta.model.archetypetype.ArchetypeTypeSet.getArchetypeTypeByBaseObject
ArchetypeType getArchetypeTypeByBaseObject(@NotNull final BaseObject<?, ?, ?, ?> baseObject)
Returns the ArchetypeType for the given BaseObject.
Definition: ArchetypeTypeSet.java:142
errors
errors
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:1
net.sf.gridarta.model.archetypetype.ArchetypeAttribute
This Class contains the data of one archetype attribute.
Definition: ArchetypeAttribute.java:28
net.sf.gridarta.model.treasurelist.TreasureTree
Stores all defined treasure lists.
Definition: TreasureTree.java:32
net.sf.gridarta.model.mapmodel.MapModel.removeMapModelListener
void removeMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Unregister a map listener.
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.LOG
static final Category LOG
The Logger for printing log messages.
Definition: GameObjectAttributesDialog.java:109
net.sf.gridarta.model.maparchobject.MapArchObject
Interface for MapArchObjects.
Definition: MapArchObject.java:40
net.sf.gridarta.model.spells.NumberSpell
Describes a numbered in-game spell.
Definition: NumberSpell.java:28
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.summaryEditButton
AbstractButton summaryEditButton
The Button for toggling the summary.
Definition: GameObjectAttributesDialog.java:237
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.mapModel
final MapModel< G, A, R > mapModel
gameObject's initial map.
Definition: GameObjectAttributesDialog.java:195
net.sf.gridarta.model.archetypetype.ArchetypeType.getDescription
String getDescription()
Returns the description.
Definition: ArchetypeType.java:196
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attribHelp
void attribHelp()
Action method for help.
Definition: GameObjectAttributesDialog.java:616
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.buildOptions
Object[] buildOptions()
Constructs the dialog options: help, default, okay, apply, cancel.
Definition: GameObjectAttributesDialog.java:605
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.buildHeader
JComponent buildHeader()
Constructs the upper left part of the attribute dialog, containing name, type, archetype name and fac...
Definition: GameObjectAttributesDialog.java:550
net.sf.gridarta.model.face.FaceObjects
FaceObjects is a container for FaceObjects.
Definition: FaceObjects.java:31
net.sf.gridarta.model.validation.ErrorCollector
An interface for classes that collect errors.
Definition: ErrorCollector.java:33
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attribEdit
void attribEdit()
Turns the summary off.
Definition: GameObjectAttributesDialog.java:680
net.sf.gridarta.gui.dialog.help
The online help system for the Gridarta editor.
Definition: Help.java:20
net.sf.gridarta.model.face.FaceObjectProviders.getFace
public< G extends GameObject< G, A, R >, A extends MapArchObject< A >, R extends Archetype< G, A, R > > ImageIcon getFace(@NotNull final BaseObject< G, A, R, ?> baseObject)
Returns the face of a BaseObject as an ImageIcon.
Definition: FaceObjectProviders.java:251
net.sf.gridarta.utils.ActionBuilderUtils.format
static String format(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final Object... args)
Returns the value of a key.
Definition: ActionBuilderUtils.java:101
net.sf.gridarta.model.gameobject.GameObjectUtils.getSyntaxErrors
static String getSyntaxErrors(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final ArchetypeType type)
This method checks the objectText for syntax errors.
Definition: GameObjectUtils.java:56
net.sf.gridarta.model.validation
This package contains the framework for validating maps.
Definition: AbstractValidator.java:20
net.sf.gridarta.utils.ActionBuilderUtils.getString
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Definition: ActionBuilderUtils.java:71
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.attribCancel
void attribCancel()
Action method for cancel.
Definition: GameObjectAttributesDialog.java:643
net.sf.gridarta.model.baseobject.BaseObject
Definition: BaseObject.java:34
net.sf.gridarta.gui.dialog
net.sf.gridarta.utils.StringUtils
Utility class for string manipulation.
Definition: StringUtils.java:31
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.model.settings.ProjectSettings
Settings that apply to a project.
Definition: ProjectSettings.java:29
net.sf.gridarta.model.mapmodel.MapSquare.getMapModel
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
Definition: MapSquare.java:99
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialogFactory< G, A, R >
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.gameObjectAttributesDialogFactory
final GameObjectAttributesDialogFactory< G, A, R > gameObjectAttributesDialogFactory
The associated factory.
Definition: GameObjectAttributesDialog.java:121
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.gameObject
final G gameObject
The game object being modified.
Definition: GameObjectAttributesDialog.java:188
net.sf.gridarta.model.spells
Definition: ArchetypeSetSpellLoader.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.faceObjectProvidersListener
final FaceObjectProvidersListener faceObjectProvidersListener
The FaceObjectProvidersListener for detecting reloaded faces.
Definition: GameObjectAttributesDialog.java:355
net.sf.gridarta.model.mapmodel.MapModelListener
Interface for listeners listening on MapModel events.
Definition: MapModelListener.java:36
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.archetypeTypeSet
final ArchetypeTypeSet archetypeTypeSet
Reference to the ArchetypeTypeSet.
Definition: GameObjectAttributesDialog.java:127
net.sf.gridarta.model.mapmodel.MapModel.getMapSquare
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection
A set of ArchetypeAttributes.
Definition: ArchetypeAttributeSection.java:32
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Reflects an Archetype.
Definition: Archetype.java:41
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.okButton
JButton okButton
The Button for ok.
Definition: GameObjectAttributesDialog.java:251
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.getFace
ImageIcon getFace(@NotNull final BaseObject< G, A, R, ?> gameObject)
Returns the face for a GameObject.
Definition: GameObjectAttributesDialog.java:539
net.sf.gridarta.model.baseobject
Definition: AbstractBaseObject.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.GameObjectAttributesDialog
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.
Definition: GameObjectAttributesDialog.java:446
net.sf.gridarta.model.archetypetype.ArchetypeTypeSet.isFallbackArchetypeType
boolean isFallbackArchetypeType(@NotNull final ArchetypeType archetypeType)
Returns whether a given ArchetypeType is the fallback archetype type used for game objects not matchi...
Definition: ArchetypeTypeSet.java:182
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.ACTION_BUILDER
static final ActionBuilder ACTION_BUILDER
Action Builder.
Definition: GameObjectAttributesDialog.java:115
net.sf.gridarta.model.face.FaceObjectProvidersListener
Interface for listeners interested in FaceObjectProviders related events.
Definition: FaceObjectProvidersListener.java:29
net.sf.gridarta.model.face
The face is the appearance of an object.
Definition: AbstractFaceObjects.java:20
net.sf.gridarta.model.anim
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
Definition: AbstractAnimationObjects.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.AttributesPaneBuilder.getDialogAttributes
Iterable< DialogAttribute< G, A, R, ?> > getDialogAttributes()
Returns all DialogAttributes in the dialog.
Definition: AttributesPaneBuilder.java:626
net.sf.gridarta.model.archetypetype.ArchetypeAttributeFixed
An ArchetypeAttribute displaying a fixed string.
Definition: ArchetypeAttributeFixed.java:29
net.sf.gridarta.model.mapcontrol.MapControl
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.archetype
final Archetype< G, A, R > archetype
gameObject's archetype.
Definition: GameObjectAttributesDialog.java:209
net.sf.gridarta.utils.ActionBuilderUtils
Utility class for ActionBuilder related functions.
Definition: ActionBuilderUtils.java:31
net.sf.gridarta.model.archetypetype.ArchetypeType
Contains the data of one Gridarta Object-Type.
Definition: ArchetypeType.java:35
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.model.gameobject.GameObjectUtils
Utility class for GameObject related functions.
Definition: GameObjectUtils.java:32
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.faceObjectProviders
final FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
Definition: GameObjectAttributesDialog.java:140
net.sf.gridarta.model.archetypetype.ArchetypeType.getTypeNo
int getTypeNo()
Returns the type number.
Definition: ArchetypeType.java:151
net.sf.gridarta.model.baseobject.BaseObject.TYPE
String TYPE
The attribute name of the object's type.
Definition: BaseObject.java:66
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.centerPanel
final Container centerPanel
The central pane, this is the parent component of above tabbed pane.
Definition: GameObjectAttributesDialog.java:258
net.sf.gridarta.utils.StringUtils.removeTrailingWhitespaceFromLines
static String removeTrailingWhitespaceFromLines(@NotNull final CharSequence str)
Removes trailing whitespace from all lines of a string.
Definition: StringUtils.java:133
net.sf.gridarta.model.spells.Spells
Common base class for spells and spell lists.
Definition: Spells.java:33
net.sf.gridarta.gui.treasurelist
Definition: CFTreasureListTree.java:20
net.sf.gridarta.model.treasurelist
Definition: ArchTreasureObj.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.archetypeType
ArchetypeType archetypeType
The ArchetypeType of gameObject.
Definition: GameObjectAttributesDialog.java:274
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.typesBoxItemListener
final ItemListener typesBoxItemListener
ItemListener for the type-selection box on the attribute dialog.
Definition: GameObjectAttributesDialog.java:368
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.optionPane
final JOptionPane optionPane
Definition: GameObjectAttributesDialog.java:149
net.sf.gridarta.gui.treasurelist.CFTreasureListTree
The CFTreasureListTree class fully manages treasurelists.
Definition: CFTreasureListTree.java:61
net.sf.gridarta.model.settings
Definition: AbstractDefaultProjectSettings.java:20
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialogFactory.hideAttributeDialog
void hideAttributeDialog(@NotNull final G gameObject)
Hides the game object attributes dialog for a given GameObject instance.
Definition: GameObjectAttributesDialogFactory.java:241
net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialog.mapPos
final Point mapPos
The position of the game object.
Definition: GameObjectAttributesDialog.java:202
net.sf.gridarta.model.archetypetype.ArchetypeTypeSet.getArchetypeTypeCount
int getArchetypeTypeCount()
Returns the number of ArchetypeTypes in the list.
Definition: ArchetypeTypeSet.java:172