From: <aki...@us...> - 2008-02-23 13:30:31
|
Revision: 3610 http://gridarta.svn.sourceforge.net/gridarta/?rev=3610&view=rev Author: akirschbaum Date: 2008-02-23 05:30:32 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move identical code from GameObjectAttributesPanel to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:25:30 UTC (rev 3609) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:30:32 UTC (rev 3610) @@ -28,20 +28,12 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.Toolkit; import java.util.prefs.Preferences; import javax.swing.Action; -import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTextField; -import javax.swing.JToggleButton; -import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ErrorListView; import net.sf.gridarta.gui.GSplitPane; @@ -49,7 +41,6 @@ import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.connectionview.MonsterControl; -import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.ErrorCollector; @@ -69,507 +60,20 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; - - /** Controller of this subview. */ - private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; - - private final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainView; - - /** The buttons for the direction panel. - * @see #directionButtonGroup - */ - private final JToggleButton[] directionButtons = new JToggleButton[9]; - - /** - * The ButtonGroup for the direction buttons. - * @see #directionButtons - */ - private final ButtonGroup directionButtonGroup = new ButtonGroup(); - - private final GSplitPane splitPane; - - /** The {@link ErrorListView} holding the error information. */ - private final ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> errorListView; - - /** Arch name field. */ - private final JTextField archNameField = new JTextField(14); - - private final JLabel archMapPos = new JLabel(); - - private final JLabel archFaceText = new JLabel(); - - private final JLabel archTypeText = new JLabel(); - - private final JPanel mapArchPanel = new JPanel(); - - private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); - - private final Action aMapArchAddInv = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); - - private final Action aMapArchAttrib = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); - - private final GameObjectTextEditor gameObjectTextEditor; - /* Build Panel */ public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { - super(mainControl); - this.mainControl = mainControl; - this.errorListView = new ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - mainView = view; - - gameObjectTextEditor = new GameObjectTextEditor(); - - mapArchPanel.setLayout(new BorderLayout()); - splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); - splitPane.setContinuousLayout(true); - splitPane.setResizeWeight(1); - splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); - add(splitPane, BorderLayout.CENTER); - - final JPanel buttonPanel = createButtonPanel(); - buttonPanel.setLayout(new GridLayout(0, 1)); - mapArchPanel.add(buttonPanel, BorderLayout.WEST); - mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - - panelDesktop.add(createArchPanel(), "Arch"); - panelDesktop.add(createTextPanel(), "Msg Text"); - panelDesktop.add(scriptPanel, "Scripts"); - panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(createConnectionPanel(), "Connection"); - panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(createMonsterPanel(), "Monster"); - panelDesktop.add(errorListView, "Warnings"); - - refreshDisplay(); + super(mainControl, view, lockedItemsControl); } /** {@inheritDoc} */ - @Override protected void setErrors(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - panelDesktop.setForegroundAt(7, mapModel.getErrors().getErrors().iterator().hasNext() ? Color.blue : Color.black); - errorListView.setErrors(mapModel, mapModel.getErrors()); - } - - /** - * Action method for applying the changes made in the arch panel. - */ - @ActionMethod public void mapArchApply() { - applyArchPanelChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); - } - - /** - * Action method for displaying the attributes of the currently selected object. - */ - @ActionMethod public void mapArchAttrib() { - mainControl.openAttrDialog(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); - } - - /** - * Action method for adding an object to the inventory of the currently selected object. - */ - @ActionMethod public void mapArchAddInv() { - final GameObject arch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); - if (arch == null) { // nothing selected? - return; - } - - GameObject inv = mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); - if (inv == null) { - return; - } - - // if this is a multi-tail, we put the new arch into the head's inv. - inv = inv.getHead(); - - final GameObject invnew; - if (arch.isArchetype()) { - // create a new copy of a default arch - invnew = arch.createArch(); + @Override protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { + final String faceName = gameObject.getFaceName(); + if (faceName != null) { + sb.append(faceName.length() == 0 ? ">no face<" : faceName); } else { - // create clone from a pickmap - invnew = arch.createClone(0, 0); + final String archFaceName = gameObject.getArchetype().getFaceName(); + sb.append(archFaceName == null ? ">no face<" : archFaceName); } - - invnew.setDirection(invnew.getArchetype().getDirection()); - mainControl.getArchetypeParser().postParseGameObject(invnew, 0); - final MapSquare<GameObject, MapArchObject, Archetype> mapSquare = inv.getMapSquare(); - assert mapSquare != null; - final MapModel mapModel = mapSquare.getModel(); - mapModel.beginTransaction("Add to inventory"); - inv.addLast(invnew); - invnew.setObjectFace(); - mapModel.endTransaction(); } - /** - * When the "apply"-button on the ArchPanel (at the bottom of the window) - * is pressed, this function updates the active arch object. - * @param activeArch the currently selected arch - */ - public void applyArchPanelChanges(final GameObject activeArch) { - if (activeArch == null) { - return; - } - - // If the active gameObject is part of a multi, the mutli-head's stats - // are taken instead: - final GameObject gameObject = activeArch.getHead(); - - final Archetype archetype = gameObject.getArchetype(); - - final MapSquare<GameObject, MapArchObject, Archetype> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - mapSquare.getModel().beginTransaction("Change object attributes"); - - // We update all panels: name, face, msg and archText (more to come...) - // the obj name: - if (isNonwhitespaceText(archNameField.getText())) { // there is something in - // if this equal the default name... - if (archetype.getObjName() != null) { - if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { - gameObject.setObjName(null); // yes, we don't need it in map - } else { - gameObject.setObjName(archNameField.getText()); // overrule in map gameObject - } - } else if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { - gameObject.setObjName(null); - } else { // def is null, something is in panel, so we set it - gameObject.setObjName(archNameField.getText()); // overrule in map gameObject - } - } else { - gameObject.setObjName(null); // nothing in, nothing in map gameObject - // hm, there is no way yet to overrule a default gameObject name with "nothing" - // like <name > ore <name "">..?? - } - - applyArchTextArea(gameObject); - - gameObjectTextEditor.applyChanges(gameObject); - - /* check we have a face and set the real face obj for fast access */ - final String face = gameObject.getAttributeString("face", false); - // we have a new face name - gameObject.setRealFace(face); - - if (gameObject.getAttributeString("direction", false).length() > 0) { - final int dir = gameObject.getAttributeInt("direction", false); - if (archetype.getDirection() != dir) { - gameObject.setDirection(dir); - } - } else { - gameObject.setDirection(archetype.getDirection()); - } - gameObject.setObjectFace(); - - // we look for 'type' in the ArchText. In future maybe type should get - // a seperate textfield - if (gameObject.getAttributeString("type", false).length() > 0) { - gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type - } - - // Recalculate the editType value. It shall stay 100% accurate ;) - gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); - - mapSquare.getModel().endTransaction(); - } - - /** Create the arch panel entry of the lower window. */ - private JPanel createArchPanel() { - final JPanel panel = new JPanel(); - final GridBagLayout gridbag = new GridBagLayout(); - final GridBagConstraints gbc = new GridBagConstraints(); - - panel.setLayout(gridbag); - gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = 1.0; - gbc.weighty = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - gbc.insets = new Insets(4, 4, 0, 0); - - archNameField.setText(""); - archNameField.setForeground(Color.blue); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archNameField, gbc); - panel.add(archNameField); - - archFaceText.setText(""); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archFaceText, gbc); - panel.add(archFaceText); - - archTypeText.setText(""); - gbc.gridx = 0; - gbc.gridy = 2; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archTypeText, gbc); - panel.add(archTypeText); - - archMapPos.setText(""); - gbc.gridx = 0; - gbc.gridy = 3; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archMapPos, gbc); - panel.add(archMapPos); - - gbc.gridx = 1; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 5; - gbc.weightx = 0.0; - panel.add(createDirPanel(), gbc); - - return panel; - } - - private JPanel createDirPanel() { - final JPanel dirPanel = new JPanel(new GridBagLayout()); - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.CENTER; - gbc.insets = new Insets(2, 2, 2, 2); - - createButton(7, dirPanel, gbc, 0, 0); - createButton(8, dirPanel, gbc, 1, 0); - createButton(1, dirPanel, gbc, 2, 0); - createButton(6, dirPanel, gbc, 0, 1); - createButton(0, dirPanel, gbc, 1, 1); - createButton(2, dirPanel, gbc, 2, 1); - createButton(5, dirPanel, gbc, 0, 2); - createButton(4, dirPanel, gbc, 1, 2); - createButton(3, dirPanel, gbc, 2, 2); - - return dirPanel; - } - - private void applyDirectionChanges(final GameObject gameObject, final int dir) { - gameObjectTextEditor.applyDirectionChanges(gameObject, dir, gameObject.getArchetype().getDirection()); - applyArchPanelChanges(gameObject); - setSelectedGameObject(gameObject); - } - - /** - * Action proxy for direction. - * @param direction Direction number - */ - private void direction(final int direction) { - applyDirectionChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(), direction); - } - - /** Action method for direction. */ - public void direction0() { - direction(0); - } - - /** Action method for direction. */ - public void direction1() { - direction(1); - } - - /** Action method for direction. */ - public void direction2() { - direction(2); - } - - /** Action method for direction. */ - public void direction3() { - direction(3); - } - - /** Action method for direction. */ - public void direction4() { - direction(4); - } - - /** Action method for direction. */ - public void direction5() { - direction(5); - } - - /** Action method for direction. */ - public void direction6() { - direction(6); - } - - /** Action method for direction. */ - public void direction7() { - direction(7); - } - - /** Action method for direction. */ - public void direction8() { - direction(8); - } - - /** - * Create a direction button. - * @param direction Direction for button - * @param panel Panel to add button to - * @param gbc GridBagConstraints to modify - * @param x x position of button - * @param y y position of button - */ - private void createButton(final int direction, final JPanel panel, final GridBagConstraints gbc, final int x, final int y) { - final JToggleButton button = new JToggleButton(ACTION_FACTORY.createAction(true, "direction" + direction, this)); - directionButtonGroup.add(button); - button.setFocusable(false); - button.setEnabled(false); - gbc.gridx = x; - gbc.gridy = y; - panel.add(button, gbc); - directionButtons[direction] = button; - } - - private JPanel createButtonPanel() { - final JPanel buttonPanel = new JPanel(); - buttonPanel.add(new JButton(aMapArchApply)); - buttonPanel.add(new JButton(aMapArchAddInv)); - buttonPanel.add(new JButton(aMapArchAttrib)); - return buttonPanel; - } - - public void appExitNotify() { - prefs.putInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); - } - - /** {@inheritDoc} */ - @Override protected void refreshDisplay() { - final GameObject selectedGameObject = getSelectedGameObject(); - final GameObject gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); - - aMapArchApply.setEnabled(gameObject != null); - aMapArchAddInv.setEnabled(gameObject != null); - aMapArchAttrib.setEnabled(gameObject != null); - - gameObjectTextEditor.refreshDisplay(gameObject); - refreshArchTab(gameObject); - refreshMsgTextTab(gameObject); - refreshScriptsTab(gameObject); - refreshAnimationTab(gameObject); - } - - /** - * Refresh the "Arch" tab in the Game Object Attributes Panel. - * - * @param gameObject The game object to set the contents from. - */ - private void refreshArchTab(final GameObject gameObject) - { - // tab color - panelDesktop.setForegroundAt(0, gameObject == null ? Color.black : Color.blue); - - // archNameField - if (gameObject == null) { - archNameField.setForeground(Color.black); - archNameField.setText(""); - } else { - final String objName = gameObject.getObjName(); - if (objName != null) { - archNameField.setForeground(Color.blue); - archNameField.setText(objName); - } else { - archNameField.setForeground(Color.black); - final String archObjName = gameObject.getArchetype().getObjName(); - archNameField.setText(archObjName != null ? archObjName : gameObject.getArchetypeName()); - } - } - - // archFaceText - if (gameObject == null) { - archFaceText.setText("Image:"); - } else { - final StringBuilder faceText = new StringBuilder("Image: "); - final String faceName = gameObject.getFaceName(); - if (faceName != null) { - faceText.append(faceName.length() == 0 ? ">no face<" : faceName); - } else { - final String archFaceName = gameObject.getArchetype().getFaceName(); - faceText.append(archFaceName == null ? ">no face<" : archFaceName); - } - archFaceText.setText(faceText.toString()); - } - - // archTypeText - if (gameObject == null) { - archTypeText.setText("Type:"); - } else { - final StringBuilder typeText = new StringBuilder("Type: "); - final CFArchType archType = mainControl.getTypeList().getType(gameObject); - typeText.append(archType.getTypeName()); - typeText.append(" (").append(archType.getTypeNr()).append(')'); - typeText.append(" [").append(gameObject.getArchetypeName()).append(']'); - if (gameObject.isMulti()) { - typeText.append(" [").append(gameObject.getSizeX()).append('x').append(gameObject.getSizeY()).append(']'); - } else { - typeText.append(" [single]"); - } - archTypeText.setText(typeText.toString()); - } - - // archMapPos - if (gameObject == null) { - archMapPos.setText("Status: "); - } else { - final StringBuilder specialText = new StringBuilder("Status:"); - if (!gameObject.isInContainer()) { - specialText.append(" (map: ").append(gameObject.getMapX()).append(", ").append(gameObject.getMapY()).append(')'); - } - if (gameObject.isScripted()) { - specialText.append(" (script)"); - } - if (gameObject.getMsgText() != null || gameObject.getArchetype().getMsgText() != null) { - specialText.append(" (msg)"); - } - final int invObjects = gameObject.countInvObjects(); - if (invObjects > 0) { - specialText.append(" (inv: ").append(invObjects).append(')'); - } - if (gameObject.isInContainer()) { - final GameObject cont = (GameObject) gameObject.getContainer(); - specialText.append(" (env: ").append(cont.getArchetypeName()).append(')'); - } - archMapPos.setText(specialText.toString()); - } - - // directions - for (final JToggleButton button : directionButtons) { - button.setBackground(null); - } - final boolean enableDirButtons = gameObject != null && gameObject.usesDirection(); - for (final JToggleButton button : directionButtons) { - button.setEnabled(enableDirButtons); - } - final int direction = enableDirButtons ? gameObject.getDirection() : 0; - directionButtons[direction < directionButtons.length ? direction : 0].setSelected(true); - } - - // calculate default value in case there is no settings file - private static int getMapArchPanelLocation() { - final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - return (int) (0.49 * screen.getWidth()); - } - - private JPanel createConnectionPanel() { - final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - return connectionControl.getView(); - } - - private JPanel createMonsterPanel() { - final MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> monsterControl = new MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - return monsterControl.getView(); - } - } // class GameObjectAttributesPanel Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:25:30 UTC (rev 3609) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:30:32 UTC (rev 3610) @@ -69,534 +69,42 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; - - /** Controller of this subview. */ - private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; - - private final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainView; - - /** The buttons for the direction panel. - * @see #directionButtonGroup - */ - private final JToggleButton[] directionButtons = new JToggleButton[9]; - - /** - * The ButtonGroup for the direction buttons. - * @see #directionButtons - */ - private final ButtonGroup directionButtonGroup = new ButtonGroup(); - - private final GSplitPane splitPane; - - /** The {@link ErrorListView} holding the error information. */ - private final ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> errorListView; - - /** Arch name field. */ - private final JTextField archNameField = new JTextField(14); - - private final JLabel archMapPos = new JLabel(); - - private final JLabel archFaceText = new JLabel(); - - private final JLabel archTypeText = new JLabel(); - - private final JPanel mapArchPanel = new JPanel(); - - private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); - - private final Action aMapArchAddInv = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); - - private final Action aMapArchAttrib = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); - - private final GameObjectTextEditor gameObjectTextEditor; - /* Build Panel */ public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { - super(mainControl); - this.mainControl = mainControl; - this.errorListView = new ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - mainView = view; - - gameObjectTextEditor = new GameObjectTextEditor(); - - mapArchPanel.setLayout(new BorderLayout()); - splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); - splitPane.setContinuousLayout(true); - splitPane.setResizeWeight(1); - splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); - add(splitPane, BorderLayout.CENTER); - - final JPanel buttonPanel = createButtonPanel(); - buttonPanel.setLayout(new GridLayout(0, 1)); - mapArchPanel.add(buttonPanel, BorderLayout.WEST); - mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - - panelDesktop.add(createArchPanel(), "Arch"); - panelDesktop.add(createTextPanel(), "Msg Text"); - panelDesktop.add(scriptPanel, "Scripts"); - panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(createConnectionPanel(), "Connection"); - panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(createMonsterPanel(), "Monster"); - panelDesktop.add(errorListView, "Warnings"); - - refreshDisplay(); + super(mainControl, view, lockedItemsControl); } /** {@inheritDoc} */ - @Override protected void setErrors(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - panelDesktop.setForegroundAt(7, mapModel.getErrors().getErrors().iterator().hasNext() ? Color.blue : Color.black); - errorListView.setErrors(mapModel, mapModel.getErrors()); - } + @Override protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { + final String faceName = gameObject.getFaceName(); + if (faceName != null) { + final GameObject.FaceSource desc = gameObject.getFaceObjSource(); + sb.append(faceName).append(" ("); + switch (desc) { + case FACE_NOT_FOUND: + sb.append("face not found"); + break; - /** - * Action method for applying the changes made in the arch panel. - */ - @ActionMethod public void mapArchApply() { - applyArchPanelChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); - } + case FACE: + sb.append("face"); + break; - /** - * Action method for displaying the attributes of the currently selected object. - */ - @ActionMethod public void mapArchAttrib() { - mainControl.openAttrDialog(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); - } + case ARCHETYPE_FACE: + sb.append("archetype face"); + break; - /** - * Action method for adding an object to the inventory of the currently selected object. - */ - @ActionMethod public void mapArchAddInv() { - final GameObject arch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); - if (arch == null) { // nothing selected? - return; - } + case ANIM: + sb.append("anim"); + break; - GameObject inv = mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); - if (inv == null) { - return; - } - - // if this is a multi-tail, we put the new arch into the head's inv. - inv = inv.getHead(); - - final GameObject invnew; - if (arch.isArchetype()) { - // create a new copy of a default arch - invnew = arch.createArch(); - } else { - // create clone from a pickmap - invnew = arch.createClone(0, 0); - } - - invnew.setDirection(invnew.getArchetype().getDirection()); - mainControl.getArchetypeParser().postParseGameObject(invnew, 0); - final MapSquare<GameObject, MapArchObject, Archetype> mapSquare = inv.getMapSquare(); - assert mapSquare != null; - final MapModel mapModel = mapSquare.getModel(); - mapModel.beginTransaction("Add to inventory"); - inv.addLast(invnew); - invnew.setObjectFace(); - mapModel.endTransaction(); - } - - /** - * When the "apply"-button on the ArchPanel (at the bottom of the window) - * is pressed, this function updates the active arch object. - * @param activeArch the currently selected arch - */ - public void applyArchPanelChanges(final GameObject activeArch) { - if (activeArch == null) { - return; - } - - // If the active gameObject is part of a multi, the mutli-head's stats - // are taken instead: - final GameObject gameObject = activeArch.getHead(); - - final Archetype archetype = gameObject.getArchetype(); - - final MapSquare<GameObject, MapArchObject, Archetype> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - mapSquare.getModel().beginTransaction("Change object attributes"); - - // We update all panels: name, face, msg and archText (more to come...) - // the obj name: - if (isNonwhitespaceText(archNameField.getText())) { // there is something in - // if this equal the default name... - if (archetype.getObjName() != null) { - if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { - gameObject.setObjName(null); // yes, we don't need it in map - } else { - gameObject.setObjName(archNameField.getText()); // overrule in map gameObject - } - } else if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { - gameObject.setObjName(null); - } else { // def is null, something is in panel, so we set it - gameObject.setObjName(archNameField.getText()); // overrule in map gameObject + case ARCHETYPE_ANIM: + sb.append("archetype anim"); + break; } + sb.append(')'); } else { - gameObject.setObjName(null); // nothing in, nothing in map gameObject - // hm, there is no way yet to overrule a default gameObject name with "nothing" - // like <name > ore <name "">..?? + sb.append(">no face<"); } - - applyArchTextArea(gameObject); - - gameObjectTextEditor.applyChanges(gameObject); - - /* check we have a face and set the real face obj for fast access */ - final String face = gameObject.getAttributeString("face", false); - // we have a new face name - gameObject.setRealFace(face); - if (gameObject.getAttributeString("animation", false).length() > 0) { - gameObject.setAnimName(gameObject.getAttributeString("animation", false)); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - - if (gameObject.getAttributeString("direction", false).length() > 0) { - final int dir = gameObject.getAttributeInt("direction", false); - if (archetype.getDirection() != dir) { - gameObject.setDirection(dir); - } - } else { - gameObject.setDirection(archetype.getDirection()); - } - gameObject.setObjectFace(); - - // we look for 'type' in the ArchText. In future maybe type should get - // a seperate textfield - if (gameObject.getAttributeString("type", false).length() > 0) { - gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type - } - - // Recalculate the editType value. It shall stay 100% accurate ;) - gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); - - mapSquare.getModel().endTransaction(); } - /** Create the arch panel entry of the lower window. */ - private JPanel createArchPanel() { - final JPanel panel = new JPanel(); - final GridBagLayout gridbag = new GridBagLayout(); - final GridBagConstraints gbc = new GridBagConstraints(); - - panel.setLayout(gridbag); - gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = 1.0; - gbc.weighty = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - gbc.insets = new Insets(4, 4, 0, 0); - - archNameField.setText(""); - archNameField.setForeground(Color.blue); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archNameField, gbc); - panel.add(archNameField); - - archFaceText.setText(""); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archFaceText, gbc); - panel.add(archFaceText); - - archTypeText.setText(""); - gbc.gridx = 0; - gbc.gridy = 2; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archTypeText, gbc); - panel.add(archTypeText); - - archMapPos.setText(""); - gbc.gridx = 0; - gbc.gridy = 3; - gbc.gridwidth = 1; - gbc.gridheight = 1; - gridbag.setConstraints(archMapPos, gbc); - panel.add(archMapPos); - - gbc.gridx = 1; - gbc.gridy = 0; - gbc.gridwidth = 1; - gbc.gridheight = 5; - gbc.weightx = 0.0; - panel.add(createDirPanel(), gbc); - - return panel; - } - - private JPanel createDirPanel() { - final JPanel dirPanel = new JPanel(new GridBagLayout()); - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.CENTER; - gbc.insets = new Insets(2, 2, 2, 2); - - createButton(7, dirPanel, gbc, 0, 0); - createButton(8, dirPanel, gbc, 1, 0); - createButton(1, dirPanel, gbc, 2, 0); - createButton(6, dirPanel, gbc, 0, 1); - createButton(0, dirPanel, gbc, 1, 1); - createButton(2, dirPanel, gbc, 2, 1); - createButton(5, dirPanel, gbc, 0, 2); - createButton(4, dirPanel, gbc, 1, 2); - createButton(3, dirPanel, gbc, 2, 2); - - return dirPanel; - } - - private void applyDirectionChanges(final GameObject gameObject, final int dir) { - gameObjectTextEditor.applyDirectionChanges(gameObject, dir, gameObject.getArchetype().getDirection()); - applyArchPanelChanges(gameObject); - setSelectedGameObject(gameObject); - } - - /** - * Action proxy for direction. - * @param direction Direction number - */ - private void direction(final int direction) { - applyDirectionChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(), direction); - } - - /** Action method for direction. */ - public void direction0() { - direction(0); - } - - /** Action method for direction. */ - public void direction1() { - direction(1); - } - - /** Action method for direction. */ - public void direction2() { - direction(2); - } - - /** Action method for direction. */ - public void direction3() { - direction(3); - } - - /** Action method for direction. */ - public void direction4() { - direction(4); - } - - /** Action method for direction. */ - public void direction5() { - direction(5); - } - - /** Action method for direction. */ - public void direction6() { - direction(6); - } - - /** Action method for direction. */ - public void direction7() { - direction(7); - } - - /** Action method for direction. */ - public void direction8() { - direction(8); - } - - /** - * Create a direction button. - * @param direction Direction for button - * @param panel Panel to add button to - * @param gbc GridBagConstraints to modify - * @param x x position of button - * @param y y position of button - */ - private void createButton(final int direction, final JPanel panel, final GridBagConstraints gbc, final int x, final int y) { - final JToggleButton button = new JToggleButton(ACTION_FACTORY.createAction(true, "direction" + direction, this)); - directionButtonGroup.add(button); - button.setFocusable(false); - button.setEnabled(false); - gbc.gridx = x; - gbc.gridy = y; - panel.add(button, gbc); - directionButtons[direction] = button; - } - - private JPanel createButtonPanel() { - final JPanel buttonPanel = new JPanel(); - buttonPanel.add(new JButton(aMapArchApply)); - buttonPanel.add(new JButton(aMapArchAddInv)); - buttonPanel.add(new JButton(aMapArchAttrib)); - return buttonPanel; - } - - public void appExitNotify() { - prefs.putInt(MAPARCHPANEL_LOCATION_KEY, splitPane.getDividerLocation()); - } - - /** {@inheritDoc} */ - @Override protected void refreshDisplay() { - final GameObject selectedGameObject = getSelectedGameObject(); - final GameObject gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); - - aMapArchApply.setEnabled(gameObject != null); - aMapArchAddInv.setEnabled(gameObject != null); - aMapArchAttrib.setEnabled(gameObject != null); - - gameObjectTextEditor.refreshDisplay(gameObject); - refreshArchTab(gameObject); - refreshMsgTextTab(gameObject); - refreshScriptsTab(gameObject); - refreshAnimationTab(gameObject); - } - - /** - * Refresh the "Arch" tab in the Game Object Attributes Panel. - * - * @param gameObject The game object to set the contents from. - */ - private void refreshArchTab(final GameObject gameObject) - { - // tab color - panelDesktop.setForegroundAt(0, gameObject == null ? Color.black : Color.blue); - - // archNameField - if (gameObject == null) { - archNameField.setForeground(Color.black); - archNameField.setText(""); - } else { - final String objName = gameObject.getObjName(); - if (objName != null) { - archNameField.setForeground(Color.blue); - archNameField.setText(objName); - } else { - archNameField.setForeground(Color.black); - final String archObjName = gameObject.getArchetype().getObjName(); - archNameField.setText(archObjName != null ? archObjName : gameObject.getArchetypeName()); - } - } - - // archFaceText - if (gameObject == null) { - archFaceText.setText("Image:"); - } else { - final StringBuilder faceText = new StringBuilder("Image: "); - final String faceName = gameObject.getFaceName(); - if (faceName != null) { - final GameObject.FaceSource desc = gameObject.getFaceObjSource(); - faceText.append(faceName).append(" ("); - switch (desc) { - case FACE_NOT_FOUND: - faceText.append("face not found"); - break; - - case FACE: - faceText.append("face"); - break; - - case ARCHETYPE_FACE: - faceText.append("archetype face"); - break; - - case ANIM: - faceText.append("anim"); - break; - - case ARCHETYPE_ANIM: - faceText.append("archetype anim"); - break; - } - faceText.append(')'); - } else { - faceText.append(">no face<"); - } - archFaceText.setText(faceText.toString()); - } - - // archTypeText - if (gameObject == null) { - archTypeText.setText("Type:"); - } else { - final StringBuilder typeText = new StringBuilder("Type: "); - final CFArchType archType = mainControl.getTypeList().getType(gameObject); - typeText.append(archType.getTypeName()); - typeText.append(" (").append(archType.getTypeNr()).append(')'); - typeText.append(" [").append(gameObject.getArchetypeName()).append(']'); - if (gameObject.isMulti()) { - typeText.append(" [").append(gameObject.getSizeX()).append('x').append(gameObject.getSizeY()).append(']'); - } else { - typeText.append(" [single]"); - } - archTypeText.setText(typeText.toString()); - } - - // archMapPos - if (gameObject == null) { - archMapPos.setText("Status: "); - } else { - final StringBuilder specialText = new StringBuilder("Status:"); - if (!gameObject.isInContainer()) { - specialText.append(" (map: ").append(gameObject.getMapX()).append(", ").append(gameObject.getMapY()).append(')'); - } - if (gameObject.isScripted()) { - specialText.append(" (script)"); - } - if (gameObject.getMsgText() != null || gameObject.getArchetype().getMsgText() != null) { - specialText.append(" (msg)"); - } - final int invObjects = gameObject.countInvObjects(); - if (invObjects > 0) { - specialText.append(" (inv: ").append(invObjects).append(')'); - } - if (gameObject.isInContainer()) { - final GameObject cont = (GameObject) gameObject.getContainer(); - specialText.append(" (env: ").append(cont.getArchetypeName()).append(')'); - } - archMapPos.setText(specialText.toString()); - } - - // directions - for (final JToggleButton button : directionButtons) { - button.setBackground(null); - } - final boolean enableDirButtons = gameObject != null && gameObject.usesDirection(); - for (final JToggleButton button : directionButtons) { - button.setEnabled(enableDirButtons); - } - final int direction = enableDirButtons ? gameObject.getDirection() : 0; - directionButtons[direction < directionButtons.length ? direction : 0].setSelected(true); - } - - // calculate default value in case there is no settings file - private static int getMapArchPanelLocation() { - final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - return (int) (0.49 * screen.getWidth()); - } - - private JPanel createConnectionPanel() { - final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - return connectionControl.getView(); - } - - private JPanel createMonsterPanel() { - final MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> monsterControl = new MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - return monsterControl.getView(); - } - } // class GameObjectAttributesPanel Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-02-23 13:25:30 UTC (rev 3609) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-02-23 13:30:32 UTC (rev 3610) @@ -22,23 +22,37 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Toolkit; +import java.util.prefs.Preferences; import javax.swing.Action; +import javax.swing.ButtonGroup; import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JToggleButton; import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.border.EtchedBorder; +import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.connectionview.ConnectionControl; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.connectionview.MonsterControl; +import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; @@ -116,7 +130,49 @@ protected JList eventList; + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + + private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; + + private final MainView<G, A, R, C, V> mainView; + + /** The buttons for the direction panel. + * @see #directionButtonGroup + */ + private final JToggleButton[] directionButtons = new JToggleButton[9]; + /** + * The ButtonGroup for the direction buttons. + * @see #directionButtons + */ + private final ButtonGroup directionButtonGroup = new ButtonGroup(); + + private final GSplitPane splitPane; + + /** The {@link ErrorListView} holding the error information. */ + private final ErrorListView<G, A, R, C, V> errorListView; + + /** Arch name field. */ + private final JTextField archNameField = new JTextField(14); + + private final JLabel archMapPos = new JLabel(); + + private final JLabel archFaceText = new JLabel(); + + private final JLabel archTypeText = new JLabel(); + + private final JPanel mapArchPanel = new JPanel(); + + private final Action aMapArchApply = ACTION_FACTORY.createAction(false, "mapArchApply", this); + + private final Action aMapArchAddInv = ACTION_FACTORY.createAction(false, "mapArchAddInv", this); + + private final Action aMapArchAttrib = ACTION_FACTORY.createAction(false, "mapArchAttrib", this); + + private final GameObjectTextEditor gameObjectTextEditor; + + /** * The main control listener which is attached to {@link #mainControl}. */ private final MainControlListener<G, A, R, C, V> mainControlListener = new MainControlListener<G, A, R, C, V>() { @@ -206,9 +262,36 @@ * Create the GameObjectAttributesPanel. * @param mainControl MainControl to use, e.g. for accessing AnimationObjects. */ - protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, C, V> mainControl) { + protected GameObjectAttributesPanel(@NotNull final MainControl<G, A, R, C, V> mainControl, final MainView<G, A, R, C, V> mainView, final LockedItemsControl<G, A, R, C, V> lockedItemsControl) { super(new BorderLayout()); this.mainControl = mainControl; + this.errorListView = new ErrorListView<G, A, R, C, V>(mainControl); + this.mainView = mainView; + + gameObjectTextEditor = new GameObjectTextEditor(); + + mapArchPanel.setLayout(new BorderLayout()); + splitPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, gameObjectTextEditor); + splitPane.setContinuousLayout(true); + splitPane.setResizeWeight(1); + splitPane.setDividerLocation(prefs.getInt(MAPARCHPANEL_LOCATION_KEY, getMapArchPanelLocation())); + add(splitPane, BorderLayout.CENTER); + + final JPanel buttonPanel = createButtonPanel(); + buttonPanel.setLayout(new GridLayout(0, 1)); + mapArchPanel.add(buttonPanel, BorderLayout.WEST); + mapArchPanel.add(panelDesktop, BorderLayout.CENTER); + + panelDesktop.add(createArchPanel(), "Arch"); + panelDesktop.add(createTextPanel(), "Msg Text"); + panelDesktop.add(scriptPanel, "Scripts"); + panelDesktop.add(animationPanel, "Animation"); + panelDesktop.add(createConnectionPanel(), "Connection"); + panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); + panelDesktop.add(createMonsterPanel(), "Monster"); + panelDesktop.add(errorListView, "Warnings"); + + refreshDisplay(); currentMap = mainControl.getMapManager().getCurrentMap(); if (currentMap != null) { currentMap.getMapModel().addMapModelListener(mapModelListener); @@ -264,14 +347,28 @@ /** * Update the displayed information for {@link #selectedGameObject}. */ - protected abstract void refreshDisplay(); + private void refreshDisplay() { + final G selectedGameObject = getSelectedGameObject(); + final G gameObject = selectedGameObject == null ? null : selectedGameObject.getHead(); + aMapArchApply.setEnabled(gameObject != null); + aMapArchAddInv.setEnabled(gameObject != null); + aMapArchAttrib.setEnabled(gameObject != null); + + gameObjectTextEditor.refreshDisplay(gameObject); + refreshArchTab(gameObject); + refreshMsgTextTab(gameObject); + refreshScriptsTab(gameObject); + refreshAnimationTab(gameObject); + } + + /** * Refresh the "Animation" tab in the Game Object Attributes Panel. * * @param gameObject The game object to set the contents from. */ - protected void refreshAnimationTab(final GameObject gameObject) { + protected void refreshAnimationTab(final G gameObject) { if (gameObject == null) { panelDesktop.setForegroundAt(3, Color.black); setAnimationName(null); @@ -357,7 +454,7 @@ * * @param gameObject The game object to set the contents from. */ - protected void refreshMsgTextTab(final GameObject gameObject) { + protected void refreshMsgTextTab(final G gameObject) { final boolean hasMessage; if (gameObject == null) { archTextArea.setForeground(Color.black); @@ -425,7 +522,7 @@ * * @param gameObject The game object to set the contents from. */ - protected void refreshScriptsTab(final GameObject gameObject) + protected void refreshScriptsTab(final G gameObject) { if (gameObject == null || !gameObject.isScripted()) { panelDesktop.setForegroundAt(2, Color.black); @@ -527,6 +624,411 @@ * * @param mapModel the map model of which the errors have changed */ - protected abstract void setErrors(@NotNull final MapModel<G, A, R> mapModel); + private void setErrors(@NotNull final MapModel<G, A, R> mapModel) { + panelDesktop.setForegroundAt(7, mapModel.getErrors().getErrors().iterator().hasNext() ? Color.blue : Color.black); + errorListView.setErrors(mapModel, mapModel.getErrors()); + } + /** + * Action method for applying the changes made in the arch panel. + */ + @ActionMethod public void mapArchApply() { + applyArchPanelChanges(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); + } + + /** + * Action method for displaying the attributes of the currently selected object. + */ + @ActionMethod public void mapArchAttrib() { + mainControl.openAttrDialog(mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection()); + } + + /** + * Action method for adding an object to the inventory of the currently selected object. + */ + @ActionMethod public void mapArchAddInv() { + final G arch = mainControl.getMainView().getObjectChooser().getObjectChooserHighlight(); + if (arch == null) { // nothing selected? + return; + } + + G inv = mainView.getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); + if (inv == null) { + return; + } + + // if this is a multi-tail, we put the new arch into the head's inv. + inv = inv.getHead(); + + final G invnew; + if (arch.isArchetype()) { + // create a new copy of a default arch + invnew = arch.createArch(); + } else { + // create clone from a pickmap + invnew = arch.createClone(0, 0); + } + + invnew.setDirection(invnew.getArchetype().getDirection()); + mainControl.getArchetypeParser().postParseGameObject(invnew, 0); + final MapSquare<G, A, R> mapSquare = inv.getMapSquare(); + assert mapSquare != null; + final MapModel mapModel = mapSquare.getModel(); + mapModel.beginTransaction("Add to inventory"); + inv.addLast(invnew); + invnew.setObjectFace(); + mapModel.endTransaction(); + } + + /** + * When the "apply"-button on the ArchPanel (at the bottom of the window) + * is pressed, this function updates the active arch object. + * @param activeArch the currently selected arch + */ + public void applyArchPanelChanges(final G activeArch) { + if (activeArch == null) { + return; + } + + // If the active gameObject is part of a multi, the mutli-head's stats + // are taken instead: + final G gameObject = activeArch.getHead(); + + final R archetype = gameObject.getArchetype(); + + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Change object attributes"); + + // We update all panels: name, face, msg and archText (more to come...) + // the obj name: + if (isNonwhitespaceText(archNameField.getText())) { // there is something in + // if this equal the default name... + if (archetype.getObjName() != null) { + if (archNameField.getText().compareTo(archetype.getObjName()) == 0) { + gameObject.setObjName(null); // yes, we don't need it in map + } else { + gameObject.setObjName(archNameField.getText()); // overrule in map gameObject + } + } else if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { + gameObject.setObjName(null); + } else { // def is null, something is in panel, so we set it + gameObject.setObjName(archNameField.getText()); // overrule in map gameObject + } + } else { + gameObject.setObjName(null); // nothing in, nothing in map gameObject + // hm, there is no way yet to overrule a default gameObject name with "nothing" + // like <name > ore <name "">..?? + } + + applyArchTextArea(gameObject); + + gameObjectTextEditor.applyChanges(gameObject); + + /* check we have a face and set the real face obj for fast access */ + final String face = gameObject.getAttributeString("face", false); + // we have a new face name + gameObject.setRealFace(face); + if (gameObject.getAttributeString("animation", false).length() > 0) { + gameObject.setAnimName(gameObject.getAttributeString("animation", false)); + } else { + gameObject.setAnimName(archetype.getAnimName()); + } + + if (gameObject.getAttributeString("direction", false).length() > 0) { + final int dir = gameObject.getAttributeInt("direction", false); + if (archetype.getDirection() != dir) { + gameObject.setDirection(dir); + } + } else { + gameObject.setDirection(archetype.getDirection()); + } + gameObject.setObjectFace(); + + // we look for 'type' in the ArchText. In future maybe type should get + // a seperate textfield + if (gameObject.getAttributeString("type", false).length() > 0) { + gameObject.setArchTypNr(gameObject.getAttributeInt("type", false)); // specified type + } + + // Recalculate the editType value. It shall stay 100% accurate ;) + gameObject.calculateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); + + mapSquare.getModel().endTransaction(); + } + + /** Create the arch panel entry of the lower window. */ + private JPanel createArchPanel() { + final JPanel panel = new JPanel(); + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints gbc = new GridBagConstraints(); + + panel.setLayout(gridbag); + gbc.fill = GridBagConstraints.BOTH; + gbc.weightx = 1.0; + gbc.weighty = 0; + gbc.anchor = GridBagConstraints.NORTHWEST; + gbc.insets = new Insets(4, 4, 0, 0); + + archNameField.setText(""); + archNameField.setForeground(Color.blue); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archNameField, gbc); + panel.add(archNameField); + + archFaceText.setText(""); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archFaceText, gbc); + panel.add(archFaceText); + + archTypeText.setText(""); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archTypeText, gbc); + panel.add(archTypeText); + + archMapPos.setText(""); + gbc.gridx = 0; + gbc.gridy = 3; + gbc.gridwidth = 1; + gbc.gridheight = 1; + gridbag.setConstraints(archMapPos, gbc); + panel.add(archMapPos); + + gbc.gridx = 1; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.gridheight = 5; + gbc.weightx = 0.0; + panel.add(createDirPanel(), gbc); + + return panel; + } + + private JPanel createDirPanel() { + final JPanel dirPanel = new JPanel(new GridBagLayout()); + final GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.CENTER; + gbc.insets = new Insets(2, 2, 2, 2); + + createButton(7, dirPanel, gbc, 0, 0); + createButton(8, dirPanel, gbc, 1, 0); + createButton(1, dirPanel, gbc, 2, 0); + createButton(6, dirPanel, gbc, 0, 1); + createButton(0, dirPanel, gbc, 1, 1); + createButton(2, ... [truncated message content] |
From: <aki...@us...> - 2008-02-23 13:39:06
|
Revision: 3611 http://gridarta.svn.sourceforge.net/gridarta/?rev=3611&view=rev Author: akirschbaum Date: 2008-02-23 05:39:09 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:30:32 UTC (rev 3610) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:39:09 UTC (rev 3611) @@ -24,28 +24,9 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridLayout; -import java.util.prefs.Preferences; -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.ErrorListView; -import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.connectionview.MonsterControl; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.validation.ErrorCollector; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; /** Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:30:32 UTC (rev 3610) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:39:09 UTC (rev 3611) @@ -24,37 +24,9 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import daieditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.Toolkit; -import java.util.prefs.Preferences; -import javax.swing.Action; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JTextField; -import javax.swing.JToggleButton; -import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.ErrorListView; -import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.connectionview.MonsterControl; -import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.validation.ErrorCollector; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-02-23 13:30:32 UTC (rev 3610) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-02-23 13:39:09 UTC (rev 3611) @@ -36,7 +36,6 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-02-23 13:30:32 UTC (rev 3610) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-02-23 13:39:09 UTC (rev 3611) @@ -35,7 +35,6 @@ import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.validation.ErrorCollector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 14:16:18
|
Revision: 3618 http://gridarta.svn.sourceforge.net/gridarta/?rev=3618&view=rev Author: akirschbaum Date: 2008-02-23 06:16:22 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Remove AbstractMapModel.getArchetype(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 14:12:16 UTC (rev 3617) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 14:16:22 UTC (rev 3618) @@ -72,7 +72,7 @@ return null; } - Archetype archetype = getArchetype(archName); + Archetype archetype = mainControl.getArchetypeSet().getArchetype(archName); if (archetype == null) { return null; } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 14:12:16 UTC (rev 3617) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 14:16:22 UTC (rev 3618) @@ -77,7 +77,7 @@ return null; } - Archetype archetype = getArchetype(archName); + Archetype archetype = mainControl.getArchetypeSet().getArchetype(archName); if (archetype == null) { return null; } Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 14:12:16 UTC (rev 3617) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 14:16:22 UTC (rev 3618) @@ -526,18 +526,6 @@ return null; } - /** - * Get an Archetype. - * - * @param archName the archetype name - * - * @return the Archetype corresponding to - * <code>archName</code>, or <code>null</code> if it does not exist - */ - @Nullable protected R getArchetype(final String archName) { - return mainControl.getArchetypeSet().getArchetype(archName); - } - /** {@inheritDoc} */ public void deleteMapArch(@NotNull final G gameObject, @NotNull final Point pos, final boolean join) { assert gameObject.getMapSquare() == getMapSquare(pos); @@ -548,7 +536,7 @@ gameObject.remove(); // do autojoining - final R temp = getArchetype(gameObject.getArchetypeName()); + final R temp = mainControl.getArchetypeSet().getArchetype(gameObject.getArchetypeName()); if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(temp) != null && !temp.isMulti()) { // remove connections to the deleted arch mainControl.getAutojoinLists().getAutojoinList(temp).joinDelete(this, pos); @@ -558,7 +546,7 @@ /** {@inheritDoc} */ public boolean isMultiArchFittingToMap(final String archName, final Point pos, final boolean allowDouble) { - for (R part = getArchetype(archName); part != null; part = (R) part.getMultiNext()) { + for (R part = mainControl.getArchetypeSet().getArchetype(archName); part != null; part = (R) part.getMultiNext()) { final Point point = new Point(part.getMultiX(), part.getMultiY()); point.translate(pos.x, pos.y); // outside map This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 14:21:54
|
Revision: 3619 http://gridarta.svn.sourceforge.net/gridarta/?rev=3619&view=rev Author: akirschbaum Date: 2008-02-23 06:21:27 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Remove reference to MapModel.mainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 14:16:22 UTC (rev 3618) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 14:21:27 UTC (rev 3619) @@ -68,15 +68,16 @@ if (archName == null || archName.length() == 0 || !isPointValid(pos)) { return null; } - if (!isMultiArchFittingToMap(archName, pos, allowDouble)) { - return null; - } Archetype archetype = mainControl.getArchetypeSet().getArchetype(archName); if (archetype == null) { return null; } + if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { + return null; + } + if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 14:16:22 UTC (rev 3618) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 14:21:27 UTC (rev 3619) @@ -73,15 +73,16 @@ if (archName == null || archName.length() == 0 || !isPointValid(pos)) { return null; } - if (!isMultiArchFittingToMap(archName, pos, allowDouble)) { - return null; - } Archetype archetype = mainControl.getArchetypeSet().getArchetype(archName); if (archetype == null) { return null; } + if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { + return null; + } + if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 14:16:22 UTC (rev 3618) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 14:21:27 UTC (rev 3619) @@ -545,8 +545,8 @@ } /** {@inheritDoc} */ - public boolean isMultiArchFittingToMap(final String archName, final Point pos, final boolean allowDouble) { - for (R part = mainControl.getArchetypeSet().getArchetype(archName); part != null; part = (R) part.getMultiNext()) { + public boolean isMultiArchFittingToMap(final R archetype, final Point pos, final boolean allowDouble) { + for (R part = archetype; part != null; part = (R) part.getMultiNext()) { final Point point = new Point(part.getMultiX(), part.getMultiY()); point.translate(pos.x, pos.y); // outside map Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-02-23 14:16:22 UTC (rev 3618) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-02-23 14:21:27 UTC (rev 3619) @@ -327,7 +327,7 @@ /** * Checks whether an GameObject (multi-arch) would still fit on this map. - * @param archName name of arch to check + * @param archetype the archetype to check * @param pos position of multitile head * @param allowDouble whether overlapping multitile arches should be allowed (check is done using the arch name) * @return whether the multi-arch would still fit on this map @@ -335,7 +335,7 @@ * @retval <code>false</code> otherwise * @todo discuss whether this method really belongs to the interface of MapModel as it is only used by MapModel implementations and heavily depends on how arches, especially multi-tile arches are implemented. */ - boolean isMultiArchFittingToMap(String archName, Point pos, boolean allowDouble); + boolean isMultiArchFittingToMap(R archetype, Point pos, boolean allowDouble); /** * Insert a new arch to the map at a specified position. This function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 19:56:36
|
Revision: 3620 http://gridarta.svn.sourceforge.net/gridarta/?rev=3620&view=rev Author: akirschbaum Date: 2008-02-23 11:55:14 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Delay check 'does archetype fit into map?' after autojoining. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 14:21:27 UTC (rev 3619) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 19:55:14 UTC (rev 3620) @@ -74,10 +74,6 @@ return null; } - if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { - return null; - } - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); @@ -86,6 +82,10 @@ } } + if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { + return null; + } + GameObject head = null; for (Archetype archetypePart = archetype; archetypePart != null; archetypePart = archetypePart.getMultiNext()) { final GameObject part = archetypePart.createArch(); Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 14:21:27 UTC (rev 3619) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 19:55:14 UTC (rev 3620) @@ -79,10 +79,6 @@ return null; } - if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { - return null; - } - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); @@ -91,6 +87,10 @@ } } + if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { + return null; + } + // FIXME: Check maximum RefX and RefY to check whether the multitile arch fits on the map. if (pos.x + archetype.getMinX() < 0 || pos.y + archetype.getMinY() < 0 || pos.x + archetype.getMaxX() > mapSize.getWidth() || pos.y + archetype.getMaxY() > mapSize.getHeight()) { // does not fit on map This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 20:25:11
|
Revision: 3622 http://gridarta.svn.sourceforge.net/gridarta/?rev=3622&view=rev Author: akirschbaum Date: 2008-02-23 12:25:10 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move MapModel.insertArchToMap() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:04:30 UTC (rev 3621) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:25:10 UTC (rev 3622) @@ -122,68 +122,6 @@ return head; } - /** - * {@inheritDoc} - * @xxx I'm too complex - */ - @Nullable public GameObject insertArchToMap(final GameObject newObject, final GameObject next, final Point pos, final boolean join) { - // map coords must be valid - if (!isPointValid(pos)) { - return null; - } - - final GameObject newGameObject; - if (next == null || !next.isInContainer()) { - - // put arch on the map - if (newObject.isArchetype()) { - newGameObject = addArchToMap(newObject.getArchetypeName(), pos, true, join, false); - if (newGameObject == null) { - return null; - } - } else { - // insert the given 'newObject' (multis not allowed here yet - sorry) - if (!newObject.isMulti()) { - newGameObject = newObject.createClone(pos.x, pos.y); - addGameObjectToMap(newGameObject, false); - } else { - return null; // tried to insert multi (probably from pickmap) - } - } - - int position = 0; - for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { - // This is okay because next is on the desired square. - //noinspection ObjectEquality - if (search == next) { - break; - } - position++; - } - for(int i = 0; i < position - 1; i++) { - newGameObject.moveDown(); - } - } else { - // insert the new arch into the inventory of a map arch - if (newObject.isArchetype()) { - newGameObject = newObject.createArch(); - } else { - // create clone from a pickmap - if (!newObject.isMulti()) { - newGameObject = newObject.createClone(pos.x, pos.y); - } else { - return null; - } - } - - next.getContainer().addLast(newGameObject); - newGameObject.setObjectFace(); - mainControl.getArchetypeParser().postParseGameObject(newGameObject, getMapControl().getActiveEditType()); - } - - return newGameObject; - } - /** {@inheritDoc} */ public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { // Make sure this arch has the proper edit_type Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 20:04:30 UTC (rev 3621) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 20:25:10 UTC (rev 3622) @@ -122,68 +122,6 @@ return head; } - /** - * {@inheritDoc} - * @xxx I'm too complex - */ - @Nullable public GameObject insertArchToMap(final GameObject newObject, final GameObject next, final Point pos, final boolean join) { - // map coords must be valid - if (!isPointValid(pos)) { - return null; - } - - final GameObject newGameObject; - if (next == null || !next.isInContainer()) { - - // put arch on the map - if (newObject.isArchetype()) { - newGameObject = addArchToMap(newObject.getArchetypeName(), pos, true, join, false); - if (newGameObject == null) { - return null; - } - } else { - // insert the given 'newObject' (multis not allowed here yet - sorry) - if (!newObject.isMulti()) { - newGameObject = newObject.createClone(pos.x, pos.y); - addGameObjectToMap(newGameObject, false); - } else { - return null; // tried to insert multi (probably from pickmap) - } - } - - int position = 0; - for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { - // This is okay because next is on the desired square. - //noinspection ObjectEquality - if (search == next) { - break; - } - position++; - } - for(int i = 0; i < position - 1; i++) { - newGameObject.moveDown(); - } - } else { - // insert the new arch into the inventory of a map arch - if (newObject.isArchetype()) { - newGameObject = newObject.createArch(); - } else { - // create clone from a pickmap - if (!newObject.isMulti()) { - newGameObject = newObject.createClone(pos.x, pos.y); - } else { - return null; - } - } - - next.getContainer().addLast(newGameObject); - newGameObject.setObjectFace(); - mainControl.getArchetypeParser().postParseGameObject(newGameObject, getMapControl().getActiveEditType()); - } - - return newGameObject; - } - /** {@inheritDoc} */ public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { // Make sure this arch has the proper edit_type Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 20:04:30 UTC (rev 3621) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 20:25:10 UTC (rev 3622) @@ -580,6 +580,68 @@ return errors; } + /** + * {@inheritDoc} + * @xxx I'm too complex + */ + @Nullable public G insertArchToMap(final G newObject, final G next, final Point pos, final boolean join) { + // map coords must be valid + if (!isPointValid(pos)) { + return null; + } + + final G newGameObject; + if (next == null || !next.isInContainer()) { + + // put arch on the map + if (newObject.isArchetype()) { + newGameObject = addArchToMap(newObject.getArchetypeName(), pos, true, join, false); + if (newGameObject == null) { + return null; + } + } else { + // insert the given 'newObject' (multis not allowed here yet - sorry) + if (!newObject.isMulti()) { + newGameObject = newObject.createClone(pos.x, pos.y); + addGameObjectToMap(newGameObject, false); + } else { + return null; // tried to insert multi (probably from pickmap) + } + } + + int position = 0; + for (final G search : mapGrid[pos.x][pos.y].reverse()) { + // This is okay because next is on the desired square. + //noinspection ObjectEquality + if (search == next) { + break; + } + position++; + } + for(int i = 0; i < position - 1; i++) { + newGameObject.moveDown(); + } + } else { + // insert the new arch into the inventory of a map arch + if (newObject.isArchetype()) { + newGameObject = newObject.createArch(); + } else { + // create clone from a pickmap + if (!newObject.isMulti()) { + newGameObject = newObject.createClone(pos.x, pos.y); + } else { + return null; + } + } + + next.getContainer().addLast(newGameObject); + newGameObject.setObjectFace(); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, getMapControl().getActiveEditType()); + } + + return newGameObject; + } + /** Iterator for iterating over all squares of a model. */ private class MapSquareIterator implements Iterator<MapSquare<G, A, R>> { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 20:31:13
|
Revision: 3624 http://gridarta.svn.sourceforge.net/gridarta/?rev=3624&view=rev Author: akirschbaum Date: 2008-02-23 12:31:19 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move MapModel.addArchToMap() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:27:52 UTC (rev 3623) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:31:19 UTC (rev 3624) @@ -64,65 +64,6 @@ } /** {@inheritDoc} */ - @Nullable public GameObject addArchToMap(final String archName, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { - if (archName == null || archName.length() == 0 || !isPointValid(pos)) { - return null; - } - - Archetype archetype = mainControl.getArchetypeSet().getArchetype(archName); - if (archetype == null) { - return null; - } - - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { - // do autojoining if enabled - archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); - if (archetype == null) { - return null; // only one autojoin type per square allowed - } - } - - if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { - return null; - } - - GameObject head = null; - for (Archetype archetypePart = archetype; archetypePart != null; archetypePart = archetypePart.getMultiNext()) { - final GameObject part = archetypePart.createArch(); - if (archetypePart == archetype) { - head = part; - } else { - head.addTailPart(part); - } - - final int mapx = pos.x + part.getMultiX(); - final int mapy = pos.y + part.getMultiY(); - - part.setMapX(mapx); - part.setMapY(mapy); - if (insertBelow) { - mapGrid[mapx][mapy].addFirst(part); - } else { - mapGrid[mapx][mapy].addLast(part); - } - - final Integer direction = mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); - if (direction != null) { - part.setDirection(direction); - part.setAttributeString("direction", Integer.toString(direction)); - } - mainControl.getArchetypeParser().postParseGameObject(part, getMapControl().getActiveEditType()); - part.setObjectFace(); - } - - for (final GameObject invObject : archetype) { - head.addLast(invObject.createClone(0, 0)); - } - - return head; - } - - /** {@inheritDoc} */ public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { // Make sure this arch has the proper edit_type if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 20:27:52 UTC (rev 3623) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 20:31:19 UTC (rev 3624) @@ -68,65 +68,6 @@ } /** {@inheritDoc} */ - @Nullable public GameObject addArchToMap(final String archName, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { - if (archName == null || archName.length() == 0 || !isPointValid(pos)) { - return null; - } - - Archetype archetype = mainControl.getArchetypeSet().getArchetype(archName); - if (archetype == null) { - return null; - } - - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { - // do autojoining if enabled - archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); - if (archetype == null) { - return null; // only one autojoin type per square allowed - } - } - - if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { - return null; - } - - GameObject head = null; - for (Archetype archetypePart = archetype; archetypePart != null; archetypePart = archetypePart.getMultiNext()) { - final GameObject part = archetypePart.createArch(); - if (archetypePart == archetype) { - head = part; - } else { - head.addTailPart(part); - } - - final int mapx = pos.x + part.getMultiX(); - final int mapy = pos.y + part.getMultiY(); - - part.setMapX(mapx); - part.setMapY(mapy); - if (insertBelow) { - mapGrid[mapx][mapy].addFirst(part); - } else { - mapGrid[mapx][mapy].addLast(part); - } - - final Integer direction = mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); - if (direction != null) { - part.setDirection(direction); - part.setAttributeString("direction", Integer.toString(direction)); - } - mainControl.getArchetypeParser().postParseGameObject(part, getMapControl().getActiveEditType()); - part.setObjectFace(); - } - - for (final GameObject invObject : archetype) { - head.addLast(invObject.createClone(0, 0)); - } - - return head; - } - - /** {@inheritDoc} */ public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { // Make sure this arch has the proper edit_type if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 20:27:52 UTC (rev 3623) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 20:31:19 UTC (rev 3624) @@ -642,6 +642,65 @@ return newGameObject; } + /** {@inheritDoc} */ + @Nullable public G addArchToMap(final String archName, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { + if (archName == null || archName.length() == 0 || !isPointValid(pos)) { + return null; + } + + R archetype = mainControl.getArchetypeSet().getArchetype(archName); + if (archetype == null) { + return null; + } + + if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { + // do autojoining if enabled + archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); + if (archetype == null) { + return null; // only one autojoin type per square allowed + } + } + + if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { + return null; + } + + G head = null; + for (R archetypePart = archetype; archetypePart != null; archetypePart = (R) archetypePart.getMultiNext()) { + final G part = archetypePart.createArch(); + if (archetypePart == archetype) { + head = part; + } else { + head.addTailPart(part); + } + + final int mapx = pos.x + part.getMultiX(); + final int mapy = pos.y + part.getMultiY(); + + part.setMapX(mapx); + part.setMapY(mapy); + if (insertBelow) { + mapGrid[mapx][mapy].addFirst(part); + } else { + mapGrid[mapx][mapy].addLast(part); + } + + final Integer direction = mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); + if (direction != null) { + part.setDirection(direction); + part.setAttributeString("direction", Integer.toString(direction)); + } + mainControl.getArchetypeParser().postParseGameObject(part, getMapControl().getActiveEditType()); + part.setObjectFace(); + } + + for (final G invObject : archetype) { + head.addLast(invObject.createClone(0, 0)); + } + + return head; + } + /** Iterator for iterating over all squares of a model. */ private class MapSquareIterator implements Iterator<MapSquare<G, A, R>> { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 21:07:53
|
Revision: 3627 http://gridarta.svn.sourceforge.net/gridarta/?rev=3627&view=rev Author: akirschbaum Date: 2008-02-23 13:07:40 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move MapModel.addGameObjectToMap() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:07:40 UTC (rev 3627) @@ -22,12 +22,9 @@ import cfeditor.CMainControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; -import java.awt.Point; import java.util.List; -import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapModel; -import org.jetbrains.annotations.Nullable; /** * The level model that represents a level. @@ -48,9 +45,6 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** * Constructs a level model. * @param mainControl main controller @@ -66,37 +60,4 @@ endTransaction(); } - /** {@inheritDoc} */ - public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { - // Make sure this arch has the proper edit_type - if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { - gameObject.calculateEditType(getMapControl().getActiveEditType()); - } - - gameObject.setObjectFace(); - - final int mapx = gameObject.getMapX(); - final int mapy = gameObject.getMapY(); - if (!isPointValid(new Point(mapx, mapy))) { - // TODO: - // Think about how this could be handled via an exception and caught much earlier, perhaps already while reading the map, not after it - // already has been read. - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "mapErrorArchOutOfGrid"); - return; - } - - if (insertBelow) { - mapGrid[mapx][mapy].addFirst(gameObject); - } else { - mapGrid[mapx][mapy].addLast(gameObject); - } - - // calculate edit type - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (getMapControl().getActiveEditType() != 0) { - gameObject.setEditType(gameObject.calculateEditType(getMapControl().getActiveEditType())); // calculate new - } - } - } // class DefaultMapModel Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -66,8 +66,6 @@ mapLoreTabTitle=Lore mapErrorInvalidDarkness.title=Invalid value mapErrorInvalidDarkness.message=Darkness level must be in range 0-5. -mapErrorArchOutOfGrid.title=Arch out of map -mapErrorArchOutOfGrid.message=Removing arch out of map bounds mapRegion=Region mapUnique=Unique map Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -63,8 +63,6 @@ mapLoreTabTitle=Geschichte mapErrorInvalidDarkness.title=Ung\xFCltiger Wert mapErrorInvalidDarkness.message=Die Dunkelheit muss zwischen 0 und 5 liegen. -mapErrorArchOutOfGrid.title=Archetyp au\xDFerhalb Karte -mapErrorArchOutOfGrid.message=Entferne Archetypen au\xDFerhalb der Karte mapRegion=Region mapUnique=Permanente Karte Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -64,8 +64,6 @@ #mapLoreTabTitle= #mapErrorInvalidDarkness.title= #mapErrorInvalidDarkness.message= -#mapErrorArchOutOfGrid.title= -#mapErrorArchOutOfGrid.message= #mapRegion= #mapUnique= Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -62,8 +62,6 @@ #mapLoreTabTitle= #mapErrorInvalidDarkness.title= #mapErrorInvalidDarkness.message= -mapErrorArchOutOfGrid.title=Objekt utanf\xF6r kartan -mapErrorArchOutOfGrid.message=Avl\xE4gsnar objekt utanf\xF6r kartan #mapRegion= #mapUnique= Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:07:40 UTC (rev 3627) @@ -22,13 +22,9 @@ import daieditor.CMainControl; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; -import java.awt.Point; import java.util.List; -import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapModel; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.Nullable; /** * The level model that represents a level. @@ -49,9 +45,6 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** * Constructs a level model. * @param mainControl main controller @@ -67,37 +60,4 @@ endTransaction(); } - /** {@inheritDoc} */ - public void addGameObjectToMap(final GameObject gameObject, final boolean insertBelow) { - // Make sure this arch has the proper edit_type - if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { - gameObject.calculateEditType(getMapControl().getActiveEditType()); - } - - gameObject.setObjectFace(); - - final int mapx = gameObject.getMapX(); - final int mapy = gameObject.getMapY(); - if (!isPointValid(new Point(mapx, mapy))) { - // TODO: - // Think about how this could be handled via an exception and caught much earlier, perhaps already while reading the map, not after it - // already has been read. - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "mapErrorArchOutOfGrid"); - return; - } - - if (insertBelow) { - mapGrid[mapx][mapy].addFirst(gameObject); - } else { - mapGrid[mapx][mapy].addLast(gameObject); - } - - // calculate edit type - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (getMapControl().getActiveEditType() != 0) { - gameObject.setEditType(gameObject.calculateEditType(getMapControl().getActiveEditType())); // calculate new - } - } - } // class DefaultMapModel Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/daimonin/src/daieditor/messages.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -156,8 +156,6 @@ mapInstantDeath=Instant Death mapPvP=PvP Enabled mapText=Map Text -mapErrorArchOutOfGrid.title=Arch out of map -mapErrorArchOutOfGrid.message=Removing arch out of map bounds mapTilesNoMapFileNoMapTilePane.title=Map tiles card unavailable mapTilesNoMapFileNoMapTilePane.message=The map has no file name (it wasn''t saved yet).\nA map without filename cannot be attached to other maps.\nTherefore, the Map tiles card is unavailable. Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -153,8 +153,6 @@ mapInstantDeath=Sofort-Tod mapPvP=Spieler gegen Spieler aktiv mapText=Kartentext -mapErrorArchOutOfGrid.title=Archetyp au\xDFerhalb Karte -mapErrorArchOutOfGrid.message=Entferne Archetypen au\xDFerhalb der Karte mapTilesNoMapFileNoMapTilePane.title=Verbindungspfade nicht verf\xFCgbar mapTilesNoMapFileNoMapTilePane.message=Die Karte wurde noch nicht gespeichert. Daher hat sie noch keinen Dateinamen.\nEine Karte ohne Dateiname kann nicht mit anderen Karten verbunden werden.\nDaher ist der Reiter "Verbindungspfade" zur Zeit nicht verf\xFCgbar. Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -153,8 +153,6 @@ #mapInstantDeath= #mapPvP= #mapText= -#mapErrorArchOutOfGrid.title= -#mapErrorArchOutOfGrid.message= #mapTilesNoMapFileNoMapTilePane.title= #mapTilesNoMapFileNoMapTilePane.message= Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -156,8 +156,6 @@ mapInstantDeath=Omedelbar d\xF6d mapPvP=Spelare mot Spelare mapText=Karttext -mapErrorArchOutOfGrid.title=Objekt utanf\xF6r kartan -mapErrorArchOutOfGrid.message=Avl\xE4gsnar objekt utanf\xF6r kartan mapTilesNoMapFileNoMapTilePane.title=N\xE4rliggande kartor ej tillg\xE4ngligt mapTilesNoMapFileNoMapTilePane.message=Kartan har inget filnamn (den \xE4r inte sparad \xE4nnu).\nEn karta utan filnamn kan inte anslutas till andra kartor.\nD\xE4rf\xF6r kan du inte v\xE4lja n\xE4rliggande kartor utan att f\xF6rst spara kartan. Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:07:40 UTC (rev 3627) @@ -31,8 +31,10 @@ import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.map.validation.DefaultErrorCollector; import net.sf.gridarta.map.validation.ErrorCollector; +import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -49,6 +51,9 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(AbstractMapModel.class); + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + /** Sync Lock Object. */ private final transient Object syncLock = new Object(); @@ -701,6 +706,39 @@ return head; } + /** {@inheritDoc} */ + public void addGameObjectToMap(final G gameObject, final boolean insertBelow) { + // Make sure this arch has the proper edit_type + if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { + gameObject.calculateEditType(getMapControl().getActiveEditType()); + } + + gameObject.setObjectFace(); + + final int mapx = gameObject.getMapX(); + final int mapy = gameObject.getMapY(); + if (!isPointValid(new Point(mapx, mapy))) { + // TODO: + // Think about how this could be handled via an exception and caught much earlier, perhaps already while reading the map, not after it + // already has been read. + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "mapErrorArchOutOfGrid"); + return; + } + + if (insertBelow) { + mapGrid[mapx][mapy].addFirst(gameObject); + } else { + mapGrid[mapx][mapy].addLast(gameObject); + } + + // calculate edit type + if (gameObject.isTail()) { + gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head + } else if (getMapControl().getActiveEditType() != 0) { + gameObject.setEditType(gameObject.calculateEditType(getMapControl().getActiveEditType())); // calculate new + } + } + /** Iterator for iterating over all squares of a model. */ private class MapSquareIterator implements Iterator<MapSquare<G, A, R>> { Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -234,6 +234,8 @@ mapTileChoose.shortdescription=Choose path to tile map mapTileChoose.text= mapTilePathMode.shortdescription=Switch between relative and absolute path +mapErrorArchOutOfGrid.title=Arch out of map +mapErrorArchOutOfGrid.message=Removing arch out of map bounds # Other Strings mapWidth=Width Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -222,6 +222,8 @@ mapTileChoose.shortdescription=Pfad w\xE4hlen mapTileChoose.text= mapTilePathMode.shortdescription=Zwischen relativem und absoluten Pfad wechseln +mapErrorArchOutOfGrid.title=Archetyp au\xDFerhalb Karte +mapErrorArchOutOfGrid.message=Entferne Archetypen au\xDFerhalb der Karte # Other Strings mapWidth=Breite Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -221,6 +221,8 @@ #mapTileChoose.shortdescription= mapTileChoose.text= #mapTilePathMode.shortdescription= +#mapErrorArchOutOfGrid.title= +#mapErrorArchOutOfGrid.message= # Other Strings #mapWidth= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-02-23 20:38:26 UTC (rev 3626) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-02-23 21:07:40 UTC (rev 3627) @@ -219,6 +219,8 @@ mapTileChoose.shortdescription=V\xE4lj s\xF6kv\xE4g till n\xE4rliggande karta mapTileChoose.text= mapTilePathMode.shortdescription=V\xE4xla mellan relativ och absolut s\xF6kv\xE4g +mapErrorArchOutOfGrid.title=Objekt utanf\xF6r kartan +mapErrorArchOutOfGrid.message=Avl\xE4gsnar objekt utanf\xF6r kartan # Other Strings mapWidth=Bredd This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 21:12:39
|
Revision: 3628 http://gridarta.svn.sourceforge.net/gridarta/?rev=3628&view=rev Author: akirschbaum Date: 2008-02-23 13:12:33 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Reorder arguments. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:07:40 UTC (rev 3627) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:12:33 UTC (rev 3628) @@ -53,7 +53,7 @@ * @param mapArch the map header (<code>MapArchObject</code>) */ public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - super(mapControl, mapArch, mainControl); + super(mainControl, mapControl, mapArch); beginTransaction("Insert initial objects"); addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:07:40 UTC (rev 3627) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:12:33 UTC (rev 3628) @@ -53,7 +53,7 @@ * @param mapArch the map header (<code>MapArchObject</code>) */ public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - super(mapControl, mapArch, mainControl); + super(mainControl, mapControl, mapArch); beginTransaction("Insert initial objects"); addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:07:40 UTC (rev 3627) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:12:33 UTC (rev 3628) @@ -120,11 +120,11 @@ /** * Create an AbstractMapModel. + * @param mainControl main controller * @param mapControl MapControl to associate with this model. * @param mapArchObject The MapArchObject to associate with this model. - * @param mainControl main controller */ - protected AbstractMapModel(final MapControl<G, A, R> mapControl, final A mapArchObject, final MainControl<G, A, R, ?, ?> mainControl) { + protected AbstractMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final A mapArchObject) { this.mapControl = mapControl; this.mapArchObject = mapArchObject; this.mainControl = mainControl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 21:16:39
|
Revision: 3629 http://gridarta.svn.sourceforge.net/gridarta/?rev=3629&view=rev Author: akirschbaum Date: 2008-02-23 13:16:37 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:12:33 UTC (rev 3628) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:16:37 UTC (rev 3629) @@ -53,11 +53,7 @@ * @param mapArch the map header (<code>MapArchObject</code>) */ public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - super(mainControl, mapControl, mapArch); - - beginTransaction("Insert initial objects"); - addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list - endTransaction(); + super(mainControl, mapControl, objects, mapArch); } } // class DefaultMapModel Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:12:33 UTC (rev 3628) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:16:37 UTC (rev 3629) @@ -53,11 +53,7 @@ * @param mapArch the map header (<code>MapArchObject</code>) */ public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - super(mainControl, mapControl, mapArch); - - beginTransaction("Insert initial objects"); - addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list - endTransaction(); + super(mainControl, mapControl, objects, mapArch); } } // class DefaultMapModel Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:12:33 UTC (rev 3628) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:16:37 UTC (rev 3629) @@ -122,9 +122,10 @@ * Create an AbstractMapModel. * @param mainControl main controller * @param mapControl MapControl to associate with this model. + * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map * @param mapArchObject The MapArchObject to associate with this model. */ - protected AbstractMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final A mapArchObject) { + protected AbstractMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final List<G> objects, final A mapArchObject) { this.mapControl = mapControl; this.mapArchObject = mapArchObject; this.mainControl = mainControl; @@ -132,6 +133,7 @@ mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; beginTransaction("init"); clearMap(); + addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list endTransaction(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 21:23:16
|
Revision: 3630 http://gridarta.svn.sourceforge.net/gridarta/?rev=3630&view=rev Author: akirschbaum Date: 2008-02-23 13:23:14 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Remove DefaultMapModel. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java Deleted: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:16:37 UTC (rev 3629) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 21:23:14 UTC (rev 3630) @@ -1,59 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package cfeditor.map; - -import cfeditor.CMainControl; -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import java.util.List; -import net.sf.gridarta.map.AbstractMapModel; -import net.sf.gridarta.map.MapModel; - -/** - * The level model that represents a level. - * <h4>XXX This code does not properly implement MVC (Model View Controller).</h4> - * What should be changed? - * <ul> - * <li>Move all methods from other classes that directly access the mapgrid partly or completely to this class.</li> - * <li>Delegate all changes within a MapSquare to MapSquare.</li> - * <li>After all this is done, MapTilePane should be changed to reflect a Tree, not a List.</li> - * <li>The templist should be removed. Instead, the corresponding methods should use Collections.</li> - * </ul> - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class DefaultMapModel extends AbstractMapModel<GameObject, MapArchObject, Archetype> implements MapModel<GameObject, MapArchObject, Archetype> { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** - * Constructs a level model. - * @param mainControl main controller - * @param mapControl the controller of this view - * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map - * @param mapArch the map header (<code>MapArchObject</code>) - */ - public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - super(mainControl, mapControl, objects, mapArch); - } - -} // class DefaultMapModel Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-23 21:16:37 UTC (rev 3629) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-23 21:23:14 UTC (rev 3630) @@ -30,6 +30,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.AbstractMapControl; +import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -75,7 +76,7 @@ super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) - mapModel = new DefaultMapModel(mainControl, this, objects, mapArchObject); + mapModel = new AbstractMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); init(); } Deleted: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:16:37 UTC (rev 3629) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2008-02-23 21:23:14 UTC (rev 3630) @@ -1,59 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.map; - -import daieditor.CMainControl; -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import java.util.List; -import net.sf.gridarta.map.AbstractMapModel; -import net.sf.gridarta.map.MapModel; - -/** - * The level model that represents a level. - * <h4>XXX This code does not properly implement MVC (Model View Controller).</h4> - * What should be changed? - * <ul> - * <li>Move all methods from other classes that directly access the mapgrid partly or completely to this class.</li> - * <li>Delegate all changes within a MapSquare to MapSquare.</li> - * <li>After all this is done, MapTilePane should be changed to reflect a Tree, not a List.</li> - * <li>The templist should be removed. Instead, the corresponding methods should use Collections.</li> - * </ul> - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class DefaultMapModel extends AbstractMapModel<GameObject, MapArchObject, Archetype> implements MapModel<GameObject, MapArchObject, Archetype> { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** - * Constructs a level model. - * @param mainControl main controller - * @param mapControl the controller of this view - * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map - * @param mapArch the map header (<code>MapArchObject</code>) - */ - public DefaultMapModel(final CMainControl mainControl, final MapControl mapControl, final List<GameObject> objects, final MapArchObject mapArch) { - super(mainControl, mapControl, objects, mapArch); - } - -} // class DefaultMapModel Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-23 21:16:37 UTC (rev 3629) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-23 21:23:14 UTC (rev 3630) @@ -30,6 +30,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.AbstractMapControl; +import net.sf.gridarta.map.AbstractMapModel; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -75,7 +76,7 @@ super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) - mapModel = new DefaultMapModel(mainControl, this, objects, mapArchObject); + mapModel = new AbstractMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); init(); } Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:16:37 UTC (rev 3629) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:23:14 UTC (rev 3630) @@ -40,14 +40,17 @@ import org.jetbrains.annotations.Nullable; /** - * Abstract implementation of {@link MapModel} that covers the similarities between crossfire and daimonin. + * Implementation of {@link MapModel} that covers the similarities between crossfire and daimonin. * The transaction system is not implemented in a way that supports overriding its method for change. * Therefore all methods belonging to the transaction system are final. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @see MapModel class MapModel for a documentation of the transaction system. */ -public abstract class AbstractMapModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapModel<G, A, R> { +public final class AbstractMapModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapModel<G, A, R> { + /** The serial version UID. */ + private static final long serialVersionUID = 1; + /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(AbstractMapModel.class); @@ -125,7 +128,7 @@ * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map * @param mapArchObject The MapArchObject to associate with this model. */ - protected AbstractMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final List<G> objects, final A mapArchObject) { + public AbstractMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final List<G> objects, final A mapArchObject) { this.mapControl = mapControl; this.mapArchObject = mapArchObject; this.mainControl = mainControl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 21:25:50
|
Revision: 3631 http://gridarta.svn.sourceforge.net/gridarta/?rev=3631&view=rev Author: akirschbaum Date: 2008-02-23 13:25:47 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Rename AbstractMapModel into DefaultMapModel since it is not anymore abstract. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-23 21:23:14 UTC (rev 3630) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-23 21:25:47 UTC (rev 3631) @@ -30,7 +30,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.AbstractMapControl; -import net.sf.gridarta.map.AbstractMapModel; +import net.sf.gridarta.map.DefaultMapModel; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -76,7 +76,7 @@ super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) - mapModel = new AbstractMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); + mapModel = new DefaultMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); init(); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-23 21:23:14 UTC (rev 3630) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-23 21:25:47 UTC (rev 3631) @@ -30,7 +30,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.AbstractMapControl; -import net.sf.gridarta.map.AbstractMapModel; +import net.sf.gridarta.map.DefaultMapModel; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -76,7 +76,7 @@ super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) - mapModel = new AbstractMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); + mapModel = new DefaultMapModel<GameObject, MapArchObject, Archetype>(mainControl, this, objects, mapArchObject); init(); } Deleted: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:23:14 UTC (rev 3630) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 21:25:47 UTC (rev 3631) @@ -1,785 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.map; - -import java.awt.Point; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; -import javax.swing.event.EventListenerList; -import net.sf.gridarta.CFArchTypeList; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.Size2D; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.map.validation.DefaultErrorCollector; -import net.sf.gridarta.map.validation.ErrorCollector; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Implementation of {@link MapModel} that covers the similarities between crossfire and daimonin. - * The transaction system is not implemented in a way that supports overriding its method for change. - * Therefore all methods belonging to the transaction system are final. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @see MapModel class MapModel for a documentation of the transaction system. - */ -public final class AbstractMapModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapModel<G, A, R> { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(AbstractMapModel.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** Sync Lock Object. */ - private final transient Object syncLock = new Object(); - - /** - * The MapControl that controls this MapModel. - * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link MapControl}. - * @todo care about Serialization if this field remains - */ - @Deprecated private final MapControl<G, A, R> mapControl; - - /** - * The MapArchObject associated with this model. - */ - private final A mapArchObject; - - /** - * The CMainControl used for various operations. - * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link MainControl}. - */ - @Deprecated protected final transient MainControl<G, A, R, ?, ?> mainControl; - - /** Size of this map. */ - protected Size2D mapSize; - - /** - * The map, containing all arches grid-wise. - * Index: [width][height] - */ - protected MapSquare<G, A, R>[][] mapGrid; - - /** The registered event listeners. */ - private final EventListenerList listenerList = new EventListenerList(); - - /** - * The transaction depth. - * A value of 0 means there's no transaction going on. - * A value > 0 means there's a transaction going on and denotes the nesting level. - * @invariant transactionDepth >= 0 - */ - private int transactionDepth; - - /** - * The name of the current transaction. - * @invariant transactionDepth > 0 || transactionName == null - */ - @Nullable private String transactionName; - - /** - * The thread that performs the current transaction. - * @invariant transactionDepth > 0 || transactionThread == null - */ - @Nullable private Thread transactionThread; - - /** The ArrayList with changed squares. */ - private final Set<MapSquare<G, A, R>> changedSquares = new HashSet<MapSquare<G, A, R>>(); - - /** The ArrayList with changed gameObjects. */ - private final Set<G> changedGameObjects = new HashSet<G>(); - - /** - * The errors of this map model. - */ - @NotNull private ErrorCollector<G, A, R> errors = new DefaultErrorCollector(); - - /** - * Create an AbstractMapModel. - * @param mainControl main controller - * @param mapControl MapControl to associate with this model. - * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map - * @param mapArchObject The MapArchObject to associate with this model. - */ - public AbstractMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final List<G> objects, final A mapArchObject) { - this.mapControl = mapControl; - this.mapArchObject = mapArchObject; - this.mainControl = mainControl; - mapSize = mapArchObject.getMapSize(); - mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; - beginTransaction("init"); - clearMap(); - addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list - endTransaction(); - } - - /** {@inheritDoc} */ - public MapControl<G, A, R> getMapControl() { - return mapControl; - } - - /** {@inheritDoc} */ - public final A getMapArchObject() { - return mapArchObject; - } - - /** {@inheritDoc} */ - public final Size2D getMapSize() { - return mapSize; - } - - /** {@inheritDoc} */ - public final Iterator<MapSquare<G, A, R>> iterator() { - return new MapSquareIterator(); - } - - /** {@inheritDoc} */ - public final MapSquare<G, A, R> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { - return mapGrid[pos.x][pos.y]; - } - - /** - * Place a list of arches onto the map. - * This method does nothing if <code><var>objects</var> == null</code>. - * @param objects List with the heads of the gameObjects to add or <code>null</code> to add nothing. - */ - protected final void addObjectListToMap(@Nullable final List<G> objects) { - if (objects != null) { - for (final G gameObject : objects) { - if (!gameObject.isInContainer()) { // only map arches.... - addGameObjectToMap(gameObject, false); - } - } - } - } - - /** - * {@inheritDoc} - * This implementation is very safe by recreating every single MapSquare as new empty square with the trade-off of some strain of the garbage-collector. - * An alternative implemenation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reusage of GameObject instances similar to J2EE. - */ - public final void clearMap() { - for (int x = 0; x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - final boolean changed = mapGrid[x][y] != null && !mapGrid[x][y].isEmpty(); - mapGrid[x][y] = new MapSquare<G, A, R>(this, x, y); - if (changed) { - squareChanged(mapGrid[x][y]); - } - } - } - } - - /** {@inheritDoc} */ - public final boolean isEmpty() { - for (int x = 0; x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - if (!mapGrid[x][y].isEmpty()) { - return false; - } - } - } - return true; - } - - /** {@inheritDoc} */ - public final boolean isPointValid(@Nullable final Point pos) { - return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); - } - - /** {@inheritDoc} */ - public void resizeMap(@NotNull final Size2D newSize) { - if (newSize.equals(mapSize)) { - return; - } - - final Set<GameObject> objectsToDelete = new HashSet<GameObject>(); - - // no other thread may access this mapmodel while resizing - synchronized (syncLock) { - // first delete all arches in the area that will get cut off - // (this is especially important to remove all multipart-objects - // reaching into that area) - if (mapSize.getWidth() > newSize.getWidth()) { - // clear out the right stripe (as far as being cut off) - for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - // for every map square: delete all arches on it - for (final GameObject node : mapGrid[x][y]) { - objectsToDelete.add(node.getHead()); - } - } - } - } - - if (mapSize.getHeight() > newSize.getHeight()) { - // clear out the bottom stripe (as far as being cut off) - // (and yes, there is an area getting sweeped twice - and yes it could - // be optimized you smartass - but I don't care!) - for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - // for every map square: delete all arches on it - for (final GameObject node : mapGrid[x][y]) { - objectsToDelete.add(node.getHead()); - } - } - } - } - - for (final GameObject node : objectsToDelete) { - node.remove(); - } - - // Now the critical step: create an GameObject array of new dimension, - // copy all objects and set it to replace the current one. - final MapSquare<G, A, R>[][] newGrid = new MapSquare[newSize.getWidth()][newSize.getHeight()]; - - // relink all arches to the new grid - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - if (x < mapSize.getWidth() && y < mapSize.getHeight()) { - newGrid[x][y] = mapGrid[x][y]; - } else { - newGrid[x][y] = new MapSquare<G, A, R>(this, x, y); - } - } - } - - // replace old grid by new one - mapGrid = newGrid; - - // adjust the map and model attributes - mapSize = newSize; - getMapArchObject().setMapSize(newSize); - - // discard changed squares that are now out of map bounds - final Iterator<MapSquare<G, A, R>> it = changedSquares.iterator(); - while (it.hasNext()) { - final MapSquare<G, A, R> mapSquare = it.next(); - if (mapSquare.getMapX() >= mapSize.getWidth() || mapSquare.getMapY() >= mapSize.getHeight()) { - it.remove(); - } - } - - fireMapSizeChanged(); - } - } - - /** {@inheritDoc} */ - public void addMapModelListener(@NotNull final MapModelListener<G, A, R> listener) { - listenerList.add(MapModelListener.class, listener); - mapArchObject.addMapArchObjectListener(listener); - } - - /** {@inheritDoc} */ - public void removeMapModelListener(@NotNull final MapModelListener<G, A, R> listener) { - listenerList.remove(MapModelListener.class, listener); - mapArchObject.removeMapArchObjectListener(listener); - } - - /** {@inheritDoc} */ - public void addMapTransactionListener(@NotNull final MapTransactionListener<G, A, R> listener) { - listenerList.add(MapTransactionListener.class, listener); - } - - /** {@inheritDoc} */ - public void removeMapTransactionListener(@NotNull final MapTransactionListener<G, A, R> listener) { - listenerList.remove(MapTransactionListener.class, listener); - } - - /** {@inheritDoc} */ - public void squareChanged(@NotNull final MapSquare<G, A, R> square) { - if (transactionDepth == 0) { - log.error("squareChanged: square was changed outside a transaction"); - fireMapSquaresChangedEvent(square); - } else { - synchronized (changedSquares) { - changedSquares.add(square); - } - } - } - - /** {@inheritDoc} */ - public void gameObjectChanged(@NotNull final G gameObject) { - if (transactionDepth == 0) { - fireGameObjectsChangedEvent(gameObject); - } else { - synchronized (changedGameObjects) { - changedGameObjects.add(gameObject); - synchronized (changedSquares) { - changedSquares.add(gameObject.getMapSquare()); - } - } - } - } - - /** {@inheritDoc} */ - public final void beginTransaction(@NotNull final String name) { - if (transactionDepth == 0) { - transactionName = name; - transactionThread = Thread.currentThread(); - - fireBeginTransaction(name); - } else { - // == is okay for threads. - //noinspection ObjectEquality - if (transactionThread != Thread.currentThread()) { - throw new IllegalStateException("A transaction must only be used by one thread."); - } - } - transactionDepth++; - } - - /** {@inheritDoc} */ - public final void endTransaction() { - endTransaction(false); - } - - /** {@inheritDoc} */ - public final void endTransaction(final boolean fireEvent) { - if (transactionDepth <= 0) { - throw new IllegalStateException("Tried to end a transaction but no transaction was open."); - } - transactionDepth--; - assert transactionDepth >= 0; - if (transactionDepth == 0) { - commitTransaction(); - } else if (fireEvent && transactionDepth == 1) { - if (!changedGameObjects.isEmpty()) { - fireGameObjectsChangedEvent(changedGameObjects.toArray((G[]) new GameObject[changedGameObjects.size()])); - } - if (!changedSquares.isEmpty()) { - fireMapSquaresChangedEvent(changedSquares.toArray(new MapSquare[changedSquares.size()])); - } - } - } - - /** {@inheritDoc} */ - public final void endAllTransactions() { - if (transactionDepth > 0) { - commitTransaction(); - } - } - - /** - * Performs ending a transaction. - * Resets all transaction states and fires an event. - */ - private void commitTransaction() { - transactionDepth = 0; - transactionThread = null; - if (!changedSquares.isEmpty()) { - fireMapSquaresChangedEvent(changedSquares.toArray(new MapSquare[changedSquares.size()])); - changedSquares.clear(); - } - fireEndTransaction(); - } - - /** {@inheritDoc} */ - public final int getTransactionDepth() { - return transactionDepth; - } - - /** {@inheritDoc} */ - public final boolean isAnyTransactionActive() { - return transactionDepth > 0; - } - - /** {@inheritDoc} */ - @Nullable public final String getTransactionName() { - return transactionName; - } - - /** - * Fire a MapSquaresChangedEvent. - * @param squares Squares to fire event for - */ - private void fireMapSquaresChangedEvent(final MapSquare<G, A, R>... squares) { - final MapModelEvent<G, A, R> e = new MapModelEvent<G, A, R>(this, MapModelEvent.Type.SQUARES_CHANGED, squares); - for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { - listener.mapSquaresChanged(e); - } - } - - /** - * Fire a GameObjectsChangedEvent. - * @param gameObjects Game Objects to fire event for - */ - private void fireGameObjectsChangedEvent(final G... gameObjects) { - final MapModelEvent<G, A, R> e = new MapModelEvent<G, A, R>(this, MapModelEvent.Type.GAMEOBJECTS_CHANGED, gameObjects); - for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { - listener.mapObjectsChanged(e); - } - } - - /** Fire a map size changed event. */ - private void fireMapSizeChanged() { - final MapModelEvent<G, A, R> e = new MapModelEvent<G, A, R>(this, MapModelEvent.Type.SIZE_CHANGED); - for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { - listener.mapSizeChanged(e); - } - } - - /** - * Fire a begin transaction event. - * @param name the transaction name - */ - private void fireBeginTransaction(@NotNull final String name) { - for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { - listener.beginTransaction(this, name); - } - } - - /** - * Fire an end transaction event. - */ - private void fireEndTransaction() { - for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { - listener.endTransaction(this); - } - } - - /** - * This method checks whether the map is rectangular. - * A map always MUST be rectangular, this method can be used for assertions regarding this assumption. - * The check for rectangularity is a check whether the array dimensions of {@link #mapGrid} match the size specified in {@link #mapSize}. - * @return <code>true</code> if the map is rectangular, otherwise <code>false</code>. - */ - private boolean isRectangular() { - final int width = mapSize.getWidth(); - final int height = mapSize.getHeight(); - if (mapGrid.length != width) { - return false; - } - for (int x = 0; x < width; x++) { - if (mapGrid[x].length != height) { - return false; - } - } - return true; - } - - /** {@inheritDoc} */ - @NotNull public MapState<G, A, R> getState() { - return new MapState<G, A, R>(mapArchObject, mapGrid); - } - - /** {@inheritDoc} */ - public void setState(@NotNull final MapState<G, A, R> mapState) { - mapArchObject.setState(mapState.getMapArchObject()); - - final Size2D newSize = mapState.getMapArchObject().getMapSize(); - resizeMap(newSize); - clearMap(); - final List<G>[][] oldMapGrid = mapState.getMapGrid(); - - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - for (final G content : oldMapGrid[x][y]) { - if (!content.isMulti()) { - mapGrid[x][y].addLast(content.createClone(x, y)); - } - } - } - } - - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - for (final G content : oldMapGrid[x][y]) { - if (content.isMulti()) { - for (G tmp = content.createMultiClone(x, y); tmp != null; tmp = tmp.getMultiNext()) { - mapGrid[tmp.getMapX()][tmp.getMapY()].addLast(tmp); - } - } - } - } - } - } - - /** {@inheritDoc} */ - @Nullable public G getExit(@Nullable final Point hspot) { - if (hspot == null || !isPointValid(hspot)) { - return null; // out of map - } - for (final G arch : mapGrid[hspot.x][hspot.y]) { - if (CFArchTypeList.isExitType(arch) && arch.getAttributeString("slaying").length() > 0) { - return arch; - } - } - return null; - } - - /** {@inheritDoc} */ - public void deleteMapArch(@NotNull final G gameObject, @NotNull final Point pos, final boolean join) { - assert gameObject.getMapSquare() == getMapSquare(pos); - - if (gameObject.isInContainer()) { - gameObject.remove(); - } else { - gameObject.remove(); - - // do autojoining - final R temp = mainControl.getArchetypeSet().getArchetype(gameObject.getArchetypeName()); - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(temp) != null && !temp.isMulti()) { - // remove connections to the deleted arch - mainControl.getAutojoinLists().getAutojoinList(temp).joinDelete(this, pos); - } - } - } - - /** {@inheritDoc} */ - public boolean isMultiArchFittingToMap(final R archetype, final Point pos, final boolean allowDouble) { - for (R part = archetype; part != null; part = (R) part.getMultiNext()) { - final Point point = new Point(part.getMultiX(), part.getMultiY()); - point.translate(pos.x, pos.y); - // outside map - if (!isPointValid(point)) { - return false; - } - - if (!allowDouble) { - final String temp = part.getArchetypeName(); - for (final G node : mapGrid[point.x][point.y]) { - if (node.getArchetypeName().equals(temp)) { - return false; - } - } - } - } - - return true; - } - - /** {@inheritDoc} */ - public void setErrors(@NotNull final ErrorCollector<G, A, R> errors) { - this.errors = errors; - for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { - listener.errorsChanged(this); - } - } - - /** {@inheritDoc} */ - @NotNull public ErrorCollector<G, A, R> getErrors() { - return errors; - } - - /** - * {@inheritDoc} - * @xxx I'm too complex - */ - @Nullable public G insertArchToMap(final G newObject, final G next, final Point pos, final boolean join) { - // map coords must be valid - if (!isPointValid(pos)) { - return null; - } - - final G newGameObject; - if (next == null || !next.isInContainer()) { - - // put arch on the map - if (newObject.isArchetype()) { - newGameObject = addArchToMap(newObject.getArchetypeName(), pos, true, join, false); - if (newGameObject == null) { - return null; - } - } else { - // insert the given 'newObject' (multis not allowed here yet - sorry) - if (!newObject.isMulti()) { - newGameObject = newObject.createClone(pos.x, pos.y); - addGameObjectToMap(newGameObject, false); - } else { - return null; // tried to insert multi (probably from pickmap) - } - } - - int position = 0; - for (final G search : mapGrid[pos.x][pos.y].reverse()) { - // This is okay because next is on the desired square. - //noinspection ObjectEquality - if (search == next) { - break; - } - position++; - } - for(int i = 0; i < position - 1; i++) { - newGameObject.moveDown(); - } - } else { - // insert the new arch into the inventory of a map arch - if (newObject.isArchetype()) { - newGameObject = newObject.createArch(); - } else { - // create clone from a pickmap - if (!newObject.isMulti()) { - newGameObject = newObject.createClone(pos.x, pos.y); - } else { - return null; - } - } - - next.getContainer().addLast(newGameObject); - newGameObject.setObjectFace(); - mainControl.getArchetypeParser().postParseGameObject(newGameObject, getMapControl().getActiveEditType()); - } - - return newGameObject; - } - - /** {@inheritDoc} */ - @Nullable public G addArchToMap(final String archName, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { - if (archName == null || archName.length() == 0 || !isPointValid(pos)) { - return null; - } - - R archetype = mainControl.getArchetypeSet().getArchetype(archName); - if (archetype == null) { - return null; - } - - if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { - // do autojoining if enabled - archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); - if (archetype == null) { - return null; // only one autojoin type per square allowed - } - } - - if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { - return null; - } - - G head = null; - for (R archetypePart = archetype; archetypePart != null; archetypePart = (R) archetypePart.getMultiNext()) { - final G part = archetypePart.createArch(); - if (archetypePart == archetype) { - head = part; - } else { - head.addTailPart(part); - } - - final int mapx = pos.x + part.getMultiX(); - final int mapy = pos.y + part.getMultiY(); - - part.setMapX(mapx); - part.setMapY(mapy); - if (insertBelow) { - mapGrid[mapx][mapy].addFirst(part); - } else { - mapGrid[mapx][mapy].addLast(part); - } - - final Integer direction = mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); - if (direction != null) { - part.setDirection(direction); - part.setAttributeString("direction", Integer.toString(direction)); - } - mainControl.getArchetypeParser().postParseGameObject(part, getMapControl().getActiveEditType()); - part.setObjectFace(); - } - - for (final G invObject : archetype) { - head.addLast(invObject.createClone(0, 0)); - } - - return head; - } - - /** {@inheritDoc} */ - public void addGameObjectToMap(final G gameObject, final boolean insertBelow) { - // Make sure this arch has the proper edit_type - if (gameObject.getEditType() == GUIConstants.EDIT_TYPE_NONE) { - gameObject.calculateEditType(getMapControl().getActiveEditType()); - } - - gameObject.setObjectFace(); - - final int mapx = gameObject.getMapX(); - final int mapy = gameObject.getMapY(); - if (!isPointValid(new Point(mapx, mapy))) { - // TODO: - // Think about how this could be handled via an exception and caught much earlier, perhaps already while reading the map, not after it - // already has been read. - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "mapErrorArchOutOfGrid"); - return; - } - - if (insertBelow) { - mapGrid[mapx][mapy].addFirst(gameObject); - } else { - mapGrid[mapx][mapy].addLast(gameObject); - } - - // calculate edit type - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (getMapControl().getActiveEditType() != 0) { - gameObject.setEditType(gameObject.calculateEditType(getMapControl().getActiveEditType())); // calculate new - } - } - - /** Iterator for iterating over all squares of a model. */ - private class MapSquareIterator implements Iterator<MapSquare<G, A, R>> { - - /** - * Index of current map square. - * The point is used as single value index to a two dimensional array. - * That works fine because the two dimensional array is a rectangular array. - */ - private int point; - - /** Create a MapSquareIterator. */ - private MapSquareIterator() { - assert isRectangular(); - } - - /** {@inheritDoc} */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - public boolean hasNext() { - return point < mapSize.getWidth() * mapSize.getHeight(); - } - - /** {@inheritDoc} */ - public MapSquare<G, A, R> next() { - try { - final MapSquare<G, A, R> square = mapGrid[point / mapSize.getHeight()][point % mapSize.getHeight()]; - point++; - return square; - } catch (final ArrayIndexOutOfBoundsException ignore) { - throw new NoSuchElementException(); - } - } - - } // class MapSquareIterator - -} // class AbstractMapModel Copied: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java (from rev 3630, trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java) =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java (rev 0) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-02-23 21:25:47 UTC (rev 3631) @@ -0,0 +1,785 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.map; + +import java.awt.Point; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Set; +import javax.swing.event.EventListenerList; +import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.map.validation.DefaultErrorCollector; +import net.sf.gridarta.map.validation.ErrorCollector; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Implementation of {@link MapModel} that covers the similarities between crossfire and daimonin. + * The transaction system is not implemented in a way that supports overriding its method for change. + * Therefore all methods belonging to the transaction system are final. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @see MapModel class MapModel for a documentation of the transaction system. + */ +public final class DefaultMapModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapModel<G, A, R> { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(DefaultMapModel.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** Sync Lock Object. */ + private final transient Object syncLock = new Object(); + + /** + * The MapControl that controls this MapModel. + * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link MapControl}. + * @todo care about Serialization if this field remains + */ + @Deprecated private final MapControl<G, A, R> mapControl; + + /** + * The MapArchObject associated with this model. + */ + private final A mapArchObject; + + /** + * The CMainControl used for various operations. + * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link MainControl}. + */ + @Deprecated protected final transient MainControl<G, A, R, ?, ?> mainControl; + + /** Size of this map. */ + protected Size2D mapSize; + + /** + * The map, containing all arches grid-wise. + * Index: [width][height] + */ + protected MapSquare<G, A, R>[][] mapGrid; + + /** The registered event listeners. */ + private final EventListenerList listenerList = new EventListenerList(); + + /** + * The transaction depth. + * A value of 0 means there's no transaction going on. + * A value > 0 means there's a transaction going on and denotes the nesting level. + * @invariant transactionDepth >= 0 + */ + private int transactionDepth; + + /** + * The name of the current transaction. + * @invariant transactionDepth > 0 || transactionName == null + */ + @Nullable private String transactionName; + + /** + * The thread that performs the current transaction. + * @invariant transactionDepth > 0 || transactionThread == null + */ + @Nullable private Thread transactionThread; + + /** The ArrayList with changed squares. */ + private final Set<MapSquare<G, A, R>> changedSquares = new HashSet<MapSquare<G, A, R>>(); + + /** The ArrayList with changed gameObjects. */ + private final Set<G> changedGameObjects = new HashSet<G>(); + + /** + * The errors of this map model. + */ + @NotNull private ErrorCollector<G, A, R> errors = new DefaultErrorCollector(); + + /** + * Create an DefaultMapModel. + * @param mainControl main controller + * @param mapControl MapControl to associate with this model. + * @param objects the <code>GameObject</code> list of this map or <code>null</code> for an empty map + * @param mapArchObject The MapArchObject to associate with this model. + */ + public DefaultMapModel(final MainControl<G, A, R, ?, ?> mainControl, final MapControl<G, A, R> mapControl, final List<G> objects, final A mapArchObject) { + this.mapControl = mapControl; + this.mapArchObject = mapArchObject; + this.mainControl = mainControl; + mapSize = mapArchObject.getMapSize(); + mapGrid = new MapSquare[mapSize.getWidth()][mapSize.getHeight()]; + beginTransaction("init"); + clearMap(); + addObjectListToMap(objects); // init mapArchObject and (when not new map) the arch list + endTransaction(); + } + + /** {@inheritDoc} */ + public MapControl<G, A, R> getMapControl() { + return mapControl; + } + + /** {@inheritDoc} */ + public final A getMapArchObject() { + return mapArchObject; + } + + /** {@inheritDoc} */ + public final Size2D getMapSize() { + return mapSize; + } + + /** {@inheritDoc} */ + public final Iterator<MapSquare<G, A, R>> iterator() { + return new MapSquareIterator(); + } + + /** {@inheritDoc} */ + public final MapSquare<G, A, R> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { + return mapGrid[pos.x][pos.y]; + } + + /** + * Place a list of arches onto the map. + * This method does nothing if <code><var>objects</var> == null</code>. + * @param objects List with the heads of the gameObjects to add or <code>null</code> to add nothing. + */ + protected final void addObjectListToMap(@Nullable final List<G> objects) { + if (objects != null) { + for (final G gameObject : objects) { + if (!gameObject.isInContainer()) { // only map arches.... + addGameObjectToMap(gameObject, false); + } + } + } + } + + /** + * {@inheritDoc} + * This implementation is very safe by recreating every single MapSquare as new empty square with the trade-off of some strain of the garbage-collector. + * An alternative implemenation would manually clean every existing MapSquare but that probably wouldn't really be faster until we have reusage of GameObject instances similar to J2EE. + */ + public final void clearMap() { + for (int x = 0; x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + final boolean changed = mapGrid[x][y] != null && !mapGrid[x][y].isEmpty(); + mapGrid[x][y] = new MapSquare<G, A, R>(this, x, y); + if (changed) { + squareChanged(mapGrid[x][y]); + } + } + } + } + + /** {@inheritDoc} */ + public final boolean isEmpty() { + for (int x = 0; x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + if (!mapGrid[x][y].isEmpty()) { + return false; + } + } + } + return true; + } + + /** {@inheritDoc} */ + public final boolean isPointValid(@Nullable final Point pos) { + return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); + } + + /** {@inheritDoc} */ + public void resizeMap(@NotNull final Size2D newSize) { + if (newSize.equals(mapSize)) { + return; + } + + final Set<GameObject> objectsToDelete = new HashSet<GameObject>(); + + // no other thread may access this mapmodel while resizing + synchronized (syncLock) { + // first delete all arches in the area that will get cut off + // (this is especially important to remove all multipart-objects + // reaching into that area) + if (mapSize.getWidth() > newSize.getWidth()) { + // clear out the right stripe (as far as being cut off) + for (int x = newSize.getWidth(); x < mapSize.getWidth(); x++) { + for (int y = 0; y < mapSize.getHeight(); y++) { + // for every map square: delete all arches on it + for (final GameObject node : mapGrid[x][y]) { + objectsToDelete.add(node.getHead()); + } + } + } + } + + if (mapSize.getHeight() > newSize.getHeight()) { + // clear out the bottom stripe (as far as being cut off) + // (and yes, there is an area getting sweeped twice - and yes it could + // be optimized you smartass - but I don't care!) + for (int y = newSize.getHeight(); y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { + // for every map square: delete all arches on it + for (final GameObject node : mapGrid[x][y]) { + objectsToDelete.add(node.getHead()); + } + } + } + } + + for (final GameObject node : objectsToDelete) { + node.remove(); + } + + // Now the critical step: create an GameObject array of new dimension, + // copy all objects and set it to replace the current one. + final MapSquare<G, A, R>[][] newGrid = new MapSquare[newSize.getWidth()][newSize.getHeight()]; + + // relink all arches to the new grid + for (int x = 0; x < newSize.getWidth(); x++) { + for (int y = 0; y < newSize.getHeight(); y++) { + if (x < mapSize.getWidth() && y < mapSize.getHeight()) { + newGrid[x][y] = mapGrid[x][y]; + } else { + newGrid[x][y] = new MapSquare<G, A, R>(this, x, y); + } + } + } + + // replace old grid by new one + mapGrid = newGrid; + + // adjust the map and model attributes + mapSize = newSize; + getMapArchObject().setMapSize(newSize); + + // discard changed squares that are now out of map bounds + final Iterator<MapSquare<G, A, R>> it = changedSquares.iterator(); + while (it.hasNext()) { + final MapSquare<G, A, R> mapSquare = it.next(); + if (mapSquare.getMapX() >= mapSize.getWidth() || mapSquare.getMapY() >= mapSize.getHeight()) { + it.remove(); + } + } + + fireMapSizeChanged(); + } + } + + /** {@inheritDoc} */ + public void addMapModelListener(@NotNull final MapModelListener<G, A, R> listener) { + listenerList.add(MapModelListener.class, listener); + mapArchObject.addMapArchObjectListener(listener); + } + + /** {@inheritDoc} */ + public void removeMapModelListener(@NotNull final MapModelListener<G, A, R> listener) { + listenerList.remove(MapModelListener.class, listener); + mapArchObject.removeMapArchObjectListener(listener); + } + + /** {@inheritDoc} */ + public void addMapTransactionListener(@NotNull final MapTransactionListener<G, A, R> listener) { + listenerList.add(MapTransactionListener.class, listener); + } + + /** {@inheritDoc} */ + public void removeMapTransactionListener(@NotNull final MapTransactionListener<G, A, R> listener) { + listenerList.remove(MapTransactionListener.class, listener); + } + + /** {@inheritDoc} */ + public void squareChanged(@NotNull final MapSquare<G, A, R> square) { + if (transactionDepth == 0) { + log.error("squareChanged: square was changed outside a transaction"); + fireMapSquaresChangedEvent(square); + } else { + synchronized (changedSquares) { + changedSquares.add(square); + } + } + } + + /** {@inheritDoc} */ + public void gameObjectChanged(@NotNull final G gameObject) { + if (transactionDepth == 0) { + fireGameObjectsChangedEvent(gameObject); + } else { + synchronized (changedGameObjects) { + changedGameObjects.add(gameObject); + synchronized (changedSquares) { + changedSquares.add(gameObject.getMapSquare()); + } + } + } + } + + /** {@inheritDoc} */ + public final void beginTransaction(@NotNull final String name) { + if (transactionDepth == 0) { + transactionName = name; + transactionThread = Thread.currentThread(); + + fireBeginTransaction(name); + } else { + // == is okay for threads. + //noinspection ObjectEquality + if (transactionThread != Thread.currentThread()) { + throw new IllegalStateException("A transaction must only be used by one thread."); + } + } + transactionDepth++; + } + + /** {@inheritDoc} */ + public final void endTransaction() { + endTransaction(false); + } + + /** {@inheritDoc} */ + public final void endTransaction(final boolean fireEvent) { + if (transactionDepth <= 0) { + throw new IllegalStateException("Tried to end a transaction but no transaction was open."); + } + transactionDepth--; + assert transactionDepth >= 0; + if (transactionDepth == 0) { + commitTransaction(); + } else if (fireEvent && transactionDepth == 1) { + if (!changedGameObjects.isEmpty()) { + fireGameObjectsChangedEvent(changedGameObjects.toArray((G[]) new GameObject[changedGameObjects.size()])); + } + if (!changedSquares.isEmpty()) { + fireMapSquaresChangedEvent(changedSquares.toArray(new MapSquare[changedSquares.size()])); + } + } + } + + /** {@inheritDoc} */ + public final void endAllTransactions() { + if (transactionDepth > 0) { + commitTransaction(); + } + } + + /** + * Performs ending a transaction. + * Resets all transaction states and fires an event. + */ + private void commitTransaction() { + transactionDepth = 0; + transactionThread = null; + if (!changedSquares.isEmpty()) { + fireMapSquaresChangedEvent(changedSquares.toArray(new MapSquare[changedSquares.size()])); + changedSquares.clear(); + } + fireEndTransaction(); + } + + /** {@inheritDoc} */ + public final int getTransactionDepth() { + return transactionDepth; + } + + /** {@inheritDoc} */ + public final boolean isAnyTransactionActive() { + return transactionDepth > 0; + } + + /** {@inheritDoc} */ + @Nullable public final String getTransactionName() { + return transactionName; + } + + /** + * Fire a MapSquaresChangedEvent. + * @param squares Squares to fire event for + */ + private void fireMapSquaresChangedEvent(final MapSquare<G, A, R>... squares) { + final MapModelEvent<G, A, R> e = new MapModelEvent<G, A, R>(this, MapModelEvent.Type.SQUARES_CHANGED, squares); + for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { + listener.mapSquaresChanged(e); + } + } + + /** + * Fire a GameObjectsChangedEvent. + * @param gameObjects Game Objects to fire event for + */ + private void fireGameObjectsChangedEvent(final G... gameObjects) { + final MapModelEvent<G, A, R> e = new MapModelEvent<G, A, R>(this, MapModelEvent.Type.GAMEOBJECTS_CHANGED, gameObjects); + for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { + listener.mapObjectsChanged(e); + } + } + + /** Fire a map size changed event. */ + private void fireMapSizeChanged() { + final MapModelEvent<G, A, R> e = new MapModelEvent<G, A, R>(this, MapModelEvent.Type.SIZE_CHANGED); + for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { + listener.mapSizeChanged(e); + } + } + + /** + * Fire a begin transaction event. + * @param name the transaction name + */ + private void fireBeginTransaction(@NotNull final String name) { + for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { + listener.beginTransaction(this, name); + } + } + + /** + * Fire an end transaction event. + */ + private void fireEndTransaction() { + for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { + listener.endTransaction(this); + } + } + + /** + * This method checks whether the map is rectangular. + * A map always MUST be rectangular, this method can be used for assertions regarding this assumption. + * The check for rectangularity is a check whether the array dimensions of {@link #mapGrid} match the size specified in {@link #mapSize}. + * @return <code>true</code> if the map is rectangular, otherwise <code>false</code>. + */ + private boolean isRectangular() { + final int width = mapSize.getWidth(); + final int height = mapSize.getHeight(); + if (mapGrid.length != width) { + return false; + } + for (int x = 0; x < width; x++) { + if (mapGrid[x].length != height) { + return false; + } + } + return true; + } + + /** {@inheritDoc} */ + @NotNull public MapState<G, A, R> getState() { + return new MapState<G, A, R>(mapArchObject, mapGrid); + } + + /** {@inheritDoc} */ + public void setState(@NotNull final MapState<G, A, R> mapState) { + mapArchObject.setState(mapState.getMapArchObject()); + + final Size2D newSize = mapState.getMapArchObject().getMapSize(); + resizeMap(newSize); + clearMap(); + final List<G>[][] oldMapGrid = mapState.getMapGrid(); + + for (int x = 0; x < newSize.getWidth(); x++) { + for (int y = 0; y < newSize.getHeight(); y++) { + for (final G content : oldMapGrid[x][y]) { + if (!content.isMulti()) { + mapGrid[x][y].addLast(content.createClone(x, y)); + } + } + } + } + + for (int x = 0; x < newSize.getWidth(); x++) { + for (int y = 0; y < newSize.getHeight(); y++) { + for (final G content : oldMapGrid[x][y]) { + if (content.isMulti()) { + for (G tmp = content.createMultiClone(x, y); tmp != null; tmp = tmp.getMultiNext()) { + mapGrid[tmp.getMapX()][tmp.getMapY()].addLast(tmp); + } + } + } + } + } + } + + /** {@inheritDoc} */ + @Nullable public G getExit(@Nullable final Point hspot) { + if (hspot == null || !isPointValid(hspot)) { + return null; // out of map + } + for (final G arch : mapGrid[hspot.x][hspot.y]) { + if (CFArchTypeList.isExitType(arch) && arch.getAttributeString("slaying").length() > 0) { + return arch; + } + } + return null; + } + + /** {@inheritDoc} */ + public void deleteMapArch(@NotNull final G gameObject, @NotNull final Point pos, final boolean join) { + assert gameObject.getMapSquare() == getMapSquare(pos); + + if (gameObject.isInContainer()) { + gameObject.remove(); + } else { + gameObject.remove(); + + // do autojoining + final R temp = mainControl.getArchetypeSet().getArchetype(gameObject.getArchetypeName()); + if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(temp) != null && !temp.isMulti()) { + // remove connections to the deleted arch + mainControl.getAutojoinLists().getAutojoinList(temp).joinDelete(this, pos); + } + } + } + + /** {@inheritDoc} */ + public boolean isMultiArchFittingToMap(final R archetype, final Point pos, final boolean allowDouble) { + for (R part = archetype; part != null; part = (R) part.getMultiNext()) { + final Point point = new Point(part.getMultiX(), part.getMultiY()); + point.translate(pos.x, pos.y); + // outside map + if (!isPointValid(point)) { + return false; + } + + if (!allowDouble) { + final String temp = part.getArchetypeName(); + for (final G node : mapGrid[point.x][point.y]) { + if (node.getArchetypeName().equals(temp)) { + return false; + } + } + } + } + + return true; + } + + /** {@inheritDoc} */ + public void setErrors(@NotNull final ErrorCollector<G, A, R> errors) { + this.errors = errors; + for (final MapModelListener<G, A, R> listener : listenerList.getListeners(MapModelListener.class)) { + listener.errorsChanged(this); + } + } + + /** {@inheritDoc} */ + @NotNull public ErrorCollector<G, A, R> getErrors() { + return errors; + } + + /** + * {@inheritDoc} + * @xxx I'm too complex + */ + @Nullable public G insertArchToMap(final G newObject, final G next, final Point pos, final boolean join) { + // map coords must be valid + if (!isPointValid(pos)) { + return null; + } + + final G newGameObject; + if (next == null || !next.isInContainer()) { + + // put arch on the map + if (newObject.isArchetype()) { + newGameObject = addArchToMap(newObject.getArchetypeName(), pos, true, join, false); + if (newGameObject == null) { + return null; + } + } else { + // insert the given 'newObject' (multis not allowed here yet - sorry) + if (!newObject.isMulti()) { + newGameObject = newObject.createClone(pos.x, pos.y); + addGameObjectToMap(newGameObject, false); + } else { + return null; // tried to insert multi (probably from pickmap) + } + } + + int position = 0; + for (final G search : mapGrid[pos.x][pos.y].reverse()) { + // This is okay because next is on the desired square. + //noinspection ObjectEquality + if (search == next) { + break; + } + position++; + } + for(int i = 0; i < position - 1; i++) { + newGameObject.moveDown(); + } + } else { + // insert the new arch into the inventory of a map arch + if (newObject.isArchetype()) { + newGameObject = newObject.createArch(); + } else { + // create clone from a pickmap + if (!newObject.isMulti()) { + newGameObject = newObject.createClone(pos.x, pos.y); + } else { + return null; + } + } + + next.getContainer().addLast(newGameObject); + newGameObject.setObjectFace(); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, getMapControl().getActiveEditType()); + } + + return newGameObject; + } + + /** {@inheritDoc} */ + @Nullable public G addArchToMap(final String archName, final Point pos, final boolean allowDouble, final boolean join, final boolean insertBelow) { + if (archName == null || archName.length() == 0 || !isPointValid(pos)) { + return null; + } + + R archetype = mainControl.getArchetypeSet().getArchetype(archName); + if (archetype == null) { + return null; + } + + if (mainControl.getMainView().isAutoJoin() && join && mainControl.getAutojoinLists().getAutojoinList(archetype) != null && !archetype.isMulti()) { + // do autojoining if enabled + archetype = mainControl.getAutojoinLists().getAutojoinList(archetype).joinInsert(this, pos); + if (archetype == null) { + return null; // only one autojoin type per square allowed + } + } + + if (!isMultiArchFittingToMap(archetype, pos, allowDouble)) { + return null; + } + + G head = null; + for (R archetypePart = archetype; archetypePart != null; archetypePart = (R) archetypePart.getMultiNext()) { + final G part = archetypePart.createArch(); + if (archetypePart == archetype) { + head = part; + } else { + head.addTailPart(part); + } + + final int mapx = pos.x + part.getMultiX(); + final int mapy = pos.y + part.getMultiY(); + + part.setMapX(mapx); + part.setMapY(mapy); + if (insertBelow) { + mapGrid[mapx][mapy].addFirst(part); + } else { + mapGrid[mapx][mapy].addLast(part); + } + + final Integer direction = mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getCurrentDirection(); + if (direction != nul... [truncated message content] |
From: <aki...@us...> - 2008-02-24 01:02:18
|
Revision: 3633 http://gridarta.svn.sourceforge.net/gridarta/?rev=3633&view=rev Author: akirschbaum Date: 2008-02-23 17:02:09 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Remove CFTreasureListTree.getInstance(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-23 21:44:43 UTC (rev 3632) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-24 01:02:09 UTC (rev 3633) @@ -757,7 +757,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, treasureListTree); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-02-23 21:44:43 UTC (rev 3632) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-02-24 01:02:09 UTC (rev 3633) @@ -70,12 +70,12 @@ * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, treasureListTree); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -91,9 +91,10 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param treasureListTree the treasure list tree */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl) { - super(archTypeList, gameObject, mainControl); + private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { + super(archTypeList, gameObject, mainControl, treasureListTree); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-02-23 21:44:43 UTC (rev 3632) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-02-24 01:02:09 UTC (rev 3633) @@ -897,7 +897,7 @@ // types.xml is missing! ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoTypes"); } else if (gameObject != null && !gameObject.hasUndefinedArchetype()) { - GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this); + GameObjectAttributesDialog.showAttribDialog(typeList, gameObject, this, treasureListTree); } else { ACTION_FACTORY.showMessageDialog(mainView, "openAttrDialogNoDefaultArch"); } Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-02-23 21:44:43 UTC (rev 3632) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-02-24 01:02:09 UTC (rev 3633) @@ -70,12 +70,12 @@ * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control */ - public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl) { + public static void showAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { synchronized (dialogs) { if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl); + final GameObjectAttributesDialog pane = new GameObjectAttributesDialog(archTypeList, gameObject, mainControl, treasureListTree); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -91,9 +91,10 @@ * @param archTypeList the list of CF type-data * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control + * @param treasureListTree the treasure list tree */ - private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl) { - super(archTypeList, gameObject, mainControl); + private GameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree) { + super(archTypeList, gameObject, mainControl, treasureListTree); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-02-23 21:44:43 UTC (rev 3632) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-02-24 01:02:09 UTC (rev 3633) @@ -124,6 +124,8 @@ /** Reference to MainControl. */ protected final MainControl<G, A, R, ?, ?> mainControl; + @NotNull private final CFTreasureListTree<G, A, R> treasureListTree; + protected final List<DialogAttrib<?>> dialogAttribs = new ArrayList<DialogAttrib<?>>(); private JComboBox typesel; // selection box for type @@ -175,11 +177,13 @@ * @param archTypeList Reference to the list of CFArchTypes. * @param gameObject GameObject to show dialog for. * @param mainControl MainControl, for retrieving AnimationObjects, FaceObjects etc.. + * @param treasureListTree the treasure list tree */ - protected AbstractGameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?, ?> mainControl) { + protected AbstractGameObjectAttributesDialog(final CFArchTypeList archTypeList, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?, ?> mainControl, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { this.archTypeList = archTypeList; this.gameObject = gameObject.getHead(); this.mainControl = mainControl; + this.treasureListTree = treasureListTree; archetype = this.gameObject.getArchetype(); type = archTypeList.getType(gameObject); @@ -749,7 +753,7 @@ final JTextField input = new JTextField(" " + treasureName, TEXTFIELD_COLUMNS); input.setEditable(false); final DialogAttrib<JTextField> tmpAttr = new DialogAttrib<JTextField>(attrib, input); - cLabel = new JButton(new ViewTreasurelistAL(tmpAttr, this)); + cLabel = new JButton(new ViewTreasurelistAL<G, A, R>(tmpAttr, this, treasureListTree)); cComp = input; newAttr = tmpAttr; } @@ -1401,11 +1405,13 @@ * ActionListener for the buttons on treasurelists. When such a button is * pressed, the dialog with treasurelists pops up. */ - private static final class ViewTreasurelistAL extends AbstractAction { + private static final class ViewTreasurelistAL<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractAction { /** The serial version UID. */ private static final long serialVersionUID = 1; + private final CFTreasureListTree<G, A, R> treasureListTree; + private final DialogAttrib<JTextField> strAttr; // attribute structure private final AbstractGameObjectAttributesDialog dialog; // reference to this dialog instance @@ -1415,8 +1421,9 @@ * @param attr the GUI-string attribute where the treasurelist button belongs to * @param dialog Parent component to show on. */ - private ViewTreasurelistAL(final DialogAttrib<JTextField> attr, final AbstractGameObjectAttributesDialog dialog) { + private ViewTreasurelistAL(final DialogAttrib<JTextField> attr, final AbstractGameObjectAttributesDialog dialog, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { super("treasurelist:"); + this.treasureListTree = treasureListTree; strAttr = attr; this.dialog = dialog; } @@ -1424,7 +1431,7 @@ /** {@inheritDoc} */ public void actionPerformed(final ActionEvent e) { if (strAttr != null) { - CFTreasureListTree.getInstance().showDialog(strAttr.input, dialog); + treasureListTree.showDialog(strAttr.input, dialog); } } Modified: trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java =================================================================== --- trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-02-23 21:44:43 UTC (rev 3632) +++ trunk/src/app/net/sf/gridarta/treasurelist/CFTreasureListTree.java 2008-02-24 01:02:09 UTC (rev 3633) @@ -62,8 +62,6 @@ public static final String NONE_SYM = "<none>"; // string displayed in attribute dialog for "none" - private static CFTreasureListTree instance; // static instance of this object - /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -97,7 +95,6 @@ */ public CFTreasureListTree(@NotNull final ArchetypeSet<G, A, R> archetypeSet, final Document specialTreasureListsDocument, final TreasureLocation... treasures) { super(root); - instance = this; putClientProperty("JTree.lineStyle", "Angled"); setCellRenderer(new TreasureCellRenderer(archetypeSet, root)); @@ -351,12 +348,4 @@ return teasureTreeNode.getTreasureObj().getName(); } - /** - * Returns the common instance. - * @return The common instance. - */ - public static CFTreasureListTree getInstance() { - return instance; - } - } // class CFTreasureListTree This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-02 13:53:42
|
Revision: 3635 http://gridarta.svn.sourceforge.net/gridarta/?rev=3635&view=rev Author: akirschbaum Date: 2008-03-02 05:53:29 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird behaviour with *). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/action.properties trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/action.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-02 09:18:55 UTC (rev 3634) +++ trunk/crossfire/ChangeLog 2008-03-02 13:53:29 UTC (rev 3635) @@ -1,3 +1,8 @@ +2008-03-02 Andreas Kirschbaum + + * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird + behaviour with *). + 2008-02-22 Andreas Kirschbaum * Implement "monster" view. It summarizes all monsters by name on Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2008-03-02 09:18:55 UTC (rev 3634) +++ trunk/crossfire/src/cfeditor/action.properties 2008-03-02 13:53:29 UTC (rev 3635) @@ -26,12 +26,11 @@ ######## # Menus -main.menubar=file edit map cursor archetypes pickmaps resources tools analyze view plugins window help +main.menubar=file edit map archetypes pickmaps resources tools analyze view plugins window help file.menu=createNew open recent close - save saveAs revert createImage - options - exit edit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap tileShow - mapCreateView mapProperties -cursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes archetypes.menu=displayObjectNames findArchetypes #pickmaps.menu: See gridarta resources.menu=collectArches - viewTreasurelists Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-02 09:18:55 UTC (rev 3634) +++ trunk/daimonin/ChangeLog 2008-03-02 13:53:29 UTC (rev 3635) @@ -1,3 +1,8 @@ +2008-03-02 Andreas Kirschbaum + + * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird + behaviour with *). + 2008-02-22 Andreas Kirschbaum * Implement "monster" view. It summarizes all monsters by name on Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-03-02 09:18:55 UTC (rev 3634) +++ trunk/daimonin/src/daieditor/action.properties 2008-03-02 13:53:29 UTC (rev 3635) @@ -26,11 +26,10 @@ ######## # Menus -main.menubar=file edit map cursor archetypes pickmaps resources tools view window help +main.menubar=file edit map archetypes pickmaps resources tools view window help file.menu=createNew open recent close - save saveAs revert createImage - options - exit edit.menu=undo redo - clear cut copy paste - shift - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterNorthEastMap enterSouthEastMap enterSouthWestMap enterNorthWestMap - mapCreateView mapProperties -cursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes archetypes.menu=displayObjectNames findArchetypes #pickmaps.menu: See gridarta resources.menu=collectArches collectSpells - reloadFaces - viewTreasurelists This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-02 14:55:44
|
Revision: 3639 http://gridarta.svn.sourceforge.net/gridarta/?rev=3639&view=rev Author: akirschbaum Date: 2008-03-02 06:54:59 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Make fill and replace work when no cursor is active. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-02 14:37:16 UTC (rev 3638) +++ trunk/crossfire/ChangeLog 2008-03-02 14:54:59 UTC (rev 3639) @@ -1,5 +1,7 @@ 2008-03-02 Andreas Kirschbaum + * Make fill and replace work when no cursor is active. + * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird behaviour with *). Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-02 14:37:16 UTC (rev 3638) +++ trunk/daimonin/ChangeLog 2008-03-02 14:54:59 UTC (rev 3639) @@ -1,5 +1,7 @@ 2008-03-02 Andreas Kirschbaum + * Make fill and replace work when no cursor is active. + * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird behaviour with *). Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-03-02 14:37:16 UTC (rev 3638) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-03-02 14:54:59 UTC (rev 3639) @@ -230,7 +230,7 @@ * @param density the fill density in percent; -1 to disable */ public void fill(final MapView<G, A, R, C, V> mapView, final boolean fillBelow, final MapView<G, A, R, C, V> seed, final int density) { - if (!mapView.getView().isHighlight()) { + if (!mapView.getView().hasSelection()) { return; // should actually never happen } Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-03-02 14:37:16 UTC (rev 3638) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-03-02 14:54:59 UTC (rev 3639) @@ -471,7 +471,7 @@ dialog.setVisible(false); ACTION_FACTORY.showMessageDialog(this, "replaceMapGone", mapView.getMapControl().getMapFileName()); return true; - } else if (!entireMap && !mapView.getView().isHighlight()) { + } else if (!entireMap && !mapView.getView().hasSelection()) { // user selected "replace highlighted" but nothing is highlighted ACTION_FACTORY.showMessageDialog(this, "replaceMapNoSelection", mapView.getMapControl().getMapFileName()); return false; Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-03-02 14:37:16 UTC (rev 3638) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-03-02 14:54:59 UTC (rev 3639) @@ -93,14 +93,6 @@ } /** - * Returns whether there is a highlighted area in this mapview. - * @return <code>true</code> if there is a highlighted area, otherwise <code>false</code>. - */ - public boolean isHighlight() { - return mapCursor.isActive(); - } - - /** * Get the cursor position. * The cursor position does not neccessarily mark a selection. * Selection is independent of the cursor. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-02 15:08:05
|
Revision: 3640 http://gridarta.svn.sourceforge.net/gridarta/?rev=3640&view=rev Author: akirschbaum Date: 2008-03-02 07:07:07 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Remove forwarding functions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapActions.java trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -146,7 +146,7 @@ /** {@inheritDoc} */ @Override @Nullable public MapSquare<GameObject, MapArchObject, Archetype> getCursorSquare() { try { - return mapModel.getMapSquare(getCursorPosition()); + return mapModel.getMapSquare(getMapCursor().getLocation()); } catch (final ArrayIndexOutOfBoundsException e) { return null; } Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -428,7 +428,7 @@ return selectedExit.getHead(); } - final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getCursorPosition()); + final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); if (cursorExit != null && CFArchTypeList.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -149,7 +149,7 @@ /** {@inheritDoc} */ @Override @Nullable public MapSquare<GameObject, MapArchObject, Archetype> getCursorSquare() { try { - return mapModel.getMapSquare(getCursorPosition()); + return mapModel.getMapSquare(getMapCursor().getLocation()); } catch (final ArrayIndexOutOfBoundsException e) { return null; } Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -417,7 +417,7 @@ return selectedExit.getHead(); } - final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getCursorPosition()); + final GameObject cursorExit = mapView.getMapControl().getMapModel().getExit(mapView.getView().getMapCursor().getLocation()); if (cursorExit != null && CFArchTypeList.isExitType(cursorExit.getHead()) && cursorExit.getHead().getAttributeString("slaying").length() > 0) { return cursorExit.getHead(); } Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -230,7 +230,7 @@ * @param density the fill density in percent; -1 to disable */ public void fill(final MapView<G, A, R, C, V> mapView, final boolean fillBelow, final MapView<G, A, R, C, V> seed, final int density) { - if (!mapView.getView().hasSelection()) { + if (mapView.getView().getMapGrid().getSelectedRec() == null) { return; // should actually never happen } @@ -262,7 +262,7 @@ */ public void floodfill(@NotNull final MapView<G, A, R, C, V> mapView) { final V mapViewBasic = mapView.getView(); - final Point cursor = mapViewBasic.getCursorPosition(); + final Point cursor = mapViewBasic.getMapCursor().getLocation(); if (cursor == null) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -677,7 +677,7 @@ * otherwise */ @Nullable private MapView<G, A, R, C, V> getSelection() { - return currentMapView != null && currentMapView.getView().hasSelection() ? currentMapView : null; + return currentMapView != null && currentMapView.getView().getMapGrid().getSelectedRec() != null ? currentMapView : null; } /** @@ -685,7 +685,7 @@ * @return the map view if a cursor exists, or <code>null</code> otherwise */ @Nullable private MapView<G, A, R, C, V> getCursor() { - return currentMapView != null && currentMapView.getView().hasCursor() ? currentMapView : null; + return currentMapView != null && currentMapView.getView().getMapCursor().isActive() ? currentMapView : null; } } // class MainActions Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -471,7 +471,7 @@ dialog.setVisible(false); ACTION_FACTORY.showMessageDialog(this, "replaceMapGone", mapView.getMapControl().getMapFileName()); return true; - } else if (!entireMap && !mapView.getView().hasSelection()) { + } else if (!entireMap && mapView.getView().getMapGrid().getSelectedRec() == null) { // user selected "replace highlighted" but nothing is highlighted ACTION_FACTORY.showMessageDialog(this, "replaceMapNoSelection", mapView.getMapControl().getMapFileName()); return false; Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-03-02 14:54:59 UTC (rev 3639) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-03-02 15:07:07 UTC (rev 3640) @@ -85,24 +85,6 @@ } /** - * Returns whether a selection exists. - * @return <code>true</code> if a selection exists, otherwise <code>false</code> - */ - public boolean hasSelection() { - return mapGrid.getSelectedRec() != null; - } - - /** - * Get the cursor position. - * The cursor position does not neccessarily mark a selection. - * Selection is independent of the cursor. - * @return cursor position - */ - @Nullable public Point getCursorPosition() { - return mapCursor.getLocation(); - } - - /** * Get the selection. * @return selection */ @@ -178,16 +160,6 @@ @Nullable public abstract MapSquare<G, A, R> getCursorSquare(); /** - * Determine if this map has an active cursor. - * - * @return <code>true</code> if this map has an active cursor, - * <code>false</code> otherwise - */ - public boolean hasCursor() { - return mapCursor.isActive(); - } - - /** * Register a MapCursorListener. * * @param listener MapCursorListener to register This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-02 15:11:32
|
Revision: 3641 http://gridarta.svn.sourceforge.net/gridarta/?rev=3641&view=rev Author: akirschbaum Date: 2008-03-02 07:11:37 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Move MapViewBasic.getCursorSquare() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-03-02 15:07:07 UTC (rev 3640) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-03-02 15:11:37 UTC (rev 3641) @@ -144,15 +144,6 @@ } /** {@inheritDoc} */ - @Override @Nullable public MapSquare<GameObject, MapArchObject, Archetype> getCursorSquare() { - try { - return mapModel.getMapSquare(getMapCursor().getLocation()); - } catch (final ArrayIndexOutOfBoundsException e) { - return null; - } - } - - /** {@inheritDoc} */ public void mapSizeChanged(final MapModelEvent<GameObject, MapArchObject, Archetype> e) { mapGrid.resize(e.getMapModel().getMapSize()); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-03-02 15:07:07 UTC (rev 3640) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-03-02 15:11:37 UTC (rev 3641) @@ -146,15 +146,6 @@ renderer.removeMouseMotionListener(mapUserListener); } - /** {@inheritDoc} */ - @Override @Nullable public MapSquare<GameObject, MapArchObject, Archetype> getCursorSquare() { - try { - return mapModel.getMapSquare(getMapCursor().getLocation()); - } catch (final ArrayIndexOutOfBoundsException e) { - return null; - } - } - /** Refreshes the data in the view from the model. */ private void refreshDataFromModel() { final Size2D mapSize = mapModel.getMapSize(); Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-03-02 15:07:07 UTC (rev 3640) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-03-02 15:11:37 UTC (rev 3641) @@ -157,7 +157,13 @@ * @return cursor square or <code>null</code> if no current cursor * @see #getCursorPosition() */ - @Nullable public abstract MapSquare<G, A, R> getCursorSquare(); + @Nullable public MapSquare<G, A, R> getCursorSquare() { + try { + return mapModel.getMapSquare(getMapCursor().getLocation()); + } catch (final ArrayIndexOutOfBoundsException e) { + return null; + } + } /** * Register a MapCursorListener. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-02 17:13:33
|
Revision: 3642 http://gridarta.svn.sourceforge.net/gridarta/?rev=3642&view=rev Author: akirschbaum Date: 2008-03-02 09:13:08 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Correctly update selected square view for multi-part objects. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-02 15:11:37 UTC (rev 3641) +++ trunk/crossfire/ChangeLog 2008-03-02 17:13:08 UTC (rev 3642) @@ -1,5 +1,7 @@ 2008-03-02 Andreas Kirschbaum + * Correctly update selected square view for multi-part objects. + * Make fill and replace work when no cursor is active. * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-03-02 15:11:37 UTC (rev 3641) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-03-02 17:13:08 UTC (rev 3642) @@ -78,7 +78,7 @@ } this.animText = animText.intern(); - squareChanged(); + gameObjectChanged(); } /** {@inheritDoc} */ @@ -101,7 +101,7 @@ } this.loreText = trimmedLoreText.intern(); - squareChanged(); + gameObjectChanged(); } /** {@inheritDoc} */ Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-02 15:11:37 UTC (rev 3641) +++ trunk/daimonin/ChangeLog 2008-03-02 17:13:08 UTC (rev 3642) @@ -1,5 +1,7 @@ 2008-03-02 Andreas Kirschbaum + * Correctly update selected square view for multi-part objects. + * Make fill and replace work when no cursor is active. * Remove "cursor" menu from main menu bar. Fixes #1726143 (Weird Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-03-02 15:11:37 UTC (rev 3641) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-03-02 17:13:08 UTC (rev 3642) @@ -159,7 +159,7 @@ } this.faceObjName = newFaceObjName; - squareChanged(); + gameObjectChanged(); } @Nullable public String getFaceObjName() { @@ -274,7 +274,7 @@ } this.animName = newAnimName; - squareChanged(); + gameObjectChanged(); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-03-02 15:11:37 UTC (rev 3641) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-03-02 17:13:08 UTC (rev 3642) @@ -183,7 +183,7 @@ } archType = typNr; - squareChanged(); + gameObjectChanged(); } /** @@ -199,7 +199,7 @@ } this.faceName = newFaceName; - squareChanged(); + gameObjectChanged(); } /** {@inheritDoc} */ @@ -662,7 +662,7 @@ } this.archetype = archetype; - squareChanged(); + gameObjectChanged(); } /** Set that this GameObject is an Archetype. */ @@ -706,7 +706,7 @@ } this.archetypeName = newArchetypeName; - squareChanged(); + gameObjectChanged(); } /** {@inheritDoc} */ @@ -729,7 +729,7 @@ } this.artifact = artifact; - squareChanged(); + gameObjectChanged(); } /** @@ -810,7 +810,7 @@ } this.editType = editType; - squareChanged(); + gameObjectChanged(); } /** Delete message text by nullification. */ @@ -821,7 +821,7 @@ // FIXME, see addMsgText for information msgText = null; - squareChanged(); + gameObjectChanged(); } /** Delete message text by emptying. */ @@ -832,7 +832,7 @@ //noinspection ConstantConditions msgText.delete(0, msgText.length()); - squareChanged(); + gameObjectChanged(); } /** @@ -863,7 +863,7 @@ } if (isChanged) { - squareChanged(); + gameObjectChanged(); } } @@ -1070,7 +1070,7 @@ } this.objName = newObjName; - squareChanged(); + gameObjectChanged(); } /** @@ -1119,7 +1119,7 @@ objectText.append('\n'); } clearAttributeCache(); - squareChanged(); + gameObjectChanged(); } /** Clears the object text of this GameObject. */ @@ -1130,7 +1130,7 @@ objectText.delete(0, objectText.length()); clearAttributeCache(); - squareChanged(); + gameObjectChanged(); } /** @@ -1145,7 +1145,7 @@ resetObjectText(); this.objectText.append(objectText); clearAttributeCache(); - squareChanged(); + gameObjectChanged(); } /** @@ -1372,7 +1372,7 @@ return; } this.direction = direction; - squareChanged(); + gameObjectChanged(); } /** @@ -1440,4 +1440,13 @@ return retErrors; } + /** + * Records that this game object has changed. + */ + protected void gameObjectChanged() { + for (G part = getHead(); part != null; part = part.getMultiNext()) { + part.squareChanged(); + } + } + } // interface GameObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-08 13:16:15
|
Revision: 3674 http://gridarta.svn.sourceforge.net/gridarta/?rev=3674&view=rev Author: akirschbaum Date: 2008-03-08 05:16:17 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Embed .dtd files into Gridarta since these files define the file formats Gridarta understands. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/build.xml trunk/daimonin/ChangeLog trunk/daimonin/build.xml trunk/src/app/net/sf/gridarta/XmlHelper.java Added Paths: ----------- trunk/resource/ trunk/resource/system/ trunk/resource/system/dtd/ trunk/resource/system/dtd/GameObjectMatchers.dtd trunk/resource/system/dtd/TreasureLists.dtd trunk/resource/system/dtd/spells.dtd trunk/resource/system/dtd/types.dtd Removed Paths: ------------- trunk/crossfire/resource/conf/GameObjectMatchers.dtd trunk/crossfire/resource/conf/TreasureLists.dtd Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/crossfire/ChangeLog 2008-03-08 13:16:17 UTC (rev 3674) @@ -1,3 +1,8 @@ +2008-03-08 Andreas Kirschbaum + + * Embed .dtd files into Gridarta since these files define the file + formats Gridarta understands. + 2008-03-05 Andreas Kirschbaum * Add support for "multiply speed" (maxsp) field in geneators. Modified: trunk/crossfire/build.xml =================================================================== --- trunk/crossfire/build.xml 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/crossfire/build.xml 2008-03-08 13:16:17 UTC (rev 3674) @@ -132,6 +132,9 @@ <include name="${resource.dir}/system/**"/> </fileset> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html" /> + <fileset dir="../resource"> + <include name="system/**"/> + </fileset> <zipfileset src="../lib/log4j-1.2.13.jar" /> <zipfileset src="${lib.dir}/jdom.jar" excludes="META-INF/**" /> <zipfileset src="${lib.dir}/bsh-core-2.0b4.jar" excludes="META-INF/**" /> Deleted: trunk/crossfire/resource/conf/GameObjectMatchers.dtd =================================================================== --- trunk/crossfire/resource/conf/GameObjectMatchers.dtd 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/crossfire/resource/conf/GameObjectMatchers.dtd 2008-03-08 13:16:17 UTC (rev 3674) @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<!ENTITY % Match "(And|Or|Attrib|TypeNrs)"> -<!ENTITY % Matches "%Match;+"> - -<!ELEMENT GameObjectMatchers (GameObjectMatcher+)> -<!ELEMENT GameObjectMatcher (title+,%Match;)> -<!ATTLIST GameObjectMatcher - id CDATA #IMPLIED -> - -<!ELEMENT title (#PCDATA)> -<!ATTLIST title - xml:lang CDATA #REQUIRED -> - -<!ELEMENT And (%Matches;)> -<!ELEMENT Or (%Matches;)> - -<!ELEMENT Attrib EMPTY> -<!ATTLIST Attrib - useArchetype (true|false) 'true' - name NMTOKEN #REQUIRED - value CDATA '1' - op (eq|ne|ge|gt|le|lt) 'eq' -> - -<!ELEMENT TypeNrs EMPTY> -<!ATTLIST TypeNrs - numbers CDATA #REQUIRED -> Deleted: trunk/crossfire/resource/conf/TreasureLists.dtd =================================================================== --- trunk/crossfire/resource/conf/TreasureLists.dtd 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/crossfire/resource/conf/TreasureLists.dtd 2008-03-08 13:16:17 UTC (rev 3674) @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<!ELEMENT lists (list*)> - -<!ELEMENT list (entry+)> -<!ATTLIST list - name CDATA #REQUIRED -> - -<!ELEMENT entry (#PCDATA)> -<!ATTLIST entry - name CDATA #REQUIRED -> Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/daimonin/ChangeLog 2008-03-08 13:16:17 UTC (rev 3674) @@ -1,3 +1,8 @@ +2008-03-08 Andreas Kirschbaum + + * Embed .dtd files into Gridarta since these files define the file + formats Gridarta understands. + 2008-03-02 Andreas Kirschbaum * Correctly update selected square view for multi-part objects. Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/daimonin/build.xml 2008-03-08 13:16:17 UTC (rev 3674) @@ -125,6 +125,9 @@ <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties" /> </copy> + <copy todir="${build.dir.production}"> + <fileset dir="../resource" includes="system/**/*.*" /> + </copy> <!--copy file="${arch.dir}/archetypes" todir="${build.dir.production}" /--> <!--copy file="${arch.dir}/daimonin.0" todir="${build.dir.production}" /--> <!--copy file="${arch.dir}/treasures" todir="${build.dir.production}" /--> Added: trunk/resource/system/dtd/GameObjectMatchers.dtd =================================================================== --- trunk/resource/system/dtd/GameObjectMatchers.dtd (rev 0) +++ trunk/resource/system/dtd/GameObjectMatchers.dtd 2008-03-08 13:16:17 UTC (rev 3674) @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!ENTITY % Match "(And|Or|Attrib|TypeNrs)"> +<!ENTITY % Matches "%Match;+"> + +<!ELEMENT GameObjectMatchers (GameObjectMatcher+)> +<!ELEMENT GameObjectMatcher (title+,%Match;)> +<!ATTLIST GameObjectMatcher + id CDATA #IMPLIED +> + +<!ELEMENT title (#PCDATA)> +<!ATTLIST title + xml:lang CDATA #REQUIRED +> + +<!ELEMENT And (%Matches;)> +<!ELEMENT Or (%Matches;)> + +<!ELEMENT Attrib EMPTY> +<!ATTLIST Attrib + useArchetype (true|false) 'true' + name NMTOKEN #REQUIRED + value CDATA '1' + op (eq|ne|ge|gt|le|lt) 'eq' +> + +<!ELEMENT TypeNrs EMPTY> +<!ATTLIST TypeNrs + numbers CDATA #REQUIRED +> Property changes on: trunk/resource/system/dtd/GameObjectMatchers.dtd ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/resource/system/dtd/TreasureLists.dtd =================================================================== --- trunk/resource/system/dtd/TreasureLists.dtd (rev 0) +++ trunk/resource/system/dtd/TreasureLists.dtd 2008-03-08 13:16:17 UTC (rev 3674) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!ELEMENT lists (list*)> + +<!ELEMENT list (entry+)> +<!ATTLIST list + name CDATA #REQUIRED +> + +<!ELEMENT entry (#PCDATA)> +<!ATTLIST entry + name CDATA #REQUIRED +> Property changes on: trunk/resource/system/dtd/TreasureLists.dtd ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/resource/system/dtd/spells.dtd =================================================================== --- trunk/resource/system/dtd/spells.dtd (rev 0) +++ trunk/resource/system/dtd/spells.dtd 2008-03-08 13:16:17 UTC (rev 3674) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Document Type Definition External Subset for Daimonin spells file. +- Author: <a href="mailto:ch...@it...">Christian Hujer</a> +--> + +<!-- spells +- Containts: spell elements (any number) +--> +<!ELEMENT spells (spell*)> + +<!-- spell defines a single spell with its number. +- @id must be a unique number, starting with 0. +- @name must be a string +--> +<!ELEMENT spell EMPTY> +<!ATTLIST spell +id CDATA #REQUIRED +name CDATA #REQUIRED +> Property changes on: trunk/resource/system/dtd/spells.dtd ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd (rev 0) +++ trunk/resource/system/dtd/types.dtd 2008-03-08 13:16:17 UTC (rev 3674) @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- Document Type Definition External Subset for Daimonin type definitions. + - Version: 1.0 + - Public Identifier: -//Daimonin//DTD Types 1.0//EN + - System Identifier: none given + --> + +<!-- The types document root element. --> +<!ELEMENT types ((bitmasks|xi:include), (lists|xi:include), (ignorelists|xi:include), (default_type|xi:include), (type|xi:include)+)> +<!ATTLIST types> + +<!ELEMENT bitmasks (bitmask*)> +<!ATTLIST bitmasks + xml:base CDATA #IMPLIED +> + +<!ELEMENT lists (list*)> +<!ATTLIST lists + xml:base CDATA #IMPLIED +> + +<!ELEMENT ignorelists (ignore_list*)> +<!ATTLIST ignorelists + xml:base CDATA #IMPLIED +> + + +<!ELEMENT bitmask (bmentry+)> +<!ATTLIST bitmask + name CDATA #REQUIRED +> + +<!ELEMENT list (listentry+)> +<!ATTLIST list + name CDATA #REQUIRED +> + +<!ELEMENT listentry EMPTY> +<!ATTLIST listentry + value CDATA #REQUIRED + name CDATA #REQUIRED +> + +<!ELEMENT bmentry EMPTY> +<!ATTLIST bmentry + bit CDATA #REQUIRED + name CDATA #REQUIRED +> + +<!ELEMENT ignore_list (attribute* | EMPTY)> +<!ATTLIST ignore_list + name CDATA #REQUIRED +> + +<!ELEMENT default_type (attribute*)> +<!ATTLIST default_type + xml:base CDATA #IMPLIED +> + +<!ELEMENT type (import_type?,required?,ignore?,description?,use?,(section | attribute)*)> +<!ATTLIST type + xml:base CDATA #IMPLIED + name CDATA #REQUIRED + number CDATA #REQUIRED + available (yes|no) 'yes' +> + +<!ELEMENT description (#PCDATA)> +<!ELEMENT use (#PCDATA)> + +<!ELEMENT import_type EMPTY> +<!ATTLIST import_type + name CDATA #REQUIRED +> + +<!ELEMENT required (attribute+)> +<!ELEMENT ignore (section*,attribute*,ignore_list*)> + +<!ELEMENT section (attribute*)> +<!ATTLIST section + name CDATA #REQUIRED +> + +<!ELEMENT attribute (#PCDATA)> +<!ATTLIST attribute + type CDATA #IMPLIED + arch CDATA #IMPLIED + arch_begin CDATA #IMPLIED + arch_end CDATA #IMPLIED + editor CDATA #IMPLIED + value CDATA #IMPLIED + length CDATA #IMPLIED + true CDATA #IMPLIED + false CDATA #IMPLIED +> + +<!ELEMENT xi:include (xi:fallback?)> +<!ATTLIST xi:include + xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude' + href CDATA #REQUIRED + parse (xml|text) "xml" + encoding CDATA #IMPLIED +> Property changes on: trunk/resource/system/dtd/types.dtd ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/XmlHelper.java =================================================================== --- trunk/src/app/net/sf/gridarta/XmlHelper.java 2008-03-08 09:55:32 UTC (rev 3673) +++ trunk/src/app/net/sf/gridarta/XmlHelper.java 2008-03-08 13:16:17 UTC (rev 3674) @@ -20,13 +20,17 @@ package net.sf.gridarta; import java.awt.Component; +import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; +import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.misc.JSAXErrorHandler; import org.jetbrains.annotations.NotNull; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; /** * Little helper class for XML, holds a {@link DocumentBuilder} and an {@link XPath} that are setup for Gridarta. @@ -57,6 +61,16 @@ dbf.setXIncludeAware(true); documentBuilder = dbf.newDocumentBuilder(); documentBuilder.setErrorHandler(new JSAXErrorHandler(viewToBlock)); + documentBuilder.setEntityResolver(new EntityResolver() { + /** {@inheritDoc} */ + public InputSource resolveEntity(final String publicId, final String systemId) throws IOException { + if (systemId.endsWith(".xml")) { + return null; + } + + return new InputSource(IOUtils.createStream("system/dtd", systemId.replaceAll(".*/", ""))); + } + }); xpath = XPathFactory.newInstance().newXPath(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-08 14:16:10
|
Revision: 3675 http://gridarta.svn.sourceforge.net/gridarta/?rev=3675&view=rev Author: akirschbaum Date: 2008-03-08 06:16:12 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Unify Daimonin and Crossfire types.dtd. Modified Paths: -------------- trunk/crossfire/resource/conf/types.xml trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/CAttribBitmask.java trunk/src/app/net/sf/gridarta/CFArchTypeList.java Modified: trunk/crossfire/resource/conf/types.xml =================================================================== --- trunk/crossfire/resource/conf/types.xml 2008-03-08 13:16:17 UTC (rev 3674) +++ trunk/crossfire/resource/conf/types.xml 2008-03-08 14:16:12 UTC (rev 3675) @@ -75,17 +75,36 @@ ###################################################################### --> <!DOCTYPE types [ - <!ELEMENT types ((bitmask | list | ignore_list)*, default_type, ignore_list*, type+)> + <!ELEMENT types ((bitmasks|xi:include), (lists|xi:include), (ignorelists|xi:include), (default_type|xi:include), (type|xi:include)+)> + <!ATTLIST types> - <!ELEMENT bitmask (entry*)> + <!ELEMENT bitmasks (bitmask*)> + <!ATTLIST bitmasks + xml:base CDATA #IMPLIED> + + <!ELEMENT lists (list*)> + <!ATTLIST lists + xml:base CDATA #IMPLIED> + + <!ELEMENT ignorelists (ignore_list*)> + <!ATTLIST ignorelists + xml:base CDATA #IMPLIED> + + <!ELEMENT bitmask (bmentry+)> <!ATTLIST bitmask name CDATA #REQUIRED is_named (yes|no) "no"> - <!ELEMENT list (entry*)> + <!ELEMENT list (listentry+)> <!ATTLIST list name CDATA #REQUIRED> - <!ELEMENT entry EMPTY> - <!ATTLIST entry bit CDATA #IMPLIED + <!ELEMENT listentry EMPTY> + <!ATTLIST listentry + value CDATA #REQUIRED + name CDATA #REQUIRED> + + <!ELEMENT bmentry EMPTY> + <!ATTLIST bmentry + bit CDATA #IMPLIED value CDATA #IMPLIED name CDATA #REQUIRED encoding CDATA #IMPLIED> @@ -94,10 +113,13 @@ <!ATTLIST ignore_list name CDATA #REQUIRED> <!ELEMENT default_type (attribute*)> + <!ATTLIST default_type xml:base CDATA #IMPLIED> <!ELEMENT type (import_type?,required?,ignore?,description?,use?,(section | attribute)*)> - <!ATTLIST type name CDATA #REQUIRED - number CDATA #REQUIRED> + <!ATTLIST type xml:base CDATA #IMPLIED + name CDATA #REQUIRED + number CDATA #REQUIRED + available (yes|no) 'yes'> <!ELEMENT description (#PCDATA)> <!ELEMENT use (#PCDATA)> @@ -106,9 +128,9 @@ <!ATTLIST import_type name CDATA #REQUIRED> <!ELEMENT required (attribute+)> - <!ELEMENT ignore (attribute*,ignore_list*)> + <!ELEMENT ignore (section*,attribute*,ignore_list*)> - <!ELEMENT section (attribute+)> + <!ELEMENT section (attribute*)> <!ATTLIST section name CDATA #REQUIRED> <!ELEMENT attribute (#PCDATA)> @@ -121,231 +143,287 @@ length CDATA #IMPLIED true CDATA #IMPLIED false CDATA #IMPLIED> + + <!ELEMENT xi:include (xi:fallback?)> + <!ATTLIST xi:include + xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude' + href CDATA #REQUIRED + parse (xml|text) "xml" + encoding CDATA #IMPLIED> ]> <types> <!--###################### bitmask definitions ######################--> -<bitmask name="attacktype"> - <entry bit="0" name="Physical" /> - <entry bit="1" name="Magical" /> - <entry bit="2" name="Fire" /> - <entry bit="3" name="Electricity" /> - <entry bit="4" name="Cold" /> - <entry bit="5" name="Confusion" /> - <entry bit="6" name="Acid" /> - <entry bit="7" name="Drain" /> - <entry bit="8" name="Weaponmagic" /> - <entry bit="9" name="Ghosthit" /> - <entry bit="10" name="Poison" /> - <entry bit="11" name="Slow" /> - <entry bit="12" name="Paralyze" /> - <entry bit="13" name="Turn Undead" /> - <entry bit="14" name="Fear" /> - <entry bit="15" name="Cancellation" /> - <entry bit="16" name="Depletion" /> - <entry bit="17" name="Death" /> - <entry bit="18" name="Chaos" /> - <entry bit="19" name="Counterspell" /> - <entry bit="20" name="God Power" /> - <entry bit="21" name="Holy Power" /> - <entry bit="22" name="Blinding" /> -</bitmask> +<bitmasks> -<bitmask name="material"> - <entry bit="0" name="Paper" /> - <entry bit="1" name="Iron" /> - <entry bit="2" name="Glass" /> - <entry bit="3" name="Leather" /> - <entry bit="4" name="Wood" /> - <entry bit="5" name="Organics" /> - <entry bit="6" name="Stone" /> - <entry bit="7" name="Cloth" /> - <entry bit="8" name="Adamantite" /> -</bitmask> + <bitmask name="attacktype"> + <bmentry bit="0" name="Physical" /> + <bmentry bit="1" name="Magical" /> + <bmentry bit="2" name="Fire" /> + <bmentry bit="3" name="Electricity" /> + <bmentry bit="4" name="Cold" /> + <bmentry bit="5" name="Confusion" /> + <bmentry bit="6" name="Acid" /> + <bmentry bit="7" name="Drain" /> + <bmentry bit="8" name="Weaponmagic" /> + <bmentry bit="9" name="Ghosthit" /> + <bmentry bit="10" name="Poison" /> + <bmentry bit="11" name="Slow" /> + <bmentry bit="12" name="Paralyze" /> + <bmentry bit="13" name="Turn Undead" /> + <bmentry bit="14" name="Fear" /> + <bmentry bit="15" name="Cancellation" /> + <bmentry bit="16" name="Depletion" /> + <bmentry bit="17" name="Death" /> + <bmentry bit="18" name="Chaos" /> + <bmentry bit="19" name="Counterspell" /> + <bmentry bit="20" name="God Power" /> + <bmentry bit="21" name="Holy Power" /> + <bmentry bit="22" name="Blinding" /> + </bitmask> -<bitmask name="spellpath"> - <entry bit="0" name="Protection" /> - <entry bit="1" name="Fire" /> - <entry bit="2" name="Frost" /> - <entry bit="3" name="Electricity" /> - <entry bit="4" name="Missiles" /> - <entry bit="5" name="Self" /> - <entry bit="6" name="Summoning" /> - <entry bit="7" name="Abjuration" /> - <entry bit="8" name="Restoration" /> - <entry bit="9" name="Detonation" /> - <entry bit="10" name="Mind" /> - <entry bit="11" name="Creation" /> - <entry bit="12" name="Teleportation" /> - <entry bit="13" name="Information" /> - <entry bit="14" name="Transmutation" /> - <entry bit="15" name="Transferrence" /> - <entry bit="16" name="Turning" /> - <entry bit="17" name="Wounding" /> - <entry bit="18" name="Death" /> - <entry bit="19" name="Light" /> -</bitmask> + <bitmask name="material"> + <bmentry bit="0" name="Paper" /> + <bmentry bit="1" name="Iron" /> + <bmentry bit="2" name="Glass" /> + <bmentry bit="3" name="Leather" /> + <bmentry bit="4" name="Wood" /> + <bmentry bit="5" name="Organics" /> + <bmentry bit="6" name="Stone" /> + <bmentry bit="7" name="Cloth" /> + <bmentry bit="8" name="Adamantite" /> + </bitmask> -<bitmask name="will_apply"> - <entry bit="0" name="Apply Handles" /> - <entry bit="1" name="Open Chests" /> - <entry bit="2" name="Break Walls" /> - <entry bit="3" name="Open Doors" /> -</bitmask> + <bitmask name="spellpath"> + <bmentry bit="0" name="Protection" /> + <bmentry bit="1" name="Fire" /> + <bmentry bit="2" name="Frost" /> + <bmentry bit="3" name="Electricity" /> + <bmentry bit="4" name="Missiles" /> + <bmentry bit="5" name="Self" /> + <bmentry bit="6" name="Summoning" /> + <bmentry bit="7" name="Abjuration" /> + <bmentry bit="8" name="Restoration" /> + <bmentry bit="9" name="Detonation" /> + <bmentry bit="10" name="Mind" /> + <bmentry bit="11" name="Creation" /> + <bmentry bit="12" name="Teleportation" /> + <bmentry bit="13" name="Information" /> + <bmentry bit="14" name="Transmutation" /> + <bmentry bit="15" name="Transferrence" /> + <bmentry bit="16" name="Turning" /> + <bmentry bit="17" name="Wounding" /> + <bmentry bit="18" name="Death" /> + <bmentry bit="19" name="Light" /> + </bitmask> -<bitmask name="pick_up"> - <entry bit="0" name="Nothing" /> - <entry bit="1" name="Wealth" /> - <entry bit="2" name="Food" /> - <entry bit="3" name="Weapons" /> - <entry bit="4" name="Armor" /> - <entry bit="5" name="Inverse" /> - <entry bit="6" name="All" /> -</bitmask> + <bitmask name="will_apply"> + <bmentry bit="0" name="Apply Handles" /> + <bmentry bit="1" name="Open Chests" /> + <bmentry bit="2" name="Break Walls" /> + <bmentry bit="3" name="Open Doors" /> + </bitmask> -<bitmask name="movement" is_named="yes"> - <entry bit="0" name="Walk" encoding="walk" /> - <entry bit="1" name="Fly low" encoding="fly_low" /> - <entry bit="2" name="Fly high" encoding="fly_high" /> - <entry bit="3" name="Swim" encoding="swim" /> - <entry bit="4" name="Boat" encoding="boat" /> - <entry value="0" name="None" encoding="0" /> - <entry value="6" name="Flying" encoding="flying" /> - <entry value="31" name="All" encoding="all" /> -</bitmask> + <bitmask name="pick_up"> + <bmentry bit="0" name="Nothing" /> + <bmentry bit="1" name="Wealth" /> + <bmentry bit="2" name="Food" /> + <bmentry bit="3" name="Weapons" /> + <bmentry bit="4" name="Armor" /> + <bmentry bit="5" name="Inverse" /> + <bmentry bit="6" name="All" /> + </bitmask> + <bitmask name="movement" is_named="yes"> + <bmentry bit="0" name="Walk" encoding="walk" /> + <bmentry bit="1" name="Fly low" encoding="fly_low" /> + <bmentry bit="2" name="Fly high" encoding="fly_high" /> + <bmentry bit="3" name="Swim" encoding="swim" /> + <bmentry bit="4" name="Boat" encoding="boat" /> + <bmentry value="0" name="None" encoding="0" /> + <bmentry value="6" name="Flying" encoding="flying" /> + <bmentry value="31" name="All" encoding="all" /> + </bitmask> + +</bitmasks> + <!--###################### list definitions ######################--> -<list name="direction"> - <entry value="0" name="<none>" /> - <entry value="1" name="north" /> - <entry value="2" name="northeast" /> - <entry value="3" name="east" /> - <entry value="4" name="southeast" /> - <entry value="5" name="south" /> - <entry value="6" name="southwest" /> - <entry value="7" name="west" /> - <entry value="8" name="northwest" /> -</list> +<lists> -<list name="mood"> - <entry value="0" name="furious" /> - <entry value="1" name="angry" /> - <entry value="2" name="calm" /> - <entry value="3" name="sleep" /> - <entry value="4" name="charm" /> -</list> + <list name="direction"> + <listentry value="0" name="<none>" /> + <listentry value="1" name="north" /> + <listentry value="2" name="northeast" /> + <listentry value="3" name="east" /> + <listentry value="4" name="southeast" /> + <listentry value="5" name="south" /> + <listentry value="6" name="southwest" /> + <listentry value="7" name="west" /> + <listentry value="8" name="northwest" /> + </list> -<list name="potion_effect"> - <entry value="0" name="<none>" /> - <entry value="65536" name="life restoration" /> - <entry value="1048576" name="improvement" /> -</list> + <list name="mood"> + <listentry value="0" name="furious" /> + <listentry value="1" name="angry" /> + <listentry value="2" name="calm" /> + <listentry value="3" name="sleep" /> + <listentry value="4" name="charm" /> + </list> -<list name="weapon_type"> - <entry value="0" name="<unknown>" /> - <entry value="1" name="sword" /> - <entry value="2" name="arrows" /> - <entry value="3" name="axe" /> - <entry value="4" name="katana" /> - <entry value="5" name="knife, dagger" /> - <entry value="6" name="whip, chain" /> - <entry value="7" name="hammer, flail" /> - <entry value="8" name="club, stick" /> -</list> + <list name="potion_effect"> + <listentry value="0" name="<none>" /> + <listentry value="65536" name="life restoration" /> + <listentry value="1048576" name="improvement" /> + </list> -<list name="skill_type"> - <entry value="1" name="lockpicking" /> - <entry value="2" name="hiding" /> - <entry value="3" name="smithery" /> - <entry value="4" name="bowyer" /> - <entry value="5" name="jeweler" /> - <entry value="6" name="alchemy" /> - <entry value="7" name="stealing" /> - <entry value="8" name="literacy" /> - <entry value="9" name="bargaining" /> - <entry value="10" name="jumping" /> - <entry value="11" name="detect magic" /> - <entry value="12" name="oratory" /> - <entry value="13" name="singing" /> - <entry value="14" name="detect curse" /> - <entry value="15" name="find traps" /> - <entry value="16" name="meditation" /> - <entry value="17" name="punching" /> - <entry value="18" name="flame touch" /> - <entry value="19" name="karate" /> - <entry value="20" name="climbing" /> - <entry value="21" name="woodsman" /> - <entry value="22" name="inscription" /> - <entry value="23" name="one handed weapons" /> - <entry value="24" name="missile weapons" /> - <entry value="25" name="throwing" /> - <entry value="26" name="use magic item" /> - <entry value="27" name="disarm traps" /> - <entry value="28" name="set traps" /> - <entry value="29" name="thaumaturgy" /> - <entry value="30" name="praying" /> - <entry value="31" name="clawing" /> - <entry value="32" name="levitation" /> - <entry value="33" name="summoning" /> - <entry value="34" name="pyromancy" /> - <entry value="35" name="evocation" /> - <entry value="36" name="sorcery" /> - <entry value="37" name="two handed weapons" /> -</list> + <list name="weapon_type"> + <listentry value="0" name="<unknown>" /> + <listentry value="1" name="sword" /> + <listentry value="2" name="arrows" /> + <listentry value="3" name="axe" /> + <listentry value="4" name="katana" /> + <listentry value="5" name="knife, dagger" /> + <listentry value="6" name="whip, chain" /> + <listentry value="7" name="hammer, flail" /> + <listentry value="8" name="club, stick" /> + </list> -<list name="spell_type"> - <entry value="1" name="raise dead" /> - <entry value="2" name="rune" /> - <entry value="3" name="make mark" /> - <entry value="4" name="bolt" /> - <entry value="5" name="bullet" /> - <entry value="6" name="explosion" /> - <entry value="7" name="cone" /> - <entry value="8" name="bomb" /> - <entry value="9" name="wonder" /> - <entry value="10" name="smite" /> - <entry value="11" name="magic missile" /> - <entry value="12" name="summon golem" /> - <entry value="13" name="dimension door" /> - <entry value="14" name="magic mapping" /> - <entry value="15" name="magic wall" /> - <entry value="16" name="destruction" /> - <entry value="17" name="perceive self" /> - <entry value="18" name="word of recall" /> - <entry value="19" name="invisible" /> - <entry value="20" name="probe" /> - <entry value="21" name="healing" /> - <entry value="22" name="create food" /> - <entry value="23" name="earth to dust" /> - <entry value="24" name="change ability" /> - <entry value="25" name="bless" /> - <entry value="26" name="curse" /> - <entry value="27" name="summon monster" /> - <entry value="28" name="recharge" /> - <entry value="29" name="polymorph" /> - <entry value="30" name="alchemy" /> - <entry value="31" name="remove curse" /> - <entry value="32" name="identify" /> - <entry value="33" name="detection" /> - <entry value="34" name="mood change" /> - <entry value="35" name="moving ball" /> - <entry value="36" name="swarm" /> - <entry value="37" name="charge mana" /> - <entry value="38" name="dispel rune" /> - <entry value="39" name="create missile" /> - <entry value="40" name="consecrate" /> - <entry value="41" name="animate weapon" /> - <entry value="42" name="light" /> - <entry value="43" name="change map light" /> - <entry value="44" name="faery fire" /> - <entry value="45" name="disease" /> - <entry value="46" name="aura" /> - <entry value="47" name="town portal" /> -</list> + <list name="skill_type"> + <listentry value="1" name="lockpicking" /> + <listentry value="2" name="hiding" /> + <listentry value="3" name="smithery" /> + <listentry value="4" name="bowyer" /> + <listentry value="5" name="jeweler" /> + <listentry value="6" name="alchemy" /> + <listentry value="7" name="stealing" /> + <listentry value="8" name="literacy" /> + <listentry value="9" name="bargaining" /> + <listentry value="10" name="jumping" /> + <listentry value="11" name="detect magic" /> + <listentry value="12" name="oratory" /> + <listentry value="13" name="singing" /> + <listentry value="14" name="detect curse" /> + <listentry value="15" name="find traps" /> + <listentry value="16" name="meditation" /> + <listentry value="17" name="punching" /> + <listentry value="18" name="flame touch" /> + <listentry value="19" name="karate" /> + <listentry value="20" name="climbing" /> + <listentry value="21" name="woodsman" /> + <listentry value="22" name="inscription" /> + <listentry value="23" name="one handed weapons" /> + <listentry value="24" name="missile weapons" /> + <listentry value="25" name="throwing" /> + <listentry value="26" name="use magic item" /> + <listentry value="27" name="disarm traps" /> + <listentry value="28" name="set traps" /> + <listentry value="29" name="thaumaturgy" /> + <listentry value="30" name="praying" /> + <listentry value="31" name="clawing" /> + <listentry value="32" name="levitation" /> + <listentry value="33" name="summoning" /> + <listentry value="34" name="pyromancy" /> + <listentry value="35" name="evocation" /> + <listentry value="36" name="sorcery" /> + <listentry value="37" name="two handed weapons" /> + </list> + <list name="spell_type"> + <listentry value="1" name="raise dead" /> + <listentry value="2" name="rune" /> + <listentry value="3" name="make mark" /> + <listentry value="4" name="bolt" /> + <listentry value="5" name="bullet" /> + <listentry value="6" name="explosion" /> + <listentry value="7" name="cone" /> + <listentry value="8" name="bomb" /> + <listentry value="9" name="wonder" /> + <listentry value="10" name="smite" /> + <listentry value="11" name="magic missile" /> + <listentry value="12" name="summon golem" /> + <listentry value="13" name="dimension door" /> + <listentry value="14" name="magic mapping" /> + <listentry value="15" name="magic wall" /> + <listentry value="16" name="destruction" /> + <listentry value="17" name="perceive self" /> + <listentry value="18" name="word of recall" /> + <listentry value="19" name="invisible" /> + <listentry value="20" name="probe" /> + <listentry value="21" name="healing" /> + <listentry value="22" name="create food" /> + <listentry value="23" name="earth to dust" /> + <listentry value="24" name="change ability" /> + <listentry value="25" name="bless" /> + <listentry value="26" name="curse" /> + <listentry value="27" name="summon monster" /> + <listentry value="28" name="recharge" /> + <listentry value="29" name="polymorph" /> + <listentry value="30" name="alchemy" /> + <listentry value="31" name="remove curse" /> + <listentry value="32" name="identify" /> + <listentry value="33" name="detection" /> + <listentry value="34" name="mood change" /> + <listentry value="35" name="moving ball" /> + <listentry value="36" name="swarm" /> + <listentry value="37" name="charge mana" /> + <listentry value="38" name="dispel rune" /> + <listentry value="39" name="create missile" /> + <listentry value="40" name="consecrate" /> + <listentry value="41" name="animate weapon" /> + <listentry value="42" name="light" /> + <listentry value="43" name="change map light" /> + <listentry value="44" name="faery fire" /> + <listentry value="45" name="disease" /> + <listentry value="46" name="aura" /> + <listentry value="47" name="town portal" /> + </list> + +</lists> + +<ignorelists> + + <!-- This ignorelist is for all system objects which are non pickable + and invisible. They don't interact with players at all. --> + <ignore_list name="system_object"> + <attribute arch="value" /> + <attribute arch="nrof" /> + <attribute arch="weight" /> + <attribute arch="name_pl" /> + <attribute arch="material" /> + <attribute arch="no_pick" /> + <attribute arch="unpaid" /> + <attribute arch="title" /> + <attribute arch="glow_radius" /> + <attribute arch="identified" /> + <attribute arch="blocksview" /> + <attribute arch="invisible" /> + </ignore_list> + + <!-- This ignorelist is for non-pickable objects. They can be seen by + the player, but don't have values like material or weight. --> + <ignore_list name="non_pickable"> + <attribute arch="value" /> + <attribute arch="nrof" /> + <attribute arch="weight" /> + <attribute arch="name_pl" /> + <attribute arch="material" /> + <attribute arch="no_pick" /> + <attribute arch="unpaid" /> + <attribute arch="title" /> + <attribute arch="identified" /> + </ignore_list> + + <!-- This ignorelist is for event objects. --> + <ignore_list name="event_object"> + <attribute arch="name" /> + <attribute arch="face" /> + </ignore_list> + +</ignorelists> + <!--###################### default attributes ######################--> <!-- @@ -432,43 +510,6 @@ </attribute> </default_type> -<!-- This ignorelist is for all system objects which are non pickable - and invisible. They don't interact with players at all. --> -<ignore_list name="system_object"> - <attribute arch="value" /> - <attribute arch="nrof" /> - <attribute arch="weight" /> - <attribute arch="name_pl" /> - <attribute arch="material" /> - <attribute arch="no_pick" /> - <attribute arch="unpaid" /> - <attribute arch="title" /> - <attribute arch="glow_radius" /> - <attribute arch="identified" /> - <attribute arch="blocksview" /> - <attribute arch="invisible" /> -</ignore_list> - -<!-- This ignorelist is for non-pickable objects. They can be seen by - the player, but don't have values like material or weight. --> -<ignore_list name="non_pickable"> - <attribute arch="value" /> - <attribute arch="nrof" /> - <attribute arch="weight" /> - <attribute arch="name_pl" /> - <attribute arch="material" /> - <attribute arch="no_pick" /> - <attribute arch="unpaid" /> - <attribute arch="title" /> - <attribute arch="identified" /> -</ignore_list> - -<!-- This ignorelist is for event objects. --> -<ignore_list name="event_object"> - <attribute arch="name" /> - <attribute arch="face" /> -</ignore_list> - <!--####################################################################--> <type number="0" name="Misc"> <required> Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2008-03-08 13:16:17 UTC (rev 3674) +++ trunk/resource/system/dtd/types.dtd 2008-03-08 14:16:12 UTC (rev 3675) @@ -1,11 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Document Type Definition External Subset for Daimonin type definitions. - - Version: 1.0 - - Public Identifier: -//Daimonin//DTD Types 1.0//EN - - System Identifier: none given - --> - <!-- The types document root element. --> <!ELEMENT types ((bitmasks|xi:include), (lists|xi:include), (ignorelists|xi:include), (default_type|xi:include), (type|xi:include)+)> <!ATTLIST types> @@ -25,10 +19,10 @@ xml:base CDATA #IMPLIED > - <!ELEMENT bitmask (bmentry+)> <!ATTLIST bitmask name CDATA #REQUIRED + is_named (yes|no) "no" > <!ELEMENT list (listentry+)> @@ -44,8 +38,10 @@ <!ELEMENT bmentry EMPTY> <!ATTLIST bmentry - bit CDATA #REQUIRED + bit CDATA #IMPLIED + value CDATA #IMPLIED name CDATA #REQUIRED + encoding CDATA #IMPLIED > <!ELEMENT ignore_list (attribute* | EMPTY)> Modified: trunk/src/app/net/sf/gridarta/CAttribBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/CAttribBitmask.java 2008-03-08 13:16:17 UTC (rev 3674) +++ trunk/src/app/net/sf/gridarta/CAttribBitmask.java 2008-03-08 14:16:12 UTC (rev 3675) @@ -94,7 +94,7 @@ * @throws XPathExpressionException in case of XPath evaluation errors */ public CAttribBitmask(final XPath xpath, final Element bitmasksElement) throws XPathExpressionException { - final NodeListIterator<Element> entries = new NodeListIterator<Element>(xpath, bitmasksElement, "bmentry|entry"); + final NodeListIterator<Element> entries = new NodeListIterator<Element>(xpath, bitmasksElement, "bmentry"); isNamed = bitmasksElement.getAttribute("is_named").equals("yes"); final String[] tmp = new String[32]; int bitValues = 0; Modified: trunk/src/app/net/sf/gridarta/CFArchTypeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2008-03-08 13:16:17 UTC (rev 3674) +++ trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2008-03-08 14:16:12 UTC (rev 3675) @@ -242,13 +242,13 @@ } private void parseBitmasks(final Element root) throws XPathExpressionException { - for (final Element elem : new NodeListIterator<Element>(xpath, root, "bitmask|bitmasks/bitmask")) { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "bitmasks/bitmask")) { bitmaskTable.put(elem.getAttribute("name"), new CAttribBitmask(xpath, elem)); } } private void parseLists(final Element root) throws XPathExpressionException { - for (final Element elem : new NodeListIterator<Element>(xpath, root, "list|lists/list")) { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "lists/list")) { if (elem.getAttribute("name") == null) { throw new RuntimeException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); } else { @@ -270,7 +270,7 @@ private List<?> parseListFromElement(final Element root) throws XPathExpressionException { // XXX The list created here contains altering types: Integer for even, String for odd indices. final List<Object> list = new ArrayList<Object>(); - for (final Element elem : new NodeListIterator<Element>(xpath, root, "entry|listentry")) { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "listentry")) { // every list entry adds value (Integer) and name (String) to the vector try { list.add(Integer.valueOf(elem.getAttribute("value"))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-08 19:42:31
|
Revision: 3678 http://gridarta.svn.sourceforge.net/gridarta/?rev=3678&view=rev Author: akirschbaum Date: 2008-03-08 11:42:35 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Add support for text highlighting in game object attributes dialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java trunk/resource/system/dtd/types.dtd trunk/src/app/net/sf/gridarta/CFArchAttrib.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-03-08 19:39:44 UTC (rev 3677) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-03-08 19:42:35 UTC (rev 3678) @@ -31,7 +31,6 @@ import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFormattedTextField; -import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.text.JTextComponent; import net.sf.gridarta.CFArchAttrib; @@ -45,6 +44,7 @@ import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -370,8 +370,8 @@ break; case TEXT: { // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JTextArea>) attr).getInput().getText().trim(); + if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { + newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); } } break; Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-03-08 19:39:44 UTC (rev 3677) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesDialog.java 2008-03-08 19:42:35 UTC (rev 3678) @@ -45,6 +45,7 @@ import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -359,8 +360,8 @@ break; case TEXT: { // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JTextArea>) attr).getInput().getText().trim(); + if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { + newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); } } break; Modified: trunk/resource/system/dtd/types.dtd =================================================================== --- trunk/resource/system/dtd/types.dtd 2008-03-08 19:39:44 UTC (rev 3677) +++ trunk/resource/system/dtd/types.dtd 2008-03-08 19:42:35 UTC (rev 3678) @@ -89,6 +89,7 @@ length CDATA #IMPLIED true CDATA #IMPLIED false CDATA #IMPLIED + marker CDATA #IMPLIED > <!ELEMENT xi:include (xi:fallback?)> Modified: trunk/src/app/net/sf/gridarta/CFArchAttrib.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchAttrib.java 2008-03-08 19:39:44 UTC (rev 3677) +++ trunk/src/app/net/sf/gridarta/CFArchAttrib.java 2008-03-08 19:42:35 UTC (rev 3678) @@ -84,6 +84,7 @@ // ArchAttribType.BOOL_SPEC uses misc[0] = true value, misc[1] = false value // ArchAttribType.BITMASK uses misc[0] = bitmask name // ArchAttribType.LIST uses misc[0] = list name + // ArchAttribType.TEXT uses misc[0] = file extension; may be null /** Identifier of the section this CFArchAttrib is in. */ private int secId; @@ -189,6 +190,11 @@ log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has text attribute missing '" + XML_KEY_ARCH_BEGIN + "' or '" + XML_KEY_ARCH_END + "'."); return false; } + + misc = new String[1]; + if ((a1 = root.getAttributeNode("marker")) != null) { + misc[0] = a1.getValue().trim(); // file extension + } } else if ("fixed".equalsIgnoreCase(atype)) { // fixed attribute dataType = ArchAttribType.FIXED; Modified: trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-03-08 19:39:44 UTC (rev 3677) +++ trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java 2008-03-08 19:42:35 UTC (rev 3678) @@ -95,6 +95,9 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.textedit.textarea.JEditTextArea; +import net.sf.gridarta.textedit.textarea.SyntaxDocument; +import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -501,15 +504,14 @@ text = gameObject.getMsgText(); } } - final JTextArea input = new JTextArea(text, 10, 20); + final JEditTextArea input = new JEditTextArea(); + input.setDocument(new SyntaxDocument()); + input.getDocument().setTokenMarker(TokenMarkerFactory.createTokenMarker(attrib.getMisc()[0])); + input.setText(text); input.setBorder(BorderFactory.createEmptyBorder(3, 7, 0, 0)); - input.setLineWrap(true); - final JScrollPane scrollPane = new JScrollPane(input); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - newAttr = new DialogAttrib<JTextArea>(attrib, input); - cGlue = scrollPane; + input.getPainter().setInvalidLinesPainted(false); + newAttr = new DialogAttrib<JEditTextArea>(attrib, input); + cGlue = input; } break; case BOOL: Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2008-03-08 19:39:44 UTC (rev 3677) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2008-03-08 19:42:35 UTC (rev 3678) @@ -38,17 +38,17 @@ */ private static final Map<String, Class<? extends TokenMarker>> tokenMarkers = new HashMap<String, Class<? extends TokenMarker>>(); static { - tokenMarkers.put(".c", CTokenMarker.class); - tokenMarkers.put(".cc", CTokenMarker.class); - tokenMarkers.put(".cpp", CTokenMarker.class); - tokenMarkers.put(".h", CTokenMarker.class); - tokenMarkers.put(".hh", CTokenMarker.class); - tokenMarkers.put(".htm", HTMLTokenMarker.class); - tokenMarkers.put(".html", HTMLTokenMarker.class); - tokenMarkers.put(".js", JavaScriptTokenMarker.class); - tokenMarkers.put(".lua", LuaTokenMarker.class); - tokenMarkers.put(".py", PythonTokenMarker.class); - tokenMarkers.put(".xml", XMLTokenMarker.class); + tokenMarkers.put("c", CTokenMarker.class); + tokenMarkers.put("cc", CTokenMarker.class); + tokenMarkers.put("cpp", CTokenMarker.class); + tokenMarkers.put("h", CTokenMarker.class); + tokenMarkers.put("hh", CTokenMarker.class); + tokenMarkers.put("htm", HTMLTokenMarker.class); + tokenMarkers.put("html", HTMLTokenMarker.class); + tokenMarkers.put("js", JavaScriptTokenMarker.class); + tokenMarkers.put("lua", LuaTokenMarker.class); + tokenMarkers.put("py", PythonTokenMarker.class); + tokenMarkers.put("xml", XMLTokenMarker.class); } /** @@ -74,7 +74,20 @@ if (dotIndex == -1) { return new EmptyTokenMarker(); } - final Class<? extends TokenMarker> class_ = tokenMarkers.get(filename.substring(dotIndex)); + return createTokenMarker(filename.substring(dotIndex + 1)); + } + + /** + * Creates a {@link TokenMarker} for a given file extension. + * @param extension the file extension + * @return the token marker + */ + @NotNull public static TokenMarker createTokenMarker(@Nullable final String extension) { + if (extension == null) { + return new EmptyTokenMarker(); + } + + final Class<? extends TokenMarker> class_ = tokenMarkers.get(extension); if (class_ == null) { return new EmptyTokenMarker(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-08 23:31:28
|
Revision: 3679 http://gridarta.svn.sourceforge.net/gridarta/?rev=3679&view=rev Author: akirschbaum Date: 2008-03-08 15:30:47 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Add syntax highlighting for AI objects. Modified Paths: -------------- trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-03-08 19:42:35 UTC (rev 3678) +++ trunk/daimonin/ChangeLog 2008-03-08 23:30:47 UTC (rev 3679) @@ -1,3 +1,7 @@ +2008-03-09 Andreas Kirschbaum + + * Add syntax highlighting for AI objects. + 2008-03-08 Andreas Kirschbaum * Embed .dtd files into Gridarta since these files define the file Added: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java (rev 0) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java 2008-03-08 23:30:47 UTC (rev 3679) @@ -0,0 +1,337 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.textedit.textarea.tokenmarker; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import javax.swing.text.Segment; +import net.sf.gridarta.textedit.textarea.Token; + +/** + * A {@link TokenMarker} for the message field of Daimonin AI objects. + * @author Andreas Kirschbaum + */ +public class DaimoninAITokenMarker extends TokenMarker { + + /** + * Commands having a fixed command name. Maps command name to command + * specification. + */ + private static final Map<String, Spec> fixedSpecs = new HashMap<String, Spec>(); + + /** + * Commands having variable command names. Maps command name to command + * specification. + */ + private static final Map<Pattern, Spec> regexSpecs = new HashMap<Pattern, Spec>(); + + static { + fixedSpecs.put("actions:", new Spec(Token.LABEL)); + fixedSpecs.put("moves:", new Spec(Token.LABEL)); + fixedSpecs.put("processes:", new Spec(Token.LABEL)); + fixedSpecs.put("bow_attack_enemy", new Spec(Token.KEYWORD1)); + fixedSpecs.put("choose_enemy", new Spec(Token.KEYWORD1, + new Parameter("antilure_distance", Token.KEYWORD2, ParameterType.INTEGER))); + fixedSpecs.put("dont_stand_still", new Spec(Token.KEYWORD1, + new Parameter("max_idle_time", Token.KEYWORD2, ParameterType.INTEGER))); + fixedSpecs.put("friendship", new Spec(Token.KEYWORD1, + new Parameter("group", Token.KEYWORD2, ParameterType.STRING_INTEGER), + new Parameter("name", Token.KEYWORD2, ParameterType.STRING_INTEGER), + new Parameter("player", Token.KEYWORD2, ParameterType.INTEGER), + new Parameter("race", Token.KEYWORD2, ParameterType.STRING_INTEGER))); + fixedSpecs.put("groups", new Spec(Token.KEYWORD1, + new Parameter("name", Token.KEYWORD2, ParameterType.STRING))); + fixedSpecs.put("heal_friend", new Spec(Token.KEYWORD1, + new Parameter("healing_min_friendship", Token.KEYWORD2, ParameterType.INTEGER))); + fixedSpecs.put("look_for_other_mobs", new Spec(Token.KEYWORD1)); + regexSpecs.put(Pattern.compile("lua:.*"), new Spec(Token.KEYWORD1)); + fixedSpecs.put("melee_attack_enemy", new Spec(Token.KEYWORD1)); + fixedSpecs.put("move_randomly", new Spec(Token.KEYWORD1, + new Parameter("xlimit", Token.KEYWORD2, ParameterType.INTEGER), + new Parameter("ylimit", Token.KEYWORD2, ParameterType.INTEGER))); + fixedSpecs.put("move_towards_enemy", new Spec(Token.KEYWORD1)); + fixedSpecs.put("move_towards_enemy_last_known_pos", new Spec(Token.KEYWORD1)); + fixedSpecs.put("move_towards_home", new Spec(Token.KEYWORD1)); + fixedSpecs.put("move_towards_waypoint", new Spec(Token.KEYWORD1)); + fixedSpecs.put("run_away_from_enemy", new Spec(Token.KEYWORD1, + new Parameter("hp_threshold", Token.KEYWORD2, ParameterType.INTEGER))); + fixedSpecs.put("search_for_lost_enemy", new Spec(Token.KEYWORD1)); + fixedSpecs.put("sleep", new Spec(Token.KEYWORD1)); + fixedSpecs.put("spell_attack_enemy", new Spec(Token.KEYWORD1)); + fixedSpecs.put("stand_still", new Spec(Token.KEYWORD1)); + } + + /** + * Describes a command (excluding the command name). + */ + private static class Spec { + + /** + * The {@link Token} id used to highlight this command. + */ + private final byte id; + + /** + * Maps parameter name to parameter specification. + */ + private final Map<String, Parameter> parameters = new HashMap<String, Parameter>(); + + /** + * Creates a new instance. + * @param id the token id used to highlight this command + * @param parameters the possible parameters of this command + */ + public Spec(final byte id, final Parameter... parameters) { + this.id = id; + for (final Parameter parameter : parameters) { + if (this.parameters.put(parameter.getName(), parameter) != null) { + throw new IllegalArgumentException("duplicate parameter name: " + parameter.getName()); + } + } + } + + /** + * Returns the {@link Token} id used to highlight this command. + * @return the token id + */ + public byte getId() { + return id; + } + + /** + * Returns the parameter specification for a parameter name. + * @param name the parameter name + * @return the parameter specification, or <code>null</code> if the + * parameter name is invalid for this command + */ + public Parameter getParameter(final String name) { + return parameters.get(name); + } + + } // class Spec + + /** + * Describes a parameter. + */ + private static class Parameter { + + /** + * The parameter name. + */ + private final String name; + + /** + * The {@link Token} id used to highlight the parameter name. + */ + private final byte id; + + /** + * The parameter type for the value of this parameter. + */ + private final ParameterType parameterType; + + /** + * Creates a new instance. + * @param name the parameter name + * @param id the token id used to highligh the parameter name + * @param parameterType the parameter type for the value of this + * parameter + */ + public Parameter(final String name, final byte id, final ParameterType parameterType) { + this.name = name; + this.id = id; + this.parameterType = parameterType; + } + + /** + * Returns the parameter name. + * @return the parameter name + */ + public String getName() { + return name; + } + + /** + * Returns the {@link Token} id used to highlight the parameter name. + * @return the token id + */ + public byte getId() { + return id; + } + + /** + * Returns the parameter type for the value of this parameter. + * @return the parameter type + */ + public ParameterType getParameterType() { + return parameterType; + } + + } // class Parameter + + /** + * Describes a parameter type. + */ + private static enum ParameterType { + + /** Integer parameter. */ + INTEGER("[0-9]+"), + + /** String parameter. */ + STRING("[a-zA-Z_][a-zA-Z_0-9]*"), + + /** String/Integer list parameter. */ + STRING_INTEGER("[a-zA-Z_][a-zA-Z_0-9]*:[-+]?[0-9]+(,[a-zA-Z_][a-zA-Z_0-9]*:[-+]?[0-9]+)*"); + + /** + * The pattern matching valid parameter values. + */ + private final Pattern pattern; + + /** + * Creates a new instance. + * @param regex a regular expression matching valid parameter values + */ + private ParameterType(final String regex) { + pattern = Pattern.compile(regex); + } + + /** + * Returns the pattern matching valid parameter values. + * @return the pattern + */ + public Pattern getPattern() { + return pattern; + } + + } // enum ParameterType + + /** + * Creates a new instance. + */ + public DaimoninAITokenMarker() { + } + + /** {@inheritDoc} */ + @Override public final byte markTokensImpl(byte token, final Segment line, final int lineIndex) { + final char[] array = line.array; + int offset = line.offset; + final int end = line.count + offset; + if (offset >= end) { + // empty line ==> mark nothing + } else if (array[offset] == '#') { + // comment line + addToken(line.count, Token.COMMENT1); + } else if (array[offset] == ' ') { + // syntax error + addToken(line.count, Token.INVALID); + } else { + // normal line + + // 1. parse line into segments + + // Collects parsed segments: command, space, parameter, space, + // parameter, space, ... + final List<Integer> segments = new ArrayList<Integer>(); + + while (offset < end) { + final int commandStart = offset; + while (offset < end && array[offset] != ' ') { + offset++; + } + segments.add(offset - commandStart); + + final int spacesStart = offset; + while (offset < end && array[offset] == ' ') { + offset++; + } + segments.add(offset - spacesStart); + } + + // 2. create tokens + final Iterator<Integer> it = segments.iterator(); + offset = line.offset; + + final int commandLength = it.next(); + final String command = new String(array, offset, commandLength); + final Spec spec = getSpec(command); + addToken(commandLength, spec != null ? spec.getId() : Token.INVALID); + offset += commandLength; + + final int spacesLength1 = it.next(); + addToken(spacesLength1, Token.NULL); + offset += spacesLength1; + + while (it.hasNext()) { + final int paramLength = it.next(); + final String[] tmp = new String(array, offset, paramLength).split("=", 2); + if (tmp.length != 2) { + // missing '=' sign ==> syntax error + addToken(paramLength, Token.INVALID); + } else { + final String param = tmp[0]; + final String arg = tmp[1]; + + final Parameter parameter = spec != null ? spec.getParameter(param) : null; + final boolean parameterValid = parameter != null; + final boolean valueValid = parameter == null || parameter.getParameterType().getPattern().matcher(arg).matches(); + addToken(param.length(), parameterValid ? parameter.getId() : Token.INVALID); + addToken(1, (param.length() == 0 && !parameterValid) || (arg.length() == 0 && !valueValid) ? Token.INVALID : Token.OPERATOR); + addToken(arg.length(), valueValid ? Token.NULL : Token.INVALID); + } + offset += paramLength; + + final int spacesLength2 = it.next(); + addToken(spacesLength2, Token.NULL); + offset += spacesLength2; + } + } + + return Token.NULL; + } + + /** + * Returns the command specification from a command name. + * @param command the command name + * @return the command specification, or <code>null</code> if the command + * name is undefined. + */ + private Spec getSpec(final String command) { + final Spec fixedSpec = fixedSpecs.get(command); + if (fixedSpec != null) { + return fixedSpec; + } + + for (final Map.Entry<Pattern, Spec> entry : regexSpecs.entrySet()) { + if (entry.getKey().matcher(command).matches()) { + return entry.getValue(); + } + } + + return null; + } + +} // class DaimoninAITokenMarker Property changes on: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/DaimoninAITokenMarker.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2008-03-08 19:42:35 UTC (rev 3678) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2008-03-08 23:30:47 UTC (rev 3679) @@ -34,6 +34,11 @@ public class TokenMarkerFactory { /** + * File extension for {@link DaimoninAITokenMarkerTokenMarkerFactory}. + */ + public static final String DAIMONIN_AI = "daimonin-ai"; + + /** * Maps file extensions to token marker classes. */ private static final Map<String, Class<? extends TokenMarker>> tokenMarkers = new HashMap<String, Class<? extends TokenMarker>>(); @@ -49,6 +54,7 @@ tokenMarkers.put("lua", LuaTokenMarker.class); tokenMarkers.put("py", PythonTokenMarker.class); tokenMarkers.put("xml", XMLTokenMarker.class); + tokenMarkers.put(DAIMONIN_AI, DaimoninAITokenMarker.class); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-09 00:38:36
|
Revision: 3680 http://gridarta.svn.sourceforge.net/gridarta/?rev=3680&view=rev Author: akirschbaum Date: 2008-03-08 16:38:40 -0800 (Sat, 08 Mar 2008) Log Message: ----------- Add syntax highlighting for message texts allowing @match. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/conf/types.xml trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/CrossfireDialogTokenMarker.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-03-08 23:30:47 UTC (rev 3679) +++ trunk/crossfire/ChangeLog 2008-03-09 00:38:40 UTC (rev 3680) @@ -1,3 +1,7 @@ +2008-03-09 Andreas Kirschbaum + + * Add syntax highlighting for message texts allowing @match. + 2008-03-08 Andreas Kirschbaum * Embed .dtd files into Gridarta since these files define the file Modified: trunk/crossfire/resource/conf/types.xml =================================================================== --- trunk/crossfire/resource/conf/types.xml 2008-03-08 23:30:47 UTC (rev 3679) +++ trunk/crossfire/resource/conf/types.xml 2008-03-09 00:38:40 UTC (rev 3680) @@ -2638,7 +2638,7 @@ The Magic_ear will trigger all objects with the same connection value, every time it is activated. </attribute> - <attribute arch_begin="msg" arch_end="endmsg" editor="keyword-matching" type="text"> + <attribute arch_begin="msg" arch_end="endmsg" editor="keyword-matching" type="text" marker="crossfire-dialog"> This text field contains the keyword-matching-syntax. The text should have the following format: "@match <keyword1>|<keyword2>|... ". Any number of keywords from one to infinite is allowed. Make sure @@ -3280,7 +3280,7 @@ <attribute arch="resist_godpower" editor="resist godpower %" length="15" type="int"> </attribute> </section> - <attribute arch_begin="msg" arch_end="endmsg" editor="npc message" type="text"> + <attribute arch_begin="msg" arch_end="endmsg" editor="npc message" type="text" marker="crossfire-dialog"> </attribute> </type> Added: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/CrossfireDialogTokenMarker.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/CrossfireDialogTokenMarker.java (rev 0) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/CrossfireDialogTokenMarker.java 2008-03-09 00:38:40 UTC (rev 3680) @@ -0,0 +1,77 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.textedit.textarea.tokenmarker; + +import javax.swing.text.Segment; +import net.sf.gridarta.textedit.textarea.Token; + +/** + * A {@link TokenMarker} for the message field of Crossfire objects + * allowing @match. + * @author Andreas Kirschbaum + */ +public class CrossfireDialogTokenMarker extends TokenMarker { + + /** + * Creates a new instance. + */ + public CrossfireDialogTokenMarker() { + } + + /** {@inheritDoc} */ + @Override public final byte markTokensImpl(byte token, final Segment line, final int lineIndex) { + final char[] array = line.array; + final int offset = line.offset; + final int length = line.count; + if (length >= 7 + && array[offset+0] == '@' + && array[offset+1] == 'm' + && array[offset+2] == 'a' + && array[offset+3] == 't' + && array[offset+4] == 'c' + && array[offset+5] == 'h' + && array[offset+6] == ' ') { + addToken(6, Token.KEYWORD1); + int start = offset + 6; + byte id = Token.NULL; + for (int i = start + 1; i < offset + length; i++) { + final byte thisId; + if (array[i] == '|') { + thisId = Token.OPERATOR; + } else if (Character.isUpperCase(array[i])) { + thisId = Token.INVALID; + } else { + thisId = Token.LITERAL1; + } + if (thisId != id) { + addToken(i - start, id); + start = i; + id = thisId; + } + } + addToken(offset + length - start, id); + } else { + addToken(length, Token.NULL); + } + + return Token.NULL; + } + +} // class CrossfireDialogTokenMarker Property changes on: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/CrossfireDialogTokenMarker.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2008-03-08 23:30:47 UTC (rev 3679) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2008-03-09 00:38:40 UTC (rev 3680) @@ -34,6 +34,11 @@ public class TokenMarkerFactory { /** + * File extension for {@link CrossfireDialogTokenMarkerTokenMarker}. + */ + public static final String CROSSFIRE_DIALOG = "crossfire-dialog"; + + /** * File extension for {@link DaimoninAITokenMarkerTokenMarkerFactory}. */ public static final String DAIMONIN_AI = "daimonin-ai"; @@ -54,6 +59,7 @@ tokenMarkers.put("lua", LuaTokenMarker.class); tokenMarkers.put("py", PythonTokenMarker.class); tokenMarkers.put("xml", XMLTokenMarker.class); + tokenMarkers.put(CROSSFIRE_DIALOG, CrossfireDialogTokenMarker.class); tokenMarkers.put(DAIMONIN_AI, DaimoninAITokenMarker.class); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-14 20:20:17
|
Revision: 3687 http://gridarta.svn.sourceforge.net/gridarta/?rev=3687&view=rev Author: akirschbaum Date: 2008-03-14 13:18:18 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-12 21:07:12 UTC (rev 3686) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-14 20:18:18 UTC (rev 3687) @@ -270,7 +270,7 @@ // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); - // Initialise the main view + // Initialize the main view mainView.init(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); @@ -728,7 +728,7 @@ /** * Load a list of map files. - * @param filenames collection of filenamess to load + * @param filenames collection of filenames to load */ public void openFiles(final Iterable<String> filenames) { for (final String filename : filenames) { @@ -963,7 +963,7 @@ } /** - * Load all system tile icons into temporare variables for more convenient + * Load all system tile icons into temporary variables for more convenient * access. */ private static void loadDefTiles() { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-12 21:07:12 UTC (rev 3686) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-14 20:18:18 UTC (rev 3687) @@ -326,7 +326,7 @@ // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); - // Initialise the main view + // Initialize the main view mainView.init(); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); @@ -533,7 +533,7 @@ } /** - * Wether to use double display like the client with walls. + * Whether to use double display like the client with walls. * @return <code>true</code> if double display should be used, otherwise <code>false</code> */ public boolean isDrawDouble() { @@ -868,7 +868,7 @@ /** * Load a list of map files. - * @param filenames collection of filenamess to load + * @param filenames collection of filenames to load */ public void openFiles(final Iterable<String> filenames) { for (final String filename : filenames) { @@ -1113,7 +1113,7 @@ } /** - * Load all system tile icons into temporare variables for more convenient + * Load all system tile icons into temporary variables for more convenient * access. */ private static void loadDefTiles() { Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-12 21:07:12 UTC (rev 3686) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-03-14 20:18:18 UTC (rev 3687) @@ -77,7 +77,7 @@ protected File currentDir; /** - * Indicates weither the user has ever changed the active directory since + * Indicates whether the user has ever changed the active directory since * the program started. */ protected boolean hasChangedDir = false; @@ -95,7 +95,8 @@ currentDir = new File(System.getProperty("user.dir")); } - /** Returns the current implementation. + /** + * Returns the current implementation. * @return The current implementation. */ public static MainControl getInstance() { @@ -107,7 +108,8 @@ return gridartaObjectsFactory; } - /** Sets the current instance. + /** + * Sets the current instance. * @param instance Current instance */ private static void setInstance(final MainControl instance) { @@ -156,7 +158,7 @@ } /** - * Creaet the cache instance for map images. + * Create the cache instance for map images. * * @param baseDir The base directory to store the cached files. * Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-12 21:07:12 UTC (rev 3686) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-14 20:18:18 UTC (rev 3687) @@ -185,14 +185,14 @@ int getEditType(); /** - * Set the mapiew to show tiles of the given type. + * Set the map view to show tiles of the given type. * (If no edit type is set, everything is displayed) * @param editType edit type bitmask of types to show */ void setEditType(int editType); /** - * Set the mapiew to hide tiles of the given type. + * Set the map view to hide tiles of the given type. * (If no edit type is set, everything is displayed) * @param editType edit type bitmask of types to hide */ @@ -241,7 +241,6 @@ /** * Return the map preview accessory. - * * @return the map preview accessory */ MapPreviewAccessory getMapPreviewAccessory(); @@ -297,7 +296,7 @@ /** * Check a map. - * @param map map to check + * @param map the map to check */ void validateMap(final MapModel<G, A, R> map); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-03-14 21:02:44
|
Revision: 3688 http://gridarta.svn.sourceforge.net/gridarta/?rev=3688&view=rev Author: akirschbaum Date: 2008-03-14 14:02:06 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CFilterControl.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CResourceLoader.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/DaimoninEditor.java trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java trunk/src/app/net/sf/gridarta/CFArchType.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/DuplicateAnimationException.java trunk/src/app/net/sf/gridarta/gameobject/face/DuplicateFaceException.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -43,7 +43,7 @@ /** * Main class, launches the level editor application. * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public final class CFJavaEditor { Modified: trunk/crossfire/src/cfeditor/CFilterControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CFilterControl.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/crossfire/src/cfeditor/CFilterControl.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -39,10 +39,10 @@ * Control to check if * 1) a specific GameObject can be shown (filter out of view part) * 2) a specific MapSquare must be highlighted (analysis part) - * It provides onyl one filterOut path (and so elements elements are visbile + * It provides only one filterOut path (and so elements are visible * or not, they can't be twice visible or such). * It provides 3 highlight paths. each of them can be (dis)enabled. - * So you can, eg, highlight walls in a specific color, teleporters in another + * So you can, e.g., highlight walls in a specific color, teleporters in another * and monsters in a third. * highlight and filterOut filters works all the same. You can activate specific * predefined filters or you can provide your own Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -117,7 +117,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> * @author Andreas Kirschbaum - * @fixme I'm 2200 lines long, therefor I suck. + * @fixme I'm 2200 lines long, therefore I suck. */ public final class CMainControl extends AbstractMainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> implements ThrowableHandler<Throwable> { Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -139,7 +139,7 @@ } /** - * Initialises (builds) this view. + * Initializes (builds) this view. */ void init() { final JPanel toolbarPanel = new JPanel(new BorderLayout()); @@ -534,7 +534,7 @@ } /** - * Enabled/disable the menu entries according to gthe current state. + * Enabled/disable the menu entries according to the current state. */ private void refreshMenus() { aPrevWindow.setEnabled(getFrameForPrevWindow() != null); Modified: trunk/crossfire/src/cfeditor/CResourceLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/CResourceLoader.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/crossfire/src/cfeditor/CResourceLoader.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -35,10 +35,10 @@ * file in the following order: * - current directory * - home directory - * - JAR ressource - * It is also able to write the ressource. If ressource was loaded + * - JAR resource + * It is also able to write the resource. If resource was loaded * from current directory or home directory, it is written at same - * place (if not read only). If the ressource was loaded from JAR, it + * place (if not read only). If the resource was loaded from JAR, it * is written to the home directory. You can also explicitly choose * where to load/save using the LOCATION_xxx constants * @author tchize @@ -57,7 +57,7 @@ /** The user's home directory location. */ public static final int LOCATION_HOME = 2; - /** The JAR ressources. */ + /** The JAR resources. */ public static final int LOCATION_JAR = 3; /** The Unknown. */ @@ -168,14 +168,14 @@ /** * Return the filename to use when dealing with this - * application's and current users' home dir. + * application's and current users' home directory. * For example, if called like this * <code>CResourceLoader.getHomeFile("myfile");</code> * will return something like /home/someuser/.gridarta/myfile - * under linux. + * under Linux. * @param filename the name of requested file. - * @return the full to user home dir, appended with - * application dir and the filename. + * @return the full to user home directory, appended with + * application directory and the filename. */ public static File getHomeFile(final String filename) { final StringBuilder buf = new StringBuilder(128); @@ -193,11 +193,11 @@ /** * Returns an aggregated XML document from the supplied parameters. - * @param filename The ressource name to load + * @param filename The resource name to load * @param readCurrent read from current directory * @param readHome read from home/gridarta directory * @param readJar read from Jar - * @return A document which's root element is the root element of jar file + * @return A document with which's element is the root element of jar file * and which content aggregates the content of root element of all files * read */ @@ -251,7 +251,7 @@ } } catch (final Exception e) { if (log.isInfoEnabled()) { - log.info("Error while loading xml ressource from JAR " + resource, e); + log.info("Error while loading XML resource from JAR " + resource, e); } } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -136,7 +136,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> * @author Andreas Kirschbaum - * @fixme I'm 2200 lines long, therefor I suck. + * @fixme I'm 2200 lines long, therefore I suck. */ public final class CMainControl extends AbstractMainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> implements ThrowableHandler<Throwable> { Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -143,7 +143,7 @@ } /** - * Initialises (builds) this view. + * Initializes (builds) this view. */ void init() { final JPanel toolbarPanel = new JPanel(new BorderLayout()); @@ -543,7 +543,7 @@ } /** - * Enabled/disable the menu entries according to gthe current state. + * Enabled/disable the menu entries according to the current state. */ private void refreshMenus() { aPrevWindow.setEnabled(getFrameForPrevWindow() != null); Modified: trunk/daimonin/src/daieditor/DaimoninEditor.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninEditor.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/daimonin/src/daieditor/DaimoninEditor.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -48,7 +48,7 @@ /** * Main class, launches the level editor application. * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"UseOfSystemOutOrSystemErr"}) public final class DaimoninEditor extends BasicCommand { Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObject.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -27,13 +27,13 @@ * Mainly this is: * <ul> * <li>Face name</li> - * <li>Weakly referenced Image Icon for different appearences of the face</li> + * <li>Weakly referenced Image Icon for different appearances of the face</li> * <li>File name of file where the face originally came from</li> * <li>File name where the face actually was loaded from (may be the same or different from the previous one)</li> * <li>File offset in the file name</li> * <li>File size</li> * </ul> - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo think how this class could be serialized because size, offset etc. are not serializable. */ public final class FaceObject extends AbstractFaceObject { @@ -63,7 +63,7 @@ private final boolean isDouble; /** - * Wether this face is an "up" face. + * Whether this face is an "up" face. * @see "Usage FACE_FLAG_UP in client/src/client.c, client/src/map.c defined by client/src/include/main.h" */ private final boolean isUp; Modified: trunk/src/app/net/sf/gridarta/CFArchType.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchType.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/src/app/net/sf/gridarta/CFArchType.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -104,7 +104,7 @@ private CFArchAttrib[] attr; /** - * List of additional attriutes that an object must have in order to be of this type. + * List of additional attributes that an object must have in order to be of this type. * The values are paired, even index = attribute name, odd index = attribute value. * typeAttributes[0] = attribute name of first type attribute. * typeAttributes[1] = attribute value of first type attribute. @@ -128,14 +128,14 @@ * Since users are expected to edit the type definitions, I have tried * to design the parser to be somewhat robust and provide error feedback. * @param root the xml 'type' element which is going to be parsed - * @param tlist archtype list + * @param tlist archetype type list * @param ignoreListTable the ignore_lists contents * @return true if the object was parsed correctly and can be used * @throws ArchTypeParseException In case <var>root</var> is malformed or contains bogus data. * @todo I'm sucking slow, improve me */ public boolean load(final Element root, final CFArchTypeList tlist, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchTypeParseException { - // this vector is used to store a temporare linked list of attributes + // this vector is used to store a temporary linked list of attributes final List<CFArchAttrib> attrList = new ArrayList<CFArchAttrib>(); // for internal section handling: @@ -144,7 +144,7 @@ final Set<String> autoIgnoreTable = new HashSet<String>(); if (root.getNodeName().equalsIgnoreCase("default_type")) { - // special case: default type (this one contains the default attribs) + // special case: default type (this one contains the default attributes) typenr = -1; typeName = "default"; @@ -282,10 +282,10 @@ int j = attrList.size(); - // don't forget about the default attribs + // don't forget about the default attributes int numDef = 0; if (defaultArchType != null && defaultArchType.attr != null && defaultArchType.attr.length > 0) { - // create an array to store the references to the default atrribs: + // create an array to store the references to the default attributes: final CFArchAttrib[] defList = new CFArchAttrib[defaultArchType.attr.length]; for (final CFArchAttrib attrib : defaultArchType.attr) { @@ -297,8 +297,8 @@ } } - // now also count the importet attribs - CFArchAttrib[] importList = null; // imported attribs array + // now also count the imported attributes + CFArchAttrib[] importList = null; // imported attributes array int importNum = 0; if (importName != null) { @@ -315,7 +315,7 @@ } if (impType != null) { - // initialize array to store imported attribs + // initialize array to store imported attributes importList = new CFArchAttrib[impType.attr.length]; for (final CFArchAttrib attrib : impType.attr) { @@ -324,7 +324,7 @@ } if (!attrib.getSecName().equalsIgnoreCase("general")) { - // import this attrib: + // import this attribute: if (!attrib.getSecName().equalsIgnoreCase("general") && !attrib.getSecName().equalsIgnoreCase("special") && !secNames.contains(attrib.getSecName())) { sectionNum++; // increment number of valid sections secNames.add(attrib.getSecName()); @@ -349,7 +349,7 @@ attr = new CFArchAttrib[j]; // create array of appropriate size - // first put in the references to the default attribs: + // first put in the references to the default attributes: for (int k = numDef; k > 0; k--) { attr[numDef - k] = defList[numDef - k]; if (log.isDebugEnabled()) { @@ -373,13 +373,13 @@ attr[numDef] = attrList.get(i); } - return true; // archtype was parsed correctly + return true; // archetype was parsed correctly } /** * Parse an xml attribute element. If parsing succeeds, the new CFArchAttrib is * added to the temporare linked list provided by the parameters (see below). - * Assigment of sections to attributes also happens in this method. + * Assignment of sections to attributes also happens in this method. * @param elem the xml attribute element * @param secNames vector storing all section names * @param inSection true if this attribute belongs to a (custom-defined) section Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -99,7 +99,7 @@ /** * Get the default folder of scripts. - * @return default folder of scrips. + * @return default folder of scripts. */ String getScriptDefaultFolder(); Modified: trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/src/app/net/sf/gridarta/data/AbstractNamedObject.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -23,7 +23,7 @@ * A <code>AbstractNamedObject</code> has a name and tree position source and provides an icon for display. * <code>AbstractNamedObject</code> is the superclass of {@link net.sf.gridarta.gameobject.face.FaceObject} and * {@link net.sf.gridarta.gameobject.anim.AnimationObject}. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public abstract class AbstractNamedObject implements NamedObject { Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -24,7 +24,7 @@ /** * Abstract base implementation of {@link AnimationObjects}. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public abstract class AbstractAnimationObjects<E extends AnimationObject> extends AbstractNamedObjects<E> implements AnimationObjects<E> { Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/DuplicateAnimationException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/DuplicateAnimationException.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/DuplicateAnimationException.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -21,7 +21,7 @@ /** * Exception that's thrown in case an animation name was not unique. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @serial exclude */ public class DuplicateAnimationException extends Exception { Modified: trunk/src/app/net/sf/gridarta/gameobject/face/DuplicateFaceException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/DuplicateFaceException.java 2008-03-14 20:18:18 UTC (rev 3687) +++ trunk/src/app/net/sf/gridarta/gameobject/face/DuplicateFaceException.java 2008-03-14 21:02:06 UTC (rev 3688) @@ -21,7 +21,7 @@ /** * Exception that's thrown in case a face name was not unique. - * @author <a href="mailto:ch...@ri...">Chrsitian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class DuplicateFaceException extends Exception { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |