 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.panel.gameobjectattributes;
22 import java.awt.BorderLayout;
23 import java.awt.Container;
24 import java.awt.Dimension;
25 import java.awt.Frame;
26 import java.awt.GridLayout;
27 import javax.swing.Action;
28 import javax.swing.DefaultListModel;
29 import javax.swing.JButton;
30 import javax.swing.JList;
31 import javax.swing.JPanel;
32 import javax.swing.JScrollPane;
33 import javax.swing.ListModel;
34 import javax.swing.ListSelectionModel;
35 import javax.swing.ScrollPaneConstants;
36 import javax.swing.border.EtchedBorder;
37 import javax.swing.event.ListSelectionListener;
49 import net.
sf.japi.swing.action.ActionBuilder;
50 import net.
sf.japi.swing.action.ActionBuilderFactory;
51 import net.
sf.japi.swing.action.ActionMethod;
52 import org.jetbrains.annotations.NotNull;
53 import org.jetbrains.annotations.Nullable;
66 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
108 private final JPanel
panel =
new JPanel();
163 public EventsTab(@NotNull
final Frame
parent, @NotNull
final MapManager<G, A, R> mapManager, @NotNull
final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull
final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull
final ScriptArchData<G, A, R> scriptArchData, @NotNull
final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull
final ScriptArchUtils scriptArchUtils) {
164 super(gameObjectAttributesModel);
174 scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
175 scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
176 scrollPane.setPreferredSize(
new Dimension(80, 40));
178 final Container buttons =
new JPanel(
new GridLayout(4, 1));
184 panel.setLayout(
new BorderLayout());
186 panel.add(buttons, BorderLayout.EAST);
187 panel.setPreferredSize(
new Dimension(100, 40));
189 eventList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
190 final ListSelectionListener listSelectionListener = e ->
updateActions();
191 eventList.addListSelectionListener(listSelectionListener);
192 refresh(gameObjectAttributesModel.getSelectedGameObject());
212 protected final void refresh(@Nullable
final G gameObject) {
214 if (gameObject ==
null || !gameObject.isScripted()) {
216 final ListModel<?> listModel =
eventList.getModel();
217 if (listModel !=
null && listModel.getSize() > 0) {
218 eventList.setModel(
new DefaultListModel<>());
239 protected void apply(@NotNull
final G gameObject) {
281 if (gameObject ==
null) {
286 final G selectedHead = gameObject.
getHead();
317 if (gameObject ==
null) {
321 final ListModel<?> listModel =
eventList.getModel();
322 if (listModel ==
null || listModel.getSize() <= 0) {
326 final int index =
eventList.getSelectedIndex();
332 final G selectedHead = gameObject.
getHead();
355 private void setEventPanelButtonState(
final boolean newButton,
final boolean modifyButton,
final boolean pathButton,
final boolean removeButton) {
A MapModel reflects the data of a map.
EVENT_EDIT_PATH
Opens a dialog to edit the script parameters.
A MapManager manages all opened maps.
MODIFIED
The tab contents are modified from defaults.
Base package of all Gridarta classes.
void apply(@NotNull final G gameObject)
void endTransaction()
End a transaction.
final ScriptArchEditor< G, A, R > scriptArchEditor
The ScriptArchEditor to use.
void eventEdit()
Action method for editing an existing event.
void beginTransaction(@NotNull String name)
Starts a new transaction.
Common types for event archetypes.
Reflects a game object (object on a map).
EVENT_OPEN
Opens an editor for the script code.
final Action aEventAddNew
The action for "add new event".
final ScriptArchUtils scriptArchUtils
The ScriptArchUtils to use.
void setEventPanelButtonState(final boolean newButton, final boolean modifyButton, final boolean pathButton, final boolean removeButton)
Sets the enable/disable states for the four buttons in the event panel.
Base class for GameObjectAttributesTab implementations.
final JList< String > eventList
The JList that shows all events.
Graphical User Interface of Gridarta.
Severity levels for colors of tabs.
void updateActions()
Updates the enabled state of all actions.
final ScriptArchData< G, A, R > scriptArchData
The ScriptArchData instance to use.
GameObjects are the objects based on Archetypes found on maps.
EVENT_REMOVE
Removes the event object.
final JScrollPane scrollPane
The JScrollPane displaying all event.s.
final Frame parent
The parent frame for dialog boxes.
void addEventScript(@NotNull final G gameObject, @NotNull final ScriptArchData< G, A, R > scriptArchData, @NotNull final Frame parent)
A popup is opened and the user can create a new scripting event which gets attached to this gameObjec...
Interface for MapArchObjects.
void eventRemove()
Action method for removing an existing event.
Dialog to create events linked to item scripting.
EventsTab(@NotNull final Frame parent, @NotNull final MapManager< G, A, R > mapManager, @NotNull final GameObjectAttributesModel< G, A, R > gameObjectAttributesModel, @NotNull final ScriptArchEditor< G, A, R > scriptArchEditor, @NotNull final ScriptArchData< G, A, R > scriptArchData, @NotNull final ScriptArchDataUtils< G, A, R > scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils)
Creates a new instance.
Parameter for operation to perform in ScriptTask, javax.swing.JList, net.sf.gridarta....
void eventAddNew()
Action method for creating a new event.
final Action aEventEdit
The action for "edit event code".
static final ActionBuilder ACTION_BUILDER
The ActionBuilder.
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
void eventEditData()
Action method for editing the data of an existing event.
boolean doAddNewEvent(final boolean performAction)
This method is invoked when the user pressed the "new event" button.
T getHead()
Return the head part of a multi-part object.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
boolean isEmpty(@NotNull G gameObject)
Returns whether this ScriptArchData is empty (contains no events).
void setTabSeverity( @NotNull final Severity tabSeverity)
Sets the tab severity.
boolean doEditEvent(@NotNull final ScriptTask task, final boolean performAction)
This method is invoked when the user pressed the "edit event"/"path"/"remove" button from the event p...
final MapManager< G, A, R > mapManager
The MapManager.
void modifyEventScript(final int eventIndex, final ScriptTask task, @NotNull final JList< String > panelList, @NotNull final MapManager<?, ?, ?> mapManager, @NotNull final Frame parent, @NotNull final Iterable< G > gameObject)
If there is a scripted event of the specified type, the script pad is opened and the appropriate scri...
The "Events" tab in the game object attributes panel.
final void refresh(@Nullable final G gameObject)
final ScriptArchDataUtils< G, A, R > scriptArchDataUtils
The ScriptArchDataUtils to use.
final Action aEventRemove
The action for "remove event".
void addEventsToJList(@NotNull JList< String > list, @NotNull Iterable<? extends GameObject<?, ?, ?>> gameObject)
Set all ScriptedEvents to appear in the given JList This method should be fast because it may be exec...
final JPanel panel
The content panel.
DEFAULT
The tab contents are unchanged from defaults.
final Action aEventEditData
The action for "edit event parameters".
GameObject< G, A, R > selectedGameObject
The currently selected game object.
net.sf.gridarta.model.scripts.ScriptArchData related functions.
Stores and manages information about scripted events.