 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.var.daimonin.gui.mappropertiesdialog;
22 import java.awt.BorderLayout;
23 import java.awt.Component;
24 import java.awt.Container;
25 import java.awt.FlowLayout;
26 import java.awt.Frame;
27 import java.awt.GridBagConstraints;
28 import java.awt.GridBagLayout;
29 import java.awt.GridLayout;
30 import java.awt.Insets;
31 import java.awt.Window;
32 import javax.swing.AbstractButton;
33 import javax.swing.BorderFactory;
34 import javax.swing.BoxLayout;
35 import javax.swing.JButton;
36 import javax.swing.JCheckBox;
37 import javax.swing.JComponent;
38 import javax.swing.JDialog;
39 import javax.swing.JFileChooser;
40 import javax.swing.JOptionPane;
41 import javax.swing.JPanel;
42 import javax.swing.JScrollPane;
43 import javax.swing.JTabbedPane;
44 import javax.swing.JTextArea;
45 import javax.swing.JTextField;
46 import javax.swing.ScrollPaneConstants;
47 import javax.swing.border.Border;
48 import javax.swing.border.EmptyBorder;
49 import javax.swing.filechooser.FileFilter;
63 import net.
sf.japi.swing.action.ActionBuilder;
64 import net.
sf.japi.swing.action.ActionBuilderFactory;
65 import net.
sf.japi.swing.action.ActionMethod;
66 import net.
sf.japi.swing.misc.JFileChooserButton;
67 import org.jetbrains.annotations.NotNull;
68 import org.jetbrains.annotations.Nullable;
89 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
130 private final JTextField
mapName =
new JTextField();
316 final JButton helpButton =
new JButton(
ACTION_BUILDER.createAction(
false,
"mapHelp",
this));
317 final JButton restoreButton =
new JButton(
ACTION_BUILDER.createAction(
false,
"mapRestore",
this));
325 final JTabbedPane tabs =
new JTabbedPane();
326 tabs.setBorder(
new EmptyBorder(10, 4, 4, 4));
339 final Container layoutHack =
new JPanel(
new BorderLayout());
340 layoutHack.add(tabs);
341 setMessage(layoutHack);
363 final GridBagConstraints gbc =
new GridBagConstraints();
364 final JComponent mainPanel =
new JPanel(
new GridBagLayout());
366 gbc.fill = GridBagConstraints.BOTH;
401 mapDescription.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0));
402 scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
414 final JPanel optionPanel =
new JPanel(
new GridLayout(0, 2));
434 final JComponent scrollPane =
new JScrollPane(optionPanel);
446 final JPanel mapPanel =
new JPanel(
new GridBagLayout());
447 final GridBagConstraints labelGbc =
new GridBagConstraints();
448 labelGbc.anchor = GridBagConstraints.EAST;
449 labelGbc.insets =
new Insets(2, 10, 2, 2);
450 final GridBagConstraints gbc =
new GridBagConstraints();
451 gbc.insets =
new Insets(2, 2, 2, 2);
452 gbc.fill = GridBagConstraints.HORIZONTAL;
453 gbc.gridwidth = GridBagConstraints.REMAINDER;
458 mapName.setText(map.getMapName());
464 final Container mapBackgroundMusicPanel =
new JPanel(
new BorderLayout());
467 mapPanel.add(mapBackgroundMusicPanel, gbc);
479 gbc.gridwidth = GridBagConstraints.REMAINDER;
483 final Container p2 =
new JPanel(
new GridBagLayout());
486 gbc.anchor = GridBagConstraints.CENTER;
487 gbc.fill = GridBagConstraints.NONE;
489 gbc.gridwidth = GridBagConstraints.REMAINDER;
493 gbc.fill = GridBagConstraints.HORIZONTAL;
494 mapPanel.add(p2, gbc);
496 final JComponent scrollPane =
new JScrollPane(mapPanel);
508 final Container panel =
new JPanel(
new BorderLayout());
548 public void setValue(@Nullable
final Object newValue) {
549 super.setValue(newValue);
550 if (
dialog !=
null && newValue != UNINITIALIZED_VALUE) {
575 private static Component
createPanelLine(@NotNull
final JTextField textField,
final int n,
final int defaultValue, @NotNull
final String labelKey) {
576 final Container lineLayout =
new JPanel(
new FlowLayout(FlowLayout.RIGHT));
578 textField.setColumns(n);
579 textField.setText(Integer.toString(defaultValue));
580 textField.setToolTipText(
ACTION_BUILDER.getString(labelKey +
".shortdescription"));
581 lineLayout.add(textField);
593 private static Component
createPanelCBox(@NotNull
final AbstractButton checkBox,
final boolean state, @NotNull
final String labelKey) {
594 final JPanel panel =
new JPanel();
595 panel.setLayout(
new BoxLayout(panel, BoxLayout.X_AXIS));
598 checkBox.setSelected(state);
610 final int difficulty;
612 final int resetTimeout;
625 if (difficulty < 1) {
626 throw new IllegalArgumentException(
"Difficulty must be > 0");
631 if (width < 1 || height < 1) {
635 mapSize =
new Size2D(width, height);
641 if (
mapName.getText().isEmpty()) {
645 }
catch (
final IllegalArgumentException e) {
646 ACTION_BUILDER.showMessageDialog(
this,
"mapErrorInvalidEntry", e.getMessage());
652 mapModel.beginTransaction(
"Map properties");
701 private static int parseProperty(@NotNull
final String s, @NotNull
final String label) {
705 final int r = Integer.parseInt(s);
707 if (r < 0 && !label.equals(
"Darkness")) {
708 throw new IllegalArgumentException(label +
": '" + s +
"' is negative.");
753 public void showDialog(@NotNull
final Component parentComponent) {
755 final JDialog window = createDialog(parentComponent, title);
757 window.getRootPane().setDefaultButton(
okButton);
758 window.setResizable(
true);
759 window.setModal(
false);
760 window.setVisible(
true);
762 ACTION_BUILDER.showOnetimeMessageDialog(window, WARNING_MESSAGE,
"mapTilesNoMapFileNoMapTilePane");
final AbstractMapTilePane< GameObject, MapArchObject, Archetype > mapTilePane
The AbstractMapTilePane.
boolean isUltimateDeath()
Returns the ultimate death attribute.
int getWidth()
Returns the width of the area.
A MapModel reflects the data of a map.
boolean isPermDeath()
Returns the permanent death attribute.
void setPvp(final boolean pvp)
Sets the pvp attribute.
A MapManager manages all opened maps.
void setBackgroundMusic(@NotNull final String backgroundMusic)
Sets the name of the background music.
final AbstractButton checkboxOutdoor
The "outdoor" attribute.
void mapRestore()
Action method for restore.
Handles the Daimonin variants of GameObjects and Archetypes.
void mapCancel()
Action method for cancel.
final JTextField fieldEnterY
The enter y coordinate.
Base package of all Gridarta classes.
Defines common UI constants used in different dialogs.
boolean isNoPriest()
Returns the no priest attribute.
final AbstractButton checkboxFixedReset
The fixed reset attribute.
final AbstractButton checkboxNoHarm
The no harm attribute.
final JTextField mapName
The name of the game object.
final JTextField fieldResetTimeout
The reset timeout.
static Component createPanelCBox(@NotNull final AbstractButton checkBox, final boolean state, @NotNull final String labelKey)
Creates a checkbox-line, similar to createPanelLine.
final JButton cancelButton
JButton for cancel.
void setMapName(@NotNull final String name)
Component createOptionsPanel(@NotNull final MapArchObject map)
Creates the options panel.
Implements Daimonin archetypes.
void setUltraDeath(final boolean ultraDeath)
Sets the ultra death attribute.
String getBackgroundMusic()
Returns the name of the background music.
final JTextField mapWidthField
The width in squares.
final JTextField mapHeightField
The height in squares.
Window dialog
The Window that represents the dialog.
static JLabel newLabel(@NotNull final ActionBuilder actionBuilder, @NotNull final String key)
Creates a new JLabel from a resource key.
static int parseProperty(@NotNull final String s, @NotNull final String label)
This is a simple string-to-int parser that throws IllegalArgumentExceptions with appropriate error me...
static final ActionBuilder ACTION_BUILDER
Action Builder.
void setFixedReset(final boolean fixedReset)
Implements the Help Window is a separate frame with html content.
void setSwapTime(final int swapTime)
void restoreMapProperties()
Resets all map properties to the saved values in the map arch object.
boolean isFixedLogin()
Returns the fixed login attribute.
Graphical User Interface of Gridarta.
void setMapSize(@NotNull final Size2D mapSize)
void setNoMagic(final boolean noMagic)
Sets the no magic attribute.
void setNoSave(final boolean noSave)
Sets the no save attribute.
void setNoHarm(final boolean noHarm)
Sets the no harm attribute.
A Panel for managing the tiling of maps.
void setDifficulty(final int difficulty)
Component createMainPanel(@NotNull final MapArchObject map)
Creates the main panel.
void setPermDeath(final boolean permDeath)
Sets the permanent death attribute.
int getHeight()
Returns the height of the area.
void setResetTimeout(final int resetTimeout)
final AbstractButton checkboxUltraDeath
The ultra death attribute.
void setText(final String text)
final AbstractButton checkboxUltimateDeath
The ultimate death attribute.
void setNoSummon(final boolean noSummon)
Sets the no summon attribute.
static Component createTilePathPanel(@NotNull final Component mapTilePane)
Creates the tile path panel.
final JTextField fieldEnterX
The enter x coordinate.
void setEnterX(final int enterX)
boolean isUltraDeath()
Returns the ultra death attribute.
Interface for MapArchObjects.
final MapModel< GameObject, MapArchObject, Archetype > mapModel
The MapModel this dialog shows.
MapPropertiesDialog(@NotNull final Frame helpParent, @NotNull final MapManager< GameObject, MapArchObject, Archetype > mapManager, @NotNull final ProjectSettings projectSettings, @NotNull final MapModel< GameObject, MapArchObject, Archetype > mapModel, @NotNull final FileFilter mapFileFilter)
Creates a map-options dialog.
final Frame helpParent
The parent frame for help windows.
A Panel for managing the tiling of maps.
void setNoPriest(final boolean noPriest)
Sets the no priest attribute.
boolean isNoMagic()
Returns the no magic attribute.
boolean isPvp()
Returns the pvp attribute.
final JTextField fieldDifficulty
The map difficulty.
The online help system for the Gridarta editor.
void setEnterY(final int enterY)
final boolean mapTilePaneEnabled
Whether the map tile pane was enabled.
final ProjectSettings projectSettings
The project settings instance.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
static final long serialVersionUID
Serial version UID.
boolean isNoSave()
Returns the no save attribute.
final JTextField fieldDarkness
The map darkness.
final JButton okButton
JButton for ok.
Handles the Daimonin GameObjects.
Settings that apply to a project.
Component createMapDataPanel(@NotNull final net.sf.gridarta.model.maparchobject.MapArchObject< MapArchObject > map)
Creates the map data panel.
boolean isNoHarm()
Returns the no harm attribute.
static Border createTitledBorder(@NotNull final String key)
Creates a border to be used in dialogs to frame dialog component groups.
final AbstractButton checkboxNoPriest
The no priest attribute.
void mapOkay()
Action method for okay.
void showDialog(@NotNull final Component parentComponent)
Creates and displays the map properties dialog.
final AbstractButton checkboxPermDeath
The perm death attribute.
void setValue(@Nullable final Object newValue)
static void setAutoSelectOnFocus(@NotNull final JTextComponent textComponent)
Selects all text of a JTextComponent when the component gains the focus.
Main package of Gridarta4Daimonin, contains all classes specific to the Daimonin version of the Grida...
final AbstractButton checkboxNoFixedLogin
The no fixed login attribute.
static Component createPanelLine(@NotNull final JTextField textField, final int n, final int defaultValue, @NotNull final String labelKey)
Creates an "attribute"-line (format: <label> <textfield>).
Base classes for rendering maps.
final AbstractButton checkboxNoSave
The no save attribute.
MapArchObject contains the specific meta data about a map that is stored in the map-arch,...
void setDarkness(final int darkness)
void setFixedLogin(final boolean fixedLogin)
Sets the fixed login attribute.
Utility class for ActionBuilder related functions.
final JTextField mapBackgroundMusic
The name of the sound file.
final AbstractButton checkboxPvp
The pvp attribute.
final AbstractButton checkboxNoSummon
The no summon attribute.
void setOutdoor(final boolean outdoor)
boolean modifyMapProperties()
Checks the given values and modifies the current map.
final AbstractButton checkboxNoMagic
The no magic attribute.
void mapHelp()
Action method for help.
File getMediaDirectory()
Returns the media directory.
A dialog to change the properties of a map, like several flags and settings about the environment and...
Utility class for JTextComponent related functions.
The class Size2D represents a 2d rectangular area.
final JTextField fieldSwapTime
The swap time.
void setUltimateDeath(final boolean ultimateDeath)
Sets the ultimate death attribute.
Component createMapPanel(@NotNull final MapArchObject map)
Creates the map panel.
boolean isNoSummon()
Returns the no summon attribute.
Border DIALOG_BORDER
The Border object to be used when creating dialogs.
final JTextArea mapDescription
The message text.