From: <aki...@us...> - 2007-11-24 12:37:25
|
Revision: 3457 http://gridarta.svn.sourceforge.net/gridarta/?rev=3457&view=rev Author: akirschbaum Date: 2007-11-24 04:37:30 -0800 (Sat, 24 Nov 2007) Log Message: ----------- Remove code having no effect. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-11-24 12:30:38 UTC (rev 3456) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-11-24 12:37:30 UTC (rev 3457) @@ -852,7 +852,7 @@ prefsGroup = new PreferencesGroup( "Gridarta for Crossfire", new ResPrefs(this), - new GUIPrefs(this), + new GUIPrefs(), new MiscPrefs(), new MapValidatorPrefs<GameObject, MapArchObject, Archetype>("cfeditor", validators, PREFS_VALIDATOR_AUTO_DEFAULT) ); // prefsGroup Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-11-24 12:30:38 UTC (rev 3456) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-11-24 12:37:30 UTC (rev 3457) @@ -53,8 +53,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - private final CMainControl mainControl; - /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); @@ -72,11 +70,8 @@ /** * Create a GUIPrefs pane. - * @param mainControl MainControl (used for accessing settings). */ - public GUIPrefs(final CMainControl mainControl) { - this.mainControl = mainControl; - + public GUIPrefs() { setListLabelText(ACTION_FACTORY.getString("prefsGUI.title")); setListLabelIcon(ACTION_FACTORY.getIcon("prefsGUI.icon")); @@ -103,7 +98,6 @@ prefs.remove(MainControl.PREFS_LANGUAGE); } prefs.putBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); - mainControl.readGlobalSettings(); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-02-23 20:38:22
|
Revision: 3626 http://gridarta.svn.sourceforge.net/gridarta/?rev=3626&view=rev Author: akirschbaum Date: 2008-02-23 12:38:26 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:37:49 UTC (rev 3625) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2008-02-23 20:38:26 UTC (rev 3626) @@ -48,6 +48,9 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + /** * Constructs a level model. * @param mainControl main controller @@ -74,6 +77,13 @@ final int mapx = gameObject.getMapX(); final int mapy = gameObject.getMapY(); + if (!isPointValid(new Point(mapx, mapy))) { + // TODO: + // Think about how this could be handled via an exception and caught much earlier, perhaps already while reading the map, not after it + // already has been read. + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "mapErrorArchOutOfGrid"); + return; + } if (insertBelow) { mapGrid[mapx][mapy].addFirst(gameObject); Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-02-23 20:37:49 UTC (rev 3625) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-02-23 20:38:26 UTC (rev 3626) @@ -66,6 +66,8 @@ mapLoreTabTitle=Lore mapErrorInvalidDarkness.title=Invalid value mapErrorInvalidDarkness.message=Darkness level must be in range 0-5. +mapErrorArchOutOfGrid.title=Arch out of map +mapErrorArchOutOfGrid.message=Removing arch out of map bounds mapRegion=Region mapUnique=Unique map Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-02-23 20:37:49 UTC (rev 3625) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-02-23 20:38:26 UTC (rev 3626) @@ -63,6 +63,8 @@ mapLoreTabTitle=Geschichte mapErrorInvalidDarkness.title=Ung\xFCltiger Wert mapErrorInvalidDarkness.message=Die Dunkelheit muss zwischen 0 und 5 liegen. +mapErrorArchOutOfGrid.title=Archetyp au\xDFerhalb Karte +mapErrorArchOutOfGrid.message=Entferne Archetypen au\xDFerhalb der Karte mapRegion=Region mapUnique=Permanente Karte Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-02-23 20:37:49 UTC (rev 3625) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-02-23 20:38:26 UTC (rev 3626) @@ -64,6 +64,8 @@ #mapLoreTabTitle= #mapErrorInvalidDarkness.title= #mapErrorInvalidDarkness.message= +#mapErrorArchOutOfGrid.title= +#mapErrorArchOutOfGrid.message= #mapRegion= #mapUnique= Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-02-23 20:37:49 UTC (rev 3625) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-02-23 20:38:26 UTC (rev 3626) @@ -62,6 +62,8 @@ #mapLoreTabTitle= #mapErrorInvalidDarkness.title= #mapErrorInvalidDarkness.message= +mapErrorArchOutOfGrid.title=Objekt utanf\xF6r kartan +mapErrorArchOutOfGrid.message=Avl\xE4gsnar objekt utanf\xF6r kartan #mapRegion= #mapUnique= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-01 23:05:55
|
Revision: 3811 http://gridarta.svn.sourceforge.net/gridarta/?rev=3811&view=rev Author: akirschbaum Date: 2008-04-01 16:06:00 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Unify CMainView. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 23:01:13 UTC (rev 3810) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-04-01 23:06:00 UTC (rev 3811) @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.MissingResourceException; +import java.util.ResourceBundle; import java.util.prefs.Preferences; import javax.swing.JFileChooser; import javax.swing.JMenu; @@ -941,6 +942,14 @@ return mapCursorControl; } + public static String getBuildNumberAsString() { + try { + return ResourceBundle.getBundle("build").getString("build.number"); + } catch (final MissingResourceException e) { + return "unknown version"; + } + } + /** {@inheritDoc} */ public RecentManager getRecentManager() { return recentManager; Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 23:01:13 UTC (rev 3810) +++ trunk/crossfire/src/cfeditor/CMainView.java 2008-04-01 23:06:00 UTC (rev 3811) @@ -145,7 +145,7 @@ * @param aCloseAll the action "close all map windows" */ CMainView(@NotNull final CMainControl mainControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> mapManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll) { - super(mainControl, mapManager, actionFactory.format("mainWindow.title")); + super(mainControl, mapManager, actionFactory.format("mainWindow.title", CMainControl.getBuildNumberAsString())); this.mainControl = mainControl; this.actionFactory = actionFactory; aViewTreasurelists = actionFactory.createAction(true, "viewTreasurelists", mainControl); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-08 07:38:06
|
Revision: 3849 http://gridarta.svn.sourceforge.net/gridarta/?rev=3849&view=rev Author: akirschbaum Date: 2008-04-08 00:38:11 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Remove access to mainControl.getMainView(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-08 07:27:34 UTC (rev 3848) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-08 07:38:11 UTC (rev 3849) @@ -121,7 +121,7 @@ getViewport().setViewPosition(initial); } - mapUserListener = new MapUserListener(mainControl, mapControl, this); + mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getMainView().getObjectChooser()); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); renderer.setErroneousMapSquares(erroneousMapSquares); Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-04-08 07:27:34 UTC (rev 3848) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-04-08 07:38:11 UTC (rev 3849) @@ -21,13 +21,16 @@ import cfeditor.CMainControl; import cfeditor.CMapViewBasic; +import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import java.awt.Point; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import net.sf.gridarta.gui.InsertionObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; @@ -48,14 +51,17 @@ private final CMainControl mainControl; + private final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser; + private final Point tmpPoint = new Point(); @NotNull private final CMapViewBasic mapView; - public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView) { + public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView, final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser) { this.mainControl = mainControl; this.mapControl = mapControl; this.mapView = mapView; + this.insertionObjectChooser = insertionObjectChooser; mapCursor = mapView.getMapCursor(); renderer = mapView.getRenderer(); } @@ -142,7 +148,7 @@ mapCursor.dragStart(); if (mapCursor.isActive() && mapControl.isPickmap()) { // an arch of a pickmap was selected - mainControl.getMainView().getObjectChooser().showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); + insertionObjectChooser.showObjectChooserQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); } mapCursor.endTransaction(); } else if (isDelete(e)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-08 07:46:36
|
Revision: 3850 http://gridarta.svn.sourceforge.net/gridarta/?rev=3850&view=rev Author: akirschbaum Date: 2008-04-08 00:46:35 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Remove calls to mainControl.getMainView(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-08 07:38:11 UTC (rev 3849) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2008-04-08 07:46:35 UTC (rev 3850) @@ -121,7 +121,7 @@ getViewport().setViewPosition(initial); } - mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getMainView().getObjectChooser()); + mapUserListener = new MapUserListener(mainControl, mapControl, this, mainControl.getMainView().getObjectChooser(), mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView(), mainControl.getMainView().getObjectChooser().getPickmapChooserControl()); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); renderer.setErroneousMapSquares(erroneousMapSquares); Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-04-08 07:38:11 UTC (rev 3849) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-04-08 07:46:35 UTC (rev 3850) @@ -34,6 +34,8 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,15 +55,21 @@ private final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser; + private final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView; + + private final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl; + private final Point tmpPoint = new Point(); @NotNull private final CMapViewBasic mapView; - public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView, final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser) { + public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView, final InsertionObjectChooser<GameObject, MapArchObject, Archetype> insertionObjectChooser, final SelectedSquareView<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> selectedSquareView, final PickmapChooserControl<GameObject, MapArchObject, Archetype, MapControl, CMapViewBasic> pickmapChooserControl) { this.mainControl = mainControl; this.mapControl = mapControl; this.mapView = mapView; this.insertionObjectChooser = insertionObjectChooser; + this.selectedSquareView = selectedSquareView; + this.pickmapChooserControl = pickmapChooserControl; mapCursor = mapView.getMapCursor(); renderer = mapView.getRenderer(); } @@ -92,7 +100,7 @@ mapControl.getMapModel().beginTransaction("Insert Object"); final GameObject insertedObject = mapControl.insertSelectedObject(temp, false); mapControl.getMapModel().endTransaction(); - mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); + selectedSquareView.setSelectedGameObject(insertedObject); } } else if (isDelete(e)) { if (mapCursor.setLocation(temp) && temp != null) { @@ -128,13 +136,13 @@ if (mapLoc != null) { // in "locked pickmaps" mode, pickmaps react only to leftclicks - if (mapControl.isPickmap() && mainControl.getMainView().getObjectChooser().getPickmapChooserControl().isLockAllPickmaps() && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { + if (mapControl.isPickmap() && pickmapChooserControl.isLockAllPickmaps() && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { return; } // right mouse button: insert arch if (isInsert(e)) { - if (!mapControl.isPickmap() || !mainControl.getMainView().getObjectChooser().getPickmapChooserControl().isLockAllPickmaps()) { + if (!mapControl.isPickmap() || !pickmapChooserControl.isLockAllPickmaps()) { mapCursor.setLocation(mapLoc); insertObject(mapLoc); } @@ -152,7 +160,7 @@ } mapCursor.endTransaction(); } else if (isDelete(e)) { - if (!mapControl.isPickmap() || !mainControl.getMainView().getObjectChooser().getPickmapChooserControl().isLockAllPickmaps()) { + if (!mapControl.isPickmap() || !pickmapChooserControl.isLockAllPickmaps()) { mapCursor.setLocation(mapLoc); deleteObject(mapLoc); } @@ -167,7 +175,7 @@ mapControl.getMapModel().beginTransaction("Insert Object"); final GameObject insertedObject = mapControl.insertSelectedObject(mapLoc, true); mapControl.getMapModel().endTransaction(); - mainControl.getMainView().getSelectedSquareControl().getSelectedSquareView().setSelectedGameObject(insertedObject); + selectedSquareView.setSelectedGameObject(insertedObject); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-04-11 19:16:13
|
Revision: 3876 http://gridarta.svn.sourceforge.net/gridarta/?rev=3876&view=rev Author: akirschbaum Date: 2008-04-11 12:16:00 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Fix crash due to NullPointerException. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/script/parameter/ParameterTypeEditor.java trunk/crossfire/src/cfeditor/script/ScriptModel.java trunk/crossfire/src/cfeditor/script/parameter/PluginParameter.java trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java Added Paths: ----------- trunk/crossfire/src/cfeditor/script/parameter/NoSuchParameterException.java Modified: trunk/crossfire/src/cfeditor/gui/script/parameter/ParameterTypeEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/script/parameter/ParameterTypeEditor.java 2008-04-11 17:50:16 UTC (rev 3875) +++ trunk/crossfire/src/cfeditor/gui/script/parameter/ParameterTypeEditor.java 2008-04-11 19:16:00 UTC (rev 3876) @@ -20,14 +20,19 @@ package cfeditor.gui.script.parameter; import cfeditor.script.ScriptModel; +import cfeditor.script.parameter.NoSuchParameterException; import cfeditor.script.parameter.PluginParameter; import cfeditor.script.parameter.PluginParameterFactory; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JComboBox; +import org.apache.log4j.Logger; public class ParameterTypeEditor extends JComboBox { + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ParameterTypeEditor.class); + private final PluginParameter parameter; private final ScriptModel theScript; @@ -43,7 +48,11 @@ public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (!parameter.getType().equals(e.getItem())) { - theScript.convertType(parameter, (String) e.getItem()); + try { + theScript.convertType(parameter, (String) e.getItem()); + } catch (final NoSuchParameterException ex) { + log.warn("Cannot create parameter for type " + e.getItem()); + } } } } Modified: trunk/crossfire/src/cfeditor/script/ScriptModel.java =================================================================== --- trunk/crossfire/src/cfeditor/script/ScriptModel.java 2008-04-11 17:50:16 UTC (rev 3875) +++ trunk/crossfire/src/cfeditor/script/ScriptModel.java 2008-04-11 19:16:00 UTC (rev 3876) @@ -19,6 +19,7 @@ package cfeditor.script; +import cfeditor.script.parameter.NoSuchParameterException; import cfeditor.script.parameter.PluginParameter; import cfeditor.script.parameter.PluginParameterFactory; import java.io.File; @@ -234,7 +235,13 @@ } public void newParameter() { - final PluginParameter p = PluginParameterFactory.createParameter((String) null); + final PluginParameter p; + try { + p = PluginParameterFactory.createParameter((String) null); + } catch (final NoSuchParameterException ex) { + log.warn("Cannot create parameter: " + ex.getMessage()); + return; + } params.add(p); modified = true; notifyListeners(); @@ -390,7 +397,13 @@ final List<Element> params = node.getChildren("parameter"); if (params != null && !params.isEmpty()) { for (final Element parameter : params) { - final PluginParameter p = PluginParameterFactory.createParameter(parameter); + final PluginParameter p; + try { + p = PluginParameterFactory.createParameter(parameter); + } catch (final NoSuchParameterException ex) { + log.warn("Cannot create parameter type " + ex.getMessage() + ", dropping parameter"); + continue; + } addParameter(p); } } @@ -431,13 +444,13 @@ return root; } - public void convertType(final int index, final String newType) { + public void convertType(final int index, final String newType) throws NoSuchParameterException { params.set(index, PluginParameterFactory.createParameter(newType, params.get(index).toXML())); modified = true; notifyListeners(); } - public void convertType(final PluginParameter param, final String newType) { + public void convertType(final PluginParameter param, final String newType) throws NoSuchParameterException { final int index = params.indexOf(param); convertType(index, newType); } Added: trunk/crossfire/src/cfeditor/script/parameter/NoSuchParameterException.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/NoSuchParameterException.java (rev 0) +++ trunk/crossfire/src/cfeditor/script/parameter/NoSuchParameterException.java 2008-04-11 19:16:00 UTC (rev 3876) @@ -0,0 +1,41 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.script.parameter; + +import org.jetbrains.annotations.NotNull; + +/** + * Thrown if a parameter does not exist. + * @author Andreas Kirschbaum + */ +public class NoSuchParameterException extends Exception { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** + * Creates a new instance. + * @param type the missing parameter type + */ + public NoSuchParameterException(@NotNull final String type) { + super(type); + } + +} // class NoSuchParameterException Property changes on: trunk/crossfire/src/cfeditor/script/parameter/NoSuchParameterException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/script/parameter/PluginParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/PluginParameter.java 2008-04-11 17:50:16 UTC (rev 3875) +++ trunk/crossfire/src/cfeditor/script/parameter/PluginParameter.java 2008-04-11 19:16:00 UTC (rev 3876) @@ -142,7 +142,11 @@ } @Nullable @Override public Object clone() throws CloneNotSupportedException { - return PluginParameterFactory.createParameter(toXML()); + try { + return PluginParameterFactory.createParameter(toXML()); + } catch (final NoSuchParameterException ex) { + throw new AssertionError(); + } } } // class PluginParameter Modified: trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-04-11 17:50:16 UTC (rev 3875) +++ trunk/crossfire/src/cfeditor/script/parameter/PluginParameterFactory.java 2008-04-11 19:16:00 UTC (rev 3876) @@ -23,6 +23,7 @@ import java.util.Map; import org.apache.log4j.Logger; import org.jdom.Element; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -51,14 +52,15 @@ throw new UnsupportedOperationException("Class PluginParameterFactory can not be instanciated"); } - @Nullable public static PluginParameter createParameter(final Element parameterNode) { + @Nullable public static PluginParameter createParameter(final Element parameterNode) throws NoSuchParameterException { return createParameter(parameterNode.getChildText("type"), parameterNode); } - @Nullable public static PluginParameter createParameter(@Nullable final String type) { - final Class<? extends PluginParameter> c = parameterTypes.get(type == null ? "java.lang.String" : type); + @NotNull public static PluginParameter createParameter(@Nullable final String type) throws NoSuchParameterException { + final String typeClass = type == null ? "java.lang.String" : type; + final Class<? extends PluginParameter> c = parameterTypes.get(typeClass); if (c == null) { - return null; + throw new NoSuchParameterException(typeClass); } try { @@ -69,14 +71,15 @@ return c.newInstance(); } catch (final Exception e) { e.printStackTrace(); - return null; + throw new NoSuchParameterException(typeClass); } } - @Nullable public static PluginParameter createParameter(@Nullable final String type, final Element parameterNode) { - final Class<? extends PluginParameter> c = parameterTypes.get(type == null ? "java.lang.String" : type); + @NotNull public static PluginParameter createParameter(@Nullable final String type, final Element parameterNode) throws NoSuchParameterException { + final String typeClass = type == null ? "java.lang.String" : type; + final Class<? extends PluginParameter> c = parameterTypes.get(typeClass); if (c == null) { - return null; + throw new NoSuchParameterException(typeClass); } try { @@ -85,7 +88,7 @@ return p; } catch (final Exception e) { e.printStackTrace(); - return null; + throw new NoSuchParameterException(typeClass); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-05-17 17:56:51
|
Revision: 4028 http://gridarta.svn.sourceforge.net/gridarta/?rev=4028&view=rev Author: akirschbaum Date: 2008-05-17 10:56:51 -0700 (Sat, 17 May 2008) Log Message: ----------- ArchetypeSet.loadAllCrossfirePNGFromCollect() to FaceObjects.loadFacesCollection() Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-05-17 17:53:59 UTC (rev 4027) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-05-17 17:56:51 UTC (rev 4028) @@ -26,15 +26,12 @@ import cfeditor.map.MapArchObject; import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -164,10 +161,12 @@ } finally { stream.close(); } - loadAllCrossfirePNGFromCollect(); + mainControl.getFaceObjects().loadFacesCollection(new File(baseDir, IGUIConstants.PNG_FILE), new File(mainControl.getConfigurationDirectory(), IGUIConstants.FACETREE_FILE)); } catch (final IOException e) { // TODO log.error("Error:", e); + } catch (final DuplicateFaceException e) { + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getFilename(), e.getExisting().getFilename()); } } @@ -243,128 +242,6 @@ } } - /** Loads all pngs from the big collected png file. */ - @SuppressWarnings({"UnnecessaryLabelOnBreakStatement"}) private void loadAllCrossfirePNGFromCollect() { - final String baseDir = mainControl.getCollectedDirectory(); - final byte[] buf; - try { - final InputStream inputStream = IOUtils.createStream(baseDir, IGUIConstants.PNG_FILE); - final ByteArrayOutputStream tmp = new ByteArrayOutputStream(); - try { - final byte[] tmp2 = new byte[65536]; - for (;;) { - final int len = inputStream.read(tmp2); - if (len < 0) { - break; - } - assert len > 0; - tmp.write(tmp2, 0, len); - } - } finally { - inputStream.close(); - } - buf = tmp.toByteArray(); - } catch (final FileNotFoundException e) { - log.warn("file " + IGUIConstants.PNG_FILE + " not found!"); - return; - } catch (final IOException e) { - log.warn("Read error in file '" + IGUIConstants.PNG_FILE + "'.", e); - return; - } - int pos = 0; -LOAD: while (pos < buf.length) { - int startPos = pos; - while (pos < buf.length && buf[pos] != '\n') { - pos++; - } - if (pos >= buf.length) { - log.warn("Truncated file " + IGUIConstants.PNG_FILE + "."); - break LOAD; - } - - // check for "IMAGE " - if (pos - startPos < 6 - || buf[startPos + 0] != 'I' - || buf[startPos + 1] != 'M' - || buf[startPos + 2] != 'A' - || buf[startPos + 3] != 'G' - || buf[startPos + 4] != 'E' - || buf[startPos + 5] != ' ') { - log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); - break LOAD; - } - startPos += 6; - - // skip image number - while (startPos < pos && buf[startPos] != ' ') { - startPos++; - } - if (startPos >= pos) { - log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); - break LOAD; - } - startPos++; - - // read image data size - int size = 0; - while (startPos < pos && buf[startPos] != ' ') { - if (buf[startPos] < '0' || buf[startPos] > '9') { - log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); - break LOAD; - } - size = 10 * size + (buf[startPos] - '0'); - startPos++; - } - if (startPos >= pos) { - log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); - break LOAD; - } - startPos++; - - // read face name - int startFaceName = startPos; - int endFaceName = pos; - while (startPos < pos) { - if (buf[startPos] == '/') { - startFaceName = startPos + 1; - endFaceName = pos; - } else if (buf[startPos] == '.') { - endFaceName = pos; - } - startPos++; - } - final String face; - try { - face = new String(buf, startFaceName, endFaceName - startFaceName, "UTF-8"); - } catch (final UnsupportedEncodingException ex) { - throw new AssertionError(); - } - - // skip '\n' character - pos++; - if (pos >= buf.length) { - log.warn("Truncated file " + IGUIConstants.PNG_FILE + "."); - break LOAD; - } - - // check that the face data is not truncated - if (pos + size > buf.length) { - log.warn("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + pos + "."); - break LOAD; - } - - // add new face - try { - mainControl.getFaceObjects().addFaceObject(face, "null", baseDir, IGUIConstants.PNG_FILE, pos, size); - } catch (final DuplicateFaceException ex) { - log.warn("Duplicate face " + face); - } - - // skip face data - pos += size; - } - } - /** * Load a png from the file, convert it to IconImage and attach it to the * facelist. Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-05-17 17:53:59 UTC (rev 4027) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-05-17 17:56:51 UTC (rev 4028) @@ -22,17 +22,21 @@ import cfeditor.IGUIConstants; import java.io.BufferedOutputStream; import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; import java.util.Iterator; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.DuplicateFaceException; +import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; @@ -88,6 +92,135 @@ put(faceObject); } + /** + * Loads all faces from a png collection file. + * @param faceFile file to load faces from + * @param treeFile file to load tree information from + * @throws IOException in case of I/O errors + * @throws FileNotFoundException in case the file couldn't be opened + * @throws DuplicateFaceException in case a face was not unique + */ + public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { + final String actualFilename = faceFile.toString(); + final String baseDir = mainControl.getCollectedDirectory(); + final byte[] data; + try { + final InputStream inputStream = IOUtils.createStream(baseDir, IGUIConstants.PNG_FILE); + final ByteArrayOutputStream bufOut = new ByteArrayOutputStream(); + try { + final byte[] buf = new byte[65536]; + for (;;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + bufOut.write(buf, 0, len); + } + } finally { + inputStream.close(); + } + data = bufOut.toByteArray(); + } catch (final FileNotFoundException e) { + log.warn("file " + IGUIConstants.PNG_FILE + " not found!"); + return; + } catch (final IOException e) { + log.warn("Read error in file '" + IGUIConstants.PNG_FILE + "'.", e); + return; + } + int pos = 0; +LOAD: while (pos < data.length) { + int startPos = pos; + while (pos < data.length && data[pos] != '\n') { + pos++; + } + if (pos >= data.length) { + log.warn("Truncated file " + IGUIConstants.PNG_FILE + "."); + break LOAD; + } + + // check for "IMAGE " + if (pos - startPos < 6 + || data[startPos + 0] != 'I' + || data[startPos + 1] != 'M' + || data[startPos + 2] != 'A' + || data[startPos + 3] != 'G' + || data[startPos + 4] != 'E' + || data[startPos + 5] != ' ') { + log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); + break LOAD; + } + startPos += 6; + + // skip image number + while (startPos < pos && data[startPos] != ' ') { + startPos++; + } + if (startPos >= pos) { + log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); + break LOAD; + } + startPos++; + + // read image data size + int size = 0; + while (startPos < pos && data[startPos] != ' ') { + if (data[startPos] < '0' || data[startPos] > '9') { + log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); + break LOAD; + } + size = 10 * size + (data[startPos] - '0'); + startPos++; + } + if (startPos >= pos) { + log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + startPos + "."); + break LOAD; + } + startPos++; + + // read face name + int startFaceName = startPos; + int endFaceName = pos; + while (startPos < pos) { + if (data[startPos] == '/') { + startFaceName = startPos + 1; + endFaceName = pos; + } else if (data[startPos] == '.') { + endFaceName = pos; + } + startPos++; + } + final String face; + try { + face = new String(data, startFaceName, endFaceName - startFaceName, "UTF-8"); + } catch (final UnsupportedEncodingException ex) { + throw new AssertionError(); + } + + // skip '\n' character + pos++; + if (pos >= data.length) { + log.warn("Truncated file " + IGUIConstants.PNG_FILE + "."); + break LOAD; + } + + // check that the face data is not truncated + if (pos + size > data.length) { + log.warn("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + pos + "."); + break LOAD; + } + + // add new face + try { + addFaceObject(face, "null", baseDir + "/" + IGUIConstants.PNG_FILE, actualFilename, pos, size); + } catch (final DuplicateFaceException ex) { + log.warn("Duplicate face " + face); + } + + // skip face data + pos += size; + } + } + /** {@inheritDoc} */ @Override protected void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { DataOutputStream binFile = null; Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-05-17 17:53:59 UTC (rev 4027) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-05-17 17:56:51 UTC (rev 4028) @@ -58,6 +58,9 @@ openScriptNotFound.title=Script file not found openScriptNotFound.message=The file ''{0}'' does not exist.\nPlease correct the path. +loadDuplicateFace.title=Error: Duplicate face +loadDuplicateFace.message=Warning!\n\nDuplicate face: ''{0}''\nFiles: ''{1}''\nand ''{2}''\nI will ignore this duplicate. + # Map Properties mapParametersTabTitle=Parameters mapShopTabTitle=Shop Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-05-17 17:53:59 UTC (rev 4027) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-05-17 17:56:51 UTC (rev 4028) @@ -55,6 +55,9 @@ openScriptNotFound.title=Script-Datei nicht gefunden openScriptNotFound.message=Die Datei ''{0}'' existiert nicht.\nBitte geben sie einen g\xFCltigen Dateinamen an. +loadDuplicateFace.title=Fehler: doppelte Grafik +loadDuplicateFace.message=Warning!\n\nDopplete Grafik: ''{0}''\nDateien: ''{1}''\nund ''{2}''\nDie doppelte Grafik wird ignoriert. + # Map Properties mapParametersTabTitle=Parameter mapShopTabTitle=Gesch\xE4ft Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-05-17 17:53:59 UTC (rev 4027) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-05-17 17:56:51 UTC (rev 4028) @@ -56,6 +56,9 @@ #openScriptNotFound.title= #openScriptNotFound.message= +#loadDuplicateFace.title= +#loadDuplicateFace.message= + # Map Properties #mapParametersTabTitle= #mapShopTabTitle= Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-05-17 17:53:59 UTC (rev 4027) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-05-17 17:56:51 UTC (rev 4028) @@ -54,6 +54,9 @@ openScriptNotFound.title=Kunde inte hitta scriptfil openScriptNotFound.message=Filen ''{0}'' finns inte.\nV\xE4r v\xE4nlig korrigera s\xF6kv\xE4gen. +loadDuplicateFace.title=Fel: duplicerad bild +loadDuplicateFace.message=Varning!\n\nDuplicerad bild: ''{0}''\nFiler: ''{1}''\noch ''{2}''\nJag kommer att ignorera detta duplikat. + # Map Properties #mapParametersTabTitle= #mapShopTabTitle= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-03 21:12:48
|
Revision: 4069 http://gridarta.svn.sourceforge.net/gridarta/?rev=4069&view=rev Author: akirschbaum Date: 2008-06-03 14:12:29 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-03 21:09:33 UTC (rev 4068) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-03 21:12:29 UTC (rev 4069) @@ -296,7 +296,7 @@ mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); archetypeParser = new ArchetypeParser(this, objectChooser.getArchetypeChooserControl(), animationObjects); - faceObjects = new FaceObjects(this); + faceObjects = new FaceObjects(mainView, this); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-03 21:09:33 UTC (rev 4068) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-03 21:12:29 UTC (rev 4069) @@ -33,6 +33,7 @@ import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.Iterator; +import java.awt.Component; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.DuplicateFaceException; @@ -54,11 +55,16 @@ /** The main control. */ @NotNull private final MainControl<?, ?, ?, ?> mainControl; + /** The parent component for error messages. */ + @NotNull private final Component parent; + /** * Creates a new instance. + * @param parent the parent component for error messages * @param mainControl the main control */ - public FaceObjects(@NotNull final MainControl<?, ?, ?, ?> mainControl) { + public FaceObjects(@NotNull final Component parent, @NotNull final MainControl<?, ?, ?, ?> mainControl) { + this.parent = parent; this.mainControl = mainControl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-03 22:19:44
|
Revision: 4084 http://gridarta.svn.sourceforge.net/gridarta/?rev=4084&view=rev Author: akirschbaum Date: 2008-06-03 15:19:49 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Unify crossfire.0 writing code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-03 22:04:55 UTC (rev 4083) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-03 22:19:49 UTC (rev 4084) @@ -20,10 +20,9 @@ package cfeditor.gameobject.face; import cfeditor.IGUIConstants; -import java.io.BufferedOutputStream; +import java.awt.Component; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -31,9 +30,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; +import java.io.PrintStream; import java.io.UnsupportedEncodingException; -import java.util.Iterator; -import java.awt.Component; +import java.nio.channels.FileChannel; import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.DuplicateFaceException; @@ -229,22 +228,28 @@ /** {@inheritDoc} */ @Override protected void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - DataOutputStream binFile = null; final File dfile = new File(dir, IGUIConstants.PNG_FILE); - binFile = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dfile))); + final FileOutputStream fout = new FileOutputStream(dfile); + //It's safely closed because the stream is closed and that closes the channel. + //noinspection ChannelOpenedButNotSafelyClosed + final FileChannel outChannel = fout.getChannel(); + final PrintStream binFile = new PrintStream(fout); try { - final byte[] imgBuffer = new byte[IMAGE_BUFFER_SIZE]; - int numBytes; - final int numOfFaceObjects = size(); progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); int i = 0; for (final FaceObject faceObject : this) { + final String face = faceObject.getPath(); final String path = faceObject.getActualFilename(); try { final FileInputStream fin = new FileInputStream(path); try { - numBytes = fin.read(imgBuffer, 0, IMAGE_BUFFER_SIZE); + //It's safely closed because the stream is closed and that closes the channel. + //noinspection ChannelOpenedButNotSafelyClosed + final FileChannel inChannel = fin.getChannel(); + final int imageSize = (int) inChannel.size(); + binFile.format("IMAGE %d %d %s\n", i, imageSize, face); + inChannel.transferTo(0, imageSize, outChannel); } finally { fin.close(); } @@ -256,15 +261,6 @@ return; } - if (numBytes == -1) { - ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileUnexpectedEOF", path); - return; - } - - // now write this png data into the big collected png file - binFile.writeBytes("IMAGE " + i + " " + numBytes + " " + faceObject.getPath() + "\n"); - binFile.write(imgBuffer, 0, numBytes); - if (i++ % 100 == 0) { progress.setValue(i); } Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-06-03 22:04:55 UTC (rev 4083) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-06-03 22:19:49 UTC (rev 4084) @@ -125,8 +125,6 @@ archCollectWarningMissed.message=Collect Warning: {0} arches have been missed during collect! archCollectErrorFileNotFound.title=Collect error archCollectErrorFileNotFound.message=Collect Error: Cannot open input file\n{0} -archCollectErrorFileUnexpectedEOF.title=Collect error -archCollectErrorFileUnexpectedEOF.message=Collect Error: Unexpected EOF in\n{0} ####### Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-06-03 22:04:55 UTC (rev 4083) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-06-03 22:19:49 UTC (rev 4084) @@ -122,8 +122,6 @@ archCollectWarningMissed.message=Warnung: Beim Sammeln der Archetypen sind wurden {0} Archetypen nicht gefunden. archCollectErrorFileNotFound.title=Fehler beim Sammeln archCollectErrorFileNotFound.message=Kann Eingabedatei nicht \xF6ffnen:\n{0} -archCollectErrorFileUnexpectedEOF.title=Fehler beim Sammeln -archCollectErrorFileUnexpectedEOF.message=Unerwartetes Dateiende erreicht in\n{0} ####### Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-06-03 22:04:55 UTC (rev 4083) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-06-03 22:19:49 UTC (rev 4084) @@ -123,8 +123,6 @@ #archCollectWarningMissed.message= #archCollectErrorFileNotFound.title= #archCollectErrorFileNotFound.message= -#archCollectErrorFileUnexpectedEOF.title= -#archCollectErrorFileUnexpectedEOF.message= ####### Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-06-03 22:04:55 UTC (rev 4083) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-06-03 22:19:49 UTC (rev 4084) @@ -121,8 +121,6 @@ archCollectWarningMissed.message=Varning under sammanst\xE4llning: {0} arketyper saknades under sammanst\xE4llningen! archCollectErrorFileNotFound.title=Fel under sammanst\xE4llning archCollectErrorFileNotFound.message=Fel under sammanst\xE4llning: kan inte \xF6ppna fil\n{0} -archCollectErrorFileUnexpectedEOF.title=Fel under sammanst\xE4llning -archCollectErrorFileUnexpectedEOF.message=Fel under sammanst\xE4llning: ov\xE4ntat filslut i\n{0} ####### This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-04 18:31:50
|
Revision: 4096 http://gridarta.svn.sourceforge.net/gridarta/?rev=4096&view=rev Author: akirschbaum Date: 2008-06-04 11:31:50 -0700 (Wed, 04 Jun 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-04 18:29:08 UTC (rev 4095) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-04 18:31:50 UTC (rev 4096) @@ -771,7 +771,6 @@ /** {@inheritDoc} */ public void reloadFaces() { - FaceObjects.reloadAll(); } /** Invoked when user wants to exit from the program. */ Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-04 18:29:08 UTC (rev 4095) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-04 18:31:50 UTC (rev 4096) @@ -73,11 +73,6 @@ this.mainControl = mainControl; } - /** Reloads all providers provided by this FaceObjects. */ - public static void reloadAll() { - // TODO - } - /** * Adds a new face object. * @param faceName name of face, e.g. <samp>"robe.101"</samp> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-07 06:41:28
|
Revision: 4163 http://gridarta.svn.sourceforge.net/gridarta/?rev=4163&view=rev Author: akirschbaum Date: 2008-06-06 23:41:36 -0700 (Fri, 06 Jun 2008) Log Message: ----------- Add missing text resources. Modified Paths: -------------- trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-06-07 06:37:49 UTC (rev 4162) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-06-07 06:41:36 UTC (rev 4163) @@ -51,6 +51,9 @@ enterExitClose.title=Close previous map? enterExitClose.message=You''ve opened a new map.\nShould I close the previous one? +enterTileIOException.title=Invalid path +enterTileIOException.message=Failed to load file for tiled map.\n{0} + enterExitRandomDestination.title=Destination invalid enterExitRandomDestination.message=The destination of this exit is a random map. enterExitNotSaved.title=Map not saved Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-06-07 06:37:49 UTC (rev 4162) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-06-07 06:41:36 UTC (rev 4163) @@ -48,6 +48,9 @@ enterExitClose.title=Letzte Karte schlie\xDFen? enterExitClose.message=Sie haben eine neue Karte ge\xF6ffnet.\nSoll die letzte Karte geschlossen werden? +enterTileIOException.title=Ung\xFCltiger Pfad +enterTileIOException.message=Kann verbundene Karte nicht laden.\n{0} + enterExitRandomDestination.title=Ziel ung\xFCltig enterExitRandomDestination.message=Der Ausgang zeigt auf eine zuf\xE4llig generierte Karte. enterExitNotSaved.title=Karte nicht gesichert Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-06-07 06:37:49 UTC (rev 4162) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-06-07 06:41:36 UTC (rev 4163) @@ -49,6 +49,9 @@ #enterExitClose.title= #enterExitClose.message= +#enterTileIOException.title= +#enterTileIOException.message= + #enterExitRandomDestination.title= #enterExitRandomDestination.message= #enterExitNotSaved.title= Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-06-07 06:37:49 UTC (rev 4162) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-06-07 06:41:36 UTC (rev 4163) @@ -47,6 +47,9 @@ #enterExitClose.title= #enterExitClose.message= +enterTileIOException.title=Ogiltig s\xF6kv\xE4g +enterTileIOException.message=Misslyckades \xF6ppna filen f\xF6r s\xF6kv\xE4gen.\n{0} + #enterExitRandomDestination.title= #enterExitRandomDestination.message= #enterExitNotSaved.title= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-06-21 21:17:05
|
Revision: 4204 http://gridarta.svn.sourceforge.net/gridarta/?rev=4204&view=rev Author: akirschbaum Date: 2008-06-21 14:17:10 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-21 18:54:01 UTC (rev 4203) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-06-21 21:17:10 UTC (rev 4204) @@ -167,7 +167,7 @@ private final AnimationObjects<AnimationObject> animationObjects; /** The Face Objects. */ - private final FaceObjects faceObjects = new FaceObjects(this); + private final FaceObjects faceObjects = new FaceObjects(); /** The Spells. */ private final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-21 18:54:01 UTC (rev 4203) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-06-21 21:17:10 UTC (rev 4204) @@ -31,14 +31,12 @@ import java.io.OutputStreamWriter; import java.io.PrintStream; import java.nio.channels.FileChannel; -import net.sf.gridarta.MainControl; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.CollectedFaceProvider; import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; -import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.utils.ArrayUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -60,24 +58,18 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** The main control. */ - @NotNull private final MainControl<?, ?, ?, ?> mainControl; - /** * Creates a new instance. - * @param mainControl the main control */ - public FaceObjects(@NotNull final MainControl<?, ?, ?, ?> mainControl) { - this.mainControl = mainControl; + public FaceObjects() { } /** {@inheritDoc} */ public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { FaceObjectProviders.setNormal(new CollectedFaceProvider(faceFile)); final String actualFilename = faceFile.toString(); - final String baseDir = mainControl.getCollectedDirectory(); final byte[] data; - final InputStream inputStream = IOUtils.createStream(baseDir, IGUIConstants.PNG_FILE); + final InputStream inputStream = new FileInputStream(faceFile); final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) faceFile.length()); try { final byte[] buf = new byte[4096]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-13 22:33:56
|
Revision: 4304 http://gridarta.svn.sourceforge.net/gridarta/?rev=4304&view=rev Author: akirschbaum Date: 2008-07-13 15:34:03 -0700 (Sun, 13 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gui/ObjectChooser.java trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-13 21:50:05 UTC (rev 4303) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-13 22:34:03 UTC (rev 4304) @@ -244,7 +244,7 @@ newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, mapTileListBottom, null); - objectChooser = new ObjectChooser(this, archetypeChooserControl, mapManager, pickmapChooserControl); + objectChooser = new ObjectChooser(this, selectedSquareControl.getSelectedSquareView(), archetypeChooserControl, mapManager, pickmapChooserControl); mainActions = new MainActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, pickmapChooserControl, animationObjects, ACTION_FACTORY, faceObjects, objectChooser); getGridartaObjectsFactory().init(faceObjects, objectChooser, archetypeChooserControl, pickmapChooserControl); mainView = new MainView<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, objectChooser, getMapManager(), ACTION_FACTORY, mapManagerActions.getCloseAllAction(), faceObjects); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-07-13 21:50:05 UTC (rev 4303) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-07-13 22:34:03 UTC (rev 4304) @@ -137,7 +137,7 @@ /** {@inheritDoc} */ @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { - return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>((MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic>) (MainControl) AbstractMainControl.getInstance(), mapControl, viewCounter, new CMapViewBasic(CMainControl.getInstance(), mapControl, viewPosition, faceObjects, objectChooser, pickmapChooserControl), ACTION_FACTORY); + return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>((MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic>) (MainControl) AbstractMainControl.getInstance(), mapControl, viewCounter, new CMapViewBasic(CMainControl.getInstance(), mapControl, viewPosition, faceObjects, objectChooser, pickmapChooserControl, ((cfeditor.gui.ObjectChooser) objectChooser).getToolSelectorPane()), ACTION_FACTORY); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/ObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-13 21:50:05 UTC (rev 4303) +++ trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-13 22:34:03 UTC (rev 4304) @@ -40,8 +40,10 @@ import net.sf.gridarta.gui.ObjectChoiceDisplay; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; +import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserListener; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,6 +68,9 @@ /** Preferences. */ private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + /** ToolSelector of this subview. */ + private final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette; + /** Panel holding both archlist and pickmaps. */ private final JTabbedPane archAndPickPane = new JTabbedPane(SwingConstants.TOP); @@ -90,11 +95,12 @@ /** * Build Panel. * @param mainControl CMainControl + * @param selectedSquareView the selected square view * @param archetypeChooserControl the archetype chooser control * @param mapManager the map manager instance * @param pickmapChooserControl the pickmap chooser control */ - public ObjectChooser(final CMainControl mainControl, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl) { + public ObjectChooser(final CMainControl mainControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl) { super(archetypeChooserControl, pickmapChooserControl); archetypeChooserControl.addArchetypeChooserListener(new ArchetypeChooserListener<GameObject, MapArchObject, Archetype>() { /** {@inheritDoc} */ @@ -107,6 +113,7 @@ // ignore } }); + toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, selectedSquareView, this); objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl, this); @@ -168,6 +175,14 @@ pickmapChooserControl.setActive(pickmapActive); } + /** + * Returns the tool selector pane. + * @return The tool selector pane. + */ + public ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> getToolSelectorPane() { + return toolPalette; + } + /** {@inheritDoc} */ public void selectArchetype(final Archetype archetype) { moveArchetypeChooserToFront(); Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-07-13 21:50:05 UTC (rev 4303) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-07-13 22:34:03 UTC (rev 4304) @@ -35,6 +35,7 @@ import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; @@ -97,8 +98,9 @@ * @param faceObjects the FaceObjects instance to use * @param objectChooser the ObjectChooser instance to use * @param pickmapChooserControl the pickmap chooser control instance to use + * @param toolPalette the tool palette */ - public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser, @NotNull final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl) { + public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser, @NotNull final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { super(mapControl); this.mapControl = mapControl; mapModel = mapControl.getMapModel(); @@ -122,7 +124,7 @@ getViewport().setViewPosition(initial); } - mapUserListener = new MapUserListener(mainControl, mapControl, this, objectChooser, mainControl.getSelectedSquareControl().getSelectedSquareView(), pickmapChooserControl); + mapUserListener = new MapUserListener(mapControl, this, pickmapChooserControl, toolPalette); renderer.addMouseListener(mapUserListener); renderer.addMouseMotionListener(mapUserListener); renderer.setErroneousMapSquares(erroneousMapSquares); Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-07-13 21:50:05 UTC (rev 4303) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2008-07-13 22:34:03 UTC (rev 4304) @@ -19,7 +19,6 @@ package cfeditor.gui.map; -import cfeditor.CMainControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; @@ -28,16 +27,12 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import net.sf.gridarta.gui.ObjectChooser; import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.map.event.MouseOpListener; -import net.sf.gridarta.gui.map.tools.DeletionTool; -import net.sf.gridarta.gui.map.tools.InsertionTool; -import net.sf.gridarta.gui.map.tools.SelectionTool; +import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,6 +43,9 @@ */ public final class MapUserListener implements MouseListener, MouseMotionListener { + /** ToolSelector of ArchPanel. */ + private final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette; + private final MapCursor mapCursor; private final LevelRenderer renderer; @@ -63,24 +61,13 @@ private final CMapViewBasic mapView; @NotNull - private final SelectionTool<GameObject, MapArchObject, Archetype, CMapViewBasic> selectionTool; - - @NotNull - private final InsertionTool<GameObject, MapArchObject, Archetype, CMapViewBasic> insertionTool; - - @NotNull - private final DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic> deletionTool; - - @NotNull final MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic> mouseOpEvent = new MouseOpEvent<GameObject, MapArchObject, Archetype, CMapViewBasic>(); - public MapUserListener(final CMainControl mainControl, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final CMapViewBasic mapView, final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser, final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl) { + public MapUserListener(final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final CMapViewBasic mapView, final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { this.mapControl = mapControl; this.mapView = mapView; this.pickmapChooserControl = pickmapChooserControl; - selectionTool = new SelectionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(objectChooser); - insertionTool = new InsertionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(selectedSquareView, objectChooser); - deletionTool = new DeletionTool<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainControl); + this.toolPalette = toolPalette; mapCursor = mapView.getMapCursor(); renderer = mapView.getRenderer(); } @@ -161,15 +148,7 @@ @Nullable private MouseOpListener<GameObject, MapArchObject, Archetype, CMapViewBasic> getMouseOperation(final MouseEvent event) { initEvent(event); - if (isSelect(event)) { - return selectionTool; - } else if (isInsert(event)) { - return insertionTool; - } else if (isDelete(event)) { - return deletionTool; - } else { - return null; - } + return toolPalette.getTool(mouseOpEvent); } /** @@ -184,32 +163,4 @@ return renderer.getTileLocationAt(event.getPoint(), tmpPoint); } - /** - * Determine if "select" was selected. - * @param e the mouse event to check for "select" - * @return <code>true</code> is "select" was selected - */ - private static boolean isSelect(final MouseEvent e) { - return (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0; - } - - /** - * Determine if "insert" was selected. - * @param e the mouse event to check for "insert" - * @return <code>true</code> is "insert" was selected - */ - private static boolean isInsert(final MouseEvent e) { - return (e.getModifiers() & (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK)) == InputEvent.BUTTON3_MASK; - } - - /** - * Determine if "delete" was selected. - * @param e the mouse event to check for "delete" - * @return <code>true</code> is "delete" was selected - */ - private static boolean isDelete(final MouseEvent e) { - return (e.getModifiers() & InputEvent.BUTTON2_MASK) != 0 - || (e.getModifiers() & (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK)) == (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK); - } - } // class MapUserListener This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-13 23:05:04
|
Revision: 4311 http://gridarta.svn.sourceforge.net/gridarta/?rev=4311&view=rev Author: akirschbaum Date: 2008-07-13 16:05:13 -0700 (Sun, 13 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-07-13 23:01:20 UTC (rev 4310) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-07-13 23:05:13 UTC (rev 4311) @@ -137,7 +137,7 @@ /** {@inheritDoc} */ @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { - return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>((MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic>) (MainControl) AbstractMainControl.getInstance(), mapControl, viewCounter, new CMapViewBasic(CMainControl.getInstance(), mapControl, viewPosition, faceObjects, objectChooser, pickmapChooserControl, ((cfeditor.gui.ObjectChooser) objectChooser).getToolSelectorPane()), ACTION_FACTORY); + return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>((MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic>) (MainControl) AbstractMainControl.getInstance(), mapControl, viewCounter, new CMapViewBasic(CMainControl.getInstance(), mapControl, viewPosition, faceObjects, pickmapChooserControl, ((cfeditor.gui.ObjectChooser) objectChooser).getToolSelectorPane()), ACTION_FACTORY); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-07-13 23:01:20 UTC (rev 4310) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-07-13 23:05:13 UTC (rev 4311) @@ -97,11 +97,10 @@ * @param initial the initial view position to show; null=show top left * corner * @param faceObjects the FaceObjects instance to use - * @param objectChooser the ObjectChooser instance to use - * @param pickmapChooserControl the pickmap chooser control instance to use + * @param pickmapChooserControl the pickmap chooser control * @param toolPalette the tool palette */ - public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChooser, @NotNull final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { + public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> pickmapChooserControl, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { super(mapControl); this.mapControl = mapControl; mapModel = mapControl.getMapModel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-05-25 23:20:30
|
Revision: 18 Author: christianhujer Date: 2006-05-25 16:20:20 -0700 (Thu, 25 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=18&view=rev Log Message: ----------- Refactored AnimationObject. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AnimationObject.java trunk/crossfire/src/cfeditor/ArchObjectStack.java trunk/crossfire/src/cfeditor/CMainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/AnimationObjects.java Modified: trunk/crossfire/src/cfeditor/AnimationObject.java =================================================================== --- trunk/crossfire/src/cfeditor/AnimationObject.java 2006-05-25 23:18:30 UTC (rev 17) +++ trunk/crossfire/src/cfeditor/AnimationObject.java 2006-05-25 23:20:20 UTC (rev 18) @@ -25,73 +25,58 @@ package cfeditor; -import java.util.HashMap; -import java.util.Map; - /** - * The <code>AnimationObject</code> - * - * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * A single animation object. */ public class AnimationObject { - private final AnimObjectNode[] animObjects = new AnimObjectNode[10000]; + /** The name of this animation. */ + private final String animName; - private final String[] nameTable = new String[10000]; + /** The animation list of this animation. + * The individual entries are all postfixed with '\n'. + */ + private final String animList; - // The hash tables hold the name and the index for the field - // if one can show me, that storing and accessing names AND objects - // in the table is faster than in the static arrays, we can change this - private final Map<String,Integer> animHashTable = new HashMap<String,Integer>(); - - private int animObjCount; - - public AnimationObject() { - animObjCount = 0; - + /** + * Create an Animation Object. + * @param animName name of the animation + * @param animList list with frames + */ + public AnimationObject(final String animName, final String animList) { + this.animList = animList; + this.animName = animName; } - public void addAnimObject(final String name, final String list) { - animObjects[animObjCount] = new AnimObjectNode(name, list); - nameTable[animObjCount] = name; - animHashTable.put(name, animObjCount); // put it in list - - animObjCount++; + /** + * Returns the animation list of this animation. + * The individual entries are all postfixed with '\n'. + * @return the animation list of this animation. + */ + public String getAnimList() { + return animList; } - public String[] nameStringTable() { - return nameTable; + /** + * Returns the name of this animation. + * @return the name of this animation. + */ + public String getAnimName() { + return animName; } - public String getNameString(final int i) { - return nameTable[i]; + /** + * {@inheritDoc} + * The String representation of an AnimObjectNode is suitable for writing into the animations file. + */ + @Override public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("anim "); + sb.append(animName); + sb.append('\n'); + sb.append(animList); + sb.append("mina\n"); + return sb.toString(); } - public int getAnimObjectCounter() { - return animObjCount; - } - - public String getAnimObjectList(final int i) { - return animObjects[i].animList; - } - - public String getAnimObjectName(final int i) { - return animObjects[i].animName; - } - - public int findAnimObject(final String name) { - return animHashTable.get(name); - } - - - private static class AnimObjectNode { - private final String animName; - private final String animList; // A List of "\n" connected strings - - AnimObjectNode (final String animName, final String animList) { - this.animList = animList; - this.animName = animName; - } - } // End of class - } // End of class Added: trunk/crossfire/src/cfeditor/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/AnimationObjects.java (rev 0) +++ trunk/crossfire/src/cfeditor/AnimationObjects.java 2006-05-25 23:20:20 UTC (rev 18) @@ -0,0 +1,75 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.TreeSet; + +/** + * The <code>AnimationObject</code>. + * + * WARNING: This class uses two indexes which are independent of each other: index of animation object and index of animation name. + * + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + */ +public class AnimationObjects implements Iterable<AnimationObject> { + + /** The animation objects. */ + private final List<AnimationObject> animObjects = new ArrayList<AnimationObject>(); + + /** Number of animation objects created. */ + private int numAnimObjects; + + /** Create the AnimationObject container. */ + public AnimationObjects() { + } + + /** {@inheritDoc} */ + public Iterator<AnimationObject> iterator() { + return new TreeSet<AnimationObject>(animObjects).iterator(); + } + + /** + * Add an animation object. + * @param name name of the animation object + * @param list list with individual frames + */ + public void addAnimObject(final String name, final String list) { + animObjects.add(new AnimationObject(name, list)); + numAnimObjects++; + } + + /** + * Returns number of animation objects created. + * @return number of animation objects created. + */ + public int getNumAnimObjects() { + return numAnimObjects; + } + +} // End of class Property changes on: trunk/crossfire/src/cfeditor/AnimationObjects.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/ArchObjectStack.java =================================================================== --- trunk/crossfire/src/cfeditor/ArchObjectStack.java 2006-05-25 23:18:30 UTC (rev 17) +++ trunk/crossfire/src/cfeditor/ArchObjectStack.java 2006-05-25 23:20:20 UTC (rev 18) @@ -2,6 +2,7 @@ * Crossfire Java Editor. * Copyright (C) 2000 Michael Toennies * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers * * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) * @@ -38,7 +39,6 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.util.Arrays; import java.util.Date; import java.util.Hashtable; import javax.swing.BorderFactory; @@ -1349,16 +1349,13 @@ DataOutputStream binFile = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(m_control.getArchDefaultFolder()+File.separator+"animations"))); - int count_ani = m_control.getAnimationObject().getAnimObjectCounter(); + final AnimationObjects animObjects = m_control.getAnimationObject(); + int count_ani = animObjects.getNumAnimObjects(); // sort it... pbar.setLabel("Collecting Animations...", 0, count_ani); - Arrays.sort(m_control.getAnimationObject().nameStringTable(), 0, count_ani); - for (int i = 0; i < count_ani; i++) { - nr = m_control.getAnimationObject().findAnimObject(m_control.getAnimationObject().getNameString(i)); - binFile.writeBytes("anim "+m_control.getAnimationObject().getAnimObjectName(nr)+"\n"); - binFile.writeBytes(m_control.getAnimationObject().getAnimObjectList(nr)); - binFile.writeBytes("mina\n"); + for (final AnimationObject node : animObjects) { + binFile.writeBytes(node.toString()); if (count_ani%10 == 0) { pbar.setValue(count_ani); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-05-25 23:18:30 UTC (rev 17) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-05-25 23:20:20 UTC (rev 18) @@ -80,7 +80,7 @@ private CMapFileEncode mapFileEncoder; private ArchObjectParser archObjectParser; - private AnimationObject animationObject; + private AnimationObjects animationObjects; // icons for the map and arch pictures . X= rectangle, normal = iso private ImageIcon mapSelIcon; @@ -233,7 +233,7 @@ // our global object parser archObjectParser = new ArchObjectParser(this); - animationObject = new AnimationObject(); + animationObjects = new AnimationObjects(); // read in the type & type field definitions archObjectParser.loadTypeNumbers(); @@ -1939,8 +1939,8 @@ return archObjectParser; } - public AnimationObject getAnimationObject() { - return animationObject; + public AnimationObjects getAnimationObject() { + return animationObjects; } public String getImageSet() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-05-31 15:00:44
|
Revision: 92 Author: akirschbaum Date: 2006-05-31 08:00:31 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/gridarta/?rev=92&view=rev Log Message: ----------- Add final where possible. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CArchQuickView.java trunk/crossfire/src/cfeditor/CAttribBitmask.java trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchAttrib.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-05-31 10:47:20 UTC (rev 91) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-05-31 15:00:31 UTC (rev 92) @@ -68,7 +68,7 @@ private static final long serialVersionUID = 8690200410771201444L; /* Build Panel */ - CArchPanelPan(CArchPanel controlPanel, CMainControl control) { + CArchPanelPan(final CArchPanel controlPanel, final CMainControl control) { mainControl = control; archPanel = controlPanel; list = new StringBuffer(""); @@ -86,7 +86,7 @@ theList = new JList(model); theList.setCellRenderer(new MyCellRenderer()); theList.setBackground(IGUIConstants.BG_COLOR); - JScrollPane scrollPane = new JScrollPane(theList); + final JScrollPane scrollPane = new JScrollPane(theList); panelDesktop.add(scrollPane, BorderLayout.CENTER); panelDesktop.add(jbox, BorderLayout.NORTH); scrollPane.setAutoscrolls(true); @@ -95,20 +95,20 @@ jbox.setAutoscrolls(true); jbox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { showArchList(); } }); theList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { + public void valueChanged(final ListSelectionEvent e) { showArchListObject(e.getFirstIndex()); } }); // listening for mouse-click events in the ArchPanel list theList.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { + public void mousePressed(final MouseEvent e) { // In JDK 1.4 it is required to transfer focus back to mapview after // every click in the panel, otherwise the menu-shortcuts stop working if (mainControl.getCurrentMap() != null && @@ -137,13 +137,13 @@ try { index = Integer.parseInt(theList.getSelectedValue().toString()); arch = mainControl.getArchObjectStack().getArch(index); - } catch (NullPointerException e) { + } catch (final NullPointerException e) { /* log.info("NullPointerException in showArchListObject()!", e); This happens in JDK 1.4 when you select an arch in panel A, then select Panel B, then Panel A again. (why??) */ - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { } } mainControl.showArchPanelQuickObject(arch); // send it to quick view @@ -155,8 +155,8 @@ * @param archname name of the arch to add * @param index index of subdir where to add */ - public void addArchPanelArch(int archnr, int index) { - String def = "00000"; + public void addArchPanelArch(final int archnr, final int index) { + final String def = "00000"; String num = Integer.toString(archnr); this.list.append(def.substring(0, 5 - num.length())); @@ -169,7 +169,7 @@ this.listcounter++; } - int addArchPanelCombo(String name) { + int addArchPanelCombo(final String name) { this.setEnabled(false); this.jbox.addItem(name); this.setEnabled(true); @@ -194,7 +194,7 @@ * @return an array of nodenumbers from all arches in this panel */ public int[] getListNodeNrArray() { - int[] numList = new int[(int) (list.length() / 10.)]; + final int[] numList = new int[(int) (list.length() / 10.)]; for (int i = 0; i < (int) (list.length() / 10.); i++) { numList[i] = Integer.parseInt(list.substring(0 + 10 * i, 5 + 10 * i)); @@ -211,12 +211,11 @@ * note that the same indices are used for same arches in 'getListNodeNrArray()' */ public String[] getListCathegoryArray() { - String[] cathList = new String[(int) (list.length() / 10.)]; + final String[] cathList = new String[(int) (list.length() / 10.)]; - int index; for (int i = 0; i < (int) (list.length() / 10.); i++) { try { - index = Integer.parseInt(list.substring(5 + 10 * i, 10 + 10 * i)); + final int index = Integer.parseInt(list.substring(5 + 10 * i, 10 + 10 * i)); cathList[i] = jbox.getItemAt(index).toString().trim(); } catch (NullPointerException e) { log.warn("Nullpointer in getListCathegoryArray()!", e); @@ -232,7 +231,7 @@ void showArchList() { int offset = 0; - int index = this.jbox.getSelectedIndex(); + final int index = this.jbox.getSelectedIndex(); this.model.removeAllElements(); @@ -258,11 +257,11 @@ /* This is the only method defined by ListCellRenderer. We just * reconfigure the Jlabel each time we're called. */ - public Component getListCellRendererComponent(JList list, - Object value, // value to display - int index, // cell index - boolean iss, // is the cell selected - boolean chf) { // the list and the cell have the focus + public Component getListCellRendererComponent(final JList list, + final Object value, // value to display + final int index, // cell index + final boolean iss, // is the cell selected + final boolean chf) { // the list and the cell have the focus /* The DefaultListCellRenderer class will take care of * the JLabels text property, it's foreground and background @@ -272,7 +271,7 @@ /* We additionally set the JLabels icon property here. */ - ArchObject arch = mainControl.getArchObjectStack().getArch(Integer.parseInt(value.toString())); + final ArchObject arch = mainControl.getArchObjectStack().getArch(Integer.parseInt(value.toString())); if (iss) { archPanel.setPanelArch(Integer.parseInt(value.toString())); mainControl.setStatusText(" " + value.toString() + " "); Modified: trunk/crossfire/src/cfeditor/CArchQuickView.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-05-31 10:47:20 UTC (rev 91) +++ trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-05-31 15:00:31 UTC (rev 92) @@ -38,7 +38,7 @@ * The <code>CArchQuickView</code> holds the tile palette. * @author <a href="mailto:mic...@no...">Michael Toennies</a> */ -public class CArchQuickView extends JPanel { +public final class CArchQuickView extends JPanel { /** Controller of this subview. */ private final CMainControl mainControl; @@ -53,7 +53,7 @@ private static final long serialVersionUID = -5176382751320643475L; - public CArchQuickView(CMainControl mainControl) { + public CArchQuickView(final CMainControl mainControl) { this.mainControl = mainControl; setLayout(new BorderLayout(1, 1)); @@ -64,9 +64,9 @@ mainControl.setPlainFont(archTileText); // setup a panel - JPanel panel = new JPanel(); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); + final JPanel panel = new JPanel(); + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints c = new GridBagConstraints(); panel.setLayout(gridbag); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; @@ -102,7 +102,7 @@ panel.add(archTileText); // put it in a scroller - JScrollPane scrollPane = new JScrollPane(panel); + final JScrollPane scrollPane = new JScrollPane(panel); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); setMinimumSize(new Dimension(1, 1)); @@ -110,7 +110,7 @@ } // show quick info of this arch - void showArchPanelQuickObject(ArchObject arch) { + void showArchPanelQuickObject(final ArchObject arch) { if (arch == null) { archArchNameText.setText("<html><font color=black>Arch:</font></html>"); archObjNameText.setText("<html><font color=black>Name:</font></html>"); @@ -121,7 +121,7 @@ archArchNameText.setText("<html><font color=black>Arch: " + arch.getArchName() + "</font></html>"); if (arch.getObjName() == null || arch.getObjName().length() <= 0) { - ArchObject def = arch.getDefaultArch(); + final ArchObject def = arch.getDefaultArch(); if (def == null || def == arch) { archObjNameText.setText("<html><font color=black>Name: -none- </font></html>"); } else if (def.getObjName() != null && def.getObjName().length() > 0) { Modified: trunk/crossfire/src/cfeditor/CAttribBitmask.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribBitmask.java 2006-05-31 10:47:20 UTC (rev 91) +++ trunk/crossfire/src/cfeditor/CAttribBitmask.java 2006-05-31 15:00:31 UTC (rev 92) @@ -48,7 +48,7 @@ * the user, with the help of the attribute dialog. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CAttribBitmask { +public final class CAttribBitmask { private static final Logger log = Logger.getLogger(CAttribBitmask.class); @@ -68,7 +68,7 @@ * Constructor of a bitmask (DEPRECATED!) * @param name array of names for the bit-entries */ - public CAttribBitmask(String[] name) { + public CAttribBitmask(final String[] name) { // initialize arrays bitName = new String[name.length + 1]; //bitValue = new int[name.length+1]; @@ -91,7 +91,7 @@ * Constructor of a bitmask from XML element. * @param root xml bitmask element */ - public CAttribBitmask(Element root) { + public CAttribBitmask(final Element root) { int i; List entries = root.getChildren("entry"); @@ -112,7 +112,7 @@ if (bit > maxBit) { maxBit = bit; // this is the highest bit so far } - } catch (DataConversionException e) { + } catch (final DataConversionException e) { log.warn("Parse error: Bitmask bit '" + a.getValue() + "' (" + elem.getAttribute("name").getValue() + ") is not an integer."); elem.detach(); // remove element from DOM tree } @@ -133,7 +133,7 @@ // fill array and assign 2^i values try { bitName[elem.getAttribute("bit").getIntValue() + 1] = elem.getAttribute("name").getValue(); - } catch (DataConversionException e) { + } catch (final DataConversionException e) { } } @@ -164,7 +164,7 @@ * @return <code>true</code> if the bit is active in mask, otherwise * <code>false</code> */ - private boolean isActive(int index, int mask) { + private static boolean isActive(final int index, final int mask) { return ((int) (Math.pow(2., (double) (index - 1))) & mask) != 0; } @@ -177,7 +177,7 @@ * @return <code>JTextArea</code> with all entries belonging to the bitmask * and proper dimensions */ - public JTextArea getText(int value, JTextArea textf) { + public JTextArea getText(final int value, JTextArea textf) { String text = " "; // text string to return int rows = 1; // rows of textarea int columns = 1; // columns of textarea (actually not needed) @@ -238,23 +238,23 @@ } /** Open a popup frame to select bitmask-entries via chooseboxes. */ - public void popupFrame(CAttribDialog attrDialog, CAttribDialog.BitmaskAttrib guiAttr) { - String title = "Choose " + guiAttr.ref.getNameNew().substring(0, 1).toUpperCase() + guiAttr.ref.getNameNew().substring(1); - JDialog frame = new JDialog(attrDialog, title, true); + public void popupFrame(final CAttribDialog attrDialog, final CAttribDialog.BitmaskAttrib guiAttr) { + final String title = "Choose " + guiAttr.ref.getNameNew().substring(0, 1).toUpperCase() + guiAttr.ref.getNameNew().substring(1); + final JDialog frame = new JDialog(attrDialog, title, true); frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); // panels - JPanel mainPanel = new JPanel(); + final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - JPanel gridPanel = new JPanel(new GridLayout(1, 2)); - JPanel leftList = new JPanel(); // left column of checkboxes + final JPanel gridPanel = new JPanel(new GridLayout(1, 2)); + final JPanel leftList = new JPanel(); // left column of checkboxes leftList.setLayout(new BoxLayout(leftList, BoxLayout.Y_AXIS)); - JPanel rightList = new JPanel(); // right column of checkboxes + final JPanel rightList = new JPanel(); // right column of checkboxes rightList.setLayout(new BoxLayout(rightList, BoxLayout.Y_AXIS)); - JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); // create checkboxes - JCheckBox[] checkbox = new JCheckBox[number]; + final JCheckBox[] checkbox = new JCheckBox[number]; for (int i = 0; i < number; i++) { checkbox[i] = new JCheckBox(" " + bitName[i + 1]); checkbox[i].setSelected(isActive(i + 1, guiAttr.getValue())); @@ -270,14 +270,14 @@ mainPanel.add(gridPanel); // buttons - JButton okButton = new JButton("Ok"); - JButton cancelButton = new JButton("Cancel"); + final JButton okButton = new JButton("Ok"); + final JButton cancelButton = new JButton("Cancel"); buttonPanel.add(okButton); buttonPanel.add(cancelButton); mainPanel.add(buttonPanel); // attach action listener to the buttons - PopupFrameAL listener = new PopupFrameAL(frame, guiAttr, this, checkbox, attrDialog); + final PopupFrameAL listener = new PopupFrameAL(frame, guiAttr, this, checkbox, attrDialog); okButton.addActionListener(listener); cancelButton.addActionListener(listener); @@ -294,15 +294,15 @@ */ private class PopupFrameAL implements ActionListener { - CAttribBitmask bitmask; // reference to this CAttribBitmask instance + final CAttribBitmask bitmask; // reference to this CAttribBitmask instance JDialog frame; // reference to the popup dialog frame - CAttribDialog.BitmaskAttrib guiAttr; // gui attribute instance + final CAttribDialog.BitmaskAttrib guiAttr; // gui attribute instance - JCheckBox[] checkbox; // array of checkboxes on the frame + final JCheckBox[] checkbox; // array of checkboxes on the frame - CAttribDialog attrDialog; // instance of attribute dialog (parent frame) + final CAttribDialog attrDialog; // instance of attribute dialog (parent frame) /** * Contructor @@ -312,8 +312,8 @@ * @param boxarray array of checkboxes in the popup frame * @param newAttrD attribute dialog frame */ - public PopupFrameAL(JDialog newFrame, CAttribDialog.BitmaskAttrib newGuiAttr, - CAttribBitmask newMask, JCheckBox[] boxarray, CAttribDialog newAttrD) { + public PopupFrameAL(final JDialog newFrame, final CAttribDialog.BitmaskAttrib newGuiAttr, + final CAttribBitmask newMask, final JCheckBox[] boxarray, final CAttribDialog newAttrD) { frame = newFrame; guiAttr = newGuiAttr; bitmask = newMask; @@ -325,7 +325,7 @@ * a button was pressed * @param event the occured <code>ActionEvent</code> (button pressed) */ - public void actionPerformed(ActionEvent event) { + public void actionPerformed(final ActionEvent event) { if (event.getSource() instanceof JButton) { // check if the okay button was pressed if (((JButton) event.getSource()).getText().equalsIgnoreCase("Ok")) { Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-05-31 10:47:20 UTC (rev 91) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-05-31 15:00:31 UTC (rev 92) @@ -70,7 +70,7 @@ * CAttribDialog poses the GUI for CF object attributes * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public class CAttribDialog extends JDialog { +public final class CAttribDialog extends JDialog { private static final Logger log = Logger.getLogger(CAttribDialog.class); @@ -154,14 +154,14 @@ * @param defaobj the default ArchObject of 'arch' * @param mcntrl main control */ - CAttribDialog(CFArchTypeList atList, ArchObject aobj, ArchObject defaobj, - CMainControl mcntrl) { + CAttribDialog(final CFArchTypeList atList, final ArchObject aobj, final ArchObject defaobj, + final CMainControl mcntrl) { super(mcntrl.getMainView(), "CF Attribute Dialog", false); // when close-box is selected, execute the 'closeDialog' method and nothing else setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent event) { + public void windowClosing(final WindowEvent event) { closeDialog(); } }); @@ -201,7 +201,7 @@ typeFound = true; } else { // check if all the type-attributes match - int argsNum = (int) (tmp.getTypeAttr().length / 2.); + final int argsNum = (int) (tmp.getTypeAttr().length / 2.); boolean match = true; String archvalue; @@ -248,14 +248,14 @@ // get the type data //type = typelist.getType(typeNr); - JPanel layout = new JPanel(new BorderLayout()); // face, name & type + final JPanel layout = new JPanel(new BorderLayout()); // face, name & type // first split top-left and -right - JScrollPane paneLeft = buildHeader(); - JScrollPane paneRight = buildInv(); + final JScrollPane paneLeft = buildHeader(); + final JScrollPane paneRight = buildInv(); //Create a split pane with the two scroll panes in it. - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, paneLeft, paneRight); splitPane.setOneTouchExpandable(false); splitPane.setDividerLocation(width - inventoryWidth - 2 * dividerSize); @@ -270,15 +270,15 @@ paneCenter = buildAttr(); //Create a split pane with the two scroll panes in it. - JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, paneCenter); splitPane2.setOneTouchExpandable(false); splitPane2.setDividerLocation(126); splitPane2.setDividerSize(dividerSize); // split horizontally again - JScrollPane paneButtons = buildButtons(); - JSplitPane splitPane3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + final JScrollPane paneButtons = buildButtons(); + final JSplitPane splitPane3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane2, paneButtons); splitPane3.setOneTouchExpandable(false); //splitPane3.setDividerLocation(height-buttonBarHeight-34); @@ -311,7 +311,7 @@ * lot more difficult, and probably not very convenient. */ public static void setDefaultBounds() { - int fontsize; // size of current font + final int fontsize; // size of current font if (CMainControl.getInstance().getPlainFont() != null) { fontsize = CMainControl.getInstance().getPlainFont().getSize(); @@ -342,18 +342,17 @@ * @return a <code>JPanel</code> with the combo box in it */ private JPanel buildTypesBox(int boxWidth) { - JPanel lineLayout = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // layout for this line - String []namelist = new String[typelist.getLength()]; // list of typenames + final JPanel lineLayout = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // layout for this line + final String []namelist = new String[typelist.getLength()]; // list of typenames // read all type names CFArchType tmp = typelist.getHead().getNext(); - int selection = -1; // position of selected type in the list for (int i = 0; tmp != null; tmp = tmp.getNext(), i++) { namelist[i] = " " + tmp.getTypeName(); } // the active type appears selected in the box - selection = listNr; + final int selection = listNr; lineLayout.add(new JLabel("Type: ")); // create label @@ -378,7 +377,7 @@ * @param attr spell-attribute * @return the completed <code>JComboBox</code> */ - private JComboBox buildSpellBox(CFArchAttrib attr) { + private JComboBox buildSpellBox(final CFArchAttrib attr) { int active = 0; // active selection in the combo box // first parse the spell-number value from arch @@ -402,7 +401,7 @@ } } - JComboBox spellsel = new JComboBox(typelist.getSpellName()); // set "content" + final JComboBox spellsel = new JComboBox(typelist.getSpellName()); // set "content" spellsel.setPreferredSize(new Dimension((textFieldWidth == 0 ? 197 : textFieldWidth), chooseBoxHeight)); spellsel.setSelectedIndex(active); // set active selection spellsel.setMaximumRowCount(10); @@ -420,9 +419,9 @@ * @param listData Vector with list items and corresponding values * @return the completed <code>JComboBox</code> */ - private JComboBox buildArrayBox(CFArchAttrib attr, Vector listData) { + private JComboBox buildArrayBox(final CFArchAttrib attr, final Vector listData) { // build the array of list-items - String []array = new String[(int) (listData.size() / 2.)]; + final String []array = new String[(int) (listData.size() / 2.)]; boolean hasSelection = false; int active = arch.getAttributeValue(attr.getNameOld(), defarch); @@ -438,7 +437,7 @@ active = 0; } - JComboBox arraysel = new JComboBox(array); // set "content" + final JComboBox arraysel = new JComboBox(array); // set "content" arraysel.setPreferredSize(new Dimension(textFieldWidth == 0 ? 197 : textFieldWidth, chooseBoxHeight)); arraysel.setSelectedIndex(active); // set active selection arraysel.setMaximumRowCount(10); @@ -457,13 +456,13 @@ * @param bitmask the bitmask data for this attribute * @param mainPanel the panel to put everything in */ - private void buildBitmask(CFArchAttrib attr, BitmaskAttrib guiAttr, CAttribBitmask bitmask, JPanel mainPanel) { + private void buildBitmask(final CFArchAttrib attr, final BitmaskAttrib guiAttr, final CAttribBitmask bitmask, final JPanel mainPanel) { // initialize bitmask value guiAttr.setValue(arch.getAttributeValue(attr.getNameOld(), defarch)); guiAttr.bitmask = bitmask; // add button - JButton button = new JButton(attr.getNameNew() + ":"); + final JButton button = new JButton(attr.getNameNew() + ":"); button.setAlignmentX(JButton.CENTER_ALIGNMENT); button.setMargin(new Insets(0, 3, 0, 3)); button.addActionListener(new MaskChangeAL(guiAttr, this)); @@ -480,18 +479,18 @@ * @return a <code>JScrollPane</code> with the upper left part of the dialog window */ private JScrollPane buildHeader() { - JPanel header = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // the final thing, in a panel + final JPanel header = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // the final thing, in a panel - JPanel layout1 = new JPanel(new BorderLayout()); // face, name & type + final JPanel layout1 = new JPanel(new BorderLayout()); // face, name & type imagePanel = new JLabel(mainControl.getArchObjectStack().getFace(arch.getFaceNr())); imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); layout1.add(imagePanel, BorderLayout.WEST); - JPanel layout2 = new JPanel(new GridLayout(2, 1)); + final JPanel layout2 = new JPanel(new GridLayout(2, 1)); - JPanel layout3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel layout3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); layout3.add(new JLabel("Name: ")); // create label if (arch.getObjName() != null && arch.getObjName().length() > 0) { nameTF = new JTextField(arch.getObjName(), 16); @@ -512,20 +511,20 @@ header.add(layout1); - JPanel layout4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel layout4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); layout4.add(new JLabel("Default Arch: ")); // create label defarchTF = new JTextField(defarch.getArchName(), 16); defarchTF.setEditable(false); layout4.add(defarchTF); - JPanel layout5 = new JPanel(); + final JPanel layout5 = new JPanel(); layout5.add(layout4); header.add(layout5); header.setPreferredSize(new Dimension(width - inventoryWidth - 2 * dividerSize, 70)); // finally put the result into a (non-scrollable) // scrollpane to get the size right - JScrollPane scrollPane = new JScrollPane(header); + final JScrollPane scrollPane = new JScrollPane(header); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); @@ -539,10 +538,10 @@ * @return a <code>JScrollPane</code> with the upper right part of the dialog window */ private JScrollPane buildInv() { - JPanel inv = new JPanel(); // the final thing, in a panel + final JPanel inv = new JPanel(); // the final thing, in a panel inv.add(new JLabel("Inventory:")); // create label - JScrollPane scrollPane = new JScrollPane(inv); + final JScrollPane scrollPane = new JScrollPane(inv); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); @@ -567,7 +566,7 @@ } for (int i = 0; i < type.getSectionNum(); i++) { - Component panel1 = makeAttribPanel(i); + final Component panel1 = makeAttribPanel(i); if (panel1 != null) { tabbedPane.addTab(getSectionName(i), null, panel1); } @@ -597,7 +596,7 @@ * @param secId the identifier of the section * @return a <code>Component</code> containing the attribute panel */ - private Component makeAttribPanel(int secId) { + private Component makeAttribPanel(final int secId) { int number = 0; // number of attributes in this section boolean isText = false; // true if this section contains a textfield boolean hasBitmask = false; // true if this section contains a bitmask attribute @@ -624,7 +623,7 @@ // All attribute-"lines" go into this panel: // We choose the boxlayout only for tabs with bitmasks, because we // need it there. For all other cases, the gridlayout is better. - JPanel panel = new JPanel(); + final JPanel panel = new JPanel(); if (hasBitmask) { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); } else { @@ -638,14 +637,14 @@ // now create the attribute-GUI-instance DialogAttrib newAttr = null; - int dType = type.getAttr()[i].getDataType(); // data type of the attribute + final int dType = type.getAttr()[i].getDataType(); // data type of the attribute if (dType == CFArchAttrib.T_TEXT) { // special case: we've got a text section isText = true; // text section (need special embedding without additional scrollbars) newAttr = new TextAttrib(); newAttr.ref = type.getAttr()[i]; - JTextArea input; + final JTextArea input; // note that the textarea is initialized with rows/columns: 1, 1 // this is pretty weird, but seems the only way to achieve desired behaviour @@ -665,13 +664,13 @@ newAttr.helpButton = new JButton("?"); newAttr.helpButton.setMargin(new Insets(0, 3, 0, 3)); - JScrollPane scrollPane = new JScrollPane(input); + final JScrollPane scrollPane = new JScrollPane(input); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); //Create a split pane with the two scroll panes in it. - JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, newAttr.helpButton); splitPane.setDividerSize(0); splitPane.setResizeWeight(1); @@ -686,19 +685,19 @@ dType == CFArchAttrib.T_BOOL_SPEC) { // create an attribute line for BOOL panel2 = new JPanel(new BorderLayout()); // need this layout for consistent resize-behaviour - JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); newAttr = new BoolAttrib(); - JCheckBox input; + final JCheckBox input; if (dType == CFArchAttrib.T_BOOL) { // normal bool input = new JCheckBox(" " + type.getAttr()[i].getNameNew(), (arch.getAttributeValue(type.getAttr()[i].getNameOld(), defarch) == 1)); } else { // parse values for customized bool - String trueVal = type.getAttr()[i].getMisc()[0]; + final String trueVal = type.getAttr()[i].getMisc()[0]; if (trueVal.equals("0")) { - String attrString = arch.getAttributeString(type.getAttr()[i].getNameOld(), defarch); + final String attrString = arch.getAttributeString(type.getAttr()[i].getNameOld(), defarch); input = new JCheckBox(" " + type.getAttr()[i].getNameNew(), (attrString.length() == 0 || attrString.equals("0"))); } else { @@ -722,20 +721,20 @@ } else if (dType == CFArchAttrib.T_INT) { // create an attribute line for INT panel2 = new JPanel(new BorderLayout()); - JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - JLabel label = new JLabel(type.getAttr()[i].getNameNew() + ": "); + final JLabel label = new JLabel(type.getAttr()[i].getNameNew() + ": "); label.setForeground(IGUIConstants.INT_COLOR); panel3.add(label); // add label newAttr = new IntAttrib(); newAttr.ref = type.getAttr()[i]; - JTextField input; + final JTextField input; // parse value from arch - int fieldLength = (type.getAttr()[i].getInputLength() == 0 ? textFieldColumns : type.getAttr()[i].getInputLength()); - int attrval = arch.getAttributeValue(type.getAttr()[i].getNameOld(), defarch); + final int fieldLength = (type.getAttr()[i].getInputLength() == 0 ? textFieldColumns : type.getAttr()[i].getInputLength()); + final int attrval = arch.getAttributeValue(type.getAttr()[i].getNameOld(), defarch); if (attrval != 0) { input = new JTextField(String.valueOf(attrval), fieldLength); } else { @@ -761,10 +760,10 @@ dType == CFArchAttrib.T_FLOAT) { // create an attribute line for STRING panel2 = new JPanel(new BorderLayout()); - JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - JLabel label = new JLabel(type.getAttr()[i].getNameNew() + ": "); + final JLabel label = new JLabel(type.getAttr()[i].getNameNew() + ": "); if (dType == CFArchAttrib.T_STRING) { newAttr = new StringAttrib(); @@ -776,10 +775,10 @@ panel3.add(label); // add label newAttr.ref = type.getAttr()[i]; - JTextField input; + final JTextField input; // parse String from arch - String dtxt; + final String dtxt; if (type.getAttr()[i].getNameOld().equalsIgnoreCase("name")) { if (arch.getObjName() != null && arch.getObjName().length() > 0) { dtxt = arch.getObjName(); @@ -826,10 +825,10 @@ dType == CFArchAttrib.T_LIST) { // create an attribute line for a combo box entry panel2 = new JPanel(new BorderLayout()); - JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - JLabel label = new JLabel(type.getAttr()[i].getNameNew() + ": "); + final JLabel label = new JLabel(type.getAttr()[i].getNameNew() + ": "); label.setForeground(IGUIConstants.INT_COLOR); panel3.add(label); // add label @@ -837,7 +836,7 @@ newAttr.ref = type.getAttr()[i]; // create ComboBox with parsed selection - JComboBox input = null; + final JComboBox input; if (dType == CFArchAttrib.T_SPELL || dType == CFArchAttrib.T_ZSPELL) { input = buildSpellBox(type.getAttr()[i]); } else if (dType == CFArchAttrib.T_LIST) { @@ -849,7 +848,10 @@ // error: list data is missing or corrupt panel3.add(new JLabel("Error: Undefined List")); panel3.add(Box.createHorizontalStrut(50)); + input = null; // XXX: is later added to panel3 } + } else { + input = null; // XXX: is later added to panel3 } panel3.add(input); // add spellbox @@ -866,8 +868,8 @@ } else if (dType == CFArchAttrib.T_BITMASK) { // create an attribute entry for a bitmask panel2 = new JPanel(new BorderLayout()); - JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); newAttr = new BitmaskAttrib(); newAttr.ref = type.getAttr()[i]; @@ -898,18 +900,18 @@ } else if (dType == CFArchAttrib.T_TREASURE) { // create an attribute entry for a treasurelist panel2 = new JPanel(new BorderLayout()); - JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); // button to view treasurelist tree - JButton viewTTree = new JButton("treasurelist:"); + final JButton viewTTree = new JButton("treasurelist:"); viewTTree.setMargin(new Insets(0, 3, 0, 3)); newAttr = new StringAttrib(); newAttr.ref = type.getAttr()[i]; // textfield (no direct input, text is set by the treasurelist dialog) - JTextField input; + final JTextField input; String treasureName = arch.getAttributeString(type.getAttr()[i].getNameOld(), defarch); if (treasureName.trim().length() == 0 || treasureName.trim().equalsIgnoreCase("none")) { treasureName = CFTreasureListTree.NONE_SYM; @@ -958,8 +960,8 @@ if (!isText) { // for non-text panels: put everything into a scrollpane - JScrollPane scrollPane = new JScrollPane(panel); - JScrollPane scrollPane2 = new JScrollPane(scrollPane); + final JScrollPane scrollPane = new JScrollPane(panel); + final JScrollPane scrollPane2 = new JScrollPane(scrollPane); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); @@ -978,7 +980,7 @@ * @param secId ID of the section * @return name of that section */ - private String getSectionName(int secId) { + private String getSectionName(final int secId) { for (int i = 0; type.getAttr().length > i; i++) { if (type.getAttr()[i].getSecId() == secId) { // we've got the string, now capitalize the first letter @@ -1000,9 +1002,9 @@ * @return a <code>JScrollPane</code> with the lower part of the attribute dialog */ private JScrollPane buildButtons() { - JPanel totalBar = new JPanel(new BorderLayout()); // all buttons - JPanel rightBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // right side - JPanel leftBar = new JPanel(new FlowLayout(FlowLayout.LEFT)); // left side + final JPanel totalBar = new JPanel(new BorderLayout()); // all buttons + final JPanel rightBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // right side + final JPanel leftBar = new JPanel(new FlowLayout(FlowLayout.LEFT)); // left side helpButton = new JButton("Help"); summaryButton = new JButton("Summary"); @@ -1023,21 +1025,21 @@ // listen for button events cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // close frame closeDialog(); } }); applyButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // write settings into the ArchObject applySettings(); } }); okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // write settings into the ArchObject, then exit if (applySettings()) { closeDialog(); @@ -1046,14 +1048,14 @@ }); helpButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // create html-docu on the current type and display it new Help(mainControl.getMainView(), type.createHtmlDocu()).setVisible(true); } }); summaryButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // switch to show the summary of attributes toggleSummary(); } @@ -1062,7 +1064,7 @@ //summaryButton.setEnabled(false); //helpButton.setEnabled(false); - JScrollPane scrollPane = new JScrollPane(totalBar); + final JScrollPane scrollPane = new JScrollPane(totalBar); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); @@ -1078,7 +1080,7 @@ * @param title name of attribute * @param msg message text */ - private void popupHelp(String title, String msg) { + private void popupHelp(final String title, final String msg) { JOptionPane.showMessageDialog(this, msg, "help: " + title, JOptionPane.PLAIN_MESSAGE); } @@ -1089,7 +1091,7 @@ private void toggleSummary() { if (!displaySummary) { // interface is displayed, switch to summary - Document doc = summaryTP.getDocument(); + final Document doc = summaryTP.getDocument(); try { // clear document @@ -1097,7 +1099,7 @@ doc.remove(0, doc.getLength()); } - Style docStyle = summaryTP.getStyle(StyleContext.DEFAULT_STYLE); + final Style docStyle = summaryTP.getStyle(StyleContext.DEFAULT_STYLE); if (mainControl.getPlainFont() != null) { StyleConstants.setFontFamily(docStyle, mainControl.getPlainFont().getFamily()); StyleConstants.setFontSize(docStyle, mainControl.getPlainFont().getSize()); @@ -1109,34 +1111,34 @@ for (DialogAttrib attr = attrHead; attr != null; attr = attr.next) { if (attr.ref.getDataType() == CFArchAttrib.T_BOOL || attr.ref.getDataType() == CFArchAttrib.T_BOOL_SPEC) { - boolean value = ((BoolAttrib) attr).input.isSelected(); // true/false + final boolean value = ((BoolAttrib) attr).input.isSelected(); // true/false if (value) { doc.insertString(doc.getLength(), "<" + attr.ref.getNameNew() + ">\n", docStyle); } } if (attr.ref.getDataType() == CFArchAttrib.T_INT) { - String value = ((IntAttrib) attr).input.getText(); // the attrib value + final String value = ((IntAttrib) attr).input.getText(); // the attrib value if (value != null && value.length() > 0 && !value.equals("0")) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } if (attr.ref.getDataType() == CFArchAttrib.T_FLOAT) { - String value = ((FloatAttrib) attr).input.getText(); // the attrib value + final String value = ((FloatAttrib) attr).input.getText(); // the attrib value if (value != null && value.length() > 0) { try { // parse float value - double dval = Double.parseDouble(value); + final double dval = Double.parseDouble(value); if (dval != 0) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { } } } if (attr.ref.getDataType() == CFArchAttrib.T_STRING) { - String value = ((StringAttrib) attr).input.getText(); // the attrib value + final String value = ((StringAttrib) attr).input.getText(); // the attrib value if (value != null && value.length() > 0) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); @@ -1145,28 +1147,28 @@ if (attr.ref.getDataType() == CFArchAttrib.T_SPELL || attr.ref.getDataType() == CFArchAttrib.T_ZSPELL || attr.ref.getDataType() == CFArchAttrib.T_LIST) { - String value = ((ListAttrib) attr).input.getSelectedItem().toString().trim(); // the attrib value + final String value = ((ListAttrib) attr).input.getSelectedItem().toString().trim(); // the attrib value if (value != null && value.length() > 0 && !value.startsWith("<")) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } if (attr.ref.getDataType() == CFArchAttrib.T_BITMASK) { - String value = ((BitmaskAttrib) attr).text.getText().trim(); + final String value = ((BitmaskAttrib) attr).text.getText().trim(); if (value != null && value.length() > 0 && !value.startsWith("<")) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } if (attr.ref.getDataType() == CFArchAttrib.T_TREASURE) { - String value = ((StringAttrib) attr).input.getText().trim(); // the attrib value + final String value = ((StringAttrib) attr).input.getText().trim(); // the attrib value if (value != null && value.length() > 0 && !value.equals(CFTreasureListTree.NONE_SYM)) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } } - } catch (BadLocationException e) { + } catch (final BadLocationException e) { log.error("toggleSummary: Bad Location in Document!", e); } @@ -1195,15 +1197,15 @@ * @return true if the settings were applied, false if error occurred */ private boolean applySettings() { - String oldArchText = arch.getArchText(); // the old ArchText + final String oldArchText = arch.getArchText(); // the old ArchText String newArchText = ""; // the new ArchText for the ArchObject String newName = null; // new object name String newFace = null; // new face name - String oldMsg = arch.getMsgText(); // old arch msg + final String oldMsg = arch.getMsgText(); // old arch msg String newMsg = null; // new arch msg String errors = null; // syntax errors in the archtext int dType; - CFArchType typeStruct = typelist.getTypeOfArch(arch); // the type structure for this arch + final CFArchType typeStruct = typelist.getTypeOfArch(arch); // the type structure for this arch try { for (DialogAttrib attr = attrHead; attr != null; attr = attr.next) { @@ -1218,7 +1220,7 @@ } } else if (dType == CFArchAttrib.T_BOOL_SPEC) { // a boolean attribute with customized true/false values - String valString; // value-string to apply + final String valString; // value-string to apply if (((BoolAttrib) attr).input.isSelected()) { valString = attr.ref.getMisc()[0]; // true string } else { @@ -1243,14 +1245,14 @@ } else { try { if (dType == CFArchAttrib.T_INT) { - int value = 0; // int value from the input form + final int value; // int value from the input form // try to parse String to Int value = Integer.parseInt(((IntAttrib) attr).input.getText().trim()); if (defarch.getAttributeValue(attr.ref.getNameOld(), null) != value) { newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } else { - double value = 0; // value from the input form + final double value; // value from the input form double defValue = 0; // value from the default arch // try to parse floating point value = Double.parseDouble(((FloatAttrib) attr).input.getText().trim()); @@ -1262,7 +1264,7 @@ newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { // parsing failed: wrong entry!! JOptionPane.showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", @@ -1272,7 +1274,7 @@ } } else if (dType == CFArchAttrib.T_STRING) { // a String attribute - String inline = ((StringAttrib) attr).input.getText().trim(); + final String inline = ((StringAttrib) attr).input.getText().trim(); if (inline != null) { if (attr.ref.getNameOld().equalsIgnoreCase("name")) { @@ -1311,14 +1313,14 @@ } else if (dType == CFArchAttrib.T_SPELL || dType == CFArchAttrib.T_ZSPELL || dType == CFArchAttrib.T_LIST) { // get attribute value that should go into the arch - int attrVal; // attribute value + final int attrVal; // attribute value if (dType == CFArchAttrib.T_SPELL || dType == CFArchAttrib.T_ZSPELL) { attrVal = typelist.getSpellNum()[((ListAttrib) attr).input.getSelectedIndex()]; } else { // get selected index of ComboBox - attrVal = ((ListAttrib) attr).input.getSelectedIndex(); + final int attrValTmp = ((ListAttrib) attr).input.getSelectedIndex(); // fetch value according to this list entry: - attrVal = ((Integer) ((Vector) (typelist.getListTable().get(attr.ref.getMisc()[0]))).elementAt(2 * attrVal)).intValue(); + attrVal = ((Integer) ((Vector) (typelist.getListTable().get(attr.ref.getMisc()[0]))).elementAt(2 * attrValTmp)).intValue(); } if (attrVal == -1 || (attrVal == 0 && dType != CFArchAttrib.T_SPELL @@ -1333,17 +1335,17 @@ } } else if (dType == CFArchAttrib.T_BITMASK) { // a bitmask attribute (similar to integer, but easier because no parsing needed) - int value = ((BitmaskAttrib) attr).getValue(); // get bitmask value + final int value = ((BitmaskAttrib) attr).getValue(); // get bitmask value if (defarch.getAttributeValue(attr.ref.getNameOld(), null) != value) { newArchText = newArchText + attr.ref.getNameOld() + " " + value + "\n"; } } else if (dType == CFArchAttrib.T_TREASURE) { // a treasurelist attribute - String inline = ((StringAttrib) attr).input.getText().trim(); // input string + final String inline = ((StringAttrib) attr).input.getText().trim(); // input string if (inline != null) { - boolean isNone = (inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0); + final boolean isNone = (inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0); if (!isNone && !CFTreasureListTree.getInstance().containsTreasureList(inline) && !inline.equalsIgnoreCase(defarch.getAttributeString(attr.ref.getNameOld(), null))) { @@ -1370,7 +1372,7 @@ // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { if (type.getAttr()[i].getDataType() == CFArchAttrib.T_FIXED) { - String defaultValue = defarch.getAttributeString(type.getAttr()[i].getNameOld(), null); + final String defaultValue = defarch.getAttributeString(type.getAttr()[i].getNameOld(), null); if (defaultValue.length() == 0 || (arch.getArchTypNr() != defarch.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the defarch. @@ -1416,7 +1418,7 @@ if (faceChanged) { if (arch.getFaceName() != null) { // we have a non-default face - Integer index = (Integer) mainControl.getArchObjectStack().getFaceHashTable().get(arch.getFaceName()); + final Integer index = (Integer) mainControl.getArchObjectStack().getFaceHashTable().get(arch.getFaceName()); if (index != null) { arch.setFaceNr(index.intValue()); } else { @@ -1424,7 +1426,7 @@ } } else { // we have the default face - Integer index = (Integer) mainControl.getArchObjectStack().getFaceHashTable().get(defarch.getFaceName()); + final Integer index = (Integer) mainControl.getArchObjectStack().getFaceHashTable().get(defarch.getFaceName()); if (index != null) { arch.setFaceNr(index.intValue()); } else { @@ -1476,7 +1478,7 @@ mainControl.getMainView().refreshMapArchPanel(); return true; // apply succeeded - } catch (CGridderException e) { + } catch (final CGridderException e) { } return false; // error (-> try again) @@ -1493,39 +1495,39 @@ * window is closed, which mimics non-event-driven behaviour. * @param errors a textual list of the encountered errors */ - private void askConfirmErrors(String errors) { - JDialog frame = new JDialog(this, "Syntax Errors", true); // dialog freezes parents + private void askConfirmErrors(final String errors) { + final JDialog frame = new JDialog(this, "Syntax Errors", true); // dialog freezes parents frame.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // closing is handled by listener - JPanel mainPanel = new JPanel(); + final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - JPanel headerPanel = new JPanel(new GridLayout(2, 1)); - JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + final JPanel headerPanel = new JPanel(new GridLayout(2, 1)); + final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); // create header labels - JLabel header1 = new JLabel("The following lines from the archtext appear to be wrong."); + final JLabel header1 = new JLabel("The following lines from the archtext appear to be wrong."); header1.setForeground(Color.black); - JLabel heade... [truncated message content] |
From: <aki...@us...> - 2006-12-02 11:33:25
|
Revision: 785 http://svn.sourceforge.net/gridarta/?rev=785&view=rev Author: akirschbaum Date: 2006-12-02 03:33:24 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Rename method names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java trunk/crossfire/src/cfeditor/CMainToolbar.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-12-02 10:50:19 UTC (rev 784) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-12-02 11:33:24 UTC (rev 785) @@ -147,7 +147,7 @@ if (f.canRead()) { mainControl.openFile(f); mainControl.createImageWanted(out); - mainControl.closeCurrentLevelWanted(); + mainControl.close(); } } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-02 10:50:19 UTC (rev 784) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-02 11:33:24 UTC (rev 785) @@ -416,7 +416,7 @@ this.getMainView().setMapTileListBottom(new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAPTILE_BOTTOM_KEY, "false")).booleanValue()); - setPickmapsLocked(new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false")).booleanValue()); + setLockAllPickmaps(new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false")).booleanValue()); // docu version if (IGUIConstants.DOCU_VERSION > (new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(DOCU_VERSION_KEY, "0"))).intValue()) { @@ -473,7 +473,7 @@ return loadFromArchive; } - public boolean isPickmapsLocked() { + public boolean isLockAllPickmaps() { return pickmapsLocked; } @@ -611,7 +611,7 @@ } /** Invoked when user wants to begin editing a new (empty) map. */ - public void newLevelWanted() { + public void createNew() { newLevelWanted(null); } @@ -626,7 +626,7 @@ } /** Invoked when user wants to open a new pickmap */ - public void newPickmapWanted() { + public void addNewPickmap() { CMainStatusbar.getInstance().setText(" Creating new pickmap..."); CNewMapDialog.showNewMapDialog(this, mainView, null, MapType.PICKMAP); CMainStatusbar.getInstance().setText(""); @@ -670,7 +670,7 @@ } /** Invoked when the user wants to close the current level. */ - public void closeCurrentLevelWanted() { + public void close() { if (currentMap != null) { closeLevel(currentMap, false); if (currentMap != null) { @@ -680,7 +680,7 @@ } /** Invoked when the user wants to close all levels. */ - public void closeAllLevelsWanted() { + public void closeAll() { for (; levels.size() > 0;) { closeLevel(currentMap, false); if (currentMap != null) { @@ -690,7 +690,7 @@ } /** Invoked when the user wants to close the active pickmap */ - public void closeActivePickmapWanted() { + public void closePickmap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { showMessage("Cannot close Pickmap", "Pickmaps aren't loaded.\n" + "Either there are no pickmaps or the loading process is not complete."); @@ -765,7 +765,7 @@ } /** Open active pickmap as normal map for extensive editing */ - public void openActivePickmapAsMapWanted() { + public void openPickmapMap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { showMessage("Cannot open Pickmap", "Pickmaps aren't loaded.\n" + "Either there are no pickmaps or the loading process is not complete."); @@ -783,7 +783,7 @@ if (!pickmapFile.exists()) { if (askConfirm("Cannot open Pickmap", "The map file for '" + activePickmap.getMapFileName() + "' does not exist.\n" + "Do you want to create the file by saving this pickmap?")) { - saveActivePickmapWanted(); + savePickmap(); openFile(pickmapFile); } } else { @@ -795,7 +795,7 @@ } /** Invoked when user wants to open a file. */ - public void openFileWanted() { + public void open() { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open Map File"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); @@ -997,7 +997,7 @@ } /** Invoked when user wants to save the current level. */ - public void saveCurrentLevelWanted() { + public void save() { if (currentMap == null) { return; } @@ -1006,7 +1006,7 @@ } /** Save current active pickmap */ - public void saveActivePickmapWanted() { + public void savePickmap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { showMessage("Cannot save Pickmap", "Pickmaps aren't loaded.\n" + "Either there are no pickmaps or the loading process is not complete."); @@ -1026,7 +1026,7 @@ } /** Invoked when user wants to save the current level to certain file. */ - public void saveCurrentLevelAsWanted() { + public void saveAs() { saveLevelAsWanted(currentMap); } @@ -1078,7 +1078,7 @@ * In this method, a filechooser is opened to let the user select * an output file name/path for the png image. */ - public void createImageWanted() { + public void createImg() { final MapControl mc = currentMap; // control of current map if (mc == null) { @@ -1164,7 +1164,7 @@ } /** Invoked when user wants to see/edit the level properties. */ - void mapPropertiesWanted() { + public void mapProperties() { showMapProperties(currentMap); } @@ -1189,7 +1189,7 @@ void toggleShowTiles() { } - void optionsWanted() { + public void options() { new COptionDialog(this, mainView); } @@ -1208,12 +1208,12 @@ } } - void setPickmapsLocked(final boolean state) { + void setLockAllPickmaps(final boolean state) { pickmapsLocked = state; } /** Invoked when user wants to exit from the program. */ - void exitWanted() { + public void exit() { if (levels.size() > 0) { for (final MapControl level : levels) { closeLevel(level, false); @@ -1231,7 +1231,7 @@ /** * Try to load the map where the selected map-exit points to. */ - public void enterExitWanted() { + public void enterExit() { final GameObject exit = currentMap.getMapModel().getExit(); if (exit == null) { // no exit found @@ -1373,12 +1373,12 @@ } /** Gives focus to the previous window. */ - public void previousWindowWanted() { + public void prevWindow() { mainView.previousWindowWanted(); } /** Gives focus to the next window. */ - public void nextWindowWanted() { + public void nextWindow() { mainView.nextWindowWanted(); } @@ -1395,7 +1395,7 @@ } /** Invoked when user wants to revert the current map to previously saved state */ - public void revertCurrentLevelWanted() { + public void revert() { final MapControl modmap = this.currentMap; // "modified map" to be reverted // ask for confirmation @@ -1413,7 +1413,7 @@ } /** Invoked when user wants to revert the current map to previously saved state */ - public void revertActivePickmapWanted() { + public void revertPickmap() { if (!CPickmapPanel.getInstance().isLoadComplete()) { showMessage("Cannot revert Pickmap", "Pickmaps aren't loaded.\n" + "Either there are no pickmaps or the loading process is not complete."); @@ -1448,7 +1448,7 @@ } /** "Clear" was selected from the Edit menu. */ - public void clearWanted() { + public void clear() { if (currentMap == null || currentMap.getMapViewFrame() == null) { return; // this should never be possible, but I just wanna make sure... } @@ -1457,7 +1457,7 @@ } /** "Cut" was selected from the Edit menu. */ - public void cutWanted() { + public void cut() { if (currentMap == null || currentMap.getMapViewFrame() == null) { return; // this should never be possible, but I just wanna make sure... } @@ -1466,7 +1466,7 @@ } /** "Copy" was selected from the Edit menu. */ - public void copyWanted() { + public void copy() { if (currentMap == null || currentMap.getMapViewFrame() == null) { return; // this should never be possible, but I just wanna make sure... } @@ -1475,7 +1475,7 @@ } /** "Paste" was selected from the Edit menu. */ - public void pasteWanted() { + public void paste() { if (currentMap == null || currentMap.getMapViewFrame() == null) { return; // this should never be possible, but I just wanna make sure... } @@ -1483,11 +1483,21 @@ copybuffer.paste(currentMap); } + /** "Fill above" was selected from the Edit menu. */ + public void fillAbove() { + fillWanted(false); + } + + /** "Fill below" was selected from the Edit menu. */ + public void fillBelow() { + fillWanted(true); + } + /** * "Fill" was selected from the Edit menu. * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" */ - public void fillWanted(final boolean fillBelow) { + private void fillWanted(final boolean fillBelow) { if (currentMap == null || currentMap.getMapViewFrame() == null) { return; // this should never be possible, but I just wanna make sure... } Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-02 10:50:19 UTC (rev 784) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-02 11:33:24 UTC (rev 785) @@ -253,7 +253,7 @@ m_new.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.newLevelWanted(); + mainControl.createNew(); } }); menuManager.addMenuEntry("main.file", m_new); @@ -265,7 +265,7 @@ m_open.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.openFileWanted(); + mainControl.open(); } }); menuManager.addMenuEntry("main.file", m_open); @@ -277,7 +277,7 @@ m_close.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.closeCurrentLevelWanted(); + mainControl.close(); } }); menuManager.addMenuEntry("main.file", m_close); @@ -291,7 +291,7 @@ m_save.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.saveCurrentLevelWanted(); + mainControl.save(); } }); menuManager.addMenuEntry("main.file", m_save); @@ -303,7 +303,7 @@ m_saveAs.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.saveCurrentLevelAsWanted(); + mainControl.saveAs(); } }); menuManager.addMenuEntry("main.file", m_saveAs); @@ -314,7 +314,7 @@ m_revert.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.revertCurrentLevelWanted(); + mainControl.revert(); } }); menuManager.addMenuEntry("main.file", m_revert); @@ -325,7 +325,7 @@ m_createImg.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.createImageWanted(); + mainControl.createImg(); } }); menuManager.addMenuEntry("main.file", m_createImg); @@ -339,7 +339,7 @@ m_options.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.optionsWanted(); + mainControl.options(); } }); menuManager.addMenuEntry("main.file", m_options); @@ -352,7 +352,7 @@ m_exit.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.exitWanted(); + mainControl.exit(); } }); menuManager.addMenuEntry("main.file", m_exit); @@ -374,7 +374,7 @@ m_clear.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); m_clear.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.clearWanted(); + mainControl.clear(); } }); menuManager.addMenuEntry("main.edit", m_clear); @@ -386,7 +386,7 @@ m_cut.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.cutWanted(); + mainControl.cut(); } }); menuManager.addMenuEntry("main.edit", m_cut); @@ -398,7 +398,7 @@ m_copy.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.copyWanted(); + mainControl.copy(); } }); menuManager.addMenuEntry("main.edit", m_copy); @@ -410,7 +410,7 @@ m_paste.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.pasteWanted(); + mainControl.paste(); } }); menuManager.addMenuEntry("main.edit", m_paste); @@ -436,7 +436,7 @@ m_fill_above.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.fillWanted(false); + mainControl.fillAbove(); } }); menuManager.addMenuEntry("main.edit", m_fill_above); @@ -448,7 +448,7 @@ m_fill_below.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.fillWanted(true); + mainControl.fillBelow(); } }); menuManager.addMenuEntry("main.edit", m_fill_below); @@ -690,7 +690,7 @@ m_enterExit.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.enterExitWanted(); + mainControl.enterExit(); } }); menuManager.addMenuEntry("main.map", m_enterExit); @@ -774,7 +774,7 @@ m_properties.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.mapPropertiesWanted(); + mainControl.mapProperties(); } }); menuManager.addMenuEntry("main.map", m_properties); @@ -798,7 +798,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // lock pickmaps - mainControl.setPickmapsLocked(m_lockPickmaps.isChecked()); + mainControl.setLockAllPickmaps(m_lockPickmaps.isChecked()); m_newPickmap.setEnabled(!m_lockPickmaps.isChecked()); final boolean isArchLoadComplete = mainControl.getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE; @@ -829,7 +829,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // create new pickmap - mainControl.newPickmapWanted(); + mainControl.addNewPickmap(); } }); menuManager.addMenuEntry("main.pickmaps", m_newPickmap); @@ -841,7 +841,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // close pickmap - mainControl.closeActivePickmapWanted(); + mainControl.closePickmap(); } }); menuManager.addMenuEntry("main.pickmaps", m_deletePickmap); @@ -854,7 +854,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // load pickmap as normal map - mainControl.openActivePickmapAsMapWanted(); + mainControl.openPickmapMap(); } }); menuManager.addMenuEntry("main.pickmaps", m_loadPickmap); @@ -866,7 +866,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // save pickmap - mainControl.saveActivePickmapWanted(); + mainControl.savePickmap(); } }); menuManager.addMenuEntry("main.pickmaps", m_savePickmap); @@ -878,7 +878,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // revert pickmap - mainControl.revertActivePickmapWanted(); + mainControl.revertPickmap(); } }); menuManager.addMenuEntry("main.pickmaps", m_revertPickmap); @@ -1129,7 +1129,7 @@ m_closeAll.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.closeAllLevelsWanted(); + mainControl.closeAll(); } }); menu_window.add(m_closeAll); @@ -1187,7 +1187,7 @@ * @param state true when there is an active pickmap */ public void setActivePickmapsEnabled(final boolean state) { - if (!mainControl.isPickmapsLocked()) { + if (!mainControl.isLockAllPickmaps()) { m_deletePickmap.setEnabled(state); m_loadPickmap.setEnabled(state); m_revertPickmap.setEnabled(state); @@ -1213,7 +1213,7 @@ if (isArchLoadComplete) { m_viewTreasure.setEnabled(true); - if (!mainControl.isPickmapsLocked() && mainControl.getMainView().isPickmapActive()) { + if (!mainControl.isLockAllPickmaps() && mainControl.getMainView().isPickmapActive()) { m_deletePickmap.setEnabled(true); m_loadPickmap.setEnabled(true); m_revertPickmap.setEnabled(true); @@ -1232,7 +1232,7 @@ m_savePickmap.setEnabled(false); } - m_newPickmap.setEnabled(!mainControl.isPickmapsLocked()); + m_newPickmap.setEnabled(!mainControl.isLockAllPickmaps()); // is there a valid open map view? if (mainControl.getCurrentMap() == null) { Modified: trunk/crossfire/src/cfeditor/CMainToolbar.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainToolbar.java 2006-12-02 10:50:19 UTC (rev 784) +++ trunk/crossfire/src/cfeditor/CMainToolbar.java 2006-12-02 11:33:24 UTC (rev 785) @@ -146,7 +146,7 @@ checkIcon(IGUIConstants.NEW_LEVEL_ICON), new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.newLevelWanted(); + mainControl.createNew(); } }); m_new.setVerticalTextPosition(JButton.BOTTOM); @@ -160,7 +160,7 @@ checkIcon(IGUIConstants.OPEN_LEVEL_ICON), new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.openFileWanted(); + mainControl.open(); } }); m_open.setVerticalTextPosition(JButton.BOTTOM); @@ -174,7 +174,7 @@ checkIcon(IGUIConstants.SAVE_LEVEL_ICON), new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.saveCurrentLevelWanted(); + mainControl.save(); } }); m_save.setVerticalTextPosition(JButton.BOTTOM); @@ -188,7 +188,7 @@ checkIcon(IGUIConstants.SAVE_LEVEL_AS_ICON), new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.saveCurrentLevelAsWanted(); + mainControl.saveAs(); } }); m_saveAs.setVerticalTextPosition(JButton.BOTTOM); @@ -205,7 +205,7 @@ checkIcon(IGUIConstants.PREVIOUS_WINDOW_ICON), new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.previousWindowWanted(); + mainControl.prevWindow(); } }); m_prevWindow.setVerticalTextPosition(JButton.BOTTOM); @@ -219,7 +219,7 @@ checkIcon(IGUIConstants.NEXT_WINDOW_ICON), new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.nextWindowWanted(); + mainControl.nextWindow(); } }); m_nextWindow.setVerticalTextPosition(JButton.BOTTOM); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-02 10:50:19 UTC (rev 784) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-02 11:33:24 UTC (rev 785) @@ -153,7 +153,7 @@ addWindowListener( new WindowAdapter() { @Override public void windowClosing(final WindowEvent event) { - mainControl.exitWanted(); + mainControl.exit(); } }); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-02 10:50:19 UTC (rev 784) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-02 11:33:24 UTC (rev 785) @@ -521,7 +521,7 @@ if (mapLoc != null) { // in "locked pickmaps" mode, pickmaps react only to leftclicks - if (mapControl.isPickmap() && mainControl.isPickmapsLocked() + if (mapControl.isPickmap() && mainControl.isLockAllPickmaps() && !(e.getModifiers() == MouseEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown())) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-05 22:38:23
|
Revision: 915 http://svn.sourceforge.net/gridarta/?rev=915&view=rev Author: akirschbaum Date: 2006-12-05 14:38:19 -0800 (Tue, 05 Dec 2006) Log Message: ----------- Unify CArchQuickView implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchQuickView.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CArchQuickView.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-12-05 22:24:35 UTC (rev 914) +++ trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-12-05 22:38:19 UTC (rev 915) @@ -25,15 +25,11 @@ package cfeditor; import cfeditor.gameobject.GameObject; -import java.awt.BorderLayout; -import java.awt.Dimension; +import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.Insets; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ScrollPaneConstants; import net.sf.gridarta.gameobject.Archetype; /** @@ -48,62 +44,48 @@ /** Controller of this subview. */ private final CMainControl mainControl; - private final JLabel archArchNameText = new JLabel(); + private final JLabel archObjNameLabel = new JLabel("Name:"); + private final JLabel archArchNameLabel = new JLabel("Arch:"); + + private final JLabel archTypeLabel = new JLabel("Type:"); + + private final JLabel archTileLabel = new JLabel("Tile:"); + private final JLabel archObjNameText = new JLabel(); + private final JLabel archArchNameText = new JLabel(); + private final JLabel archTypeText = new JLabel(); private final JLabel archTileText = new JLabel(); public CArchQuickView(final CMainControl mainControl) { this.mainControl = mainControl; - setLayout(new BorderLayout(1, 1)); + setLayout(new GridBagLayout()); - // setup a panel - final JPanel panel = new JPanel(); - final GridBagLayout gridbag = new GridBagLayout(); - final GridBagConstraints c = new GridBagConstraints(); - panel.setLayout(gridbag); - c.fill = GridBagConstraints.HORIZONTAL; - c.ipadx = 0; - c.ipady = 0; - c.weightx = 0.5; - c.weighty = 0; - c.gridwidth = 1; - c.insets = new Insets(0, 0, 0, 0); - c.anchor = GridBagConstraints.WEST; - // add our elements - archObjNameText.setText("<html><font color=black>Name:</font></html>"); - c.gridx = 0; - c.gridy = 0; - gridbag.setConstraints(archObjNameText, c); - panel.add(archObjNameText); + final GridBagConstraints gcl = new GridBagConstraints(); + final GridBagConstraints gcr = new GridBagConstraints(); + gcl.fill = GridBagConstraints.HORIZONTAL; + gcr.fill = GridBagConstraints.HORIZONTAL; + gcl.weightx = 0.0; + gcr.weightx = 1.0; + gcl.anchor = GridBagConstraints.WEST; + gcr.anchor = GridBagConstraints.WEST; + gcl.gridwidth = 1; + gcr.gridwidth = GridBagConstraints.REMAINDER; - archArchNameText.setText("<html><font color=black>Arch:</font></html>"); - c.gridx = 0; - c.gridy = 1; - gridbag.setConstraints(archArchNameText, c); - panel.add(archArchNameText); + add(archObjNameLabel, gcl); + add(archObjNameText, gcr); - archTypeText.setText("<html><font color=black>Type:</font></html>"); - c.gridx = 0; - c.gridy = 2; - gridbag.setConstraints(archTypeText, c); - panel.add(archTypeText); + add(archArchNameLabel, gcl); + add(archArchNameText, gcr); - archTileText.setText("<html><font color=black>Tile:</font></html>"); - c.gridx = 0; - c.gridy = 3; - gridbag.setConstraints(archTileText, c); - panel.add(archTileText); + add(archTypeLabel, gcl); + add(archTypeText, gcr); - // put it in a scroller - final JScrollPane scrollPane = new JScrollPane(panel); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - setMinimumSize(new Dimension(1, 1)); - add(scrollPane); // and add it to this panel object + add(archTileLabel, gcl); + add(archTileText, gcr); } /** @@ -114,41 +96,45 @@ */ void showArchPanelQuickObject(final GameObject gameObject) { if (gameObject == null) { - archArchNameText.setText("<html><font color=black>Arch:</font></html>"); - archObjNameText.setText("<html><font color=black>Name:</font></html>"); - archTypeText.setText("<html><font color=black>Type:</font></html>"); - archTileText.setText("<html><font color=black>Tile:</font></html>"); - return; - } - - final GameObject headObject = gameObject.getHead(); - archArchNameText.setText("<html><font color=black>Arch: " + headObject.getArchetypeName() + "</font></html>"); - if (headObject.getObjName() == null || headObject.getObjName().length() <= 0) { - final Archetype<GameObject> archetype = headObject.getArchetype(); - if (archetype == null || archetype == headObject) { - archObjNameText.setText("<html><font color=black>Name: -none- </font></html>"); - } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - archObjNameText.setText("<html><font color=black>Name: " + archetype.getObjName() + "</font></html>"); - } else if (archetype.getArchetypeName() != null && archetype.getArchetypeName().length() > 0) { - archObjNameText.setText("<html><font color=black>Name: " + archetype.getArchetypeName() + "</font></html>"); + archObjNameText.setText(null); + archArchNameText.setText(null); + archTypeText.setText(null); + archTileText.setText(null); + } else { + final GameObject headObject = gameObject.getHead(); + String objName = headObject.getObjName(); + if (objName == null || objName.length() == 0) { + final Archetype<GameObject> archetype = headObject.getArchetype(); + if (archetype == null || archetype == headObject) { + objName = null; + } else if ((objName = archetype.getObjName()) != null && objName.length() != 0) { + } else if ((objName = archetype.getArchetypeName()) != null && objName.length() != 0) { + } else { + objName = null; + } + } + if (objName == null) { + objName = " -none- "; + archObjNameText.setForeground(Color.RED); } else { - archObjNameText.setText("<html><font color=black>Name: -none- </font></html>"); + archObjNameText.setForeground(Color.BLACK); } - } else { - archObjNameText.setText("<html><font color=black>Name: " + headObject.getObjName() + "</font></html>"); - } + archObjNameText.setText(objName); - archTypeText.setText("<html><font color=black>Type: " + mainControl.getArchetypeParser().getArchTypeName(headObject.getArchTypNr()) + " (" + headObject.getArchTypNr() + ") </font></html>"); + archArchNameText.setText(headObject.getArchetypeName()); - if (headObject.isMulti()) { - archTileText.setText("<html><font color=black>Tile: </font><font color=green> multi</font><font color=black> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + "," + headObject.getSizeY() + ")</font></html>"); - } else { - archTileText.setText("<html><font color=black>Tile: single" + "</font></html>"); - } + archTypeText.setText(mainControl.getTypeList().getArchTypeName(headObject.getArchTypNr()) + " (" + headObject.getArchTypNr() + ')'); - // notify ReplaceDialog - if (ReplaceDialog.isBuilt() && ReplaceDialog.getInstance().isShowing()) { - ReplaceDialog.getInstance().updateArchSelection(headObject, false); + if (headObject.isMulti()) { + archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + ',' + headObject.getSizeY() + ")</html>"); + } else { + archTileText.setText("single"); + } + + // notify ReplaceDialog + if (ReplaceDialog.isBuilt() && ReplaceDialog.getInstance().isShowing()) { + ReplaceDialog.getInstance().updateArchSelection(headObject, false); + } } } Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-05 22:24:35 UTC (rev 914) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-05 22:38:19 UTC (rev 915) @@ -40,6 +40,7 @@ import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.io.IOUtils; +import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jdom.Attribute; import org.jdom.DataConversionException; @@ -65,6 +66,18 @@ private int[] spellNum; // array of spell numbers /** + * Table with type numbers as keys (Integer), and type names as values (String). + */ + private final Map<Integer, String> archTypeNumbers = new HashMap<Integer, String>(); + + // table with type arch type name as keys (String), and arch type object as values (CFArchType) + private final Map<String, CFArchType> archTypeNames = new HashMap<String, CFArchType>(); + + private final CFArchType defaultArchType = new CFArchType(null); // contains default type + + private final List<CFArchType> archTypeList = new ArrayList<CFArchType>(); // All but the default ArchType + + /** * Table with CAttribBitmask objects (value) accessible by name (key). */ private final Map<String, CAttribBitmask> bitmaskTable; @@ -109,6 +122,7 @@ // start parsing the xml final Element root = doc.getRootElement(); + parseTypes(root); Element elem; Attribute a; if (root == null || !root.getName().equalsIgnoreCase("types")) { @@ -259,6 +273,31 @@ return head; } + private void parseTypes(final Element root) { + // parse all type elements + final List entries = root.getChildren("type"); + for (int i = 0; entries != null && i < entries.size(); i++) { + final Element elem = (Element) entries.get(i); + final Attribute attr = elem.getAttribute("available"); + if (attr != null && !attr.getValue().equals("no")) { + // create a new CFArchType element + final CFArchType newType = new CFArchType(defaultArchType); + + // attach the new CFArchType element to the list + // if we manage to parse it properly from the file + if (newType.load(elem, this)) { + archTypeList.add(newType); + archTypeNames.put(newType.getTypeName(), newType); + } + } + try { + archTypeNumbers.put(elem.getAttribute("number").getIntValue(), elem.getAttribute("name").getValue()); + } catch (final DataConversionException ex) { + // ignore + } + } + } + public String[] getSpellName() { return spellName; } @@ -402,6 +441,15 @@ } /** + * Lookup the name of an archtype. + * @param typeNr type number + * @return name of this type, as defined in "typenumbers.xml" + */ + public String getArchTypeName(final int typeNr) { + return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + '*'; + } + + /** * Read all spells from a CF spellist file and write an * alphabetical list into "spells.def" * @param spellfile spellfile to read Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-05 22:24:35 UTC (rev 914) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-05 22:38:19 UTC (rev 915) @@ -1689,6 +1689,10 @@ return levels.toArray(new MapControl[levels.size()]); } + public CFArchTypeList getTypeList() { + return typeList; + } + /** * Returns the current top map we are working with. * @return the current top map we are working with This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-06 14:38:33
|
Revision: 1457 http://svn.sourceforge.net/gridarta/?rev=1457&view=rev Author: akirschbaum Date: 2007-01-06 06:38:30 -0800 (Sat, 06 Jan 2007) Log Message: ----------- Rename method names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/map/MapArchObject.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2007-01-06 13:39:50 UTC (rev 1456) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2007-01-06 14:38:30 UTC (rev 1457) @@ -190,7 +190,7 @@ final JPanel panel = new JPanel(new GridLayout(0, 1)); panel.add(createPanelLine(mapName, 16, map.getMapName(), "mapName")); - panel.add(createPanelLine(mapRegion, 16, map.getMapRegion(), "mapRegion")); + panel.add(createPanelLine(mapRegion, 16, map.getRegion(), "mapRegion")); final Size2D mapSize = mapControl.getMapSize(); panel.add(createPanelLine(levelWidthField, 10, String.valueOf(mapSize.getWidth()), "mapWidth")); panel.add(createPanelLine(levelHeightField, 10, String.valueOf(mapSize.getHeight()), "mapHeight")); @@ -462,7 +462,7 @@ map.setLore(mapLore.getText()); map.setMapName(mapNameString.trim()); // trim, this string might come from the UI - map.setMapRegion(region); + map.setRegion(region); map.setEnterX(enterX); map.setEnterY(enterY); map.setResetTimeout(resetTimeout); @@ -574,7 +574,7 @@ mapDescription.setText(map.getText()); mapLore.setText(map.getLore()); mapName.setText(map.getMapName()); - mapRegion.setText(map.getMapRegion()); + mapRegion.setText(map.getRegion()); final Size2D mapSize = map.getMapSize(); levelWidthField.setText(String.valueOf(mapSize.getWidth())); levelHeightField.setText(String.valueOf(mapSize.getHeight())); Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-06 13:39:50 UTC (rev 1456) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-06 14:38:30 UTC (rev 1457) @@ -172,11 +172,11 @@ tilePaths[direction] = tilePath; } - @NotNull public String getMapRegion() { + @NotNull public String getRegion() { return region; } - public void setMapRegion(@NotNull final String region) { + public void setRegion(@NotNull final String region) { this.region = region; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |