From: <aki...@us...> - 2008-02-13 17:53:49
|
Revision: 3563 http://gridarta.svn.sourceforge.net/gridarta/?rev=3563&view=rev Author: akirschbaum Date: 2008-02-13 09:53:46 -0800 (Wed, 13 Feb 2008) Log Message: ----------- Move code to create actions to correct classes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/script/ScriptView.java trunk/crossfire/src/cfeditor/script/ScriptController.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-13 09:11:13 UTC (rev 3562) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-13 17:53:46 UTC (rev 3563) @@ -262,6 +262,7 @@ archetypeSet = new ArchetypeSet(this); scriptControl = new ScriptController(this); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", this); + ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); mainView = new CMainView(this); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this); @@ -275,6 +276,7 @@ // Initialise the main view mainView.init(); + scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, mainView.getObjectChooser().getArchetypeChooserControl()); animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-02-13 09:11:13 UTC (rev 3562) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-02-13 17:53:46 UTC (rev 3563) @@ -153,7 +153,6 @@ toolbarPanel.add(createCenterPanel(defwidth, defheight), BorderLayout.CENTER); archetypesActions = new ArchetypesActions<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this, objectChooser.getArchetypeChooserControl(), mainControl.getArchetypeSet(), objectChooser); setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); - mainControl.getScriptController().setMenu((JMenu) ACTION_FACTORY.find(getJMenuBar(), "plugins")); mapActions.updateMenuState(); @@ -469,9 +468,7 @@ /** {@inheritDoc} */ @Override protected void initActions() { - ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "onlineHelp", "tod", "about"); ACTION_FACTORY.createActions(true, this, "about"); - ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "importPlugin"); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/script/ScriptView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/ScriptView.java 2008-02-13 09:11:13 UTC (rev 3562) +++ trunk/crossfire/src/cfeditor/gui/script/ScriptView.java 2008-02-13 17:53:46 UTC (rev 3563) @@ -101,7 +101,7 @@ */ public ScriptView(final ScriptController control) { this.control = control; - + ACTION_FACTORY.createActions(true, this, "editPlugins", "savePlugins", "importPlugin"); control.addScriptControlListener(scriptControlListener); } @@ -111,7 +111,7 @@ * * @param menuScripts the plugins menu */ - public synchronized void setMenu(@Nullable final JMenu menuScripts) { + public void setMenu(@Nullable final JMenu menuScripts) { this.menuScripts = menuScripts; updateMenuEntries(); } Modified: trunk/crossfire/src/cfeditor/script/ScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-02-13 09:11:13 UTC (rev 3562) +++ trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-02-13 17:53:46 UTC (rev 3563) @@ -79,8 +79,8 @@ @Nullable private File scriptsDir = null; public ScriptController(final CMainControl mainControl) { - view = new ScriptView(this); this.mainControl = mainControl; + view = new ScriptView(this); } /** @@ -109,16 +109,6 @@ } } - /** - * Set the menu to add script commands to. Entries already present in the - * menu are deleted. - * - * @param menuScripts the plugins menu - */ - public void setMenu(@Nullable final JMenu menuScripts) { - view.setMenu(menuScripts); - } - public Set<String> listScript() { return Collections.unmodifiableSet(scripts.keySet()); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-02-13 09:11:13 UTC (rev 3562) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-02-13 17:53:46 UTC (rev 3563) @@ -313,6 +313,8 @@ instance = this; archetypeSet = new ArchetypeSet(this); mapCursorControl = new MapCursorControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", this); + ACTION_FACTORY.createActions(true, this, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about", "update"); + ACTION_FACTORY.createToggles(true, this, "drawDouble"); mainView = new CMainView(this); undoControl = new UndoControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(this); Updater.startup(mainView, this); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-02-13 09:11:13 UTC (rev 3562) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-02-13 17:53:46 UTC (rev 3563) @@ -477,9 +477,7 @@ /** {@inheritDoc} */ @Override protected void initActions() { - ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "cleanCompletelyBlockedSquares", "zoom", "gc", "onlineHelp", "tod", "about", "update"); ACTION_FACTORY.createActions(true, this, "about"); - ACTION_FACTORY.createToggles(true, mainControl, "drawDouble"); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-13 18:04:30
|
Revision: 3564 http://gridarta.svn.sourceforge.net/gridarta/?rev=3564&view=rev Author: akirschbaum Date: 2008-02-13 10:04:29 -0800 (Wed, 13 Feb 2008) Log Message: ----------- Unify GameObjectAttributesPanel. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-02-13 17:53:46 UTC (rev 3563) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-02-13 18:04:29 UTC (rev 3564) @@ -46,6 +46,7 @@ import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.MainView; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; @@ -181,7 +182,8 @@ objectChooser = new InsertionObjectChooser(mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("cfeditor", mainControl, this, mapTileListBottom, null); - gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, this); + final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); + gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, this, lockedItemsControl); if (mapTileListBottom) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-13 17:53:46 UTC (rev 3563) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-13 18:04:29 UTC (rev 3564) @@ -133,14 +133,13 @@ private final GameObjectTextEditor gameObjectTextEditor; /* Build Panel */ - public GameObjectAttributesPanel(final CMainControl mainControl, final CMainView view) { + public GameObjectAttributesPanel(final CMainControl mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { super(mainControl); this.mainControl = mainControl; this.errorListView = new ErrorListView(mainControl); mainView = view; final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); gameObjectTextEditor = new GameObjectTextEditor(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2008-02-13 17:53:46 UTC (rev 3563) +++ trunk/daimonin/src/daieditor/CMainView.java 2008-02-13 18:04:29 UTC (rev 3564) @@ -46,6 +46,7 @@ import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.GUIUtils; import net.sf.gridarta.gui.MainView; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.japi.swing.ActionFactory; @@ -185,7 +186,8 @@ objectChooser = new InsertionObjectChooser(mainControl); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>("daieditor", mainControl, this, mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH)); - gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, this); + final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER); + gameObjectAttributesPanel = new GameObjectAttributesPanel(mainControl, this, lockedItemsControl); if (mapTileListBottom) { splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, gameObjectAttributesPanel, selectedSquareControl.getSelectedSquareView()); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-13 17:53:46 UTC (rev 3563) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-13 18:04:29 UTC (rev 3564) @@ -126,14 +126,13 @@ private final GameObjectTextEditor gameObjectTextEditor; /* Build Panel */ - public GameObjectAttributesPanel(final CMainControl mainControl, final CMainView view) { + public GameObjectAttributesPanel(final CMainControl mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { super(mainControl); this.mainControl = mainControl; this.errorListView = new ErrorListView(mainControl); mainView = view; final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER); gameObjectTextEditor = new GameObjectTextEditor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-13 18:28:32
|
Revision: 3566 http://gridarta.svn.sourceforge.net/gridarta/?rev=3566&view=rev Author: akirschbaum Date: 2008-02-13 10:28:23 -0800 (Wed, 13 Feb 2008) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/script/ScriptController.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMatrix.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-13 18:19:22 UTC (rev 3565) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-13 18:28:23 UTC (rev 3566) @@ -36,20 +36,13 @@ import java.awt.Toolkit; import java.util.prefs.Preferences; import javax.swing.Action; -import javax.swing.BoxLayout; import javax.swing.ButtonGroup; -import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextField; -import javax.swing.JTextPane; import javax.swing.JToggleButton; -import javax.swing.JViewport; -import javax.swing.ScrollPaneConstants; -import javax.swing.border.EtchedBorder; import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ErrorListView; Modified: trunk/crossfire/src/cfeditor/script/ScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-02-13 18:19:22 UTC (rev 3565) +++ trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-02-13 18:28:23 UTC (rev 3566) @@ -37,7 +37,6 @@ import java.util.Set; import java.util.TreeMap; import javax.swing.JFileChooser; -import javax.swing.JMenu; import javax.swing.JOptionPane; import javax.swing.event.EventListenerList; import net.sf.japi.swing.ActionFactory; Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-13 18:19:22 UTC (rev 3565) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-13 18:28:23 UTC (rev 3566) @@ -40,12 +40,9 @@ import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextField; import javax.swing.JToggleButton; -import javax.swing.ScrollPaneConstants; -import javax.swing.border.EtchedBorder; import net.sf.gridarta.CFArchType; import net.sf.gridarta.MainControl; import net.sf.gridarta.gui.ErrorListView; Modified: trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2008-02-13 18:19:22 UTC (rev 3565) +++ trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2008-02-13 18:28:23 UTC (rev 3566) @@ -32,7 +32,6 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMatrix.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMatrix.java 2008-02-13 18:19:22 UTC (rev 3565) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMatrix.java 2008-02-13 18:28:23 UTC (rev 3566) @@ -24,7 +24,6 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-13 18:39:19
|
Revision: 3567 http://gridarta.svn.sourceforge.net/gridarta/?rev=3567&view=rev Author: akirschbaum Date: 2008-02-13 10:39:18 -0800 (Wed, 13 Feb 2008) Log Message: ----------- Use local variable for common expression. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-13 18:28:23 UTC (rev 3566) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-13 18:39:18 UTC (rev 3567) @@ -792,8 +792,9 @@ } // if file already exists, select it - if (mapControl.getMapFile() != null && mapControl.getMapFile().exists()) { - fileChooser.setSelectedFile(mapControl.getMapFile()); + final File mapFile = mapControl.getMapFile(); + if (mapFile != null && mapFile.exists()) { + fileChooser.setSelectedFile(mapFile); } else { fileChooser.setSelectedFile(new File(mapDir, mapControl.getMapFileName())); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-02-13 18:28:23 UTC (rev 3566) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-02-13 18:39:18 UTC (rev 3567) @@ -935,8 +935,9 @@ } // if file already exists, select it - if (mapControl.getMapFile() != null && mapControl.getMapFile().exists()) { - fileChooser.setSelectedFile(mapControl.getMapFile()); + final File mapFile = mapControl.getMapFile(); + if (mapFile != null && mapFile.exists()) { + fileChooser.setSelectedFile(mapFile); } else { fileChooser.setSelectedFile(new File(mapDir, mapControl.getMapFileName())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 17:38:32
|
Revision: 3568 http://gridarta.svn.sourceforge.net/gridarta/?rev=3568&view=rev Author: akirschbaum Date: 2008-02-14 09:38:34 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Fix memory leaks. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/gui/script/ScriptView.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-02-13 18:39:18 UTC (rev 3567) +++ trunk/crossfire/ChangeLog 2008-02-14 17:38:34 UTC (rev 3568) @@ -1,3 +1,11 @@ +2008-02-14 Andreas Kirschbaum + + * Fix memory leak in new map dialog. + + * Fix memory leak in run script dialog. + + * Fix memory leak in map properties dialog. + 2008-02-13 Andreas Kirschbaum * Remove face input field from game object attributes panel. Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-02-13 18:39:18 UTC (rev 3567) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2008-02-14 17:38:34 UTC (rev 3568) @@ -60,6 +60,8 @@ private final MapControl mapControl; + private JDialog dialog = null; + // input components, see MapArchObject for expl. of purpose private final JTextArea mapDescription = new JTextArea(4, 4); // the msg text/arch text @@ -320,6 +322,14 @@ setValue(cancelButton); } + /** {@inheritDoc} */ + @Override public void setValue(final Object newValue) { + super.setValue(newValue); + if (dialog != null && newValue != UNINITIALIZED_VALUE) { + dialog.dispose(); + } + } + /** * Create an "attribute"-line (format: <label> <textfield>). * @param textField textfield @@ -590,6 +600,7 @@ public static void showDialog(final Component parent, final CMainControl mainControl, final MapControl level) { final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, level); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.format("mapTitle", level.getMapModel().getMapArchObject().getMapDisplayName(), level.getMapFileName())); + pane.dialog = dialog; dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); dialog.setModal(false); Modified: trunk/crossfire/src/cfeditor/gui/script/ScriptView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/ScriptView.java 2008-02-13 18:39:18 UTC (rev 3567) +++ trunk/crossfire/src/cfeditor/gui/script/ScriptView.java 2008-02-14 17:38:34 UTC (rev 3568) @@ -194,13 +194,14 @@ return true; } - final JOptionPane p = new JOptionPane(); + final ScriptViewPane p = new ScriptViewPane(); p.setOptionType(JOptionPane.OK_CANCEL_OPTION); p.setMessageType(JOptionPane.QUESTION_MESSAGE); p.setMessage("Please provide runtime parameters for " + model.getName()); final GridBagLayout layout = new GridBagLayout(); final JPanel panel = new JPanel(layout); final JDialog dialog = p.createDialog(control.getMainControl().getMainView(), "hi"); + p.dialog = dialog; dialog.setModal(true); dialog.setTitle(model.getName()); dialog.getContentPane().removeAll(); @@ -231,4 +232,21 @@ return false; } + private static class ScriptViewPane extends JOptionPane { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + private JDialog dialog = null; + + /** {@inheritDoc} */ + @Override public void setValue(final Object newValue) { + super.setValue(newValue); + if (dialog != null && newValue != UNINITIALIZED_VALUE) { + dialog.dispose(); + } + } + + } // class ScriptViewPane + } // class ScriptView Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-02-13 18:39:18 UTC (rev 3567) +++ trunk/daimonin/ChangeLog 2008-02-14 17:38:34 UTC (rev 3568) @@ -1,3 +1,9 @@ +2008-02-14 Andreas Kirschbaum + + * Fix memory leak in new map dialog. + + * Fix memory leak in map properties dialog. + 2007-11-24 Andreas Kirschbaum * Do not silently fail when saving a map fails. Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-02-13 18:39:18 UTC (rev 3567) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2008-02-14 17:38:34 UTC (rev 3568) @@ -72,6 +72,8 @@ private final MapControl mapControl; + private JDialog dialog = null; + // input components, see MapArchObject for expl. of purpose private final JTextArea mapDescription = new JTextArea(4, 4); // the msg text/arch text @@ -343,6 +345,14 @@ setValue(cancelButton); } + /** {@inheritDoc} */ + @Override public void setValue(final Object newValue) { + super.setValue(newValue); + if (dialog != null && newValue != UNINITIALIZED_VALUE) { + dialog.dispose(); + } + } + /** * Creates a border to be used in dialogs to frame dialog component groups. * @param key i18n Key to look up the l10n title using the ActionFactory @@ -533,6 +543,7 @@ public static void showDialog(final Component parent, final CMainControl mainControl, final MapControl level) { final MapPropertiesDialog pane = new MapPropertiesDialog(mainControl, level); final JDialog dialog = pane.createDialog(parent, ACTION_FACTORY.format("mapTitle", level.getMapModel().getMapArchObject().getMapDisplayName(), level.getMapFileName())); + pane.dialog = dialog; dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); dialog.setModal(false); Modified: trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java 2008-02-13 18:39:18 UTC (rev 3567) +++ trunk/src/app/net/sf/gridarta/gui/NewMapDialog.java 2008-02-14 17:38:34 UTC (rev 3568) @@ -260,16 +260,22 @@ public void mapOkay() { if (createNewLevel(this)) { setValue(okButton); - dialog.dispose(); } } /** Action method for cancel. */ public void mapCancel() { setValue(cancelButton); - dialog.dispose(); } + /** {@inheritDoc} */ + @Override public void setValue(final Object newValue) { + super.setValue(newValue); + if (newValue != UNINITIALIZED_VALUE) { + dialog.dispose(); + } + } + /** * Checks the given values and creates a new level. * @param parent the parent component to be used for error messages This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 18:07:19
|
Revision: 3570 http://gridarta.svn.sourceforge.net/gridarta/?rev=3570&view=rev Author: akirschbaum Date: 2008-02-14 10:07:08 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move MapControl.save() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 17:41:38 UTC (rev 3569) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:07:08 UTC (rev 3570) @@ -74,7 +74,7 @@ * @param isPickmap true if this is a pickmap */ public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject mapArchObject, final boolean isPickmap) { - super(isPickmap); + super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) mapModel = new DefaultMapModel(mainControl, this, objects, mapArchObject); @@ -90,45 +90,13 @@ } } - /** {@inheritDoc} */ - public void save() { - if (isPickmap()) { - mainControl.getMainView().setStatusText("Saving pickmap '" + getMapFileName() + "'..."); - } else { - mainControl.getMainView().setStatusText("Saving map '" + getMapFileName() + "'..."); - } - assert mapFile != null; - if (isModified()) { - mapModel.getMapArchObject().updateModifiedAttribute(); - } - if (!encodeMapFile(mapFile, mapModel, mainControl)) { - return; - } - /* if we open a pickmap in the editor, is handled as normal map. - * to find out its original a pickmap we check the file name. - */ - if (isPickmap()) { - // this is called when we do a "add-new-pickmap from the pickmap menu - // we need to link the full path & save the map at creation time - // so the pickmap menu can handle it right - try { - setMapFileName(mapFile.getCanonicalPath()); - } catch (final IOException e) { - // TODO - } - } else { - mainControl.getMainView().getObjectChooser().getPickmapChooserControl().reloadPickmap(mapFile); - } - resetModified(); - } - /** * Save the file with the given file name. * @param file the file to be saved to */ public void saveAs(@NotNull final File file) { mainControl.getMainView().setStatusText("Saving the map to a file..."); - if (!encodeMapFile(file, mapModel, mainControl)) { + if (!encodeMapFile(file, mapModel)) { return; } mapFile = file; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 17:41:38 UTC (rev 3569) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:07:08 UTC (rev 3570) @@ -74,7 +74,7 @@ * @param isPickmap true if this is a pickmap */ public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject mapArchObject, final boolean isPickmap) { - super(isPickmap); + super(mainControl, isPickmap); this.mainControl = mainControl; // we create model (= data) mapModel = new DefaultMapModel(mainControl, this, objects, mapArchObject); @@ -90,45 +90,13 @@ } } - /** {@inheritDoc} */ - public void save() { - if (isPickmap()) { - mainControl.getMainView().setStatusText("Saving pickmap '" + getMapFileName() + "'..."); - } else { - mainControl.getMainView().setStatusText("Saving map '" + getMapFileName() + "'..."); - } - assert mapFile != null; - if (isModified()) { - mapModel.getMapArchObject().updateModifiedAttribute(); - } - if (!encodeMapFile(mapFile, mapModel, mainControl)) { - return; - } - /* if we open a pickmap in the editor, is handled as normal map. - * to find out its original a pickmap we check the file name. - */ - if (isPickmap()) { - // this is called when we do a "add-new-pickmap from the pickmap menu - // we need to link the full path & save the map at creation time - // so the pickmap menu can handle it right - try { - setMapFileName(mapFile.getCanonicalPath()); - } catch (final IOException e) { - // TODO - } - } else { - mainControl.getMainView().getObjectChooser().getPickmapChooserControl().reloadPickmap(mapFile); - } - resetModified(); - } - /** * Save the file with the given file name. * @param file the file to be saved to */ public void saveAs(@NotNull final File file) { mainControl.getMainView().setStatusText("Saving the map to a file..."); - if (!encodeMapFile(file, mapModel, mainControl)) { + if (!encodeMapFile(file, mapModel)) { return; } mapFile = file; Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 17:41:38 UTC (rev 3569) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:07:08 UTC (rev 3570) @@ -29,6 +29,7 @@ import javax.swing.event.EventListenerList; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; @@ -66,6 +67,11 @@ private final EventListenerList listenerList = new EventListenerList(); /** + * The main control. + */ + @NotNull private final MainControl<G, A, R, ?, ?> mainControl; + + /** * Flag that indicates whether this is a pickmap or not. */ private final boolean isPickmap; @@ -123,9 +129,12 @@ /** * Create a new instance. * + * @param mainControl The main control. + * * @param isPickmap true if this is a pickmap */ - protected AbstractMapControl(final boolean isPickmap) { + protected AbstractMapControl(@NotNull final MainControl<G, A, R, ?, ?> mainControl, final boolean isPickmap) { + this.mainControl = mainControl; this.isPickmap = isPickmap; } @@ -394,7 +403,7 @@ * @param mapModel MapModel to save * @return Whether saving was successful. */ - protected <C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> boolean encodeMapFile(@NotNull final File file, final MapModel<G, A, R> mapModel, @NotNull final AbstractMainControl<G, A, R, C, V> mainControl) { + protected boolean encodeMapFile(@NotNull final File file, final MapModel<G, A, R> mapModel) { try { final MapWriter<G, A, R> mapFileEncoder = new DefaultMapWriter<G, A, R>(mainControl, file); try { @@ -411,4 +420,36 @@ return true; } + /** {@inheritDoc} */ + public void save() { + if (isPickmap()) { + mainControl.getMainView().setStatusText("Saving pickmap '" + getMapFileName() + "'..."); + } else { + mainControl.getMainView().setStatusText("Saving map '" + getMapFileName() + "'..."); + } + assert mapFile != null; + if (isModified()) { + getMapModel().getMapArchObject().updateModifiedAttribute(); + } + if (!encodeMapFile(mapFile, getMapModel())) { + return; + } + /* if we open a pickmap in the editor, is handled as normal map. + * to find out its original a pickmap we check the file name. + */ + if (isPickmap()) { + // this is called when we do a "add-new-pickmap from the pickmap menu + // we need to link the full path & save the map at creation time + // so the pickmap menu can handle it right + try { + setMapFileName(mapFile.getCanonicalPath()); + } catch (final IOException e) { + // TODO + } + } else { + mainControl.getMainView().getObjectChooser().getPickmapChooserControl().reloadPickmap(mapFile); + } + resetModified(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 18:21:18
|
Revision: 3571 http://gridarta.svn.sourceforge.net/gridarta/?rev=3571&view=rev Author: akirschbaum Date: 2008-02-14 10:21:18 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move MapControl.saveAs() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:07:08 UTC (rev 3570) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:21:18 UTC (rev 3571) @@ -90,20 +90,6 @@ } } - /** - * Save the file with the given file name. - * @param file the file to be saved to - */ - public void saveAs(@NotNull final File file) { - mainControl.getMainView().setStatusText("Saving the map to a file..."); - if (!encodeMapFile(file, mapModel)) { - return; - } - mapFile = file; - setMapFileName(file.getName()); - resetModified(); - } - /** {@inheritDoc} */ public MapModel<GameObject, MapArchObject, Archetype> getMapModel() { return mapModel; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:07:08 UTC (rev 3570) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:21:18 UTC (rev 3571) @@ -90,20 +90,6 @@ } } - /** - * Save the file with the given file name. - * @param file the file to be saved to - */ - public void saveAs(@NotNull final File file) { - mainControl.getMainView().setStatusText("Saving the map to a file..."); - if (!encodeMapFile(file, mapModel)) { - return; - } - mapFile = file; - setMapFileName(file.getName()); - resetModified(); - } - /** {@inheritDoc} */ public MapModel<GameObject, MapArchObject, Archetype> getMapModel() { return mapModel; Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:07:08 UTC (rev 3570) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:21:18 UTC (rev 3571) @@ -452,4 +452,18 @@ resetModified(); } + /** + * Save the file with the given file name. + * @param file the file to be saved to + */ + public void saveAs(@NotNull final File file) { + mainControl.getMainView().setStatusText("Saving the map to a file..."); + if (!encodeMapFile(file, getMapModel())) { + return; + } + mapFile = file; + setMapFileName(file.getName()); + resetModified(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 18:26:49
|
Revision: 3572 http://gridarta.svn.sourceforge.net/gridarta/?rev=3572&view=rev Author: akirschbaum Date: 2008-02-14 10:26:54 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move MapControl.insertSelArchToMap() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:21:18 UTC (rev 3571) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:26:54 UTC (rev 3572) @@ -96,60 +96,6 @@ } /** {@inheritDoc} */ - protected GameObject insertSelArchToMap(@NotNull final Point pos, final boolean allowMany) { - // this is the arch that would get inserted from pickmap, but it also could - // be a default arch (when pickmap has no selection) - final MapControl activePickmap = mainControl.getMainView().getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); - GameObject newarch = activePickmap == null ? null : activePickmap.getMapViewFrame().getSelectedGameObject(); - - final GameObject newObject; - if (!mainControl.getMainView().getObjectChooser().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { - // insert default arch from archlist: - mapModel.beginTransaction("Insert"); // TODO: I18N/L10N - newObject = mapModel.addArchToMap(mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getSelectedArch(), pos, allowMany, true, false); - mapModel.endTransaction(); - } else { - // insert custom arch from the pickmap: - if (newarch != null) { - boolean insertAllowed = true; // are we allowed to insert this? - if (!allowMany) { - // check if there is already an arch of that kind - for (final GameObject t : mapModel.getMapSquare(pos)) { - if (t.hasSameArchetype(newarch) || t.getArchTypNr() == newarch.getArchTypNr()) { - insertAllowed = false; // there's a match - don't insert a second one - } - } - } - - if (insertAllowed) { - if (!newarch.isMulti()) { - // insert single tile from pickmap - newObject = newarch.createClone(pos.x, pos.y); - mapModel.addGameObjectToMap(newObject, false); - } else { - // insert multi tile from pickmap: - newarch = newarch.getHead(); - // first insert default arch from archlist - newObject = mapModel.addArchToMap(newarch.getArchetypeName(), pos, allowMany, false, false); - if (newObject != null) { - newObject.setObjectText(newarch.getObjectText()); - newObject.setObjName(newarch.getObjName()); - newObject.resetMsgText(); - newObject.addMsgText(newarch.getMsgText()); - } - } - } else { - newObject = null; - } - } else { - newObject = null; - } - } - - return newObject; - } - - /** {@inheritDoc} */ protected void insertMapArchToPickmap(@NotNull final Point pos) { final MapControl currentMap = mainControl.getMapManager().getCurrentMap(); // insertion is only allowed for valid *empty* squares Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:21:18 UTC (rev 3571) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:26:54 UTC (rev 3572) @@ -96,60 +96,6 @@ } /** {@inheritDoc} */ - protected GameObject insertSelArchToMap(@NotNull final Point pos, final boolean allowMany) { - // this is the arch that would get inserted from pickmap, but it also could - // be a default arch (when pickmap has no selection) - final MapControl activePickmap = mainControl.getMainView().getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); - GameObject newarch = activePickmap == null ? null : activePickmap.getMapViewFrame().getSelectedGameObject(); - - final GameObject newObject; - if (!mainControl.getMainView().getObjectChooser().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { - // insert default arch from archlist: - mapModel.beginTransaction("Insert"); // TODO: I18N/L10N - newObject = mapModel.addArchToMap(mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getSelectedArch(), pos, allowMany, true, false); - mapModel.endTransaction(); - } else { - // insert custom arch from the pickmap: - if (newarch != null) { - boolean insertAllowed = true; // are we allowed to insert this? - if (!allowMany) { - // check if there is already an arch of that kind - for (final GameObject t : mapModel.getMapSquare(pos)) { - if (t.hasSameArchetype(newarch) || t.getArchTypNr() == newarch.getArchTypNr()) { - insertAllowed = false; // there's a match - don't insert a second one - } - } - } - - if (insertAllowed) { - if (!newarch.isMulti()) { - // insert single tile from pickmap - newObject = newarch.createClone(pos.x, pos.y); - mapModel.addGameObjectToMap(newObject, false); - } else { - // insert multi tile from pickmap: - newarch = newarch.getHead(); - // first insert default arch from archlist - newObject = mapModel.addArchToMap(newarch.getArchetypeName(), pos, allowMany, false, false); - if (newObject != null) { - newObject.setObjectText(newarch.getObjectText()); - newObject.setObjName(newarch.getObjName()); - newObject.resetMsgText(); - newObject.addMsgText(newarch.getMsgText()); - } - } - } else { - newObject = null; - } - } else { - newObject = null; - } - } - - return newObject; - } - - /** {@inheritDoc} */ protected void insertMapArchToPickmap(@NotNull final Point pos) { final MapControl currentMap = mainControl.getMapManager().getCurrentMap(); // insertion is only allowed for valid *empty* squares Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:21:18 UTC (rev 3571) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:26:54 UTC (rev 3572) @@ -232,8 +232,61 @@ * @param allowMany when true, it is possible to insert same arches many times * @return the inserted object, or <code>null</code> if nothing was inserted */ - protected abstract G insertSelArchToMap(@NotNull final Point pos, final boolean allowMany); + private G insertSelArchToMap(@NotNull final Point pos, final boolean allowMany) { + final MapModel<G, A, R> mapModel = getMapModel(); + // this is the arch that would get inserted from pickmap, but it also could + // be a default arch (when pickmap has no selection) + final MapControl<G, A, R> activePickmap = mainControl.getMainView().getObjectChooser().getPickmapChooserControl().getCurrentPickmap(); + G newarch = activePickmap == null ? null : activePickmap.getMapViewFrame().getSelectedGameObject(); + + final G newObject; + if (!mainControl.getMainView().getObjectChooser().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { + // insert default arch from archlist: + mapModel.beginTransaction("Insert"); // TODO: I18N/L10N + newObject = mapModel.addArchToMap(mainControl.getMainView().getObjectChooser().getArchetypeChooserControl().getSelectedArch(), pos, allowMany, true, false); + mapModel.endTransaction(); + } else { + // insert custom arch from the pickmap: + if (newarch != null) { + boolean insertAllowed = true; // are we allowed to insert this? + if (!allowMany) { + // check if there is already an arch of that kind + for (final G t : mapModel.getMapSquare(pos)) { + if (t.hasSameArchetype(newarch) || t.getArchTypNr() == newarch.getArchTypNr()) { + insertAllowed = false; // there's a match - don't insert a second one + } + } + } + + if (insertAllowed) { + if (!newarch.isMulti()) { + // insert single tile from pickmap + newObject = newarch.createClone(pos.x, pos.y); + mapModel.addGameObjectToMap(newObject, false); + } else { + // insert multi tile from pickmap: + newarch = newarch.getHead(); + // first insert default arch from archlist + newObject = mapModel.addArchToMap(newarch.getArchetypeName(), pos, allowMany, false, false); + if (newObject != null) { + newObject.setObjectText(newarch.getObjectText()); + newObject.setObjName(newarch.getObjName()); + newObject.resetMsgText(); + newObject.addMsgText(newarch.getMsgText()); + } + } + } else { + newObject = null; + } + } else { + newObject = null; + } + } + + return newObject; + } + /** * This method is only called for pickmaps. Take the currently highlighted * arch on the map (if any) and insert it on this pickmap. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 18:44:30
|
Revision: 3573 http://gridarta.svn.sourceforge.net/gridarta/?rev=3573&view=rev Author: akirschbaum Date: 2008-02-14 10:44:35 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move CopyBuffer.addCopyToMap() to MapControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:26:54 UTC (rev 3572) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:44:35 UTC (rev 3573) @@ -117,7 +117,7 @@ } } if (allSpacesFree) { - mainControl.getCopyBuffer().addCopyToMap(this, newarch, pos, true, false); + addCopyToMap(newarch, pos, true, false); } } } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:26:54 UTC (rev 3572) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:44:35 UTC (rev 3573) @@ -117,7 +117,7 @@ } } if (allSpacesFree) { - mainControl.getCopyBuffer().addCopyToMap(this, newarch, pos, true, false); + addCopyToMap(newarch, pos, true, false); } } } Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-02-14 18:26:54 UTC (rev 3572) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-02-14 18:44:35 UTC (rev 3573) @@ -201,7 +201,7 @@ if (mapControl.getMapModel().isPointValid(pos)) { for (final G gameObject : square) { if (!gameObject.isMulti()) { - addCopyToMap(mapControl, gameObject, pos, true, false); + mapControl.addCopyToMap(gameObject, pos, true, false); } } } @@ -213,7 +213,7 @@ if (mapControl.getMapModel().isPointValid(pos)) { for (final G gameObject : square) { if (gameObject.isMulti()) { - addCopyToMap(mapControl, gameObject, pos, true, false); + mapControl.addCopyToMap(gameObject, pos, true, false); } } } @@ -250,7 +250,7 @@ continue; } final G gameObject = archList.get(MainControl.rnd.nextInt(archList.size())); - addCopyToMap(mapView.getMapControl(), gameObject, p, false, fillBelow); + mapView.getMapControl().addCopyToMap(gameObject, p, false, fillBelow); } mapView.getMapControl().getMapModel().endTransaction(); } @@ -333,7 +333,7 @@ if (mapControl.getMapModel().isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { area[p.x][p.y] = WAS_EMPTY; final G gameObject = archList.get(MainControl.rnd.nextInt(archList.size())); - addCopyToMap(mapControl, gameObject, p, false, false); + mapControl.addCopyToMap(gameObject, p, false, false); try { if (area[p.x - 1][p.y] == NOT_LOOKED_AT) { area[p.x - 1][p.y] = BORDER; @@ -377,34 +377,4 @@ return copyMapCtrl; } - /** - * Add an archetype to the destination map. Inserts a new object instance - * for default archetypes, and a clone for non-default archetypes. - * If <var>allowDouble</var> is <code>false</code> and <var>gameObject</var> is an {@link Archetype}, the object will only be inserted if there wasn't already an object with the same Archetype. - * @param mapControl MapControl of the map the object should be added to. - * @param gameObject GameObject to add. - * @param pos position to add GameObject at - * @param allowDouble <code>true</code> for allowing similar GameObjects on the same square, <code>false</code> to disallow - * @param fillBelow <code>true</code> if the GameObject should be added below all others, <code>false</code> for above - */ - public void addCopyToMap(final C mapControl, final G gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { - if (gameObject.isArchetype()) { - mapControl.getMapModel().addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); - } else { - final G newGameObject = gameObject.createMultiClone(pos.x, pos.y); - for (G tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { - if (!mapControl.getMapModel().isPointValid(new Point(tmp.getMapX(), tmp.getMapY()))) { - // outside map - return; - } - } - - mapControl.getMapModel().addGameObjectToMap(newGameObject, fillBelow); - for (G tmp = newGameObject.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { - mapControl.getMapModel().addGameObjectToMap(tmp, fillBelow); - mainControl.getArchetypeParser().postParseGameObject(tmp, mapControl.getActiveEditType()); - } - } - } - } // class CopyBuffer Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:26:54 UTC (rev 3572) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:44:35 UTC (rev 3573) @@ -519,4 +519,25 @@ resetModified(); } + /** {@inheritDoc} */ + public void addCopyToMap(final G gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { + if (gameObject.isArchetype()) { + getMapModel().addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); + } else { + final G newGameObject = gameObject.createMultiClone(pos.x, pos.y); + for (G tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { + if (!getMapModel().isPointValid(new Point(tmp.getMapX(), tmp.getMapY()))) { + // outside map + return; + } + } + + getMapModel().addGameObjectToMap(newGameObject, fillBelow); + for (G tmp = newGameObject.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + getMapModel().addGameObjectToMap(tmp, fillBelow); + mainControl.getArchetypeParser().postParseGameObject(tmp, activeEditType); + } + } + } + } Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-02-14 18:26:54 UTC (rev 3572) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-02-14 18:44:35 UTC (rev 3573) @@ -213,4 +213,17 @@ */ LevelRenderer getRenderer(); + /** + * Add an archetype to this map. Inserts a new object instance for + * archetypes, and a clone for game objects. If <var>allowDouble</var> is + * <code>false</code> and <var>gameObject</var> is an {@link Archetype}, + * the object will only be inserted if there wasn't already an object with + * the same Archetype. + * @param gameObject GameObject to add. + * @param pos position to add GameObject at + * @param allowDouble <code>true</code> for allowing similar GameObjects on the same square, <code>false</code> to disallow + * @param fillBelow <code>true</code> if the GameObject should be added below all others, <code>false</code> for above + */ + void addCopyToMap(G gameObject, Point pos, boolean allowDouble, boolean fillBelow); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 18:57:21
|
Revision: 3574 http://gridarta.svn.sourceforge.net/gridarta/?rev=3574&view=rev Author: akirschbaum Date: 2008-02-14 10:57:25 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move MapControl.insertMapArchToPickmap() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:44:35 UTC (rev 3573) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 18:57:25 UTC (rev 3574) @@ -96,34 +96,6 @@ } /** {@inheritDoc} */ - protected void insertMapArchToPickmap(@NotNull final Point pos) { - final MapControl currentMap = mainControl.getMapManager().getCurrentMap(); - // insertion is only allowed for valid *empty* squares - if (currentMap != null && isPickmap() && mapModel.isPointValid(pos) && mapModel.getMapSquare(pos).isEmpty()) { - // get the currently selected map arch - GameObject newarch = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); - if (newarch != null) { - newarch = newarch.getHead(); - - // check if all spaces are free that the multi will occupy - boolean allSpacesFree = true; - final Point d = new Point(); - for (Archetype part = newarch.getArchetype(); part != null; part = part.getMultiNext()) { - d.x = pos.x + part.getMultiX(); - d.y = pos.y + part.getMultiY(); - if (!mapModel.isPointValid(d) || !mapModel.getMapSquare(d).isEmpty()) { - allSpacesFree = false; - break; - } - } - if (allSpacesFree) { - addCopyToMap(newarch, pos, true, false); - } - } - } - } - - /** {@inheritDoc} */ public LevelRenderer getRenderer() { final SimpleLevelRenderer tmpLevelRenderer = simpleLevelRendererReference == null ? null : simpleLevelRendererReference.get(); final SimpleLevelRenderer simpleLevelRenderer; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:44:35 UTC (rev 3573) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 18:57:25 UTC (rev 3574) @@ -96,34 +96,6 @@ } /** {@inheritDoc} */ - protected void insertMapArchToPickmap(@NotNull final Point pos) { - final MapControl currentMap = mainControl.getMapManager().getCurrentMap(); - // insertion is only allowed for valid *empty* squares - if (currentMap != null && isPickmap() && mapModel.isPointValid(pos) && mapModel.getMapSquare(pos).isEmpty()) { - // get the currently selected map arch - GameObject newarch = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); - if (newarch != null) { - newarch = newarch.getHead(); - - // check if all spaces are free that the multi will occupy - boolean allSpacesFree = true; - final Point d = new Point(); - for (Archetype part = newarch.getArchetype(); part != null; part = part.getMultiNext()) { - d.x = pos.x + part.getMultiX(); - d.y = pos.y + part.getMultiY(); - if (!mapModel.isPointValid(d) || !mapModel.getMapSquare(d).isEmpty()) { - allSpacesFree = false; - break; - } - } - if (allSpacesFree) { - addCopyToMap(newarch, pos, true, false); - } - } - } - } - - /** {@inheritDoc} */ public LevelRenderer getRenderer() { final SimpleLevelRenderer tmpLevelRenderer = simpleLevelRendererReference == null ? null : simpleLevelRendererReference.get(); final SimpleLevelRenderer simpleLevelRenderer; Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:44:35 UTC (rev 3573) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 18:57:25 UTC (rev 3574) @@ -292,8 +292,35 @@ * arch on the map (if any) and insert it on this pickmap. * @param pos tile-coordinates in pickmap */ - protected abstract void insertMapArchToPickmap(@NotNull final Point pos); + private void insertMapArchToPickmap(@NotNull final Point pos) { + final MapModel<G, A, R> mapModel = getMapModel(); + final MapControl<G, A, R> currentMap = mainControl.getMapManager().getCurrentMap(); + // insertion is only allowed for valid *empty* squares + if (currentMap != null && isPickmap() && mapModel.isPointValid(pos) && mapModel.getMapSquare(pos).isEmpty()) { + // get the currently selected map arch + G newarch = mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().getMapTileSelection(); + if (newarch != null) { + newarch = newarch.getHead(); + + // check if all spaces are free that the multi will occupy + boolean allSpacesFree = true; + final Point d = new Point(); + for (R part = newarch.getArchetype(); part != null; part = (R) part.getMultiNext()) { + d.x = pos.x + part.getMultiX(); + d.y = pos.y + part.getMultiY(); + if (!mapModel.isPointValid(d) || !mapModel.getMapSquare(d).isEmpty()) { + allSpacesFree = false; + break; + } + } + if (allSpacesFree) { + addCopyToMap(newarch, pos, true, false); + } + } + } + } + /** {@inheritDoc} */ public boolean isPlainSaveEnabled() { return mapFile != null && !getMapFileName().equals(CommonConstants.DEF_MAPFNAME); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 20:54:03
|
Revision: 3578 http://gridarta.svn.sourceforge.net/gridarta/?rev=3578&view=rev Author: akirschbaum Date: 2008-02-14 12:54:01 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-14 20:48:48 UTC (rev 3577) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-14 20:54:01 UTC (rev 3578) @@ -59,7 +59,7 @@ * The direction determines to which direction the GameObject's face is facing. * E.g. some walls have two faces, some mobs 4 and very good animated objects might even have 8 or 9 (8 + still) facings. */ - private int direction; + private int direction = -1; /** {@inheritDoc} */ @Override public void propagateElevation(@NotNull final GameObject gameObject) { @@ -148,9 +148,7 @@ clone.multiY = multiY; clone.setArchetype(getArchetype()); // default arch - clone.editType = editType; // bitmask for view-settings - clone.archType = archType; // type attribute of the arch clone.scriptArchData = new ScriptArchData(clone); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-14 20:48:48 UTC (rev 3577) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-14 20:54:01 UTC (rev 3578) @@ -83,7 +83,7 @@ /** * The direction determines to which direction the GameObject's face is facing. - * E.g. some walls have to faces, some mobs 4 and very good animated objects might even have 8 or 9 (8 + still) facings. + * E.g. some walls have two faces, some mobs 4 and very good animated objects might even have 8 or 9 (8 + still) facings. */ private int direction = -1; @@ -417,7 +417,7 @@ /** * This method checks the objectText for syntax errors. More precisely: It * reads every line in the objectText and looks if it matches the - * type-definitions (-> see CFArchTypeList) for this arch. If there is no + * type-definitions (-> see CFArchTypeList) for this arch. If there is no * match, the line is considered wrong. Of course the type-definitions will * never be perfect, this should be kept in mind. * <p/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 21:07:48
|
Revision: 3579 http://gridarta.svn.sourceforge.net/gridarta/?rev=3579&view=rev Author: akirschbaum Date: 2008-02-14 13:07:43 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Move CMainControl.autojoinLists to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-14 20:54:01 UTC (rev 3578) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-14 21:07:43 UTC (rev 3579) @@ -248,9 +248,6 @@ /** The filter control. */ private final CFilterControl filterControl; - /** The autojoin lists. */ - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists = new AutojoinLists<GameObject, MapArchObject, Archetype>(); - /** * Constructs the main controller and its model and view. * @@ -347,7 +344,7 @@ // load the autojoin lists mainView.setStatusText("Loading Autojoin Tables..."); - autojoinLists.loadList(archetypeSet, getConfigurationDirectory()); + getAutojoinLists().loadList(archetypeSet, getConfigurationDirectory()); mainView.setStatusText("Ready."); @@ -1089,9 +1086,4 @@ return result; } - /** {@inheritDoc} */ - public AutojoinLists<GameObject, MapArchObject, Archetype> getAutojoinLists() { - return autojoinLists; - } - } // class CMainControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-02-14 20:54:01 UTC (rev 3578) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-02-14 21:07:43 UTC (rev 3579) @@ -300,9 +300,6 @@ /** The auto-validator. */ private final AutoValidator<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> autoValidator; - /** The autojoin lists. */ - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists = new AutojoinLists<GameObject, MapArchObject, Archetype>(); - /** * Constructs the main controller and its model and view. * @@ -415,7 +412,7 @@ // load the autojoin lists mainView.setStatusText("Loading Autojoin Tables..."); - autojoinLists.loadList(archetypeSet, getConfigurationDirectory()); + getAutojoinLists().loadList(archetypeSet, getConfigurationDirectory()); mainView.setStatusText("Ready."); @@ -1249,9 +1246,4 @@ return new File(getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR); } - /** {@inheritDoc} */ - public AutojoinLists<GameObject, MapArchObject, Archetype> getAutojoinLists() { - return autojoinLists; - } - } // class CMainControl Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-02-14 20:54:01 UTC (rev 3578) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-02-14 21:07:43 UTC (rev 3579) @@ -84,6 +84,9 @@ protected static ImageIcon unknownTileIcon; + /** The autojoin lists. */ + private final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(); + /** Create an AbstractMainControl. */ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, C, V> gridartaObjectsFactory) { this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -187,4 +190,9 @@ return unknownTileIcon; } + /** {@inheritDoc} */ + public AutojoinLists<G, A, R> getAutojoinLists() { + return autojoinLists; + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-14 21:30:19
|
Revision: 3580 http://gridarta.svn.sourceforge.net/gridarta/?rev=3580&view=rev Author: akirschbaum Date: 2008-02-14 13:30:13 -0800 (Thu, 14 Feb 2008) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-14 21:07:43 UTC (rev 3579) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-14 21:30:13 UTC (rev 3580) @@ -53,7 +53,6 @@ import javax.swing.filechooser.FileFilter; import javax.xml.parsers.ParserConfigurationException; import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.AutojoinLists; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.DefaultMapManager; Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 21:07:43 UTC (rev 3579) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2008-02-14 21:30:13 UTC (rev 3580) @@ -25,8 +25,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.map.SimpleLevelRenderer; import java.awt.Point; -import java.io.File; -import java.io.IOException; import java.lang.ref.SoftReference; import java.util.List; import net.sf.gridarta.gui.map.LevelRenderer; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-02-14 21:07:43 UTC (rev 3579) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-02-14 21:30:13 UTC (rev 3580) @@ -59,7 +59,6 @@ import javax.swing.filechooser.FileFilter; import javax.xml.parsers.ParserConfigurationException; import net.sf.gridarta.AbstractMainControl; -import net.sf.gridarta.AutojoinLists; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.DefaultMapManager; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 21:07:43 UTC (rev 3579) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2008-02-14 21:30:13 UTC (rev 3580) @@ -25,8 +25,6 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.SimpleLevelRenderer; import java.awt.Point; -import java.io.File; -import java.io.IOException; import java.lang.ref.SoftReference; import java.util.List; import net.sf.gridarta.gui.map.LevelRenderer; Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 21:07:43 UTC (rev 3579) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-14 21:30:13 UTC (rev 3580) @@ -27,7 +27,6 @@ import java.util.LinkedList; import java.util.List; import javax.swing.event.EventListenerList; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-22 22:24:31
|
Revision: 3587 http://gridarta.svn.sourceforge.net/gridarta/?rev=3587&view=rev Author: akirschbaum Date: 2008-02-22 14:24:35 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Implement "monster" view. It summarizes all monsters by name on the current map. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-02-22 21:47:43 UTC (rev 3586) +++ trunk/crossfire/ChangeLog 2008-02-22 22:24:35 UTC (rev 3587) @@ -1,3 +1,8 @@ +2008-02-22 Andreas Kirschbaum + + * Implement "monster" view. It summarizes all monsters by name on + the current map. + 2008-02-14 Andreas Kirschbaum * Fix memory leak in new map dialog. Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-22 21:47:43 UTC (rev 3586) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-22 22:24:35 UTC (rev 3587) @@ -49,6 +49,7 @@ import net.sf.gridarta.gui.GSplitPane; 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; @@ -131,6 +132,8 @@ final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); + final MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> monsterControl = new MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); + gameObjectTextEditor = new GameObjectTextEditor(); mapArchPanel.setLayout(new BorderLayout()); @@ -154,6 +157,7 @@ panelDesktop.add(animationPanel, "Animation"); panelDesktop.add(connectionControl.getView(), "Connection"); panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); + panelDesktop.add(monsterControl.getView(), "Monsters"); panelDesktop.add(errorListView, "Warnings"); refreshDisplay(); @@ -167,7 +171,7 @@ * @param errorCollector The errors. */ public void setErrors(final MapModel<GameObject, MapArchObject, Archetype> map, final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector) { - panelDesktop.setForegroundAt(6, errorCollector.getErrors().iterator().hasNext() ? Color.blue : Color.black); + panelDesktop.setForegroundAt(7, errorCollector.getErrors().iterator().hasNext() ? Color.blue : Color.black); errorListView.setErrors(map, errorCollector); } Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-02-22 21:47:43 UTC (rev 3586) +++ trunk/daimonin/ChangeLog 2008-02-22 22:24:35 UTC (rev 3587) @@ -1,3 +1,8 @@ +2008-02-22 Andreas Kirschbaum + + * Implement "monster" view. It summarizes all monsters by name on + the current map. + 2008-02-14 Andreas Kirschbaum * Fix memory leak in new map dialog. Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-22 21:47:43 UTC (rev 3586) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-22 22:24:35 UTC (rev 3587) @@ -49,6 +49,7 @@ import net.sf.gridarta.gui.GSplitPane; 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; @@ -131,6 +132,8 @@ final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); + final MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> monsterControl = new MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); + gameObjectTextEditor = new GameObjectTextEditor(); mapArchPanel.setLayout(new BorderLayout()); @@ -154,6 +157,7 @@ panelDesktop.add(animationPanel, "Animation"); panelDesktop.add(connectionControl.getView(), "Connection"); panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); + panelDesktop.add(monsterControl.getView(), "Monster"); panelDesktop.add(errorListView, "Warnings"); refreshDisplay(); @@ -167,7 +171,7 @@ * @param errorCollector The errors. */ public void setErrors(final MapModel<GameObject, MapArchObject, Archetype> map, final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector) { - panelDesktop.setForegroundAt(6, errorCollector.getErrors().iterator().hasNext() ? Color.blue : Color.black); + panelDesktop.setForegroundAt(7, errorCollector.getErrors().iterator().hasNext() ? Color.blue : Color.black); errorListView.setErrors(map, errorCollector); } Added: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java 2008-02-22 22:24:35 UTC (rev 3587) @@ -0,0 +1,46 @@ +/* + * 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.gui.connectionview; + +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * The controller of the monster view control. + * + * @author Andreas Kirschbaum + */ +public class MonsterControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends Control<String, G, A, R, C, V> { + + /** + * Create a new instance. + * + * @param mainControl the main control to use + */ + public MonsterControl(@NotNull final MainControl<G, A, R, C, V> mainControl) { + super(new MonsterView<G, A, R, C, V>(mainControl)); + } + +} // class MonsterControl Property changes on: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterControl.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java 2008-02-22 22:24:35 UTC (rev 3587) @@ -0,0 +1,70 @@ +/* + * 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.gui.connectionview; + +import net.sf.gridarta.CFArchTypeList; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * The view of the connection view control. It holds information about the + * connections of the selected connection value on the selected map. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public final class MonsterView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, C extends MapControl<G, A, R>, V extends MapViewBasic<G, A, R>> extends View<String, G, A, R, C, V> { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * Create a MonsterView. + * @param mainControl MainControl. + */ + public MonsterView(@NotNull final MainControl<G, A, R, C, V> mainControl) { + super(mainControl); + } + + /** {@inheritDoc} */ + @Override protected void scanGameObjectForConnections(@NotNull final G gameObject) { + scanGameObject(gameObject); + for (final G invObject : gameObject.recursive()) { + scanGameObject(invObject); + } + } + + /** + * Add the given game object as a connection if it has a "connected" field. + * + * @param gameObject The game object to process. + */ + private void scanGameObject(@NotNull final G gameObject) { + if (gameObject.isHead() && CFArchTypeList.isMonsterType(gameObject)) { + addConnection(gameObject.getBestName(), gameObject); + } + } + +} // class MonsterView Property changes on: trunk/src/app/net/sf/gridarta/gui/connectionview/MonsterView.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 10:08:43
|
Revision: 3591 http://gridarta.svn.sourceforge.net/gridarta/?rev=3591&view=rev Author: akirschbaum Date: 2008-02-23 02:08:30 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move GameObject.direction to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/Archetype.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/Archetype.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/Archetype.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/Archetype.java 2008-02-23 09:58:12 UTC (rev 3590) +++ trunk/crossfire/src/cfeditor/gameobject/Archetype.java 2008-02-23 10:08:30 UTC (rev 3591) @@ -113,10 +113,4 @@ int TYPE_TRAP = 155; - /** - * Returns the direction of this Archetype or GameObject. - * @return The direction of this Archetype or GameObject. - */ - int getDirection(); - } // class Archetype Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 09:58:12 UTC (rev 3590) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 10:08:30 UTC (rev 3591) @@ -55,12 +55,6 @@ */ @NotNull private ScriptArchData scriptArchData = new ScriptArchData(this); - /** - * The direction determines to which direction the GameObject's face is facing. - * E.g. some walls have two faces, some mobs 4 and very good animated objects might even have 8 or 9 (8 + still) facings. - */ - private int direction = -1; - /** {@inheritDoc} */ @Override public void propagateElevation(@NotNull final GameObject gameObject) { final String elevation = gameObject.getAttributeString("elevation", false); @@ -75,19 +69,6 @@ } /** {@inheritDoc} */ - public int getDirection() { - return direction; - } - - public void setDirection(final int direction) { - if (this.direction == direction) { - return; - } - this.direction = direction; - squareChanged(); - } - - /** {@inheritDoc} */ public boolean usesDirection() { return false;//getAttributeInt("is_turnable") != 0; } @@ -316,7 +297,6 @@ && (gameObject.animText == null ? animText == null : gameObject.animText.equals(animText)) && gameObject.loreText.equals(loreText) // ignore "scriptArchData" - && gameObject.direction == direction && gameObject.archType == archType; } Modified: trunk/daimonin/src/daieditor/gameobject/Archetype.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Archetype.java 2008-02-23 09:58:12 UTC (rev 3590) +++ trunk/daimonin/src/daieditor/gameobject/Archetype.java 2008-02-23 10:08:30 UTC (rev 3591) @@ -97,12 +97,6 @@ int TYPE_CONNECTION_SENSOR = 134; - /** - * Returns the direction of this Archetype or GameObject. - * @return The direction of this Archetype or GameObject. - */ - int getDirection(); - int getMultiShapeID(); int getMultiPartNr(); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 09:58:12 UTC (rev 3590) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 10:08:30 UTC (rev 3591) @@ -81,12 +81,6 @@ */ private boolean noface; - /** - * The direction determines to which direction the GameObject's face is facing. - * E.g. some walls have two faces, some mobs 4 and very good animated objects might even have 8 or 9 (8 + still) facings. - */ - private int direction = -1; - /** The normal face. */ private ImageIcon normalFace; @@ -143,19 +137,6 @@ } } - /** {@inheritDoc} */ - public int getDirection() { - return direction; - } - - public void setDirection(final int direction) { - if (this.direction == direction) { - return; - } - this.direction = direction; - squareChanged(); - } - public boolean hasFaceObject() { return noface; } @@ -225,9 +206,9 @@ final AnimationObject animationObject = animationObjects.get(effectiveAnimName); if (animationObject != null) { noface = false; - //faceObjName = animationObjects.getAnimFrame(animnr, direction); + //faceObjName = animationObjects.getAnimFrame(animnr, getDirection()); try { - effectiveFaceObjName = animationObject.getFirstFrame(direction); + effectiveFaceObjName = animationObject.getFirstFrame(getDirection()); } catch (final IndexOutOfBoundsException ex) { effectiveFaceObjName = null; } @@ -505,7 +486,6 @@ // ignore "scriptArchData" && gameObject.noface == noface // ignore "faceObjSource" - && gameObject.direction == direction && gameObject.archType == archType && gameObject.normalFace == normalFace && gameObject.transFace == transFace; Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 09:58:12 UTC (rev 3590) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 10:08:30 UTC (rev 3591) @@ -254,4 +254,10 @@ */ @NotNull Iterator<G> iterator(); + /** + * Returns the direction of this Archetype or GameObject. + * @return The direction of this Archetype or GameObject. + */ + int getDirection(); + } // interface Archetype Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-02-23 09:58:12 UTC (rev 3590) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-02-23 10:08:30 UTC (rev 3591) @@ -151,6 +151,12 @@ protected int archType = TYPE_UNSET; /** + * The direction determines to which direction the GameObject's face is facing. + * E.g. some walls have two faces, some mobs 4 and very good animated objects might even have 8 or 9 (8 + still) facings. + */ + private int direction = -1; + + /** * Constructor. */ protected GameObject() { @@ -1223,7 +1229,8 @@ // ignore "multi" // ignore "editType" && (gameObject.editorFolder == null ? editorFolder == null : gameObject.editorFolder.equals(editorFolder)) - && (gameObject.faceName == null ? faceName == null : gameObject.faceName.equals(faceName)); + && (gameObject.faceName == null ? faceName == null : gameObject.faceName.equals(faceName)) + && gameObject.direction == direction; } /** @@ -1354,4 +1361,17 @@ */ public abstract void addEventScript(@NotNull final JList eventList, @NotNull final GameObjectAttributesPanel<G, A, R, ?, ?> mapanel); + /** {@inheritDoc} */ + public int getDirection() { + return direction; + } + + public void setDirection(final int direction) { + if (this.direction == direction) { + return; + } + this.direction = direction; + 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-02-23 10:21:17
|
Revision: 3593 http://gridarta.svn.sourceforge.net/gridarta/?rev=3593&view=rev Author: akirschbaum Date: 2008-02-23 02:20:35 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Move GameObject.getSyntaxErrors() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 10:16:44 UTC (rev 3592) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 10:20:35 UTC (rev 3593) @@ -23,7 +23,6 @@ import cfeditor.map.MapArchObject; import java.io.Serializable; import javax.swing.JList; -import net.sf.gridarta.CFArchType; import net.sf.gridarta.gui.GameObjectAttributesPanel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -206,70 +205,6 @@ } } - /** - * This method checks the objectText for syntax errors. More precisely: It - * reads every line in the objectText and looks if it matches the - * type-definitions (-> see CFArchTypeList) for this arch. If there is no - * match, the line is considered wrong. Of course the type-definitions will - * never be perfect, this should be kept in mind. - * <p/> - * Note that the default arch is ignored in the check. The default arches - * should be correct, and even if not - it isn't the map maker to blame. - * @param archType the type structure belonging to this arch. if null, the - * type is calculated in this function - * @return A String with all lines which don't match the - * type-definitions.<br> If no such "errors" encountered, null is returned. - */ - @Nullable public String getSyntaxErrors(@Nullable final CFArchType archType) { - if (typeList == null || !hasObjectText()) { - return null; - } - - final CFArchType type = archType != null ? archType : typeList.getTypeOfArch(this); - - final StringBuilder errors = new StringBuilder(); // return value: all error lines - for (final String line : getObjectText().split("\\s*\n")) { - // get only the key-part of the attribute. - final String attrKey = line.contains(" ") ? line.substring(0, line.indexOf(" ")) : line; - - // now check if there's a match in the definitions - boolean doesMatch = false; - /* we exclude "direction" on the hard way */ - if (attrKey.compareTo("direction") == 0) { - doesMatch = true; - } else { - for (int t = 0; t < type.getAttr().length && !doesMatch; t++) { - if (type.getAttr()[t].getNameOld().equals(attrKey)) { - // found a match: - doesMatch = true; - } - } - } - if (!doesMatch) { - errors.append(line.trim()).append('\n'); // append line to the errors - /* - // the attribute doesn't match the definitions, - // now check if it is a negation of an entry in the default arch - if (line.contains(" ")) { - String attr_val = line.substring(line.indexOf(" ")).trim(); - if (!(archetype.getAttributeString(attrKey, null).length() > 0 && (attr_val.equals("0") || attr_val.equals("null") || attr_val.equals("none")))) { - errors.append(line.trim()).append('\n'); // append line to the errors - } - } else { - errors.append(line.trim()).append('\n'); // append line to the errors - } - */ - } - } - - // return errors, or null if empty - final String retErrors = errors.toString(); - if (retErrors.trim().length() == 0) { - return null; - } - return retErrors; - } - /** {@inheritDoc} */ @NotNull @Override public GameObject createArch() { if (!isArchetype()) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 10:16:44 UTC (rev 3592) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 10:20:35 UTC (rev 3593) @@ -27,7 +27,6 @@ import java.io.Serializable; import javax.swing.ImageIcon; import javax.swing.JList; -import net.sf.gridarta.CFArchType; import net.sf.gridarta.gui.GameObjectAttributesPanel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -395,70 +394,6 @@ } } - /** - * This method checks the objectText for syntax errors. More precisely: It - * reads every line in the objectText and looks if it matches the - * type-definitions (-> see CFArchTypeList) for this arch. If there is no - * match, the line is considered wrong. Of course the type-definitions will - * never be perfect, this should be kept in mind. - * <p/> - * Note that the default arch is ignored in the check. The default arches - * should be correct, and even if not - it isn't the map maker to blame. - * @param archType the type structure belonging to this arch. if null, the - * type is calculated in this function - * @return A String with all lines which don't match the - * type-definitions.<br> If no such "errors" encountered, null is returned. - */ - @Nullable public String getSyntaxErrors(@Nullable final CFArchType archType) { - if (typeList == null || !hasObjectText()) { - return null; - } - - final CFArchType type = archType != null ? archType : typeList.getTypeOfArch(this); - - final StringBuilder errors = new StringBuilder(); // return value: all error lines - for (final String line : getObjectText().split("\\s*\n")) { - // get only the key-part of the attribute. - final String attrKey = line.contains(" ") ? line.substring(0, line.indexOf(" ")) : line; - - // now check if there's a match in the definitions - boolean doesMatch = false; - /* we exclude "direction" on the hard way */ - if (attrKey.compareTo("direction") == 0) { - doesMatch = true; - } else { - for (int t = 0; t < type.getAttr().length && !doesMatch; t++) { - if (type.getAttr()[t].getNameOld().equals(attrKey)) { - // found a match: - doesMatch = true; - } - } - } - if (!doesMatch) { - errors.append(line.trim()).append('\n'); // append line to the errors - /* - // the attribute doesn't match the definitions, - // now check if it is a negation of an entry in the default arch - if (line.contains(" ")) { - String attr_val = line.substring(line.indexOf(" ")).trim(); - if (!(archetype.getAttributeString(attrKey, null).length() > 0 && (attr_val.equals("0") || attr_val.equals("null") || attr_val.equals("none")))) { - errors.append(line.trim()).append('\n'); // append line to the errors - } - } else { - errors.append(line.trim()).append('\n'); // append line to the errors - } - */ - } - } - - // return errors, or null if empty - final String retErrors = errors.toString(); - if (retErrors.trim().length() == 0) { - return null; - } - return retErrors; - } - /** {@inheritDoc} */ @NotNull @Override public GameObject createArch() { if (!isArchetype()) { Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-02-23 10:16:44 UTC (rev 3592) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-02-23 10:20:35 UTC (rev 3593) @@ -23,6 +23,7 @@ import java.util.Map; import java.util.regex.Pattern; import javax.swing.JList; +import net.sf.gridarta.CFArchType; import net.sf.gridarta.CFArchTypeList; import net.sf.gridarta.gui.GameObjectAttributesPanel; import net.sf.gridarta.gui.GUIConstants; @@ -1374,4 +1375,68 @@ squareChanged(); } + /** + * This method checks the objectText for syntax errors. More precisely: It + * reads every line in the objectText and looks if it matches the + * type-definitions (-> see CFArchTypeList) for this arch. If there is no + * match, the line is considered wrong. Of course the type-definitions will + * never be perfect, this should be kept in mind. + * <p/> + * Note that the default arch is ignored in the check. The default arches + * should be correct, and even if not - it isn't the map maker to blame. + * @param archType the type structure belonging to this arch. if null, the + * type is calculated in this function + * @return A String with all lines which don't match the + * type-definitions.<br> If no such "errors" encountered, null is returned. + */ + @Nullable public String getSyntaxErrors(@Nullable final CFArchType archType) { + if (typeList == null || !hasObjectText()) { + return null; + } + + final CFArchType type = archType != null ? archType : typeList.getTypeOfArch(this); + + final StringBuilder errors = new StringBuilder(); // return value: all error lines + for (final String line : getObjectText().split("\\s*\n")) { + // get only the key-part of the attribute. + final String attrKey = line.contains(" ") ? line.substring(0, line.indexOf(" ")) : line; + + // now check if there's a match in the definitions + boolean doesMatch = false; + /* we exclude "direction" on the hard way */ + if (attrKey.compareTo("direction") == 0) { + doesMatch = true; + } else { + for (int t = 0; t < type.getAttr().length && !doesMatch; t++) { + if (type.getAttr()[t].getNameOld().equals(attrKey)) { + // found a match: + doesMatch = true; + } + } + } + if (!doesMatch) { + errors.append(line.trim()).append('\n'); // append line to the errors + /* + // the attribute doesn't match the definitions, + // now check if it is a negation of an entry in the default arch + if (line.contains(" ")) { + String attr_val = line.substring(line.indexOf(" ")).trim(); + if (!(archetype.getAttributeString(attrKey, null).length() > 0 && (attr_val.equals("0") || attr_val.equals("null") || attr_val.equals("none")))) { + errors.append(line.trim()).append('\n'); // append line to the errors + } + } else { + errors.append(line.trim()).append('\n'); // append line to the errors + } + */ + } + } + + // return errors, or null if empty + final String retErrors = errors.toString(); + if (retErrors.trim().length() == 0) { + return null; + } + return retErrors; + } + } // interface GameObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 10:41:00
|
Revision: 3595 http://gridarta.svn.sourceforge.net/gridarta/?rev=3595&view=rev Author: akirschbaum Date: 2008-02-23 02:40:59 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Add AbstractAnimationObjects.addAnimPath() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-02-23 10:23:59 UTC (rev 3594) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-02-23 10:40:59 UTC (rev 3595) @@ -101,4 +101,8 @@ } } + /** {@inheritDoc} */ + @Override public void addAnimPath(final String name, final String path) { + } + } // class AnimationObjects Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-02-23 10:23:59 UTC (rev 3594) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-02-23 10:40:59 UTC (rev 3595) @@ -151,12 +151,8 @@ } } - /** - * Adds name-path pair to <var>animHashTable</var>. - * @param name Name of the object - * @param path Path of directory containing the arc file - */ - public void addAnimPath(final String name, final String path) { + /** {@inheritDoc} */ + @Override public void addAnimPath(final String name, final String path) { animMap.put(name, path); } Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-02-23 10:23:59 UTC (rev 3594) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-02-23 10:40:59 UTC (rev 3595) @@ -38,4 +38,11 @@ super(ACTION_FACTORY.getString("nameOfAnimationObject")); } + /** + * Adds name-path pair to <var>animHashTable</var>. + * @param name Name of the object + * @param path Path of directory containing the arc file + */ + public abstract void addAnimPath(final String name, final String path); + } // class AbstractAnimationObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 12:03:48
|
Revision: 3599 http://gridarta.svn.sourceforge.net/gridarta/?rev=3599&view=rev Author: akirschbaum Date: 2008-02-23 04:03:47 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Use MVC for distribution of map validation errors. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/connectionview/View.java trunk/src/app/net/sf/gridarta/gui/map/MapView.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/map/AutoValidator.java trunk/src/app/net/sf/gridarta/map/MapModel.java trunk/src/app/net/sf/gridarta/map/MapModelListener.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -459,21 +459,11 @@ /** * {@inheritDoc} - * @todo that's not nice here. Instead there should be an error model and error listeners. */ public void validateMap(final MapModel<GameObject, MapArchObject, Archetype> map) { - final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = runMapValidation(map); - for (final MapView<GameObject, MapArchObject, Archetype, ?, ?> mapView : map.getMapControl().getMapViewFrames()) { - mapView.getView().setErrors(errorCollector); - } - mainView.getGameObjectAttributesPanel().setErrors(map, errorCollector); - } - - /** {@inheritDoc} */ - @NotNull public ErrorCollector<GameObject, MapArchObject, Archetype> runMapValidation(@NotNull final MapModel<GameObject, MapArchObject, Archetype> map) { final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = new DefaultErrorCollector<GameObject, MapArchObject, Archetype>(); validators.validateAll(map, errorCollector); - return errorCollector; + map.setErrors(errorCollector); } /** Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -177,7 +177,8 @@ } /** {@inheritDoc} */ - @Override public void setErrors(final ErrorCollector<GameObject, MapArchObject, Archetype> errors) { + public void errorsChanged(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { + final ErrorCollector<GameObject, MapArchObject, Archetype> errors = mapModel.getErrors(); erroneousMapSquares.clear(); erroneousArchObjects.clear(); mapGrid.clearErrors(); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -56,6 +56,7 @@ import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; /** * <code>GameObjectAttributesPanel</code> implements the panel that holds information about @@ -163,16 +164,10 @@ refreshDisplay(); } - /** - * Update the displayed errors. - * - * @param map The map of which the errors has changed. - * - * @param errorCollector The errors. - */ - public void setErrors(final MapModel<GameObject, MapArchObject, Archetype> map, final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector) { - panelDesktop.setForegroundAt(7, errorCollector.getErrors().iterator().hasNext() ? Color.blue : Color.black); - errorListView.setErrors(map, errorCollector); + /** {@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()); } /** Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -119,6 +119,11 @@ // ignore } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { + // ignore + } + }; /** Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -575,21 +575,11 @@ /** * {@inheritDoc} - * @todo that's not nice here. Instead there should be an error model and error listeners. */ public void validateMap(final MapModel<GameObject, MapArchObject, Archetype> map) { - final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = runMapValidation(map); - for (final MapView<GameObject, MapArchObject, Archetype, ?, ?> mapView : map.getMapControl().getMapViewFrames()) { - mapView.getView().setErrors(errorCollector); - } - mainView.getGameObjectAttributesPanel().setErrors(map, errorCollector); - } - - /** {@inheritDoc} */ - @NotNull public ErrorCollector<GameObject, MapArchObject, Archetype> runMapValidation(@NotNull final MapModel<GameObject, MapArchObject, Archetype> map) { final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = new DefaultErrorCollector<GameObject, MapArchObject, Archetype>(); validators.validateAll(map, errorCollector); - return errorCollector; + map.setErrors(errorCollector); } /** Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -41,7 +41,6 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.ErrorCollector; -import net.sf.gridarta.map.validation.ErrorHandler; import net.sf.gridarta.map.validation.ValidationError; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,7 +67,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> */ -public final class CMapViewBasic extends MapViewBasic<GameObject, MapArchObject, Archetype> implements ErrorHandler<GameObject, MapArchObject, Archetype> { +public final class CMapViewBasic extends MapViewBasic<GameObject, MapArchObject, Archetype> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -209,7 +208,8 @@ } /** {@inheritDoc} */ - @Override public void setErrors(final ErrorCollector<GameObject, MapArchObject, Archetype> errors) { + public void errorsChanged(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { + final ErrorCollector<GameObject, MapArchObject, Archetype> errors = mapModel.getErrors(); erroneousMapSquares.clear(); erroneousArchObjects.clear(); mapGrid.clearErrors(); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -56,6 +56,7 @@ import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; /** * <code>GameObjectAttributesPanel</code> implements the panel that holds information about @@ -163,16 +164,10 @@ refreshDisplay(); } - /** - * Update the displayed errors. - * - * @param map The map of which the errors has changed. - * - * @param errorCollector The errors. - */ - public void setErrors(final MapModel<GameObject, MapArchObject, Archetype> map, final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector) { - panelDesktop.setForegroundAt(7, errorCollector.getErrors().iterator().hasNext() ? Color.blue : Color.black); - errorListView.setErrors(map, errorCollector); + /** {@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()); } /** Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -303,16 +303,6 @@ void validateMap(final MapModel<G, A, R> map); /** - * Run all map validators and return the validation errors. Does not update - * the displayed map errors. - * - * @param map The map to validate. - * - * @return The validation errors. - */ - @NotNull ErrorCollector<G, A, R> runMapValidation(@NotNull MapModel<G, A, R> map); - - /** * Invoked when the user wants to reload the images. */ void reloadFaces(); Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -43,6 +43,7 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -194,6 +195,11 @@ // ignore } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + setErrors(mapModel); + } + }; /** @@ -516,4 +522,11 @@ } } + /** + * Update the displayed errors. + * + * @param mapModel the map model of which the errors have changed + */ + protected abstract void setErrors(@NotNull final MapModel<G, A, R> mapModel); + } // class GameObjectAttributesPanel Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -230,6 +230,11 @@ // ignore } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/View.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/View.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -104,6 +104,11 @@ // ignore } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** @@ -143,6 +148,11 @@ // ignore } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapView.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/gui/map/MapView.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -35,6 +35,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlListener; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -97,6 +98,11 @@ updateTitle(); } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -252,6 +252,4 @@ } } - public abstract void setErrors(final ErrorCollector<G, A, R> errors); - } // class MapViewBasic Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -48,6 +48,7 @@ import net.sf.gridarta.gui.maptilelist.MapTileSelectionCache; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -138,6 +139,11 @@ // ignore } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -123,6 +123,11 @@ setModified(); } + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -31,6 +31,8 @@ import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.validation.DefaultErrorCollector; +import net.sf.gridarta.map.validation.ErrorCollector; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -107,6 +109,11 @@ 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 mapControl MapControl to associate with this model. * @param mapArchObject The MapArchObject to associate with this model. @@ -572,6 +579,19 @@ 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; + } + /** 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/map/AutoValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/map/AutoValidator.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -135,6 +135,12 @@ assert mapModel != null; autoValidatorProcessor.addChangedMapModel(mapModel); } + + /** {@inheritDoc} */ + public void errorsChanged(@NotNull final MapModel<G, A, R> mapModel) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -24,6 +24,7 @@ import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.validation.ErrorCollector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -379,4 +380,16 @@ */ @Deprecated MapControl<G, A, R> getMapControl(); + /** + * Sets the errors in this map. + * @param errors the errors + */ + void setErrors(@NotNull ErrorCollector<G, A, R> errors); + + /** + * Gets the errors in this map. + * @return the errors + */ + @NotNull ErrorCollector<G, A, R> getErrors(); + } // interface MapModel Modified: trunk/src/app/net/sf/gridarta/map/MapModelListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModelListener.java 2008-02-23 10:51:18 UTC (rev 3598) +++ trunk/src/app/net/sf/gridarta/map/MapModelListener.java 2008-02-23 12:03:47 UTC (rev 3599) @@ -21,6 +21,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import org.jetbrains.annotations.NotNull; /** * Interface for listeners listening on {@link MapModelEvent}s. @@ -60,4 +61,10 @@ */ void mapObjectsChanged(MapModelEvent<G, A, R> e); + /** + * The errors of a map model have changed. + * @param mapModel the map model that has changed + */ + void errorsChanged(@NotNull MapModel<G, A, R> mapModel); + } // interface MapModelListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 12:13:35
|
Revision: 3602 http://gridarta.svn.sourceforge.net/gridarta/?rev=3602&view=rev Author: akirschbaum Date: 2008-02-23 04:13:40 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:09:53 UTC (rev 3601) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:13:40 UTC (rev 3602) @@ -96,12 +96,6 @@ private final GSplitPane splitPane; - /** Panel with name/face etc. */ - private final JPanel archPanel; - - /** Panel with message text. */ - private final JPanel textPanel; - /** The {@link ErrorListView} holding the error information. */ private final ErrorListView errorListView; @@ -131,10 +125,6 @@ this.errorListView = new ErrorListView(mainControl); mainView = view; - final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - - final MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> monsterControl = new MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - gameObjectTextEditor = new GameObjectTextEditor(); mapArchPanel.setLayout(new BorderLayout()); @@ -149,16 +139,13 @@ mapArchPanel.add(buttonPanel, BorderLayout.WEST); mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - archPanel = createArchPanel(); - textPanel = createTextPanel(); - - panelDesktop.add(archPanel, "Arch"); - panelDesktop.add(textPanel, "Msg Text"); + panelDesktop.add(createArchPanel(), "Arch"); + panelDesktop.add(createTextPanel(), "Msg Text"); panelDesktop.add(scriptPanel, "Scripts"); panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(connectionControl.getView(), "Connection"); + panelDesktop.add(createConnectionPanel(), "Connection"); panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(monsterControl.getView(), "Monster"); + panelDesktop.add(createMonsterPanel(), "Monster"); panelDesktop.add(errorListView, "Warnings"); refreshDisplay(); @@ -569,4 +556,14 @@ 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 12:09:53 UTC (rev 3601) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:13:40 UTC (rev 3602) @@ -96,12 +96,6 @@ private final GSplitPane splitPane; - /** Panel with name/face etc. */ - private final JPanel archPanel; - - /** Panel with message text. */ - private final JPanel textPanel; - /** The {@link ErrorListView} holding the error information. */ private final ErrorListView errorListView; @@ -131,10 +125,6 @@ this.errorListView = new ErrorListView(mainControl); mainView = view; - final ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> connectionControl = new ConnectionControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - - final MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> monsterControl = new MonsterControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); - gameObjectTextEditor = new GameObjectTextEditor(); mapArchPanel.setLayout(new BorderLayout()); @@ -149,16 +139,13 @@ mapArchPanel.add(buttonPanel, BorderLayout.WEST); mapArchPanel.add(panelDesktop, BorderLayout.CENTER); - archPanel = createArchPanel(); - textPanel = createTextPanel(); - - panelDesktop.add(archPanel, "Arch"); - panelDesktop.add(textPanel, "Msg Text"); + panelDesktop.add(createArchPanel(), "Arch"); + panelDesktop.add(createTextPanel(), "Msg Text"); panelDesktop.add(scriptPanel, "Scripts"); panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(connectionControl.getView(), "Connection"); + panelDesktop.add(createConnectionPanel(), "Connection"); panelDesktop.add(lockedItemsControl.getView(), "Locked Items"); - panelDesktop.add(monsterControl.getView(), "Monster"); + panelDesktop.add(createMonsterPanel(), "Monster"); panelDesktop.add(errorListView, "Warnings"); refreshDisplay(); @@ -603,4 +590,14 @@ 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 12:20:29
|
Revision: 3603 http://gridarta.svn.sourceforge.net/gridarta/?rev=3603&view=rev Author: akirschbaum Date: 2008-02-23 04:20:32 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Replace CMainControl with MainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:13:40 UTC (rev 3602) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:20:32 UTC (rev 3603) @@ -19,7 +19,6 @@ package cfeditor.gui; -import cfeditor.CMainControl; import cfeditor.CMainView; import cfeditor.CMapViewBasic; import cfeditor.gameobject.Archetype; @@ -79,7 +78,7 @@ private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; /** Controller of this subview. */ - private final CMainControl mainControl; + private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; private final CMainView mainView; @@ -119,7 +118,7 @@ private final GameObjectTextEditor gameObjectTextEditor; /* Build Panel */ - public GameObjectAttributesPanel(final CMainControl mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { super(mainControl); this.mainControl = mainControl; this.errorListView = new ErrorListView(mainControl); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:13:40 UTC (rev 3602) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:20:32 UTC (rev 3603) @@ -19,7 +19,6 @@ package daieditor.gui; -import daieditor.CMainControl; import daieditor.CMainView; import daieditor.CMapViewBasic; import daieditor.gameobject.Archetype; @@ -79,7 +78,7 @@ private static final String MAPARCHPANEL_LOCATION_KEY = "MainWindowMapArchPanel.dividerLocation"; /** Controller of this subview. */ - private final CMainControl mainControl; + private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; private final CMainView mainView; @@ -119,7 +118,7 @@ private final GameObjectTextEditor gameObjectTextEditor; /* Build Panel */ - public GameObjectAttributesPanel(final CMainControl mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { super(mainControl); this.mainControl = mainControl; this.errorListView = new ErrorListView(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 12:22:00
|
Revision: 3604 http://gridarta.svn.sourceforge.net/gridarta/?rev=3604&view=rev Author: akirschbaum Date: 2008-02-23 04:21:56 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Replace CMainView with MainView. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:20:32 UTC (rev 3603) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:21:56 UTC (rev 3604) @@ -19,7 +19,6 @@ package cfeditor.gui; -import cfeditor.CMainView; import cfeditor.CMapViewBasic; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; @@ -46,6 +45,7 @@ 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; @@ -80,7 +80,7 @@ /** Controller of this subview. */ private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; - private final CMainView mainView; + private final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainView; /** The buttons for the direction panel. * @see #directionButtonGroup @@ -118,7 +118,7 @@ private final GameObjectTextEditor gameObjectTextEditor; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + 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(mainControl); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:20:32 UTC (rev 3603) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:21:56 UTC (rev 3604) @@ -19,7 +19,6 @@ package daieditor.gui; -import daieditor.CMainView; import daieditor.CMapViewBasic; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; @@ -46,6 +45,7 @@ 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; @@ -80,7 +80,7 @@ /** Controller of this subview. */ private final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl; - private final CMainView mainView; + private final MainView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainView; /** The buttons for the direction panel. * @see #directionButtonGroup @@ -118,7 +118,7 @@ private final GameObjectTextEditor gameObjectTextEditor; /* Build Panel */ - public GameObjectAttributesPanel(final MainControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mainControl, final CMainView view, final LockedItemsControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> lockedItemsControl) { + 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(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 12:23:40
|
Revision: 3605 http://gridarta.svn.sourceforge.net/gridarta/?rev=3605&view=rev Author: akirschbaum Date: 2008-02-23 04:23:45 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Remove raw type. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:21:56 UTC (rev 3604) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:23:45 UTC (rev 3605) @@ -96,7 +96,7 @@ private final GSplitPane splitPane; /** The {@link ErrorListView} holding the error information. */ - private final ErrorListView errorListView; + private final ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> errorListView; /** Arch name field. */ private final JTextField archNameField = new JTextField(14); @@ -121,7 +121,7 @@ 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(mainControl); + this.errorListView = new ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); mainView = view; gameObjectTextEditor = new GameObjectTextEditor(); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:21:56 UTC (rev 3604) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:23:45 UTC (rev 3605) @@ -96,7 +96,7 @@ private final GSplitPane splitPane; /** The {@link ErrorListView} holding the error information. */ - private final ErrorListView errorListView; + private final ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> errorListView; /** Arch name field. */ private final JTextField archNameField = new JTextField(14); @@ -121,7 +121,7 @@ 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(mainControl); + this.errorListView = new ErrorListView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic>(mainControl); mainView = view; gameObjectTextEditor = new GameObjectTextEditor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 12:55:08
|
Revision: 3606 http://gridarta.svn.sourceforge.net/gridarta/?rev=3606&view=rev Author: akirschbaum Date: 2008-02-23 04:54:09 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Add Archetype.setObjectFace() to common code base; unify affected code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/gameobject/Archetype.java trunk/daimonin/src/daieditor/io/GameObjectParser.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -130,6 +130,7 @@ reportErrors(mainControl.getMainView()); mainControl.getGridartaObjectsFactory().newGameObjectParser().collectTempList(mainControl, invObjects, fname, true); + connectFaces(); // attach faces to arches // print message if no arches were found if (getArchetypeCount() == 0) { @@ -399,6 +400,12 @@ } } + private void connectFaces() { + for (final Archetype arch : getArchetypes()) { + arch.setObjectFace(); + } + } + /** * {@inheritDoc} * Collects the Archetypes. Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -81,6 +81,10 @@ squareChanged(); } + /** {@inheritDoc} */ + public void setObjectFace() { + } + // lore text @NotNull public String getLoreText() { return loreText; @@ -215,6 +219,7 @@ arch.setArchetype(getArchetype()); arch.setMultiX(multiX); arch.setMultiY(multiY); + arch.setObjectFace(); arch.setDirection(getDirection()); return arch; } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -542,6 +542,9 @@ if (newFace != null) { gameObject.setFaceName(newFace.length() == 0 ? null : newFace); } + + // now lets assign the visible face - perhaps we have still a anim + gameObject.setObjectFace(); imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject)); if (newMsg != null) { Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -203,6 +203,7 @@ final MapModel mapModel = mapSquare.getModel(); mapModel.beginTransaction("Add to inventory"); inv.addLast(invnew); + invnew.setObjectFace(); mapModel.endTransaction(); } @@ -259,6 +260,7 @@ } else { gameObject.setDirection(archetype.getDirection()); } + gameObject.setObjectFace(); // we look for 'type' in the ArchText. In future maybe type should get // a seperate textfield Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -111,6 +111,7 @@ part.setAttributeString("direction", Integer.toString(direction)); } mainControl.getArchetypeParser().postParseGameObject(part, getMapControl().getActiveEditType()); + part.setObjectFace(); } for (final GameObject invObject : archetype) { @@ -175,6 +176,7 @@ } next.getContainer().addLast(newGameObject); + newGameObject.setObjectFace(); mainControl.getArchetypeParser().postParseGameObject(newGameObject, getMapControl().getActiveEditType()); } @@ -188,6 +190,8 @@ gameObject.calculateEditType(getMapControl().getActiveEditType()); } + gameObject.setObjectFace(); + final int mapx = gameObject.getMapX(); final int mapy = gameObject.getMapY(); Modified: trunk/daimonin/src/daieditor/gameobject/Archetype.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Archetype.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/daimonin/src/daieditor/gameobject/Archetype.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -103,16 +103,6 @@ boolean isLowestPart(); - /** - * We set here the real face of the objects, depending on the set face and - * the set animation. The rule is, that a active animation will overrule - * the default face. We will catch it here. This method should always be - * invoked after the face or animation has changed and no other change is - * expected right now, so the changes to animation / face should be - * applied. - */ - void setObjectFace(); - String getFaceObjName(); boolean hasFaceObject(); Modified: trunk/daimonin/src/daieditor/io/GameObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -126,9 +126,4 @@ return false; } - /** {@inheritDoc} */ - @Override protected void postProcess(@NotNull final GameObject gameObject) { - gameObject.setObjectFace(); - } - } // class GameObjectParser Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -260,4 +260,14 @@ */ int getDirection(); + /** + * We set here the real face of the objects, depending on the set face and + * the set animation. The rule is, that a active animation will overrule + * the default face. We will catch it here. This method should always be + * invoked after the face or animation has changed and no other change is + * expected right now, so the changes to animation / face should be + * applied. + */ + void setObjectFace(); + } // interface Archetype Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-02-23 12:23:45 UTC (rev 3605) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-02-23 12:54:09 UTC (rev 3606) @@ -188,7 +188,7 @@ // NOW we post parse the object... // (We calculate only edit types that are active, to save time) mainControl.getArchetypeParser().postParseGameObject(gameObject, mainControl.getEditType()); - postProcess(gameObject); + gameObject.setObjectFace(); if (!gameObject.isInContainer()) { mainControl.getArchetypeParser().expandMulti(gameObject, tailList); @@ -210,12 +210,4 @@ } } - /** - * Performs implementation-specific per-gameobject post processing. - * Invoked from {@link #collectTempList(java.util.List, String, boolean)}. - * @param gameObject GameObject to perform postprocessing on. - */ - protected void postProcess(@NotNull final G gameObject) { - } - } // class AbstractGameObjectParser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 13:09:26
|
Revision: 3607 http://gridarta.svn.sourceforge.net/gridarta/?rev=3607&view=rev Author: akirschbaum Date: 2008-02-23 05:09:18 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Add Archetype.setRealFace() to common code base; unify affected code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-02-23 12:54:09 UTC (rev 3606) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-02-23 13:09:18 UTC (rev 3607) @@ -335,6 +335,7 @@ if (gameObject.getDirection() == -1) { // still the invalid direction! gameObject.setDirection(archetype.getDirection()); } + gameObject.setRealFace(gameObject.getFaceName()); // if the type is still unset, then we take the default one if (gameObject.getArchTypNr() == net.sf.gridarta.gameobject.GameObject.TYPE_UNSET) { gameObject.setArchTypNr(archetype.getArchTypNr()); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 12:54:09 UTC (rev 3606) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 13:09:18 UTC (rev 3607) @@ -82,6 +82,10 @@ } /** {@inheritDoc} */ + public void setRealFace(@Nullable final String name) { + } + + /** {@inheritDoc} */ public void setObjectFace() { } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 12:54:09 UTC (rev 3606) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2008-02-23 13:09:18 UTC (rev 3607) @@ -252,6 +252,11 @@ 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) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 12:54:09 UTC (rev 3606) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 13:09:18 UTC (rev 3607) @@ -166,12 +166,7 @@ return faceObjName; } - /** - * Set The "face >name>" field of a object. We need this for fast - * access. We set here the string name, the face number and we will handle - * invalid/double names including comparing with a default arch. - * @param name Real face name. - */ + /** {@inheritDoc} */ public void setRealFace(@Nullable final String name) { final String face = getArchetype().getFaceName(); Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 12:54:09 UTC (rev 3606) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 13:09:18 UTC (rev 3607) @@ -270,4 +270,12 @@ */ void setObjectFace(); + /** + * Set The "face >name>" field of a object. We need this for fast + * access. We set here the string name, the face number and we will handle + * invalid/double names including comparing with a default arch. + * @param name Real face name. + */ + void setRealFace(@Nullable String name); + } // interface Archetype This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 13:25:26
|
Revision: 3609 http://gridarta.svn.sourceforge.net/gridarta/?rev=3609&view=rev Author: akirschbaum Date: 2008-02-23 05:25:30 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Add Archetype.setAnimName() to common code base; unify affected code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-02-23 13:19:42 UTC (rev 3608) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-02-23 13:25:30 UTC (rev 3609) @@ -175,6 +175,8 @@ } archetype.addObjectText("animation " + archetype.getArchetypeName()); + archetype.setAnimName(archetype.getArchetypeName()); + // here we must add this to AnimationObject // and add Animation cmd here! animflag = false; @@ -244,6 +246,11 @@ } else { if (thisLine.equals("msg")) { msgflag = true; + } else if (thisLine.startsWith("animation ")) { + archetype.addObjectText(thisLine); + final String animName = thisLine.substring(10).trim(); + archetype.setAnimName(animName); + //arch.setAnimNr(mainControl.animationObjects.findAnimObject(animName)); // probably not needed, but better not delete it yet } else if (thisLine.equals("anim")) { animflag = true; animText = new StringBuilder(); @@ -325,6 +332,9 @@ if (line.length() > 0) { if (line.startsWith("name ")) { gameObject.setObjName(line.substring(5)); + } else if (line.startsWith("animation ")) { + gameObject.setAnimName(line.substring(10)); + gameObject.addObjectText(line); } else { // this is an unparsed arch attribute, it has to stay in the archtext gameObject.addObjectText(line); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 13:19:42 UTC (rev 3608) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-02-23 13:25:30 UTC (rev 3609) @@ -105,6 +105,10 @@ } /** {@inheritDoc} */ + public void setAnimName(@Nullable final String animName) { + } + + /** {@inheritDoc} */ @Nullable public String getAnimName() { return null; } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-02-23 13:19:42 UTC (rev 3608) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2008-02-23 13:25:30 UTC (rev 3609) @@ -336,6 +336,13 @@ } else { newName = ""; } + } else if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { + if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); + gameObject.setAnimName(inline); + } else { + gameObject.setAnimName(archetype.getAnimName()); + } } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { // special case #2: "face"-textfield final String archFaceName = archetype.getFaceName(); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 13:19:42 UTC (rev 3608) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-02-23 13:25:30 UTC (rev 3609) @@ -264,11 +264,7 @@ return transFace; } - /** - * Sets object animation <code>animation <var>animName</var></code>. - * @param animName object animation <code>animation - * <var>animName</var></code> - */ + /** {@inheritDoc} */ public void setAnimName(@Nullable final String animName) { final String newAnimName = animName != null ? animName.intern() : null; // Using == on these Strings is okay, they are both interned. Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 13:19:42 UTC (rev 3608) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-02-23 13:25:30 UTC (rev 3609) @@ -158,6 +158,13 @@ @Nullable String getFaceName(); /** + * Sets object animation <code>animation <var>animName</var></code>. + * @param animName object animation <code>animation + * <var>animName</var></code> + */ + void setAnimName(@Nullable String animName); + + /** * DaiEditor only: Returns the name of the animation. * @return The name of the animation. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |