From: <aki...@us...> - 2010-06-23 19:28:55
|
Revision: 8418 http://gridarta.svn.sourceforge.net/gridarta/?rev=8418&view=rev Author: akirschbaum Date: 2010-06-23 19:28:49 +0000 (Wed, 23 Jun 2010) Log Message: ----------- Make --script command line option work in headless mode. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-23 19:22:16 UTC (rev 8417) +++ trunk/atrinik/ChangeLog 2010-06-23 19:28:49 UTC (rev 8418) @@ -1,3 +1,7 @@ +2010-06-23 Andreas Kirschbaum + + * Make --script command line option work in headless mode. + 2010-06-22 Andreas Kirschbaum * Improve CTRL-ALT-E (toggle game object text editor): do not Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-23 19:22:16 UTC (rev 8417) +++ trunk/crossfire/ChangeLog 2010-06-23 19:28:49 UTC (rev 8418) @@ -1,3 +1,7 @@ +2010-06-23 Andreas Kirschbaum + + * Make --script command line option work in headless mode. + 2010-06-22 Andreas Kirschbaum * Improve CTRL-ALT-E (toggle game object text editor): do not Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-23 19:22:16 UTC (rev 8417) +++ trunk/daimonin/ChangeLog 2010-06-23 19:28:49 UTC (rev 8418) @@ -1,3 +1,7 @@ +2010-06-23 Andreas Kirschbaum + + * Make --script command line option work in headless mode. + 2010-06-22 Andreas Kirschbaum * Improve CTRL-ALT-E (toggle game object text editor): do not Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-23 19:22:16 UTC (rev 8417) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-23 19:28:49 UTC (rev 8418) @@ -21,6 +21,7 @@ import gnu.getopt.Getopt; import gnu.getopt.LongOpt; +import java.awt.GraphicsEnvironment; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; @@ -218,7 +219,7 @@ } // Create the application and give it the parameters - final ErrorView errorView = mode.isConsoleMode() ? new ConsoleErrorView() : new DefaultErrorView(null); + final ErrorView errorView = GraphicsEnvironment.isHeadless() || mode.isConsoleMode() ? new ConsoleErrorView() : new DefaultErrorView(null); final GUIUtils guiUtils = new GUIUtils(); final SystemIcons systemIcons = new SystemIcons(guiUtils); final ConfigSourceFactory configSourceFactory = new DefaultConfigSourceFactory(); @@ -286,7 +287,7 @@ final ScriptExecutor<G, A, R> scriptExecutor = new ScriptExecutor<G, A, R>(scriptModel, scriptParameters); if (script != null) { - returnCode = runScript(script, editorFactory, mainControl, errorView, args2, guiUtils, configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, mapManager, pickmapManager, mapControlFactory, archetypeSet, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, scriptModel, animationObjects, archetypeChooserModel, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + returnCode = runScript(script, errorView, args2, scriptExecutor); } else { try { switch (mode) { @@ -333,69 +334,13 @@ /** * Executes a plugin script. - * @param mainControl the main control to use * @param script the name of the script to run - * @param editorFactory the editor factory to use * @param errorView the error view to add errors to * @param args2 the arguments for the script - * @param guiUtils the gui utils to use - * @param configSourceFactory the config source factory to use - * @param rendererFactory the renderer factory to use - * @param filterControl the filter control to use * @param scriptExecutor the script executor to use - * @param scriptParameters the script parameters to use - * @param mapManager the map manager to use - * @param pickmapManager the pickmap manager to use - * @param mapControlFactory the map control factory to use - * @param archetypeSet the archetype set - * @param faceObjects the face objects - * @param globalSettings the global settings - * @param mapViewSettings the map view settings - * @param faceObjectProviders the face object providers - * @param pathManager the path manager - * @param topmostInsertionMode the "topmost" insertion mode - * @param gameObjectFactory the game object factory - * @param systemIcons the system icons for creating icons - * @param archetypeTypeSet the archetype type set - * @param mapArchObjectFactory the map arch object factory to use - * @param mapReaderFactory the map reader factory to use - * @param validators the map validators - * @param gameObjectMatchers the game object matchers - * @param scriptModel the script model - * @param animationObjects the animation objects - * @param archetypeChooserModel the archetype chooser model - * @param scriptedEventEditor the scripted event editor - * @param resources the resources - * @param numberSpells the number spells to use - * @param gameObjectSpells the game object spells to use - * @param attributeRangeChecker the attribute range checker to use - * @param pluginParameterFactory the plugin parameter factory to use * @return return code suitable for passing to {@link System#exit(int)} */ - private int runScript(@NotNull final String script, final EditorFactory<G, A, R> editorFactory, final DefaultMainControl<G, A, R> mainControl, final ErrorView errorView, final List<String> args2, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final ScriptExecutor<G, A, R> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager, @NotNull final MapControlFactory<G, A, R> mapControlFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<G, A, R> topmostInsertionMode, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<G, A, R> mapReaderFactory, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { - final GUIMainControl<G, A, R>[] tmp2 = (GUIMainControl<G, A, R>[]) new GUIMainControl<?, ?, ?>[1]; - final Runnable runnable2 = new Runnable() { - - /** {@inheritDoc} */ - @Override - public void run() { - tmp2[0] = editorFactory.createGUIMainControl(mainControl, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, mapManager, pickmapManager, mapControlFactory, archetypeSet, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, scriptModel, animationObjects, archetypeChooserModel, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); - } - - }; - try { - SwingUtilities.invokeAndWait(runnable2); - } catch (final InterruptedException ex) { - log.fatal(ex.getMessage(), ex); - Thread.currentThread().interrupt(); - return 1; - } catch (final InvocationTargetException ex) { - log.fatal(ex.getMessage(), ex); - return 1; - } - assert tmp2[0] != null; - final GUIMainControl<G, A, R> guiMainControl = tmp2[0]; - + private int runScript(@NotNull final String script, final ErrorView errorView, final List<String> args2, @NotNull final ScriptExecutor<G, A, R> scriptExecutor) { checkForErrors(errorView); waitDialog(errorView); @@ -406,12 +351,8 @@ /** {@inheritDoc} */ @Override public void run() { - try { - final Command command = new ScriptCommand(script2, args2, guiMainControl.getScriptExecutor()); - tmp[0] = command.execute(); - } finally { - guiMainControl.getExiter().doExit(tmp[0]); - } + final Command command = new ScriptCommand(script2, args2, scriptExecutor); + tmp[0] = command.execute(); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |