20 package net.sf.gridarta.gui.dialog.gameobjectattributes;
22 import javax.swing.JComboBox;
23 import javax.swing.text.Document;
24 import javax.swing.text.Style;
32 import org.jetbrains.annotations.NotNull;
45 private final JComboBox<?>
input;
70 final int index = input.getSelectedIndex();
71 if (index < gameObjectSpells.
size() + (isOptionalSpell ? 1 : 0)) {
72 final boolean isModified;
73 switch (gameObject.countInvObjects()) {
77 isModified = index != gameObjectSpells.
size();
86 if (index >= gameObjectSpells.
size()) {
96 final String invObjectArchetypeName = invObject.
getArchetype().getArchetypeName();
106 gameObject.removeAll();
107 if (index < gameObjectSpells.
size()) {
108 final G spellObject = gameObjectSpells.
getSpell(index).createGameObject();
109 gameObject.addLast(spellObject);
113 final int modelSize = input.getModel().getSize();
114 if (modelSize > gameObjectSpells.
size() + (isOptionalSpell ? 1 : 0)) {
115 input.removeItemAt(modelSize - 1);
124 public void appendSummary(@NotNull
final Document doc, @NotNull
final Style style) {
125 final Object selectedItem = input.getSelectedItem();
126 if (selectedItem == null) {
130 final String value = selectedItem.toString().trim();
131 if (value.isEmpty() || value.startsWith(
"<")) {
135 addLine(doc, style,
"",
" = " + value);
void appendSummary(@NotNull final Document doc, @NotNull final Style style)
Iterator< G > iterator()
The Iterator returned does not recurse, it only contains objects on the first level.
Contains the data of one Gridarta Object-Type.
String getArchetypeName()
Return the archetype name of the spell object.
String getObjectText(@NotNull final G gameObject, @NotNull final Archetype< G, A, R > archetype, @NotNull final String[] newMsg, @NotNull final ArchetypeType archetypeType)
Base package of all Gridarta classes.
Common base class for spells and spell lists.
Reflects a game object (object on a map).
final Spells< GameObjectSpell< G, A, R > > gameObjectSpells
The game object spells to display.
GameObjects are the objects based on Archetypes found on maps.
final T ref
Reference to the attribute data.
Describes a numbered in-game spell.
R getArchetype()
Returns the Archetype this GameObject is based on.
A single Attribute, combining an ArchetypeAttribute with its input component(s).
void addLine( @NotNull final Document doc, @NotNull final AttributeSet style, @NotNull final String prefix, @NotNull final String postfix)
Appends a line to a Document.
S getSpell(final int index)
Return one spell object by index.
boolean isDefaultGameObject()
Returns whether this game object is unmodified from its underlying archetype.
final JComboBox<?> input
The input ui component for editing the value.
DialogAttributeInvSpell(final boolean isOptionalSpell, @NotNull final ArchetypeAttributeInvSpell ref, @NotNull final JComboBox<?> input, @NotNull final Spells< GameObjectSpell< G, A, R >> gameObjectSpells)
Creates a new instance.
final boolean isOptionalSpell
Whether the spell game object is optional.
An ArchetypeAttribute for selecting a spell encoded as an inventory game object.
Defines types of GameObjects with corresponding attributes.
Interface for MapArchObjects.
int size()
Return the number of existing spell objects.