From: <aki...@us...> - 2007-01-07 11:49:52
|
Revision: 1484 http://svn.sourceforge.net/gridarta/?rev=1484&view=rev Author: akirschbaum Date: 2007-01-07 03:49:52 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Unify GUI code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 11:24:59 UTC (rev 1483) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 11:49:52 UTC (rev 1484) @@ -273,8 +273,7 @@ if (task == GameObjectAttributesPanel.SCRIPT_OPEN) { event.openScript(); } else if (task == GameObjectAttributesPanel.SCRIPT_EDIT_PATH) { - // show popup to edit file path and plugin name - event.editScriptPath(); + event.editParameters(); eventList.set(index, event); // save changes } else if (task == GameObjectAttributesPanel.SCRIPT_REMOVE) { // first ask for confirmation @@ -386,14 +385,14 @@ // event type mainPanel.add(Box.createVerticalStrut(10)); final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JLabel tlabel1 = new JLabel("Event Type: "); + final JLabel tlabel1 = new JLabel("Event type:"); line2.add(tlabel1); line2.add(eventTypeBox); //mainPanel.add(line2); line2.add(Box.createHorizontalStrut(10)); // plugin name - final JLabel tlabel2 = new JLabel("Plugin: "); + final JLabel tlabel2 = new JLabel("Plugin:"); line2.add(tlabel2); line2.add(pluginNameBox); mainPanel.add(line2); @@ -401,13 +400,8 @@ // path mainPanel.add(Box.createVerticalStrut(5)); final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JLabel tlabel3 = new JLabel("Script File:"); + final JLabel tlabel3 = new JLabel("Script file:"); line3.add(tlabel3); - final int diff = tlabel1.getPreferredSize().width - tlabel3.getPreferredSize().width - 5; - if (diff > 0) { - line3.add(Box.createHorizontalStrut(diff)); - } - mainPanel.add(line3); inputScriptPath = new JTextField(defScriptName, 20); final JButton browseb = new JButton("..."); @@ -434,24 +428,23 @@ line3.add(browseb); mainPanel.add(line3); - // description + // options + mainPanel.add(Box.createVerticalStrut(5)); final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); + line4.add(new JLabel("Script options:")); + inputOptions = new JTextField("", 20); + line4.add(inputOptions); + mainPanel.add(line4); + + // description + final JPanel line5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); final JPanel textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS)); final JLabel tlabel4 = new JLabel("When you specify an existing file, the new event will be linked"); textPanel.add(tlabel4); final JLabel tlabel5 = new JLabel("to that existing script. Otherwise a new script file is created."); textPanel.add(tlabel5); - line4.add(textPanel); - mainPanel.add(line4); - - // event options input - mainPanel.add(Box.createVerticalStrut(10)); - final JPanel line5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JLabel tlabel6 = new JLabel("Event Options: "); - line5.add(tlabel6); - inputOptions = new JTextField(25); - line5.add(inputOptions); + line5.add(textPanel); mainPanel.add(line5); // button panel: Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 11:24:59 UTC (rev 1483) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 11:49:52 UTC (rev 1484) @@ -174,7 +174,7 @@ * Edit path and plugin name for this event. A popup dialog is shown * with input textfields for file path and plugin name. */ - public void editScriptPath() { + public void editParameters() { if (pathFrame == null) { // initialize popup frame pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Edit Parameters", true); @@ -192,22 +192,22 @@ line1.add(inputScriptPath); mainPanel.add(line1); - // input line: plugin name + // input line: plugin options final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text2 = new JLabel("Plugin name:"); + final JLabel text2 = new JLabel("Event options:"); line2.add(text2); - inputPluginName = new JTextField(getPluginName(), 20); - line2.add(inputPluginName); + inputOptions = new JTextField(getOptions(), 20); + line2.add(inputOptions); mainPanel.add(line2); + mainPanel.add(Box.createVerticalStrut(5)); - // input line: plugin options + // input line: plugin name final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text3 = new JLabel("Event options:"); + final JLabel text3 = new JLabel("Plugin name:"); line3.add(text3); - inputOptions = new JTextField(getOptions(), 20); - line3.add(inputOptions); + inputPluginName = new JTextField(getPluginName(), 20); + line3.add(inputPluginName); mainPanel.add(line3); - mainPanel.add(Box.createVerticalStrut(5)); // button panel: final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 11:24:59 UTC (rev 1483) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 11:49:52 UTC (rev 1484) @@ -208,8 +208,7 @@ if (task == GameObjectAttributesPanel.SCRIPT_OPEN) { event.openScript(); } else if (task == GameObjectAttributesPanel.SCRIPT_EDIT_PATH) { - // show popup to edit file path and plugin name - event.editScriptPath(); + event.editParameters(); } else if (task == GameObjectAttributesPanel.SCRIPT_REMOVE) { // first ask for confirmation //boolean breakpath = (event.getScriptPath().length() > 15); @@ -335,14 +334,14 @@ // event type mainPanel.add(Box.createVerticalStrut(10)); final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JLabel tlabel1 = new JLabel("Event Type: "); + final JLabel tlabel1 = new JLabel("Event type:"); line2.add(tlabel1); line2.add(eventTypeBox); //mainPanel.add(line2); line2.add(Box.createHorizontalStrut(10)); // plugin name - final JLabel tlabel2 = new JLabel("Plugin: "); + final JLabel tlabel2 = new JLabel("Plugin:"); line2.add(tlabel2); line2.add(pluginNameBox); mainPanel.add(line2); @@ -350,7 +349,7 @@ // path mainPanel.add(Box.createVerticalStrut(5)); final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JLabel tlabel3 = new JLabel("Script File:"); + final JLabel tlabel3 = new JLabel("Script file:"); line3.add(tlabel3); mainPanel.add(line3); inputScriptPath = new JTextField(defScriptName, 20); @@ -381,7 +380,7 @@ // options mainPanel.add(Box.createVerticalStrut(5)); final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - line4.add(new JLabel("Script Options:")); + line4.add(new JLabel("Script options:")); inputOptions = new JTextField("", 20); line4.add(inputOptions); mainPanel.add(line4); @@ -418,6 +417,7 @@ // just set fields and show nsHeading.setText("New scripted event for \"" + archName + "\":"); inputScriptPath.setText(defScriptName); + inputOptions.setText(""); nsOkListener.setScriptArchData(this); newScriptFrame.toFront(); newScriptFrame.setVisible(true); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 11:24:59 UTC (rev 1483) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 11:49:52 UTC (rev 1484) @@ -149,10 +149,10 @@ * Edit path and plugin name for this event. A popup dialog is shown * with input textfields for file path and plugin name. */ - public void editScriptPath() { + public void editParameters() { if (pathFrame == null) { // initialize popup frame - pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Script Path", true); + pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Edit Parameters", true); pathFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); final JPanel mainPanel = new JPanel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 12:24:14
|
Revision: 1485 http://svn.sourceforge.net/gridarta/?rev=1485&view=rev Author: akirschbaum Date: 2007-01-07 04:24:14 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fix #1497857 (Creating a new Script for unsaved map throws NPE). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/crossfire/src/cfeditor/messages_de.properties trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/messages.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/crossfire/ChangeLog 2007-01-07 12:24:14 UTC (rev 1485) @@ -1,3 +1,7 @@ +2007-01-07 Andreas Kirschbaum + + * Fix #1497857 (Creating a new Script for unsaved map throws NPE). + 2007-01-06 Andreas Kirschbaum * Add "move to top" and "move to bottom" buttons to map tile Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 12:24:14 UTC (rev 1485) @@ -1699,6 +1699,14 @@ } /** + * Get the map directory. + * @return map directory + */ + public File getMapDir() { + return mapDir; + } + + /** * Shows the given message in the UI. * @param strTitle The title of the message. * @param strMessage The message to be shown. Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:24:14 UTC (rev 1485) @@ -27,6 +27,7 @@ import cfeditor.CMainControl; import cfeditor.gameobject.GameObject; import cfeditor.gui.GameObjectAttributesPanel; +import cfeditor.map.MapControl; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Insets; @@ -322,7 +323,7 @@ */ private static String localizeEventPath(final File f) { final CMainControl mainControl = CMainControl.getInstance(); // main control - final File localMapDir = mainControl.getCurrentMap().getMapFile().getParentFile(); // local map directory + final File localMapDir = getLocalMapDir(); final File mapDir = new File(mainControl.getMapDefaultFolder()); // global map directory if (!mapDir.exists()) { @@ -408,7 +409,7 @@ browseb.setMargin(new Insets(0, 10, 0, 10)); browseb.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { - final File home = CMainControl.getInstance().getCurrentMap().getMapFile().getParentFile(); // map dir + final File home = getLocalMapDir(); final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Select Script File"); @@ -486,7 +487,7 @@ final String pluginName = ((String) (pluginNameBox.getSelectedItem())).trim(); final String options = inputOptions.getText().trim(); - final File localMapDir = mainControl.getCurrentMap().getMapFile().getParentFile(); // local map directory + final File localMapDir = getLocalMapDir(); // first check if that event type is not already in use final int replaceIndex = getScriptedEvent(eventType); @@ -583,4 +584,26 @@ return eventList == null || eventList.isEmpty(); } + /** + * Return a guess for the directory to use. + * + * @return the directory to use + */ + static File getLocalMapDir() { + final CMainControl mainControl = CMainControl.getInstance(); + + final MapControl mapControl = mainControl.getCurrentMap(); + if (mapControl == null) { + return mainControl.getMapDir(); + } + + final File mapFile = mapControl.getMapFile(); + if (mapFile == null) { + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "createNewEventNoMapPath"); + return mainControl.getMapDir(); + } + + return mapFile.getParentFile(); + } + } // class ScriptArchData Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 12:24:14 UTC (rev 1485) @@ -152,7 +152,7 @@ path += scriptPath; } else { // file path is relative to map dir - path = mainControl.getCurrentMap().getMapFile().getParentFile().getAbsolutePath(); // map dir + path = ScriptArchData.getLocalMapDir().getAbsolutePath(); if (!path.endsWith("/")) { path += '/'; // append slash to map dir } Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-07 12:24:14 UTC (rev 1485) @@ -78,6 +78,9 @@ importSpellsFailed.title=Zauberspr\xFCche sammeln importSpellsFailed.message=Das Sammeln der Zauberspr\xFCche ist fehlgeschlagen.\nEvtl. ist das Dateiformat falsch? +createNewEventNoMapPath.title=Kann Script-Pfad nicht ermitteln +createNewEventNoMapPath.message=Kann Script-Pfad nicht ermitteln, da die Karte noch nicht gespeichert ist. + openScriptNotFound.title=Script-Datei nicht gefunden openScriptNotFound.message=Die Datei ''{0}'' existiert nicht.\nBitte geben sie einen g\xFCltigen Dateinamen an. Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:24:14 UTC (rev 1485) @@ -27,6 +27,7 @@ import daieditor.CMainControl; import daieditor.gameobject.GameObject; import daieditor.gui.GameObjectAttributesPanel; +import daieditor.map.MapControl; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Insets; @@ -246,8 +247,8 @@ defScriptName += "Script.lua"; try { - return PathManager.getMapPath(new File(CMainControl.getInstance().getCurrentMap().getMapFile().getParent(), defScriptName).getPath()); - } catch (final Exception e) { + return PathManager.getMapPath(new File(getLocalMapDir(), defScriptName).getPath()); + } catch (final IOException e) { return defScriptName; } } @@ -261,7 +262,7 @@ */ private static String localizeEventPath(final File f) { final CMainControl mainControl = CMainControl.getInstance(); // main control - final File localMapDir = mainControl.getCurrentMap().getMapFile().getParentFile(); // local map directory + final File localMapDir = getLocalMapDir(); final File mapDir = new File(mainControl.getMapDefaultFolder()); // global map directory if (!mapDir.exists()) { @@ -357,7 +358,7 @@ browseb.setMargin(new Insets(0, 10, 0, 10)); browseb.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { - final File home = CMainControl.getInstance().getCurrentMap().getMapFile().getParentFile(); // map dir + final File home = getLocalMapDir(); final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Select Script File"); @@ -436,13 +437,7 @@ final int eventType = eventTypeBox.getSelectedIndex() + 1; final String pluginName = ((String) pluginNameBox.getSelectedItem()).trim(); - File localMapDir; - try { - localMapDir = mainControl.getCurrentMap().getMapFile().getParentFile(); // local map directory - } catch (final NullPointerException e) { - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "createNewEventException"); - localMapDir = mainControl.getMapDir(); - } + File localMapDir = getLocalMapDir(); changed = false; @@ -552,4 +547,26 @@ } } + /** + * Return a guess for the directory to use. + * + * @return the directory to use + */ + static File getLocalMapDir() { + final CMainControl mainControl = CMainControl.getInstance(); + + final MapControl mapControl = mainControl.getCurrentMap(); + if (mapControl == null) { + return mainControl.getMapDir(); + } + + final File mapFile = mapControl.getMapFile(); + if (mapFile == null) { + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "createNewEventNoMapPath"); + return mainControl.getMapDir(); + } + + return mapFile.getParentFile(); + } + } // class ScriptArchData Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 12:24:14 UTC (rev 1485) @@ -127,7 +127,7 @@ path += scriptPath; } else { // file path is relative to map dir - path = mainControl.getCurrentMap().getMapFile().getParentFile().getAbsolutePath(); // map dir + path = ScriptArchData.getLocalMapDir().getAbsolutePath(); if (!path.endsWith("/")) { path += '/'; // append slash to map dir } Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/daimonin/src/daieditor/messages.properties 2007-01-07 12:24:14 UTC (rev 1485) @@ -79,8 +79,6 @@ importSpellsFailed.message=Collecting spells failed!\nMaybe the specified file is of wrong format. loadArchesNoArchfiles.title=No archfiles loadArchesNoArchfiles.message=No archfiles could be found. If you have no archfiles\nyet, you need to download them. If you do, make sure\nthe path is correct under menu ''File->Options''. -createNewEventException.title=Can''t create script path -createNewEventException.message=Can''t create script path from map. Perhaps you should save your map first. openScriptNotFound.title=Script file not found openScriptNotFound.message=The file ''{0}'' does not exist.\nPlease correct the path. newMapDifficultyNotANumber.title=Illegal value Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2007-01-07 12:24:14 UTC (rev 1485) @@ -121,8 +121,8 @@ importSpellsFailed.message=Sammanst\xE4llning av trollformler misslyckades.\nVar den angivna filen inte av r\xE4tt format? loadArchesNoArchfiles.title=Inga arketypfiler loadArchesNoArchfiles.message=Inga arketypfiler kunde hittas. Om du saknar arketypfiler\n m\xE5ste du ladda hem dom. Om du g\xF6r detta, se till\natt s\xF6kv\xE4gen under ''Arkiv->Inst\xE4llningar'' \xE4r korrekt. -createNewEventException.title=Kan inte skapa s\xF6kv\xE4g f\xF6r script -createNewEventException.message=Kan inte utg\xE5 fr\xE5n kartans s\xF6kv\xE4g. Du kanske skall spara kartan f\xF6rst? +createNewEventNoMapPath.title=Kan inte skapa s\xF6kv\xE4g f\xF6r script +createNewEventNoMapPath.message=Kan inte utg\xE5 fr\xE5n kartans s\xF6kv\xE4g. Du kanske skall spara kartan f\xF6rst? openScriptNotFound.title=Kunde inte hitta scriptfil openScriptNotFound.message=Filen ''{0}'' finns inte.\nV\xE4r v\xE4nlig korrigera s\xF6kv\xE4gen. # New Map Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2007-01-07 11:49:52 UTC (rev 1484) +++ trunk/src/app/net/sf/gridarta/messages.properties 2007-01-07 12:24:14 UTC (rev 1485) @@ -107,6 +107,9 @@ confirmRevertPickmap.title=Revert pickmap? confirmRevertPickmap.message=If you revert the pickmap ''{0}''\n to its last saved state, all recent changes will be lost.\nDo you really want to revert this pickmap? +createNewEventNoMapPath.title=Can''t create script path +createNewEventNoMapPath.message=Can''t create script path from map. Perhaps you should save your map first. + # Map Properties mapTitle={0} ({1}) - Map Properties mapHelp.text=Help This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 12:40:23
|
Revision: 1486 http://svn.sourceforge.net/gridarta/?rev=1486&view=rev Author: akirschbaum Date: 2007-01-07 04:40:23 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fix #1613729 (Monsters appear as "weak wall (0)"). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2007-01-07 12:24:14 UTC (rev 1485) +++ trunk/crossfire/ChangeLog 2007-01-07 12:40:23 UTC (rev 1486) @@ -1,5 +1,8 @@ 2007-01-07 Andreas Kirschbaum + * Fix #1613729 (Monsters appear as "weak wall (0)"). (Previous fix + did miss the game object attributes panel.) + * Fix #1497857 (Creating a new Script for unsaved map throws NPE). 2007-01-06 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-07 12:24:14 UTC (rev 1485) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-07 12:40:23 UTC (rev 1486) @@ -60,6 +60,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.CFArchType; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.japi.swing.ActionFactory; @@ -752,7 +753,8 @@ final StringBuilder typeText = new StringBuilder(); if (archetype != null) { - typeText.append("Type: ").append(mainControl.getTypeList().getArchTypeName(gameObject.getArchTypNr())).append(" (").append(gameObject.getArchTypNr()).append(") [").append(gameObject.getArchetypeName()).append(']'); + final CFArchType archType = mainControl.getTypeList().getType(gameObject); + typeText.append("Type: ").append(archType.getTypeName()).append(" (").append(archType.getTypeNr()).append(") [").append(gameObject.getArchetypeName()).append(']'); } else { typeText.append("Type: <unknown>"); } Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2007-01-07 12:24:14 UTC (rev 1485) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2007-01-07 12:40:23 UTC (rev 1486) @@ -62,6 +62,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.CFArchType; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.connectionview.ConnectionControl; import net.sf.japi.swing.ActionFactory; @@ -875,7 +876,8 @@ final StringBuilder typeText = new StringBuilder(); if (archetype != null) { - typeText.append("Type: ").append(mainControl.getTypeList().getArchTypeName(gameObject.getArchTypNr())).append(" (").append(gameObject.getArchTypNr()).append(") [").append(gameObject.getArchetypeName()).append(']'); + final CFArchType archType = mainControl.getTypeList().getType(gameObject); + typeText.append("Type: ").append(archType.getTypeName()).append(" (").append(archType.getTypeNr()).append(") [").append(gameObject.getArchetypeName()).append(']'); } else { typeText.append("Type: <unknown>"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 12:41:29
|
Revision: 1487 http://svn.sourceforge.net/gridarta/?rev=1487&view=rev Author: akirschbaum Date: 2007-01-07 04:41:29 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CFArchTypeList.java trunk/src/app/net/sf/gridarta/CFArchTypeList.java Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2007-01-07 12:40:23 UTC (rev 1486) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2007-01-07 12:41:29 UTC (rev 1487) @@ -193,11 +193,6 @@ } /** {@inheritDoc} */ - @Override public String getArchTypeName(final int typeNr) { - return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + "*"; - } - - /** {@inheritDoc} */ @Override public CFArchType getTypeByName(final String typeName) { // return: matching type or first type (misc) if no other found final CFArchType type = archTypeNames.get(typeName.trim()); Modified: trunk/daimonin/src/daieditor/CFArchTypeList.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchTypeList.java 2007-01-07 12:40:23 UTC (rev 1486) +++ trunk/daimonin/src/daieditor/CFArchTypeList.java 2007-01-07 12:41:29 UTC (rev 1487) @@ -226,11 +226,6 @@ } /** {@inheritDoc} */ - @Override public String getArchTypeName(final int typeNr) { - return archTypeNumbers.containsKey(typeNr) ? archTypeNumbers.get(typeNr) : "*UNKNOWN" + typeNr + "*"; - } - - /** {@inheritDoc} */ @Override public CFArchType getTypeByName(final String typeName) { // return: matching type or first type (misc) if no other found final CFArchType type = archTypeNames.get(typeName.trim()); Modified: trunk/src/app/net/sf/gridarta/CFArchTypeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2007-01-07 12:40:23 UTC (rev 1486) +++ trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2007-01-07 12:41:29 UTC (rev 1487) @@ -283,13 +283,6 @@ } /** - * Lookup the name of an archtype. - * @param typeNr type number - * @return name of this type, as defined in "typenumbers.xml" - */ - public abstract String getArchTypeName(final int typeNr); - - /** * Returns whether this typelist contains no data. * @return <code>true</code> if this typelist contains no data, otherwise <code>false</code>. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 12:43:33
|
Revision: 1488 http://svn.sourceforge.net/gridarta/?rev=1488&view=rev Author: akirschbaum Date: 2007-01-07 04:43:33 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Unify comment. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:41:29 UTC (rev 1487) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:43:33 UTC (rev 1488) @@ -552,6 +552,7 @@ // try to create new empty file couldCreateFile = newScriptFile.createNewFile(); } catch (final IOException e) { + /* ignore (really?) */ } if (couldCreateFile) { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:41:29 UTC (rev 1487) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:43:33 UTC (rev 1488) @@ -502,7 +502,9 @@ try { // try to create new empty file couldCreateFile = newScriptFile.createNewFile(); - } catch (final IOException e) { /* ignore (really?) */ } + } catch (final IOException e) { + /* ignore (really?) */ + } if (!couldCreateFile) { JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + "Please check your path and write premissions.", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 12:45:48
|
Revision: 1489 http://svn.sourceforge.net/gridarta/?rev=1489&view=rev Author: akirschbaum Date: 2007-01-07 04:45:49 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Unify whitespace. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:43:33 UTC (rev 1488) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:45:49 UTC (rev 1489) @@ -555,7 +555,9 @@ /* ignore (really?) */ } - if (couldCreateFile) { + if (!couldCreateFile) { + JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + "Please check your path and write premissions.", "Cannot create file", JOptionPane.ERROR_MESSAGE); + } else { // file has been created, now link it to the event final ScriptedEvent event = new ScriptedEvent(eventType, pluginName, scriptPath, options); if (replaceIndex != -1) { @@ -567,10 +569,6 @@ // open new script file ScriptEditControl.getInstance().openScriptFile(newScriptFile.getAbsolutePath()); - } else { - JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + - "Please check your path and write premissions.", - "Cannot create file", JOptionPane.ERROR_MESSAGE); } } } Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:43:33 UTC (rev 1488) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 12:45:49 UTC (rev 1489) @@ -507,8 +507,7 @@ } if (!couldCreateFile) { - JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + "Please check your path and write premissions.", - "Cannot create file", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(frame, "File '" + newScriptFile.getName() + "' could not be created.\n" + "Please check your path and write premissions.", "Cannot create file", JOptionPane.ERROR_MESSAGE); } else { // file has been created, now link it to the event final ScriptedEvent event = new ScriptedEvent(eventType, pluginName, scriptPath, options); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 12:47:11
|
Revision: 1490 http://svn.sourceforge.net/gridarta/?rev=1490&view=rev Author: akirschbaum Date: 2007-01-07 04:47:10 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java 2007-01-07 12:45:49 UTC (rev 1489) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java 2007-01-07 12:47:10 UTC (rev 1490) @@ -52,9 +52,9 @@ * @param scriptArchData this is only set for the ok-button of "create new" frame, otherwise null */ PathButtonListener(final boolean isOkButton, final JDialog frame, @Nullable final ScriptArchData scriptArchData) { - this.isOkButton = isOkButton; - this.frame = frame; - this.scriptArchData = scriptArchData; + this.isOkButton = isOkButton; + this.frame = frame; + this.scriptArchData = scriptArchData; } /** @@ -62,7 +62,7 @@ * @param scriptedEvent new target event to script. */ public void setTargetEvent(final ScriptedEvent scriptedEvent) { - this.scriptedEvent = scriptedEvent; + this.scriptedEvent = scriptedEvent; } /** @@ -70,21 +70,21 @@ * @param scriptArchData ScriptArchData to operate on. */ public void setScriptArchData(final ScriptArchData scriptArchData) { - this.scriptArchData = scriptArchData; + this.scriptArchData = scriptArchData; } /** {@inheritDoc} */ public void actionPerformed(final ActionEvent e) { - if (isOkButton && scriptArchData == null && scriptedEvent != null) { - scriptedEvent.modifyEventPath(); // ok button for modifying path - } + if (isOkButton && scriptArchData == null && scriptedEvent != null) { + scriptedEvent.modifyEventPath(); // ok button for modifying path + } - if (isOkButton && scriptArchData != null) { - // ok button for creating a new event/script - scriptArchData.createNewEvent(frame); - } else { - frame.setVisible(false); // hide dialog - } + if (isOkButton && scriptArchData != null) { + // ok button for creating a new event/script + scriptArchData.createNewEvent(frame); + } else { + frame.setVisible(false); // hide dialog + } } } // class PathButtonListener Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 12:45:49 UTC (rev 1489) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 12:47:10 UTC (rev 1490) @@ -71,9 +71,9 @@ * @param eventType Type of the event. */ ScriptedEvent(final String eventType) { - this.eventType = eventType; - pluginName = null; - scriptPath = null; + this.eventType = eventType; + pluginName = null; + scriptPath = null; } /** @@ -84,10 +84,10 @@ * @param options options for this event */ ScriptedEvent(final String eventType, final String pluginName, final String scriptPath, final String options) { - this.eventType = eventType; - this.pluginName = pluginName; - this.scriptPath = scriptPath; - this.options = options; + this.eventType = eventType; + this.pluginName = pluginName; + this.scriptPath = scriptPath; + this.options = options; } /** @@ -95,21 +95,21 @@ * @return true if this object is valid, otherwise false */ public boolean isValid() { - if (scriptPath == null || scriptPath.length() <= 0) { - log.error("Map Error: Found event_" + eventType + " without file name!"); - return false; - } + if (scriptPath == null || scriptPath.length() <= 0) { + log.error("Map Error: Found event_" + eventType + " without file name!"); + return false; + } - if (pluginName == null || pluginName.length() <= 0) { - pluginName = "Python"; - if (log.isInfoEnabled()) { - log.info("Found event_" + eventType + " without plugin name. Setting to \"Python\"."); - } - } + if (pluginName == null || pluginName.length() <= 0) { + pluginName = "Python"; + if (log.isInfoEnabled()) { + log.info("Found event_" + eventType + " without plugin name. Setting to \"Python\"."); + } + } - scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' + scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' - return true; + return true; } /** @@ -117,13 +117,13 @@ * @return Event text for the map file. */ public String getMapArchText() { - final StringBuilder buff = new StringBuilder(""); - buff.append("event_").append(eventType).append("_plugin ").append(pluginName).append("\n"); - buff.append("event_").append(eventType).append(" ").append(scriptPath).append("\n"); - if (options != null && options.trim().length() > 0) { - buff.append("event_").append(eventType).append("_options ").append(options).append("\n"); - } - return buff.toString(); + final StringBuilder buff = new StringBuilder(""); + buff.append("event_").append(eventType).append("_plugin ").append(pluginName).append("\n"); + buff.append("event_").append(eventType).append(" ").append(scriptPath).append("\n"); + if (options != null && options.trim().length() > 0) { + buff.append("event_").append(eventType).append("_options ").append(options).append("\n"); + } + return buff.toString(); } /** @@ -132,42 +132,42 @@ * @todo instead override {@link Object#clone()}. */ public ScriptedEvent getClone() { - final ScriptedEvent clone = new ScriptedEvent(eventType); - clone.pluginName = pluginName; - clone.scriptPath = scriptPath; - clone.options = options; + final ScriptedEvent clone = new ScriptedEvent(eventType); + clone.pluginName = pluginName; + clone.scriptPath = scriptPath; + clone.options = options; - return clone; + return clone; } /** Opens the script pad to display the script for this event. */ public void openScript() { - final CMainControl mainControl = CMainControl.getInstance(); // reference to main control + final CMainControl mainControl = CMainControl.getInstance(); // reference to main control - // trying to get the absolute path to scriptfile: - String path; - if (scriptPath.startsWith("/")) { - // filepath is absolue (to map base directory): - path = mainControl.getMapDefaultFolder(); - path += scriptPath; - } else { - // file path is relative to map dir - path = ScriptArchData.getLocalMapDir().getAbsolutePath(); - if (!path.endsWith("/")) { - path += '/'; // append slash to map dir - } - path += scriptPath; // append relative path to map dir - path = path.replace('\\', '/'); // make sure there's only one kind of slash - } + // trying to get the absolute path to scriptfile: + String path; + if (scriptPath.startsWith("/")) { + // filepath is absolue (to map base directory): + path = mainControl.getMapDefaultFolder(); + path += scriptPath; + } else { + // file path is relative to map dir + path = ScriptArchData.getLocalMapDir().getAbsolutePath(); + if (!path.endsWith("/")) { + path += '/'; // append slash to map dir + } + path += scriptPath; // append relative path to map dir + path = path.replace('\\', '/'); // make sure there's only one kind of slash + } - // now see if that file really exists: - final File scriptFile = new File(path); - if (scriptFile.exists() && scriptFile.isFile()) { - ScriptEditControl.getInstance().openScriptFile(scriptFile.getAbsolutePath()); - } else { - // file does not exist! - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "openScriptNotFound", path); - } + // now see if that file really exists: + final File scriptFile = new File(path); + if (scriptFile.exists() && scriptFile.isFile()) { + ScriptEditControl.getInstance().openScriptFile(scriptFile.getAbsolutePath()); + } else { + // file does not exist! + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "openScriptNotFound", path); + } } /** @@ -175,69 +175,69 @@ * with input textfields for file path and plugin name. */ public void editParameters() { - if (pathFrame == null) { - // initialize popup frame - pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Edit Parameters", true); - pathFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + if (pathFrame == null) { + // initialize popup frame + pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Edit Parameters", true); + pathFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); + final JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); - // input line: script path - final JPanel line1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text1 = new JLabel("Script:"); - line1.add(text1); - inputScriptPath = new JTextField(getScriptPath(), 20); - line1.add(inputScriptPath); - mainPanel.add(line1); + // input line: script path + final JPanel line1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JLabel text1 = new JLabel("Script:"); + line1.add(text1); + inputScriptPath = new JTextField(getScriptPath(), 20); + line1.add(inputScriptPath); + mainPanel.add(line1); - // input line: plugin options - final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text2 = new JLabel("Event options:"); - line2.add(text2); - inputOptions = new JTextField(getOptions(), 20); - line2.add(inputOptions); - mainPanel.add(line2); - mainPanel.add(Box.createVerticalStrut(5)); + // input line: plugin options + final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JLabel text2 = new JLabel("Event options:"); + line2.add(text2); + inputOptions = new JTextField(getOptions(), 20); + line2.add(inputOptions); + mainPanel.add(line2); + mainPanel.add(Box.createVerticalStrut(5)); - // input line: plugin name - final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text3 = new JLabel("Plugin name:"); - line3.add(text3); - inputPluginName = new JTextField(getPluginName(), 20); - line3.add(inputPluginName); - mainPanel.add(line3); + // input line: plugin name + final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JLabel text3 = new JLabel("Plugin name:"); + line3.add(text3); + inputPluginName = new JTextField(getPluginName(), 20); + line3.add(inputPluginName); + mainPanel.add(line3); - // button panel: - final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JButton okButton = new JButton("OK"); - okListener = new PathButtonListener(true, pathFrame, null); - okListener.setTargetEvent(this); - okButton.addActionListener(okListener); - line4.add(okButton); + // button panel: + final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JButton okButton = new JButton("OK"); + okListener = new PathButtonListener(true, pathFrame, null); + okListener.setTargetEvent(this); + okButton.addActionListener(okListener); + line4.add(okButton); - final JButton cancelButton = new JButton("Cancel"); - ccListener = new PathButtonListener(false, pathFrame, null); - ccListener.setTargetEvent(this); - cancelButton.addActionListener(ccListener); - line4.add(cancelButton); - mainPanel.add(line4); + final JButton cancelButton = new JButton("Cancel"); + ccListener = new PathButtonListener(false, pathFrame, null); + ccListener.setTargetEvent(this); + cancelButton.addActionListener(ccListener); + line4.add(cancelButton); + mainPanel.add(line4); - pathFrame.getContentPane().add(mainPanel); - pathFrame.pack(); - pathFrame.setLocationRelativeTo(CMainControl.getInstance().getMainView()); - pathFrame.setVisible(true); - } else { - // just set fields and show - okListener.setTargetEvent(this); - ccListener.setTargetEvent(this); - inputScriptPath.setText(getScriptPath()); - inputPluginName.setText(getPluginName()); - inputOptions.setText(getOptions()); - pathFrame.toFront(); - pathFrame.setVisible(true); - } + pathFrame.getContentPane().add(mainPanel); + pathFrame.pack(); + pathFrame.setLocationRelativeTo(CMainControl.getInstance().getMainView()); + pathFrame.setVisible(true); + } else { + // just set fields and show + okListener.setTargetEvent(this); + ccListener.setTargetEvent(this); + inputScriptPath.setText(getScriptPath()); + inputPluginName.setText(getPluginName()); + inputOptions.setText(getOptions()); + pathFrame.toFront(); + pathFrame.setVisible(true); + } } /** @@ -245,46 +245,46 @@ * dialog. */ public void modifyEventPath() { - final String newPath = inputScriptPath.getText().trim(); - final String newPluginName = inputPluginName.getText().trim(); - final String newOptions = inputOptions.getText().trim(); + final String newPath = inputScriptPath.getText().trim(); + final String newPluginName = inputPluginName.getText().trim(); + final String newOptions = inputOptions.getText().trim(); - if (newPath.length() > 0) { - setScriptPath(newPath); - } - if (newPluginName.length() > 0) { - setPluginName(newPluginName); - } - setOptions(newOptions); // unlike the above two, event options can be empty + if (newPath.length() > 0) { + setScriptPath(newPath); + } + if (newPluginName.length() > 0) { + setPluginName(newPluginName); + } + setOptions(newOptions); // unlike the above two, event options can be empty } // GET/SET methods public String getEventType() { - return eventType; + return eventType; } public String getPluginName() { - return pluginName; + return pluginName; } public String getScriptPath() { - return scriptPath; + return scriptPath; } public String getOptions() { - return options; + return options; } public void setPluginName(final String pluginName) { - this.pluginName = pluginName; + this.pluginName = pluginName; } public void setScriptPath(final String scriptPath) { - this.scriptPath = scriptPath; + this.scriptPath = scriptPath; } public void setOptions(final String options) { - this.options = options; + this.options = options; } public static JDialog getPathFrame() { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java 2007-01-07 12:45:49 UTC (rev 1489) +++ trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java 2007-01-07 12:47:10 UTC (rev 1490) @@ -52,9 +52,9 @@ * @param scriptArchData this is only set for the ok-button of "create new" frame, otherwise null */ PathButtonListener(final boolean isOkButton, final JDialog frame, @Nullable final ScriptArchData scriptArchData) { - this.isOkButton = isOkButton; - this.frame = frame; - this.scriptArchData = scriptArchData; + this.isOkButton = isOkButton; + this.frame = frame; + this.scriptArchData = scriptArchData; } /** @@ -62,7 +62,7 @@ * @param scriptedEvent new target event to script. */ public void setTargetEvent(final ScriptedEvent scriptedEvent) { - this.scriptedEvent = scriptedEvent; + this.scriptedEvent = scriptedEvent; } /** @@ -70,22 +70,22 @@ * @param scriptArchData ScriptArchData to operate on. */ public void setScriptArchData(final ScriptArchData scriptArchData) { - this.scriptArchData = scriptArchData; + this.scriptArchData = scriptArchData; } /** {@inheritDoc} */ public void actionPerformed(final ActionEvent e) { - if (isOkButton && scriptArchData == null && scriptedEvent != null) { - scriptedEvent.modifyEventPath(); // ok button for modifying path - } + if (isOkButton && scriptArchData == null && scriptedEvent != null) { + scriptedEvent.modifyEventPath(); // ok button for modifying path + } - if (isOkButton && scriptArchData != null) { - // ok button for creating a new event/script - scriptArchData.createNewEvent(frame); - scriptArchData.changed = true; - } else { - frame.setVisible(false); // hide dialog - } + if (isOkButton && scriptArchData != null) { + // ok button for creating a new event/script + scriptArchData.createNewEvent(frame); + scriptArchData.changed = true; + } else { + frame.setVisible(false); // hide dialog + } } } // class PathButtonListener Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 12:45:49 UTC (rev 1489) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 12:47:10 UTC (rev 1490) @@ -66,7 +66,7 @@ * @param event GameObject that describes the event. */ ScriptedEvent(final GameObject event) { - this.event = event; + this.event = event; } /** @@ -77,12 +77,12 @@ * @param options options for this event */ ScriptedEvent(final int eventType, final String pluginName, final String scriptPath, final String options) { - event = new GameObject(); // FIXME: This arch has no default arch - event.setArchTypNr(118); - event.setArchetypeName("event_obj"); - event.setArchetype(CMainControl.getInstance().getArchetypeSet().getArchetype("event_obj")); - event.setObjectFace(); - setEventData(eventType, pluginName, scriptPath, options); + event = new GameObject(); // FIXME: This arch has no default arch + event.setArchTypNr(118); + event.setArchetypeName("event_obj"); + event.setArchetype(CMainControl.getInstance().getArchetypeSet().getArchetype("event_obj")); + event.setObjectFace(); + setEventData(eventType, pluginName, scriptPath, options); } /** @@ -90,59 +90,59 @@ * @return true if this object is valid, otherwise false */ public boolean isValid() { - final String options = getOptions(); - String scriptPath = getScriptPath(); - String pluginName = getPluginName(); - final int eventType = getEventType(); + final String options = getOptions(); + String scriptPath = getScriptPath(); + String pluginName = getPluginName(); + final int eventType = getEventType(); - if (scriptPath == null || scriptPath.length() <= 0) { - log.error("Map Error: Found " + ScriptArchData.typeName(eventType) + " event without file name!"); - return false; - } + if (scriptPath == null || scriptPath.length() <= 0) { + log.error("Map Error: Found " + ScriptArchData.typeName(eventType) + " event without file name!"); + return false; + } - if (pluginName == null || pluginName.length() <= 0) { - pluginName = "Python"; - if (log.isInfoEnabled()) { - log.info("Found " + ScriptArchData.typeName(eventType) + " without plugin name. Setting to \"Python\"."); - } - } + if (pluginName == null || pluginName.length() <= 0) { + pluginName = "Python"; + if (log.isInfoEnabled()) { + log.info("Found " + ScriptArchData.typeName(eventType) + " without plugin name. Setting to \"Python\"."); + } + } - scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' + scriptPath = scriptPath.replace('\\', '/'); // just make sure there are only slashes: '/' - setEventData(eventType, pluginName, scriptPath, options); + setEventData(eventType, pluginName, scriptPath, options); - return true; + return true; } /** Opens the script pad to display the script for this event. */ public void openScript() { - final CMainControl mainControl = CMainControl.getInstance(); // reference to main control - final String scriptPath = getScriptPath(); + final CMainControl mainControl = CMainControl.getInstance(); // reference to main control + final String scriptPath = getScriptPath(); - // trying to get the absolute path to scriptfile: - String path; - if (scriptPath.startsWith("/")) { - // filepath is absolue (to map base directory): - path = mainControl.getMapDefaultFolder(); - path += scriptPath; - } else { - // file path is relative to map dir - path = ScriptArchData.getLocalMapDir().getAbsolutePath(); - if (!path.endsWith("/")) { - path += '/'; // append slash to map dir - } - path += scriptPath; // append relative path to map dir - path = path.replace('\\', '/'); // make sure there's only one kind of slash - } + // trying to get the absolute path to scriptfile: + String path; + if (scriptPath.startsWith("/")) { + // filepath is absolue (to map base directory): + path = mainControl.getMapDefaultFolder(); + path += scriptPath; + } else { + // file path is relative to map dir + path = ScriptArchData.getLocalMapDir().getAbsolutePath(); + if (!path.endsWith("/")) { + path += '/'; // append slash to map dir + } + path += scriptPath; // append relative path to map dir + path = path.replace('\\', '/'); // make sure there's only one kind of slash + } - // now see if that file really exists: - final File scriptFile = new File(path); - if (scriptFile.exists() && scriptFile.isFile()) { - ScriptEditControl.getInstance().openScriptFile(scriptFile.getAbsolutePath()); - } else { - // file does not exist! - ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "openScriptNotFound", path); - } + // now see if that file really exists: + final File scriptFile = new File(path); + if (scriptFile.exists() && scriptFile.isFile()) { + ScriptEditControl.getInstance().openScriptFile(scriptFile.getAbsolutePath()); + } else { + // file does not exist! + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "openScriptNotFound", path); + } } /** @@ -150,70 +150,70 @@ * with input textfields for file path and plugin name. */ public void editParameters() { - if (pathFrame == null) { - // initialize popup frame - pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Edit Parameters", true); - pathFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); + if (pathFrame == null) { + // initialize popup frame + pathFrame = new JDialog(CMainControl.getInstance().getMainView(), "Edit Parameters", true); + pathFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); + final JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); + mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 2, 5)); - // input line: script path - final JPanel line1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text1 = new JLabel("Script:"); - line1.add(text1); - inputScriptPath = new JTextField(getScriptPath(), 20); - line1.add(inputScriptPath); - mainPanel.add(line1); + // input line: script path + final JPanel line1 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JLabel text1 = new JLabel("Script:"); + line1.add(text1); + inputScriptPath = new JTextField(getScriptPath(), 20); + line1.add(inputScriptPath); + mainPanel.add(line1); - // input line: plugin options - final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text2 = new JLabel("Script options:"); - line2.add(text2); - inputOptions = new JTextField(getOptions(), 20); - line2.add(inputOptions); - mainPanel.add(line2); - mainPanel.add(Box.createVerticalStrut(5)); + // input line: plugin options + final JPanel line2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JLabel text2 = new JLabel("Script options:"); + line2.add(text2); + inputOptions = new JTextField(getOptions(), 20); + line2.add(inputOptions); + mainPanel.add(line2); + mainPanel.add(Box.createVerticalStrut(5)); - // input line: plugin name - final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JLabel text3 = new JLabel("Plugin name:"); - line3.add(text3); - inputPluginName = new JTextField(getPluginName(), 20); - line3.add(inputPluginName); - mainPanel.add(line3); - mainPanel.add(Box.createVerticalStrut(5)); + // input line: plugin name + final JPanel line3 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JLabel text3 = new JLabel("Plugin name:"); + line3.add(text3); + inputPluginName = new JTextField(getPluginName(), 20); + line3.add(inputPluginName); + mainPanel.add(line3); + mainPanel.add(Box.createVerticalStrut(5)); - // button panel: - final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - final JButton okButton = new JButton("OK"); - okListener = new PathButtonListener(true, pathFrame, null); - okListener.setTargetEvent(this); - okButton.addActionListener(okListener); - line4.add(okButton); + // button panel: + final JPanel line4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + final JButton okButton = new JButton("OK"); + okListener = new PathButtonListener(true, pathFrame, null); + okListener.setTargetEvent(this); + okButton.addActionListener(okListener); + line4.add(okButton); - final JButton cancelButton = new JButton("Cancel"); - ccListener = new PathButtonListener(false, pathFrame, null); - ccListener.setTargetEvent(this); - cancelButton.addActionListener(ccListener); - line4.add(cancelButton); - mainPanel.add(line4); + final JButton cancelButton = new JButton("Cancel"); + ccListener = new PathButtonListener(false, pathFrame, null); + ccListener.setTargetEvent(this); + cancelButton.addActionListener(ccListener); + line4.add(cancelButton); + mainPanel.add(line4); - pathFrame.getContentPane().add(mainPanel); - pathFrame.pack(); - pathFrame.setLocationRelativeTo(CMainControl.getInstance().getMainView()); - pathFrame.setVisible(true); - } else { - // just set fields and show - okListener.setTargetEvent(this); - ccListener.setTargetEvent(this); - inputScriptPath.setText(getScriptPath()); - inputPluginName.setText(getPluginName()); - inputOptions.setText(getOptions()); - pathFrame.toFront(); - pathFrame.setVisible(true); - } + pathFrame.getContentPane().add(mainPanel); + pathFrame.pack(); + pathFrame.setLocationRelativeTo(CMainControl.getInstance().getMainView()); + pathFrame.setVisible(true); + } else { + // just set fields and show + okListener.setTargetEvent(this); + ccListener.setTargetEvent(this); + inputScriptPath.setText(getScriptPath()); + inputPluginName.setText(getPluginName()); + inputOptions.setText(getOptions()); + pathFrame.toFront(); + pathFrame.setVisible(true); + } } /** @@ -221,66 +221,66 @@ * dialog. */ public void modifyEventPath() { - final String newPath = inputScriptPath.getText().trim(); - final String newPluginName = inputPluginName.getText().trim(); - final String newOptions = inputOptions.getText().trim(); + final String newPath = inputScriptPath.getText().trim(); + final String newPluginName = inputPluginName.getText().trim(); + final String newOptions = inputOptions.getText().trim(); - if (newPath.length() > 0) { - setScriptPath(newPath); - } - if (newPluginName.length() > 0) { - setPluginName(newPluginName); - } - if (newOptions.length() > 0) { - setOptions(newOptions); - } + if (newPath.length() > 0) { + setScriptPath(newPath); + } + if (newPluginName.length() > 0) { + setPluginName(newPluginName); + } + if (newOptions.length() > 0) { + setOptions(newOptions); + } } // GET/SET methods public GameObject getEventArch() { - return event; + return event; } public int getEventType() { - return event.getAttributeInt("sub_type"); + return event.getAttributeInt("sub_type"); } public String getPluginName() { - return event.getBestName(); + return event.getBestName(); } public String getScriptPath() { - return event.getAttributeString("race"); + return event.getAttributeString("race"); } public String getOptions() { - return event.getAttributeString("slaying"); + return event.getAttributeString("slaying"); } public void setPluginName(final String pluginName) { - setEventData(getEventType(), pluginName, getScriptPath(), getOptions()); + setEventData(getEventType(), pluginName, getScriptPath(), getOptions()); } public void setScriptPath(final String scriptPath) { - setEventData(getEventType(), getPluginName(), scriptPath, getOptions()); + setEventData(getEventType(), getPluginName(), scriptPath, getOptions()); } public void setOptions(final String options) { - setEventData(getEventType(), getPluginName(), getScriptPath(), options); + setEventData(getEventType(), getPluginName(), getScriptPath(), options); } private void setEventData(final int eventType, final String pluginName, final String scriptPath, final String options) { - event.resetObjectText(); - if (pluginName != null && pluginName.length() > 0) { - event.setObjName(pluginName); - } - if (scriptPath != null && scriptPath.length() > 0) { - event.addObjectText("race " + scriptPath); - } - if (options != null && options.length() > 0) { - event.addObjectText("slaying " + options); - } - event.addObjectText("sub_type " + eventType); + event.resetObjectText(); + if (pluginName != null && pluginName.length() > 0) { + event.setObjName(pluginName); + } + if (scriptPath != null && scriptPath.length() > 0) { + event.addObjectText("race " + scriptPath); + } + if (options != null && options.length() > 0) { + event.addObjectText("slaying " + options); + } + event.addObjectText("sub_type " + eventType); } } // class ScriptedEvent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 14:15:49
|
Revision: 1494 http://svn.sourceforge.net/gridarta/?rev=1494&view=rev Author: akirschbaum Date: 2007-01-07 06:15:48 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 13:24:47 UTC (rev 1493) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2007-01-07 14:15:48 UTC (rev 1494) @@ -80,7 +80,7 @@ // popup frame for new scripts: private static JDialog newScriptFrame; - private static JLabel nsHeading; + private static JLabel headingLabel; private static PathButtonListener nsOkListener; @@ -378,9 +378,9 @@ // first line: heading final JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - nsHeading = new JLabel("New scripted event for \"" + archName + "\":"); - nsHeading.setForeground(Color.black); - line1.add(nsHeading); + headingLabel = new JLabel("New scripted event for \"" + archName + "\":"); + headingLabel.setForeground(Color.black); + line1.add(headingLabel); mainPanel.add(line1); // event type @@ -467,7 +467,7 @@ newScriptFrame.setVisible(true); } else { // just set fields and show - nsHeading.setText("New scripted event for \"" + archName + "\":"); + headingLabel.setText("New scripted event for \"" + archName + "\":"); inputScriptPath.setText(defScriptName); inputOptions.setText(""); nsOkListener.setScriptArchData(this); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 13:24:47 UTC (rev 1493) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2007-01-07 14:15:48 UTC (rev 1494) @@ -77,7 +77,7 @@ // popup frame for new scripts: private static JDialog newScriptFrame; - private static JLabel nsHeading; + private static JLabel headingLabel; private static PathButtonListener nsOkListener; @@ -327,9 +327,9 @@ // first line: heading final JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); - nsHeading = new JLabel("New scripted event for \"" + archName + "\":"); - nsHeading.setForeground(Color.black); - line1.add(nsHeading); + headingLabel = new JLabel("New scripted event for \"" + archName + "\":"); + headingLabel.setForeground(Color.black); + line1.add(headingLabel); mainPanel.add(line1); // event type @@ -416,7 +416,7 @@ newScriptFrame.setVisible(true); } else { // just set fields and show - nsHeading.setText("New scripted event for \"" + archName + "\":"); + headingLabel.setText("New scripted event for \"" + archName + "\":"); inputScriptPath.setText(defScriptName); inputOptions.setText(""); nsOkListener.setScriptArchData(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 14:18:29
|
Revision: 1495 http://svn.sourceforge.net/gridarta/?rev=1495&view=rev Author: akirschbaum Date: 2007-01-07 06:18:29 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 14:15:48 UTC (rev 1494) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 14:18:29 UTC (rev 1495) @@ -51,7 +51,7 @@ private static JTextField inputOptions; - private static PathButtonListener ccListener; + private static PathButtonListener cancelListener; private static PathButtonListener okListener; @@ -218,9 +218,9 @@ line4.add(okButton); final JButton cancelButton = new JButton("Cancel"); - ccListener = new PathButtonListener(false, pathFrame, null); - ccListener.setTargetEvent(this); - cancelButton.addActionListener(ccListener); + cancelListener = new PathButtonListener(false, pathFrame, null); + cancelListener.setTargetEvent(this); + cancelButton.addActionListener(cancelListener); line4.add(cancelButton); mainPanel.add(line4); @@ -231,7 +231,7 @@ } else { // just set fields and show okListener.setTargetEvent(this); - ccListener.setTargetEvent(this); + cancelListener.setTargetEvent(this); inputScriptPath.setText(getScriptPath()); inputPluginName.setText(getPluginName()); inputOptions.setText(getOptions()); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 14:15:48 UTC (rev 1494) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 14:18:29 UTC (rev 1495) @@ -54,7 +54,7 @@ private static JTextField inputOptions; - private static PathButtonListener ccListener; + private static PathButtonListener cancelListener; private static PathButtonListener okListener; @@ -194,9 +194,9 @@ line4.add(okButton); final JButton cancelButton = new JButton("Cancel"); - ccListener = new PathButtonListener(false, pathFrame, null); - ccListener.setTargetEvent(this); - cancelButton.addActionListener(ccListener); + cancelListener = new PathButtonListener(false, pathFrame, null); + cancelListener.setTargetEvent(this); + cancelButton.addActionListener(cancelListener); line4.add(cancelButton); mainPanel.add(line4); @@ -207,7 +207,7 @@ } else { // just set fields and show okListener.setTargetEvent(this); - ccListener.setTargetEvent(this); + cancelListener.setTargetEvent(this); inputScriptPath.setText(getScriptPath()); inputPluginName.setText(getPluginName()); inputOptions.setText(getOptions()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 14:34:33
|
Revision: 1497 http://svn.sourceforge.net/gridarta/?rev=1497&view=rev Author: akirschbaum Date: 2007-01-07 06:34:34 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/PickmapChooser.java trunk/daimonin/src/daieditor/gui/PickmapChooser.java Modified: trunk/crossfire/src/cfeditor/gui/PickmapChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/PickmapChooser.java 2007-01-07 14:24:32 UTC (rev 1496) +++ trunk/crossfire/src/cfeditor/gui/PickmapChooser.java 2007-01-07 14:34:34 UTC (rev 1497) @@ -194,7 +194,6 @@ * if an error has occurred */ public boolean addNewPickmap(final Component parent, final MapArchObject maparch) { - final File mapFile = new File(IGUIConstants.PICKMAP_DIR, maparch.getFileName()); if (mapFile.exists()) { ACTION_FACTORY.showMessageDialog(parent, "pickmapExists", mapFile); @@ -279,7 +278,6 @@ /** Update info which pickmap is currently on top. */ private void updateActivePickmap() { - if (tabpane == null) { return; // for safety, shouldn't happen } Modified: trunk/daimonin/src/daieditor/gui/PickmapChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/PickmapChooser.java 2007-01-07 14:24:32 UTC (rev 1496) +++ trunk/daimonin/src/daieditor/gui/PickmapChooser.java 2007-01-07 14:34:34 UTC (rev 1497) @@ -189,7 +189,6 @@ * if an error has occurred */ public boolean addNewPickmap(final Component parent, final MapArchObject maparch) { - final File mapFile = new File(new File(CMainControl.getInstance().getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), maparch.getFileName()); if (mapFile.exists()) { ACTION_FACTORY.showMessageDialog(parent, "pickmapExists", mapFile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 14:51:50
|
Revision: 1498 http://svn.sourceforge.net/gridarta/?rev=1498&view=rev Author: akirschbaum Date: 2007-01-07 06:51:50 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Rename PickmapChooser to pickmapchooser/PickmapChooserControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/crossfire/src/cfeditor/gui/NewMapDialog.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/gui/NewMapDialog.java trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java trunk/daimonin/src/daieditor/map/MapControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/pickmapchooser/ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/gui/pickmapchooser/ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/PickmapChooser.java trunk/daimonin/src/daieditor/gui/PickmapChooser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -32,10 +32,10 @@ import cfeditor.gameobject.face.FaceObjects; import cfeditor.gui.GameObjectAttributesDialog; import cfeditor.gui.NewMapDialog; -import cfeditor.gui.PickmapChooser; import cfeditor.gui.ReplaceDialog; import cfeditor.gui.map.MapCursorControl; import cfeditor.gui.map.MapPropertiesDialog; +import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; import cfeditor.io.CMapReader; @@ -238,7 +238,7 @@ readGlobalSettings(); // initialize pickmap panel (needed early during the loading process) - new PickmapChooser(); + new PickmapChooserControl(); // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); @@ -772,13 +772,13 @@ /** Invoked when the user wants to close the active pickmap. */ public void closePickmap() { - if (!PickmapChooser.getInstance().isLoadComplete()) { + if (!PickmapChooserControl.getInstance().isLoadComplete()) { ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNotLoaded"); } else { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "closePickmapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNoPickmaps"); } else { @@ -839,7 +839,7 @@ if (level.isPickmap()) { // special case: close a pickmap - PickmapChooser.getInstance().closePickmap(level); + PickmapChooserControl.getInstance().closePickmap(level); level.levelCloseNotify(); } else { // Notify the level about the closing @@ -860,13 +860,13 @@ /** Open active pickmap as normal map for extensive editing. */ public void openPickmapMap() { - if (!PickmapChooser.getInstance().isLoadComplete()) { + if (!PickmapChooserControl.getInstance().isLoadComplete()) { ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapNotLoaded"); } else { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "openPickmapNoPickmaps"); } else { @@ -1091,11 +1091,11 @@ /** Save current active pickmap. */ public void savePickmap() { - if (PickmapChooser.getInstance().isLoadComplete()) { + if (PickmapChooserControl.getInstance().isLoadComplete()) { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "savePickmapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNoPickmaps"); } else { @@ -1559,13 +1559,13 @@ /** Invoked when user wants to revert the current pickmap to previously saved state. */ public void revertPickmap() { - if (!PickmapChooser.getInstance().isLoadComplete()) { + if (!PickmapChooserControl.getInstance().isLoadComplete()) { ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNotLoaded"); } else { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNoPickmaps"); } else { @@ -1577,8 +1577,8 @@ } closeLevel(activePickmap, true); // close the old map - PickmapChooser.getInstance().openPickmap(mfile); // open the new map - PickmapChooser.getInstance().setActivePickmap(mfile.getName()); + PickmapChooserControl.getInstance().openPickmap(mfile); // open the new map + PickmapChooserControl.getInstance().setActivePickmap(mfile.getName()); // Update the main view so the new map instantly pops up. mainView.update(mainView.getGraphics()); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -27,7 +27,7 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.GameObjectAttributesPanel; import cfeditor.gui.InsertionObjectChooser; -import cfeditor.gui.PickmapChooser; +import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.gui.selectedsquare.SelectedSquareControl; import cfeditor.map.MapControl; import java.awt.BorderLayout; @@ -210,7 +210,7 @@ // initialize pickmap panel pickmapPanel = new JTabbedPane(SwingConstants.TOP); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); - PickmapChooser.getInstance().addPickmapSelectionListener(pickmapPanel); + PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); statusBar = new StatusBar(mainControl); getContentPane().add(statusBar, BorderLayout.SOUTH); @@ -324,9 +324,9 @@ */ public GameObject getArchPanelHighlight() { - if ((isPickmapActive() || archPanel.getArchPanelSelection() == null) && PickmapChooser.getInstance().isLoadComplete() && PickmapChooser.getInstance().getCurrentPickmap() != null) { + if ((isPickmapActive() || archPanel.getArchPanelSelection() == null) && PickmapChooserControl.getInstance().isLoadComplete() && PickmapChooserControl.getInstance().getCurrentPickmap() != null) { // get the active pickmap - final MapControl pmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (pmap != null && pmap.getMapViewFrame().isHighlight()) { // now try to get the topmost object Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -30,7 +30,7 @@ import cfeditor.IGUIConstants; import cfeditor.gameobject.face.FaceObject; import cfeditor.gameobject.face.FaceObjects; -import cfeditor.gui.PickmapChooser; +import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.map.MapArchObject; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -172,7 +172,7 @@ } // load pickmaps - PickmapChooser.getInstance().loadPickmaps(); + PickmapChooserControl.getInstance().loadPickmaps(); // load the treasurelists data CFTreasureListTree.init(); Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -29,6 +29,7 @@ import cfeditor.CSettings; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; +import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.map.MapArchObject; import java.awt.BorderLayout; import java.awt.Dimension; @@ -96,7 +97,7 @@ archAndPickPane.addTab("Arch List", tabDesktop); archAndPickPane.addTab("Pickmaps", mainControl.getMainView().getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? - PickmapChooser.getInstance().addArchNPickChangeListener(archAndPickPane); + PickmapChooserControl.getInstance().addArchNPickChangeListener(archAndPickPane); // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Modified: trunk/crossfire/src/cfeditor/gui/NewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -28,6 +28,7 @@ import cfeditor.CSettings; import cfeditor.IGUIConstants; import cfeditor.gameobject.ArchetypeSet; +import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.map.MapArchObject; import java.awt.Component; import java.awt.FlowLayout; @@ -259,7 +260,7 @@ if (mapType == MapType.GAMEMAP) { mainControl.newLevel(null, maparch, true, null); } else if (mapType == MapType.PICKMAP) { - return PickmapChooser.getInstance().addNewPickmap(parent, maparch); + return PickmapChooserControl.getInstance().addNewPickmap(parent, maparch); } return true; Deleted: trunk/crossfire/src/cfeditor/gui/PickmapChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/PickmapChooser.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/crossfire/src/cfeditor/gui/PickmapChooser.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -1,389 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor.gui; - -import cfeditor.CMainControl; -import cfeditor.CMainView; -import cfeditor.CMapViewBasic; -import cfeditor.IGUIConstants; -import cfeditor.gameobject.GameObject; -import cfeditor.io.CMapReader; -import cfeditor.map.MapArchObject; -import cfeditor.map.MapControl; -import java.awt.Component; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; - -/** - * The <code>PickmapChooser</code> manages the pickmap panel - * and most pickmap-related code in general. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class PickmapChooser { - - private static final Logger log = Logger.getLogger(PickmapChooser.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - - /** Singleton instance of this class. */ - private static PickmapChooser instance; - - private final CMainControl mainControl; // main control reference - - private boolean loadComplete; // true when all pickmaps have been loaded (at least one) - - private JTabbedPane tabpane = null; // tab pane with pickmaps - - /** All open pickmaps (the map controllers get stored in the vector). */ - private final Map<String, MapControl> pickmaps = new HashMap<String, MapControl>(); - - /** The current active pickmap ontop. */ - private MapControl currentPickMap; - - /** - * Create a PickmapChooser. - */ - public PickmapChooser() { - mainControl = CMainControl.getInstance(); - instance = this; - loadComplete = false; - currentPickMap = null; - } - - /** - * Return the singleton instance of this class. - * @return the singleton instance of this class - */ - public static PickmapChooser getInstance() { - return instance; - } - - /** - * Return whether loading of pickmaps is complete and at least one pickmap is available. - * @return <code>true</code> if loading of pickmaps is complete and at least one pickmap is available, otherwise <code>false</code> - * @todo check whether this method returns <code>true</code> or <code>false</code> if the loading process is complete but no pickmaps are availbale. - */ - public boolean isLoadComplete() { - return loadComplete; - } - - /** - * Return the currently active pickmap. - * If there is no currently active pickmap, this method returns <code>null</code>. - * @return the currently active pickmap or <code>null</code> if there is no pickmap - */ - public MapControl getCurrentPickmap() { - return currentPickMap; - } - - /** - * Load all pickmaps and build the pickmap-panel. - */ - public void loadPickmaps() { - // the main-panel for pickmaps: - tabpane = mainControl.getMainView().getPickmapPanel(); - - final File pickmapDir = new File(IGUIConstants.PICKMAP_DIR); - if (!pickmapDir.exists() || !pickmapDir.isDirectory()) { - log.warn("No pickmaps directory found."); - return; - } - - final File[] flist = pickmapDir.listFiles(); // list of files - Arrays.sort(flist); - for (final File aFlist : flist) { - // open the pickmaps - if (aFlist.isFile()) { - openPickmap(aFlist); - } - } - mainControl.refreshMenusAndToolbars(); - - // did we get something? - if (!pickmaps.isEmpty()) { - loadComplete = true; - } - - updateActivePickmap(); // make sure we know which one is on top - } - - /** - * Open and load a pickmap from the given file. - * @param mapFile the map file - * @return true when pickmap was opened successfully - */ - public boolean openPickmap(final File mapFile) { - // open the pickmaps - final CMapViewBasic bmapview; - final MapArchObject maparch; - - try { - final CMapReader decoder = new CMapReader(mapFile); - final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile - maparch = decoder.getMapArch(); // get map arch - - if (objects == null) { - // The map is totally empty - bmapview = newPickmap(null, maparch, mapFile); // init the map - } else { - // go to ArchetypeParser and add the default arch list information to them - if (!mainControl.collectTempList(objects, mapFile)) { // get face names, face id, etc. - return false; - } - mainControl.getArchetypeParser().sortTempList(objects); // sort the list (put multiparts at the end) - bmapview = newPickmap(objects, maparch, mapFile); // init the map - } - - // looks like it worked, so we add a panel and display this pickmap - if (bmapview != null) { - int i; - for (i = 0; i < tabpane.getTabCount() && mapFile.getName().compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { - ; - } - tabpane.insertTab(mapFile.getName(), null, bmapview, null, i); - return true; - } - } catch (final IOException e) { - // loading failed - could be a system file in that directory, - // or something else. Doesn't deserve more attention than a printout. - if (!mapFile.getName().startsWith(".")) { - log.warn("Couldn't load pickmap", e); - } - } - return false; - } - - /** - * Create a new pickmap and display it. - * @param parent the parent component to be used for error messages - * @param maparch MapArchObject containing map name and -size - * @return <code>true</code> if the pickmap was added, <code>false</code> - * if an error has occurred - */ - public boolean addNewPickmap(final Component parent, final MapArchObject maparch) { - final File mapFile = new File(IGUIConstants.PICKMAP_DIR, maparch.getFileName()); - if (mapFile.exists()) { - ACTION_FACTORY.showMessageDialog(parent, "pickmapExists", mapFile); - return false; - } - if (!mapFile.getParentFile().exists()) { - mapFile.getParentFile().mkdirs(); - } - - final CMapViewBasic bmapview = newPickmap(null, maparch, mapFile); - if (bmapview != null) { - // insert new pickmap in the alphabetic order - int i; - for (i = 0; i < tabpane.getTabCount() && mapFile.getName().compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { - ; - } - tabpane.insertTab(mapFile.getName(), null, bmapview, null, i); - setActivePickmap(mapFile.getName()); - loadComplete = true; - return true; - } - return false; - } - - /** - * Add a new pickmap. - * @param objects list of objects or <code>null</code> for empty - * @param maparch the maparch of the pickmap - * @param mapFile The map file that's stored in the MapControl. - * @return basic mapview - */ - private CMapViewBasic newPickmap(final List<GameObject> objects, final MapArchObject maparch, final File mapFile) { - final MapControl mapControl = new MapControl(mainControl, objects, maparch, true, null); - mapControl.getMapViewFrame().setAutoscrolls(true); - mapControl.setMapFile(mapFile); - - // add pickmap to hashtable - pickmaps.put(mapFile.getName(), mapControl); - - currentPickMap = mapControl; - mapControl.resetModified(); - - return mapControl.getMapViewFrame().getBasicView(); - } - - /** - * Close a pickmap: Remove it from the panel and the data vector. - * @param mapControl MapControl of the pickmap to remove - * @return true when closing successful - */ - public boolean closePickmap(final MapControl mapControl) { - boolean mapClosed = false; - - final Iterator<String> keyit = pickmaps.keySet().iterator(); - while (!mapClosed && keyit.hasNext()) { - final String tmpKey = keyit.next(); - final MapControl tmpMap = pickmaps.get(tmpKey); - if (tmpMap == mapControl) { - pickmaps.remove(tmpKey); - tabpane.remove(tmpMap.getMapViewFrame().getBasicView()); - mapClosed = true; - } - } - - if (mapClosed) { - updateActivePickmap(); - } - - return mapClosed; - } - - /** - * Set pickmap with given name to be the active one (ontop). - * @param name map name (which is also the tab title) - */ - public void setActivePickmap(final String name) { - final MapControl tmpMap = pickmaps.get(name); - if (tmpMap != null) { - tabpane.setSelectedComponent(tmpMap.getMapViewFrame().getBasicView()); - } - } - - /** Update info which pickmap is currently on top. */ - private void updateActivePickmap() { - if (tabpane == null) { - return; // for safety, shouldn't happen - } - - if (pickmaps.isEmpty()) { - currentPickMap = null; - return; - } - - final String newName = tabpane.getTitleAt(tabpane.getSelectedIndex()); - - final MapControl tmp = pickmaps.get(newName); - boolean foundMap = false; - if (tmp != null && tmp.getMapFileName().endsWith("/"+newName)) { - // this is the new active pickmap - currentPickMap = tmp; // <- new pickmap - foundMap = true; - if (log.isDebugEnabled()) { - log.debug("new pickmap: " + newName); - } - } - - if (!foundMap && mainControl.getMainView().isPickmapActive() && loadComplete) { - // error: the new selected pickmap couldn't be found - log.error("Bad Error in PickmapChooser.updateActivePickmap: Selected pickmap couldn't be found!"); - } - } - - /** - * Add the PickmapSelectionListener to the pickmap tabbed panel. - * @param pickpane the panel with pickmaps - * @todo this method's name is a Bad Thing - */ - public void addPickmapSelectionListener(final JTabbedPane pickpane) { - pickpane.addChangeListener(new PickmapSelectionListener(pickpane)); - } - - /** - * Add the ArchNPickChangeListener to the panel containing both - * archlist and pickmaps. - * @param pane the left-side panel - * @todo this method's name is a Bad Thing - */ - public void addArchNPickChangeListener(final JTabbedPane pane) { - pane.addChangeListener(new ArchNPickChangeListener(mainControl.getMainView(), pane)); - } - - // ------------------------ nested and inner classes ------------------------ - - /** Listener class to keep track of the currently active pickmap. */ - private final class PickmapSelectionListener implements ChangeListener { - - private final String activePickmap; // file-name of active pickmap - - private PickmapSelectionListener(final JTabbedPane pane) { - tabpane = pane; - activePickmap = null; - } - - public void stateChanged(final ChangeEvent e) { - if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { - // new pickmap is active - updateActivePickmap(); - } - } - - } // class PickmapSelectionListener - - /** - * In the left-side panel, archlist and pickmaps are exclusive - * (only the one being displayed is active). - * This listener gets to know which of them is active and - * keeps the main view informed whenever the state changes. - */ - private static final class ArchNPickChangeListener implements ChangeListener { - - private final CMainView mainView; // main view - - private final JTabbedPane tabpane; // parent pane for archlist & pickmaps - - private int selectedIndex; // current state of selection - - /** - * Create an ArchNPickChangeListener. - * @param mainView the main view - * @param pane the JTabbedPane containing both archlist and pickmaps - */ - private ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { - this.mainView = mainView; - tabpane = pane; - selectedIndex = tabpane.getSelectedIndex(); - } - - public void stateChanged(final ChangeEvent e) { - if (tabpane.getSelectedIndex() != selectedIndex) { - // the state has changed, user has switched panels - if (tabpane.getSelectedIndex() == 0) { - mainView.setPickmapActive(false); - } else { - mainView.setPickmapActive(true); - } - - selectedIndex = tabpane.getSelectedIndex(); // save new state - } - } - - } // class ArchNPickChangeListener - -} // class PickmapChooser Copied: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java (from rev 1497, trunk/crossfire/src/cfeditor/gui/PickmapChooser.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -0,0 +1,390 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2007 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.pickmapchooser; + +import cfeditor.CMainControl; +import cfeditor.CMainView; +import cfeditor.CMapViewBasic; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.GameObject; +import cfeditor.io.CMapReader; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapControl; +import java.awt.Component; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; + +/** + * The <code>PickmapChooserControl</code> manages the pickmap panel + * and most pickmap-related code in general. + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author Andreas Kirschbaum + */ +public final class PickmapChooserControl { + + private static final Logger log = Logger.getLogger(PickmapChooserControl.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** Singleton instance of this class. */ + private static PickmapChooserControl instance; + + private final CMainControl mainControl; // main control reference + + private boolean loadComplete; // true when all pickmaps have been loaded (at least one) + + private JTabbedPane tabpane = null; // tab pane with pickmaps + + /** All open pickmaps (the map controllers get stored in the vector). */ + private final Map<String, MapControl> pickmaps = new HashMap<String, MapControl>(); + + /** The current active pickmap ontop. */ + private MapControl currentPickMap; + + /** + * Create a PickmapChooserControl. + */ + public PickmapChooserControl() { + mainControl = CMainControl.getInstance(); + instance = this; + loadComplete = false; + currentPickMap = null; + } + + /** + * Return the singleton instance of this class. + * @return the singleton instance of this class + */ + public static PickmapChooserControl getInstance() { + return instance; + } + + /** + * Return whether loading of pickmaps is complete and at least one pickmap is available. + * @return <code>true</code> if loading of pickmaps is complete and at least one pickmap is available, otherwise <code>false</code> + * @todo check whether this method returns <code>true</code> or <code>false</code> if the loading process is complete but no pickmaps are availbale. + */ + public boolean isLoadComplete() { + return loadComplete; + } + + /** + * Return the currently active pickmap. + * If there is no currently active pickmap, this method returns <code>null</code>. + * @return the currently active pickmap or <code>null</code> if there is no pickmap + */ + public MapControl getCurrentPickmap() { + return currentPickMap; + } + + /** + * Load all pickmaps and build the pickmap-panel. + */ + public void loadPickmaps() { + // the main-panel for pickmaps: + tabpane = mainControl.getMainView().getPickmapPanel(); + + final File pickmapDir = new File(IGUIConstants.PICKMAP_DIR); + if (!pickmapDir.exists() || !pickmapDir.isDirectory()) { + log.warn("No pickmaps directory found."); + return; + } + + final File[] flist = pickmapDir.listFiles(); // list of files + Arrays.sort(flist); + for (final File aFlist : flist) { + // open the pickmaps + if (aFlist.isFile()) { + openPickmap(aFlist); + } + } + mainControl.refreshMenusAndToolbars(); + + // did we get something? + if (!pickmaps.isEmpty()) { + loadComplete = true; + } + + updateActivePickmap(); // make sure we know which one is on top + } + + /** + * Open and load a pickmap from the given file. + * @param mapFile the map file + * @return true when pickmap was opened successfully + */ + public boolean openPickmap(final File mapFile) { + // open the pickmaps + final CMapViewBasic bmapview; + final MapArchObject maparch; + + try { + final CMapReader decoder = new CMapReader(mapFile); + final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile + maparch = decoder.getMapArch(); // get map arch + + if (objects == null) { + // The map is totally empty + bmapview = newPickmap(null, maparch, mapFile); // init the map + } else { + // go to ArchetypeParser and add the default arch list information to them + if (!mainControl.collectTempList(objects, mapFile)) { // get face names, face id, etc. + return false; + } + mainControl.getArchetypeParser().sortTempList(objects); // sort the list (put multiparts at the end) + bmapview = newPickmap(objects, maparch, mapFile); // init the map + } + + // looks like it worked, so we add a panel and display this pickmap + if (bmapview != null) { + int i; + for (i = 0; i < tabpane.getTabCount() && mapFile.getName().compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { + ; + } + tabpane.insertTab(mapFile.getName(), null, bmapview, null, i); + return true; + } + } catch (final IOException e) { + // loading failed - could be a system file in that directory, + // or something else. Doesn't deserve more attention than a printout. + if (!mapFile.getName().startsWith(".")) { + log.warn("Couldn't load pickmap", e); + } + } + return false; + } + + /** + * Create a new pickmap and display it. + * @param parent the parent component to be used for error messages + * @param maparch MapArchObject containing map name and -size + * @return <code>true</code> if the pickmap was added, <code>false</code> + * if an error has occurred + */ + public boolean addNewPickmap(final Component parent, final MapArchObject maparch) { + final File mapFile = new File(IGUIConstants.PICKMAP_DIR, maparch.getFileName()); + if (mapFile.exists()) { + ACTION_FACTORY.showMessageDialog(parent, "pickmapExists", mapFile); + return false; + } + if (!mapFile.getParentFile().exists()) { + mapFile.getParentFile().mkdirs(); + } + + final CMapViewBasic bmapview = newPickmap(null, maparch, mapFile); + if (bmapview != null) { + // insert new pickmap in the alphabetic order + int i; + for (i = 0; i < tabpane.getTabCount() && mapFile.getName().compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { + ; + } + tabpane.insertTab(mapFile.getName(), null, bmapview, null, i); + setActivePickmap(mapFile.getName()); + loadComplete = true; + return true; + } + return false; + } + + /** + * Add a new pickmap. + * @param objects list of objects or <code>null</code> for empty + * @param maparch the maparch of the pickmap + * @param mapFile The map file that's stored in the MapControl. + * @return basic mapview + */ + private CMapViewBasic newPickmap(final List<GameObject> objects, final MapArchObject maparch, final File mapFile) { + final MapControl mapControl = new MapControl(mainControl, objects, maparch, true, null); + mapControl.getMapViewFrame().setAutoscrolls(true); + mapControl.setMapFile(mapFile); + + // add pickmap to hashtable + pickmaps.put(mapFile.getName(), mapControl); + + currentPickMap = mapControl; + mapControl.resetModified(); + + return mapControl.getMapViewFrame().getBasicView(); + } + + /** + * Close a pickmap: Remove it from the panel and the data vector. + * @param mapControl MapControl of the pickmap to remove + * @return true when closing successful + */ + public boolean closePickmap(final MapControl mapControl) { + boolean mapClosed = false; + + final Iterator<String> keyit = pickmaps.keySet().iterator(); + while (!mapClosed && keyit.hasNext()) { + final String tmpKey = keyit.next(); + final MapControl tmpMap = pickmaps.get(tmpKey); + if (tmpMap == mapControl) { + pickmaps.remove(tmpKey); + tabpane.remove(tmpMap.getMapViewFrame().getBasicView()); + mapClosed = true; + } + } + + if (mapClosed) { + updateActivePickmap(); + } + + return mapClosed; + } + + /** + * Set pickmap with given name to be the active one (ontop). + * @param name map name (which is also the tab title) + */ + public void setActivePickmap(final String name) { + final MapControl tmpMap = pickmaps.get(name); + if (tmpMap != null) { + tabpane.setSelectedComponent(tmpMap.getMapViewFrame().getBasicView()); + } + } + + /** Update info which pickmap is currently on top. */ + private void updateActivePickmap() { + if (tabpane == null) { + return; // for safety, shouldn't happen + } + + if (pickmaps.isEmpty()) { + currentPickMap = null; + return; + } + + final String newName = tabpane.getTitleAt(tabpane.getSelectedIndex()); + + final MapControl tmp = pickmaps.get(newName); + boolean foundMap = false; + if (tmp != null && tmp.getMapFileName().endsWith("/"+newName)) { + // this is the new active pickmap + currentPickMap = tmp; // <- new pickmap + foundMap = true; + if (log.isDebugEnabled()) { + log.debug("new pickmap: " + newName); + } + } + + if (!foundMap && mainControl.getMainView().isPickmapActive() && loadComplete) { + // error: the new selected pickmap couldn't be found + log.error("Bad Error in PickmapChooserControl.updateActivePickmap: Selected pickmap couldn't be found!"); + } + } + + /** + * Add the PickmapSelectionListener to the pickmap tabbed panel. + * @param pickpane the panel with pickmaps + * @todo this method's name is a Bad Thing + */ + public void addPickmapSelectionListener(final JTabbedPane pickpane) { + pickpane.addChangeListener(new PickmapSelectionListener(pickpane)); + } + + /** + * Add the ArchNPickChangeListener to the panel containing both + * archlist and pickmaps. + * @param pane the left-side panel + * @todo this method's name is a Bad Thing + */ + public void addArchNPickChangeListener(final JTabbedPane pane) { + pane.addChangeListener(new ArchNPickChangeListener(mainControl.getMainView(), pane)); + } + + // ------------------------ nested and inner classes ------------------------ + + /** Listener class to keep track of the currently active pickmap. */ + private final class PickmapSelectionListener implements ChangeListener { + + private final String activePickmap; // file-name of active pickmap + + private PickmapSelectionListener(final JTabbedPane pane) { + tabpane = pane; + activePickmap = null; + } + + public void stateChanged(final ChangeEvent e) { + if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { + // new pickmap is active + updateActivePickmap(); + } + } + + } // class PickmapSelectionListener + + /** + * In the left-side panel, archlist and pickmaps are exclusive + * (only the one being displayed is active). + * This listener gets to know which of them is active and + * keeps the main view informed whenever the state changes. + */ + private static final class ArchNPickChangeListener implements ChangeListener { + + private final CMainView mainView; // main view + + private final JTabbedPane tabpane; // parent pane for archlist & pickmaps + + private int selectedIndex; // current state of selection + + /** + * Create an ArchNPickChangeListener. + * @param mainView the main view + * @param pane the JTabbedPane containing both archlist and pickmaps + */ + private ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { + this.mainView = mainView; + tabpane = pane; + selectedIndex = tabpane.getSelectedIndex(); + } + + public void stateChanged(final ChangeEvent e) { + if (tabpane.getSelectedIndex() != selectedIndex) { + // the state has changed, user has switched panels + if (tabpane.getSelectedIndex() == 0) { + mainView.setPickmapActive(false); + } else { + mainView.setPickmapActive(true); + } + + selectedIndex = tabpane.getSelectedIndex(); // save new state + } + } + + } // class ArchNPickChangeListener + +} // class PickmapChooserControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -38,11 +38,11 @@ import daieditor.gui.GameObjectAttributesDialog; import daieditor.gui.MapFileFilter; import daieditor.gui.NewMapDialog; -import daieditor.gui.PickmapChooser; import daieditor.gui.ReplaceDialog; import daieditor.gui.map.MapCursorControl; import daieditor.gui.map.MapPreviewAccessory; import daieditor.gui.map.MapPropertiesDialog; +import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.DevPrefs; import daieditor.gui.prefs.GUIPrefs; @@ -411,7 +411,7 @@ readGlobalSettings(); // initialize pickmap panel (needed early during the loading process) - new PickmapChooser(); + new PickmapChooserControl(); // initialize & load MultiPositionData.init(); @@ -944,13 +944,13 @@ /** Invoked when the user wants to close the active pickmap. */ public void closePickmap() { - if (!PickmapChooser.getInstance().isLoadComplete()) { + if (!PickmapChooserControl.getInstance().isLoadComplete()) { ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNotLoaded"); } else { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "closePickmapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNoPickmaps"); } else { @@ -1011,7 +1011,7 @@ if (level.isPickmap()) { // special case: close a pickmap - PickmapChooser.getInstance().closePickmap(level); + PickmapChooserControl.getInstance().closePickmap(level); level.levelCloseNotify(); } else { // Notify the level about the closing @@ -1034,13 +1034,13 @@ /** Open active pickmap as normal map for extensive editing. */ public void openPickmapMap() { - if (!PickmapChooser.getInstance().isLoadComplete()) { + if (!PickmapChooserControl.getInstance().isLoadComplete()) { ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapNotLoaded"); } else { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "openPickmapNoPickmaps"); } else { @@ -1313,11 +1313,11 @@ /** Save current active pickmap. */ public void savePickmap() { - if (PickmapChooser.getInstance().isLoadComplete()) { + if (PickmapChooserControl.getInstance().isLoadComplete()) { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "savePickmapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNoPickmaps"); } else { @@ -1760,13 +1760,13 @@ /** Invoked when user wants to revert the current pickmap to previously saved state. */ public void revertPickmap() { - if (!PickmapChooser.getInstance().isLoadComplete()) { + if (!PickmapChooserControl.getInstance().isLoadComplete()) { ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNotLoaded"); } else { if (!mainView.isPickmapActive()) { ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapHidden"); } else { - final MapControl activePickmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (activePickmap == null) { ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNoPickmaps"); } else { @@ -1777,11 +1777,11 @@ return; } - final int tabIndex = PickmapChooser.getInstance().getPickmapTabIndex(activePickmap); + final int tabIndex = PickmapChooserControl.getInstance().getPickmapTabIndex(activePickmap); if (tabIndex >= 0) { closeLevel(activePickmap, true); // close the old map - PickmapChooser.getInstance().openPickmap(mfile, tabIndex); // open the new map - PickmapChooser.getInstance().setActivePickmap(tabIndex); + PickmapChooserControl.getInstance().openPickmap(mfile, tabIndex); // open the new map + PickmapChooserControl.getInstance().setActivePickmap(tabIndex); // Update the main view so the new map instantly pops up. mainView.update(mainView.getGraphics()); @@ -2340,7 +2340,7 @@ if (arch != null) { title.append("with arch ").append(arch.getArchetypeName()); } else { - pmap = PickmapChooser.getInstance().getCurrentPickmap(); + pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (pmap != null) { title.append("with pickmap ").append(pmap.getMapArchObject().getMapName()); } else { // ok ,we have a problem here: arch == null, pmap == null... Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -28,7 +28,7 @@ import daieditor.gui.AboutDialog; import daieditor.gui.GameObjectAttributesPanel; import daieditor.gui.InsertionObjectChooser; -import daieditor.gui.PickmapChooser; +import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.gui.selectedsquare.SelectedSquareControl; import daieditor.map.MapControl; import daieditor.map.validation.ErrorCollector; @@ -219,7 +219,7 @@ pickmapPanel = new JTabbedPane(SwingConstants.TOP); pickmapPanel.setComponentPopupMenu(ACTION_FACTORY.createPopupMenu(true, "pickmaps")); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); - PickmapChooser.getInstance().addPickmapSelectionListener(pickmapPanel); + PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); statusBar = new StatusBar(mainControl); archPanel = new InsertionObjectChooser(mainControl); @@ -287,9 +287,9 @@ */ @Nullable public GameObject getArchPanelHighlight() { - if ((pickmapActive || archPanel.getArchPanelSelection() == null) && PickmapChooser.getInstance().isLoadComplete() && PickmapChooser.getInstance().getCurrentPickmap() != null) { + if ((pickmapActive || archPanel.getArchPanelSelection() == null) && PickmapChooserControl.getInstance().isLoadComplete() && PickmapChooserControl.getInstance().getCurrentPickmap() != null) { // get the active pickmap - final MapControl pmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (pmap != null && pmap.getMapViewFrame().isHighlight()) { // now try to get the topmost object @@ -322,9 +322,9 @@ */ @Nullable public List<GameObject> getArchPanelSelection() { - if ((pickmapActive || archPanel.getArchPanelSelection() == null) && PickmapChooser.getInstance().isLoadComplete()) { + if ((pickmapActive || archPanel.getArchPanelSelection() == null) && PickmapChooserControl.getInstance().isLoadComplete()) { // get the active pickmap - final MapControl pmap = PickmapChooser.getInstance().getCurrentPickmap(); + final MapControl pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); if (pmap != null) { return CopyBuffer.getMapArchList(pmap, 100); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -33,7 +33,7 @@ import daieditor.gameobject.face.ArchFaceProvider; import daieditor.gameobject.face.DuplicateFaceException; import daieditor.gameobject.face.FaceObjects; -import daieditor.gui.PickmapChooser; +import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import java.awt.BorderLayout; import java.io.BufferedReader; @@ -214,7 +214,7 @@ } // load pickmaps - PickmapChooser.getInstance().loadPickmaps(); + PickmapChooserControl.getInstance().loadPickmaps(); // load the treasurelists data CFTreasureListTree.init(); Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -29,6 +29,7 @@ import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.gui.map.tools.ToolPalette; +import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import java.awt.BorderLayout; import java.awt.GridBagConstraints; @@ -115,7 +116,7 @@ archAndPickPane.addTab("Arch List", archPane); archAndPickPane.addTab("Pickmaps", mainControl.getMainView().getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? - PickmapChooser.getInstance().addArchNPickChangeListener(archAndPickPane); + PickmapChooserControl.getInstance().addArchNPickChangeListener(archAndPickPane); // calculate default value in case there is no settings file Modified: trunk/daimonin/src/daieditor/gui/NewMapDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/NewMapDialog.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/daimonin/src/daieditor/gui/NewMapDialog.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -29,6 +29,7 @@ import static daieditor.CMainControl.PREFS_USERNAME; import static daieditor.CMainControl.PREFS_USERNAME_DEFAULT; import daieditor.IGUIConstants; +import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import java.awt.Component; import java.awt.FlowLayout; @@ -299,7 +300,7 @@ if (mapType == MapType.GAMEMAP) { mainControl.newLevel(null, maparch, true); } else if (mapType == MapType.PICKMAP) { - return PickmapChooser.getInstance().addNewPickmap(parent, maparch); + return PickmapChooserControl.getInstance().addNewPickmap(parent, maparch); } return true; Deleted: trunk/daimonin/src/daieditor/gui/PickmapChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/PickmapChooser.java 2007-01-07 14:34:34 UTC (rev 1497) +++ trunk/daimonin/src/daieditor/gui/PickmapChooser.java 2007-01-07 14:51:50 UTC (rev 1498) @@ -1,425 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package daieditor.gui; - -import daieditor.CMainControl; -import daieditor.CMainView; -import daieditor.CMapViewBasic; -import daieditor.IGUIConstants; -import daieditor.gameobject.GameObject; -import daieditor.io.CMapReader; -import daieditor.map.MapArchObject; -import daieditor.map.MapControl; -import java.awt.Component; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; - -/** - * The <code>PickmapChooser</code> manages the pickmap panel - * and most pickmap-related code in general. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class PickmapChooser { - - private static final Logger log = Logger.getLogger(PickmapChooser.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Singleton instance of this class. */ - private static PickmapChooser instance; - - private final CMainControl mainControl; // main control reference - - private boolean loadComplete; // true when all pickmaps have been loaded (at least one) - - private JTabbedPane tabpane = null; // tab pane with pickmaps - - /** All open pickmaps (the map controllers get stored in the vector). */ - private final List<MapControl> pickmaps = new ArrayList<MapControl>(); - - /** The current active pickmap ontop. */ - private MapControl currentPickMap; - - /** - * Create a PickmapChooser. - */ - public PickmapChooser() { - mainControl = CMainControl.getInstance(); - instance = this; - loadComplete = false; - currentPickMap = null; - } - - /** - * Return the singleton instance of this class. - * @return the singleton instance of this class - */ - public static PickmapChooser getInstance() { - return instance; - } - - /** - * Return whether loading of pickmaps is complete and at least one pickmap is available. - * @return <code>true</code> if loading of pickmaps is complete and at least one pickmap is available, otherwise <code>false</code> - */ - public boolean isLoadComplete() { - return loadComplete; - } - - /** - * Return the currently active pickmap (is on top). - * @return the currently active pickmap or <code>null</code> if there is no pickmap - */ - public MapControl getCurrentPickmap() { - return currentPickMap; - } - - /** - * Load all pickmaps and build the pickmap-panel. - */ - public void loadPickmaps() { - // the main-panel for pickmaps: - tabpane = mainControl.getMainView().getPickmapPanel(); - - final File pickmapDir = new File(CMainControl.getInstance().getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR); - if (!pickmapDir.exists() || !pickmapDir.isDirectory()) { - log.warn("No pickmaps directory found."); - return; - } - - final File[] flist = pickmapDir.listFiles(); // list of files - Arrays.sort(flist); - for (final File aFlist : flist) { - // open the pickmaps - if (aFlist.isFile()) { - openPickmap(aFlist); - } - } - mainControl.refreshMenusAndToolbars(); - - // did we get something? - if (!pickmaps.isEmpty()) { - loadComplete = true; - - mainControl.getMainView().movePickmapPanelToFront(); - } - - updateActivePickmap(); // make sure we know which one is on top - } - - public boolean openPickmap(final File mapFile) { - return openPickmap(mapFile, -1); - } - - /** - * Open and load a pickmap from the given file. - * @param mapFile the map file - * @param index the tab index where this pickmap should be inserted - * @return true when pickmap was opened successfully - */ - public boolean openPickmap(final File mapFile, final int index) { - // open the pickmaps - - try { - // FIXME: This is somewhat dangerous regarding multithreading - final CMapReader decoder = new CMapReader(mapFile); - try { - final List<GameObject> objects = decoder.decodeMapFile(); - final MapArchObject maparch = decoder.getMapArch(); - final CMapViewBasic bmapview; - - // go to ArchetypeParser and add the default arch list information to them - bmapview = newPickmap(objects, maparch, mapFile, index); // init the map - - // looks like it worked, so we add a panel and display this pickmap - if (bmapview != null) { - if (index < 0 || index >= tabpane.getTabCount()) { - tabpane.addTab(mapFile.getName(), bmapview); - } else { - tabpane.insertTab(mapFile.getName(), null, bmapview, null, index); - } - bmapview.g... [truncated message content] |
From: <aki...@us...> - 2007-01-07 15:14:51
|
Revision: 1499 http://svn.sourceforge.net/gridarta/?rev=1499&view=rev Author: akirschbaum Date: 2007-01-07 07:14:50 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Do not overwrite field in parent class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 14:51:50 UTC (rev 1498) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:14:50 UTC (rev 1499) @@ -333,6 +333,8 @@ private final String activePickmap; // file-name of active pickmap + private final JTabbedPane tabpane; + private PickmapSelectionListener(final JTabbedPane pane) { tabpane = pane; activePickmap = null; Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 14:51:50 UTC (rev 1498) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:14:50 UTC (rev 1499) @@ -366,6 +366,8 @@ private final String activePickmap; // file-name of active pickmap + private final JTabbedPane tabpane; + private PickmapSelectionListener(final JTabbedPane pane) { tabpane = pane; activePickmap = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 15:36:40
|
Revision: 1500 http://svn.sourceforge.net/gridarta/?rev=1500&view=rev Author: akirschbaum Date: 2007-01-07 07:36:39 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Extract inner classes to separate files. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java Added: trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java 2007-01-07 15:36:39 UTC (rev 1500) @@ -0,0 +1,66 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.pickmapchooser; + +import cfeditor.CMainView; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +/** + * In the left-side panel, archlist and pickmaps are exclusive + * (only the one being displayed is active). + * This listener gets to know which of them is active and + * keeps the main view informed whenever the state changes. + */ +public final class ArchNPickChangeListener implements ChangeListener { + + private final CMainView mainView; // main view + + private final JTabbedPane tabpane; // parent pane for archlist & pickmaps + + private int selectedIndex; // current state of selection + + /** + * Create an ArchNPickChangeListener. + * @param mainView the main view + * @param pane the JTabbedPane containing both archlist and pickmaps + */ + public ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { + this.mainView = mainView; + tabpane = pane; + selectedIndex = tabpane.getSelectedIndex(); + } + + public void stateChanged(final ChangeEvent e) { + if (tabpane.getSelectedIndex() != selectedIndex) { + // the state has changed, user has switched panels + if (tabpane.getSelectedIndex() == 0) { + mainView.setPickmapActive(false); + } else { + mainView.setPickmapActive(true); + } + + selectedIndex = tabpane.getSelectedIndex(); // save new state + } + } + +} // class ArchNPickChangeListener Property changes on: trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:14:50 UTC (rev 1499) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:36:39 UTC (rev 1500) @@ -41,8 +41,6 @@ import java.util.List; import java.util.Map; import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -278,7 +276,7 @@ } /** Update info which pickmap is currently on top. */ - private void updateActivePickmap() { + void updateActivePickmap() { if (tabpane == null) { return; // for safety, shouldn't happen } @@ -313,7 +311,7 @@ * @todo this method's name is a Bad Thing */ public void addPickmapSelectionListener(final JTabbedPane pickpane) { - pickpane.addChangeListener(new PickmapSelectionListener(pickpane)); + pickpane.addChangeListener(new PickmapSelectionListener(this, pickpane)); } /** @@ -326,67 +324,4 @@ pane.addChangeListener(new ArchNPickChangeListener(mainControl.getMainView(), pane)); } - // ------------------------ nested and inner classes ------------------------ - - /** Listener class to keep track of the currently active pickmap. */ - private final class PickmapSelectionListener implements ChangeListener { - - private final String activePickmap; // file-name of active pickmap - - private final JTabbedPane tabpane; - - private PickmapSelectionListener(final JTabbedPane pane) { - tabpane = pane; - activePickmap = null; - } - - public void stateChanged(final ChangeEvent e) { - if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { - // new pickmap is active - updateActivePickmap(); - } - } - - } // class PickmapSelectionListener - - /** - * In the left-side panel, archlist and pickmaps are exclusive - * (only the one being displayed is active). - * This listener gets to know which of them is active and - * keeps the main view informed whenever the state changes. - */ - private static final class ArchNPickChangeListener implements ChangeListener { - - private final CMainView mainView; // main view - - private final JTabbedPane tabpane; // parent pane for archlist & pickmaps - - private int selectedIndex; // current state of selection - - /** - * Create an ArchNPickChangeListener. - * @param mainView the main view - * @param pane the JTabbedPane containing both archlist and pickmaps - */ - private ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { - this.mainView = mainView; - tabpane = pane; - selectedIndex = tabpane.getSelectedIndex(); - } - - public void stateChanged(final ChangeEvent e) { - if (tabpane.getSelectedIndex() != selectedIndex) { - // the state has changed, user has switched panels - if (tabpane.getSelectedIndex() == 0) { - mainView.setPickmapActive(false); - } else { - mainView.setPickmapActive(true); - } - - selectedIndex = tabpane.getSelectedIndex(); // save new state - } - } - - } // class ArchNPickChangeListener - } // class PickmapChooserControl Added: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-07 15:36:39 UTC (rev 1500) @@ -0,0 +1,49 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.pickmapchooser; + +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +/** Listener class to keep track of the currently active pickmap. */ +public final class PickmapSelectionListener implements ChangeListener { + + private final PickmapChooserControl control; + + private final String activePickmap; // file-name of active pickmap + + private final JTabbedPane tabpane; + + public PickmapSelectionListener(final PickmapChooserControl control, final JTabbedPane pane) { + this.control = control; + tabpane = pane; + activePickmap = null; + } + + public void stateChanged(final ChangeEvent e) { + if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { + // new pickmap is active + control.updateActivePickmap(); + } + } + +} // class PickmapSelectionListener Property changes on: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java 2007-01-07 15:36:39 UTC (rev 1500) @@ -0,0 +1,66 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package daieditor.gui.pickmapchooser; + +import daieditor.CMainView; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +/** + * In the left-side panel, archlist and pickmaps are exclusive + * (only the one being displayed is active). + * This listener gets to know which of them is active and + * keeps the main view informed whenever the state changes. + */ +public final class ArchNPickChangeListener implements ChangeListener { + + private final CMainView mainView; // main view + + private final JTabbedPane tabpane; // parent pane for archlist & pickmaps + + private int selectedIndex; // current state of selection + + /** + * Create an ArchNPickChangeListener. + * @param mainView the main view + * @param pane the JTabbedPane containing both archlist and pickmaps + */ + public ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { + this.mainView = mainView; + tabpane = pane; + selectedIndex = tabpane.getSelectedIndex(); + } + + public void stateChanged(final ChangeEvent e) { + if (tabpane.getSelectedIndex() != selectedIndex) { + // the state has changed, user has switched panels + if (tabpane.getSelectedIndex() == 0) { + mainView.setPickmapActive(false); + } else { + mainView.setPickmapActive(true); + } + + selectedIndex = tabpane.getSelectedIndex(); // save new state + } + } + +} // class ArchNPickChangeListener Property changes on: trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:14:50 UTC (rev 1499) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:36:39 UTC (rev 1500) @@ -39,8 +39,6 @@ import java.util.Arrays; import java.util.List; import javax.swing.JTabbedPane; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -305,7 +303,7 @@ } /** Update info which pickmap is currently on top. */ - private void updateActivePickmap() { + void updateActivePickmap() { if (tabpane == null) { return; // for safety, shouldn't happen @@ -346,7 +344,7 @@ * @todo this method's name is a Bad Thing */ public void addPickmapSelectionListener(final JTabbedPane pickpane) { - pickpane.addChangeListener(new PickmapSelectionListener(pickpane)); + pickpane.addChangeListener(new PickmapSelectionListener(this, mainControl, pickpane)); } /** @@ -359,69 +357,4 @@ pane.addChangeListener(new ArchNPickChangeListener(mainControl.getMainView(), pane)); } - // ------------------------ nested and inner classes ------------------------ - - /** Listener class to keep track of the currently active pickmap. */ - private final class PickmapSelectionListener implements ChangeListener { - - private final String activePickmap; // file-name of active pickmap - - private final JTabbedPane tabpane; - - private PickmapSelectionListener(final JTabbedPane pane) { - tabpane = pane; - activePickmap = null; - } - - public void stateChanged(final ChangeEvent e) { - if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { - // new pickmap is active - updateActivePickmap(); - } - getInstance().getCurrentPickmap().getMapViewFrame().unHighlight(); - mainControl.showArchPanelQuickObject(null); // send it to quick view - } - - } // class PickmapSelectionListener - - /** - * In the left-side panel, archlist and pickmaps are exclusive - * (only the one being displayed is active). - * This listener gets to know which of them is active and - * keeps the main view informed whenever the state changes. - */ - private static final class ArchNPickChangeListener implements ChangeListener { - - private final CMainView mainView; // main view - - private final JTabbedPane tabpane; // parent pane for archlist & pickmaps - - private int selectedIndex; // current state of selection - - /** - * Create an ArchNPickChangeListener. - * @param mainView the main view - * @param pane the JTabbedPane containing both archlist and pickmaps - */ - private ArchNPickChangeListener(final CMainView mainView, final JTabbedPane pane) { - this.mainView = mainView; - tabpane = pane; - selectedIndex = tabpane.getSelectedIndex(); - } - - public void stateChanged(final ChangeEvent e) { - if (tabpane.getSelectedIndex() != selectedIndex) { - // the state has changed, user has switched panels - if (tabpane.getSelectedIndex() == 0) { - mainView.setPickmapActive(false); - } else { - mainView.setPickmapActive(true); - } - - selectedIndex = tabpane.getSelectedIndex(); // save new state - } - } - - } // class ArchNPickChangeListener - } // class PickmapChooserControl Added: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-07 15:36:39 UTC (rev 1500) @@ -0,0 +1,55 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package daieditor.gui.pickmapchooser; + +import daieditor.CMainControl; +import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +/** Listener class to keep track of the currently active pickmap. */ +public final class PickmapSelectionListener implements ChangeListener { + + private final PickmapChooserControl control; + + private final CMainControl mainControl; + + private final String activePickmap; // file-name of active pickmap + + private final JTabbedPane tabpane; + + public PickmapSelectionListener(final PickmapChooserControl control, final CMainControl mainControl, final JTabbedPane pane) { + this.control = control; + this.mainControl = mainControl; + tabpane = pane; + activePickmap = null; + } + + public void stateChanged(final ChangeEvent e) { + if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { + // new pickmap is active + control.updateActivePickmap(); + } + control.getCurrentPickmap().getMapViewFrame().unHighlight(); + mainControl.showArchPanelQuickObject(null); // send it to quick view + } + +} // class PickmapSelectionListener Property changes on: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 16:19:18
|
Revision: 1501 http://svn.sourceforge.net/gridarta/?rev=1501&view=rev Author: akirschbaum Date: 2007-01-07 08:19:18 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Split pickmap chooser into view and control. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 15:36:39 UTC (rev 1500) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -237,9 +237,6 @@ readGlobalSettings(); - // initialize pickmap panel (needed early during the loading process) - new PickmapChooserControl(); - // initialize the script-editor pad ScriptEditControl.init(strMapDir, this); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-07 15:36:39 UTC (rev 1500) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -209,6 +209,8 @@ // initialize pickmap panel pickmapPanel = new JTabbedPane(SwingConstants.TOP); + // initialize pickmap panel (needed early during the loading process) + new PickmapChooserControl(pickmapPanel); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:36:39 UTC (rev 1500) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -64,22 +64,24 @@ private boolean loadComplete; // true when all pickmaps have been loaded (at least one) - private JTabbedPane tabpane = null; // tab pane with pickmaps - /** All open pickmaps (the map controllers get stored in the vector). */ private final Map<String, MapControl> pickmaps = new HashMap<String, MapControl>(); /** The current active pickmap ontop. */ private MapControl currentPickMap; + /** The view for this control. */ + private final PickmapChooserView view; + /** * Create a PickmapChooserControl. */ - public PickmapChooserControl() { + public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); instance = this; loadComplete = false; currentPickMap = null; + view = new PickmapChooserView(tabpane); } /** @@ -112,9 +114,6 @@ * Load all pickmaps and build the pickmap-panel. */ public void loadPickmaps() { - // the main-panel for pickmaps: - tabpane = mainControl.getMainView().getPickmapPanel(); - final File pickmapDir = new File(IGUIConstants.PICKMAP_DIR); if (!pickmapDir.exists() || !pickmapDir.isDirectory()) { log.warn("No pickmaps directory found."); @@ -165,16 +164,10 @@ mainControl.getArchetypeParser().sortTempList(objects); // sort the list (put multiparts at the end) bmapview = newPickmap(objects, maparch, mapFile); // init the map } - - // looks like it worked, so we add a panel and display this pickmap - if (bmapview != null) { - int i; - for (i = 0; i < tabpane.getTabCount() && mapFile.getName().compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { - ; - } - tabpane.insertTab(mapFile.getName(), null, bmapview, null, i); - return true; + if (bmapview == null) { + return false; } + view.addPanel(mapFile.getName(), bmapview); } catch (final IOException e) { // loading failed - could be a system file in that directory, // or something else. Doesn't deserve more attention than a printout. @@ -182,7 +175,8 @@ log.warn("Couldn't load pickmap", e); } } - return false; + + return true; } /** @@ -203,18 +197,13 @@ } final CMapViewBasic bmapview = newPickmap(null, maparch, mapFile); - if (bmapview != null) { - // insert new pickmap in the alphabetic order - int i; - for (i = 0; i < tabpane.getTabCount() && mapFile.getName().compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { - ; - } - tabpane.insertTab(mapFile.getName(), null, bmapview, null, i); - setActivePickmap(mapFile.getName()); - loadComplete = true; - return true; + if (bmapview == null) { + return false; } - return false; + view.addPanel(mapFile.getName(), bmapview); + setActivePickmap(mapFile.getName()); + loadComplete = true; + return true; } /** @@ -252,7 +241,7 @@ final MapControl tmpMap = pickmaps.get(tmpKey); if (tmpMap == mapControl) { pickmaps.remove(tmpKey); - tabpane.remove(tmpMap.getMapViewFrame().getBasicView()); + view.removePanel(tmpMap.getMapViewFrame().getBasicView()); mapClosed = true; } } @@ -271,23 +260,23 @@ public void setActivePickmap(final String name) { final MapControl tmpMap = pickmaps.get(name); if (tmpMap != null) { - tabpane.setSelectedComponent(tmpMap.getMapViewFrame().getBasicView()); + view.selectPanel(tmpMap.getMapViewFrame().getBasicView()); } } /** Update info which pickmap is currently on top. */ void updateActivePickmap() { - if (tabpane == null) { - return; // for safety, shouldn't happen + if (pickmaps.isEmpty()) { + currentPickMap = null; + return; } - if (pickmaps.isEmpty()) { + final String newName = view.getSelectedPanelTitle(); + if (newName == null) { currentPickMap = null; return; } - final String newName = tabpane.getTitleAt(tabpane.getSelectedIndex()); - final MapControl tmp = pickmaps.get(newName); boolean foundMap = false; if (tmp != null && tmp.getMapFileName().endsWith("/"+newName)) { Added: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -0,0 +1,67 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2007 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.pickmapchooser; + +import java.awt.Component; +import javax.swing.JTabbedPane; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; + +/** + * @author Andreas Kirschbaum + */ +public final class PickmapChooserView { + + private static final Logger log = Logger.getLogger(PickmapChooserView.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + private final JTabbedPane tabpane; // tab pane with pickmaps + + public PickmapChooserView(final JTabbedPane tabpane) { + // the main-panel for pickmaps: + this.tabpane = tabpane; + } + + void addPanel(final String name, final Component mapView) { + int i; + for (i = 0; i < tabpane.getTabCount() && name.compareToIgnoreCase(tabpane.getTitleAt(i)) < 0; i++) { + ; + } + tabpane.insertTab(name, null, mapView, null, i); + } + + void removePanel(final Component mapView) { + tabpane.remove(mapView); + } + + void selectPanel(final Component mapView) { + tabpane.setSelectedComponent(mapView); + } + + String getSelectedPanelTitle() { + return tabpane.getTitleAt(tabpane.getSelectedIndex()); + } + +} // class PickmapChooserView Property changes on: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 15:36:39 UTC (rev 1500) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -410,9 +410,6 @@ readGlobalSettings(); - // initialize pickmap panel (needed early during the loading process) - new PickmapChooserControl(); - // initialize & load MultiPositionData.init(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-07 15:36:39 UTC (rev 1500) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -217,6 +217,8 @@ final int divLocation = prefs.getInt(DIVIDER_LOCATION_KEY, (int) (defwidth * 0.17)); pickmapPanel = new JTabbedPane(SwingConstants.TOP); + // initialize pickmap panel (needed early during the loading process) + new PickmapChooserControl(pickmapPanel); pickmapPanel.setComponentPopupMenu(ACTION_FACTORY.createPopupMenu(true, "pickmaps")); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 15:36:39 UTC (rev 1500) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -61,22 +61,24 @@ private boolean loadComplete; // true when all pickmaps have been loaded (at least one) - private JTabbedPane tabpane = null; // tab pane with pickmaps - /** All open pickmaps (the map controllers get stored in the vector). */ private final List<MapControl> pickmaps = new ArrayList<MapControl>(); /** The current active pickmap ontop. */ private MapControl currentPickMap; + /** The view for this control. */ + private final PickmapChooserView view; + /** * Create a PickmapChooserControl. */ - public PickmapChooserControl() { + public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); instance = this; loadComplete = false; currentPickMap = null; + view = new PickmapChooserView(tabpane); } /** @@ -107,9 +109,6 @@ * Load all pickmaps and build the pickmap-panel. */ public void loadPickmaps() { - // the main-panel for pickmaps: - tabpane = mainControl.getMainView().getPickmapPanel(); - final File pickmapDir = new File(CMainControl.getInstance().getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR); if (!pickmapDir.exists() || !pickmapDir.isDirectory()) { log.warn("No pickmaps directory found."); @@ -162,11 +161,7 @@ // looks like it worked, so we add a panel and display this pickmap if (bmapview != null) { - if (index < 0 || index >= tabpane.getTabCount()) { - tabpane.addTab(mapFile.getName(), bmapview); - } else { - tabpane.insertTab(mapFile.getName(), null, bmapview, null, index); - } + view.addPanel(mapFile.getName(), bmapview, index); bmapview.getMapControl().setPickmap(true); return true; } @@ -197,14 +192,14 @@ } final CMapViewBasic bmapview = newPickmap(null, maparch, mapFile, -1); - if (bmapview != null) { - bmapview.getLevel().save(); - tabpane.addTab(mapFile.getName(), bmapview); - setActivePickmap(tabpane.getTabCount() - 1); - loadComplete = true; - return true; + if (bmapview == null) { + return false; } - return false; + + bmapview.getLevel().save(); + setActivePickmap(view.addPanel(mapFile.getName(), bmapview, -1)); + loadComplete = true; + return true; } /** @@ -243,7 +238,7 @@ final MapControl tmpMap = pickmaps.get(i); if (tmpMap == mapControl) { pickmaps.remove(i); - tabpane.remove(i); + view.removePanel(i); mapClosed = true; } } @@ -297,18 +292,11 @@ * @param index tab index */ public void setActivePickmap(final int index) { - if (index >= 0 && index < tabpane.getTabCount()) { - tabpane.setSelectedIndex(index); - } + view.selectPanel(index); } /** Update info which pickmap is currently on top. */ void updateActivePickmap() { - - if (tabpane == null) { - return; // for safety, shouldn't happen - } - if (pickmaps.isEmpty()) { currentPickMap = null; return; @@ -316,9 +304,11 @@ boolean foundMap = false; + final String selectedName = view.getSelectedPanelTitle(); + // Fix for Mantis #0000541: pickmap selection doesn't work on windows // This has to be a '/' always, even on Windows, because the pickmap filename is a URI. - final String newName = '/' + tabpane.getTitleAt(tabpane.getSelectedIndex()); + final String newName = '/' + selectedName; for (MapControl tmp : pickmaps) { if (tmp != null && tmp.getMapFileName().endsWith(newName)) { Added: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java 2007-01-07 16:19:18 UTC (rev 1501) @@ -0,0 +1,71 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2007 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package daieditor.gui.pickmapchooser; + +import java.awt.Component; +import javax.swing.JTabbedPane; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; + +/** + * @author Andreas Kirschbaum + */ +public final class PickmapChooserView { + + private static final Logger log = Logger.getLogger(PickmapChooserView.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + + private final JTabbedPane tabpane; // tab pane with pickmaps + + public PickmapChooserView(final JTabbedPane tabpane) { + // the main-panel for pickmaps: + this.tabpane = tabpane; + } + + int addPanel(final String name, final Component mapView, final int index) { + if (index < 0 || index >= tabpane.getTabCount()) { + tabpane.addTab(name, mapView); + return tabpane.getTabCount() - 1; + } else { + tabpane.insertTab(name, null, mapView, null, index); + return index; + } + } + + void removePanel(final int index) { + tabpane.remove(index); + } + + void selectPanel(final int index) { + if (index >= 0 && index < tabpane.getTabCount()) { + tabpane.setSelectedIndex(index); + } + } + + String getSelectedPanelTitle() { + return tabpane.getTitleAt(tabpane.getSelectedIndex()); + } + +} // class PickmapChooserView Property changes on: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-07 18:57:50
|
Revision: 1504 http://svn.sourceforge.net/gridarta/?rev=1504&view=rev Author: christianhujer Date: 2007-01-07 10:57:49 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Updated JAPI version. Should fix some JAPI related bugs. Modified Paths: -------------- trunk/crossfire/build.xml trunk/crossfire/crossfire.iml trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java trunk/daimonin/build.xml trunk/daimonin/daimonin.iml trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java trunk/gridarta.iml trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/CFArchTypeList.java trunk/src/app/net/sf/gridarta/gameobject/Collectable.java trunk/src/app/net/sf/gridarta/gameobject/Collector.java trunk/src/app/net/sf/gridarta/gui/FileField.java Added Paths: ----------- trunk/lib/japi-lib-lang-0.1.jar trunk/lib/japi-lib-swing-action-0.1.jar trunk/lib/japi-lib-swing-extlib-0.1.jar trunk/lib/japi-lib-swing-misc-0.1.jar trunk/lib/japi-lib-swing-prefs-0.1.jar trunk/lib/japi-lib-swing-tod-0.1.jar trunk/lib/japi-lib-util-0.1.jar trunk/lib/japi-lib-xml-0.1.jar Removed Paths: ------------- trunk/lib/japi.jar Modified: trunk/crossfire/build.xml =================================================================== --- trunk/crossfire/build.xml 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/crossfire/build.xml 2007-01-07 18:57:49 UTC (rev 1504) @@ -94,7 +94,6 @@ <unjar src="${lib.dir}/bsh-classgen.jar" dest="${build.dir}" /> <unjar src="${lib.dir}/bsh-util.jar" dest="${build.dir}" /> <unjar src="${lib.dir}/log4j.jar" dest="${build.dir}" /> - <unjar src="../lib/japi.jar" dest="${build.dir}" /> <delete dir="${build.dir}/META-INF" /> <!-- copy the resource files into the build dir --> @@ -117,18 +116,7 @@ <fileset dir="${build.dir}" excludes="MANIFEST.MF,test/**"/> <fileset dir="${src.dir}" includes="**/*.properties" /> - <zipfileset src="../lib/japi.jar"> - <include name="net/sf/japi/swing/DisposeAction.class" /> - <include name="net/sf/japi/util/Arrays2.class" /> - <include name="net/sf/japi/util/filter/file/AbstractFileFilter.class" /> - <include name="net/sf/japi/util/filter/file/FileFilter.class" /> - <include name="net/sf/japi/util/filter/Filter.class" /> - <include name="net/sf/japi/util/filter/file/EndingFileFilter.class" /> - <include name="net/sf/japi/swing/ActionFactory.class" /> - <include name="net/sf/japi/swing/NamedActionMap.class" /> - <include name="net/sf/japi/swing/Progress.class" /> - <include name="net/sf/japi/swing/ProgressDisplay.class" /> - </zipfileset> + <zipgroupfileset dir="../lib/" includes="japi-*.jar" /> <!-- creating the manifest --> <manifest> <attribute name="Main-Class" value="cfeditor.CFJavaEditor"/> Modified: trunk/crossfire/crossfire.iml =================================================================== --- trunk/crossfire/crossfire.iml 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/crossfire/crossfire.iml 2007-01-07 18:57:49 UTC (rev 1504) @@ -62,6 +62,14 @@ <orderEntry type="library" name="japi" level="project" /> <orderEntry type="library" name="log4j-1.2.13" level="project" /> <orderEntry type="library" name="junit-4.1" level="project" /> + <orderEntry type="library" name="annotations" level="project" /> + <orderEntry type="library" name="japi-lib-lang-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-xml-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-action-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-util-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-misc-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-prefs-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-extlib-0.1" level="project" /> <orderEntryProperties /> </component> <component name="copyright"> Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -51,7 +51,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -31,7 +31,7 @@ import java.util.List; import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; /** Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -25,7 +25,7 @@ import java.io.File; import java.io.IOException; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; /** Modified: trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/crossfire/src/cfeditor/gui/prefs/GUIPrefs.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -43,9 +43,9 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.LocaleComparator; -import net.sf.japi.swing.LocaleListCellRenderer; +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. Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/build.xml 2007-01-07 18:57:49 UTC (rev 1504) @@ -136,44 +136,7 @@ <include name="arch/dev/editor/conf/ArchObjectMatchers.xml" /> </fileset> <zipfileset src="../lib/log4j-1.2.13.jar" /> - <zipfileset src="../lib/japi.jar"> - <include name="net/sf/japi/swing/ActionFactory.class" /> - <include name="net/sf/japi/swing/action*.properties" /> - <include name="net/sf/japi/swing/ColumnLayout.class" /> - <include name="net/sf/japi/swing/DisposeAction.class" /> - <include name="net/sf/japi/swing/DummyAction.class" /> - <include name="net/sf/japi/swing/IconManager.class" /> - <include name="net/sf/japi/swing/IconManager$1.class" /> - <include name="net/sf/japi/swing/JFileChooserButton.class" /> - <include name="net/sf/japi/swing/JSAXErrorHandler.class" /> - <include name="net/sf/japi/swing/LocaleComparator.class" /> - <include name="net/sf/japi/swing/LocaleListCellRenderer.class" /> - <include name="net/sf/japi/swing/NamedActionMap.class" /> - <include name="net/sf/japi/swing/prefs/AbstractPrefs.class" /> - <include name="net/sf/japi/swing/prefs/action*.properties" /> - <include name="net/sf/japi/swing/prefs/PreferencesGroup.class" /> - <include name="net/sf/japi/swing/prefs/PreferencesPane*.class" /> - <include name="net/sf/japi/swing/prefs/Prefs.class" /> - <include name="net/sf/japi/swing/Progress.class" /> - <include name="net/sf/japi/swing/ProgressDisplay.class" /> - <include name="net/sf/japi/swing/ReflectionAction.class" /> - <include name="net/sf/japi/swing/TipOfTheDayManager.class" /> - <include name="net/sf/japi/swing/ToggleAction.class" /> - <include name="net/sf/japi/util/Arrays2.class" /> - <include name="net/sf/japi/util/EnumerationIterator.class" /> - <include name="net/sf/japi/util/filter/file/AbstractFileFilter.class" /> - <include name="net/sf/japi/util/filter/file/EndingFileFilter.class" /> - <include name="net/sf/japi/util/filter/file/Factory*.class" /> - <include name="net/sf/japi/util/filter/file/FileFilter.class" /> - <include name="net/sf/japi/util/filter/file/FilenameFileFilter.class" /> - <include name="net/sf/japi/util/filter/file/GlobFileFilter.class" /> - <include name="net/sf/japi/util/filter/file/RegexFileFilter.class" /> - <include name="net/sf/japi/util/filter/Filter*.class" /> - <include name="net/sf/japi/util/ThrowableHandler.class" /> - <include name="net/sf/japi/xml/FilteredNodeList.class" /> - <include name="net/sf/japi/xml/NodeListIterator.class" /> - <include name="net/sf/japi/lang/SuperClassIterator.class" /> - </zipfileset> + <zipgroupfileset dir="../lib/" includes="japi-*.jar" /> <!-- creating the manifest --> <manifest> <attribute name="Main-Class" value="daieditor.CFJavaEditor"/> Modified: trunk/daimonin/daimonin.iml =================================================================== --- trunk/daimonin/daimonin.iml 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/daimonin.iml 2007-01-07 18:57:49 UTC (rev 1504) @@ -25,6 +25,15 @@ <orderEntry type="library" name="japi" level="project" /> <orderEntry type="library" name="log4j-1.2.13" level="project" /> <orderEntry type="library" name="junit-4.1" level="project" /> + <orderEntry type="library" name="annotations" level="project" /> + <orderEntry type="library" name="japi-lib-lang-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-xml-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-action-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-util-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-misc-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-prefs-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-tod-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-extlib-0.1" level="project" /> <orderEntryProperties /> </component> <component name="copyright"> Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -62,7 +62,7 @@ import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -44,7 +44,7 @@ import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -42,7 +42,7 @@ import javax.swing.GrayFilter; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -57,7 +57,7 @@ import net.sf.gridarta.Size2D; import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.JFileChooserButton; +import net.sf.japi.swing.misc.JFileChooserButton; /** * A dialog to change the properties of a map, like several flags and settings about the environment and the map tiles. Modified: trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/src/daieditor/gui/prefs/AppPrefs.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -46,7 +46,7 @@ import javax.swing.border.TitledBorder; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.JFileChooserButton; +import net.sf.japi.swing.misc.JFileChooserButton; import net.sf.japi.swing.prefs.AbstractPrefs; /** Modified: trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/daimonin/src/daieditor/gui/prefs/GUIPrefs.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -43,9 +43,9 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.LocaleComparator; -import net.sf.japi.swing.LocaleListCellRenderer; +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. Modified: trunk/gridarta.iml =================================================================== --- trunk/gridarta.iml 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/gridarta.iml 2007-01-07 18:57:49 UTC (rev 1504) @@ -18,6 +18,14 @@ <orderEntry type="library" name="japi" level="project" /> <orderEntry type="library" name="log4j-1.2.13" level="project" /> <orderEntry type="library" name="junit-4.1" level="project" /> + <orderEntry type="library" name="annotations" level="project" /> + <orderEntry type="library" name="japi-lib-lang-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-xml-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-action-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-util-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-misc-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-prefs-0.1" level="project" /> + <orderEntry type="library" name="japi-lib-swing-extlib-0.1" level="project" /> <orderEntryProperties /> </component> <component name="copyright"> Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/gridarta.ipr 2007-01-07 18:57:49 UTC (rev 1504) @@ -2190,13 +2190,6 @@ </doccer> </component> <component name="libraryTable"> - <library name="japi"> - <CLASSES> - <root url="jar://$PROJECT_DIR$/lib/japi.jar!/" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - </library> <library name="log4j-1.2.13"> <CLASSES> <root url="jar://$PROJECT_DIR$/lib/log4j-1.2.13.jar!/" /> @@ -2218,6 +2211,69 @@ <JAVADOC /> <SOURCES /> </library> + <library name="annotations"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/annotations.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-lang-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-lang-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-xml-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-xml-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-swing-action-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-swing-action-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-util-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-util-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-swing-misc-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-swing-misc-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-swing-prefs-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-swing-prefs-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-swing-tod-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-swing-tod-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + <library name="japi-lib-swing-extlib-0.1"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/japi-lib-swing-extlib-0.1.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> </component> <component name="org.tmatesoft.tmate.projectComponent" /> <component name="uidesigner-configuration"> Added: trunk/lib/japi-lib-lang-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-lang-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-swing-action-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-swing-action-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-swing-extlib-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-swing-extlib-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-swing-misc-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-swing-misc-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-swing-prefs-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-swing-prefs-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-swing-tod-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-swing-tod-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-util-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-util-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/lib/japi-lib-xml-0.1.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/japi-lib-xml-0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/lib/japi.jar =================================================================== (Binary files differ) Modified: trunk/src/app/net/sf/gridarta/CFArchTypeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/src/app/net/sf/gridarta/CFArchTypeList.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -17,7 +17,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.map.MapArchObject; -import net.sf.japi.swing.JSAXErrorHandler; +import net.sf.japi.swing.misc.JSAXErrorHandler; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gameobject/Collectable.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collectable.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/src/app/net/sf/gridarta/gameobject/Collectable.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -2,7 +2,7 @@ import java.io.File; import java.io.IOException; -import net.sf.japi.swing.Progress; +import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/gameobject/Collector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -7,8 +7,8 @@ import java.util.List; import javax.swing.JFrame; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.Progress; -import net.sf.japi.swing.ProgressDisplay; +import net.sf.japi.swing.misc.Progress; +import net.sf.japi.swing.misc.ProgressDisplay; /** * A Collector is capable of iterating over a collection of {@link Collectable}s and collecting them in a separate Thread with a nice GUI. Modified: trunk/src/app/net/sf/gridarta/gui/FileField.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/FileField.java 2007-01-07 18:39:50 UTC (rev 1503) +++ trunk/src/app/net/sf/gridarta/gui/FileField.java 2007-01-07 18:57:49 UTC (rev 1504) @@ -4,7 +4,7 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTextField; -import net.sf.japi.swing.JFileChooserButton; +import net.sf.japi.swing.misc.JFileChooserButton; /** * Class for selecting a file. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-07 19:35:14
|
Revision: 1505 http://svn.sourceforge.net/gridarta/?rev=1505&view=rev Author: christianhujer Date: 2007-01-07 11:35:10 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Added missing @Override annotations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-07 18:57:49 UTC (rev 1504) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-07 19:35:10 UTC (rev 1505) @@ -157,7 +157,7 @@ } } - public void levelCloseNotify() { + @Override public void levelCloseNotify() { super.levelCloseNotify(); levelClosing = true; mapViewFrame.closeNotify(); Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-07 18:57:49 UTC (rev 1504) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-07 19:35:10 UTC (rev 1505) @@ -206,7 +206,7 @@ } } - public void levelCloseNotify() { + @Override public void levelCloseNotify() { super.levelCloseNotify(); levelClosing = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-07 19:40:31
|
Revision: 1506 http://svn.sourceforge.net/gridarta/?rev=1506&view=rev Author: christianhujer Date: 2007-01-07 11:40:25 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fixed javadoc format / missing tag issues. Modified Paths: -------------- trunk/crossfire/src/cfeditor/filter/Filter.java trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/filter/Filter.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/Filter.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/filter/Filter.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -31,7 +31,7 @@ * not called with the remaining ArchObjects on the map square and a reset * is issued. * @param config Filterconfiguration to use - * @param object The Object being analysed on the map + * @param gameObject The Object being analysed on the map * @return true if it match the criterion, false otherwise. This value is * ignored if hasGlobalMatch() returns true. */ Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/PathButtonListener.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -28,6 +28,7 @@ /** * Small class, listening for button-press events in the popup frame for * script paths or create-new-event frame. + * @author Andreas Kirschbaum */ public final class PathButtonListener implements ActionListener { Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -36,7 +36,10 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; -/** Class which stores information about one scripted event. */ +/** + * Class which stores information about one scripted event. + * @author Andreas Kirschbaum + */ public final class ScriptedEvent { /** Logger. */ Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/ArchNPickChangeListener.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -30,6 +30,7 @@ * (only the one being displayed is active). * This listener gets to know which of them is active and * keeps the main view informed whenever the state changes. + * @author Andreas Kirschbaum */ public final class ArchNPickChangeListener implements ChangeListener { Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -75,6 +75,7 @@ /** * Create a PickmapChooserControl. + * @param tabpane Tabbed pane to create view on. */ public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserView.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -28,6 +28,7 @@ import org.apache.log4j.Logger; /** + * A View for choosing pickmaps. * @author Andreas Kirschbaum */ public final class PickmapChooserView { Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -24,7 +24,10 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -/** Listener class to keep track of the currently active pickmap. */ +/** + * Listener class to keep track of the currently active pickmap. + * @author Andreas Kirschbaum + */ public final class PickmapSelectionListener implements ChangeListener { private final PickmapChooserControl control; Modified: trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/daimonin/src/daieditor/gameobject/scripts/PathButtonListener.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -28,6 +28,7 @@ /** * Small class, listening for button-press events in the popup frame for * script paths or create-new-event frame. + * @author Andreas Kirschbaum */ public final class PathButtonListener implements ActionListener { Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -37,7 +37,10 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; -/** Class which stores information about one scripted event. */ +/** + * Class which stores information about one scripted event. + * @author Andreas Kirschbaum + */ public final class ScriptedEvent { /** Logger. */ Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/ArchNPickChangeListener.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -30,6 +30,7 @@ * (only the one being displayed is active). * This listener gets to know which of them is active and * keeps the main view informed whenever the state changes. + * @author Andreas Kirschbaum */ public final class ArchNPickChangeListener implements ChangeListener { Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -72,6 +72,7 @@ /** * Create a PickmapChooserControl. + * @param tabpane Tabbed pane to create view on. */ public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserView.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -28,6 +28,7 @@ import org.apache.log4j.Logger; /** + * A View for choosing pickmaps. * @author Andreas Kirschbaum */ public final class PickmapChooserView { Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -25,7 +25,10 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -/** Listener class to keep track of the currently active pickmap. */ +/** + * Listener class to keep track of the currently active pickmap. + * @author Andreas Kirschbaum + */ public final class PickmapSelectionListener implements ChangeListener { private final PickmapChooserControl control; Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2007-01-07 19:35:10 UTC (rev 1505) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2007-01-07 19:40:25 UTC (rev 1506) @@ -73,7 +73,7 @@ }; /** - * Create a new instance + * Create a new instance. */ protected AbstractMapControl() { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-07 19:46:59
|
Revision: 1507 http://svn.sourceforge.net/gridarta/?rev=1507&view=rev Author: christianhujer Date: 2007-01-07 11:47:00 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fixed declaration has problems in javadoc references. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-07 19:40:25 UTC (rev 1506) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-07 19:47:00 UTC (rev 1507) @@ -249,7 +249,7 @@ * The cursor position does not neccessarily mark a selection. * Selection is independent of the cursor. * @return cursor position - * @see #getCursorSquare() + * @see #setCursorPosition(Point) */ @Nullable public Point getCursorPosition() { return mapCursor.getLocation(); Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java 2007-01-07 19:40:25 UTC (rev 1506) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java 2007-01-07 19:47:00 UTC (rev 1507) @@ -337,7 +337,6 @@ /** * Fire a MapMetaChangedEvent. - * @param squares Squares to fire event for */ private void fireMetaChangedEvent() { for (final MapArchObjectListener<MapArchObject<M>> listener : listenerList.getListeners(MapArchObjectListener.class)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-07 19:55:20
|
Revision: 1511 http://svn.sourceforge.net/gridarta/?rev=1511&view=rev Author: christianhujer Date: 2007-01-07 11:55:21 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Cosmetic: Fixed performance issues. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapArchObject.java Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-07 19:54:39 UTC (rev 1510) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-07 19:55:21 UTC (rev 1511) @@ -362,7 +362,7 @@ * @param text string to add */ public void addText(@NotNull final String text) { - if (text.equals("")) { + if (text.length() == 0) { return; } @@ -407,7 +407,7 @@ * @param text string to add */ public void addLore(@NotNull final String text) { - if (text.equals("")) { + if (text.length() == 0) { return; } Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2007-01-07 19:54:39 UTC (rev 1510) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2007-01-07 19:55:21 UTC (rev 1511) @@ -337,7 +337,7 @@ * @param text string to add */ public void addText(@NotNull final String text) { - if (text.equals("")) { + if (text.length() == 0) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-07 20:03:34
|
Revision: 1512 http://svn.sourceforge.net/gridarta/?rev=1512&view=rev Author: christianhujer Date: 2007-01-07 12:03:31 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fixed probably bugs: @NotNull / @Nullable problems. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapViewIFrame.java trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -606,7 +606,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { // ignore } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -95,7 +95,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { updateTitle(); } Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -415,7 +415,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { // ignore } Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareView.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -390,7 +390,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { // ignore } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -2013,7 +2013,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { // ignore } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -371,7 +371,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { // ignore } Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -96,7 +96,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { updateTitle(); } Modified: trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareView.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -393,7 +393,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final MapArchObject mapArchObject) { + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/ConnectionView.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -126,7 +126,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final A mapArchObject) { + public void mapMetaChanged(@NotNull final A mapArchObject) { // ignore } Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2007-01-07 19:55:21 UTC (rev 1511) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControl.java 2007-01-07 20:03:31 UTC (rev 1512) @@ -66,7 +66,7 @@ } /** {@inheritDoc} */ - public void mapMetaChanged(final A mapArchObject) { + public void mapMetaChanged(@NotNull final A mapArchObject) { setModified(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 20:17:07
|
Revision: 1513 http://svn.sourceforge.net/gridarta/?rev=1513&view=rev Author: akirschbaum Date: 2007-01-07 12:17:02 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Implement undo/redo. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/action.properties trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapControl.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/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/gui/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java trunk/src/app/net/sf/gridarta/map/AbstractMapModel.java trunk/src/app/net/sf/gridarta/map/MapArchObject.java trunk/src/app/net/sf/gridarta/map/MapControl.java trunk/src/app/net/sf/gridarta/map/MapModel.java trunk/src/app/net/sf/gridarta/map/MapSquare.java trunk/src/app/net/sf/gridarta/messages.properties Added Paths: ----------- trunk/crossfire/resource/icons/general/Redo16.gif trunk/crossfire/resource/icons/general/Undo16.gif trunk/src/app/net/sf/gridarta/gui/undo/ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/MapState.java trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java trunk/src/app/net/sf/gridarta/undo/ trunk/src/app/net/sf/gridarta/undo/UndoModel.java trunk/src/app/net/sf/gridarta/undo/UndoState.java Removed Paths: ------------- trunk/crossfire/resource/icons/RedoIcon.gif trunk/crossfire/resource/icons/UndoIcon.gif trunk/daimonin/resource/icons/RedoIcon.gif trunk/daimonin/resource/icons/UndoIcon.gif trunk/daimonin/resource/icons/UndoSmallIcon.gif trunk/src/app/net/sf/gridarta/EditOperation.java trunk/src/app/net/sf/gridarta/UndoAndRedo.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/ChangeLog 2007-01-07 20:17:02 UTC (rev 1513) @@ -1,5 +1,7 @@ 2007-01-07 Andreas Kirschbaum + * Implement undo/redo. + * Update archetypes. * Do not reflect filter settings into pickmaps. Deleted: trunk/crossfire/resource/icons/RedoIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/UndoIcon.gif =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/icons/general/Redo16.gif (from rev 1442, trunk/daimonin/resource/icons/general/Redo16.gif) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/icons/general/Undo16.gif (from rev 1442, trunk/daimonin/resource/icons/general/Undo16.gif) =================================================================== (Binary files differ) Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -68,6 +68,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGridEvent; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.MapType; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; @@ -112,6 +113,9 @@ /** The main view. */ private final CMainView mainView; + /** The undo control. */ + @NotNull private final UndoControl undoControl; + /** Bit field of edit types to show only. */ private int tileEdit = 0; @@ -212,6 +216,7 @@ scriptControl = new CScriptController(this); mapCursorControl = new MapCursorControl(this); mainView = new CMainView(); + undoControl = new UndoControl(this); } /** Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -46,7 +46,6 @@ import javax.swing.JViewport; import javax.swing.ScrollPaneConstants; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.EditOperation; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapCursorEvent; @@ -395,9 +394,6 @@ } else { mapCursor.setLocation(mapLoc); } - /* - UndoAndRedo.getInstance(mapControl).add(new CPaintOp(previewRect, aOrigData, (short)mapControl.getSelectedTile())); - */ endFill(); } @@ -441,7 +437,9 @@ // Right Mouse Button: Arches get inserted all the way if (temp != null) { + mapControl.getMapModel().beginTransaction("Insert Object"); mapControl.insertSelArchToMap(temp, false); + mapControl.getMapModel().endTransaction(); } } else { mapCursor.setLocation(temp); @@ -465,7 +463,9 @@ } if (tmpArch != null) { mapControl.calcArchRedraw(tmpArch); // get redraw info + mapControl.getMapModel().beginTransaction("Delete Object"); mapControl.deleteMapArch(tmpArch, temp, MapModel.JOIN_ENABLE); + mapControl.getMapModel().endTransaction(); } } } @@ -480,6 +480,7 @@ startMapLoc = mapLoc; if (mapLoc.x != -1 && mapLoc.y != -1) { + mapControl.getMapModel().beginTransaction("Insert Object"); if (mapControl.isPickmap()) { // insert on pickmap insertMapArchToPickmap(mapLoc); @@ -504,6 +505,7 @@ insertArchName = "nothing"; } } + mapControl.getMapModel().endTransaction(); } } @@ -521,7 +523,9 @@ } if (tmpArch != null) { mapControl.calcArchRedraw(tmpArch); // get redraw info + mapControl.getMapModel().beginTransaction("Delete Object"); mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); + mapControl.getMapModel().endTransaction(); } } } @@ -610,56 +614,6 @@ // ignore } - public static final class CPaintOp implements EditOperation { - - final Rectangle fillRect; - - final int[][] aOrigData; - - final int tileIndex; - - CPaintOp(final Rectangle fillRect, final int[][] aOrigData, final int tileIndex) { - this.fillRect = fillRect; - this.aOrigData = aOrigData; - this.tileIndex = tileIndex; - } - - public void undo() { - for (int y = 0; y < fillRect.height; y++) { - for (int x = 0; x < fillRect.width; x++) { - //levelGrid[x+fillRect.x][y+fillRect.y] = - //aOrigData[x][y]; - //repaint(); - } - } - } - - public void redo() { - for (int y = fillRect.y; - y < fillRect.height + fillRect.y; - y++) { - for (int x = fillRect.x; - x < fillRect.width + fillRect.x; - x++) { - //levelGrid[x][y] = tileIndex; - //repaint(); - } - } - } - - public boolean isUndoable() { - return true; - } - - public boolean isRedoable() { - return true; - } - - public String getName() { - return "Paint"; - } - } - /** {@inheritDoc} */ public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { final MapCursor mapCursor = e.getSource(); Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -137,6 +137,11 @@ } mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N + + if (copyMapCtrl != null) { + copyMapCtrl.getMapModel().beginTransaction("Cut / Clear"); + } + final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); for (final MapSquare<GameObject, MapArchObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { final int posx = square.getMapX(); @@ -164,6 +169,10 @@ } } + if (copyMapCtrl != null) { + copyMapCtrl.getMapModel().beginTransaction("cut/copy"); + } + for (final GameObject gameObject : gameObjectsToDelete) { gameObject.remove(); } @@ -306,21 +315,16 @@ if (gameObject.isArchetype()) { mapControl.addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); } else { - final GameObject newHead = gameObject.createClone(pos.x, pos.y); - for (GameObject tmp = gameObject.getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { - final Point mapPos = new Point(pos.x + tmp.getMultiX(), pos.y + tmp.getMultiY()); - - if (!mapControl.isPointValid(mapPos)) { + final GameObject newGameObject = gameObject.createMultiClone(pos.x, pos.y); + for (GameObject tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { + if (!mapControl.isPointValid(new Point(tmp.getMapX(), tmp.getMapY()))) { // outside map return; } - - final GameObject newTail = tmp.createClone(mapPos.x, mapPos.y); - newHead.addTailPart(newTail); } - mapControl.addArchObjectToMap(newHead, fillBelow); - for (GameObject tmp = newHead.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + mapControl.addArchObjectToMap(newGameObject, fillBelow); + for (GameObject tmp = newGameObject.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { mapControl.addArchObjectToMap(tmp, fillBelow); mainControl.getArchetypeParser().postParseGameObject(tmp, mapControl.getActiveEditType()); } Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/action.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -10,7 +10,7 @@ main.menubar=file edit map cursor pickmaps resources tools analyze view plugins window help file.menu=createNew open close - save saveAs revert createImg - options - exit -edit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll +edit.menu=undo redo - clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterUpperMap enterLowerMap tileShow - mapProperties cursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes pickmaps.menu=lockAllPickmaps - addNewPickmap closePickmap - openPickmapMap - savePickmap revertPickmap @@ -25,7 +25,7 @@ mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowCursor mapwindowView mapwindowFile.menu=save saveAs createImg - revert - close -mapwindowEdit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow floodfill +mapwindowEdit.menu=undo redo - clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow floodfill mapwindowMap.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterUpperMap enterLowerMap tileShow - mapProperties mapwindowCursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes mapwindowView.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView @@ -57,6 +57,10 @@ exit.icon=EmptySmallIcon +undo.icon=general/Undo16 + +redo.icon=general/Redo16 + clear.icon=general/Remove16 cut.icon=general/Cut16 Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -473,14 +473,7 @@ return join; } - /** - * Returns a new GameObject, containing a copy of 'this' arch. References - * of course cannot be copied that way! This does NOT work for multipart - * objects. Also note that the returned clone is not linked to any map. - * @param posx map x coords. for the returned clone - * @param posy map y coords. for the returned clone - * @return clone instance of this <code>GameObject</code> - */ + /** {@inheritDoc} */ public GameObject createClone(final int posx, final int posy) { final GameObject clone = new GameObject(); // The clone is a new object! @@ -506,7 +499,7 @@ clone.animText = null; } - if (multi != null) { + if (multi != null && isHead()) { clone.initMultiData(); } clone.multiX = multiX; @@ -537,6 +530,15 @@ } /** {@inheritDoc} */ + public GameObject createMultiClone(final int posx, final int posy) { + final GameObject newHead = createClone(posx, posy); + for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); + } + return newHead; + } + + /** {@inheritDoc} */ public boolean isMulti() { return multi != null; } @@ -778,4 +780,19 @@ this.editorFolder = editorFolder; } + /** {@inheritDoc} */ + public boolean isEqual(@NotNull final GameObject gameObject) { + return super.isEqual(gameObject) + && (gameObject.faceName == null ? faceName == null : gameObject.faceName.equals(faceName)) + && (gameObject.animText == null ? animText == null : gameObject.animText.equals(animText)) + && (gameObject.loreText == null ? loreText == null : gameObject.loreText.equals(loreText)) + // ignore "script" + && gameObject.noface == noface + && gameObject.facenr == facenr + // ignore "editflag" + && gameObject.archType == archType + // ignore "join" + && (gameObject.editorFolder == null ? editorFolder == null : gameObject.editorFolder.equals(editorFolder)); + } + } // class GameObject Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -63,6 +63,8 @@ import net.sf.gridarta.CFArchType; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.connectionview.ConnectionControl; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -282,7 +284,12 @@ } mainControl.getArchetypeParser().postParseGameObject(invnew, 0); + final MapSquare mapSquare = inv.getMapSquare(); + assert mapSquare != null; + final MapModel mapModel = mapSquare.getModel(); + mapModel.beginTransaction("Add to inventory"); inv.addLast(invnew); + mapModel.endTransaction(); } /** @@ -307,6 +314,10 @@ return; } + final MapSquare mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Change object attributes"); + final String oldArchText = gameObject.getObjectText(); final String oldMsg = gameObject.getMsgText(); @@ -418,6 +429,8 @@ // Recalculate the editType value. It shall stay 100% accurate ;) gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); + mapSquare.getModel().endTransaction(); + // there we go!!!!! // now here will be the special panels added! refresh(); @@ -864,7 +877,11 @@ String eventType = (String) eventList.getSelectedValue(); if (eventType != null && eventType.length() > 0) { eventType = eventType.trim(); + final MapSquare mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Modify event script"); gameObject.getHead().modifyEventScript(eventType, task, eventList, this); + mapSquare.getModel().endTransaction(); } } } @@ -873,7 +890,11 @@ public void addNewScriptWanted() { final GameObject gameObject = mainControl.getMainView().getMapTileSelection(); // get selected arch if (gameObject != null) { + final MapSquare mapSquare = gameObject.getHead().getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Add event script"); gameObject.getHead().addEventScript(eventList, this); + mapSquare.getModel().endTransaction(); } } Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -442,14 +442,6 @@ return false; } - // if the mapsize has been modified, see if we should ask for a confirm - if (!mapControl.isCutoffSafe(mapSize)) { - if (!askConfirmResize(mapSize)) { - // resizing has been cancelled - mapSize = mapControl.getMapSize(); - } - } - // now that all is well, write the new values into the maparch final MapArchObject map = mapControl.getMapArchObject(); @@ -607,16 +599,6 @@ } /** - * Open a popup and ask user to confirm his map-resizing selection. This - * popup dialog disables all other windows (and threads). - * @param size New size for the map. - * @return true if user confirmed, false if user cancelled resize - */ - private boolean askConfirmResize(final Size2D size) { - return ACTION_FACTORY.showQuestionDialog(this, "mapShrink", size.getWidth(), size.getHeight()); - } - - /** * Show a dialog querying the user for map properties. * @param mainView CMainView to show dialog on * @param mainControl CMainControl with information Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -125,7 +125,11 @@ @ActionMethod public void moveTileTop() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Top"); arch.moveTop(); + mapSquare.getModel().endTransaction(); } } @@ -135,7 +139,11 @@ @ActionMethod public void moveTileUp() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Up"); arch.moveUp(); + mapSquare.getModel().endTransaction(); } } @@ -145,7 +153,11 @@ @ActionMethod public void moveTileDown() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Down"); arch.moveDown(); + mapSquare.getModel().endTransaction(); } } @@ -155,7 +167,11 @@ @ActionMethod public void moveTileBottom() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Bottom"); arch.moveBottom(); + mapSquare.getModel().endTransaction(); } } Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -28,6 +28,7 @@ import cfeditor.IGUIConstants; import java.io.BufferedReader; import java.io.IOException; +import java.util.Arrays; import net.sf.gridarta.Size2D; import net.sf.gridarta.map.AbstractMapArchObject; import org.jetbrains.annotations.NotNull; @@ -119,6 +120,62 @@ } /** + * Create a new instance as a copy of an existing map arch object. + * + * @param mapArchObject the map arch object to copy + */ + public MapArchObject(@NotNull final MapArchObject mapArchObject) { + super(mapArchObject); + msgText.append(mapArchObject.msgText.toString()); + loreText.append(mapArchObject.loreText.toString()); + unique = mapArchObject.unique; + template = mapArchObject.template; + outdoor = mapArchObject.outdoor; + nosmooth = mapArchObject.nosmooth; + temp = mapArchObject.temp; + pressure = mapArchObject.pressure; + humid = mapArchObject.humid; + windspeed = mapArchObject.windspeed; + winddir = mapArchObject.winddir; + sky = mapArchObject.sky; + shopItems = mapArchObject.shopItems; + shopGreed = mapArchObject.shopGreed; + shopMin = mapArchObject.shopMin; + shopMax = mapArchObject.shopMax; + region = mapArchObject.region; + for (int i = 0; i < tilePaths.length; i++) { + tilePaths[i] = mapArchObject.tilePaths[i]; + } + } + + /** {@inheritDoc} */ + public void setState(@NotNull final net.sf.gridarta.map.MapArchObject mapArchObjectIn) { + super.setState(mapArchObjectIn); + final MapArchObject mapArchObject = (MapArchObject) mapArchObjectIn; + setText(mapArchObject.msgText.toString()); + setLore(mapArchObject.loreText.toString()); + setUnique(mapArchObject.unique); + setTemplate(mapArchObject.template); + setOutdoor(mapArchObject.outdoor); + setNosmooth(mapArchObject.nosmooth); + setTemp(mapArchObject.temp); + setPressure(mapArchObject.pressure); + setHumid(mapArchObject.humid); + setWindspeed(mapArchObject.windspeed); + setWinddir(mapArchObject.winddir); + setSky(mapArchObject.sky); + setShopItems(mapArchObject.shopItems); + setShopRace(mapArchObject.shopRace); + setShopGreed(mapArchObject.shopGreed); + setShopMin(mapArchObject.shopMin); + setShopMax(mapArchObject.shopMax); + setRegion(mapArchObject.region); + for (int i = 0; i < tilePaths.length; i++) { + setTilePath(i, mapArchObject.tilePaths[i]); + } + } + + /** * {@inheritDoc} * @note Crossfire currently doesn't store additional information in a map name. */ @@ -709,4 +766,65 @@ appendable.append("end\n"); } + /** {@inheritDoc} */ + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof MapArchObject)) { + return false; + } + + final MapArchObject mapArchObject = (MapArchObject) obj; + return super.equals(obj) + && mapArchObject.msgText.toString().equals(msgText.toString()) + && mapArchObject.loreText.toString().equals(loreText.toString()) + && mapArchObject.unique == unique + && mapArchObject.template == template + && mapArchObject.outdoor == outdoor + && mapArchObject.nosmooth == nosmooth + && mapArchObject.temp == temp + && mapArchObject.pressure == pressure + && mapArchObject.humid == humid + && mapArchObject.windspeed == windspeed + && mapArchObject.winddir == winddir + && mapArchObject.sky == sky + && mapArchObject.shopItems.equals(shopItems) + && mapArchObject.shopRace.equals(shopRace) + && mapArchObject.shopGreed == shopGreed + && mapArchObject.shopMin == shopMin + && mapArchObject.shopMax == shopMax + && mapArchObject.region.equals(region) + && Arrays.equals(mapArchObject.tilePaths, tilePaths); + } + + /** {@inheritDoc} */ + public int hashCode() { + return super.hashCode() + + msgText.hashCode() + + loreText.hashCode() + + (unique ? 1 : 0) + + (template ? 2 : 0) + + (outdoor ? 4 : 0) + + (nosmooth ? 8 : 0) + + temp + + pressure + + humid + + windspeed + + winddir + + sky + + shopItems.hashCode() + + shopRace.hashCode() + + (int) shopGreed + + shopMin + + shopMax + + region.hashCode() + + Arrays.hashCode(tilePaths); + } + + /** {@inheritDoc} */ + public MapArchObject createClone() { + return new MapArchObject(this); + } + } // class MapArchObject Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -227,10 +227,6 @@ return mapModel.getMapArchObject().getTilePath(direction); } - public boolean isCutoffSafe(final Size2D size) { - return mapModel.isCutoffSafe(size); - } - public String getMapFileName() { return mapModel.getMapArchObject().getFileName(); } @@ -517,6 +513,7 @@ mapFile = file; } + /** {@inheritDoc} */ public MapArchObject getMapArchObject() { return mapModel.getMapArchObject(); } Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/messages.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -148,7 +148,7 @@ clear.accel=DELETE cut.text=Cut -cut.mnemonic=U +cut.mnemonic=T cut.accel=ctrl pressed X copy.text=Copy Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -177,8 +177,6 @@ mapWindDirection=Windrichtung mapWindSpeed=Windgeschwindigkeit -mapShrink.title=Karte verkleinern -mapShrink.message=Sie haben eine neue Kartengr\xF6\xDFe von {0,number,integer} \xD7 {1,number,integer} gew\xE4hlt. Wenn die Karte\nso verkleinert wird, werden einige Objekte gel\xF6scht.\nSind Sie sicher, dass Sie das wollen? mapErrorMissingMapName.title=Kartenname fehlt mapErrorMissingMapName.message=Dar Kartenname muss angegeben werden. mapErrorIllegalSize.title=Ung\xFCltiger Wert @@ -248,12 +246,14 @@ # Edit undo.text=R\xFCckg\xE4ngig +undo.name=R\xFCckg\xE4ngig {0} undo.shortdescription=Letze Aktion zur\xFCcknehmen undo.longdescription=Nimmt die letzte durchgef\xFChrte Aktion zur\xFCck. undo.mnemonic=R undo.accel=ctrl pressed Z redo.text=Wiederholen +redo.name=Wiederholen {0} redo.shortdescription=Letze Aktion wiederholen redo.longdescription=Wiederholt die letzte durchgef\xFChrte Aktion. redo.mnemonic=W Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -8,8 +8,6 @@ overwriteOtherFile.message=Un fichier nomm\xE9 "{0}" existe d\xE9j\xE0.\n\nVoulez vous vraiment le remplacer? mapTitle={0} ({1}) - Propri\xE9t\xE9s de la carte -mapShrink.title=Confirm shrinking map -mapShrink.message=Vous avez s\xE9lectionn\xE9 une carte de taille {0,number,integer} \xD7 {1,number,integer}. En modifiant la taille \nde la carte ainsi, certains objets seraient d\xE9truits.\\xCAtes-vous certain de le faire? #replace replaceTitle=Remplacer Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -135,8 +135,6 @@ mapTextTabTitle=Karttext mapTilesTabTitle=S\xF6kv\xE4gar -mapShrink.title=Bekr\xE4fta storleksminskning -mapShrink.message=Du valde en ny kartstorlek p\xE5 {0,number,integer} \xD7 {1,number,integer}. Om storleken \xE4ndras \ns\xE5, kan vissa objekt kapas bort och raderas.\n\xC4r du s\xE4ker att du vill forts\xE4tta? mapErrorMissingMapName.title=Kartnamn saknas. mapErrorMissingMapName.message=Du m\xE5ste ange ett kartnamn. mapErrorIllegalSize.title=Ogiltigt v\xE4rde Deleted: trunk/daimonin/resource/icons/RedoIcon.gif =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/icons/UndoIcon.gif =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/icons/UndoSmallIcon.gif =================================================================== (Binary files differ) Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -109,6 +109,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGridEvent; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; @@ -192,6 +193,9 @@ /** The main view. */ private final CMainView mainView; + /** The undo control. */ + @NotNull private final UndoControl undoControl; + /** Bit field of edit types to show only. */ private int tileEdit = 0; @@ -318,6 +322,7 @@ archetypeSet = new ArchetypeSet(this); mapCursorControl = new MapCursorControl(this); mainView = new CMainView(); + undoControl = new UndoControl(this); Updater.startup(mainView); init(); refreshMenusAndToolbars(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -747,10 +747,6 @@ private final Action aCreateImg = ACTION_FACTORY.createAction(true, "createImg", mainControl); - private final Action aUndo = ACTION_FACTORY.createAction(true, "undo", mainControl); - - private final Action aRedo = ACTION_FACTORY.createAction(true, "redo", mainControl); - private final Action aEnterExit = ACTION_FACTORY.createAction(true, "enterExit", mainControl); private final Action aMapCreateView = ACTION_FACTORY.createAction(true, "mapCreateView", mainControl); @@ -782,9 +778,6 @@ * @todo remove me */ private void refresh3() { - aUndo.setEnabled(false); - aRedo.setEnabled(false); - aCollectSpells.setEnabled(true); aEnterExit.setEnabled(false); Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -403,50 +403,6 @@ renderer.repaint(); } - // This can be done later, it was unused anyway. - //public static final class CPaintOp implements EditOperation { - - // final Rectangle fillRect; - // final int[][] aOrigData; - // final int tileIndex; - - // CPaintOp(Rectangle fillRect, int[][] aOrigData, int tileIndex) { - // this.fillRect = fillRect; - // this.aOrigData = aOrigData; - // this.tileIndex = tileIndex; - // } - - // public final void undo() { - // for (int y = 0; y < fillRect.height; y++) { - // for (int x = 0; x < fillRect.width; x++) { - // // levelGrid[x + fillRect.x][y + fillRect.y] = - // // aOrigData[x][y]; - // } - // } - // } - - // public final void redo() { - // for (int y = fillRect.y; y < fillRect.height + fillRect.y; y++) { - // for (int x = fillRect.x; x < fillRect.width + fillRect.x; x++) { - // // levelGrid[x][y] = tileIndex; - // } - // } - // } - - // public final boolean isUndoable() { - // return true; - // } - - // public final boolean isRedoable() { - // return true; - // } - - // public final String getName() { - // return "Paint"; - // } - - //} // class CPaintOp - /** {@inheritDoc} */ public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { final MapCursor mapCursor = e.getSource(); Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -139,6 +139,11 @@ } mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N + + if (copyMapCtrl != null) { + copyMapCtrl.getMapModel().beginTransaction("Cut / Clear"); + } + final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); for (final MapSquare<GameObject, MapArchObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { final int posx = square.getMapX(); @@ -166,6 +171,10 @@ } } + if (copyMapCtrl != null) { + copyMapCtrl.getMapModel().beginTransaction("cut/copy"); + } + for (final GameObject gameObject : gameObjectsToDelete) { gameObject.remove(); } @@ -464,21 +473,16 @@ if (gameObject.isArchetype()) { mapControl.getMapModel().addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, fillBelow); } else { - final GameObject newHead = gameObject.createClone(pos.x, pos.y); - for (GameObject tmp = gameObject.getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { - final Point mapPos = new Point(pos.x + tmp.getMultiX(), pos.y + tmp.getMultiY()); - - if (!mapControl.isPointValid(mapPos)) { + final GameObject newGameObject = gameObject.createMultiClone(pos.x, pos.y); + for (GameObject tmp = newGameObject; tmp != null; tmp = tmp.getMultiNext()) { + if (!mapControl.isPointValid(new Point(tmp.getMapX(), tmp.getMapY()))) { // outside map return; } - - final GameObject newTail = tmp.createClone(mapPos.x, mapPos.y); - newHead.addTailPart(newTail); } - mapControl.getMapModel().addGameObjectToMap(newHead, fillBelow); - for (GameObject tmp = newHead.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + mapControl.getMapModel().addGameObjectToMap(newGameObject, fillBelow); + for (GameObject tmp = newGameObject.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { mapControl.getMapModel().addGameObjectToMap(tmp, fillBelow); mainControl.getArchetypeParser().postParseGameObject(tmp, mapControl.getActiveEditType()); } Modified: trunk/daimonin/src/daieditor/action.properties =================================================================== --- trunk/daimonin/src/daieditor/action.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/action.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -9,7 +9,7 @@ # Menus main.menubar=file edit map cursor pickmaps resources tools view window help file.menu=createNew open recent close closeAll - save saveAs revert createImg - options - exit -edit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll +edit.menu=undo redo - clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow floodfill - selectAll map.menu=enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterNorthEastMap enterSouthEastMap enterSouthWestMap enterNorthWestMap - mapCreateView mapProperties cursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -528,14 +528,7 @@ } } - /** - * Returns a new GameObject, containing a copy of 'this' arch. References - * of course cannot be copied that way! This does NOT work for multipart - * objects. Also note that the returned clone is not linked to any map. - * @param posx map x coords. for the returned clone - * @param posy map y coords. for the returned clone - * @return clone instance of this <code>GameObject</code> - */ + /** {@inheritDoc} */ public GameObject createClone(final int posx, final int posy) { final GameObject clone = clone(); // The clone is a new object! @@ -544,7 +537,8 @@ clone.msgText = new StringBuffer(msgText); } - if (multi != null) { + if (multi != null && isHead()) { + clone.multi = null; clone.initMultiData(); } clone.multiX = multiX; @@ -562,6 +556,16 @@ } /** {@inheritDoc} */ + public GameObject createMultiClone(final int posx, final int posy) { + final GameObject newHead = createClone(posx, posy); + for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { + newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); + } + + return newHead; + } + + /** {@inheritDoc} */ public boolean isMulti() { return multi != null; } @@ -737,6 +741,25 @@ this.editorFolder = editorFolder; } + /** {@inheritDoc} */ + public boolean isEqual(@NotNull final GameObject gameObject) { + return super.isEqual(gameObject) + && (gameObject.faceObjName == null ? faceObjName == null : gameObject.faceObjName.equals(faceObjName)) + && (gameObject.faceRealName == null ? faceRealName == null : gameObject.faceRealName.equals(faceRealName)) + && (gameObject.animName == null ? animName == null : gameObject.animName.equals(animName)) + && gameObject.multiPartNr == multiPartNr + && gameObject.isLowestPart == isLowestPart + // ignore "script" + && gameObject.noface == noface + // ignore "faceobjdesc" (XXX: is this correct?) + && gameObject.directionSet == directionSet + && gameObject.direction == direction + && gameObject.archType == archType + && (gameObject.editorFolder == null ? editorFolder == null : gameObject.editorFolder.equals(editorFolder)) + && gameObject.normalFace == normalFace + && gameObject.transFace == transFace; + } + /** Enumeration describing the state of the face. */ public enum FaceDesc { Modified: trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/gui/GameObjectAttributesPanel.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -65,6 +65,8 @@ import net.sf.gridarta.CFArchType; import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.connectionview.ConnectionControl; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -304,8 +306,13 @@ invnew.setDirection(invnew.getArchetype().getDirection()); mainControl.getArchetypeParser().postParseGameObject(invnew, 0); + final MapSquare mapSquare = inv.getMapSquare(); + assert mapSquare != null; + final MapModel mapModel = mapSquare.getModel(); + mapModel.beginTransaction("Add to inventory"); inv.addLast(invnew); invnew.setObjectFace(); + mapModel.endTransaction(); mainControl.getCurrentMap().repaint(); // XXX not nice but no better way yet } @@ -330,6 +337,10 @@ return; } + final MapSquare mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Change object attributes"); + // We update all panels: name, face, msg and archText (more to come...) // the obj name: if (isNonwhitespaceText(archNameField.getText())) { // there is something in @@ -416,6 +427,8 @@ // Recalculate the editType value. It shall stay 100% accurate ;) gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); + mapSquare.getModel().endTransaction(); + // there we go!!!!! // now here will be the special panels added! refresh(); @@ -993,7 +1006,11 @@ // there final int index = eventList.getSelectedIndex(); if (index >= 0) { + final MapSquare mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Modify event script"); gameObject.getHead().modifyEventScript(index, task, eventList, this); + mapSquare.getModel().endTransaction(); } } } @@ -1002,7 +1019,11 @@ public void addNewScriptWanted() { final GameObject gameObject = mainControl.getMainView().getMapTileSelection(); // get selected arch if (gameObject != null) { + final MapSquare mapSquare = gameObject.getHead().getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Add event script"); gameObject.getHead().addEventScript(eventList, this); + mapSquare.getModel().endTransaction(); } } Modified: trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/gui/map/MapPropertiesDialog.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -439,18 +439,11 @@ return false; } - // if the mapsize has been modified, see if we should ask for a confirm - if (!mapControl.isCutoffSafe(mapSize)) { - if (!askConfirmResize(mapSize)) { - // resizing has been cancelled - mapSize = mapControl.getMapSize(); - } - } - // now that all is well, write the new values into the maparch final MapArchObject map = mapControl.getMapArchObject(); + mapControl.getMapModel().beginTransaction("Map properties"); // TODO: I18N/L10N map.beginTransaction(); final String mapNameString = mapName.getText() + (mapSound.getText().length() > 0 ? '§' + mapSound.getText() + "|0|-1" : ""); @@ -480,6 +473,7 @@ mapTilePane.modifyMapProperties(); + mapControl.getMapModel().endTransaction(); map.endTransaction(); return true; @@ -537,16 +531,6 @@ } /** - * Open a popup and ask user to confirm his map-resizing selection. This - * popup dialog disables all other windows (and threads). - * @param size New size for the map. - * @return true if user confirmed, false if user cancelled resize - */ - private boolean askConfirmResize(final Size2D size) { - return ACTION_FACTORY.showQuestionDialog(this, "mapShrink", size.getWidth(), size.getHeight()); - } - - /** * Show a dialog querying the user for map properties. * @param mainView CMainView to show dialog on * @param mainControl CMainControl with information Modified: trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/gui/map/tools/DeletionTool.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -72,12 +72,14 @@ final MapSquare<GameObject, MapArchObject> mapSquare = mapControl.getMapModel().getMapSquare(mapLoc); for (final GameObject searchArch : deleteBelow ? mapSquare : mapSquare.reverse()) { if (CMainControl.getInstance().isTileEdit(searchArch)) { - delArch = searchArch; + delArch = searchArch.getHead(); break; } } if (delArch != null) { + mapSquare.getModel().beginTransaction("Delete Object"); delArch.remove(); + mapSquare.getModel().endTransaction(); } } Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -43,6 +43,7 @@ final MapControl mapControl = e.getMapControl(); final boolean selChange = mapCursor.isActive(); if (p != null) { + mapControl.getMapModel().beginTransaction("Insert Object"); if (mapControl.isPickmap()) { // insert on pickmap mapControl.insertMapArchToPickmap(p); @@ -51,6 +52,7 @@ mapControl.insertSelArchToMap(p, true); mapCursor.setLocation(p); } + mapControl.getMapModel().endTransaction(); } if (!(selChange == mapCursor.isActive())) { CMainControl.getInstance().getMainView().refreshMenus(); @@ -63,7 +65,9 @@ final MapCursor mapCursor = e.getMapCursor(); final MapControl mapControl = e.getMapControl(); if (!mapControl.isPickmap() && mapCursor.setLocationSafe(p)) { + mapControl.getMapModel().beginTransaction("Insert Object"); mapControl.insertSelArchToMap(p, false); + mapControl.getMapModel().endTransaction(); } } Modified: trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -88,7 +88,11 @@ @ActionMethod public void moveTileTop() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Top"); arch.moveTop(); + mapSquare.getModel().endTransaction(); } } @@ -98,7 +102,11 @@ @ActionMethod public void moveTileUp() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Up"); arch.moveUp(); + mapSquare.getModel().endTransaction(); } } @@ -108,7 +116,11 @@ @ActionMethod public void moveTileDown() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Down"); arch.moveDown(); + mapSquare.getModel().endTransaction(); } } @@ -118,7 +130,11 @@ @ActionMethod public void moveTileBottom() { final GameObject arch = getMapTileSelection(); if (arch != null) { + final MapSquare mapSquare = arch.getMapSquare(); + assert mapSquare != null; + mapSquare.getModel().beginTransaction("Move Bottom"); arch.moveBottom(); + mapSquare.getModel().endTransaction(); } } Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -28,6 +28,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.Serializable; +import java.util.Arrays; import java.util.Formatter; import net.sf.gridarta.Size2D; import net.sf.gridarta.map.AbstractMapArchObject; @@ -119,6 +120,32 @@ } /** + * Create a new instance as a copy of an existing map arch object. + * + * @param mapArchObject the map arch object to copy + */ + public MapArchObject(@NotNull final MapArchObject mapArchObject) { + super(mapArchObject); + outdoor = mapArchObject.outdoor; + noSave = mapArchObject.noSave; + noMagic = mapArchObject.noMagic; + noPriest = mapArchObject.noPriest; + noHarm = mapArchObject.noHarm; + noSummon = mapArchObject.noSummon; + fixedLogin = mapArchObject.fixedLogin; + permDeath = mapArchObject.permDeath; + ultraDeath = mapArchObject.ultraDeath; + ultimateDeath = mapArchObject.ultimateDeath; + pvp = mapArchObject.pvp; + for (int i = 0; i < tilePaths.length; i++) { + tilePaths[i] = mapArchObject.tilePaths[i]; + } + tilesetId = mapArchObject.tilesetId; + tilesetX = mapArchObject.tilesetX; + tilesetY = mapArchObject.tilesetY; + } + + /** * {@inheritDoc} * @note Daimonin stores background music information in the map name. */ @@ -626,4 +653,59 @@ appendable.append("end\n"); } + /** {@inheritDoc} */ + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof MapArchObject)) { + return false; + } + + final MapArchObject mapArchObject = (MapArchObject) obj; + return super.equals(obj) + && mapArchObject.msgText.toString().equals(msgText.toString()) + && mapArchObject.outdoor == outdoor + && mapArchObject.noSave == noSave + && mapArchObject.noMagic == noMagic + && mapArchObject.noPriest == noPriest + && mapArchObject.noHarm == noHarm + && mapArchObject.noSummon == noSummon + && mapArchObject.fixedLogin == fixedLogin + && mapArchObject.permDeath == permDeath + && mapArchObject.ultraDeath == ultraDeath + && mapArchObject.ultimateDeath == ultimateDeath + && mapArchObject.pvp == pvp + && Arrays.equals(mapArchObject.tilePaths, tilePaths) + && mapArchObject.tilesetId == tilesetId + && mapArchObject.tilesetX == tilesetX + && mapArchObject.tilesetY == tilesetY; + } + + /** {@inheritDoc} */ + public int hashCode() { + return super.hashCode() + + msgText.hashCode() + + (outdoor ? 1 : 0) + + (noSave ? 2 : 0) + + (noMagic ? 4 : 0) + + (noPriest ? 8 : 0) + + (noHarm ? 16 : 0) + + (noSummon ? 32 : 0) + + (fixedLogin ? 64 : 0) + + (permDeath ? 128 : 0) + + (ultraDeath ? 256 : 0) + + (ultimateDeath ? 512 : 0) + + (pvp ? 1024 : 0) + + Arrays.hashCode(tilePaths) + + tilesetId + + tilesetX + + tilesetY; + } + + /** {@inheritDoc} */ + public MapArchObject createClone() { + return new MapArchObject(this); + } + } // class MapArchObject Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-07 20:17:02 UTC (rev 1513) @@ -257,10 +257,6 @@ return mapModel.isPointValid(pos); } - public boolean isCutoffSafe(final Size2D size) { - return mapModel.isCutoffSafe(size); - } - // TODO: Rename because the filename is a URI now. public String getMapFileName() { return mapModel.getMapArchObject().getFileName(); @@ -629,6 +625,7 @@ isPickmap = pickmap; } + /** {@inheritDoc} */ public MapArchObject getMapArchObject() { return mapModel.getMapArchObject(); } Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/messages.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -294,10 +294,6 @@ edit.text=Edit edit.mnemonic=E -undo.error.text=Can''t undo last action - -redo.error.text=Can''t redo - clear.text=Clear clear.mnemonic=L clear.shortdescription=Clear selection @@ -306,7 +302,7 @@ clear.accel=DELETE cut.text=Cut -cut.mnemonic=U +cut.mnemonic=T cut.accel=ctrl pressed X copy.text=Copy Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2007-01-07 20:03:31 UTC (rev 1512) +++ trunk/daimonin/src/daieditor/messages_de.properties 2007-01-07 20:17:02 UTC (rev 1513) @@ -92,8 +92,6 @@ mapTilesAttach.shortdescription=Verbindet die Karte automatisch in allen Richtungen mit ihren benachbarten Karten. mapTilesClear.text=Pfade l\xF6schen mapTilesClear.shortdescription=L\xF6scht die Verbindungspfade zu den benachbarten Karten. -mapShrink.title=Karte verkleinern -mapShrink.message=Du hast eine neue Kartengr\xF6\xDFe von {0,number,integer} \xD7 {1,number,integer} gew\xE4hlt. Wenn die Karte\nso verkleinert wird, werden einige Objekte gel\xF6scht.\nBist Du sicher, dass Du das willst? mapHelp.text=Hilfe mapOkay.text=OK mapRestore.text=Zur\xFCcksetzen @@ -252,18 +250,18 @@ edit.mnemonic=B undo.text=R\xFCckg\xE4ngig +undo.name=R\xFCckg\xE4ngig {0} undo.shortdescription=Letze \xC4nderung r\xFCckg\xE4ngig undo.longdescription=Macht die letzte \xC4nderung r\xFCckg\xE4ngig, falls m\xF6glich undo.mnemonic=R undo.accel=ctrl pressed Z -u... [truncated message content] |
From: <chr...@us...> - 2007-01-07 23:37:04
|
Revision: 1514 http://svn.sourceforge.net/gridarta/?rev=1514&view=rev Author: christianhujer Date: 2007-01-07 15:37:02 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fixed inspection issues / warnings. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java trunk/src/app/net/sf/gridarta/map/MapArchObject.java trunk/src/app/net/sf/gridarta/map/MapState.java trunk/src/app/net/sf/gridarta/undo/UndoModel.java trunk/src/app/net/sf/gridarta/undo/UndoState.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -474,7 +474,7 @@ } /** {@inheritDoc} */ - public GameObject createClone(final int posx, final int posy) { + @Override public GameObject createClone(final int posx, final int posy) { final GameObject clone = new GameObject(); // The clone is a new object! clone.faceName = faceName; // face name @@ -530,7 +530,7 @@ } /** {@inheritDoc} */ - public GameObject createMultiClone(final int posx, final int posy) { + @Override public GameObject createMultiClone(final int posx, final int posy) { final GameObject newHead = createClone(posx, posy); for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -143,35 +143,33 @@ shopMin = mapArchObject.shopMin; shopMax = mapArchObject.shopMax; region = mapArchObject.region; - for (int i = 0; i < tilePaths.length; i++) { - tilePaths[i] = mapArchObject.tilePaths[i]; - } + System.arraycopy(mapArchObject.tilePaths, 0, tilePaths, 0, tilePaths.length); } /** {@inheritDoc} */ - public void setState(@NotNull final net.sf.gridarta.map.MapArchObject mapArchObjectIn) { - super.setState(mapArchObjectIn); - final MapArchObject mapArchObject = (MapArchObject) mapArchObjectIn; - setText(mapArchObject.msgText.toString()); - setLore(mapArchObject.loreText.toString()); - setUnique(mapArchObject.unique); - setTemplate(mapArchObject.template); - setOutdoor(mapArchObject.outdoor); - setNosmooth(mapArchObject.nosmooth); - setTemp(mapArchObject.temp); - setPressure(mapArchObject.pressure); - setHumid(mapArchObject.humid); - setWindspeed(mapArchObject.windspeed); - setWinddir(mapArchObject.winddir); - setSky(mapArchObject.sky); - setShopItems(mapArchObject.shopItems); - setShopRace(mapArchObject.shopRace); - setShopGreed(mapArchObject.shopGreed); - setShopMin(mapArchObject.shopMin); - setShopMax(mapArchObject.shopMax); - setRegion(mapArchObject.region); + @Override public void setState(@NotNull final net.sf.gridarta.map.MapArchObject mapArchObject) { + super.setState(mapArchObject); + final MapArchObject myMapArchObject = (MapArchObject) mapArchObject; + setText(myMapArchObject.msgText.toString()); + setLore(myMapArchObject.loreText.toString()); + setUnique(myMapArchObject.unique); + setTemplate(myMapArchObject.template); + setOutdoor(myMapArchObject.outdoor); + setNosmooth(myMapArchObject.nosmooth); + setTemp(myMapArchObject.temp); + setPressure(myMapArchObject.pressure); + setHumid(myMapArchObject.humid); + setWindspeed(myMapArchObject.windspeed); + setWinddir(myMapArchObject.winddir); + setSky(myMapArchObject.sky); + setShopItems(myMapArchObject.shopItems); + setShopRace(myMapArchObject.shopRace); + setShopGreed(myMapArchObject.shopGreed); + setShopMin(myMapArchObject.shopMin); + setShopMax(myMapArchObject.shopMax); + setRegion(myMapArchObject.region); for (int i = 0; i < tilePaths.length; i++) { - setTilePath(i, mapArchObject.tilePaths[i]); + setTilePath(i, myMapArchObject.tilePaths[i]); } } @@ -767,7 +765,8 @@ } /** {@inheritDoc} */ - public boolean equals(final Object obj) { + @SuppressWarnings({"FloatingPointEquality"}) + @Override public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -799,7 +798,7 @@ } /** {@inheritDoc} */ - public int hashCode() { + @Override public int hashCode() { return super.hashCode() + msgText.hashCode() + loreText.hashCode() @@ -823,7 +822,7 @@ } /** {@inheritDoc} */ - public MapArchObject createClone() { + @NotNull public MapArchObject createClone() { return new MapArchObject(this); } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -514,7 +514,7 @@ } /** {@inheritDoc} */ - public MapArchObject getMapArchObject() { + @NotNull public MapArchObject getMapArchObject() { return mapModel.getMapArchObject(); } Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -529,7 +529,7 @@ } /** {@inheritDoc} */ - public GameObject createClone(final int posx, final int posy) { + @Override public GameObject createClone(final int posx, final int posy) { final GameObject clone = clone(); // The clone is a new object! // Clone Recursion for complex types @@ -556,7 +556,7 @@ } /** {@inheritDoc} */ - public GameObject createMultiClone(final int posx, final int posy) { + @Override public GameObject createMultiClone(final int posx, final int posy) { final GameObject newHead = createClone(posx, posy); for (GameObject tmp = getArchetype().getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { newHead.addTailPart(tmp.createClone(posx + tmp.getMultiX(), posy + tmp.getMultiY())); Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -137,9 +137,7 @@ ultraDeath = mapArchObject.ultraDeath; ultimateDeath = mapArchObject.ultimateDeath; pvp = mapArchObject.pvp; - for (int i = 0; i < tilePaths.length; i++) { - tilePaths[i] = mapArchObject.tilePaths[i]; - } + System.arraycopy(mapArchObject.tilePaths, 0, tilePaths, 0, tilePaths.length); tilesetId = mapArchObject.tilesetId; tilesetX = mapArchObject.tilesetX; tilesetY = mapArchObject.tilesetY; @@ -654,7 +652,7 @@ } /** {@inheritDoc} */ - public boolean equals(final Object obj) { + @Override public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -683,7 +681,7 @@ } /** {@inheritDoc} */ - public int hashCode() { + @Override public int hashCode() { return super.hashCode() + msgText.hashCode() + (outdoor ? 1 : 0) @@ -704,7 +702,7 @@ } /** {@inheritDoc} */ - public MapArchObject createClone() { + @NotNull public MapArchObject createClone() { return new MapArchObject(this); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -626,7 +626,7 @@ } /** {@inheritDoc} */ - public MapArchObject getMapArchObject() { + @NotNull public MapArchObject getMapArchObject() { return mapModel.getMapArchObject(); } Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -1026,6 +1026,8 @@ * @param posx the x-map coordinate * * @param posy the y-map coordinate + * + * @return Newly created multi clone. */ public abstract G createMultiClone(int posx, int posy); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -409,6 +409,7 @@ return false; } + //noinspection ForLoopReplaceableByForEach for (int i = 0; i < contents.size(); i++) { if (!gameObjectContainer.contents.get(i).isEqual(contents.get(i))) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -37,6 +37,7 @@ /** * The class <code>UndoControl</code> implements the controller for undo/redo * actions. + * @author Andreas Kirschbaum */ public class UndoControl { Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapArchObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -275,22 +275,22 @@ } /** {@inheritDoc} */ - public void setState(@NotNull final MapArchObject mapArchObjectIn) { - final AbstractMapArchObject mapArchObject = (AbstractMapArchObject) mapArchObjectIn; - mapSize = mapArchObject.mapSize; - mapName = mapArchObject.mapName; - fileName = mapArchObject.fileName; - enterX = mapArchObject.enterX; - enterY = mapArchObject.enterY; - resetTimeout = mapArchObject.resetTimeout; - swapTime = mapArchObject.swapTime; - difficulty = mapArchObject.difficulty; - fixedReset = mapArchObject.fixedReset; - darkness = mapArchObject.darkness; + public void setState(@NotNull final MapArchObject mapArchObject) { + final AbstractMapArchObject abstractMapArchObject = (AbstractMapArchObject) mapArchObject; + mapSize = abstractMapArchObject.mapSize; + mapName = abstractMapArchObject.mapName; + fileName = abstractMapArchObject.fileName; + enterX = abstractMapArchObject.enterX; + enterY = abstractMapArchObject.enterY; + resetTimeout = abstractMapArchObject.resetTimeout; + swapTime = abstractMapArchObject.swapTime; + difficulty = abstractMapArchObject.difficulty; + fixedReset = abstractMapArchObject.fixedReset; + darkness = abstractMapArchObject.darkness; } /** {@inheritDoc} */ - public boolean equals(final Object obj) { + @Override public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -312,7 +312,7 @@ } /** {@inheritDoc} */ - public int hashCode() { + @Override public int hashCode() { return mapSize.hashCode() + mapName.hashCode() + fileName.hashCode() Modified: trunk/src/app/net/sf/gridarta/map/MapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapArchObject.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/map/MapArchObject.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -204,6 +204,7 @@ /** * Create a copy of this object. + * @return Newly created clone of this object. */ @NotNull MapArchObject createClone(); Modified: trunk/src/app/net/sf/gridarta/map/MapState.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapState.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/map/MapState.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -94,7 +94,7 @@ } /** {@inheritDoc} */ - public boolean equals(final Object obj) { + @Override public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -147,7 +147,7 @@ } /** {@inheritDoc} */ - public int hashCode() { + @Override public int hashCode() { return mapArchObject.hashCode() + Arrays.hashCode(mapGrid); } Modified: trunk/src/app/net/sf/gridarta/undo/UndoModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/undo/UndoModel.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/undo/UndoModel.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -46,7 +46,7 @@ @NotNull private final ArrayList<UndoState> undoStack = new ArrayList<UndoState>(); /** - * Current index into {@link undoStack}. If <code>undoStackIndex == + * Current index into {@link #undoStack}. If <code>undoStackIndex == * 0</code>, "undo" is not possible; if <code>undoStackIndex == * undoStack.size()</code>, "redo" is not possible. */ @@ -184,7 +184,7 @@ * Discard one "redo" information. */ private void discardRedo() { - assert undoStack.size() > 0; + assert !undoStack.isEmpty(); assert undoStackIndex < undoStack.size(); undoStack.remove(undoStack.size() - 1); } @@ -193,7 +193,7 @@ * Discard one "undo" information. */ private void discardUndo() { - assert undoStack.size() > 0; + assert !undoStack.isEmpty(); assert undoStackIndex > 0; undoStack.remove(0); undoStackIndex--; @@ -202,7 +202,7 @@ /** * Enable or disable the recording of new undo information. * - * @param enable if set, enable recording of new undo information + * @param enabled if set, enable recording of new undo information */ public void setEnabled(final boolean enabled) { this.enabled = enabled; Modified: trunk/src/app/net/sf/gridarta/undo/UndoState.java =================================================================== --- trunk/src/app/net/sf/gridarta/undo/UndoState.java 2007-01-07 20:17:02 UTC (rev 1513) +++ trunk/src/app/net/sf/gridarta/undo/UndoState.java 2007-01-07 23:37:02 UTC (rev 1514) @@ -78,7 +78,7 @@ } /** {@inheritDoc} */ - public boolean equals(final Object obj) { + @Override public boolean equals(final Object obj) { if (obj == null) { return false; } @@ -91,7 +91,7 @@ } /** {@inheritDoc} */ - public int hashCode() { + @Override public int hashCode() { return name.hashCode() + mapState.hashCode(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-08 21:48:16
|
Revision: 1516 http://svn.sourceforge.net/gridarta/?rev=1516&view=rev Author: akirschbaum Date: 2007-01-08 13:48:15 -0800 (Mon, 08 Jan 2007) Log Message: ----------- Extract pickmap chooser's action handling to separate class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CSettings.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/messages.properties Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java trunk/daimonin/src/daieditor/gui/pickmapchooser/Actions.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -105,8 +105,6 @@ public static final String LOAD_ARCH_COLL = "loadArchFromCollection"; - private static final String PICKMAPS_LOCKED = "pickmapsLocked"; - /** Preferences key for language. */ public static final String PREFS_LANGUAGE = "language"; @@ -197,9 +195,6 @@ /** The list of archtype-data (loaded from "types.xml"). */ private CFArchTypeList typeList = null; - /** Pickmaps cannot be edited while lockedPickmaps is true. */ - private boolean lockAllPickmaps = false; - private final MapCursorControl mapCursorControl; /** The MainControlListeners to inform of changes. */ @@ -499,8 +494,6 @@ getMainView().setMapTileListBottom(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAP_TILE_LIST_BOTTOM_KEY, Boolean.toString(CMainView.MAP_TILE_LIST_BOTTOM_DEFAULT)))); - setLockAllPickmaps(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false"))); - // docu version if (IGUIConstants.DOCU_VERSION > new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(DOCU_VERSION_KEY, "0"))) { // remember to open docu @@ -544,7 +537,6 @@ */ void setGlobalSettings(final String arch, String map, final String script, final boolean baseImageSet, final boolean load, final boolean mapTileBottom) { CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(USE_IMAGESET, baseImageSet ? "base" : "none"); - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(PICKMAPS_LOCKED, isLockAllPickmaps() ? "true" : "false"); readGlobalSettings(); refreshMenusAndToolbars(); @@ -582,7 +574,7 @@ } public boolean isLockAllPickmaps() { - return lockAllPickmaps; + return mainView.isLockAllPickmaps(); } // ask arch panel which arch is highlighted @@ -700,11 +692,6 @@ NewMapDialog.showNewMapDialog(this, mainView, filename, MapType.GAMEMAP); } - /** Invoked when user wants to open a new pickmap. */ - public void addNewPickmap() { - NewMapDialog.showNewMapDialog(this, mainView, null, MapType.PICKMAP); - } - /** * Begins the editing of a new Map. * @param objects the list of map objects, or <code>null</code> for new empty maps @@ -772,34 +759,6 @@ return true; } - /** Invoked when the user wants to close the active pickmap. */ - public void closePickmap() { - if (!PickmapChooserControl.getInstance().isLoadComplete()) { - ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNotLoaded"); - } else { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "closePickmapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNoPickmaps"); - } else { - // if pickmap was modified, ask for confirmation: - if (!activePickmap.isModified() || ACTION_FACTORY.showQuestionDialog(mainView, "confirmClosePickmap", activePickmap.getMapFileName())) { - final File pickmapFile = activePickmap.getMapFile(); - // close pickmap - closeLevel(activePickmap, true); - - // also delete pickmap file? - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmDeletePickmap", activePickmap.getMapFileName(), activePickmap.getMapFileName())) { - pickmapFile.delete(); - } - } - } - } - } - } - /** * Closes the given level, asking the user whether to save changes. * @param level throws level to close @@ -860,33 +819,6 @@ return true; } - /** Open active pickmap as normal map for extensive editing. */ - public void openPickmapMap() { - if (!PickmapChooserControl.getInstance().isLoadComplete()) { - ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapNotLoaded"); - } else { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "openPickmapNoPickmaps"); - } else { - // open pickmap as map - final File pickmapFile = activePickmap.getMapFile(); - if (!pickmapFile.exists()) { - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmCreatePickmap", activePickmap.getMapFileName())) { - savePickmap(); - openFile(pickmapFile); - } - } else { - openFile(pickmapFile); - } - } - } - } - } - /** Invoked when user wants to open a file. */ public void open() { final JFileChooser fileChooser = new JFileChooser(); @@ -1091,24 +1023,6 @@ currentMap.save(); } - /** Save current active pickmap. */ - public void savePickmap() { - if (PickmapChooserControl.getInstance().isLoadComplete()) { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "savePickmapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNoPickmaps"); - } else { - activePickmap.save(); - } - } - } else { - ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNotLoaded"); - } - } - /** Invoked when user wants to save the current level to certain file. */ public void saveAs() { saveLevelAsWanted(currentMap); @@ -1282,10 +1196,6 @@ showPreferencesDialog(mainView, prefsGroup, false); } - void setLockAllPickmaps(final boolean lockAllPickmaps) { - this.lockAllPickmaps = lockAllPickmaps; - } - /** Invoked when user wants to exit from the program. */ public void exit() { if (closeAll()) { @@ -1559,37 +1469,6 @@ } } - /** Invoked when user wants to revert the current pickmap to previously saved state. */ - public void revertPickmap() { - if (!PickmapChooserControl.getInstance().isLoadComplete()) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNotLoaded"); - } else { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNoPickmaps"); - } else { - if (!activePickmap.isModified() || ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertPickmap", activePickmap.getMapFileName())) { - final File mfile = activePickmap.getMapFile(); // store file - if (!mfile.exists()) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapGone", activePickmap.getMapFileName()); - return; - } - - closeLevel(activePickmap, true); // close the old map - PickmapChooserControl.getInstance().openPickmap(mfile); // open the new map - PickmapChooserControl.getInstance().setActivePickmap(mfile.getName()); - - // Update the main view so the new map instantly pops up. - mainView.update(mainView.getGraphics()); - } - } - } - } - } - /** * Returns whether the CopyBuffer is empty. * @return <code>true</code> if the CopyBuffer is empty, otherwise <code>false</code>. @@ -1822,6 +1701,15 @@ } /** + * Determine whether a pickmap is active. + * + * @return <code>true</code> if a pickmap is active + */ + public boolean isPickmapActive() { + return mainView.isPickmapActive(); + } + + /** * Encapsulates actions and related functions. */ public static final class MainActions implements MainControlListener<MapControl>, MapCursorListener, MapGridListener { Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -156,6 +156,9 @@ /** <code>true</code> when archpanel is merged into the bottom panel. */ private boolean mapTileListBottom = true; + /** The pickmap chooser control. */ + private PickmapChooserControl pickmapChooserControl = null; + /** * Constructs the main view and registers the given main controller. */ @@ -210,7 +213,7 @@ // initialize pickmap panel pickmapPanel = new JTabbedPane(SwingConstants.TOP); // initialize pickmap panel (needed early during the loading process) - new PickmapChooserControl(pickmapPanel); + pickmapChooserControl = new PickmapChooserControl(pickmapPanel); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); @@ -289,14 +292,19 @@ new Help(this, null).setVisible(true); } - public void setPickmapActive(final boolean state) { - pickmapActive = state; - if (!mainControl.isLockAllPickmaps()) { - aClosePickmap.setEnabled(state); - aOpenPickmap.setEnabled(state); - aRevertPickmap.setEnabled(state); - aSavePickmap.setEnabled(state); + /** + * Set whether a pickmap is active. + * + * @param pickmapActive <code>true</code> if a pickmap is active, + * <code>false</code> if no pickmap is active + */ + public void setPickmapActive(final boolean pickmapActive) { + if (this.pickmapActive == pickmapActive) { + return; } + + this.pickmapActive = pickmapActive; + pickmapChooserControl.pickmapActiveChanged(); } /** @@ -764,19 +772,15 @@ return mapArchPanel; } + /** + * Return whether all pickmaps are locked. + * + * @return <code>true</code> if all pickmaps are locked + */ public boolean isLockAllPickmaps() { - return mainControl.isLockAllPickmaps(); + return pickmapChooserControl.isLockAllPickmaps(); } - public void setLockAllPickmaps(final boolean lockAllPickmaps) { - mainControl.setLockAllPickmaps(lockAllPickmaps); - aAddNewPickmap.setEnabled(!lockAllPickmaps); - aOpenPickmap.setEnabled(!lockAllPickmaps && pickmapActive); - aClosePickmap.setEnabled(!lockAllPickmaps && pickmapActive); - aSavePickmap.setEnabled(!lockAllPickmaps && pickmapActive); - aRevertPickmap.setEnabled(!lockAllPickmaps && pickmapActive); - } - public void resetView() { // set tileEdit to zero (-> show all) mainControl.unsetTileEdit(~0); @@ -798,7 +802,6 @@ ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createActions(true, this, "resetView"); ACTION_FACTORY.createToggles(true, mainControl, "autoJoin"); - ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); aTileShow.setEnabled(false); // not yet implemented } @@ -821,16 +824,6 @@ private final Action aMapProperties = ACTION_FACTORY.createAction(true, "mapProperties", mainControl); - private final Action aAddNewPickmap = ACTION_FACTORY.createAction(true, "addNewPickmap", mainControl); - - private final Action aOpenPickmap = ACTION_FACTORY.createAction(true, "openPickmapMap", mainControl); - - private final Action aClosePickmap = ACTION_FACTORY.createAction(true, "closePickmap", mainControl); - - private final Action aSavePickmap = ACTION_FACTORY.createAction(true, "savePickmap", mainControl); - - private final Action aRevertPickmap = ACTION_FACTORY.createAction(true, "revertPickmap", mainControl); - private final Action aCollectArches = ACTION_FACTORY.createAction(true, "collectArches", mainControl); private final Action aCollectSpells = ACTION_FACTORY.createAction(true, "collectSpells", mainControl); @@ -867,12 +860,6 @@ aCollectArches.setEnabled(!mainControl.getArchetypeSet().isLoadedFromArchive()); aViewTreasurelists.setEnabled(true); - final boolean pickmapState = !mainControl.isLockAllPickmaps() && pickmapActive; - aAddNewPickmap.setEnabled(!mainControl.isLockAllPickmaps()); - aOpenPickmap.setEnabled(pickmapState); - aClosePickmap.setEnabled(pickmapState); - aRevertPickmap.setEnabled(pickmapState); - aSavePickmap.setEnabled(pickmapState); final boolean mapState = mainControl.getCurrentMap() != null; final boolean fLevelEdited = mapState && mainControl.isLevelEdited(); Modified: trunk/crossfire/src/cfeditor/CSettings.java =================================================================== --- trunk/crossfire/src/cfeditor/CSettings.java 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/crossfire/src/cfeditor/CSettings.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -58,6 +58,11 @@ private static final Map<String, CSettings> hashFromNameToInstance = new HashMap<String, CSettings>(); /** + * Key for "all pickmaps are locked". + */ + public static final String PICKMAPS_LOCKED = "pickmapsLocked"; + + /** * Returns the settings instance for the given filename. If no such instance * is found one is created and the settings loaded from the file. * @param strFile The filename whose settings object instance we want. Added: trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -0,0 +1,335 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.pickmapchooser; + +import cfeditor.CSettings; +import cfeditor.IGUIConstants; +import cfeditor.map.MapControl; +import javax.swing.Action; +import net.sf.gridarta.map.MapControlListener; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The class <code>Actions</code> encapsulates functionality related to actions + * used by the pickmap chooser. + * + * @Author Andreas Kirschbaum + */ +public class Actions { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(Actions.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + /** The control to forward to. */ + @NotNull private final PickmapChooserControl control; + + /** Action called for "add new pickmap". */ + private final Action aAddNewPickmap = ACTION_FACTORY.createAction(true, "addNewPickmap", this); + + /** Action called for "open active pickmap as map". */ + private final Action aOpenPickmapMap = ACTION_FACTORY.createAction(true, "openPickmapMap", this); + + /** Action called for "close active pickmap". */ + private final Action aClosePickmap = ACTION_FACTORY.createAction(true, "closePickmap", this); + + /** Action called for "save active pickmap". */ + private final Action aSavePickmap = ACTION_FACTORY.createAction(true, "savePickmap", this); + + /** Action called for "revert active pickmap". */ + private final Action aRevertPickmap = ACTION_FACTORY.createAction(true, "revertPickmap", this); + + /** The current active pickmap ontop. */ + private MapControl currentPickmap = null; + + /** Set if pickmap loading has completed. */ + private boolean loadComplete = false; // true when all pickmaps have been loaded (at least one) + + /** Set if all pickmaps are locked. */ + private boolean lockAllPickmaps = false; + + /** + * The map control listener which is registered to the selected pickmap. + */ + private final MapControlListener<MapControl> mapControlListener = new MapControlListener<MapControl>() { + + /** {@inheritDoc} */ + public void modifiedChanged(@NotNull MapControl mapControl) { + refresh(); + } + + }; + + /** + * Create a new instance. + * + * @param control the control to forward to + */ + public Actions(@NotNull final PickmapChooserControl control) { + this.control = control; + lockAllPickmaps = Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CSettings.PICKMAPS_LOCKED, "false")); + ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); + } + + /** + * Finish instance creation. This function must be called once before any + * other function is called. + */ + void init() { + refresh(); + } + + /** Invoked when user wants to open a new pickmap. */ + public void addNewPickmap() { + if (isAddNewPickmapEnabled()) { + control.addNewPickmap(); + } + } + + /** Open active pickmap as normal map for extensive editing. */ + public void openPickmapMap() { + final MapControl pickmap = getOpenPickmapMap(); + if(pickmap != null) { + control.openPickmapMap(pickmap); + } + } + + /** Invoked when the user wants to close the active pickmap. */ + public void closePickmap() { + final MapControl pickmap = getClosePickmap(); + if (pickmap != null) { + control.closePickmapWanted(pickmap); + } + } + + /** Save current active pickmap. */ + public void savePickmap() { + final MapControl pickmap = getSavePickmap(); + if (pickmap != null) { + control.savePickmap(pickmap); + } + } + + /** Invoked when user wants to revert the current pickmap to previously saved state. */ + public void revertPickmap() { + final MapControl pickmap = getRevertPickmap(); + if (pickmap != null) { + control.revertPickmap(pickmap); + } + } + + /** + * Determine if "add new pickmap" is enabled. + * + * @return <code>true</code> if "add new pickmap" is enabled, + * <code>false</code> otherwise + */ + private boolean isAddNewPickmapEnabled() { + return !control.isLockAllPickmaps() && isLoadComplete() && control.isPickmapActive(); + } + + /** + * Determine if "open pickmap as map" is enabled. + * + * @return the pickmap to open as map, or <code>null</code> if "open + * pickmap as map" is disabled + */ + private MapControl getOpenPickmapMap() { + if (control.isLockAllPickmaps() || !isLoadComplete() || !control.isPickmapActive()) { + return null; + } + + final MapControl pickmap = control.getCurrentPickmap(); + if (pickmap == null) { + return null; + } + + return pickmap; + } + + /** + * Determine if "close active pickmap" is enabled. + * + * @return the pickmap to close, or <code>null</code> if "close active + * pickmap" is disabled + */ + private MapControl getClosePickmap() { + if (control.isLockAllPickmaps() || !isLoadComplete() || !control.isPickmapActive()) { + return null; + } + + final MapControl pickmap = control.getCurrentPickmap(); + if (pickmap == null) { + return null; + } + + return pickmap; + } + + /** + * Determine if "save active pickmap" is enabled. + * + * @return the pickmap to save, or <code>null</code> if "save active + * pickmap" is disabled + */ + private MapControl getSavePickmap() { + if (control.isLockAllPickmaps() || !isLoadComplete() || !control.isPickmapActive()) { + return null; + } + + final MapControl pickmap = control.getCurrentPickmap(); + if (pickmap == null || !pickmap.isModified()) { + return null; + } + + return pickmap; + } + + /** + * Determine if "revert active pickmap" is enabled. + * + * @return the pickmap to revert, or <code>null</code> if "revert active + * pickmap" is disabled + */ + private MapControl getRevertPickmap() { + if (control.isLockAllPickmaps() || !isLoadComplete() || !control.isPickmapActive()) { + return null; + } + + final MapControl pickmap = control.getCurrentPickmap(); + if (pickmap == null || !pickmap.isModified() || !pickmap.getMapFile().exists()) { + return null; + } + + return pickmap; + } + + /** + * Update the actions' states. + */ + private void refresh() { + final boolean pickmapActive = control.isPickmapActive(); + aAddNewPickmap.setEnabled(isAddNewPickmapEnabled()); + aOpenPickmapMap.setEnabled(getOpenPickmapMap() != null); + aClosePickmap.setEnabled(getClosePickmap() != null); + aSavePickmap.setEnabled(getSavePickmap() != null); + aRevertPickmap.setEnabled(getRevertPickmap() != null); + } + + /** + * Return the currently active pickmap. If there is no currently active + * pickmap, this method returns <code>null</code>. + * + * @return the currently active pickmap or <code>null</code> if there is no pickmap + */ + @Nullable MapControl getCurrentPickmap() { + return currentPickmap; + } + + /** + * Set the currently active pickmap. + * + * @param currentPickmap the currently active pickmap + */ + void setCurrentPickmap(@Nullable final MapControl currentPickmap) { + if (this.currentPickmap == currentPickmap) { + return; + } + + if (this.currentPickmap != null) { + this.currentPickmap.removeMapControlListener(mapControlListener); + } + + this.currentPickmap = currentPickmap; + + if (this.currentPickmap != null) { + this.currentPickmap.addMapControlListener(mapControlListener); + } + + refresh(); + } + + /** + * Return whether loading of pickmaps is complete and at least one pickmap is available. + * + * @return <code>true</code> if loading of pickmaps is complete and at + * least one pickmap is available, otherwise <code>false</code> + * + * @todo check whether this method returns <code>true</code> or + * <code>false</code> if the loading process is complete but no pickmaps + * are availbale. + */ + boolean isLoadComplete() { + return loadComplete; + } + + /** + * Set whether loading of pickmaps is complete. + * + * @param loadComplete <code>true</code> if loading of pickmaps is complete + */ + void setLoadComplete(final boolean loadComplete) { + if (this.loadComplete == loadComplete) { + return; + } + + this.loadComplete = loadComplete; + refresh(); + } + + /** + * Callback function: <code>control.isPickmapActive()</code> has changed. + */ + void pickmapActiveChanged() { + refresh(); + } + + /** + * Return whether all pickmaps are locked. + * + * @return <code>true</code> if all pickmaps are locked + */ + public boolean isLockAllPickmaps() { + return lockAllPickmaps; + } + + /** + * Set whether all pickmaps are locked. + * + * @param lockAddPickmaps <code>true</code> if all pickmaps are locked + */ + public void setLockAllPickmaps(final boolean lockAllPickmaps) { + if (this.lockAllPickmaps == lockAllPickmaps) { + return; + } + + this.lockAllPickmaps = lockAllPickmaps; + CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CSettings.PICKMAPS_LOCKED, isLockAllPickmaps() ? "true" : "false"); + + refresh(); + } + +} // class Actions Property changes on: trunk/crossfire/src/cfeditor/gui/pickmapchooser/Actions.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -29,6 +29,7 @@ import cfeditor.CMapViewBasic; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; +import cfeditor.gui.NewMapDialog; import cfeditor.io.CMapReader; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; @@ -41,8 +42,11 @@ import java.util.List; import java.util.Map; import javax.swing.JTabbedPane; +import net.sf.gridarta.map.MapType; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The <code>PickmapChooserControl</code> manages the pickmap panel @@ -62,17 +66,15 @@ private final CMainControl mainControl; // main control reference - private boolean loadComplete; // true when all pickmaps have been loaded (at least one) - /** All open pickmaps (the map controllers get stored in the vector). */ private final Map<String, MapControl> pickmaps = new HashMap<String, MapControl>(); - /** The current active pickmap ontop. */ - private MapControl currentPickMap; - /** The view for this control. */ private final PickmapChooserView view; + /** The actions for this control. */ + private final Actions actions; + /** * Create a PickmapChooserControl. * @param tabpane Tabbed pane to create view on. @@ -80,9 +82,9 @@ public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); instance = this; - loadComplete = false; - currentPickMap = null; view = new PickmapChooserView(tabpane); + actions = new Actions(this); + actions.init(); } /** @@ -99,16 +101,15 @@ * @todo check whether this method returns <code>true</code> or <code>false</code> if the loading process is complete but no pickmaps are availbale. */ public boolean isLoadComplete() { - return loadComplete; + return actions.isLoadComplete(); } /** * Return the currently active pickmap. - * If there is no currently active pickmap, this method returns <code>null</code>. * @return the currently active pickmap or <code>null</code> if there is no pickmap */ - public MapControl getCurrentPickmap() { - return currentPickMap; + @Nullable public MapControl getCurrentPickmap() { + return actions.getCurrentPickmap(); } /** @@ -133,7 +134,7 @@ // did we get something? if (!pickmaps.isEmpty()) { - loadComplete = true; + actions.setLoadComplete(true); } updateActivePickmap(); // make sure we know which one is on top @@ -203,7 +204,7 @@ } view.addPanel(mapFile.getName(), bmapview); setActivePickmap(mapFile.getName()); - loadComplete = true; + actions.setLoadComplete(true); return true; } @@ -222,8 +223,8 @@ // add pickmap to hashtable pickmaps.put(mapFile.getName(), mapControl); - currentPickMap = mapControl; mapControl.resetModified(); + actions.setCurrentPickmap(mapControl); return mapControl.getMapViewFrame().getBasicView(); } @@ -268,13 +269,13 @@ /** Update info which pickmap is currently on top. */ void updateActivePickmap() { if (pickmaps.isEmpty()) { - currentPickMap = null; + actions.setCurrentPickmap(null); return; } final String newName = view.getSelectedPanelTitle(); if (newName == null) { - currentPickMap = null; + actions.setCurrentPickmap(null); return; } @@ -282,14 +283,14 @@ boolean foundMap = false; if (tmp != null && tmp.getMapFileName().endsWith("/"+newName)) { // this is the new active pickmap - currentPickMap = tmp; // <- new pickmap + actions.setCurrentPickmap(tmp); // <- new pickmap foundMap = true; if (log.isDebugEnabled()) { log.debug("new pickmap: " + newName); } } - if (!foundMap && mainControl.getMainView().isPickmapActive() && loadComplete) { + if (!foundMap && isPickmapActive() && isLoadComplete()) { // error: the new selected pickmap couldn't be found log.error("Bad Error in PickmapChooserControl.updateActivePickmap: Selected pickmap couldn't be found!"); } @@ -314,4 +315,106 @@ pane.addChangeListener(new ArchNPickChangeListener(mainControl.getMainView(), pane)); } + /** + * Callback function: {@link CMainView#isPickmapActive()} has changed. + */ + public void pickmapActiveChanged() { + actions.pickmapActiveChanged(); + } + + /** + * Determine whether a pickmap is active. + * + * @return <code>true</code> if a pickmap is active + */ + boolean isPickmapActive() { + return mainControl.isPickmapActive(); + } + + /** + * Return whether all pickmaps are locked. + * + * @return <code>true</code> if all pickmaps are locked + */ + public boolean isLockAllPickmaps() { + return actions.isLockAllPickmaps(); + } + + /** Invoked when user wants to open a new pickmap. */ + public void addNewPickmap() { + NewMapDialog.showNewMapDialog(mainControl, mainControl.getMainView(), null, MapType.PICKMAP); + } + + /** + * Open a pickmap as a normal map for extensive editing. + * + * @param pickmap the pickmap to open as a map + */ + public void openPickmapMap(@NotNull final MapControl pickmap) { + final File pickmapFile = pickmap.getMapFile(); + if (!pickmapFile.exists()) { + if (!ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmCreatePickmap", pickmap.getMapFileName())) { + return; + } + + savePickmap(pickmap); + } + + mainControl.openFile(pickmapFile); + } + + /** + * Close a pickmap. + * + * @param pickmap the pickmap to close + */ + public void closePickmapWanted(@NotNull final MapControl pickmap) { + // if pickmap was modified, ask for confirmation: + if (pickmap.isModified() && !ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmClosePickmap", pickmap.getMapFileName())) { + return; + } + + final File pickmapFile = pickmap.getMapFile(); + // close pickmap + mainControl.closeLevel(pickmap, true); + + // also delete pickmap file? + if (ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmDeletePickmap", pickmap.getMapFileName(), pickmap.getMapFileName())) { + pickmapFile.delete(); + } + } + + /** + * Save a pickmap. + * + * @param pickmap the pickmap to save + */ + public void savePickmap(@NotNull final MapControl pickmap) { + pickmap.save(); + } + + /** + * Revert a pickmap. + * + * @param pickmap the pickmap to revert + */ + public void revertPickmap(@NotNull final MapControl pickmap) { + if (pickmap.isModified() && !ACTION_FACTORY.showQuestionDialog(mainControl.getMainView(), "confirmRevertPickmap", pickmap.getMapFileName())) { + return; + } + + final File mfile = pickmap.getMapFile(); // store file + if (!mfile.exists()) { + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "revertPickmapGone", pickmap.getMapFileName()); + return; + } + + mainControl.closeLevel(pickmap, true); // close the old map + openPickmap(mfile); // open the new map + setActivePickmap(mfile.getName()); + + // Update the main view so the new map instantly pops up. + mainControl.getMainView().update(mainControl.getMainView().getGraphics()); + } + } // class PickmapChooserControl Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2007-01-08 21:48:15 UTC (rev 1516) @@ -13,22 +13,9 @@ mapDirDoesntExist.title=Ung\xFCltiges Verzeichnis mapDirDoesntExist.message=Das Verzeichnis f\xFCr Karten "{0}" existiert nicht.\nBitte legen sie es unter ''Datei->Optionen...'' fest. -closePickmapNotLoaded.title=Kann Pickmap nicht schlie\xDFen -closePickmapNotLoaded.message=Es sind keine Pickmaps geladen.\nEntweder existieren keine Pickmaps oder\nsie sind noch nicht vollst\xE4ndig geladen. -closePickmapHidden.title=Kann Pickmap nicht schlie\xDFen -closePickmapHidden.message=Pickmaps werden nicht angezeigt\nSie m\xFCssen eine Pickmap ausw\xE4hlen, um dieses Kommando zu verwenden. -closePickmapNoPickmaps.title=Kann Pickmap nicht schlie\xDFen -closePickmapNoPickmaps.message=Es existieren keine Pickmaps. - closeLevelNullLevel.title=Kann Karte nicht schlie\xDFen closeLevelNullLevel.message=Die Karte {1} existiert nicht; Anzahl existierender Karten: {0}. -openPickmapMapNotLoaded.title=Kann Pickmap nicht \xF6ffnen -openPickmapMapNotLoaded.message=Es sind keine Pickmaps geladen.\nEntweder existieren keine Pickmaps oder\nsie sind noch nicht vollst\xE4ndig geladen. -openPickmapMapHidden.title=Kann Pickmap nicht \xF6ggnen -openPickmapMapHidden.message=Pickmaps werden nicht angezeigt.\nSie m\xFCssen eine Pickmap ausw\xE4hlen, um dieses Kommando zu verwenden. -openPickmapNoPickmaps.title=Kann Pickmap nicht \xF6ffnen -openPickmapNoPickmaps.message=Es existieren keine Pickmaps. openFileWantedNoArches.title=Kann Karte nicht \xF6ffnen openFileWantedNoArches.message=Es sind keine Archetypen verf\xFCgbar.\nDiese werden ben\xF6tigt, um eine Karte zu \xF6ffnen. openFileWantedNotReady.title=Kann Karte nicht \xF6ffnen @@ -45,13 +32,6 @@ encodeMapFile.title=Fehler beim Sichern encodeMapFile.message=Beim Sichern von {0}\nist ein Fehler aufgetreten:\n{1} -savePickmapNotLoaded.title=Kann Pickmap nicht sichern -savePickmapNotLoaded.message=Es sind keine Pickmaps geladen.\nEntweder existieren keine Pickmaps oder\nsie sind noch nicht vollst\xE4ndig geladen. -savePickmapHidden.title=Kann Pickmap nicht sichern -savePickmapHidden.message=Pickmaps werden nicht angezeigt.\nSie m\xFCssen eine Pickmap ausw\xE4hlen, um dieses Kommando zu verwenden. -savePickmapNoPickmaps.title=Kann Pickmap nicht sichern -savePickmapNoPickmaps.message=Es existieren keine Pickmaps. - createImgNoMap.title=Kann Bild nicht erzeugen createImgNoMap.message=Um ein Bild einer Karte erstellen zu k\xF6nnen muss eine Karte ge\xF6ffnet sein. createImgIOException.title=Kann Bild nicht erzeugen @@ -87,12 +67,6 @@ enterTileNoTile.title=Ziel ung\xFCltig enterTileNoTile.message=In die angegebene Richtung existiert kein Verbindungspfad. -revertPickmapNotLoaded.title=Kann \xC4nderungen nicht zur\xFCcknehmen -revertPickmapNotLoaded.message=Es sind keine Pickmaps geladen.\nEntweder existieren keine Pickmaps oder\nsie sind noch nicht vollst\xE4ndig geladen. -revertPickmapHidden.title=Kann \xC4nderungen nicht zur\xFCcknehmen -revertPickmapHidden.message=Pickmaps werden nicht angezeigt.\nSie m\xFCssen eine Pickmap ausw\xE4hlen, um dieses Kommando zu verwenden. -revertPickmapNoPickmaps.title=Kann \xC4nderungen nicht zur\xFCcknehmen -revertPickmapNoPickmaps.message=Es existieren keine Pickmaps. revertPickmapGone.title=Kann \xC4nderungen nicht zur\xFCcknehmen revertPickmapGone.message=F\xFCr die Pickmap ''{0}'' existiert keine Datei. Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2007-01-08 21:48:15 UTC (rev 1516) @@ -10,22 +10,9 @@ mapDirDoesntExist.title=Ogiltig katalog f\xF6r kartor. mapDirDoesntExist.message=Katalogen f\xF6r kartor, "{0}", finns inte.\nVar v\xE4nlig och v\xE4lj menyn ''Arkiv->Inst\xE4llningar...'' f\xF6r att byta katalog. -closePickmapNotLoaded.title=Kan inte st\xE4nga plockkarta -closePickmapNotLoaded.message=Plockkartor \xE4r inte inladdade.\nAntingen finns det inga, eller ocks\xE5 \xE4r de inte f\xE4rdigladdade \xE4n. -closePickmapHidden.title=Kan inte st\xE4nga plockkarta -closePickmapHidden.message=Plockkartor \xE4r dolda f\xF6r tillf\xE4llet.\nVar v\xE4nlig och v\xE4lj en plockkarta innan du aktiverar detta kommando. -closePickmapNoPickmaps.title=Kan inte st\xE4nga plockkarta -closePickmapNoPickmaps.message=Det finns inga plockkartor. - closeLevelNullLevel.title=St\xE4ng niv\xE5 closeLevelNullLevel.message=FIND NULL LEVEL : {0} v\xE5r karta: {1}. -openPickmapMapNotLoaded.title=Kan inte \xF6ppna plockkarta -openPickmapMapNotLoaded.message=Plockkartor \xE4r inte inladdade.\nAntingen finns det inga, eller ocks\xE5 \xE4r de inte f\xE4rdigladdade \xE4n. -openPickmapMapHidden.title=Kan inte \xF6ppna plockkarta -openPickmapMapHidden.message=Plockkartor \xE4r dolda f\xF6r tillf\xE4llet.\nVar v\xE4nlig och v\xE4lj en plockkarta innan du aktiverar detta kommando. -openPickmapNoPickmaps.title=Kan inte \xF6ppna plockkarta -openPickmapNoPickmaps.message=Det finns inga plockkartor. openFileWantedNoArches.title=Kan inte \xF6ppna karta openFileWantedNoArches.message=Det finns inga arketyper (arches) tillg\xE4ngliga!\nDu m\xE5ste ha arketyperna innan du kan \xF6ppna en karta.\nL\xE4s i online-dokumentationen hur du kan skaffa Daimonins arketypfiler.. @@ -36,13 +23,6 @@ encodeMapFile.title=Misslyckades att spara karta encodeMapFile.message=Kunde inte skriva fil {0}. -savePickmapNotLoaded.title=Kan inte spara plockkarta -savePickmapNotLoaded.message=Antingen finns det inga plockkartor, eller ocks\xE5 \xE4r de inte f\xE4rdigladdade \xE4n. -savePickmapHidden.title=Kan inte spara plockkarta -savePickmapHidden.message=Plockkartor \xE4r dolda f\xF6r tillf\xE4llet.\nVar v\xE4nlig och v\xE4lj en plockkarta innan du aktiverar detta kommando. -savePickmapNoPickmaps.title=Kan inte spara plockkarta -savePickmapNoPickmaps.message=Det finns inga plockkartor. - createImgNoMap.title=Kunde inte skapa bild createImgNoMap.message=Du kan inte skapa en bild om ingen karta \xE4r \xF6ppnad. createImgIOException.title=Kunde inte skapa bild @@ -68,12 +48,6 @@ enterTileNoTile.title=M\xE5let ogiltigt enterTileNoTile.message=Det finns ingen karta \xE5t det h\xE5llet. -revertPickmapNotLoaded.title=Kan inte \xE5terst\xE4lla plockkarta -revertPickmapNotLoaded.message=Inga plockkartor \xE4r inladdade.\nAntingen finns det inga plockkartor, eller ocks\xE5 \xE4r de inte f\xE4rdigladdade \xE4n. -revertPickmapHidden.title=Kan inte \xE5terst\xE4lla plockkarta -revertPickmapHidden.message=Plockkartor \xE4r dolda f\xF6r tillf\xE4llet.\nVar v\xE4nlig och v\xE4lj en plockkarta innan du aktiverar detta kommando. -revertPickmapNoPickmaps.title=Kan inte \xE5terst\xE4lla plockkarta -revertPickmapNoPickmaps.message=Det finns inga plockkartor. revertPickmapGone.title=Kan inte \xE5terst\xE4lla plockkartan. revertPickmapGone.message=Filen f\xF6r plockkartan "{0}" existerar inte. Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -155,8 +155,6 @@ public static final String LOAD_ARCH_COLL = "loadArchFromCollection"; - private static final String PICKMAPS_LOCKED = "pickmapsLocked"; - /** Preferences key for username. */ public static final String PREFS_USERNAME = "username"; @@ -275,9 +273,6 @@ /** The list of archtype-data (loaded from "types.xml"). */ private CFArchTypeList typeList = null; - /** Pickmaps cannot be edited while lockedPickmaps is true. */ - private boolean lockAllPickmaps = false; - /** Client Control Component. */ private ProcessRunner controlClient; @@ -691,8 +686,6 @@ mainView.setMapTileListBottom(prefs.getBoolean(MAP_TILE_LIST_BOTTOM_KEY, MAP_TILE_LIST_BOTTOM_DEFAULT)); - lockAllPickmaps = prefs.getBoolean(PICKMAPS_LOCKED, false); - // docu version if (IGUIConstants.DOCU_VERSION > prefs.getInt(DOCU_VERSION_KEY, 0)) { // remember to open docu @@ -765,7 +758,7 @@ } public boolean isLockAllPickmaps() { - return lockAllPickmaps; + return mainView.isLockAllPickmaps(); } /** Refresh the active map view, if there is one. */ @@ -869,11 +862,6 @@ NewMapDialog.showNewMapDialog(this, mainView, filename, MapType.GAMEMAP); } - /** Invoked when user wants to open a new pickmap. */ - public void addNewPickmap() { - NewMapDialog.showNewMapDialog(this, mainView, null, MapType.PICKMAP); - } - /** * Begins the editing of a new Map. * @param objects the list of map objects, or <code>null</code> for new empty maps @@ -944,34 +932,6 @@ return true; } - /** Invoked when the user wants to close the active pickmap. */ - public void closePickmap() { - if (!PickmapChooserControl.getInstance().isLoadComplete()) { - ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNotLoaded"); - } else { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "closePickmapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "closePickmapNoPickmaps"); - } else { - // if pickmap was modified, ask for confirmation: - if (!activePickmap.isModified() || ACTION_FACTORY.showQuestionDialog(mainView, "confirmClosePickmap", activePickmap.getMapFileName())) { - final File pickmapFile = activePickmap.getMapFile(); - // close pickmap - closeLevel(activePickmap, true); - - // also delete pickmap file? - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmDeletePickmap", activePickmap.getMapFileName(), activePickmap.getMapFileName())) { - pickmapFile.delete(); - } - } - } - } - } - } - /** * Closes the given level, asking the user whether to save changes. * @param level throws level to close @@ -1034,33 +994,6 @@ return true; } - /** Open active pickmap as normal map for extensive editing. */ - public void openPickmapMap() { - if (!PickmapChooserControl.getInstance().isLoadComplete()) { - ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapNotLoaded"); - } else { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "openPickmapMapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "openPickmapNoPickmaps"); - } else { - // open pickmap as map - final File pickmapFile = activePickmap.getMapFile(); - if (!pickmapFile.exists()) { - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmCreatePickmap", activePickmap.getMapFileName())) { - savePickmap(); - openFile(pickmapFile); - } - } else { - openFile(pickmapFile); - } - } - } - } - } - /** JFileChooser for opening a file. */ private JFileChooser fileChooser; @@ -1170,7 +1103,7 @@ * @return true if the file was new, false if the file already was open or * something went wrong */ - boolean openFile(final File file) { + public boolean openFile(final File file) { return openFile(file, true) != null; } @@ -1313,24 +1246,6 @@ currentMap.save(); } - /** Save current active pickmap. */ - public void savePickmap() { - if (PickmapChooserControl.getInstance().isLoadComplete()) { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "savePickmapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNoPickmaps"); - } else { - activePickmap.save(); - } - } - } else { - ACTION_FACTORY.showMessageDialog(mainView, "savePickmapNotLoaded"); - } - } - /** Invoked when user wants to save the current level to certain file. */ public void saveAs() { saveLevelAsWanted(currentMap); @@ -1499,10 +1414,6 @@ showPreferencesDialog(mainView, prefsGroup, false); } - void setLockAllPickmaps(final boolean lockAllPickmaps) { - this.lockAllPickmaps = lockAllPickmaps; - } - /** Invoked to show the next tip of the day or bring the tip of the day to front. */ public void tod() { TipOfTheDayManager.show(mainView); @@ -1760,40 +1671,6 @@ } } - /** Invoked when user wants to revert the current pickmap to previously saved state. */ - public void revertPickmap() { - if (!PickmapChooserControl.getInstance().isLoadComplete()) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNotLoaded"); - } else { - if (!mainView.isPickmapActive()) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapHidden"); - } else { - final MapControl activePickmap = PickmapChooserControl.getInstance().getCurrentPickmap(); - if (activePickmap == null) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapNoPickmaps"); - } else { - if (!activePickmap.isModified() || ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertPickmap", activePickmap.getMapFileName())) { - final File mfile = activePickmap.getMapFile(); // store file - if (!mfile.exists()) { - ACTION_FACTORY.showMessageDialog(mainView, "revertPickmapGone", activePickmap.getMapFileName()); - return; - } - - final int tabIndex = PickmapChooserControl.getInstance().getPickmapTabIndex(activePickmap); - if (tabIndex >= 0) { - closeLevel(activePickmap, true); // close the old map - PickmapChooserControl.getInstance().openPickmap(mfile, tabIndex); // open the new map - PickmapChooserControl.getInstance().setActivePickmap(tabIndex); - - // Update the main view so the new map instantly pops up. - mainView.update(mainView.getGraphics()); - } - } - } - } - } - } - /** * Returns whether the CopyBuffer is empty. * @return <code>true</code> if the CopyBuffer is empty, otherwise <code>false</code>. @@ -2046,6 +1923,15 @@ return mainView.getActiveDirection(); } + /** + * Determine whether a pickmap is active. + * + * @return <code>true</code> if a pickmap is active + */ + public boolean isPickmapActive() { + return mainView.isPickmapActive(); + } + /** Recent entry. */ public final class Recent extends AbstractAction { Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-08 00:29:07 UTC (rev 1515) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -160,6 +160,9 @@ /** <code>true</code> when archpanel is merged into the bottom panel. */ private boolean mapTileListBottom = true; + /** The pickmap chooser control. */ + private PickmapChooserControl pickmapChooserControl = null; + /** * Constructs the main view and registers the given main controller. */ @@ -185,9 +188,9 @@ final int defwidth = (int) (0.9 * screen.getWidth()); final int defheight = (int) (0.9 * screen.getHeight()); - setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); add(ACTION_FACTORY.createToolBar("main"), BorderLayout.NORTH); add(createCenterPanel(prefs, defwidth, defheight), BorderLayout.CENTER); + setJMenuBar(ACTION_FACTORY.createMenuBar(true, "main")); // set bounds (location and size) of the main frame setBounds(new Rectangle( @@ -218,7 +221,7 @@ pickmapPanel = new JTabbedPane(SwingConstants.TOP); // initialize pickmap panel (needed early during the loading process) - new PickmapChooserControl(pickmapPanel); + pickmapChooserControl = new PickmapChooserControl(pickmapPanel); pickmapPanel.setComponentPopupMenu(ACTION_FACTORY.createPopupMenu(true, "pickmaps")); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); @@ -252,14 +255,19 @@ new Help(this, null).setVisible(true); } - public void setPickmapActive(final boolean state) { - pickmapActive = state; - if (!mainControl.isLockAllPickmaps()) { - aClosePickmap.setEnabled(state); - aOpenPickmap.setEnabled(state); - aRevertPickmap.setEnabled(state); - aSavePickmap.setEnabled(state); + /** + * Set whether a pickmap is active. + * + * @param pickmapActive <code>true</code> if a pickmap is active, + * <code>false</code> if no pickmap is active + */ + public void setPickmapActive(final boolean pickmapActive) { + if (this.pickmapActive == pickmapActive) { + return; } + + this.pickmapActive = pickmapActive; + pickmapChooserControl.pickmapActiveChanged(); } /** @@ -715,26 +723,21 @@ return mapArchPanel; } + /** + * Return whether all pickmaps are locked. + * + * @return <code>true</code> if all pickmaps are locked + */ public boolean isLockAllPickmaps() { - return mainControl.isLockAllPickmaps(); + return pickmapChooserControl.isLockAllPickmaps(); } - public void setLockAllPickmaps(final boolean lockAllPickmaps) { - mainControl.setLockAllPickmaps(lockAllPickmaps); - aAddNewPickmap.setEnabled(!lockAllPickmaps); - aClosePickmap.setEnabled(!lockAllPickmaps); - aOpenPickmap.setEnabled(!lockAllPickmaps); - aSavePickmap.setEnabled(!lockAllPickmaps); - aRevertPickmap.setEnabled(!lockAllPickmaps); - } - private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterNorthEastMap", "enterSouthEastMap", "enterSouthWestMap", "enterNorthWestMap"}; private void initActions() { ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "newScript", "editScript", "controlServer", "controlClient", "validateMap", "cleanCompletelyBlockedSquares", "zoom", "gc", "prevWindow", "nextWindow", "onlineHelp", "tod", "about", "update"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createToggles(true, mainControl, "drawDouble", "gridVisible"); - ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); } private final Action aClose = ACTION_FACTORY.createAction(true, "close", mainControl); @@ -753,16 +756,6 @@ private final Action aMapProperties = ACTION_FACTORY.createAction(true, "mapProperties", mainControl); - private final Action aAddNewPickmap = ACTION_FACTORY.createAction(true, "addNewPickmap", mainControl); - - private final Action aClosePickmap = ACTION_FACTORY.createAction(true, "closePickmap", mainControl); - - private final Action aOpenPickmap = ACTION_FACTORY.createAction(true, "openPickmapMap", mainControl); - - private final Action aSavePickmap = ACTION_FACTORY.createAction(true, "savePickmap", mainControl); - - private final Action aRevertPickmap = ACTION_FACTORY.createAction(true, "revertPickmap", mainControl); - private final Action aCollectArches = ACTION_FACTORY.createAction(true, "collectArches", mainControl); private final Action aReloadFaces = ACTION_FACTORY.createAction(true, "reloadFaces", mainControl); @@ -786,12 +779,6 @@ aReloadFaces.setEnabled(!mainControl.getArchetypeSet().isLoadedFromArchive()); aViewTreasurelists.setEnabled(true); - final boolean pickmapState = !mainControl.isLockAllPickmaps() && mainControl.getMainView().pickmapActive; - aClosePickmap.setEnabled(pickmapState); - aOpenPickmap.setEnabled(pickmapState); - aRevertPickmap.setEnabled(pickmapState); - aSavePickmap.setEnabled(pickmapState); - aAddNewPickmap.setEnabled(!mainControl.isLockAllPickmaps()); final boolean mapState = mainControl.getCurrentMap() != null; final boolean fLevelEdited = mapState && mainControl.isLevelEdited(); Added: trunk/daimonin/src/daieditor/gui/pickmapchooser/Actions.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/Actions.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/Actions.java 2007-01-08 21:48:15 UTC (rev 1516) @@ -0,0 +1,345 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package daieditor.gui.pickmapchooser; + +import daieditor.CMainControl; +import daieditor.IGUIConstants; +import daieditor.map.MapControl; +import java.util.prefs.Preferences; +import static java.util.prefs.Preferences.userNodeForPackage; +import javax.swing.Action; +import net.sf.gridarta.map.MapControlListener; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The class <code>Actions</code> encapsulates functionality related to actions + * used by the pickmap chooser. + * + * @Author Andreas Kirschbaum + */ +public class Actions { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(Actions.class); + + /** Preferences. */ + private static final Preferences prefs = userNodeForPackage(CMainControl.class); + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + + /** The control to forward to. */ + @NotNull private final PickmapChooserControl control; + + /** Action called for "add new pickmap". */ + private final Action aAddNewPickmap = ACTION_FACTORY.createAction(true, "addNewPickmap", this); + + /** Action called for "open active pickmap as map". */ + private final Action aOpenPickmapMap = ACTION_FACTORY.createAction(true, "openPickmapMap", this); + + /** Action ca... [truncated message content] |
From: <aki...@us...> - 2007-01-08 22:10:04
|
Revision: 1517 http://svn.sourceforge.net/gridarta/?rev=1517&view=rev Author: akirschbaum Date: 2007-01-08 14:10:03 -0800 (Mon, 08 Jan 2007) Log Message: ----------- Simplify PickmapSelectionListener; do not crash if no pickmap exists. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-08 21:48:15 UTC (rev 1516) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-08 22:10:03 UTC (rev 1517) @@ -215,7 +215,6 @@ // initialize pickmap panel (needed early during the loading process) pickmapChooserControl = new PickmapChooserControl(pickmapPanel); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); - PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); statusBar = new StatusBar(mainControl); getContentPane().add(statusBar, BorderLayout.SOUTH); Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 21:48:15 UTC (rev 1516) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 22:10:03 UTC (rev 1517) @@ -85,6 +85,7 @@ view = new PickmapChooserView(tabpane); actions = new Actions(this); actions.init(); + tabpane.addChangeListener(new PickmapSelectionListener(this)); } /** @@ -297,15 +298,6 @@ } /** - * Add the PickmapSelectionListener to the pickmap tabbed panel. - * @param pickpane the panel with pickmaps - * @todo this method's name is a Bad Thing - */ - public void addPickmapSelectionListener(final JTabbedPane pickpane) { - pickpane.addChangeListener(new PickmapSelectionListener(this, pickpane)); - } - - /** * Add the ArchNPickChangeListener to the panel containing both * archlist and pickmaps. * @param pane the left-side panel Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-08 21:48:15 UTC (rev 1516) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-08 22:10:03 UTC (rev 1517) @@ -20,7 +20,6 @@ package cfeditor.gui.pickmapchooser; -import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -32,21 +31,12 @@ private final PickmapChooserControl control; - private final String activePickmap; // file-name of active pickmap - - private final JTabbedPane tabpane; - - public PickmapSelectionListener(final PickmapChooserControl control, final JTabbedPane pane) { + public PickmapSelectionListener(final PickmapChooserControl control) { this.control = control; - tabpane = pane; - activePickmap = null; } public void stateChanged(final ChangeEvent e) { - if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { - // new pickmap is active - control.updateActivePickmap(); - } + control.updateActivePickmap(); } } // class PickmapSelectionListener Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-08 21:48:15 UTC (rev 1516) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-08 22:10:03 UTC (rev 1517) @@ -224,7 +224,6 @@ pickmapChooserControl = new PickmapChooserControl(pickmapPanel); pickmapPanel.setComponentPopupMenu(ACTION_FACTORY.createPopupMenu(true, "pickmaps")); pickmapPanel.setBorder(BorderFactory.createEmptyBorder(IGUIConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); - PickmapChooserControl.getInstance().addPickmapSelectionListener(pickmapPanel); statusBar = new StatusBar(mainControl); archPanel = new InsertionObjectChooser(mainControl); Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 21:48:15 UTC (rev 1516) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 22:10:03 UTC (rev 1517) @@ -83,6 +83,7 @@ view = new PickmapChooserView(tabpane); actions = new Actions(this); actions.init(); + tabpane.addChangeListener(new PickmapSelectionListener(this, mainControl)); } /** @@ -333,15 +334,6 @@ } /** - * Add the PickmapSelectionListener to the pickmap tabbed panel. - * @param pickpane the panel with pickmaps - * @todo this method's name is a Bad Thing - */ - public void addPickmapSelectionListener(final JTabbedPane pickpane) { - pickpane.addChangeListener(new PickmapSelectionListener(this, mainControl, pickpane)); - } - - /** * Add the ArchNPickChangeListener to the panel containing both * archlist and pickmaps. * @param pane the left-side panel Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-08 21:48:15 UTC (rev 1516) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapSelectionListener.java 2007-01-08 22:10:03 UTC (rev 1517) @@ -21,7 +21,7 @@ package daieditor.gui.pickmapchooser; import daieditor.CMainControl; -import javax.swing.JTabbedPane; +import daieditor.map.MapControl; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -35,23 +35,17 @@ private final CMainControl mainControl; - private final String activePickmap; // file-name of active pickmap - - private final JTabbedPane tabpane; - - public PickmapSelectionListener(final PickmapChooserControl control, final CMainControl mainControl, final JTabbedPane pane) { + public PickmapSelectionListener(final PickmapChooserControl control, final CMainControl mainControl) { this.control = control; this.mainControl = mainControl; - tabpane = pane; - activePickmap = null; } public void stateChanged(final ChangeEvent e) { - if (activePickmap == null || activePickmap.length() <= 0 || !tabpane.getTitleAt(tabpane.getSelectedIndex()).equals(activePickmap)) { - // new pickmap is active - control.updateActivePickmap(); + control.updateActivePickmap(); + final MapControl pickmap = control.getCurrentPickmap(); + if (pickmap != null) { + pickmap.getMapViewFrame().unHighlight(); } - control.getCurrentPickmap().getMapViewFrame().unHighlight(); mainControl.showArchPanelQuickObject(null); // send it to quick view } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-08 22:24:55
|
Revision: 1518 http://svn.sourceforge.net/gridarta/?rev=1518&view=rev Author: akirschbaum Date: 2007-01-08 14:24:56 -0800 (Mon, 08 Jan 2007) Log Message: ----------- Remove PickmapChooserControl singleton instance. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java trunk/crossfire/src/cfeditor/gui/NewMapDialog.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java trunk/daimonin/src/daieditor/gui/NewMapDialog.java trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java trunk/daimonin/src/daieditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -35,7 +35,6 @@ import cfeditor.gui.ReplaceDialog; import cfeditor.gui.map.MapCursorControl; import cfeditor.gui.map.MapPropertiesDialog; -import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; import cfeditor.io.CMapReader; @@ -800,7 +799,7 @@ if (level.isPickmap()) { // special case: close a pickmap - PickmapChooserControl.getInstance().closePickmap(level); + mainView.getPickmapChooserControl().closePickmap(level); level.levelCloseNotify(); } else { // Notify the level about the closing Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -333,9 +333,9 @@ */ public GameObject getArchPanelHighlight() { - if ((isPickmapActive() || archPanel.getArchPanelSelection() == null) && PickmapChooserControl.getInstance().isLoadComplete() && PickmapChooserControl.getInstance().getCurrentPickmap() != null) { + if ((isPickmapActive() || archPanel.getArchPanelSelection() == null) && pickmapChooserControl.isLoadComplete() && pickmapChooserControl.getCurrentPickmap() != null) { // get the active pickmap - final MapControl pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); + final MapControl pmap = pickmapChooserControl.getCurrentPickmap(); if (pmap != null && pmap.getMapViewFrame().isHighlight()) { // now try to get the topmost object @@ -893,6 +893,15 @@ return selectedSquareControl; } + /** + * Return the pickmap chooser control. + * + * @return the pickmap chooser control + */ + public PickmapChooserControl getPickmapChooserControl() { + return pickmapChooserControl; + } + private final class LookAndFeelAction extends AbstractAction { private final String className; Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -30,7 +30,6 @@ import cfeditor.IGUIConstants; import cfeditor.gameobject.face.FaceObject; import cfeditor.gameobject.face.FaceObjects; -import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.map.MapArchObject; import java.io.BufferedOutputStream; import java.io.BufferedReader; @@ -172,7 +171,7 @@ } // load pickmaps - PickmapChooserControl.getInstance().loadPickmaps(); + mainControl.getMainView().getPickmapChooserControl().loadPickmaps(); // load the treasurelists data CFTreasureListTree.init(); Modified: trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/crossfire/src/cfeditor/gui/InsertionObjectChooser.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -29,7 +29,6 @@ import cfeditor.CSettings; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; -import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.map.MapArchObject; import java.awt.BorderLayout; import java.awt.Dimension; @@ -97,7 +96,7 @@ archAndPickPane.addTab("Arch List", tabDesktop); archAndPickPane.addTab("Pickmaps", mainControl.getMainView().getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? - PickmapChooserControl.getInstance().addArchNPickChangeListener(archAndPickPane); + mainControl.getMainView().getPickmapChooserControl().addArchNPickChangeListener(archAndPickPane); // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Modified: trunk/crossfire/src/cfeditor/gui/NewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/crossfire/src/cfeditor/gui/NewMapDialog.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -28,7 +28,6 @@ import cfeditor.CSettings; import cfeditor.IGUIConstants; import cfeditor.gameobject.ArchetypeSet; -import cfeditor.gui.pickmapchooser.PickmapChooserControl; import cfeditor.map.MapArchObject; import java.awt.Component; import java.awt.FlowLayout; @@ -260,7 +259,7 @@ if (mapType == MapType.GAMEMAP) { mainControl.newLevel(null, maparch, true, null); } else if (mapType == MapType.PICKMAP) { - return PickmapChooserControl.getInstance().addNewPickmap(parent, maparch); + return mainControl.getMainView().getPickmapChooserControl().addNewPickmap(parent, maparch); } return true; Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -61,9 +61,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** Singleton instance of this class. */ - private static PickmapChooserControl instance; - private final CMainControl mainControl; // main control reference /** All open pickmaps (the map controllers get stored in the vector). */ @@ -81,7 +78,6 @@ */ public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); - instance = this; view = new PickmapChooserView(tabpane); actions = new Actions(this); actions.init(); @@ -89,14 +85,6 @@ } /** - * Return the singleton instance of this class. - * @return the singleton instance of this class - */ - public static PickmapChooserControl getInstance() { - return instance; - } - - /** * Return whether loading of pickmaps is complete and at least one pickmap is available. * @return <code>true</code> if loading of pickmaps is complete and at least one pickmap is available, otherwise <code>false</code> * @todo check whether this method returns <code>true</code> or <code>false</code> if the loading process is complete but no pickmaps are availbale. Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -42,7 +42,6 @@ import daieditor.gui.map.MapCursorControl; import daieditor.gui.map.MapPreviewAccessory; import daieditor.gui.map.MapPropertiesDialog; -import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.DevPrefs; import daieditor.gui.prefs.GUIPrefs; @@ -973,7 +972,7 @@ if (level.isPickmap()) { // special case: close a pickmap - PickmapChooserControl.getInstance().closePickmap(level); + mainView.getPickmapChooserControl().closePickmap(level); level.levelCloseNotify(); } else { // Notify the level about the closing @@ -2228,7 +2227,7 @@ if (arch != null) { title.append("with arch ").append(arch.getArchetypeName()); } else { - pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); + pmap = mainControl.getMainView().getPickmapChooserControl().getCurrentPickmap(); if (pmap != null) { title.append("with pickmap ").append(pmap.getMapArchObject().getMapName()); } else { // ok ,we have a problem here: arch == null, pmap == null... Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/CMainView.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -296,9 +296,9 @@ */ @Nullable public GameObject getArchPanelHighlight() { - if ((pickmapActive || archPanel.getArchPanelSelection() == null) && PickmapChooserControl.getInstance().isLoadComplete() && PickmapChooserControl.getInstance().getCurrentPickmap() != null) { + if ((pickmapActive || archPanel.getArchPanelSelection() == null) && pickmapChooserControl.isLoadComplete() && pickmapChooserControl.getCurrentPickmap() != null) { // get the active pickmap - final MapControl pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); + final MapControl pmap = pickmapChooserControl.getCurrentPickmap(); if (pmap != null && pmap.getMapViewFrame().isHighlight()) { // now try to get the topmost object @@ -331,9 +331,9 @@ */ @Nullable public List<GameObject> getArchPanelSelection() { - if ((pickmapActive || archPanel.getArchPanelSelection() == null) && PickmapChooserControl.getInstance().isLoadComplete()) { + if ((pickmapActive || archPanel.getArchPanelSelection() == null) && pickmapChooserControl.isLoadComplete()) { // get the active pickmap - final MapControl pmap = PickmapChooserControl.getInstance().getCurrentPickmap(); + final MapControl pmap = pickmapChooserControl.getCurrentPickmap(); if (pmap != null) { return CopyBuffer.getMapArchList(pmap, 100); } @@ -835,4 +835,13 @@ return archPanel.currentDirection; } + /** + * Return the pickmap chooser control. + * + * @return the pickmap chooser control + */ + public PickmapChooserControl getPickmapChooserControl() { + return pickmapChooserControl; + } + } // class CMainView Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -33,7 +33,6 @@ import daieditor.gameobject.face.ArchFaceProvider; import daieditor.gameobject.face.DuplicateFaceException; import daieditor.gameobject.face.FaceObjects; -import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import java.awt.BorderLayout; import java.io.BufferedReader; @@ -214,7 +213,7 @@ } // load pickmaps - PickmapChooserControl.getInstance().loadPickmaps(); + mainControl.getMainView().getPickmapChooserControl().loadPickmaps(); // load the treasurelists data CFTreasureListTree.init(); Modified: trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java =================================================================== --- trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/gui/InsertionObjectChooser.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -29,7 +29,6 @@ import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.gui.map.tools.ToolPalette; -import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import java.awt.BorderLayout; import java.awt.GridBagConstraints; @@ -116,7 +115,7 @@ archAndPickPane.addTab("Arch List", archPane); archAndPickPane.addTab("Pickmaps", mainControl.getMainView().getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? - PickmapChooserControl.getInstance().addArchNPickChangeListener(archAndPickPane); + mainControl.getMainView().getPickmapChooserControl().addArchNPickChangeListener(archAndPickPane); // calculate default value in case there is no settings file Modified: trunk/daimonin/src/daieditor/gui/NewMapDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/NewMapDialog.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/gui/NewMapDialog.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -29,7 +29,6 @@ import static daieditor.CMainControl.PREFS_USERNAME; import static daieditor.CMainControl.PREFS_USERNAME_DEFAULT; import daieditor.IGUIConstants; -import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import java.awt.Component; import java.awt.FlowLayout; @@ -300,7 +299,7 @@ if (mapType == MapType.GAMEMAP) { mainControl.newLevel(null, maparch, true); } else if (mapType == MapType.PICKMAP) { - return PickmapChooserControl.getInstance().addNewPickmap(parent, maparch); + return mainControl.getMainView().getPickmapChooserControl().addNewPickmap(parent, maparch); } return true; Modified: trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -59,9 +59,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** Singleton instance of this class. */ - private static PickmapChooserControl instance; - private final CMainControl mainControl; // main control reference /** All open pickmaps (the map controllers get stored in the vector). */ @@ -79,7 +76,6 @@ */ public PickmapChooserControl(final JTabbedPane tabpane) { mainControl = CMainControl.getInstance(); - instance = this; view = new PickmapChooserView(tabpane); actions = new Actions(this); actions.init(); @@ -87,14 +83,6 @@ } /** - * Return the singleton instance of this class. - * @return the singleton instance of this class - */ - public static PickmapChooserControl getInstance() { - return instance; - } - - /** * Return whether loading of pickmaps is complete and at least one pickmap is available. * @return <code>true</code> if loading of pickmaps is complete and at least one pickmap is available, otherwise <code>false</code> */ Modified: trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -30,7 +30,6 @@ import daieditor.CMainView; import daieditor.CopyBuffer; import daieditor.gameobject.GameObject; -import daieditor.gui.pickmapchooser.PickmapChooserControl; import daieditor.map.MapArchObject; import daieditor.map.MapControl; import daieditor.map.MapModel; @@ -248,7 +247,7 @@ GameObject gameObject = mainControl.getArchPanelHighlight(); String archname = mainControl.getPanelArchName(); if (gameObject == null) { - gameObject = CopyBuffer.getRandomMapArch(PickmapChooserControl.getInstance().getCurrentPickmap(), 100); + gameObject = CopyBuffer.getRandomMapArch(mainControl.getMainView().getPickmapChooserControl().getCurrentPickmap(), 100); if (gameObject == null) { return; } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-08 22:10:03 UTC (rev 1517) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2007-01-08 22:24:56 UTC (rev 1518) @@ -31,7 +31,6 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.LevelRenderer; import daieditor.gui.map.SimpleLevelRenderer; -import daieditor.gui.pickmapchooser.PickmapChooserControl; import java.awt.Graphics; import java.awt.Image; import static java.awt.Image.SCALE_SMOOTH; @@ -294,13 +293,13 @@ // TODO } } else { - final int i = PickmapChooserControl.getInstance().getPickmapTabIndexByName(getMapFileName()); + final int i = mainControl.getMainView().getPickmapChooserControl().getPickmapTabIndexByName(getMapFileName()); // -1: this map is not a pickmap - every other value is the tab index if (i != -1) { - PickmapChooserControl.getInstance().closePickmap(PickmapChooserControl.getInstance().getPickmapByIndex(i)); - PickmapChooserControl.getInstance().openPickmap(mapFile, -1); // open the new map - PickmapChooserControl.getInstance().setActivePickmap(PickmapChooserControl.getInstance().getPickmapTabIndexByName(getMapFileName())); + mainControl.getMainView().getPickmapChooserControl().closePickmap(mainControl.getMainView().getPickmapChooserControl().getPickmapByIndex(i)); + mainControl.getMainView().getPickmapChooserControl().openPickmap(mapFile, -1); // open the new map + mainControl.getMainView().getPickmapChooserControl().setActivePickmap(mainControl.getMainView().getPickmapChooserControl().getPickmapTabIndexByName(getMapFileName())); if (mapViewFrame != null) { // Update the main view so the new map instantly pops up. final Graphics g = mapViewFrame.getGraphics(); @@ -384,7 +383,7 @@ public void insertSelArchToMap(final Point pos, final boolean allowMany) { // this is the arch that would get inserted from pickmap, but it also could // be a default arch (when pickmap has no selection) - GameObject newarch = CopyBuffer.getRandomMapArch(PickmapChooserControl.getInstance().getCurrentPickmap(), 100); + GameObject newarch = CopyBuffer.getRandomMapArch(mainControl.getMainView().getPickmapChooserControl().getCurrentPickmap(), 100); if (!mainControl.getMainView().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { // insert default arch from archlist: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |