From: <aki...@us...> - 2008-08-15 12:28:41
|
Revision: 4828 http://gridarta.svn.sourceforge.net/gridarta/?rev=4828&view=rev Author: akirschbaum Date: 2008-08-15 12:28:45 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Move MainControl.getLocalMapDir() to MapManager.getLocalMapDir(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/MapManager.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -233,7 +233,7 @@ public CMainControl() { super(new CrossfireObjectsFactory(), "cfeditor", new GlobalSettingsImpl()); globalSettings.readGlobalSettings(); - ScriptArchEditor.setGlobalSettings(globalSettings, this); + ScriptArchEditor.setGlobalSettings(globalSettings, mapManager); ScriptedEventEditor.setGlobalSettings(globalSettings); final AnimationObjects<AnimationObject> animationObjects = new cfeditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, globalSettings, editTypes, animationObjects, faceObjects, ((GlobalSettingsImpl) globalSettings).getImageSet(), gridartaObjectsFactory); @@ -334,12 +334,12 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox(), pythonFileFilter, globalSettings, this); + AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox(), pythonFileFilter, globalSettings, mapManager); // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); PluginParameterFactory.init(archetypeSet, gameObjectAttributesModel, objectChooser, mapManager); final NamedFilterList defaultNamedFilterList = new NamedFilterList(gameObjectMatchers.getFilters()); final CFilterControl filterControl = new CFilterControl(null, mapManager, defaultNamedFilterList); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -24,7 +24,7 @@ import java.awt.Frame; import javax.swing.ImageIcon; import javax.swing.JList; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; @@ -254,8 +254,8 @@ /** {@inheritDoc} */ @Override - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { - scriptArchData.modifyEventScript(eventType, task, eventList, mainControl, parent); + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { + scriptArchData.modifyEventScript(eventType, task, eventList, mapManager, parent); if (scriptArchData.isEmpty()) { mapanel.setScriptPanelButtonState(true, false, false, false); Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -27,7 +27,7 @@ import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JOptionPane; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; @@ -118,10 +118,10 @@ * @param task ID number for task (open script/ edit path/ remove) * @param panelList JList from the MapArchPanel (script tab) which displays * the events - * @param mainControl the main control instance + * @param mapManager the map manager instance * @param parent the parent frame for dialog boxes */ - public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { + public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { GameObject oldEvent = null; /* Find the event object */ @@ -140,7 +140,7 @@ final ScriptedEvent event = new ScriptedEvent(oldEvent); // now decide what to do: if (task == ScriptTab.SCRIPT_OPEN) { - ScriptedEventEditor.openScript(mainControl, event.getScriptPath(), parent); + ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { ScriptedEventEditor.editParameters(event, parent); } else if (task == ScriptTab.SCRIPT_REMOVE) { Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -28,7 +28,7 @@ import javax.swing.JDialog; import javax.swing.JOptionPane; import net.sf.gridarta.GlobalSettings; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; @@ -49,7 +49,7 @@ * The main control instance. */ @Nullable - private static MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl = null; + private static MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager = null; /** * The global settings instance. @@ -57,9 +57,9 @@ @Nullable private static GlobalSettings globalSettings = null; - public static void setGlobalSettings(@NotNull final GlobalSettings globalSettings, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl) { + public static void setGlobalSettings(@NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager) { ScriptArchEditor.globalSettings = globalSettings; - ScriptArchEditor.mainControl = mainControl; + ScriptArchEditor.mapManager = mapManager; } public static boolean createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { @@ -68,7 +68,7 @@ final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); - final File localMapDir = mainControl.getLocalMapDir(); + final File localMapDir = mapManager.getLocalMapDir(); scriptArchData.setChanged(false); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesControl.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -24,7 +24,6 @@ import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Frame; -import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; @@ -58,11 +57,11 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @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) { + 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 MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, 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)); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -293,7 +293,7 @@ public CMainControl() { super(new DaimoninObjectsFactory(), "daieditor", new GlobalSettingsImpl()); globalSettings.readGlobalSettings(); - ScriptArchEditor.setGlobalSettings(globalSettings, this); + ScriptArchEditor.setGlobalSettings(globalSettings, mapManager); ScriptedEventEditor.setGlobalSettings(globalSettings); final AnimationObjects<AnimationObject> animationObjects = new daieditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, globalSettings, editTypes, animationObjects, faceObjects, gridartaObjectsFactory); @@ -400,12 +400,12 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox(), luaFileFilter, globalSettings, this); + AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox(), luaFileFilter, globalSettings, mapManager); // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager, mapViewManager, 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); final GameObjectAttributesModel<GameObject, MapArchObject, Archetype> gameObjectAttributesModel = new GameObjectAttributesModel<GameObject, MapArchObject, Archetype>(); - gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, this, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); + gameObjectAttributesControl = new GameObjectAttributesControl(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, archetypeTypeSet, mapManager, mapViewManager, animationObjects, lockedItemsControl, monsterMatcher, selectedSquareControl, selectedSquareView, mainView); final ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic> objectChoiceDisplay = new ObjectChoiceDisplay<GameObject, MapArchObject, Archetype, CMapViewBasic>(replaceDialogManager, archetypeTypeSet, objectChooser, archetypeChooserModel, pickmapChooserControl); final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = new ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic>(editTypes, selectedSquareView, objectChooser, pickmapChooserControl, copyBuffer); final LeftPanel leftPanel = new LeftPanel(objectChooser, toolPalette, objectChoiceDisplay); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -25,7 +25,7 @@ import java.awt.Frame; import javax.swing.ImageIcon; import javax.swing.JList; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; @@ -401,8 +401,8 @@ /** {@inheritDoc} */ @Override - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { - scriptArchData.modifyEventScript(eventType, task, eventList, mainControl, parent); + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<GameObject, MapArchObject, Archetype> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { + scriptArchData.modifyEventScript(eventType, task, eventList, mapManager, parent); if (scriptArchData.isEmpty()) { mapanel.setScriptPanelButtonState(true, false, false, false); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -27,7 +27,7 @@ import javax.swing.JDialog; import javax.swing.JList; import javax.swing.JOptionPane; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import org.apache.log4j.Logger; @@ -118,9 +118,10 @@ * @param task ID number for task (open script/ edit path/ remove) * @param panelList JList from the MapArchPanel (script tab) which displays * the events + * @param mapManager the map manager instance * @param parent the parent frame for dialog boxes */ - public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { + public void modifyEventScript(int eventIndex, final int task, @NotNull final JList panelList, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { GameObject oldEvent = null; /* Find the event object */ @@ -139,7 +140,7 @@ final ScriptedEvent event = new ScriptedEvent(oldEvent); // now decide what to do: if (task == ScriptTab.SCRIPT_OPEN) { - ScriptedEventEditor.openScript(mainControl, event.getScriptPath(), parent); + ScriptedEventEditor.openScript(mapManager, event.getScriptPath(), parent); } else if (task == ScriptTab.SCRIPT_EDIT_PATH) { ScriptedEventEditor.editParameters(event, parent); } else if (task == ScriptTab.SCRIPT_REMOVE) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -28,7 +28,7 @@ import javax.swing.JDialog; import javax.swing.JOptionPane; import net.sf.gridarta.GlobalSettings; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; @@ -55,11 +55,11 @@ * The main control instance. */ @Nullable - private static MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl = null; + private static MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager = null; - public static void setGlobalSettings(@NotNull final GlobalSettings globalSettings, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl) { + public static void setGlobalSettings(@NotNull final GlobalSettings globalSettings, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager) { ScriptArchEditor.globalSettings = globalSettings; - ScriptArchEditor.mainControl = mainControl; + ScriptArchEditor.mapManager = mapManager; } public static boolean createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { @@ -68,7 +68,7 @@ final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); - final File localMapDir = mainControl.getLocalMapDir(); + final File localMapDir = mapManager.getLocalMapDir(); scriptArchData.setChanged(false); Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesControl.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -24,7 +24,6 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; import java.awt.Frame; -import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; @@ -58,11 +57,11 @@ private static final long serialVersionUID = 1L; /* Build Panel */ - public GameObjectAttributesControl(@NotNull final GameObjectAttributesModel<GameObject, MapArchObject, Archetype>gameObjectAttributesModel, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @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) { + 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 MsgTextTab<GameObject, MapArchObject, Archetype>(gameObjectAttributesModel)); - addTab(new ScriptTab<GameObject, MapArchObject, Archetype>(parent, mainControl, 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)); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -35,7 +35,6 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; @@ -108,7 +107,7 @@ */ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings) { this.globalSettings = globalSettings; - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory); + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, globalSettings); editTypes = new EditTypes<G, A, R, V>(tmpMapManager); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; @@ -132,22 +131,6 @@ } - /** {@inheritDoc} */ - public File getLocalMapDir() { - final MapControl<G, A, R, V> mapControl = mapManager.getCurrentMap(); - if (mapControl == null) { - return globalSettings.getMapDir(); - } - - final File mapFile = mapControl.getMapFile(); - if (mapFile == null) { - ACTION_FACTORY.showMessageDialog(getMainView(), "createNewEventNoMapPath"); - return globalSettings.getMapDir(); - } - - return mapFile.getParentFile(); - } - public static String getBuildNumberAsString() { try { return ResourceBundle.getBundle("build").getString("build.number"); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -58,6 +58,12 @@ private final MainControl<G, A, R, V> mainControl; /** + * The global settings instance. + */ + @NotNull + private final GlobalSettings globalSettings; + + /** * The gridarta objects factory instance. */ @NotNull @@ -84,8 +90,10 @@ * @param mainControl the main control * @param key The action factory key. * @param gridartaObjectsFactory the gridarta objects factory instance + * @param globalSettings the global settings instance */ - public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory) { + public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final GlobalSettings globalSettings) { + this.globalSettings = globalSettings; actionFactory = ActionFactory.getFactory(key); this.mainControl = mainControl; this.gridartaObjectsFactory = gridartaObjectsFactory; @@ -462,4 +470,20 @@ } } + /** {@inheritDoc} */ + public File getLocalMapDir() { + final MapControl<G, A, R, V> mapControl = currentMap; + if (mapControl == null) { + return globalSettings.getMapDir(); + } + + final File mapFile = mapControl.getMapFile(); + if (mapFile == null) { + actionFactory.showMessageDialog(mainControl.getMainView(), "createNewEventNoMapPath"); + return globalSettings.getMapDir(); + } + + return mapFile.getParentFile(); + } + } // class DefaultMapManager Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -19,7 +19,6 @@ package net.sf.gridarta; -import java.io.File; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainView; @@ -101,10 +100,4 @@ */ ObjectChooser<G, A, R> getObjectChooser(); - /** - * Returns a guess for a script directory to use. - * @return the directory - */ - File getLocalMapDir(); - } // interface MainControl Modified: trunk/src/app/net/sf/gridarta/MapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/MapManager.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -193,4 +193,10 @@ */ void revert(MapControl<G, A, R, V> mapControl); + /** + * Returns a guess for a script directory to use. + * @return the directory + */ + File getLocalMapDir(); + } // interface MapManager Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -24,7 +24,7 @@ import java.util.Map; import java.util.regex.Pattern; import javax.swing.JList; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.match.GameObjectMatchers; @@ -1364,11 +1364,11 @@ * @param eventList JList from the MapArchPanel (script tab) which displays * the events * @param mapanel the MapArchPanel - * @param mainControl the main control instance + * @param mapManager the map manager instance * @param parent the parent frame for dialog boxes * @xxx this method knows things it should never know, it is evil! */ - public abstract void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent); + public abstract void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<G, A, R> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent); /** * A popup is opened and the user can create a new scripting event which Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -39,7 +39,7 @@ import javax.swing.WindowConstants; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.GlobalSettings; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.GameObject; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -59,8 +59,11 @@ @NotNull private static GlobalSettings globalSettings; + /** + * The map manager instance to use. + */ @NotNull - private static MainControl<?, ?, ?, ?> mainControl; + private static MapManager<?, ?, ?, ?> mapManager; protected static JComboBox pluginNameBox; @@ -85,8 +88,9 @@ * @param name the default event type * @param eventTypeBox the <code>JComboBox</code> containing all event * types + * @param mapManager the map manager instance to use */ - public static synchronized void initEventTypeBoxes(final String scriptEnding, final String name, final JComboBox eventTypeBox, @NotNull final FileFilter scriptFileFilter, @NotNull final GlobalSettings globalSettings, @NotNull final MainControl<?, ?, ?, ?> mainControl) { + public static synchronized void initEventTypeBoxes(final String scriptEnding, final String name, final JComboBox eventTypeBox, @NotNull final FileFilter scriptFileFilter, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<?, ?, ?, ?> mapManager) { AbstractScriptArchEditor.scriptEnding = scriptEnding; pluginNameBox = new JComboBox(new String[] {name}); @@ -95,7 +99,7 @@ AbstractScriptArchEditor.eventTypeBox = eventTypeBox; AbstractScriptArchEditor.scriptFileFilter = scriptFileFilter; AbstractScriptArchEditor.globalSettings = globalSettings; - AbstractScriptArchEditor.mainControl = mainControl; + AbstractScriptArchEditor.mapManager = mapManager; } /** @@ -109,7 +113,7 @@ public static <G extends GameObject<G, ?, ?>> void addEventScript(final G gameObject, final ScriptArchData<G> scriptArchData, @NotNull final Frame parent) { final String archName = gameObject.getBestName(); // create a reasonable default script name for lazy users :-) - final String defScriptName = ScriptUtils.chooseDefaultScriptName(mainControl.getLocalMapDir(), archName, scriptEnding); + final String defScriptName = ScriptUtils.chooseDefaultScriptName(mapManager.getLocalMapDir(), archName, scriptEnding); if (newScriptFrame == null) { // initialize popup frame @@ -153,7 +157,7 @@ browseb.setMargin(new Insets(0, 10, 0, 10)); browseb.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { - final File home = mainControl.getLocalMapDir(); + final File home = mapManager.getLocalMapDir(); final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Select Script File"); @@ -165,7 +169,7 @@ if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { // user has selected a file final File f = fileChooser.getSelectedFile(); - inputScriptPath.setText(ScriptUtils.localizeEventPath(mainControl.getLocalMapDir(), f, new File(globalSettings.getMapDefaultFolder()))); + inputScriptPath.setText(ScriptUtils.localizeEventPath(mapManager.getLocalMapDir(), f, new File(globalSettings.getMapDefaultFolder()))); } } }); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEventEditor.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -33,7 +33,7 @@ import javax.swing.JTextField; import javax.swing.WindowConstants; import net.sf.gridarta.GlobalSettings; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -78,11 +78,11 @@ /** * Opens the script pad to display a script. - * @param mainControl the main control instance + * @param mapManager the map manager instance * @param scriptPath the script path * @param parent the parent component for dialog boxes */ - public static void openScript(@NotNull final MainControl<?, ?, ?, ?> mainControl, final String scriptPath, @NotNull final Component parent) { + public static void openScript(@NotNull final MapManager<?, ?, ?, ?> mapManager, final String scriptPath, @NotNull final Component parent) { // trying to get the absolute path to scriptfile: final StringBuilder tmpPath = new StringBuilder(); if (scriptPath.startsWith("/")) { @@ -91,7 +91,7 @@ tmpPath.append(scriptPath); } else { // file path is relative to map dir - final String mapPath = mainControl.getLocalMapDir().getAbsolutePath(); + final String mapPath = mapManager.getLocalMapDir().getAbsolutePath(); tmpPath.append(mapPath); if (!mapPath.endsWith("/")) { tmpPath.append('/'); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ScriptTab.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -12,7 +12,7 @@ import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; import javax.swing.border.EtchedBorder; -import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -46,10 +46,10 @@ private final Frame parent; /** - * The main control. + * The map manager. */ @NotNull - private final MainControl<G, A, R, ?> mainControl; + private final MapManager<G, A, R, ?> mapManager; private final Action aScriptAddNew = ACTION_FACTORY.createAction(false, "scriptAddNew", this); @@ -70,13 +70,13 @@ /** * Creates a new instance. * @param parent the parent frame for dialog boxes - * @param mainControl the main control + * @param mapManager the map manager * @param gameObjectAttributesModel the model to track */ - public ScriptTab(@NotNull final Frame parent, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { + public ScriptTab(@NotNull final Frame parent, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel) { super(gameObjectAttributesModel); this.parent = parent; - this.mainControl = mainControl; + this.mapManager = mapManager; refresh(gameObjectAttributesModel.getSelectedGameObject()); } @@ -203,7 +203,7 @@ final MapSquare<G, A, R> mapSquare = selectedGameObject.getMapSquare(); assert mapSquare != null; mapSquare.getMapModel().beginTransaction("Modify event script"); - selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mainControl, parent); + selectedGameObject.getHead().modifyEventScript(index, task, eventList, this, mapManager, parent); mapSquare.getMapModel().endTransaction(); } } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-13 23:03:50 UTC (rev 4827) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-15 12:28:45 UTC (rev 4828) @@ -386,7 +386,7 @@ final TestMapArchObject mapArchObject = new TestMapArchObject(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); - final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", gridartaObjectsFactory); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", gridartaObjectsFactory, globalSettings); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); @@ -785,7 +785,7 @@ } /** {@inheritDoc} */ - public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<TestGameObject, TestMapArchObject, TestArchetype> mapanel, @NotNull final MainControl<?, ?, ?, ?> mainControl, @NotNull final Frame parent) { + public void modifyEventScript(final int eventType, final int task, @NotNull final JList eventList, @NotNull final ScriptTab<TestGameObject, TestMapArchObject, TestArchetype> mapanel, @NotNull final MapManager<?, ?, ?, ?> mapManager, @NotNull final Frame parent) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |