From: <aki...@us...> - 2008-09-16 20:50:37
|
Revision: 5152 http://gridarta.svn.sourceforge.net/gridarta/?rev=5152&view=rev Author: akirschbaum Date: 2008-09-16 20:50:47 +0000 (Tue, 16 Sep 2008) Log Message: ----------- Remove dependency NewMapDialogFactory -> MainControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-16 20:40:44 UTC (rev 5151) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-16 20:50:47 UTC (rev 5152) @@ -162,7 +162,7 @@ @NotNull @Override protected NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newNewMapDialogFactory(@NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - return new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); + return new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-16 20:40:44 UTC (rev 5151) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-16 20:50:47 UTC (rev 5152) @@ -222,7 +222,7 @@ @NotNull @Override protected NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newNewMapDialogFactory(@NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - return new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); + return new NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, gridartaObjectsFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-16 20:40:44 UTC (rev 5151) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-16 20:50:47 UTC (rev 5152) @@ -313,6 +313,7 @@ final ActionFactory actionFactory = ActionFactory.getFactory(key); new MapFileActions<G, A, R, V>(this, mapManager, mapViewManager, null); mainView = new MainView<G, A, R, V>(this, editTypes, mapManager, mapViewManager, actionFactory, mapManagerActions.getCloseAllAction(), statusBar, getBuildNumberAsString()); + newMapDialogFactory.setParent(mainView); pickmapChooserControl.setParent(mainView); final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R, V>(archetypeTypeSet, archetypeSet, mapManager, mainView); final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl = new ArchetypeChooserControl<G, A, R, V>(archetypeChooserModel, createDirectionPane, gameObjectAttributesDialogFactory); Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-09-16 20:40:44 UTC (rev 5151) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialogFactory.java 2008-09-16 20:50:47 UTC (rev 5152) @@ -19,8 +19,8 @@ package net.sf.gridarta.gui.newmap; +import java.awt.Component; import net.sf.gridarta.GridartaObjectsFactory; -import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; @@ -40,10 +40,6 @@ */ public final class NewMapDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { - /** The main control instance. */ - @NotNull - private final MainControl<G, A, R, V> mainControl; - /** * The map manager to use. */ @@ -85,9 +81,12 @@ @NotNull private ObjectChooser<G, A, R> objectChooser; + /** The parent component for dialog windows. */ + @NotNull + private Component parent; + /** * Creates a new instance. - * @param mainControl the main control instance * @param mapManager the map manager to use * @param gridartaObjectsFactory the gridarta objects factory instance * @param defaultMapWidth the default width for new maps @@ -98,8 +97,7 @@ * @param defaultPickmapWidth the default width for new pickmaps * @param defaultPickmapHeight the default height for new pickmaps */ - public NewMapDialogFactory(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, final int defaultMapWidth, final int defaultMapHeight, final int defaultMapDifficulty, final boolean showMapDifficulty, final boolean showMapSizeDefault, final int defaultPickmapWidth, final int defaultPickmapHeight) { - this.mainControl = mainControl; + public NewMapDialogFactory(@NotNull final MapManager<G, A, R, V> mapManager, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, final int defaultMapWidth, final int defaultMapHeight, final int defaultMapDifficulty, final boolean showMapDifficulty, final boolean showMapSizeDefault, final int defaultPickmapWidth, final int defaultPickmapHeight) { this.mapManager = mapManager; this.gridartaObjectsFactory = gridartaObjectsFactory; this.defaultMapWidth = defaultMapWidth; @@ -111,6 +109,14 @@ this.defaultPickmapHeight = defaultPickmapHeight; } + /** + * Sets the parent component for dialog windows. + * @param parent the parent component + */ + public void setParent(@NotNull final Component parent) { + this.parent = parent; + } + public void setPickmapChooserControl(@NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { this.pickmapChooserControl = pickmapChooserControl; } @@ -125,12 +131,12 @@ * unknown */ public void showNewMapDialog(final String filename) { - new NewMapDialog<G, A, R, V>(mapManager, gridartaObjectsFactory, mainControl.getMainView(), filename, showMapSizeDefault, showMapDifficulty, defaultMapWidth, defaultMapHeight, defaultMapDifficulty); + new NewMapDialog<G, A, R, V>(mapManager, gridartaObjectsFactory, parent, filename, showMapSizeDefault, showMapDifficulty, defaultMapWidth, defaultMapHeight, defaultMapDifficulty); } /** Shows a dialog for creating a new pickmap. */ public void showNewPickmapDialog() { - new NewPickmapDialog<G, A, R, V>(objectChooser, mainControl.getMainView(), defaultPickmapWidth, defaultPickmapHeight, pickmapChooserControl); + new NewPickmapDialog<G, A, R, V>(objectChooser, parent, defaultPickmapWidth, defaultPickmapHeight, pickmapChooserControl); } /** @@ -139,7 +145,7 @@ * @param parent the parent folder to add the pickmap folder to */ public void showNewPickmapFolderDialog(@NotNull final MapFolderTree<G, A, R, V> mapFolderTree, @Nullable final MapFolder<G, A, R, V> parent) { - new NewPickmapFolderDialog<G, A, R, V>(mainControl.getMainView(), mapFolderTree, parent); + new NewPickmapFolderDialog<G, A, R, V>(this.parent, mapFolderTree, parent); } } // class NewMapDialogFactory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-17 06:08:39
|
Revision: 5158 http://gridarta.svn.sourceforge.net/gridarta/?rev=5158&view=rev Author: akirschbaum Date: 2008-09-17 06:08:49 +0000 (Wed, 17 Sep 2008) Log Message: ----------- Remove trailing whitespace. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/MapViewManager.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserListener.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-16 21:15:03 UTC (rev 5157) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-17 06:08:49 UTC (rev 5158) @@ -133,7 +133,7 @@ protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { return new DefaultMapControlFactory(gridartaObjectsFactory); } - + /** {@inheritDoc} */ @NotNull @Override Modified: trunk/src/app/net/sf/gridarta/gui/MapViewManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-09-16 21:15:03 UTC (rev 5157) +++ trunk/src/app/net/sf/gridarta/gui/MapViewManager.java 2008-09-17 06:08:49 UTC (rev 5158) @@ -44,7 +44,7 @@ private final List<MapView<G, A, R, V>> mapViews = Collections.synchronizedList(new ArrayList<MapView<G, A, R, V>>()); /** - * The current map view. + * The current map view. */ @Nullable private MapView<G, A, R, V> currentMapView = null; @@ -147,7 +147,7 @@ } /** - * Updates the current map view and notifies all listeners of changes. + * Updates the current map view and notifies all listeners of changes. */ private void updateCurrentMapView() { final MapView<G, A, R, V> newCurrentMapView = getCurrentMapView(); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-09-16 21:15:03 UTC (rev 5157) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-09-17 06:08:49 UTC (rev 5158) @@ -259,7 +259,7 @@ docStyle = summaryTP.getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setForeground(docStyle, Color.black); - + setMessage(contentPanel); } Modified: trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserListener.java 2008-09-16 21:15:03 UTC (rev 5157) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserListener.java 2008-09-17 06:08:49 UTC (rev 5158) @@ -21,7 +21,7 @@ /** * Interface for listener interested in {@link ObjectChooser} events. - * @author Andreas Kirschbaum + * @author Andreas Kirschbaum */ public interface ObjectChooserListener { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-17 06:27:38
|
Revision: 5162 http://gridarta.svn.sourceforge.net/gridarta/?rev=5162&view=rev Author: akirschbaum Date: 2008-09-17 06:27:32 +0000 (Wed, 17 Sep 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/MapActions.java Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-09-17 06:24:29 UTC (rev 5161) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-09-17 06:27:32 UTC (rev 5162) @@ -353,13 +353,13 @@ * @param currentMapView the map view to leave * @param path path to map that should be loaded * @param direction the direction to go - * @param destinationPoint the new cursor position + * @param destinationPoint the desired destination point on the map (pass + * 0|0 if unknown, and note that the point gets modified) * @param exit the applied exit object */ private void enterMap(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMapView, @NotNull final String path, final int direction, final Point destinationPoint, final GameObject exit) { final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMap = currentMapView.getMapControl(); - // path points to a different map @NotNull final File newfile; // new mapfile to open if (exit != null && path.equals("/!")) { // destination is a random map; extract the final non-random map @@ -381,17 +381,15 @@ } newfile = new File(currentMap.getMapFile().getParent(), path); } - if (path.length() == 0 || (currentMap.getMapFile() != null && newfile.equals(currentMap.getMapFile()))) { // path points to the same map if (destinationPoint != null) { if (destinationPoint.x == 0 && destinationPoint.y == 0) { ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); - } else - if (!currentMap.getMapModel().isPointValid(destinationPoint)) { - ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); - } else { + } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { currentMapView.getMapViewBasic().setCursorPosition(destinationPoint); + } else { + ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } } return; Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-09-17 06:24:29 UTC (rev 5161) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-09-17 06:27:32 UTC (rev 5162) @@ -353,8 +353,8 @@ * @param currentMapView the map view to leave * @param path path to map that should be loaded * @param direction the direction to go - * @param destinationPoint Desired destination point on the map (pass 0|0 if - * unknown, and note that the point gets modified) + * @param destinationPoint the desired destination point on the map (pass + * 0|0 if unknown, and note that the point gets modified) */ private void enterMap(@NotNull final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMapView, @NotNull final String path, final int direction, @NotNull final Point destinationPoint) { final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> currentMap = currentMapView.getMapControl(); @@ -376,8 +376,7 @@ if (destinationPoint != null) { if (destinationPoint.x == 0 && destinationPoint.y == 0) { ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); - } else - if (currentMap.getMapModel().isPointValid(destinationPoint)) { + } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { currentMapView.getMapViewBasic().setCursorPosition(destinationPoint); } else { ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-17 06:40:29
|
Revision: 5164 http://gridarta.svn.sourceforge.net/gridarta/?rev=5164&view=rev Author: akirschbaum Date: 2008-09-17 06:40:18 +0000 (Wed, 17 Sep 2008) Log Message: ----------- Merge duplicate code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/io/GameObjectParser.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/io/GameObjectParser.java trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-09-17 06:33:07 UTC (rev 5163) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-09-17 06:40:18 UTC (rev 5164) @@ -311,7 +311,7 @@ final Archetype archetype = getArchetype(); resetObjectText(); - for (final String line : lineSeparatorPattern.split(text)) { + for (final String line : patternEndOfLine.split(text)) { if (line.length() > 0) { if (line.startsWith("name ")) { setObjName(line.substring(5)); Modified: trunk/crossfire/src/cfeditor/io/GameObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/io/GameObjectParser.java 2008-09-17 06:33:07 UTC (rev 5163) +++ trunk/crossfire/src/cfeditor/io/GameObjectParser.java 2008-09-17 06:40:18 UTC (rev 5164) @@ -53,9 +53,6 @@ /** Pattern to match spaces. */ private static final Pattern patternSpaces = Pattern.compile(" +"); - /** Pattern to match end of lines. */ - private static final Pattern patternEndOfLine = Pattern.compile("\n"); - /* * Initialize {@link keys} array. * @todo this information should be read from a file. @@ -387,7 +384,7 @@ final String objText = gameObject.getObjectText(); if (objText.length() != 0) { - for (final String aTmp : patternEndOfLine.split(objText, 0)) { + for (final String aTmp : net.sf.gridarta.gameobject.GameObject.patternEndOfLine.split(objText, 0)) { final String[] line = patternSpaces.split(aTmp, 2); if (line.length != 2) { log.warn("writeMapArch: ignoring invalid arch line: " + aTmp); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-09-17 06:33:07 UTC (rev 5163) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-09-17 06:40:18 UTC (rev 5164) @@ -450,7 +450,7 @@ final Archetype archetype = getArchetype(); resetObjectText(); - for (final String line : lineSeparatorPattern.split(text)) { + for (final String line : patternEndOfLine.split(text)) { if (line.length() > 0) { if (line.startsWith("name ")) { setObjName(line.substring(5)); Modified: trunk/daimonin/src/daieditor/io/GameObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-09-17 06:33:07 UTC (rev 5163) +++ trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-09-17 06:40:18 UTC (rev 5164) @@ -24,7 +24,6 @@ import daieditor.map.MapArchObject; import java.io.IOException; import java.util.Formatter; -import java.util.regex.Pattern; import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.io.AbstractGameObjectParser; import org.jetbrains.annotations.NotNull; @@ -36,9 +35,6 @@ */ public class GameObjectParser extends AbstractGameObjectParser<GameObject, MapArchObject, Archetype> { - /** Pattern to match end of lines. */ - private static final Pattern patternEndOfLine = Pattern.compile("\n"); - /** * Create a new instance. * @param gameObjectFactory the game object factory for creating new game @@ -82,7 +78,7 @@ final StringBuilder newArchText = new StringBuilder(); final String objText = gameObject.getObjectText(); if (objText.length() != 0) { - for (final String line : patternEndOfLine.split(objText, 0)) { + for (final String line : net.sf.gridarta.gameobject.GameObject.patternEndOfLine.split(objText, 0)) { if (!line.startsWith("type ")) { newArchText.append(line).append('\n'); } Modified: trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java 2008-09-17 06:33:07 UTC (rev 5163) +++ trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java 2008-09-17 06:40:18 UTC (rev 5164) @@ -19,7 +19,6 @@ package net.sf.gridarta.gameobject; -import java.util.regex.Pattern; import org.jetbrains.annotations.NotNull; /** @@ -29,11 +28,6 @@ public class AttributeListUtils { /** - * The pattern for splitting attribute lines. - */ - private static final Pattern patternEndOfLine = Pattern.compile("\\s*\n"); - - /** * Private constructor to prevent instantiation. */ private AttributeListUtils() { @@ -52,7 +46,7 @@ final String prefix = key + " "; - final String[] lines = patternEndOfLine.split(attributeList, -1); + final String[] lines = GameObject.patternEndOfLine.split(attributeList, -1); final StringBuilder sb = new StringBuilder(); for (final String line : lines) { Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-09-17 06:33:07 UTC (rev 5163) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-09-17 06:40:18 UTC (rev 5164) @@ -58,7 +58,7 @@ * The pattern to match end of line characters separating lines in the arch * text. */ - protected static final Pattern lineSeparatorPattern = Pattern.compile("\n"); + public static final Pattern patternEndOfLine = Pattern.compile("\\s*\n"); /** * The archetype set to use. @@ -171,9 +171,6 @@ /** The location in the archetype selector. */ private String editorFolder; - /** Pattern to match end of lines. */ - private static final Pattern patternEndOfLine = Pattern.compile("\\s*\n"); - /** * The name of the face. Object face name <code>face * <var>name</var></code>. @@ -1498,7 +1495,7 @@ } boolean scriptflag = false; - for (final String line : lineSeparatorPattern.split(text)) { + for (final String line : patternEndOfLine.split(text)) { if (line.length() > 0) { if (scriptflag) { addObjectText(line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 11:20:00
|
Revision: 5191 http://gridarta.svn.sourceforge.net/gridarta/?rev=5191&view=rev Author: akirschbaum Date: 2008-09-18 18:20:10 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move GameObject.FaceSource to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gui/ArchTab.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/FaceSource.java Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-09-18 18:18:41 UTC (rev 5190) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-09-18 18:20:10 UTC (rev 5191) @@ -26,6 +26,7 @@ import javax.swing.JList; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; @@ -494,30 +495,4 @@ updateEditType(editType); } - /** Enumeration describing the state of the face. */ - public enum FaceSource { - - /** The face of this GameObject was not found. */ - FACE_NOT_FOUND, - - /** This GameObject has a normal face defined. */ - FACE, - - /** - * This GameObject has no face defined and thus inherited the face from - * its default arch. - */ - ARCHETYPE_FACE, - - /** This GameObject has an animation defined. */ - ANIM, - - /** - * This GameObject is animated but doesn't define an animation and thus - * inherited the animation from its default arch. - */ - ARCHETYPE_ANIM - - } // enum FaceSource - } // class GameObject Modified: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:18:41 UTC (rev 5190) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:20:10 UTC (rev 5191) @@ -23,6 +23,7 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import org.jetbrains.annotations.NotNull; @@ -44,7 +45,7 @@ protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { final String faceName = gameObject.getFaceName(); if (faceName != null) { - final GameObject.FaceSource desc = gameObject.getFaceObjSource(); + final FaceSource desc = gameObject.getFaceObjSource(); sb.append(faceName).append(" ("); switch (desc) { case FACE_NOT_FOUND: Added: trunk/src/app/net/sf/gridarta/gameobject/FaceSource.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/FaceSource.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/FaceSource.java 2008-09-18 18:20:10 UTC (rev 5191) @@ -0,0 +1,51 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gameobject; + +/** + * Enumeration describing the state of the face. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public enum FaceSource { + + /** The face of this GameObject was not found. */ + FACE_NOT_FOUND, + + /** This GameObject has a normal face defined. */ + FACE, + + /** + * This GameObject has no face defined and thus inherited the face from + * its default arch. + */ + ARCHETYPE_FACE, + + /** This GameObject has an animation defined. */ + ANIM, + + /** + * This GameObject is animated but doesn't define an animation and thus + * inherited the animation from its default arch. + */ + ARCHETYPE_ANIM + +} // enum FaceSource Property changes on: trunk/src/app/net/sf/gridarta/gameobject/FaceSource.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 11:47:52
|
Revision: 5193 http://gridarta.svn.sourceforge.net/gridarta/?rev=5193&view=rev Author: akirschbaum Date: 2008-09-18 18:48:00 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Fix display of "Image:" information in game object attributes panel. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/gui/ArchTab.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-18 18:39:46 UTC (rev 5192) +++ trunk/crossfire/ChangeLog 2008-09-18 18:48:00 UTC (rev 5193) @@ -1,3 +1,8 @@ +2008-09-18 Andreas Kirschbaum + + * Fix display of "Image:" information in game object attributes + panel. + 2008-09-07 Andreas Kirschbaum * Add options pane "Developers". Modified: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-09-18 18:39:46 UTC (rev 5192) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-09-18 18:48:00 UTC (rev 5193) @@ -43,7 +43,7 @@ /** {@inheritDoc} */ @Override protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { - final String faceName = gameObject.getFaceName(); + final String faceName = gameObject.getFaceObjName(); if (faceName != null) { final FaceSource desc = gameObject.getFaceObjSource(); sb.append(faceName).append(" ("); Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-09-18 18:39:46 UTC (rev 5192) +++ trunk/daimonin/ChangeLog 2008-09-18 18:48:00 UTC (rev 5193) @@ -1,3 +1,8 @@ +2008-09-18 Andreas Kirschbaum + + * Fix display of "Image:" information in game object attributes + panel. + 2008-08-29 Andreas Kirschbaum * Ignore empty lines in .anim files. Modified: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:39:46 UTC (rev 5192) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:48:00 UTC (rev 5193) @@ -43,7 +43,7 @@ /** {@inheritDoc} */ @Override protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { - final String faceName = gameObject.getFaceName(); + final String faceName = gameObject.getFaceObjName(); if (faceName != null) { final FaceSource desc = gameObject.getFaceObjSource(); sb.append(faceName).append(" ("); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 11:57:49
|
Revision: 5194 http://gridarta.svn.sourceforge.net/gridarta/?rev=5194&view=rev Author: akirschbaum Date: 2008-09-18 18:57:57 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move ArchTab.appendFaceSource() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/Archetype.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/daimonin/src/daieditor/gameobject/Archetype.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gui/ArchTab.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/gameobject/Archetype.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/Archetype.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/crossfire/src/cfeditor/gameobject/Archetype.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -115,6 +115,4 @@ int SUBTYPE_EVENT_CONNECTOR_TRIGGER = 10; - String getFaceObjName(); - } // class Archetype Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -107,6 +107,7 @@ gameObjectChanged(); } + /** {@inheritDoc} */ @NotNull public FaceSource getFaceObjSource() { return faceObjSource; Modified: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -23,7 +23,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import org.jetbrains.annotations.NotNull; @@ -40,38 +39,4 @@ super(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor); } - /** {@inheritDoc} */ - @Override - protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { - final String faceName = gameObject.getFaceObjName(); - if (faceName != null) { - final FaceSource desc = gameObject.getFaceObjSource(); - sb.append(faceName).append(" ("); - switch (desc) { - case FACE_NOT_FOUND: - sb.append("face not found"); - break; - - case FACE: - sb.append("face"); - break; - - case ARCHETYPE_FACE: - sb.append("archetype face"); - break; - - case ANIM: - sb.append("anim"); - break; - - case ARCHETYPE_ANIM: - sb.append("archetype anim"); - break; - } - sb.append(')'); - } else { - sb.append(">no face<"); - } - } - } // class ArchTab Modified: trunk/daimonin/src/daieditor/gameobject/Archetype.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Archetype.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/daimonin/src/daieditor/gameobject/Archetype.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -103,8 +103,6 @@ boolean isLowestPart(); - String getFaceObjName(); - boolean hasFaceObject(); } // class Archetype Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -155,6 +155,7 @@ return getAttributeInt("is_turnable") != 0 || getAttributeInt("is_animated") != 0; } + /** {@inheritDoc} */ @NotNull public FaceSource getFaceObjSource() { return faceObjSource; Modified: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -23,7 +23,6 @@ import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import org.jetbrains.annotations.NotNull; @@ -40,38 +39,4 @@ super(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor); } - /** {@inheritDoc} */ - @Override - protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final GameObject gameObject) { - final String faceName = gameObject.getFaceObjName(); - if (faceName != null) { - final FaceSource desc = gameObject.getFaceObjSource(); - sb.append(faceName).append(" ("); - switch (desc) { - case FACE_NOT_FOUND: - sb.append("face not found"); - break; - - case FACE: - sb.append("face"); - break; - - case ARCHETYPE_FACE: - sb.append("archetype face"); - break; - - case ANIM: - sb.append("anim"); - break; - - case ARCHETYPE_ANIM: - sb.append("archetype anim"); - break; - } - sb.append(')'); - } else { - sb.append(">no face<"); - } - } - } // class ArchTab Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -297,4 +297,7 @@ */ void postParseArchetype(); + @Nullable + String getFaceObjName(); + } // interface Archetype Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -1570,4 +1570,7 @@ } } + @NotNull + public abstract FaceSource getFaceObjSource(); + } // interface GameObject Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -31,6 +31,7 @@ import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.map.MapArchObject; @@ -45,7 +46,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public abstract class ArchTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { +public class ArchTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { /** The action factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -342,8 +343,38 @@ directionButtons[direction < directionButtons.length ? direction : 0].setSelected(true); } - protected abstract void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final G gameObject); + protected void appendFaceSource(@NotNull final StringBuilder sb, @NotNull final G gameObject) { + final String faceName = gameObject.getFaceObjName(); + if (faceName != null) { + final FaceSource desc = gameObject.getFaceObjSource(); + sb.append(faceName).append(" ("); + switch (desc) { + case FACE_NOT_FOUND: + sb.append("face not found"); + break; + case FACE: + sb.append("face"); + break; + + case ARCHETYPE_FACE: + sb.append("archetype face"); + break; + + case ANIM: + sb.append("anim"); + break; + + case ARCHETYPE_ANIM: + sb.append("archetype anim"); + break; + } + sb.append(')'); + } else { + sb.append(">no face<"); + } + } + /** Action method for direction. */ public void direction0() { direction(0); Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-18 18:48:00 UTC (rev 5193) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-18 18:57:57 UTC (rev 5194) @@ -56,6 +56,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectFactory; +import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gameobject.anim.AbstractAnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; @@ -886,6 +887,12 @@ } /** {@inheritDoc} */ + @Nullable + public String getFaceObjName() { + throw new AssertionError(); + } + + /** {@inheritDoc} */ public TestGameObject createClone(final int posx, final int posy) { throw new AssertionError(); } @@ -926,6 +933,12 @@ throw new AssertionError(); } + /** {@inheritDoc} */ + @NotNull + public FaceSource getFaceObjSource() { + throw new AssertionError(); + } + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 12:01:06
|
Revision: 5195 http://gridarta.svn.sourceforge.net/gridarta/?rev=5195&view=rev Author: akirschbaum Date: 2008-09-18 19:01:15 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move ArchTab to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/ArchTab.java trunk/daimonin/src/daieditor/gui/ArchTab.java Deleted: trunk/crossfire/src/cfeditor/gui/ArchTab.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-09-18 18:57:57 UTC (rev 5194) +++ trunk/crossfire/src/cfeditor/gui/ArchTab.java 2008-09-18 19:01:15 UTC (rev 5195) @@ -1,42 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package cfeditor.gui; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; -import org.jetbrains.annotations.NotNull; - -public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { - - /** - * Creates a new instance. - * @param archetypeTypeSet the archetype type set - * @param gameObjectAttributesModel the model to track - * @param gameObjectTextEditor the game object text editor to modify - */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { - super(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor); - } - -} // class ArchTab Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-09-18 18:57:57 UTC (rev 5194) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-09-18 19:01:15 UTC (rev 5195) @@ -32,6 +32,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ArchTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; @@ -59,7 +60,7 @@ /* Build Panel */ public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); + addTab(new ArchTab<GameObject, MapArchObject, Archetype>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mapManager, gameObjectAttributesModel)); addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); Deleted: trunk/daimonin/src/daieditor/gui/ArchTab.java =================================================================== --- trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 18:57:57 UTC (rev 5194) +++ trunk/daimonin/src/daieditor/gui/ArchTab.java 2008-09-18 19:01:15 UTC (rev 5195) @@ -1,42 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.gui; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.map.MapArchObject; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; -import org.jetbrains.annotations.NotNull; - -public class ArchTab extends net.sf.gridarta.gui.gameobjectattributespanel.ArchTab<GameObject, MapArchObject, Archetype> { - - /** - * Creates a new instance. - * @param archetypeTypeSet the archetype type set - * @param gameObjectAttributesModel the model to track - * @param gameObjectTextEditor the game object text editor to modify - */ - public ArchTab(@NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { - super(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor); - } - -} // class ArchTab Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-09-18 18:57:57 UTC (rev 5194) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-09-18 19:01:15 UTC (rev 5195) @@ -32,6 +32,7 @@ import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; +import net.sf.gridarta.gui.gameobjectattributespanel.ArchTab; import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; @@ -59,7 +60,7 @@ /* Build Panel */ public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); + addTab(new ArchTab<GameObject, MapArchObject, Archetype>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mapManager, gameObjectAttributesModel)); addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-09-18 18:57:57 UTC (rev 5194) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-09-18 19:01:15 UTC (rev 5195) @@ -101,7 +101,7 @@ * @param gameObjectAttributesModel the model to track * @param gameObjectTextEditor the game object text editor to modify */ - protected ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { + public ArchTab(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectTextEditor gameObjectTextEditor) { super(gameObjectAttributesModel); this.archetypeTypeSet = archetypeTypeSet; this.gameObjectAttributesModel = gameObjectAttributesModel; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 12:08:39
|
Revision: 5197 http://gridarta.svn.sourceforge.net/gridarta/?rev=5197&view=rev Author: akirschbaum Date: 2008-09-18 19:08:48 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move CMainControl.processFile() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-18 19:07:09 UTC (rev 5196) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-18 19:08:48 UTC (rev 5197) @@ -39,10 +39,7 @@ import cfeditor.script.ScriptExecException; import cfeditor.script.ScriptParameters; import cfeditor.script.parameter.PluginParameterFactory; -import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; -import java.io.IOException; import java.util.List; import java.util.Map; import javax.swing.JComboBox; @@ -325,32 +322,6 @@ return super.canExit() && scriptControl.canExit(); } - public void processFile(final String filelist) throws IOException { - try { - final BufferedReader reader = new BufferedReader(new FileReader(filelist)); - try { - while (true) { - final String in = reader.readLine(); - final String out = reader.readLine(); - if (in == null || out == null) { - log.info("done."); - return; - } - makeImage(new File(in), new File(out)); - } - } catch (final IOException e) { - // XXX:cher:Getting an error and not reporting it is evil. - log.info("done."); - return; - } finally { - reader.close(); - } - } catch (final IOException e) { - log.warn("Read error: ", e); - throw e; - } - } - public void createImageFile(final List<String> infiles, final String outfile) { openFiles(infiles); createImageWanted(mapViewManager.getCurrentMapView(), new File(outfile)); // create map image Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-18 19:07:09 UTC (rev 5196) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-18 19:08:48 UTC (rev 5197) @@ -40,10 +40,7 @@ import daieditor.map.validation.checks.ExitChecker; import daieditor.map.validation.checks.SlayingChecker; import daieditor.map.validation.checks.TilePathsChecker; -import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; -import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -559,32 +556,6 @@ return 0; } - public void processFile(final String filelist) throws IOException { - try { - final BufferedReader reader = new BufferedReader(new FileReader(filelist)); - try { - while (true) { - final String in = reader.readLine(); - final String out = reader.readLine(); - if (in == null || out == null) { - log.info("done."); - return; - } - makeImage(new File(in), new File(out)); - } - } catch (final IOException e) { - // XXX:cher:Getting an error and not reporting it is evil. - log.info("done."); - return; - } finally { - reader.close(); - } - } catch (final IOException e) { - log.warn("Read error: ", e); - throw e; - } - } - /** {@inheritDoc} */ @NotNull @Override Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-18 19:07:09 UTC (rev 5196) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-18 19:08:48 UTC (rev 5197) @@ -19,8 +19,10 @@ package net.sf.gridarta; +import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Collections; @@ -775,4 +777,30 @@ } } + public void processFile(final String filelist) throws IOException { + try { + final BufferedReader reader = new BufferedReader(new FileReader(filelist)); + try { + while (true) { + final String in = reader.readLine(); + final String out = reader.readLine(); + if (in == null || out == null) { + log.info("done."); + return; + } + makeImage(new File(in), new File(out)); + } + } catch (final IOException e) { + // XXX:cher:Getting an error and not reporting it is evil. + log.info("done."); + return; + } finally { + reader.close(); + } + } catch (final IOException e) { + log.warn("Read error: ", e); + throw e; + } + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 12:40:06
|
Revision: 5199 http://gridarta.svn.sourceforge.net/gridarta/?rev=5199&view=rev Author: akirschbaum Date: 2008-09-18 19:40:17 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Fix comments. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-09-18 19:35:24 UTC (rev 5198) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-09-18 19:40:17 UTC (rev 5199) @@ -85,7 +85,7 @@ private final String collectedDirectory; /** - * The collected directory. + * The configuration directory. */ @NotNull private final String configurationDirectory; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-09-18 19:35:24 UTC (rev 5198) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-09-18 19:40:17 UTC (rev 5199) @@ -77,7 +77,7 @@ private final GlobalSettings globalSettings; /** - * The gridarta objects factory instance. + * The game object parser instance. */ @NotNull private final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 12:49:57
|
Revision: 5202 http://gridarta.svn.sourceforge.net/gridarta/?rev=5202&view=rev Author: akirschbaum Date: 2008-09-18 19:50:01 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-09-18 19:42:57 UTC (rev 5201) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-09-18 19:50:01 UTC (rev 5202) @@ -31,15 +31,7 @@ import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ArchTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; -import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; @@ -59,15 +51,7 @@ /* Build Panel */ public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab<GameObject, MapArchObject, Archetype>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mapManager, gameObjectAttributesModel)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, gameObjectAttributesModel)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); + super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, parent); } } // class GameObjectAttributesControl Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-09-18 19:42:57 UTC (rev 5201) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-09-18 19:50:01 UTC (rev 5202) @@ -31,15 +31,7 @@ import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributespanel.AnimationTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ArchTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ConnectionsTab; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.gameobjectattributespanel.LockedItemsTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MonstersTab; -import net.sf.gridarta.gui.gameobjectattributespanel.MsgTextTab; -import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; -import net.sf.gridarta.gui.gameobjectattributespanel.WarningsTab; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; @@ -59,15 +51,7 @@ /* Build Panel */ public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, mapManager, selectedSquareControl); - addTab(new ArchTab<GameObject, MapArchObject, Archetype>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); - addTab(new MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mapManager, gameObjectAttributesModel)); - addTab(new AnimationTab<GameObject, MapArchObject, Archetype>(animationObjects, gameObjectAttributesModel)); - addTab(new ConnectionsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, gameObjectAttributesModel)); - addTab(new LockedItemsTab<GameObject, MapArchObject, Archetype>(lockedItemsControl, gameObjectAttributesModel)); - addTab(new MonstersTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); - addTab(new WarningsTab<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, selectedSquareView, gameObjectAttributesModel)); + super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, parent); } } // class GameObjectAttributesControl Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-09-18 19:42:57 UTC (rev 5201) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-09-18 19:50:01 UTC (rev 5202) @@ -22,6 +22,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; +import java.awt.Frame; import java.awt.GridLayout; import java.awt.Toolkit; import java.util.HashSet; @@ -38,15 +39,21 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.MapManagerListener; +import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.GSplitPane; +import net.sf.gridarta.gui.MapViewManager; +import net.sf.gridarta.gui.connectionview.LockedItemsControl; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjecttexteditor.GameObjectTextEditor; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareListener; +import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; @@ -293,10 +300,17 @@ * @param gameObjectAttributesDialogFactory the factory for creating game * object attributes dialog instances * @param objectChooser the object chooser instance + * @param archetypeTypeSet the archetype type set instance * @param mapManager the map manager instance + * @param mapViewManager the map view manager instance + * @param animationObjects the animation objects instance + * @param lockedItemsControl the locked items control instance + * @param monsterMatcher the monster matcher instance * @param selectedSquareControl the selected square control instance + * @param selectedSquareView the selected square view instance + * @param parent the parent component for dialog windows */ - protected GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl) { + protected GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { super(new BorderLayout()); this.gameObjectAttributesModel = gameObjectAttributesModel; this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; @@ -327,6 +341,14 @@ mapManager.addMapManagerListener(mapManagerListener); addTabInt(new TextEditorTab<G, A, R>(gameObjectAttributesModel, gameObjectTextEditor)); + addTab(new ArchTab<G, A, R>(archetypeTypeSet, gameObjectAttributesModel, gameObjectTextEditor)); + addTab(new MsgTextTab<G, A, R>(gameObjectAttributesModel)); + addTab(new ScriptTab<G, A, R>(parent, mapManager, gameObjectAttributesModel)); + addTab(new AnimationTab<G, A, R>(animationObjects, gameObjectAttributesModel)); + addTab(new ConnectionsTab<G, A, R, V>(mapManager, mapViewManager, gameObjectAttributesModel)); + addTab(new LockedItemsTab<G, A, R, V>(lockedItemsControl, gameObjectAttributesModel)); + addTab(new MonstersTab<G, A, R, V>(mapManager, mapViewManager, monsterMatcher, gameObjectAttributesModel)); + addTab(new WarningsTab<G, A, R, V>(mapManager, selectedSquareView, gameObjectAttributesModel)); } /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java 2008-09-18 19:42:57 UTC (rev 5201) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/LockedItemsTab.java 2008-09-18 19:50:01 UTC (rev 5202) @@ -23,6 +23,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -32,20 +33,20 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public class LockedItemsTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { +public class LockedItemsTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends AbstractGameObjectAttributesTab<G, A, R> { /** * The locked items control to display. */ @NotNull - private final LockedItemsControl<G, A, R, ?> lockedItemsControl; + private final LockedItemsControl<G, A, R, V> lockedItemsControl; /** * Creates a new instance. * @param lockedItemsControl the locked items control to display * @param gameObjectAttributesModel the model to track */ - public LockedItemsTab(@NotNull final LockedItemsControl<G, A, R, ?> lockedItemsControl, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + public LockedItemsTab(@NotNull final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { super(gameObjectAttributesModel); this.lockedItemsControl = lockedItemsControl; refresh(gameObjectAttributesModel.getSelectedGameObject()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 12:57:49
|
Revision: 5203 http://gridarta.svn.sourceforge.net/gridarta/?rev=5203&view=rev Author: akirschbaum Date: 2008-09-18 19:57:56 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move GameObjectAttributesControl to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -28,7 +28,6 @@ import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; -import cfeditor.gui.GameObjectAttributesControl; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.map.DefaultRendererFactory; import cfeditor.gui.prefs.GUIPrefs; @@ -57,19 +56,14 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.ConfigFileUtils; import net.sf.gridarta.io.GameObjectParser; @@ -165,13 +159,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newGameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, final DefaultObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, final GameObjectMatcher monsterMatcher, final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView) { - return new GameObjectAttributesControl(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected JComboBox createEventTypeBox() { return ScriptArchUtils.createEventTypeBox(); } Deleted: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -1,57 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package cfeditor.gui; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; -import cfeditor.map.MapArchObject; -import java.awt.Frame; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.MapViewManager; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import org.jetbrains.annotations.NotNull; - -/** - * <code>GameObjectAttributesPanel</code> implements the panel that holds - * information about the currently selected GameObject on the map. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class GameObjectAttributesControl extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /* Build Panel */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, parent); - } - -} // class GameObjectAttributesControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -28,7 +28,6 @@ import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchUtils; -import daieditor.gui.GameObjectAttributesControl; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.DefaultRendererFactory; import daieditor.gui.prefs.AppPrefs; @@ -61,19 +60,14 @@ import net.sf.gridarta.gameobject.match.MutableOrGameObjectMatcher; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; import net.sf.gridarta.io.GameObjectParser; @@ -225,13 +219,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newGameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, final DefaultObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, final GameObjectMatcher monsterMatcher, final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView) { - return new GameObjectAttributesControl(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected JComboBox createEventTypeBox() { return ScriptArchUtils.createEventTypeBox(); } Deleted: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -1,57 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.gui; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import java.awt.Frame; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.gui.MapViewManager; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; -import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import org.jetbrains.annotations.NotNull; - -/** - * <code>GameObjectAttributesPanel</code> implements the panel that holds - * information about the currently selected GameObject on the map. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class GameObjectAttributesControl extends net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /* Build Panel */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser, @NotNull final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final MapViewManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final Frame parent) { - super(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, parent); - } - -} // class GameObjectAttributesControl Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -399,7 +399,7 @@ AbstractScriptArchEditor.initEventTypeBoxes(scriptExtension, scriptName, createEventTypeBox(), scriptFileFilter, globalSettings, mapManager); final LockedItemsControl<G, A, R, V> lockedItemsControl = new LockedItemsControl<G, A, R, V>(mapManager, mapViewManager, lockedItemsTypeNumbers); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); - gameObjectAttributesControl = newGameObjectAttributesControl(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R, V>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); init2(gridartaObjectsFactory, globalSettings, mapManager, archetypeSet, validators, gameObjectMatchers, gameObjectAttributesModel, objectChooser); final ObjectChoiceDisplay<G, A, R, V> objectChoiceDisplay = new ObjectChoiceDisplay<G, A, R, V>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<G, A, R, V> toolPalette = new ToolPalette<G, A, R, V>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl); @@ -459,9 +459,6 @@ protected abstract void createActions(); @NotNull - protected abstract GameObjectAttributesControl<G, A, R, V> newGameObjectAttributesControl(final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, final DefaultObjectChooser<G, A, R> objectChooser, final ArchetypeTypeSet<G, A, R> archetypeTypeSet, final MapManager<G, A, R, V> mapManager, final MapViewManager<G, A, R, V> mapViewManager, final AnimationObjects<? extends AnimationObject> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, final GameObjectMatcher monsterMatcher, final SelectedSquareControl<G, A, R, V> selectedSquareControl, final SelectedSquareView<G, A, R, V> selectedSquareView, final MainView<G, A, R, V> mainView); - - @NotNull protected abstract JComboBox createEventTypeBox(); @NotNull Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -71,7 +71,7 @@ * attributes. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class GameObjectAttributesControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { +public class GameObjectAttributesControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> extends JPanel { /** The serial version UID. */ private static final long serialVersionUID = 1; @@ -310,7 +310,7 @@ * @param selectedSquareView the selected square view instance * @param parent the parent component for dialog windows */ - protected GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { + public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final AnimationObjects<?> animationObjects, final LockedItemsControl<G, A, R, V> lockedItemsControl, @NotNull final GameObjectMatcher monsterMatcher, @NotNull final SelectedSquareControl<G, A, R, V> selectedSquareControl, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final Frame parent) { super(new BorderLayout()); this.gameObjectAttributesModel = gameObjectAttributesModel; this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-18 19:50:01 UTC (rev 5202) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-18 19:57:56 UTC (rev 5203) @@ -54,9 +54,9 @@ import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectFactory; -import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gameobject.anim.AbstractAnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObject; import net.sf.gridarta.gameobject.anim.AnimationObjects; @@ -68,12 +68,8 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import net.sf.gridarta.gui.map.LevelRenderer; @@ -82,9 +78,7 @@ import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.objectchooser.DefaultObjectChooser; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.AbstractGameObjectParser; import net.sf.gridarta.io.GameObjectParser; @@ -491,13 +485,6 @@ /** {@inheritDoc} */ @NotNull @Override - protected GameObjectAttributesControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newGameObjectAttributesControl(final GameObjectAttributesModel<TestGameObject, TestMapArchObject, TestArchetype> gameObjectAttributesModel, final GameObjectAttributesDialogFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gameObjectAttributesDialogFactory, final DefaultObjectChooser<TestGameObject, TestMapArchObject, TestArchetype> objectChooser, final ArchetypeTypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeTypeSet, final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager, final MapViewManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapViewManager, final AnimationObjects<? extends AnimationObject> animationObjects, final LockedItemsControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> lockedItemsControl, final GameObjectMatcher monsterMatcher, final SelectedSquareControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareControl, final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override protected JComboBox createEventTypeBox() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-18 13:35:57
|
Revision: 5205 http://gridarta.svn.sourceforge.net/gridarta/?rev=5205&view=rev Author: akirschbaum Date: 2008-09-18 20:36:04 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Move GUIPrefs to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/action.properties trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/action.properties trunk/src/app/net/sf/gridarta/action.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/prefs/GUIPrefs.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-18 20:36:04 UTC (rev 5205) @@ -30,7 +30,6 @@ import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.map.DefaultRendererFactory; -import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; import cfeditor.map.DefaultMapControlFactory; import cfeditor.map.MapArchObject; @@ -61,6 +60,7 @@ import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.prefs.DevPrefs; +import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/crossfire/src/cfeditor/action.properties 2008-09-18 20:36:04 UTC (rev 5205) @@ -21,8 +21,6 @@ # See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#encoding ActionFactory.additionalBundles=cfeditor.messages -# Extend this if you add a new locale. The order is irrelevant. -availableLocales=en de fr sv ######## # Menus @@ -134,5 +132,4 @@ prefsRes.icon=general/Save24 -prefsGUI.icon=development/Host24 prefsMapValidator.icon=general/Search24 Deleted: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2008-09-18 20:36:04 UTC (rev 5205) @@ -1,190 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package cfeditor.gui.prefs; - -import java.awt.Component; -import java.util.Arrays; -import java.util.Locale; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.MainView; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.LocaleListCellRenderer; -import net.sf.japi.swing.prefs.AbstractPrefs; -import net.sf.japi.util.LocaleComparator; - -/** - * Preferences Module for user interface preferences. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @serial exclude - */ -public final class GUIPrefs extends AbstractPrefs { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - /** ComboBox for choosing the locale. */ - private JComboBox localeBox; - - /** Whether to place the map tile panel at the bottom or the right. */ - private JCheckBox mapPanelBottom; - - /** Whether to show the main window's toolbar. */ - private JCheckBox showMainToolbar; - - /** Locale[]. */ - private Locale[] locales; - - /** LocaleComparator. */ - private final LocaleComparator comp = new LocaleComparator(); - - /** Create a GUIPrefs pane. */ - public GUIPrefs() { - setListLabelText(ACTION_FACTORY.getString("prefsGUI.title")); - setListLabelIcon(ACTION_FACTORY.getIcon("prefsGUI.icon")); - - add(createGlobalPanel()); - add(createLayoutPanel()); - add(Box.createVerticalGlue()); - } - - /** - * Create a titled border. - * @param titleKey Action Key for border title - * @return titled border - */ - private static Border createTitledBorder(final String titleKey) { - return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); - } - - /** {@inheritDoc} */ - public void apply() { - final Locale loc = (Locale) localeBox.getSelectedItem(); - if (loc != null) { - prefs.put(MainControl.PREFS_LANGUAGE, loc.getLanguage()); - } else { - prefs.remove(MainControl.PREFS_LANGUAGE); - } - prefs.putBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); - prefs.putBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, showMainToolbar.isSelected()); - } - - /** {@inheritDoc} */ - public void revert() { - final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); - localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); - mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); - showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); - } - - /** {@inheritDoc} */ - public void defaults() { - localeBox.setSelectedIndex(Arrays.binarySearch(locales, null, comp)); - mapPanelBottom.setSelected(MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - showMainToolbar.setSelected(MainView.SHOW_MAIN_TOOLBAR_DEFAULT); - } - - /** {@inheritDoc} */ - public boolean isChanged() { - final Locale loc = (Locale) localeBox.getSelectedItem(); - final String currentName = prefs.get(MainControl.PREFS_LANGUAGE, null); - final Locale current = currentName != null ? new Locale(currentName) : null; - return !( - (loc == null ? current == null : loc.equals(current)) - && mapPanelBottom.isSelected() == prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT) - && showMainToolbar.isSelected() == prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT) - ); - } - - /** - * Construct the Combo box for the selection of locales. - * @return combo box with locales to select - */ - private Component buildLocaleBox() { - final Box lineLayout = Box.createHorizontalBox(); - - final String availableLocales = ACTION_FACTORY.getString("availableLocales"); - final String[] locNames = availableLocales != null ? availableLocales.split("\\s+") : new String[0]; - locales = new Locale[locNames.length + 1]; - // locales[0] is intentionally null. It will be displayed as default and always get sorted to the top. - for (int i = 0; i < locNames.length; i++) { - locales[i + 1] = new Locale(locNames[i]); - } - Arrays.sort(locales, comp); - - lineLayout.add(new JLabel(ACTION_FACTORY.getString("optionsLanguage"))); // create label - - localeBox = new JComboBox(locales); // set "content" - localeBox.setRenderer(new LocaleListCellRenderer()); - //localeBox.setPreferredSize(new Dimension(150, 25)); - final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); - localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); - - lineLayout.add(localeBox); - return lineLayout; - } - - /** - * Creates the subpanel with the global settings. - * @return subpanel - */ - private Component createGlobalPanel() { - final Box globalPanel = Box.createVerticalBox(); - globalPanel.setBorder(createTitledBorder("optionsGlobal")); - - globalPanel.add(buildLocaleBox()); - - return globalPanel; - } - - /** - * Creates the subpanel with the layout settings. - * @return subpanel - */ - private Component createLayoutPanel() { - final Box layoutPanel = Box.createVerticalBox(); - layoutPanel.setBorder(createTitledBorder("optionsLayout")); - - mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); - mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); - layoutPanel.add(mapPanelBottom); - - showMainToolbar = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsShowMainToolbar")); - showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); - layoutPanel.add(showMainToolbar); - - return layoutPanel; - } - -} // class GUIPrefs Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-18 20:36:04 UTC (rev 5205) @@ -31,7 +31,6 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.DefaultRendererFactory; import daieditor.gui.prefs.AppPrefs; -import daieditor.gui.prefs.GUIPrefs; import daieditor.gui.prefs.NetPrefs; import daieditor.gui.prefs.ResPrefs; import daieditor.map.DefaultMapControlFactory; @@ -65,6 +64,7 @@ import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.prefs.DevPrefs; +import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/daimonin/src/daieditor/action.properties 2008-09-18 20:36:04 UTC (rev 5205) @@ -21,8 +21,6 @@ # See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#encoding ActionFactory.additionalBundles=daieditor.messages -# Extend this if you add a new locale. The order is irrelevant. -availableLocales=en de fr sv ######## # Menus Deleted: trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2008-09-18 20:36:04 UTC (rev 5205) @@ -1,190 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.gui.prefs; - -import java.awt.Component; -import java.util.Arrays; -import java.util.Locale; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.MainView; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.LocaleListCellRenderer; -import net.sf.japi.swing.prefs.AbstractPrefs; -import net.sf.japi.util.LocaleComparator; - -/** - * Preferences Module for user interface preferences. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @serial exclude - */ -public final class GUIPrefs extends AbstractPrefs { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Preferences. */ - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); - - /** ComboBox for choosing the locale. */ - private JComboBox localeBox; - - /** Whether to place the map tile panel at the bottom or the right. */ - private JCheckBox mapPanelBottom; - - /** Whether to show the main window's toolbar. */ - private JCheckBox showMainToolbar; - - /** Locale[]. */ - private Locale[] locales; - - /** LocaleComparator. */ - private final LocaleComparator comp = new LocaleComparator(); - - /** Create a GUIPrefs pane. */ - public GUIPrefs() { - setListLabelText(ACTION_FACTORY.getString("prefsGUI.title")); - setListLabelIcon(ACTION_FACTORY.getIcon("prefsGUI.icon")); - - add(createGlobalPanel()); - add(createLayoutPanel()); - add(Box.createVerticalGlue()); - } - - /** - * Create a titled border. - * @param titleKey Action Key for border title - * @return titled border - */ - private static Border createTitledBorder(final String titleKey) { - return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); - } - - /** {@inheritDoc} */ - public void apply() { - final Locale loc = (Locale) localeBox.getSelectedItem(); - if (loc != null) { - prefs.put(MainControl.PREFS_LANGUAGE, loc.getLanguage()); - } else { - prefs.remove(MainControl.PREFS_LANGUAGE); - } - prefs.putBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); - prefs.putBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, showMainToolbar.isSelected()); - } - - /** {@inheritDoc} */ - public void revert() { - final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); - localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); - mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); - showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); - } - - /** {@inheritDoc} */ - public void defaults() { - localeBox.setSelectedIndex(Arrays.binarySearch(locales, null, comp)); - mapPanelBottom.setSelected(MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); - showMainToolbar.setSelected(MainView.SHOW_MAIN_TOOLBAR_DEFAULT); - } - - /** {@inheritDoc} */ - public boolean isChanged() { - final Locale loc = (Locale) localeBox.getSelectedItem(); - final String currentName = prefs.get(MainControl.PREFS_LANGUAGE, null); - final Locale current = currentName != null ? new Locale(currentName) : null; - return !( - (loc == null ? current == null : loc.equals(current)) - && mapPanelBottom.isSelected() == prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT) - && showMainToolbar.isSelected() == prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT) - ); - } - - /** - * Construct the Combo box for the selection of locales. - * @return combo box with locales to select - */ - private Component buildLocaleBox() { - final Box lineLayout = Box.createHorizontalBox(); - - final String availableLocales = ACTION_FACTORY.getString("availableLocales"); - final String[] locNames = availableLocales != null ? availableLocales.split("\\s+") : new String[0]; - locales = new Locale[locNames.length + 1]; - // locales[0] is intentionally null. It will be displayed as default and always get sorted to the top. - for (int i = 0; i < locNames.length; i++) { - locales[i + 1] = new Locale(locNames[i]); - } - Arrays.sort(locales, comp); - - lineLayout.add(new JLabel(ACTION_FACTORY.getString("optionsLanguage"))); // create label - - localeBox = new JComboBox(locales); // set "content" - localeBox.setRenderer(new LocaleListCellRenderer()); - //localeBox.setPreferredSize(new Dimension(150, 25)); - final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); - localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); - - lineLayout.add(localeBox); - return lineLayout; - } - - /** - * Creates the subpanel with the global settings. - * @return subpanel - */ - private Component createGlobalPanel() { - final Box globalPanel = Box.createVerticalBox(); - globalPanel.setBorder(createTitledBorder("optionsGlobal")); - - globalPanel.add(buildLocaleBox()); - - return globalPanel; - } - - /** - * Creates the subpanel with the layout settings. - * @return subpanel - */ - private Component createLayoutPanel() { - final Box layoutPanel = Box.createVerticalBox(); - layoutPanel.setBorder(createTitledBorder("optionsLayout")); - - mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); - mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); - layoutPanel.add(mapPanelBottom); - - showMainToolbar = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsShowMainToolbar")); - showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); - layoutPanel.add(showMainToolbar); - - return layoutPanel; - } - -} // class GUIPrefs Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-09-18 19:59:40 UTC (rev 5204) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-09-18 20:36:04 UTC (rev 5205) @@ -22,7 +22,10 @@ ActionFactory.additionalBundles=net.sf.gridarta.messages +# Extend this if you add a new locale. The order is irrelevant. +availableLocales=en de fr sv + #this is empty but yet must be here. recent.menu= @@ -79,6 +82,7 @@ prefsMapValidator.icon=general/Search24 prefsDev.icon=development/Server24 prefsUpdate.icon=general/Search24 +prefsGUI.icon=development/Host24 mapTileRevert.icon=general/Undo16 mapTileClear.icon=general/Remove16 Copied: trunk/src/app/net/sf/gridarta/gui/prefs/GUIPrefs.java (from rev 5195, trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/GUIPrefs.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/prefs/GUIPrefs.java 2008-09-18 20:36:04 UTC (rev 5205) @@ -0,0 +1,190 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.prefs; + +import java.awt.Component; +import java.util.Arrays; +import java.util.Locale; +import java.util.prefs.Preferences; +import javax.swing.Box; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.TitledBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.gui.MainView; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.misc.LocaleListCellRenderer; +import net.sf.japi.swing.prefs.AbstractPrefs; +import net.sf.japi.util.LocaleComparator; + +/** + * Preferences Module for user interface preferences. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @serial exclude + */ +public final class GUIPrefs extends AbstractPrefs { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** Preferences. */ + private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + + /** ComboBox for choosing the locale. */ + private JComboBox localeBox; + + /** Whether to place the map tile panel at the bottom or the right. */ + private JCheckBox mapPanelBottom; + + /** Whether to show the main window's toolbar. */ + private JCheckBox showMainToolbar; + + /** Locale[]. */ + private Locale[] locales; + + /** LocaleComparator. */ + private final LocaleComparator comp = new LocaleComparator(); + + /** Create a GUIPrefs pane. */ + public GUIPrefs() { + setListLabelText(ACTION_FACTORY.getString("prefsGUI.title")); + setListLabelIcon(ACTION_FACTORY.getIcon("prefsGUI.icon")); + + add(createGlobalPanel()); + add(createLayoutPanel()); + add(Box.createVerticalGlue()); + } + + /** + * Create a titled border. + * @param titleKey Action Key for border title + * @return titled border + */ + private static Border createTitledBorder(final String titleKey) { + return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); + } + + /** {@inheritDoc} */ + public void apply() { + final Locale loc = (Locale) localeBox.getSelectedItem(); + if (loc != null) { + prefs.put(MainControl.PREFS_LANGUAGE, loc.getLanguage()); + } else { + prefs.remove(MainControl.PREFS_LANGUAGE); + } + prefs.putBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, mapPanelBottom.isSelected()); + prefs.putBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, showMainToolbar.isSelected()); + } + + /** {@inheritDoc} */ + public void revert() { + final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); + localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); + mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); + showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); + } + + /** {@inheritDoc} */ + public void defaults() { + localeBox.setSelectedIndex(Arrays.binarySearch(locales, null, comp)); + mapPanelBottom.setSelected(MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); + showMainToolbar.setSelected(MainView.SHOW_MAIN_TOOLBAR_DEFAULT); + } + + /** {@inheritDoc} */ + public boolean isChanged() { + final Locale loc = (Locale) localeBox.getSelectedItem(); + final String currentName = prefs.get(MainControl.PREFS_LANGUAGE, null); + final Locale current = currentName != null ? new Locale(currentName) : null; + return !( + (loc == null ? current == null : loc.equals(current)) + && mapPanelBottom.isSelected() == prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT) + && showMainToolbar.isSelected() == prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT) + ); + } + + /** + * Construct the Combo box for the selection of locales. + * @return combo box with locales to select + */ + private Component buildLocaleBox() { + final Box lineLayout = Box.createHorizontalBox(); + + final String availableLocales = ACTION_FACTORY.getString("availableLocales"); + final String[] locNames = availableLocales != null ? availableLocales.split("\\s+") : new String[0]; + locales = new Locale[locNames.length + 1]; + // locales[0] is intentionally null. It will be displayed as default and always get sorted to the top. + for (int i = 0; i < locNames.length; i++) { + locales[i + 1] = new Locale(locNames[i]); + } + Arrays.sort(locales, comp); + + lineLayout.add(new JLabel(ACTION_FACTORY.getString("optionsLanguage"))); // create label + + localeBox = new JComboBox(locales); // set "content" + localeBox.setRenderer(new LocaleListCellRenderer()); + //localeBox.setPreferredSize(new Dimension(150, 25)); + final String current = prefs.get(MainControl.PREFS_LANGUAGE, null); + localeBox.setSelectedIndex(Arrays.binarySearch(locales, current != null ? new Locale(current) : null, comp)); + + lineLayout.add(localeBox); + return lineLayout; + } + + /** + * Creates the subpanel with the global settings. + * @return subpanel + */ + private Component createGlobalPanel() { + final Box globalPanel = Box.createVerticalBox(); + globalPanel.setBorder(createTitledBorder("optionsGlobal")); + + globalPanel.add(buildLocaleBox()); + + return globalPanel; + } + + /** + * Creates the subpanel with the layout settings. + * @return subpanel + */ + private Component createLayoutPanel() { + final Box layoutPanel = Box.createVerticalBox(); + layoutPanel.setBorder(createTitledBorder("optionsLayout")); + + mapPanelBottom = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsSepMapTile")); + mapPanelBottom.setSelected(prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT)); + layoutPanel.add(mapPanelBottom); + + showMainToolbar = new JCheckBox(ACTION_FACTORY.createAction(false, "optionsShowMainToolbar")); + showMainToolbar.setSelected(prefs.getBoolean(MainView.SHOW_MAIN_TOOLBAR_KEY, MainView.SHOW_MAIN_TOOLBAR_DEFAULT)); + layoutPanel.add(showMainToolbar); + + return layoutPanel; + } + +} // class GUIPrefs Property changes on: trunk/src/app/net/sf/gridarta/gui/prefs/GUIPrefs.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-24 18:45:44
|
Revision: 5213 http://gridarta.svn.sourceforge.net/gridarta/?rev=5213&view=rev Author: akirschbaum Date: 2008-09-24 18:45:31 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Retain view positions when reverting maps. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-24 18:12:05 UTC (rev 5212) +++ trunk/crossfire/ChangeLog 2008-09-24 18:45:31 UTC (rev 5213) @@ -1,3 +1,7 @@ +2008-09-24 Andreas Kirschbaum + + * Retain view positions when reverting maps. + 2008-09-18 Andreas Kirschbaum * Fix display of "Image:" information in game object attributes Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-09-24 18:12:05 UTC (rev 5212) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-09-24 18:45:31 UTC (rev 5213) @@ -126,11 +126,14 @@ * @param selectedSquareView the selected square view */ public CMapViewBasic(@NotNull final CFilterControl filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { - super(mapControl, initial, xScrollDistance, yScrollDistance, selectedSquareView); + super(mapControl, xScrollDistance, yScrollDistance, selectedSquareView); getMapCursor().addMapCursorListener(mapCursorListener); renderer = mapControl.isPickmap() ? new PickmapRenderer(mapControl, getMapGrid()) : new MapRenderer(filterControl, editTypes, mapControl, getMapGrid()); setViewportView(renderer); + if (initial != null) { + getViewport().setViewPosition(initial); + } mapModel.addMapModelListener(mapModelListener); Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-09-24 18:12:05 UTC (rev 5212) +++ trunk/daimonin/ChangeLog 2008-09-24 18:45:31 UTC (rev 5213) @@ -1,3 +1,7 @@ +2008-09-24 Andreas Kirschbaum + + * Retain view positions when reverting maps. + 2008-09-19 Andreas Kirschbaum * Fix animation chooser to display the first defined face for each Modified: trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java 2008-09-24 18:12:05 UTC (rev 5212) +++ trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java 2008-09-24 18:45:31 UTC (rev 5213) @@ -130,11 +130,14 @@ * @param selectedSquareView the selected square view */ public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { - super(mapControl, initial, xScrollDistance, yScrollDistance, selectedSquareView); + super(mapControl, xScrollDistance, yScrollDistance, selectedSquareView); getMapCursor().addMapCursorListener(mapCursorListener); renderer = mapControl.isPickmap() ? new PickmapRenderer(mainControl, mapControl, getMapGrid(), faceObjects) : new MapRenderer(mainControl, editTypes, mapControl, getMapGrid(), faceObjects); setViewportView(renderer); + if (initial != null) { + getViewport().setViewPosition(initial); + } mapModel.addMapModelListener(mapModelListener); Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-09-24 18:12:05 UTC (rev 5212) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2008-09-24 18:45:31 UTC (rev 5213) @@ -84,13 +84,11 @@ /** * Creates a MapViewBasic. * @param mapControl MapControl to use. - * @param initial the initial view position to show; null=show top left - * corner * @param xScrollDistance the x distance when scrolling * @param yScrollDistance the y distance when scrolling * @param selectedSquareView the selected square view */ - protected MapViewBasic(@NotNull final MapControl<G, A, R, V> mapControl, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView) { + protected MapViewBasic(@NotNull final MapControl<G, A, R, V> mapControl, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView) { super(VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); this.selectedSquareView = selectedSquareView; mapModel = mapControl.getMapModel(); @@ -107,10 +105,6 @@ getVerticalScrollBar().setUnitIncrement(yScrollDistance); getHorizontalScrollBar().setUnitIncrement(xScrollDistance); - if (initial != null) { - getViewport().setViewPosition(initial); - } - getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-24 18:12:05 UTC (rev 5212) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-24 18:45:31 UTC (rev 5213) @@ -814,13 +814,12 @@ /** * Creates a new instance. * @param mapControl the map control - * @param initial the initial view position * @param xScrollDistance the x scroll distance * @param yScrollDistance the y scroll distance * @param selectedSquareView the selected square view to use */ - protected TestMapViewBasic(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView) { - super(mapControl, initial, xScrollDistance, yScrollDistance, selectedSquareView); + protected TestMapViewBasic(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView) { + super(mapControl, xScrollDistance, yScrollDistance, selectedSquareView); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-24 18:53:26
|
Revision: 5214 http://gridarta.svn.sourceforge.net/gridarta/?rev=5214&view=rev Author: akirschbaum Date: 2008-09-24 18:53:18 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/MapActions.java Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-09-24 18:45:31 UTC (rev 5213) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-09-24 18:53:18 UTC (rev 5214) @@ -385,7 +385,7 @@ if (destinationPoint.x == 0 && destinationPoint.y == 0) { ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { - currentMapView.getMapViewBasic().setCursorPosition(destinationPoint); + showLocation(currentMapView, destinationPoint); } else { ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } @@ -422,7 +422,7 @@ destinationPoint.x = newMapView.getMapControl().getMapModel().getMapArchObject().getEnterX(); destinationPoint.y = newMapView.getMapControl().getMapModel().getMapArchObject().getEnterY(); } - newMapView.getMapViewBasic().setCursorPosition(destinationPoint); + showLocation(newMapView, destinationPoint); } else { newMapView.getMapViewBasic().setViewPosition(calculateNewViewPosition(currentMapView.getMapViewBasic(), newMapView.getMapViewBasic(), direction)); } @@ -434,6 +434,15 @@ } /** + * Scrolls a map view to make a give tile visible. + * @param mapView the map view + * @param point the tile + */ + private void showLocation(final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView, final Point point) { + mapView.getMapViewBasic().setCursorPosition(point); + } + + /** * Determine whether "grid visible" is enabled. * @return the current map view, or <code>null</code> if "grid visible" is * disabled Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-09-24 18:45:31 UTC (rev 5213) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-09-24 18:53:18 UTC (rev 5214) @@ -377,7 +377,7 @@ if (destinationPoint.x == 0 && destinationPoint.y == 0) { ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { - currentMapView.getMapViewBasic().setCursorPosition(destinationPoint); + showLocation(currentMapView, destinationPoint); } else { ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } @@ -414,7 +414,7 @@ destinationPoint.x = newMapView.getMapControl().getMapModel().getMapArchObject().getEnterX(); destinationPoint.y = newMapView.getMapControl().getMapModel().getMapArchObject().getEnterY(); } - newMapView.getMapViewBasic().setCursorPosition(destinationPoint); + showLocation(newMapView, destinationPoint); } else { newMapView.getMapViewBasic().setViewPosition(calculateNewViewPosition(currentMapView.getMapViewBasic(), newMapView.getMapViewBasic(), direction)); } @@ -426,6 +426,15 @@ } /** + * Scrolls a map view to make a give tile visible. + * @param mapView the map view + * @param point the tile + */ + private void showLocation(final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView, final Point point) { + mapView.getMapViewBasic().setCursorPosition(point); + } + + /** * Determine whether "grid visible" is enabled. * @return the current map view, or <code>null</code> if "grid visible" is * disabled This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-24 18:59:28
|
Revision: 5215 http://gridarta.svn.sourceforge.net/gridarta/?rev=5215&view=rev Author: akirschbaum Date: 2008-09-24 18:59:09 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Unify error checks. Modified Paths: -------------- trunk/crossfire/src/cfeditor/MapActions.java trunk/daimonin/src/daieditor/MapActions.java Modified: trunk/crossfire/src/cfeditor/MapActions.java =================================================================== --- trunk/crossfire/src/cfeditor/MapActions.java 2008-09-24 18:53:18 UTC (rev 5214) +++ trunk/crossfire/src/cfeditor/MapActions.java 2008-09-24 18:59:09 UTC (rev 5215) @@ -384,10 +384,8 @@ if (destinationPoint != null) { if (destinationPoint.x == 0 && destinationPoint.y == 0) { ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); - } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { + } else { showLocation(currentMapView, destinationPoint); - } else { - ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } } return; @@ -439,6 +437,11 @@ * @param point the tile */ private void showLocation(final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView, final Point point) { + if (!mapView.getMapControl().getMapModel().isPointValid(point)) { + ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); + return; + } + mapView.getMapViewBasic().setCursorPosition(point); } Modified: trunk/daimonin/src/daieditor/MapActions.java =================================================================== --- trunk/daimonin/src/daieditor/MapActions.java 2008-09-24 18:53:18 UTC (rev 5214) +++ trunk/daimonin/src/daieditor/MapActions.java 2008-09-24 18:59:09 UTC (rev 5215) @@ -376,10 +376,8 @@ if (destinationPoint != null) { if (destinationPoint.x == 0 && destinationPoint.y == 0) { ACTION_FACTORY.showMessageDialog(parent, "enterExitNowhere"); - } else if (currentMap.getMapModel().isPointValid(destinationPoint)) { + } else { showLocation(currentMapView, destinationPoint); - } else { - ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); } } return; @@ -431,6 +429,11 @@ * @param point the tile */ private void showLocation(final MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> mapView, final Point point) { + if (!mapView.getMapControl().getMapModel().isPointValid(point)) { + ACTION_FACTORY.showMessageDialog(parent, "enterExitOutside"); + return; + } + mapView.getMapViewBasic().setCursorPosition(point); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-25 06:10:19
|
Revision: 5216 http://gridarta.svn.sourceforge.net/gridarta/?rev=5216&view=rev Author: akirschbaum Date: 2008-09-25 06:10:11 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Use correct filename in updater. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-24 18:59:09 UTC (rev 5215) +++ trunk/crossfire/ChangeLog 2008-09-25 06:10:11 UTC (rev 5216) @@ -1,3 +1,7 @@ +2008-09-25 Andreas Kirschbaum + + * Use correct filename in updater. + 2008-09-24 Andreas Kirschbaum * Retain view positions when reverting maps. Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-24 18:59:09 UTC (rev 5215) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-25 06:10:11 UTC (rev 5216) @@ -111,7 +111,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory, new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "DaimoninEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT); + super(gridartaObjectsFactory, new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), false, ConfigFileUtils.getHomeFile("thumbnails"), null, "CrossfireEditor.jar", pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, Archetype.TYPE_EVENT_CONNECTOR, false, 0, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT); } /** {@inheritDoc} */ Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-09-24 18:59:09 UTC (rev 5215) +++ trunk/daimonin/ChangeLog 2008-09-25 06:10:11 UTC (rev 5216) @@ -1,3 +1,7 @@ +2008-09-25 Andreas Kirschbaum + + * Use correct filename in updater. + 2008-09-24 Andreas Kirschbaum * Retain view positions when reverting maps. Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-24 18:59:09 UTC (rev 5215) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-25 06:10:11 UTC (rev 5216) @@ -173,7 +173,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory, new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "CrossfireEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT); + super(gridartaObjectsFactory, new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), true, null, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, 0, true, -1, new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFS_VALIDATOR_AUTO_DEFAULT); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-25 17:35:18
|
Revision: 5218 http://gridarta.svn.sourceforge.net/gridarta/?rev=5218&view=rev Author: akirschbaum Date: 2008-09-25 17:35:10 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Make the tool selector more compact. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-25 06:32:41 UTC (rev 5217) +++ trunk/crossfire/ChangeLog 2008-09-25 17:35:10 UTC (rev 5218) @@ -1,5 +1,7 @@ 2008-09-25 Andreas Kirschbaum + * Make the tool selector more compact. + * Use correct filename in updater. 2008-09-24 Andreas Kirschbaum Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-09-25 06:32:41 UTC (rev 5217) +++ trunk/daimonin/ChangeLog 2008-09-25 17:35:10 UTC (rev 5218) @@ -1,5 +1,7 @@ 2008-09-25 Andreas Kirschbaum + * Make the tool selector more compact. + * Use correct filename in updater. 2008-09-24 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-09-25 06:32:41 UTC (rev 5217) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-09-25 17:35:10 UTC (rev 5218) @@ -360,10 +360,6 @@ gbcCheckBox.fill = GridBagConstraints.HORIZONTAL; gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER; - final GridBagConstraints gbcFiller = new GridBagConstraints(); - gbcFiller.fill = GridBagConstraints.BOTH; - gbcFiller.weighty = 1.0; - panel.add(SwingUtils.createLabel("deletionTool.delete", deleteComboBox), gbcLabel); panel.add(deleteComboBox, gbcComboBox); @@ -373,7 +369,6 @@ panel.add(ignoreWallsAction.createCheckBox(), gbcCheckBox); panel.add(ignoreFloorsAction.createCheckBox(), gbcCheckBox); panel.add(ignoreMonstersAction.createCheckBox(), gbcCheckBox); - panel.add(new JPanel(), gbcFiller); return panel; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-09-25 06:32:41 UTC (rev 5217) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2008-09-25 17:35:10 UTC (rev 5218) @@ -208,13 +208,8 @@ gbcCheckBox.fill = GridBagConstraints.HORIZONTAL; gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER; - final GridBagConstraints gbcFiller = new GridBagConstraints(); - gbcFiller.fill = GridBagConstraints.BOTH; - gbcFiller.weighty = 1.0; - panel.add(SwingUtils.createLabel("insertionTool.mode", modeComboBox), gbcLabel); panel.add(modeComboBox, gbcComboBox); - panel.add(new JPanel(), gbcFiller); return panel; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-09-25 06:32:41 UTC (rev 5217) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2008-09-25 17:35:10 UTC (rev 5218) @@ -199,15 +199,9 @@ gbcCheckBox.fill = GridBagConstraints.HORIZONTAL; gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER; - final GridBagConstraints gbcFiller = new GridBagConstraints(); - gbcFiller.fill = GridBagConstraints.BOTH; - gbcFiller.weighty = 1.0; - panel.add(autoFillAction.createCheckBox(), gbcCheckBox); panel.add(SwingUtils.createLabel("selectionTool.mode", modeComboBox), gbcLabel); panel.add(modeComboBox, gbcComboBox); - - panel.add(new JPanel(), gbcFiller); return panel; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-09-25 06:32:41 UTC (rev 5217) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-09-25 17:35:10 UTC (rev 5218) @@ -128,7 +128,9 @@ @NotNull final Component optionsView = createOptionsView(tool); selectionButtonGroup.add(toggleButton); selectionPane.add(toggleButton); - optionsPane.add(optionsView, tool.getId()); + final JPanel panel = new JPanel(new BorderLayout()); + panel.add(optionsView, BorderLayout.NORTH); + optionsPane.add(panel, tool.getId()); toggleButton.setSelected(selected); tools.put(tool.getId(), tool); if (selected) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-25 17:37:03
|
Revision: 5219 http://gridarta.svn.sourceforge.net/gridarta/?rev=5219&view=rev Author: akirschbaum Date: 2008-09-25 17:36:58 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Add undo/redo buttons to toolbar. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/action.properties trunk/daimonin/ChangeLog trunk/daimonin/src/daieditor/action.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-25 17:35:10 UTC (rev 5218) +++ trunk/crossfire/ChangeLog 2008-09-25 17:36:58 UTC (rev 5219) @@ -1,5 +1,7 @@ 2008-09-25 Andreas Kirschbaum + * Add undo/redo buttons to toolbar. + * Make the tool selector more compact. * Use correct filename in updater. Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2008-09-25 17:35:10 UTC (rev 5218) +++ trunk/crossfire/src/cfeditor/action.properties 2008-09-25 17:36:58 UTC (rev 5219) @@ -47,7 +47,7 @@ ########## # ToolBars -main.toolbar=createNew open save saveAs - prevWindow nextWindow +main.toolbar=createNew open save saveAs - prevWindow nextWindow - undo redo mapTileRevert.icon=general/Undo16 mapTileClear.icon=general/Remove16 Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-09-25 17:35:10 UTC (rev 5218) +++ trunk/daimonin/ChangeLog 2008-09-25 17:36:58 UTC (rev 5219) @@ -1,5 +1,7 @@ 2008-09-25 Andreas Kirschbaum + * Add undo/redo buttons to toolbar. + * Make the tool selector more compact. * Use correct filename in updater. Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-09-25 17:35:10 UTC (rev 5218) +++ trunk/daimonin/src/daieditor/action.properties 2008-09-25 17:36:58 UTC (rev 5219) @@ -50,7 +50,7 @@ ########## # ToolBars -main.toolbar=createNew open save saveAs - prevWindow nextWindow +main.toolbar=createNew open save saveAs - prevWindow nextWindow - undo redo oldLibs.okayLibs=.svn CVS README LICENSE-* *-LICENSE japi.jar jlfgr-1_0.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-25 21:06:41
|
Revision: 5232 http://gridarta.svn.sourceforge.net/gridarta/?rev=5232&view=rev Author: akirschbaum Date: 2008-09-25 21:06:34 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Move CFilterControl to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java trunk/crossfire/src/cfeditor/script/ScriptController.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/filter/CFilterControl.java trunk/src/app/net/sf/gridarta/filter/FilterState.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/filter/ Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-25 20:50:23 UTC (rev 5231) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -19,7 +19,6 @@ package cfeditor; -import cfeditor.filter.CFilterControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.ArchetypeParser; import cfeditor.gameobject.ArchetypeSet; @@ -49,6 +48,7 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.filter.CFilterControl; import net.sf.gridarta.filter.NamedFilterList; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.GameObjectFactory; @@ -101,7 +101,7 @@ /** The current script controller. */ private ScriptController scriptControl; - private CFilterControl filterControl; + private CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; /** Preferences default for auto validation. */ private static final boolean PREFS_VALIDATOR_AUTO_DEFAULT = true; @@ -182,7 +182,7 @@ protected void init2(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); - filterControl = new CFilterControl(mapManager, defaultNamedFilterList); + filterControl = new CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, defaultNamedFilterList); ((CrossfireObjectsFactory) gridartaObjectsFactory).setFilterControl(filterControl); final ScriptParameters scriptParameters = new ScriptParameters(archetypeSet, globalSettings, mapManager, validators); scriptControl = new ScriptController(filterControl, scriptParameters, getMainView()); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-09-25 20:50:23 UTC (rev 5231) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -19,7 +19,6 @@ package cfeditor; -import cfeditor.filter.CFilterControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.CrossfireGameObjectFactory; import cfeditor.gameobject.GameObject; @@ -37,6 +36,7 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; +import net.sf.gridarta.filter.CFilterControl; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; @@ -83,7 +83,7 @@ private ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet = null; @NotNull - private CFilterControl filterControl; + private CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; /** The tool palette instance. */ @NotNull @@ -132,7 +132,7 @@ this.toolPalette = toolPalette; } - public void setFilterControl(@NotNull final CFilterControl filterControl) { + public void setFilterControl(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { this.filterControl = filterControl; } Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-09-25 20:50:23 UTC (rev 5231) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -19,13 +19,13 @@ package cfeditor.gui.map; -import cfeditor.filter.CFilterControl; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import java.awt.Point; import java.awt.Rectangle; import net.sf.gridarta.EditTypes; +import net.sf.gridarta.filter.CFilterControl; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -125,7 +125,7 @@ * @param yScrollDistance the y distance when scrolling * @param selectedSquareView the selected square view */ - public CMapViewBasic(@NotNull final CFilterControl filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public CMapViewBasic(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { super(mapControl, xScrollDistance, yScrollDistance, selectedSquareView); getMapCursor().addMapCursorListener(mapCursorListener); Modified: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-09-25 20:50:23 UTC (rev 5231) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -19,8 +19,6 @@ package cfeditor.gui.map; -import cfeditor.filter.CFilterControl; -import cfeditor.filter.FilterState; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; @@ -33,6 +31,8 @@ import java.lang.ref.SoftReference; import javax.swing.ImageIcon; import net.sf.gridarta.EditTypes; +import net.sf.gridarta.filter.CFilterControl; +import net.sf.gridarta.filter.FilterState; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.map.MapControl; @@ -53,7 +53,7 @@ private static final long serialVersionUID = 1L; @NotNull - private final CFilterControl filterControl; + private final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; private final Color[] highLightMask = new Color[] { new Color(1.0f, 0.0f, 0.0f, 0.33f), @@ -87,7 +87,7 @@ * @param mapControl MapControl of the map to render * @param mapGrid Grid to render */ - public MapRenderer(@NotNull final CFilterControl filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final MapGrid mapGrid) { + public MapRenderer(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final MapGrid mapGrid) { super(mapControl, mapGrid, 32); this.filterControl = filterControl; this.editTypes = editTypes; Modified: trunk/crossfire/src/cfeditor/script/ScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-09-25 20:50:23 UTC (rev 5231) +++ trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -23,8 +23,11 @@ import bsh.EvalError; import bsh.Interpreter; import bsh.TargetError; -import cfeditor.filter.CFilterControl; +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.script.ScriptView; +import cfeditor.map.MapArchObject; import java.awt.Component; import java.io.CharArrayWriter; import java.io.File; @@ -43,6 +46,7 @@ import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.event.EventListenerList; +import net.sf.gridarta.filter.CFilterControl; import net.sf.gridarta.filter.Filter; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -90,13 +94,13 @@ private final Component parent; @NotNull - private final CFilterControl filterControl; + private final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; /** The default directory for saving scripts. */ @Nullable private File scriptsDir = null; - public ScriptController(@NotNull final CFilterControl filterControl, @NotNull final ScriptParameters scriptParameters, @NotNull final Component parent) { + public ScriptController(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final ScriptParameters scriptParameters, @NotNull final Component parent) { this.parent = parent; this.filterControl = filterControl; this.scriptParameters = scriptParameters; Copied: trunk/src/app/net/sf/gridarta/filter/CFilterControl.java (from rev 5231, trunk/crossfire/src/cfeditor/filter/CFilterControl.java) =================================================================== --- trunk/src/app/net/sf/gridarta/filter/CFilterControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/filter/CFilterControl.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -0,0 +1,138 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.filter; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * Control for filters. + * <p/> + * Control to check if 1) a specific GameObject can be shown (filter out of view + * part) 2) a specific MapSquare must be highlighted (analysis part) It provides + * only one filterOut path (and so elements are visible or not, they can't be + * twice visible or such). It provides 3 highlight paths. each of them can be + * (dis)enabled. So you can, e.g., highlight walls in a specific color, + * teleporters in another and monsters in a third. highlight and filterOut + * filters works all the same. You can activate specific predefined filters or + * you can provide your own If several predefined Filters are activated for a + * path, they are combined in an OR way. For example, if you enable the + * filterOut path, activate in this path the wall and the floor filters, only + * walls and floors will be shown. + * @author tchize + */ +//TODO allow implementation of own filter +public final class CFilterControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + public static final int MAX_HIGHLIGHT = 3; + + private final NamedFilterList filterList; + + private final NamedFilterConfig filterOutConfig; + + private final NamedFilterConfig[] highlightConfig; + + @NotNull + private final MapManager<G, A, R, V> mapManager; + + private final ConfigListener configListener = new ConfigListener() { + + /** {@inheritDoc} */ + public void configChanged(final ConfigEvent event) { + for (final MapControl<G, A, R, V> mapControl : mapManager.getOpenedMaps()) { + mapControl.repaint(); + } + } + + }; + + /** + * Create a new FilterControl. Do not highlight anything and does not + * filterOut anything + * @param mapManager the map manager instance + * @param filterList the filter list instance to use + */ + public CFilterControl(@NotNull final MapManager<G, A, R, V> mapManager, final NamedFilterList filterList) { + this.filterList = filterList; + this.mapManager = mapManager; + filterOutConfig = (NamedFilterConfig) filterList.createConfig(); + highlightConfig = new NamedFilterConfig[MAX_HIGHLIGHT]; + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + highlightConfig[i] = (NamedFilterConfig) filterList.createConfig(); + } + filterOutConfig.addConfigChangeListener(configListener); + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + highlightConfig[i].addConfigChangeListener(configListener); + } + } + + public void createMenuEntries(final JMenu menu) { + final JMenuItem menuItem = filterList.createMenuEntry(filterOutConfig); + menuItem.setText("Filter view"); + menu.add(menuItem); + menu.addSeparator(); + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + final JMenuItem menuItem2 = filterList.createMenuEntry(highlightConfig[i]); + menuItem2.setText("Highlight " + i); + menu.add(menuItem2); + } + } + + public void newSquare(@NotNull final FilterState filterState) { + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + filterList.reset(highlightConfig[i]); + } + filterState.reset(); + } + + public boolean isHighlightedSquare(@NotNull final FilterState filterState, final int path) { + return highlightConfig[path].isEnabled() && filterState.isHighlightedSquare(path); + } + + public void objectInSquare(@NotNull final FilterState filterState, @NotNull final GameObject<?, ?, ?> gameObject) { + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + if (highlightConfig[i].isEnabled()) { + if(!filterState.isHighlightedSquare(i)) { + filterState.setHighlightedSquare(i, filterList.match(highlightConfig[i], gameObject)); + } + } + } + } + + public boolean canShow(final G gameObject) { + return !filterOutConfig.isEnabled() || filterList.canShow(gameObject, filterOutConfig); + } + + public void addFilter(final String name, final Filter filter) { + filterList.addFilter(name, filter); + } + + public void removeFilter(final String name) { + filterList.removeFilter(name); + } + +} // class CFilterControl Copied: trunk/src/app/net/sf/gridarta/filter/FilterState.java (from rev 5231, trunk/crossfire/src/cfeditor/filter/FilterState.java) =================================================================== --- trunk/src/app/net/sf/gridarta/filter/FilterState.java (rev 0) +++ trunk/src/app/net/sf/gridarta/filter/FilterState.java 2008-09-25 21:06:34 UTC (rev 5232) @@ -0,0 +1,60 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.filter; + +import java.util.Arrays; + +/** + * The highlighted state while using a {@link CFilterControl} instance. + * @author Andreas Kirschbaum + */ +public class FilterState { + + /** + * The current hightlight state. + */ + private final boolean[] highlightedSquare = new boolean[CFilterControl.MAX_HIGHLIGHT]; + + /** + * Resets the state to no highlights. + */ + public void reset() { + Arrays.fill(highlightedSquare, false); + } + + /** + * Returns whether the given path should be highlighted. + * @param path the path + * @return the highlighted state + */ + public boolean isHighlightedSquare(final int path) { + return highlightedSquare[path]; + } + + /** + * Sets the highlighted state for a given path. + * @param path the path + * @param highlightedSquare the highlighted state + */ + public void setHighlightedSquare(final int path, final boolean highlightedSquare) { + this.highlightedSquare[path] = highlightedSquare; + } + +} // class FilterState Property changes on: trunk/src/app/net/sf/gridarta/filter/FilterState.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-25 21:12:26
|
Revision: 5233 http://gridarta.svn.sourceforge.net/gridarta/?rev=5233&view=rev Author: akirschbaum Date: 2008-09-25 21:12:19 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Rename CFilterControl to FilterControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java trunk/crossfire/src/cfeditor/script/ScriptController.java trunk/src/app/net/sf/gridarta/filter/FilterState.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/filter/FilterControl.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/filter/CFilterControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -48,7 +48,7 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.filter.CFilterControl; +import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.filter.NamedFilterList; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.GameObjectFactory; @@ -101,7 +101,7 @@ /** The current script controller. */ private ScriptController scriptControl; - private CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; + private FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; /** Preferences default for auto validation. */ private static final boolean PREFS_VALIDATOR_AUTO_DEFAULT = true; @@ -182,7 +182,7 @@ protected void init2(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final ObjectChooser<GameObject, MapArchObject, Archetype> objectChooser) { PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); - filterControl = new CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, defaultNamedFilterList); + filterControl = new FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, defaultNamedFilterList); ((CrossfireObjectsFactory) gridartaObjectsFactory).setFilterControl(filterControl); final ScriptParameters scriptParameters = new ScriptParameters(archetypeSet, globalSettings, mapManager, validators); scriptControl = new ScriptController(filterControl, scriptParameters, getMainView()); Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -36,7 +36,7 @@ import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; -import net.sf.gridarta.filter.CFilterControl; +import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; @@ -83,7 +83,7 @@ private ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet = null; @NotNull - private CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; + private FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; /** The tool palette instance. */ @NotNull @@ -132,7 +132,7 @@ this.toolPalette = toolPalette; } - public void setFilterControl(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + public void setFilterControl(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { this.filterControl = filterControl; } Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -25,7 +25,7 @@ import java.awt.Point; import java.awt.Rectangle; import net.sf.gridarta.EditTypes; -import net.sf.gridarta.filter.CFilterControl; +import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -125,7 +125,7 @@ * @param yScrollDistance the y distance when scrolling * @param selectedSquareView the selected square view */ - public CMapViewBasic(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public CMapViewBasic(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { super(mapControl, xScrollDistance, yScrollDistance, selectedSquareView); getMapCursor().addMapCursorListener(mapCursorListener); Modified: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -31,7 +31,7 @@ import java.lang.ref.SoftReference; import javax.swing.ImageIcon; import net.sf.gridarta.EditTypes; -import net.sf.gridarta.filter.CFilterControl; +import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.filter.FilterState; import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.map.MapGrid; @@ -53,7 +53,7 @@ private static final long serialVersionUID = 1L; @NotNull - private final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; + private final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; private final Color[] highLightMask = new Color[] { new Color(1.0f, 0.0f, 0.0f, 0.33f), @@ -87,7 +87,7 @@ * @param mapControl MapControl of the map to render * @param mapGrid Grid to render */ - public MapRenderer(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final MapGrid mapGrid) { + public MapRenderer(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, final MapGrid mapGrid) { super(mapControl, mapGrid, 32); this.filterControl = filterControl; this.editTypes = editTypes; @@ -194,7 +194,7 @@ } } } - for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { + for (int i = 0; i < FilterControl.MAX_HIGHLIGHT; i++) { if (filterControl.isHighlightedSquare(filterState, i)) { final Color c = grfx.getColor(); grfx.setColor(highLightMask[i]); Modified: trunk/crossfire/src/cfeditor/script/ScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/crossfire/src/cfeditor/script/ScriptController.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -46,8 +46,8 @@ import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.event.EventListenerList; -import net.sf.gridarta.filter.CFilterControl; import net.sf.gridarta.filter.Filter; +import net.sf.gridarta.filter.FilterControl; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jdom.Document; @@ -94,13 +94,13 @@ private final Component parent; @NotNull - private final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; + private final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; /** The default directory for saving scripts. */ @Nullable private File scriptsDir = null; - public ScriptController(@NotNull final CFilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final ScriptParameters scriptParameters, @NotNull final Component parent) { + public ScriptController(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final ScriptParameters scriptParameters, @NotNull final Component parent) { this.parent = parent; this.filterControl = filterControl; this.scriptParameters = scriptParameters; Deleted: trunk/src/app/net/sf/gridarta/filter/CFilterControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/filter/CFilterControl.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/src/app/net/sf/gridarta/filter/CFilterControl.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -1,138 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.filter; - -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; -import org.jetbrains.annotations.NotNull; - -/** - * Control for filters. - * <p/> - * Control to check if 1) a specific GameObject can be shown (filter out of view - * part) 2) a specific MapSquare must be highlighted (analysis part) It provides - * only one filterOut path (and so elements are visible or not, they can't be - * twice visible or such). It provides 3 highlight paths. each of them can be - * (dis)enabled. So you can, e.g., highlight walls in a specific color, - * teleporters in another and monsters in a third. highlight and filterOut - * filters works all the same. You can activate specific predefined filters or - * you can provide your own If several predefined Filters are activated for a - * path, they are combined in an OR way. For example, if you enable the - * filterOut path, activate in this path the wall and the floor filters, only - * walls and floors will be shown. - * @author tchize - */ -//TODO allow implementation of own filter -public final class CFilterControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { - - public static final int MAX_HIGHLIGHT = 3; - - private final NamedFilterList filterList; - - private final NamedFilterConfig filterOutConfig; - - private final NamedFilterConfig[] highlightConfig; - - @NotNull - private final MapManager<G, A, R, V> mapManager; - - private final ConfigListener configListener = new ConfigListener() { - - /** {@inheritDoc} */ - public void configChanged(final ConfigEvent event) { - for (final MapControl<G, A, R, V> mapControl : mapManager.getOpenedMaps()) { - mapControl.repaint(); - } - } - - }; - - /** - * Create a new FilterControl. Do not highlight anything and does not - * filterOut anything - * @param mapManager the map manager instance - * @param filterList the filter list instance to use - */ - public CFilterControl(@NotNull final MapManager<G, A, R, V> mapManager, final NamedFilterList filterList) { - this.filterList = filterList; - this.mapManager = mapManager; - filterOutConfig = (NamedFilterConfig) filterList.createConfig(); - highlightConfig = new NamedFilterConfig[MAX_HIGHLIGHT]; - for (int i = 0; i < MAX_HIGHLIGHT; i++) { - highlightConfig[i] = (NamedFilterConfig) filterList.createConfig(); - } - filterOutConfig.addConfigChangeListener(configListener); - for (int i = 0; i < MAX_HIGHLIGHT; i++) { - highlightConfig[i].addConfigChangeListener(configListener); - } - } - - public void createMenuEntries(final JMenu menu) { - final JMenuItem menuItem = filterList.createMenuEntry(filterOutConfig); - menuItem.setText("Filter view"); - menu.add(menuItem); - menu.addSeparator(); - for (int i = 0; i < MAX_HIGHLIGHT; i++) { - final JMenuItem menuItem2 = filterList.createMenuEntry(highlightConfig[i]); - menuItem2.setText("Highlight " + i); - menu.add(menuItem2); - } - } - - public void newSquare(@NotNull final FilterState filterState) { - for (int i = 0; i < MAX_HIGHLIGHT; i++) { - filterList.reset(highlightConfig[i]); - } - filterState.reset(); - } - - public boolean isHighlightedSquare(@NotNull final FilterState filterState, final int path) { - return highlightConfig[path].isEnabled() && filterState.isHighlightedSquare(path); - } - - public void objectInSquare(@NotNull final FilterState filterState, @NotNull final GameObject<?, ?, ?> gameObject) { - for (int i = 0; i < MAX_HIGHLIGHT; i++) { - if (highlightConfig[i].isEnabled()) { - if(!filterState.isHighlightedSquare(i)) { - filterState.setHighlightedSquare(i, filterList.match(highlightConfig[i], gameObject)); - } - } - } - } - - public boolean canShow(final G gameObject) { - return !filterOutConfig.isEnabled() || filterList.canShow(gameObject, filterOutConfig); - } - - public void addFilter(final String name, final Filter filter) { - filterList.addFilter(name, filter); - } - - public void removeFilter(final String name) { - filterList.removeFilter(name); - } - -} // class CFilterControl Copied: trunk/src/app/net/sf/gridarta/filter/FilterControl.java (from rev 5232, trunk/src/app/net/sf/gridarta/filter/CFilterControl.java) =================================================================== --- trunk/src/app/net/sf/gridarta/filter/FilterControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/filter/FilterControl.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -0,0 +1,138 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.filter; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; + +/** + * Control for filters. + * <p/> + * Control to check if 1) a specific GameObject can be shown (filter out of view + * part) 2) a specific MapSquare must be highlighted (analysis part) It provides + * only one filterOut path (and so elements are visible or not, they can't be + * twice visible or such). It provides 3 highlight paths. each of them can be + * (dis)enabled. So you can, e.g., highlight walls in a specific color, + * teleporters in another and monsters in a third. highlight and filterOut + * filters works all the same. You can activate specific predefined filters or + * you can provide your own If several predefined Filters are activated for a + * path, they are combined in an OR way. For example, if you enable the + * filterOut path, activate in this path the wall and the floor filters, only + * walls and floors will be shown. + * @author tchize + */ +//TODO allow implementation of own filter +public final class FilterControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + public static final int MAX_HIGHLIGHT = 3; + + private final NamedFilterList filterList; + + private final NamedFilterConfig filterOutConfig; + + private final NamedFilterConfig[] highlightConfig; + + @NotNull + private final MapManager<G, A, R, V> mapManager; + + private final ConfigListener configListener = new ConfigListener() { + + /** {@inheritDoc} */ + public void configChanged(final ConfigEvent event) { + for (final MapControl<G, A, R, V> mapControl : mapManager.getOpenedMaps()) { + mapControl.repaint(); + } + } + + }; + + /** + * Create a new FilterControl. Do not highlight anything and does not + * filterOut anything + * @param mapManager the map manager instance + * @param filterList the filter list instance to use + */ + public FilterControl(@NotNull final MapManager<G, A, R, V> mapManager, final NamedFilterList filterList) { + this.filterList = filterList; + this.mapManager = mapManager; + filterOutConfig = (NamedFilterConfig) filterList.createConfig(); + highlightConfig = new NamedFilterConfig[MAX_HIGHLIGHT]; + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + highlightConfig[i] = (NamedFilterConfig) filterList.createConfig(); + } + filterOutConfig.addConfigChangeListener(configListener); + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + highlightConfig[i].addConfigChangeListener(configListener); + } + } + + public void createMenuEntries(final JMenu menu) { + final JMenuItem menuItem = filterList.createMenuEntry(filterOutConfig); + menuItem.setText("Filter view"); + menu.add(menuItem); + menu.addSeparator(); + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + final JMenuItem menuItem2 = filterList.createMenuEntry(highlightConfig[i]); + menuItem2.setText("Highlight " + i); + menu.add(menuItem2); + } + } + + public void newSquare(@NotNull final FilterState filterState) { + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + filterList.reset(highlightConfig[i]); + } + filterState.reset(); + } + + public boolean isHighlightedSquare(@NotNull final FilterState filterState, final int path) { + return highlightConfig[path].isEnabled() && filterState.isHighlightedSquare(path); + } + + public void objectInSquare(@NotNull final FilterState filterState, @NotNull final GameObject<?, ?, ?> gameObject) { + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + if (highlightConfig[i].isEnabled()) { + if(!filterState.isHighlightedSquare(i)) { + filterState.setHighlightedSquare(i, filterList.match(highlightConfig[i], gameObject)); + } + } + } + } + + public boolean canShow(final G gameObject) { + return !filterOutConfig.isEnabled() || filterList.canShow(gameObject, filterOutConfig); + } + + public void addFilter(final String name, final Filter filter) { + filterList.addFilter(name, filter); + } + + public void removeFilter(final String name) { + filterList.removeFilter(name); + } + +} // class FilterControl Modified: trunk/src/app/net/sf/gridarta/filter/FilterState.java =================================================================== --- trunk/src/app/net/sf/gridarta/filter/FilterState.java 2008-09-25 21:06:34 UTC (rev 5232) +++ trunk/src/app/net/sf/gridarta/filter/FilterState.java 2008-09-25 21:12:19 UTC (rev 5233) @@ -22,7 +22,7 @@ import java.util.Arrays; /** - * The highlighted state while using a {@link CFilterControl} instance. + * The highlighted state while using a {@link FilterControl} instance. * @author Andreas Kirschbaum */ public class FilterState { @@ -30,7 +30,7 @@ /** * The current hightlight state. */ - private final boolean[] highlightedSquare = new boolean[CFilterControl.MAX_HIGHLIGHT]; + private final boolean[] highlightedSquare = new boolean[FilterControl.MAX_HIGHLIGHT]; /** * Resets the state to no highlights. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-26 21:24:04
|
Revision: 5242 http://gridarta.svn.sourceforge.net/gridarta/?rev=5242&view=rev Author: akirschbaum Date: 2008-09-26 21:23:47 +0000 (Fri, 26 Sep 2008) Log Message: ----------- Fix CrossfireEditor's collection process: include default inventories. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-26 20:50:11 UTC (rev 5241) +++ trunk/crossfire/ChangeLog 2008-09-26 21:23:47 UTC (rev 5242) @@ -1,5 +1,7 @@ 2008-09-26 Andreas Kirschbaum + * Fix collection process: include default inventories. + * Update archetypes. 2008-09-25 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-09-26 20:50:11 UTC (rev 5241) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-09-26 21:23:47 UTC (rev 5242) @@ -30,6 +30,7 @@ import javax.swing.ImageIcon; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.AbstractArchetypeSet; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -54,6 +55,12 @@ private final String imageSet; /** + * The game object parser for saving inventories. + */ + @NotNull + private GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; + + /** * Create the ArchetypeSet. * @param imageSet the image set to use * @param gridartaObjectsFactory the gridarta objects factory instance to @@ -65,6 +72,11 @@ } /** {@inheritDoc} */ + public void init(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) { + this.gameObjectParser = gameObjectParser; + } + + /** {@inheritDoc} */ @NotNull public ImageIcon getFace(@NotNull final Archetype archetype) { return getFace(archetype.getFaceObjName(), archetype.isUndefinedArchetype()); @@ -157,6 +169,10 @@ out.append(arch.getObjectText()); + for (final GameObject inv : arch) { + gameObjectParser.save(out, inv); + } + out.append("end\n"); // process the multipart tails: Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-09-26 20:50:11 UTC (rev 5241) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-09-26 21:23:47 UTC (rev 5242) @@ -32,6 +32,7 @@ import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gui.SystemIcons; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -59,6 +60,10 @@ } /** {@inheritDoc} */ + public void init(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) { + } + + /** {@inheritDoc} */ @NotNull public ImageIcon getFace(@NotNull final Archetype archetype) { return getFace(archetype.getFaceObjName(), archetype.isUndefinedArchetype()); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-26 20:50:11 UTC (rev 5241) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-09-26 21:23:47 UTC (rev 5242) @@ -411,6 +411,7 @@ init3(); final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); final GameObjectParser<G, A, R> gameObjectParser = newGameObjectParser(gameObjectFactory); + archetypeSet.init(gameObjectParser); final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet); gridartaObjectsFactory.init(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, archetypeSet, toolPalette); mapControlFactory.init(gridartaObjectsFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2008-09-26 20:50:11 UTC (rev 5241) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2008-09-26 21:23:47 UTC (rev 5242) @@ -23,6 +23,7 @@ import java.io.File; import java.util.Collection; import javax.swing.ImageIcon; +import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,6 +35,8 @@ */ public interface ArchetypeSet<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends Collectable { + void init(@NotNull GameObjectParser<G, A, R> gameObjectParser); + /** * Returns the load status of this ArchetypeSet. * @return The load status of this ArchetypeSet. Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-26 20:50:11 UTC (rev 5241) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-09-26 21:23:47 UTC (rev 5242) @@ -992,6 +992,11 @@ } /** {@inheritDoc} */ + public void init(@NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ @NotNull public ImageIcon getFace(@NotNull final TestArchetype archetype) { throw new AssertionError(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-26 22:17:02
|
Revision: 5243 http://gridarta.svn.sourceforge.net/gridarta/?rev=5243&view=rev Author: akirschbaum Date: 2008-09-26 22:16:54 +0000 (Fri, 26 Sep 2008) Log Message: ----------- Fix collection process: do not remove leading whitespace from msg...endmsg blocks. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/io/GameObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/io/GameObjectParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribText.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/utils/StringUtils.java trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/crossfire/ChangeLog 2008-09-26 22:16:54 UTC (rev 5243) @@ -1,6 +1,8 @@ 2008-09-26 Andreas Kirschbaum - * Fix collection process: include default inventories. + * Fix collection process: + - include default inventories + - do not remove leading whitespace from msg...endmsg blocks * Update archetypes. Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -163,8 +163,8 @@ out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); // add message text - if (arch.getMsgText() != null && arch.getMsgText().trim().length() > 0) { - out.append("msg\n").append(arch.getMsgText().trim()).append("\nendmsg\n"); + if (arch.getMsgText() != null) { + out.append("msg\n").append(arch.getMsgText()).append("endmsg\n"); } out.append(arch.getObjectText()); Modified: trunk/crossfire/src/cfeditor/io/GameObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/io/GameObjectParser.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/crossfire/src/cfeditor/io/GameObjectParser.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -353,8 +353,8 @@ final String msgText = gameObject.getMsgText(); final String archMsgText = archetype.getMsgText(); - if (msgText != null && !msgText.trim().equals(archMsgText == null ? "" : archMsgText.trim())) { - fields.put("msg", String.format("%s%sendmsg", msgText, msgText.endsWith("\n") ? "" : "\n")); + if (msgText != null && !msgText.equals(archMsgText == null ? "" : archMsgText)) { + fields.put("msg", msgText + "endmsg"); } if (gameObject.getArchTypNr() != archetype.getArchTypNr()) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -189,14 +189,7 @@ } if (arch.getMsgText() != null) { - out.append("msg").append('\n'); - if (arch.getMsgText().length() > 1) { - out.append(arch.getMsgText()); - if (arch.getMsgText().lastIndexOf('\n') != arch.getMsgText().length() - 1) { - out.append('\n'); - } - } - out.append("endmsg\n"); + out.append("msg\n").append(arch.getMsgText()).append("endmsg\n"); } // special: add a string-attribute with the display-category @@ -234,14 +227,7 @@ } if (tail.getMsgText() != null) { - out.append("msg\n"); - if (tail.getMsgText().length() > 1) { - out.append(tail.getMsgText()); - if (tail.getMsgText().lastIndexOf('\n') != tail.getMsgText().length() - 1) { - out.append('\n'); - } - } - out.append("endmsg\n"); + out.append("msg\n").append(tail.getMsgText()).append("endmsg\n"); } out.append(tail.getObjectText()); Modified: trunk/daimonin/src/daieditor/io/GameObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/daimonin/src/daieditor/io/GameObjectParser.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -63,8 +63,8 @@ final String msgText = gameObject.getMsgText(); final String archMsgText = archetype.getMsgText(); - if (msgText != null && !msgText.trim().equals(archMsgText == null ? "" : archMsgText.trim())) { - format.format("msg\n%s%sendmsg\n", msgText, msgText.endsWith("\n") ? "" : "\n"); + if (msgText != null && !msgText.equals(archMsgText == null ? "" : archMsgText)) { + format.format("msg\n%sendmsg\n", msgText); } if (gameObject.getArchTypNr() != archetype.getArchTypNr()) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -60,7 +60,7 @@ public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, @NotNull final Component parent) { String text = ""; if (getArchetypeAttributeName().equalsIgnoreCase("msg")) { - if (archetype.getMsgText() != null && archetype.getMsgText().length() > 0 && (gameObject.getMsgText() == null || gameObject.getMsgText().trim().length() == 0)) { + if (archetype.getMsgText() != null && archetype.getMsgText().length() > 0 && (gameObject.getMsgText() == null || gameObject.getMsgText().length() == 0)) { text = archetype.getMsgText(); } else { text = gameObject.getMsgText(); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -865,7 +865,7 @@ } msgText.append(StringUtils.removeTrailingWhitespace(text)); - msgText.append("\n"); + msgText.append('\n'); gameObjectChanged(); } @@ -883,7 +883,7 @@ * @param msgText the message text */ public void setMsgText(@Nullable final String msgText) { - final String trimmedMsgText = msgText == null ? null : StringUtils.removeTrailingWhitespaceFromLines(msgText); + final String trimmedMsgText = msgText == null ? null : StringUtils.removeTrailingWhitespaceFromLines(StringUtils.ensureTrailingNewline(msgText)); if (this.msgText == null ? trimmedMsgText == null : this.msgText.toString().equals(trimmedMsgText)) { return; } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribText.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribText.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribText.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -28,6 +28,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.textedit.textarea.JEditTextArea; +import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; public class DialogAttribText<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends DialogAttrib<G, A, R, JEditTextArea> { @@ -44,8 +45,11 @@ /** {@inheritDoc} */ public String getText2(@NotNull final G gameObject, @NotNull final R archetype, final String[] newName, final String[] newFace, final String[] newMsg, final String[] newAnim, final ArchetypeType typeStruct, final Component parent) { // a String attribute - if (ref.getArchetypeAttributeName().equalsIgnoreCase("msg") && getInput().getText().trim().length() > 0) { - newMsg[0] = getInput().getText().trim(); + if (ref.getArchetypeAttributeName().equalsIgnoreCase("msg")) { + final String msgText = StringUtils.removeTrailingWhitespaceFromLines(getInput().getText()); + if (msgText.length() > 0) { + newMsg[0] = msgText; + } } return ""; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -75,6 +75,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -696,13 +697,13 @@ if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype - if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { - gameObject.setMsgText(newMsg[0]); + final String msgText = StringUtils.removeTrailingWhitespaceFromLines(newMsg[0]); + if (!msgText.equals(archetype.getMsgText() == null ? "" : archetype.getMsgText())) { + gameObject.setMsgText(msgText); } else { gameObject.setMsgText(null); } - } else - if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { + } else if (archetype.getMsgText() != null && archetype.getMsgText().length() > 0) { // we must override archetype msg by an empty msg gameObject.setMsgText(""); } else { Modified: trunk/src/app/net/sf/gridarta/utils/StringUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -56,14 +56,15 @@ } /** - * Returns a given string which ends with a trailing newline character. If - * the input strings ends in a newline character it is returned; else a - * newline character is appended first. + * Returns a given string which ends with a trailing newline character; + * empty strings remain empty. If the input strings ends in a newline + * character or if it is empty, it is returned; else a newline character is + * appended first. * @param str the input string * @return the string with a trailing newline character */ public static String ensureTrailingNewline(final String str) { - return str.endsWith("\n") ? str : str + "\n"; + return str.length() <= 0 ? "" : str.endsWith("\n") ? str : str + "\n"; } /** Modified: trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java 2008-09-26 21:23:47 UTC (rev 5242) +++ trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java 2008-09-26 22:16:54 UTC (rev 5243) @@ -72,7 +72,7 @@ /** Test case for {@link StringUtils#ensureTrailingNewline(String)}. */ @Test public void testEnsureTrailingNewline() { - testEnsureTrailingNewline("", "\n"); + testEnsureTrailingNewline("", ""); testEnsureTrailingNewline("\n", "\n"); testEnsureTrailingNewline(" abc def ", " abc def \n"); testEnsureTrailingNewline("\n\n\n", "\n\n\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-27 11:54:00
|
Revision: 5247 http://gridarta.svn.sourceforge.net/gridarta/?rev=5247&view=rev Author: akirschbaum Date: 2008-09-27 11:53:52 +0000 (Sat, 27 Sep 2008) Log Message: ----------- Move ProcessRunner to common code base. Modified Paths: -------------- trunk/daimonin/build.xml trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/action.properties trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/resource/icons/ trunk/resource/icons/media/ trunk/src/app/net/sf/gridarta/ProcessRunner.java Removed Paths: ------------- trunk/daimonin/resource/icons/media/ trunk/daimonin/src/daieditor/ProcessRunner.java Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/build.xml 2008-09-27 11:53:52 UTC (rev 5247) @@ -126,6 +126,7 @@ </copy> <copy todir="${build.dir.production}"> <fileset dir="../resource"> + <include name="icons/**/*.*"/> <include name="system/**/*.*"/> <include name="toolbarButtonGraphics/**/*.*"/> </fileset> Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-27 11:53:52 UTC (rev 5247) @@ -50,6 +50,7 @@ import net.sf.gridarta.GlobalSettings; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MapManager; +import net.sf.gridarta.ProcessRunner; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.filter.NamedFilterList; Deleted: trunk/daimonin/src/daieditor/ProcessRunner.java =================================================================== --- trunk/daimonin/src/daieditor/ProcessRunner.java 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/src/daieditor/ProcessRunner.java 2008-09-27 11:53:52 UTC (rev 5247) @@ -1,383 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Font; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import javax.swing.Action; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JToolBar; -import javax.swing.SwingUtilities; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.Nullable; - -/** - * Class to run an external process. - * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> - */ -public final class ProcessRunner extends JPanel { - - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(ProcessRunner.class); - - /** Serial Version. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** - * The Dialog. - * @serial include - */ - private JDialog dialog; - - /** - * The i18n key. - * @serial include - */ - private final String key; - - /** - * The command. - * @serial include - */ - private String command; - - /** - * The working directory for the command. - * @serial include - */ - private File dir; - - /** The Process. */ - private transient Process process; - - /** - * JTextArea with log. - * @serial include - */ - private final JTextArea stdtxt = new JTextArea(25, 80); - - /** - * CopyOutput for stdout. - * @serial include - */ - private final CopyOutput stdout = new CopyOutput("stdout", stdtxt); - - /** - * CopyOutput for stderr. - * @serial include - */ - private final CopyOutput stderr = new CopyOutput("stderr", stdtxt); - - /** - * Action for start. - * @serial include - */ - private final Action controlStart = ACTION_FACTORY.createAction(false, "controlStart", this); - - /** - * Action for stop. - * @serial include - */ - private final Action controlStop = ACTION_FACTORY.createAction(false, "controlStop", this); - - /** - * Action for clearing the log. - * @serial include - */ - private final Action controlClear = ACTION_FACTORY.createAction(false, "controlClear", this); - - /** The lock object for thread synchronization. */ - private final Object lock = new Object(); - - /** - * Creates a ProcessRunner for running the given command in the given - * directory. - * @param key i18n key - * @param command Command to run - * @param dir Working directory for command - */ - private ProcessRunner(final String key, final String command, final String dir) { - this.key = key; - this.command = command; - this.dir = new File(dir); - setLayout(new BorderLayout()); - stdtxt.setFont(new Font("monospaced", Font.PLAIN, stdtxt.getFont().getSize())); - stdtxt.setEditable(false); - stdtxt.setFocusable(false); - stdtxt.setLineWrap(true); - stdtxt.setBackground(Color.BLACK); - stdtxt.setForeground(Color.WHITE); - final JScrollPane scroller = new JScrollPane(stdtxt); - scroller.setFocusable(true); - add(scroller, BorderLayout.CENTER); - final JToolBar toolBar = new JToolBar(); - toolBar.add(controlStart); - toolBar.add(controlStop); - toolBar.add(controlClear); - toolBar.add(new JLabel(ACTION_FACTORY.getString("controlCloseOkay"))); - controlStop.setEnabled(false); - add(toolBar, BorderLayout.SOUTH); - } - - /** - * Creates a ProcessRunner for running the given command in its directory. - * @param key i18n key - * @param command Command to run - */ - public ProcessRunner(final String key, final String command) { - this(key, command, new File(command).getParent()); - } - - /** - * Show a dialog if not already visible. - * @param parent owner frame to display on - */ - public void showDialog(final JFrame parent) { - if (dialog == null || dialog.getOwner() != parent) { - createDialog(parent); - } - dialog.setVisible(true); - dialog.requestFocus(); - } - - /** - * Create the dialog. - * @param parent owner frame to display on - */ - private void createDialog(final JFrame parent) { - dialog = new JDialog(parent, ACTION_FACTORY.getString(key + ".title")); - dialog.add(this); - dialog.pack(); - dialog.setLocationRelativeTo(parent); - } - - /** - * Set the command to be executed by this ProcessRunner. - * @param command command - */ - public void setCommand(final String command) { - this.command = command; - } - - /** - * Get the command to be executed by this ProcessRunner. - * @return command - */ - public String getCommand() { - return command; - } - - /** - * Set the working directory. - * @param dir working directory - */ - public void setDir(final File dir) { - this.dir = dir; - } - - /** - * Get the working directory. - * @return working directory - */ - public File getDir() { - return dir; - } - - /** Action method for starting. */ - public void controlStart() { - synchronized (lock) { - if (process != null) { - try { - try { - process.getInputStream().close(); - } catch (final IOException e) { /* ignore */ } - try { - process.getErrorStream().close(); - } catch (final IOException e) { /* ignore */ } - try { - process.getOutputStream().close(); - } catch (final IOException e) { /* ignore */ } - process.exitValue(); - } catch (final IllegalThreadStateException e) { - log.error("Still running!"); - // Process is still running, don't start a new one - return; - } - } - try { - process = new ProcessBuilder(command).directory(dir).redirectErrorStream(true).start(); - final InputStream out = process.getInputStream(); - final InputStream err = process.getErrorStream(); - stdout.start(process.getInputStream()); - if (out != err) { - stderr.start(process.getErrorStream()); - } - controlStop.setEnabled(true); - controlStart.setEnabled(false); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(this, "controlError", e); - } - } - } - - /** Action method for stopping. */ - public void controlStop() { - if (process != null) { - process.destroy(); - } - controlStop.setEnabled(false); - controlStart.setEnabled(true); - } - - /** Action method for clearing the log. */ - public void controlClear() { - stdtxt.setText(""); - } - - /** Class for reading data from a stream and appending it to a JTextArea. */ - private static final class CopyOutput implements Runnable { - - /** BufferedReader to read from. */ - @Nullable - @SuppressWarnings({"InstanceVariableNamingConvention"}) - private InputStream in; - - /** JTextArea to write to. */ - private final Appender appender; - - /** Title. */ - private final String title; - - /** - * Create a CopyOutput. - * @param title Title for this CopyOutput - * @param textArea JTextArea to append output to - */ - CopyOutput(final String title, final JTextArea textArea) { - this.title = title; - appender = new Appender(textArea); - } - - /** {@inheritDoc} */ - public void run() { - try { - try { - final byte[] buf = new byte[4096]; - for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { - appender.append(new String(buf, 0, bytesRead)); - } - //for (String line; (line = in.readLine()) != null;) { - // appender.append(title, line, "\n"); - //} - } finally { - in.close(); - } - } catch (final IOException e) { - appender.append(title, ": ", e.toString()); - } finally { - in = null; - } - } - - /** - * Start running. - * @param stream InputStream to read from - */ - private void start(final InputStream stream) { - if (in != null) { - if (log.isInfoEnabled()) { - log.info("Trying to stop previous stream."); - } - try { - in.close(); - } catch (final IOException e) { - /* ignore */ - } - if (log.isInfoEnabled()) { - log.info("Stopped previous stream."); - } - } - //in = new BufferedInputStream(stream); - in = stream; - new Thread(this).start(); - } - - /** - * Class for SwingUtilities to append text. Why is this class used? - * Quite simple. Swing is not thread-safe. All modifications on realized - * Swing components must be done by the AWT Event thread. Concurrent - * modifications might crash some or more swing components. The - * CopyOutput is a thread of its own. This class makes sure that - * appending text to the JTextArea is done by the AWT Event thread. - */ - private static class Appender implements Runnable { - - /** Strings to append. */ - private final Queue<String> texts = new ConcurrentLinkedQueue<String>(); - - /** JTextArea to append to. */ - private final JTextArea textArea; - - /** - * Create an Appender. - * @param textArea JTextArea to append to - */ - Appender(final JTextArea textArea) { - this.textArea = textArea; - } - - /** - * Append text to the JTextArea. - * @param texts texts to append - */ - public void append(final String... texts) { - for (final String text : texts) { - this.texts.offer(text); - } - SwingUtilities.invokeLater(this); - } - - /** {@inheritDoc} */ - public void run() { - while (!texts.isEmpty()) { - textArea.append(texts.poll()); - } - } - - } // class Appender - - } // class CopyOutput - -} // class ProcessRunner Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/src/daieditor/messages.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -191,23 +191,8 @@ ######## # Tools -controlServer.text=Control Server -controlServer.mnemonic=S -controlServer.name=Server -controlServer.title=Daimonin server console -controlClient.text=Control Client -controlClient.mnemonic=C -controlClient.name=Client -controlClient.title=Daimonin client console -controlError.title=Control error -controlError.message=Error while starting subprocess:\n{0} -controlStart.text=Start -controlStop.text=Stop -controlStop.accel=ESCAPE -controlClear.text=Clear controlServerWarning.title=Warning controlServerWarning.message=<html><h3>Warning!</h3><p>Java cannot cope with processes that use signal handlers doing lots of work.<br>The Daimonin Server is such a process.<br>Terminating the server using the Stop button will extremely likely<br>result in a Zombie process only killable via operating system tools.</p><p><strong>You have been warned!</strong></p></html> -controlCloseOkay=You may safely close this window. cleanCompletelyBlockedSquares.text=Clean blocked squares cleanCompletelyBlockedSquares.mnemonic=B Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -172,22 +172,8 @@ ######## # Tools -controlServer.text=Server steuern -controlServer.mnemonic=S -controlServer.name=Server -controlServer.title=Daimonin Server-Konsole -controlClient.text=Client steuern -controlClient.mnemonic=C -controlClient.name=Client -controlClient.title=Daimonin Client-Konsole -controlError.title=Steuerungsfehler -controlError.message=Konnte Prozess nicht starten:\n{0} -controlStart.text=Start -controlStop.text=Stopp -controlClear.text=L\xF6schen controlServerWarning.title=Warnung controlServerWarning.message=<html><h3>Warnung!</h3><p>Java kann mit Prozessen nicht richtig umgehen, die im Signal-Handler viel Code ausf\xFChren.<br>Der Daimonin-Server ist so ein Prozess.<br>Die Beendigung durch "Stopp" wird wahrscheinlich einen Zombie-Prozess<br>erzeugen, der durch das Betriebssystem beendet werden muss.</p><p><strong>Sie sind gewarnt worden!</strong></p></html> -controlCloseOkay=Sie k\xF6nnen dieses Fenster schlie\xDFen. #cleanCompletelyBlockedSquares.text= #cleanCompletelyBlockedSquares.mnemonic= Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -173,22 +173,8 @@ ######## # Tools -#controlServer.text= -#controlServer.mnemonic= -#controlServer.name= -#controlServer.title= -#controlClient.text= -#controlClient.mnemonic= -#controlClient.name= -#controlClient.title= -#controlError.title= -#controlError.message= -#controlStart.text= -#controlStop.text= -#controlClear.text= #controlServerWarning.title= #controlServerWarning.message= -#controlCloseOkay= #cleanCompletelyBlockedSquares.text= #cleanCompletelyBlockedSquares.mnemonic= Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -174,22 +174,8 @@ ######## # Tools -controlServer.text=Styr server -controlServer.mnemonic=S -controlServer.name=Server -controlServer.title=Daimonin serverkonsoll -controlClient.text=Styr klient -controlClient.mnemonic=K -controlClient.name=Klient -controlClient.title=Daimonin klientkonsoll -controlError.title=Styrfel -controlError.message=Fel vid start av underprocess:\n{0} -controlStart.text=Starta -controlStop.text=Stoppa -#controlClear.text= controlServerWarning.title=Varning controlServerWarning.message=<html><h3>Varning!</h3><p>Java kan inte hantera processer som anv\xE4nder signalhanterare f\xF6r mycket arbete.<br>Daimoninservern \xE4r en s\xE5dan process.<br>Stopp av servern med "stoppa"-knappen kommer med stor sannolikhet<br>att resultera i en zombie-process som bara g\xE5r att ta bort med operativsystemets verktyg.</p><p><strong>Du har blivit varnad!</strong></p></html> -controlCloseOkay=Du kan st\xE4nga f\xF6nstret nu. #cleanCompletelyBlockedSquares.text= #cleanCompletelyBlockedSquares.mnemonic= Property changes on: trunk/resource/icons/media ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/src/app/net/sf/gridarta/ProcessRunner.java (from rev 5245, trunk/daimonin/src/daieditor/ProcessRunner.java) =================================================================== --- trunk/src/app/net/sf/gridarta/ProcessRunner.java (rev 0) +++ trunk/src/app/net/sf/gridarta/ProcessRunner.java 2008-09-27 11:53:52 UTC (rev 5247) @@ -0,0 +1,383 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import javax.swing.Action; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JToolBar; +import javax.swing.SwingUtilities; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.Nullable; + +/** + * Class to run an external process. + * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> + */ +public final class ProcessRunner extends JPanel { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ProcessRunner.class); + + /** Serial Version. */ + private static final long serialVersionUID = 1L; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The Dialog. + * @serial include + */ + private JDialog dialog; + + /** + * The i18n key. + * @serial include + */ + private final String key; + + /** + * The command. + * @serial include + */ + private String command; + + /** + * The working directory for the command. + * @serial include + */ + private File dir; + + /** The Process. */ + private transient Process process; + + /** + * JTextArea with log. + * @serial include + */ + private final JTextArea stdtxt = new JTextArea(25, 80); + + /** + * CopyOutput for stdout. + * @serial include + */ + private final CopyOutput stdout = new CopyOutput("stdout", stdtxt); + + /** + * CopyOutput for stderr. + * @serial include + */ + private final CopyOutput stderr = new CopyOutput("stderr", stdtxt); + + /** + * Action for start. + * @serial include + */ + private final Action controlStart = ACTION_FACTORY.createAction(false, "controlStart", this); + + /** + * Action for stop. + * @serial include + */ + private final Action controlStop = ACTION_FACTORY.createAction(false, "controlStop", this); + + /** + * Action for clearing the log. + * @serial include + */ + private final Action controlClear = ACTION_FACTORY.createAction(false, "controlClear", this); + + /** The lock object for thread synchronization. */ + private final Object lock = new Object(); + + /** + * Creates a ProcessRunner for running the given command in the given + * directory. + * @param key i18n key + * @param command Command to run + * @param dir Working directory for command + */ + private ProcessRunner(final String key, final String command, final String dir) { + this.key = key; + this.command = command; + this.dir = new File(dir); + setLayout(new BorderLayout()); + stdtxt.setFont(new Font("monospaced", Font.PLAIN, stdtxt.getFont().getSize())); + stdtxt.setEditable(false); + stdtxt.setFocusable(false); + stdtxt.setLineWrap(true); + stdtxt.setBackground(Color.BLACK); + stdtxt.setForeground(Color.WHITE); + final JScrollPane scroller = new JScrollPane(stdtxt); + scroller.setFocusable(true); + add(scroller, BorderLayout.CENTER); + final JToolBar toolBar = new JToolBar(); + toolBar.add(controlStart); + toolBar.add(controlStop); + toolBar.add(controlClear); + toolBar.add(new JLabel(ACTION_FACTORY.getString("controlCloseOkay"))); + controlStop.setEnabled(false); + add(toolBar, BorderLayout.SOUTH); + } + + /** + * Creates a ProcessRunner for running the given command in its directory. + * @param key i18n key + * @param command Command to run + */ + public ProcessRunner(final String key, final String command) { + this(key, command, new File(command).getParent()); + } + + /** + * Show a dialog if not already visible. + * @param parent owner frame to display on + */ + public void showDialog(final JFrame parent) { + if (dialog == null || dialog.getOwner() != parent) { + createDialog(parent); + } + dialog.setVisible(true); + dialog.requestFocus(); + } + + /** + * Create the dialog. + * @param parent owner frame to display on + */ + private void createDialog(final JFrame parent) { + dialog = new JDialog(parent, ACTION_FACTORY.getString(key + ".title")); + dialog.add(this); + dialog.pack(); + dialog.setLocationRelativeTo(parent); + } + + /** + * Set the command to be executed by this ProcessRunner. + * @param command command + */ + public void setCommand(final String command) { + this.command = command; + } + + /** + * Get the command to be executed by this ProcessRunner. + * @return command + */ + public String getCommand() { + return command; + } + + /** + * Set the working directory. + * @param dir working directory + */ + public void setDir(final File dir) { + this.dir = dir; + } + + /** + * Get the working directory. + * @return working directory + */ + public File getDir() { + return dir; + } + + /** Action method for starting. */ + public void controlStart() { + synchronized (lock) { + if (process != null) { + try { + try { + process.getInputStream().close(); + } catch (final IOException e) { /* ignore */ } + try { + process.getErrorStream().close(); + } catch (final IOException e) { /* ignore */ } + try { + process.getOutputStream().close(); + } catch (final IOException e) { /* ignore */ } + process.exitValue(); + } catch (final IllegalThreadStateException e) { + log.error("Still running!"); + // Process is still running, don't start a new one + return; + } + } + try { + process = new ProcessBuilder(command).directory(dir).redirectErrorStream(true).start(); + final InputStream out = process.getInputStream(); + final InputStream err = process.getErrorStream(); + stdout.start(process.getInputStream()); + if (out != err) { + stderr.start(process.getErrorStream()); + } + controlStop.setEnabled(true); + controlStart.setEnabled(false); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(this, "controlError", e); + } + } + } + + /** Action method for stopping. */ + public void controlStop() { + if (process != null) { + process.destroy(); + } + controlStop.setEnabled(false); + controlStart.setEnabled(true); + } + + /** Action method for clearing the log. */ + public void controlClear() { + stdtxt.setText(""); + } + + /** Class for reading data from a stream and appending it to a JTextArea. */ + private static final class CopyOutput implements Runnable { + + /** BufferedReader to read from. */ + @Nullable + @SuppressWarnings({"InstanceVariableNamingConvention"}) + private InputStream in; + + /** JTextArea to write to. */ + private final Appender appender; + + /** Title. */ + private final String title; + + /** + * Create a CopyOutput. + * @param title Title for this CopyOutput + * @param textArea JTextArea to append output to + */ + CopyOutput(final String title, final JTextArea textArea) { + this.title = title; + appender = new Appender(textArea); + } + + /** {@inheritDoc} */ + public void run() { + try { + try { + final byte[] buf = new byte[4096]; + for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { + appender.append(new String(buf, 0, bytesRead)); + } + //for (String line; (line = in.readLine()) != null;) { + // appender.append(title, line, "\n"); + //} + } finally { + in.close(); + } + } catch (final IOException e) { + appender.append(title, ": ", e.toString()); + } finally { + in = null; + } + } + + /** + * Start running. + * @param stream InputStream to read from + */ + private void start(final InputStream stream) { + if (in != null) { + if (log.isInfoEnabled()) { + log.info("Trying to stop previous stream."); + } + try { + in.close(); + } catch (final IOException e) { + /* ignore */ + } + if (log.isInfoEnabled()) { + log.info("Stopped previous stream."); + } + } + //in = new BufferedInputStream(stream); + in = stream; + new Thread(this).start(); + } + + /** + * Class for SwingUtilities to append text. Why is this class used? + * Quite simple. Swing is not thread-safe. All modifications on realized + * Swing components must be done by the AWT Event thread. Concurrent + * modifications might crash some or more swing components. The + * CopyOutput is a thread of its own. This class makes sure that + * appending text to the JTextArea is done by the AWT Event thread. + */ + private static class Appender implements Runnable { + + /** Strings to append. */ + private final Queue<String> texts = new ConcurrentLinkedQueue<String>(); + + /** JTextArea to append to. */ + private final JTextArea textArea; + + /** + * Create an Appender. + * @param textArea JTextArea to append to + */ + Appender(final JTextArea textArea) { + this.textArea = textArea; + } + + /** + * Append text to the JTextArea. + * @param texts texts to append + */ + public void append(final String... texts) { + for (final String text : texts) { + this.texts.offer(text); + } + SwingUtilities.invokeLater(this); + } + + /** {@inheritDoc} */ + public void run() { + while (!texts.isEmpty()) { + textArea.append(texts.poll()); + } + } + + } // class Appender + + } // class CopyOutput + +} // class ProcessRunner Property changes on: trunk/src/app/net/sf/gridarta/ProcessRunner.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -60,6 +60,9 @@ zoomAlg.menu=zoomAlgDefault zoomAlgFast zoomAlgSmooth zoomAlgReplicate zoomAlgAreaAveraging +controlStart.icon=media/Play16 +controlStop.icon=media/Stop16 +controlClear.icon=media/Clear16 ##################### # Script Editor Menu Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -1121,3 +1121,20 @@ importSpellsSuccess.message=Successfully collected {0} spells. importSpellsFailed.title=Collect spells importSpellsFailed.message=Collecting spells failed!\nMaybe the specified file is of wrong format. + + +controlServer.text=Control Server +controlServer.mnemonic=S +controlServer.name=Server +controlServer.title=Server console +controlClient.text=Control Client +controlClient.mnemonic=C +controlClient.name=Client +controlClient.title=Client console +controlError.title=Control error +controlError.message=Error while starting subprocess:\n{0} +controlStart.text=Start +controlStop.text=Stop +controlStop.accel=ESCAPE +controlClear.text=Clear +controlCloseOkay=You may safely close this window. Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -978,3 +978,19 @@ importSpellsSuccess.message={0} Zauberspr\xFCche geladen. importSpellsFailed.title=Zauberspr\xFCche sammeln importSpellsFailed.message=Das Sammeln der Zauberspr\xFCche ist fehlgeschlagen.\nEvtl. ist das Dateiformat falsch? + + +controlServer.text=Server steuern +controlServer.mnemonic=S +controlServer.name=Server +controlServer.title=Server-Konsole +controlClient.text=Client steuern +controlClient.mnemonic=C +controlClient.name=Client +controlClient.title=Client-Konsole +controlError.title=Steuerungsfehler +controlError.message=Konnte Prozess nicht starten:\n{0} +controlStart.text=Start +controlStop.text=Stopp +controlClear.text=L\xF6schen +controlCloseOkay=Sie k\xF6nnen dieses Fenster schlie\xDFen. Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -974,3 +974,19 @@ #importSpellsSuccess.message= #importSpellsFailed.title= #importSpellsFailed.message= + + +#controlServer.text= +#controlServer.mnemonic= +#controlServer.name= +#controlServer.title= +#controlClient.text= +#controlClient.mnemonic= +#controlClient.name= +#controlClient.title= +#controlError.title= +#controlError.message= +#controlStart.text= +#controlStop.text= +#controlClear.text= +#controlCloseOkay= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-09-27 11:30:42 UTC (rev 5246) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-09-27 11:53:52 UTC (rev 5247) @@ -977,3 +977,19 @@ importSpellsSuccess.message=Lyckades sammanst\xE4lla {0} trollformler. importSpellsFailed.title=Sammanst\xE4ll trollformler importSpellsFailed.message=Sammanst\xE4llning av trollformler misslyckades.\nVar den angivna filen inte av r\xE4tt format? + + +controlServer.text=Styr server +controlServer.mnemonic=S +controlServer.name=Server +controlServer.title=Serverkonsoll +controlClient.text=Styr klient +controlClient.mnemonic=K +controlClient.name=Klient +controlClient.title=Klientkonsoll +controlError.title=Styrfel +controlError.message=Fel vid start av underprocess:\n{0} +controlStart.text=Starta +controlStop.text=Stoppa +#controlClear.text= +controlCloseOkay=Du kan st\xE4nga f\xF6nstret nu. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-09-27 13:26:01
|
Revision: 5253 http://gridarta.svn.sourceforge.net/gridarta/?rev=5253&view=rev Author: akirschbaum Date: 2008-09-27 13:25:51 +0000 (Sat, 27 Sep 2008) Log Message: ----------- Move AppPrefs to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/action.properties trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/action.properties trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-09-27 13:25:51 UTC (rev 5253) @@ -30,7 +30,6 @@ import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.DefaultRendererFactory; -import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.NetPrefs; import daieditor.gui.prefs.ResPrefs; import daieditor.map.DefaultMapControlFactory; @@ -67,6 +66,7 @@ import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.ObjectChooser; +import net.sf.gridarta.gui.prefs.AppPrefs; import net.sf.gridarta.gui.prefs.DevPrefs; import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/action.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -135,7 +135,6 @@ update.url=http://daimonin.sourceforge.net/editor/update.properties -prefsApp.icon=development/Application24 prefsRes.icon=general/Save24 prefsGUI.icon=development/Host24 Deleted: trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2008-09-27 13:25:51 UTC (rev 5253) @@ -1,211 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.gui.prefs; - -import java.awt.Component; -import java.awt.Container; -import java.awt.FlowLayout; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.io.PathManager; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.JFileChooserButton; -import net.sf.japi.swing.prefs.AbstractPrefs; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Preferences Module for application preferences. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @serial exclude - */ -public final class AppPrefs extends AbstractPrefs { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Preferences. */ - private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); - - /** TextField for server executable. */ - private JTextField serverField; - - /** TextField for client executable. */ - private JTextField clientField; - - /** TextField for external editor executable. */ - private JTextField editorField; - - /** Preferences key for server application. */ - public static final String PREFS_APP_SERVER = "appServer"; - - /** Preferences key for client application. */ - public static final String PREFS_APP_CLIENT = "appClient"; - - /** Preferences key for editor application. */ - public static final String PREFS_APP_EDITOR = "appEditor"; - - /** - * The default value for the server setting. - */ - @NotNull - private final String serverDefault; - - /** - * The default value for the client setting. - */ - @NotNull - private final String clientDefault; - - /** - * The default value for the editor setting. - */ - @NotNull - private final String editorDefault; - - /** - * Creates a new instance. - * @param serverDefault the default value for the server setting - * @param clientDefault the default value for the client setting - * @param editorDefault the default value for the editor setting - */ - public AppPrefs(@NotNull final String serverDefault, @NotNull final String clientDefault, @NotNull final String editorDefault) { - this.serverDefault = serverDefault; - this.clientDefault = clientDefault; - this.editorDefault = editorDefault; - setListLabelText(ACTION_FACTORY.getString("prefsApp.title")); - setListLabelIcon(ACTION_FACTORY.getIcon("prefsApp.icon")); - - add(createAppPanel()); - add(Box.createVerticalGlue()); - } - - /** - * Create a titled border. - * @param titleKey Action Key for border title - * @return titled border - */ - private static Border createTitledBorder(final String titleKey) { - return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); - } - - /** {@inheritDoc} */ - public void apply() { - PREFS.put(PREFS_APP_SERVER, PathManager.path(serverField.getText())); - PREFS.put(PREFS_APP_CLIENT, PathManager.path(clientField.getText())); - PREFS.put(PREFS_APP_EDITOR, PathManager.path(editorField.getText())); - } - - /** {@inheritDoc} */ - public void revert() { - serverField.setText(PREFS.get(PREFS_APP_SERVER, serverDefault)); - clientField.setText(PREFS.get(PREFS_APP_CLIENT, clientDefault)); - editorField.setText(PREFS.get(PREFS_APP_EDITOR, editorDefault)); - } - - /** {@inheritDoc} */ - public void defaults() { - serverField.setText(serverDefault); - clientField.setText(clientDefault); - editorField.setText(editorDefault); - } - - /** {@inheritDoc} */ - public boolean isChanged() { - return !( - serverField.getText().equals(PREFS.get(PREFS_APP_SERVER, serverDefault)) - && clientField.getText().equals(PREFS.get(PREFS_APP_CLIENT, clientDefault)) - && editorField.getText().equals(PREFS.get(PREFS_APP_EDITOR, editorDefault)) - ); - } - - /** - * Creates the subpanel with the external applications. - * @return subpanel - */ - private Component createAppPanel() { - final Box appPanel = Box.createVerticalBox(); - appPanel.setBorder(createTitledBorder("optionsApps")); - - serverField = createFileField(appPanel, "optionsAppServer", PREFS.get(PREFS_APP_SERVER, serverDefault), JFileChooser.FILES_ONLY); - clientField = createFileField(appPanel, "optionsAppClient", PREFS.get(PREFS_APP_CLIENT, clientDefault), JFileChooser.FILES_ONLY); - editorField = createFileField(appPanel, "optionsAppEditor", PREFS.get(PREFS_APP_EDITOR, editorDefault), JFileChooser.FILES_ONLY); - - return appPanel; - } - - /** - * Creats a textpanel for choosing a file and adds it to another panel. - * @param panel JPanel to add field to - * @param key Key for label - * @param initial Initial value for textfield - * @param fileSelectionMode file selection mode - * @return the created JTextField - */ - private static JTextField createFileField(final Container panel, final String key, final String initial, final int fileSelectionMode) { - final JPanel subPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - subPanel.add(new JLabel(ACTION_FACTORY.getString(key))); - final JTextField textField = new JTextField(initial, 16); - subPanel.add(textField); - subPanel.add(new JFileChooserButton(textField, fileSelectionMode)); - panel.add(subPanel); - return textField; - } - - /** - * Returns the server setting. - * @return the server setting - */ - @Nullable - public String getServer() { - return PREFS.get(PREFS_APP_SERVER, serverDefault); - } - - /** - * Returns the client setting. - * @return the client setting - */ - @Nullable - public String getClient() { - return PREFS.get(PREFS_APP_CLIENT, clientDefault); - } - - /** - * Returns the editor setting. - * @return the editor setting - */ - @Nullable - public String getEditor() { - return PREFS.get(PREFS_APP_EDITOR, editorDefault); - } - -} // class AppPrefs Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/messages.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -84,10 +84,6 @@ optionsLoadArchColl.text=Load Arches from Collection optionsResMedia=Media optionsResMedia.shortdescription=<html>The media directory is for choosing background sounds for maps.<br>Please know that you cannot simply choose any media directory you want.<br>The background sound will only work if the files exist on the client as well.<br>Therefore, choosing a standard daimonin media directory is crucial.</html> -optionsApps=External Applications -optionsAppServer=Server -optionsAppClient=Client -optionsAppEditor=Editor # Old Libraries oldLibsFound.message=Old libraries found.\nLocation: {0}\nThey aren''t used anymore.\nDelete them? @@ -306,12 +302,6 @@ mapwindowCursor.mnemonic=C -##################### -# Preference Modules - -prefsApp.title=External Applications - - ################# # Map Validation Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -84,10 +84,6 @@ optionsLoadArchColl.text=Vorbereitete Archetypen laden #optionsResMedia= #optionsResMedia.shortdescription= -optionsApps=Externe Anwendungen -optionsAppServer=Server -optionsAppClient=Client -optionsAppEditor=Editor # Old Libraries #oldLibsFound.message= @@ -275,12 +271,6 @@ mapwindowCursor.mnemonic=C -##################### -# Preference Modules - -prefsApp.title=Externe Anwendungen - - ################# # Map Validation Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -85,10 +85,6 @@ #optionsLoadArchColl.text= #optionsResMedia= #optionsResMedia.shortdescription= -#optionsApps= -#optionsAppServer= -#optionsAppClient= -#optionsAppEditor= # Old Libraries #oldLibsFound.message= @@ -272,12 +268,6 @@ #mapwindowCursor.mnemonic= -##################### -# Preference Modules - -#prefsApp.title= - - ################# # Map Validation Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -84,10 +84,6 @@ optionsLoadArchColl.text=L\xE4s arketyper fr\xE5n samling optionsResMedia=Media optionsResMedia.shortdescription=<html>Mediakatalogen anv\xE4nds f\xF6r att v\xE4lja bakgrundsljud till kartor.<br>Observera att det inte g\xE5r att v\xE4lja vilka filer som helst.<br>Bakgrundsljud fungerar enbart om filen finns i klienten ocks\xE5.<br>D\xE4rf\xF6r \xE4r det viktigt att v\xE4lja en Daimonin standardkatalog f\xF6r media.</html> -optionsApps=Externa applikationer -optionsAppServer=Server -optionsAppClient=Klient -optionsAppEditor=Editor # Old Libraries oldLibsFound.message=Hittade gamla bibliotek.\nS\xF6kv\xE4g: {0}\nDe anv\xE4nds inte l\xE4ngre. Skall jag ta bort dem? @@ -273,12 +269,6 @@ mapwindowCursor.mnemonic=M -##################### -# Preference Modules - -prefsApp.title=Externa applikationer - - ################# # Map Validation Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -81,6 +81,7 @@ direction7.icon=Dir7 direction8.icon=Dir8 +prefsApp.icon=development/Application24 prefsMisc.icon=general/Preferences24 prefsMapValidator.icon=general/Search24 prefsDev.icon=development/Server24 Copied: trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java (from rev 5250, trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java 2008-09-27 13:25:51 UTC (rev 5253) @@ -0,0 +1,211 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.prefs; + +import java.awt.Component; +import java.awt.Container; +import java.awt.FlowLayout; +import java.util.prefs.Preferences; +import javax.swing.Box; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.TitledBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.gridarta.io.PathManager; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.misc.JFileChooserButton; +import net.sf.japi.swing.prefs.AbstractPrefs; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Preferences Module for application preferences. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @serial exclude + */ +public final class AppPrefs extends AbstractPrefs { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** Preferences. */ + private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); + + /** TextField for server executable. */ + private JTextField serverField; + + /** TextField for client executable. */ + private JTextField clientField; + + /** TextField for external editor executable. */ + private JTextField editorField; + + /** Preferences key for server application. */ + public static final String PREFS_APP_SERVER = "appServer"; + + /** Preferences key for client application. */ + public static final String PREFS_APP_CLIENT = "appClient"; + + /** Preferences key for editor application. */ + public static final String PREFS_APP_EDITOR = "appEditor"; + + /** + * The default value for the server setting. + */ + @NotNull + private final String serverDefault; + + /** + * The default value for the client setting. + */ + @NotNull + private final String clientDefault; + + /** + * The default value for the editor setting. + */ + @NotNull + private final String editorDefault; + + /** + * Creates a new instance. + * @param serverDefault the default value for the server setting + * @param clientDefault the default value for the client setting + * @param editorDefault the default value for the editor setting + */ + public AppPrefs(@NotNull final String serverDefault, @NotNull final String clientDefault, @NotNull final String editorDefault) { + this.serverDefault = serverDefault; + this.clientDefault = clientDefault; + this.editorDefault = editorDefault; + setListLabelText(ACTION_FACTORY.getString("prefsApp.title")); + setListLabelIcon(ACTION_FACTORY.getIcon("prefsApp.icon")); + + add(createAppPanel()); + add(Box.createVerticalGlue()); + } + + /** + * Create a titled border. + * @param titleKey Action Key for border title + * @return titled border + */ + private static Border createTitledBorder(final String titleKey) { + return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); + } + + /** {@inheritDoc} */ + public void apply() { + PREFS.put(PREFS_APP_SERVER, PathManager.path(serverField.getText())); + PREFS.put(PREFS_APP_CLIENT, PathManager.path(clientField.getText())); + PREFS.put(PREFS_APP_EDITOR, PathManager.path(editorField.getText())); + } + + /** {@inheritDoc} */ + public void revert() { + serverField.setText(PREFS.get(PREFS_APP_SERVER, serverDefault)); + clientField.setText(PREFS.get(PREFS_APP_CLIENT, clientDefault)); + editorField.setText(PREFS.get(PREFS_APP_EDITOR, editorDefault)); + } + + /** {@inheritDoc} */ + public void defaults() { + serverField.setText(serverDefault); + clientField.setText(clientDefault); + editorField.setText(editorDefault); + } + + /** {@inheritDoc} */ + public boolean isChanged() { + return !( + serverField.getText().equals(PREFS.get(PREFS_APP_SERVER, serverDefault)) + && clientField.getText().equals(PREFS.get(PREFS_APP_CLIENT, clientDefault)) + && editorField.getText().equals(PREFS.get(PREFS_APP_EDITOR, editorDefault)) + ); + } + + /** + * Creates the subpanel with the external applications. + * @return subpanel + */ + private Component createAppPanel() { + final Box appPanel = Box.createVerticalBox(); + appPanel.setBorder(createTitledBorder("optionsApps")); + + serverField = createFileField(appPanel, "optionsAppServer", PREFS.get(PREFS_APP_SERVER, serverDefault), JFileChooser.FILES_ONLY); + clientField = createFileField(appPanel, "optionsAppClient", PREFS.get(PREFS_APP_CLIENT, clientDefault), JFileChooser.FILES_ONLY); + editorField = createFileField(appPanel, "optionsAppEditor", PREFS.get(PREFS_APP_EDITOR, editorDefault), JFileChooser.FILES_ONLY); + + return appPanel; + } + + /** + * Creats a textpanel for choosing a file and adds it to another panel. + * @param panel JPanel to add field to + * @param key Key for label + * @param initial Initial value for textfield + * @param fileSelectionMode file selection mode + * @return the created JTextField + */ + private static JTextField createFileField(final Container panel, final String key, final String initial, final int fileSelectionMode) { + final JPanel subPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + subPanel.add(new JLabel(ACTION_FACTORY.getString(key))); + final JTextField textField = new JTextField(initial, 16); + subPanel.add(textField); + subPanel.add(new JFileChooserButton(textField, fileSelectionMode)); + panel.add(subPanel); + return textField; + } + + /** + * Returns the server setting. + * @return the server setting + */ + @Nullable + public String getServer() { + return PREFS.get(PREFS_APP_SERVER, serverDefault); + } + + /** + * Returns the client setting. + * @return the client setting + */ + @Nullable + public String getClient() { + return PREFS.get(PREFS_APP_CLIENT, clientDefault); + } + + /** + * Returns the editor setting. + * @return the editor setting + */ + @Nullable + public String getEditor() { + return PREFS.get(PREFS_APP_EDITOR, editorDefault); + } + +} // class AppPrefs Property changes on: trunk/src/app/net/sf/gridarta/gui/prefs/AppPrefs.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -738,6 +738,7 @@ ##################### # Preference Modules +prefsApp.title=External Applications prefsRes.title=Paths & resources prefsGUI.title=Appearance prefsDev.title=Developers @@ -770,6 +771,10 @@ optionsLoadArchColl.text=Load Arches from Collection optionsSystemExit.text=Use System.exit() for exiting optionsSystemExit.shortdescription=<html><strong>Developers</strong> should uncheck this and report when the application does not exit gracefully without using System.exit().</html> +optionsApps=External Applications +optionsAppServer=Server +optionsAppClient=Client +optionsAppEditor=Editor arcDoc.htmlText=<html><head><meta name="Gridarta" content="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">{0}</h1><h3 style="colour:navy;">Functionality of {0}:</h3><p>{1}</p><h3 style="colour:navy;">Notes on Usage:</h3><p>{2}</p></body></html> Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -693,6 +693,7 @@ ##################### # Preference Modules +prefsApp.title=Externe Anwendungen prefsRes.title=Pfade & Ressourcen prefsGUI.title=Aussehen prefsDev.title=Entwickler @@ -725,6 +726,10 @@ optionsLoadArchColl.text=Vorbereitete Archetypen laden #optionsSystemExit.text= #optionsSystemExit.shortdescription= +optionsApps=Externe Anwendungen +optionsAppServer=Server +optionsAppClient=Client +optionsAppEditor=Editor arcDoc.htmlText=<html><head meta name="Gridarta" content="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">{0}</h1><h3 style="colour:navy;">Funktionalität von {0}:</h3><p>{1}</p><h3 style="colour:navy;">Nutzungshinweise:</h3><p>{2}</p></body></html> Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -692,6 +692,7 @@ ##################### # Preference Modules +#prefsApp.title= #prefsRes.title= #prefsGUI.title= #prefsDev.title= @@ -724,6 +725,10 @@ #optionsLoadArchColl.text= #optionsSystemExit.text= #optionsSystemExit.shortdescription= +#optionsApps= +#optionsAppServer= +#optionsAppClient= +#optionsAppEditor= arcDoc.htmlText=<html><head><meta name="Gridarta" contents="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">Type: {0}</h1><h3 style="colour:navy;">Fonctionalit\xE9s de {0}</h3><p>{1}</p><h3 style="colour:navy;">Notes d'utilisation:</h3><p>{2}</p></body></html> Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-09-27 13:14:40 UTC (rev 5252) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-09-27 13:25:51 UTC (rev 5253) @@ -696,6 +696,7 @@ #################### # Preference Module +prefsApp.title=Externa applikationer prefsRes.title=S\xF6kv\xE4gar och resurser prefsGUI.title=Utseende prefsDev.title=Utvecklare @@ -728,6 +729,10 @@ optionsLoadArchColl.text=L\xE4s arketyper fr\xE5n samling optionsSystemExit.text=Anv\xE4nd System.exit() f\xF6r avslutning optionsSystemExit.shortdescription=<html><strong>Utvecklare</strong> b\xF6r avmarkera detta och rapportera n\xE4r applikationen inte avslutar korrekt utan att anv\xE4nda System.exit().</html> +optionsApps=Externa applikationer +optionsAppServer=Server +optionsAppClient=Klient +optionsAppEditor=Editor arcDoc.htmlText=<html><head name="Gridarta" content="tmp"><title>{0}</title></head><body><h1 style="text-align:center;colour:navy;">Type: {0}</h1><h3 style="colour:navy;">Funktionalitet f\xF6r {0}</h3><p>{1}</p><h3 style="colour:navy;">Tips f\xF6r anv\xE4ndning:</h3><p>{2}</p></body></html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |