You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2006-12-02 10:50:19
|
Revision: 784 http://svn.sourceforge.net/gridarta/?rev=784&view=rev Author: akirschbaum Date: 2006-12-02 02:50:19 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Rename cfeditor.CMapPropertiesDialog to cfeditor.gui.map.MapPropertiesDialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-02 09:42:45 UTC (rev 783) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-02 10:50:19 UTC (rev 784) @@ -31,6 +31,7 @@ import cfeditor.gameobject.face.FaceObjects; import cfeditor.io.CMapReader; import cfeditor.io.CMapWriter; +import cfeditor.gui.map.MapPropertiesDialog; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -1173,7 +1174,7 @@ */ void showMapProperties(final MapControl level) { if (level != null) { - new CMapPropertiesDialog(this, mainView, level); + new MapPropertiesDialog(this, mainView, level); } } @@ -1200,7 +1201,7 @@ * @param strMapTitle map name * @param mapSize size of map */ - void setLevelProperties(final MapControl level, final String archText, final String loreText, final String strMapTitle, final Size2D mapSize) { + public void setLevelProperties(final MapControl level, final String archText, final String loreText, final String strMapTitle, final Size2D mapSize) { if (level != null) { level.setProperties(archText, loreText, strMapTitle, mapSize); refreshMenusAndToolbars(); Deleted: trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java 2006-12-02 09:42:45 UTC (rev 783) +++ trunk/crossfire/src/cfeditor/CMapPropertiesDialog.java 2006-12-02 10:50:19 UTC (rev 784) @@ -1,661 +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; - -import cfeditor.map.MapArchObject; -import cfeditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JViewport; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EmptyBorder; -import javax.swing.border.EtchedBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.Size2D; -import net.sf.gridarta.help.Help; - -/** - * Dialog used to ask the user the properties for the new level. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - */ -public final class CMapPropertiesDialog extends CDialogBase { - - public static final String CENTER_MAP_KEY = "MapProperties.centerMapOnResize"; - - private final CMainControl mainControl; - - private final MapControl m_level; - - // input components, see MapArchObject for expl. of purpose - private final JTextArea m_textArea; // the msg text/arch text - - private final JTextArea m_loreArea; // the lore text - - private final JTextField m_nameField = new JTextField(); // name of arch - - private final JTextField m_regionField = new JTextField(); // map's region - - private final JTextField m_levelWidthField = new JTextField(); // len x - - private final JTextField m_levelHeightField = new JTextField(); // len y - - private final JCheckBox m_unique = new JCheckBox(); // map unique - - private final JCheckBox m_outdoor = new JCheckBox(); // map outdoor - - private final JCheckBox m_fixedReset = new JCheckBox(); // fixed reset - - private final JCheckBox m_nosmooth = new JCheckBox(); // map nosmooth - - private final JTextField m_enterX = new JTextField(); // enter x - - private final JTextField m_enterY = new JTextField(); // enter y - - private final JTextField m_swapTime = new JTextField(); // swap time - - private final JTextField m_resetTimeout = new JTextField(); // reset timeout - - private final JTextField m_difficulty = new JTextField(); // map difficulty - - private final JTextField m_darkness = new JTextField(); // darkness - - private final JTextField[] m_tilePath = new JTextField[IGUIConstants.DIRECTIONS]; // tile paths - - // only for CF: - private final JTextField m_shopitems = new JTextField(); // shopitems - - private final JTextField m_shopgreed = new JTextField(); // shopgreed - - private final JTextField m_shopmax = new JTextField(); // shop maximum price - - private final JTextField m_shopmin = new JTextField(); // shop minimum price - - private final JTextField m_shoprace = new JTextField(); // shop's preferred race - - private final JTextField m_temp = new JTextField(); // temperature - - private final JTextField m_pressure = new JTextField(); // pressure - - private final JTextField m_humid = new JTextField(); // humidity - - private final JTextField m_windspeed = new JTextField(); // wind speed - - private final JTextField m_winddir = new JTextField(); // wind direction - - private final JTextField m_sky = new JTextField(); // sky setting - - // only for ISO: - private final JCheckBox m_no_magic = new JCheckBox(); - - private final JCheckBox m_no_priest = new JCheckBox(); - - private final JCheckBox m_no_summon = new JCheckBox(); - - private final JCheckBox m_no_harm = new JCheckBox(); - - private final JCheckBox m_fixed_login = new JCheckBox(); - - private final JCheckBox m_perm_death = new JCheckBox(); - - private final JCheckBox m_ultra_death = new JCheckBox(); - - private final JCheckBox m_ultimate_death = new JCheckBox(); - - private final JCheckBox m_pvp = new JCheckBox(); - - private static final long serialVersionUID = 1L; - - /** - * Constructs the map-options dialog. - * @param mainControl The controller of this dialog. - * @param parentFrame The parent frame of this dialog. - * @param level The level whose properties are shown/edited. - */ - CMapPropertiesDialog(final CMainControl mainControl, final Frame parentFrame, final MapControl level) { - // set title - super(parentFrame, "" + level.getMapNameWithoutMusic() + " - Map Properties"); - final MapArchObject map = level.getMapModel().getMapArchObject(); // map arch object - - this.mainControl = mainControl; // main control - m_level = level; // map control - - getContentPane().setLayout(new BorderLayout()); - - // main panel (gridbag) - final GridBagLayout gridbag = new GridBagLayout(); - final GridBagConstraints c = new GridBagConstraints(); - final JPanel mainPanel = new JPanel(gridbag); - //mainPanel.setLayout(new CardLayout()); - mainPanel.setBorder(new EmptyBorder( - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS)); - - // 1. map panel: - final JPanel mapPanel = new JPanel(new GridLayout(0, 1)); - mapPanel.setBorder( - new CompoundBorder( - new TitledBorder(new EtchedBorder(), "Map"), - new EmptyBorder( - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS))); - - createPanelLine(mapPanel, m_nameField, 16, m_level.getMapName(), "Name: "); - createPanelLine(mapPanel, m_regionField, 16, map.getMapRegion(), "Region: "); - final Size2D mapSize = m_level.getMapSize(); - createPanelLine(mapPanel, m_levelWidthField, 10, String.valueOf(mapSize.getWidth()), "Width: "); - createPanelLine(mapPanel, m_levelHeightField, 10, String.valueOf(mapSize.getHeight()), "Height: "); - createPanelCBox(mapPanel, m_unique, map.isUnique(), " Unique Map"); - createPanelCBox(mapPanel, m_outdoor, map.isOutdoor(), " Outdoor Map"); - createPanelCBox(mapPanel, m_fixedReset, map.isFixedReset(), " Fixed Reset"); - createPanelCBox(mapPanel, m_nosmooth, map.isNosmooth(), " Nosmooth Map"); - - // set constraints - c.fill = GridBagConstraints.BOTH; - c.weightx = 1.0; - c.weighty = 1.0; - gridbag.setConstraints(mapPanel, c); - mainPanel.add(mapPanel); - - // 2. options panel: - final JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP); - tabPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 0)); - - final JPanel optionPanel = new JPanel(new GridLayout(1, 1)); - final JPanel optionPanel2 = new JPanel(); - optionPanel2.setLayout(new BoxLayout(optionPanel2, BoxLayout.Y_AXIS)); - final JScrollPane scrollPane2 = new JScrollPane(optionPanel2); - scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - scrollPane2.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - - createPanelLine(optionPanel2, m_enterX, 10, String.valueOf(map.getEnterX()), "Enter X: "); - createPanelLine(optionPanel2, m_enterY, 10, String.valueOf(map.getEnterY()), "Enter Y: "); - createPanelLine(optionPanel2, m_difficulty, 10, String.valueOf(map.getDifficulty()), "Difficulty: "); - createPanelLine(optionPanel2, m_darkness, 10, String.valueOf(map.getDarkness()), "Darkness: "); - createPanelLine(optionPanel2, m_swapTime, 10, String.valueOf(map.getSwapTime()), "Swap Time: "); - createPanelLine(optionPanel2, m_resetTimeout, 10, String.valueOf(map.getResetTimeout()), "Reset Timeout: "); - - createPanelLine(optionPanel2, m_shopitems, 10, map.getShopItems(), "Shop Type: "); - createPanelLine(optionPanel2, m_shopgreed, 10, String.valueOf(map.getShopGreed()), "Shop Greed: "); - createPanelLine(optionPanel2, m_shopmax, 10, String.valueOf(map.getShopMax()), "Upper Price Limit: "); - createPanelLine(optionPanel2, m_shopmin, 10, String.valueOf(map.getShopMin()), "Lower Price Limit: "); - createPanelLine(optionPanel2, m_shoprace, 10, map.getShopRace(), "Shop Race: "); - - createPanelLine(optionPanel2, m_temp, 10, String.valueOf(map.getTemp()), "Temperature: "); - createPanelLine(optionPanel2, m_pressure, 10, String.valueOf(map.getPressure()), "Pressure: "); - createPanelLine(optionPanel2, m_humid, 10, String.valueOf(map.getHumid()), "Humidity: "); - createPanelLine(optionPanel2, m_windspeed, 10, String.valueOf(map.getWindspeed()), "Wind Speed: "); - createPanelLine(optionPanel2, m_winddir, 10, String.valueOf(map.getWinddir()), "Wind Direction: "); - createPanelLine(optionPanel2, m_sky, 10, String.valueOf(map.getSky()), "Sky Setting: "); - - optionPanel.add(scrollPane2); - - optionPanel.setPreferredSize(new Dimension(240, 185)); - - // set constraints - c.weightx = 1.0; - c.weighty = 1.0; - c.gridwidth = GridBagConstraints.REMAINDER; //end row - m_loreArea = new JTextArea(); - gridbag.setConstraints(tabPane, c); - - tabPane.addTab("Options", optionPanel); - m_loreArea.setText(m_level.getMapLore()); - m_loreArea.setCaretPosition(0); - m_loreArea.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0)); - final JScrollPane lscrollPane = new JScrollPane(m_loreArea); - lscrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - lscrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - lscrollPane.setPreferredSize(new Dimension(20, 20)); - - tabPane.addTab("Lore", lscrollPane); - mainPanel.add(tabPane); - - // 3. map text panel: - final JPanel mapDataPanel = new JPanel(new BorderLayout(1, 1)); - mapDataPanel.setBorder( - new CompoundBorder( - new TitledBorder(new EtchedBorder(), "Map Text"), - new EmptyBorder( - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS))); - - final JPanel labelPanel = new JPanel(new BorderLayout(1, 1)); - m_textArea = new JTextArea(4, 4); - m_textArea.setText(m_level.getMapText()); - m_textArea.setCaretPosition(0); - m_textArea.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0)); - final JScrollPane scrollPane = new JScrollPane(m_textArea); - scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - - labelPanel.add(scrollPane, BorderLayout.CENTER); - mapDataPanel.add(labelPanel); - - // set constraints - c.weightx = 1.0; - c.weighty = 1.0; - c.gridwidth = GridBagConstraints.RELATIVE; - gridbag.setConstraints(mapDataPanel, c); - mainPanel.add(mapDataPanel); - - // 4. map tiling panel: - final JPanel tilePathPanel = new JPanel(new GridLayout(IGUIConstants.DIRECTIONS, 2)); - tilePathPanel.setBorder( - new CompoundBorder( - new TitledBorder(new EtchedBorder(), "Paths for Map-Tiling"), - new EmptyBorder( - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS, - IGUIConstants.DIALOG_INSETS))); - - createPanelLine(tilePathPanel, m_tilePath[0] = new JTextField(), 16, map.getTilePath(0), "North: "); - createPanelLine(tilePathPanel, m_tilePath[1] = new JTextField(), 16, map.getTilePath(1), "East: "); - createPanelLine(tilePathPanel, m_tilePath[2] = new JTextField(), 16, map.getTilePath(2), "South: "); - createPanelLine(tilePathPanel, m_tilePath[3] = new JTextField(), 16, map.getTilePath(3), "West: "); - createPanelLine(tilePathPanel, m_tilePath[4] = new JTextField(), 16, map.getTilePath(4), "Top: "); - createPanelLine(tilePathPanel, m_tilePath[5] = new JTextField(), 16, map.getTilePath(5), "Bottom: "); - - // set constraints - c.weightx = 1.0; - c.weighty = 1.0; - gridbag.setConstraints(tilePathPanel, c); - mainPanel.add(tilePathPanel); - - getContentPane().add(mainPanel, BorderLayout.CENTER); - - // build the button panel - final JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(new BorderLayout()); - buttonPanel.add(Box.createGlue()); - final JPanel left_buttons = new JPanel(new FlowLayout(FlowLayout.LEFT)); - final JPanel right_buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - - // Help button - JButton button = new JButton("Help"); - button.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // open the help window - new Help(mainControl.getMainView(), "tut_mapattr.html").setVisible(true); - } - }); - left_buttons.add(button); - - // OK button - button = new JButton("OK"); - button.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // try to apply changes, then kill window - if (modifyMapProperties()) { - dispose(); - } - } - }); - right_buttons.add(button); - - // Restore Button - button = new JButton("Restore"); - button.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // restore to saved values from maparch - restoreMapProperties(); - } - }); - right_buttons.add(button); - - // Cancel Button - button = new JButton("Cancel"); - button.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // kill window - dispose(); - } - }); - right_buttons.add(button); - - buttonPanel.add(left_buttons, BorderLayout.WEST); - buttonPanel.add(right_buttons, BorderLayout.EAST); - - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - - setBounds(this.mainControl.getMainView().getX() + (this.mainControl.getMainView().getWidth() - 545) / 2, - this.mainControl.getMainView().getY() + (this.mainControl.getMainView().getHeight() - 480) / 2, - 545, 480); - pack(); - setVisible(true); - } - - /** - * create an "attribute"-line (format: <label> <textfield>) and insert it - * into the given parent layout - * @param parent parent panel where line gets inserted - * @param textField textfield - * @param n lenght of textfield - * @param defaultText initial text in textfield - * @param label (attribute-)label - */ - void createPanelLine(final JPanel parent, final JTextField textField, final int n, - final String defaultText, final String label) { - final JPanel lineLayout = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // layout for this line - lineLayout.add(new JLabel(label)); // create label (attr. name) - //textField = new JTextField(n); // create text field - textField.setColumns(n); - textField.setText(defaultText); // insert default text - lineLayout.add(textField); // add textf. to line - parent.add(lineLayout); // add line to parent layout - } - - /** - * create a checkbox-line and insert it into the given parent layout. - * similar to createPanelLine - * @param parent parent panel where checkbox gets inserted - * @param checkBox checkbox - * @param state initial state - * @param label (attribute-)label - */ - void createPanelCBox(final JPanel parent, final JCheckBox checkBox, - final boolean state, final String label) { - final JPanel lineLayout = new JPanel(new FlowLayout(FlowLayout.CENTER)); // layout for this line - //checkBox = new JCheckBox(label); // create checkbox - checkBox.setText(label); - checkBox.setSelected(state); // set to current state - lineLayout.add(checkBox); // add checkbox to line - parent.add(lineLayout); // add line to parent layout - } - - /** - * Checks the given values and modifies the current level. - * @return true if the level properties were edited, false if the - * parameters were wrong. - */ - private boolean modifyMapProperties() { - final MapArchObject map = m_level.getMapModel().getMapArchObject(); // map arch object - boolean modifyTilepaths = false; // true when map tile-paths were modified - - // tmp variables for parsing - final int width, height; - final int t_enter_x, t_enter_y; - final int t_reset_timeout, t_swap_time; - final int t_difficulty, t_darkness; - final int t_temp, t_pressure, t_humid; - final int t_winds, t_windd, t_sky; - final double t_shopgreed; - final int t_shopmax, t_shopmin; - final String t_shopitems, t_shoprace; - final String t_region; - - // first check if the entries are all okay - try { - // try to parse everything - width = parseProperty(m_levelWidthField.getText(), "Width"); - height = parseProperty(m_levelHeightField.getText(), "Height"); - t_enter_x = parseProperty(m_enterX.getText(), "Enter X"); - t_enter_y = parseProperty(m_enterY.getText(), "Enter Y"); - t_swap_time = parseProperty(m_swapTime.getText(), "Swap Time"); - t_reset_timeout = parseProperty(m_resetTimeout.getText(), "Reset Timeout"); - t_difficulty = parseProperty(m_difficulty.getText(), "Difficulty"); - t_darkness = parseProperty(m_darkness.getText(), "Darkness"); - t_region = m_regionField.getText(); - - t_shopitems = m_shopitems.getText(); - t_shoprace = m_shoprace.getText(); - t_shopmax = parseProperty(m_shopmax.getText(), "Shop Maximum"); - t_shopmin = parseProperty(m_shopmin.getText(), "Shop Minimum"); - t_shopgreed = parsePropertyToDouble(m_shopgreed.getText(), "Shop Greed"); - t_temp = parseProperty(m_temp.getText(), "Temperature"); - t_pressure = parseProperty(m_pressure.getText(), "Pressure"); - t_humid = parseProperty(m_humid.getText(), "Humidity"); - t_winds = parseProperty(m_windspeed.getText(), "Wind Speed"); - t_windd = parseProperty(m_winddir.getText(), "Wind Direction"); - t_sky = parseProperty(m_sky.getText(), "Sky Setting"); - - // Now do some sanity checks: - if (width < 1 || height < 1) { - mainControl.showMessage( - "Illegal Value", - "Level dimensions must be greater than zero."); - return false; - } - if (t_darkness > 5) { - mainControl.showMessage( - "Illegal Value", - "Darkness level must be in range 0-5."); - return false; - } - if (m_nameField.getText().length() == 0) { - mainControl.showMessage( - "missing Map Name", - "You must specify a Map Name."); - return false; - } - } catch (final GridderException e) { - mainControl.showMessage("Invalid Entry", e.getMessage()); - return false; - } - - // if the mapsize has been modified, see if we should ask for a confirm - Size2D size = new Size2D(width, height); - if (!m_level.isCutoffSave(size)) { - if (!askConfirmResize(size)) { - // resizing has been cancelled - size = m_level.getMapSize(); - } - } - - // now that all is well, write the new values into the maparch - mainControl.setLevelProperties(m_level, m_textArea.getText(), m_loreArea.getText(), - m_nameField.getText(), size); - - map.setMapRegion(t_region); - map.setEnterX(t_enter_x); - map.setEnterY(t_enter_y); - map.setResetTimeout(t_reset_timeout); - map.setSwapTime(t_swap_time); - map.setDifficulty(t_difficulty); - map.setDarkness(t_darkness); - map.setUnique(m_unique.isSelected()); - map.setOutdoor(m_outdoor.isSelected()); - map.setFixedReset(m_fixedReset.isSelected()); - map.setNosmooth(m_nosmooth.isSelected()); - - map.setShopItems(t_shopitems); - map.setShopRace(t_shoprace); - map.setShopMin(t_shopmin); - map.setShopMax(t_shopmax); - map.setShopGreed(t_shopgreed); - - map.setTemp(t_temp); - map.setPressure(t_pressure); - map.setHumid(t_humid); - map.setWindspeed(t_winds); - map.setWinddir(t_windd); - map.setSky(t_sky); - - // update tilepaths - for (int i = 0; i < IGUIConstants.DIRECTIONS; i++) { - if ((map.getTilePath(i) == null && (m_tilePath[i].getText() == null || m_tilePath[i].getText().length() == 0)) - || (map.getTilePath(i) != null && !map.getTilePath(i).equals(m_tilePath[i].getText()))) { - modifyTilepaths = true; - } - map.setTilePath(i, m_tilePath[i].getText()); - } - - // refresh menus if tilepaths have been modified - if (modifyTilepaths) { - mainControl.refreshMenus(); - } - - // set flag that map has changed - m_level.setLevelChangedFlag(); - - return true; - } - - /** - * This is a simple string-to-int parser that throws CGridder- instead of - * NumberFormatExceptions, with appropriate errormessage. Used in - * modifyMapProperties(). - * @param s string to be parse - * @param label attribute label for errormessage - * @return value of String 's', zero if 's' is empty - * @throws GridderException when parsing fails - */ - private int parseProperty(final String s, final String label) throws GridderException { - final int r; // return value - - if (s.length() == 0) { - return 0; // empty string is interpreted as zero - } - - try { - r = Integer.parseInt(s); // trying to parse - } catch (final NumberFormatException illegalNumbers) { - // 's' is not a number - throw new GridderException(label + ": '" + s + "' is not a numerical integer value."); - } - - // negative values are not allowed - if (r < 0) { - throw new GridderException(label + ": '" + s + "' is negative."); - } - - return r; // everything okay - } - - /** - * This is a simple string-to-double parser that throws CGridder- instead - * of NumberFormatExceptions, with appropriate errormessage. Used in - * modifyMapProperties(). - * @param s string to be parse - * @param label attribute label for errormessage - * @return value of String 's', zero if 's' is empty - * @throws GridderException when parsing fails - */ - private double parsePropertyToDouble(final String s, final String label) throws GridderException { - final double r; // return value - - if (s.length() == 0) { - return 0; // empty string is interpreted as zero - } - - try { - r = Double.parseDouble(s); // trying to parse - } catch (final NumberFormatException illegalNumbers) { - // 's' is not a number - throw new GridderException(label + ": '" + s + "' is not a numerical double value."); - } - - // negative values are not allowed - if (r < 0) { - throw new GridderException(label + ": '" + s + "' is negative."); - } - - return r; // everything okay - } - - /** Reset all map properties to the saved values in the maparch */ - private void restoreMapProperties() { - final MapArchObject map = m_level.getMapModel().getMapArchObject(); // map arch object - - m_level.getMapModel().getMapArchObject().getText(); - m_textArea.setText(m_level.getMapText()); - m_loreArea.setText(m_level.getMapLore()); - m_nameField.setText(m_level.getMapName()); - m_regionField.setText("" + map.getMapRegion()); - final Size2D mapSize = map.getMapSize(); - m_levelWidthField.setText(String.valueOf(mapSize.getWidth())); - m_levelHeightField.setText(String.valueOf(mapSize.getHeight())); - m_enterX.setText("" + map.getEnterX()); - m_enterY.setText("" + map.getEnterY()); - m_swapTime.setText("" + map.getSwapTime()); - m_resetTimeout.setText("" + map.getResetTimeout()); - m_darkness.setText("" + map.getDarkness()); - m_difficulty.setText("" + map.getDifficulty()); - - m_unique.setSelected(map.isUnique()); - m_outdoor.setSelected(map.isOutdoor()); - m_fixedReset.setSelected(map.isFixedReset()); - m_nosmooth.setSelected(map.isNosmooth()); - - m_shopitems.setText("" + map.getShopItems()); - m_shoprace.setText("" + map.getShopRace()); - m_shopmax.setText("" + map.getShopMax()); - m_shopmin.setText("" + map.getShopMin()); - m_shopgreed.setText("" + map.getShopGreed()); - m_temp.setText("" + map.getTemp()); - m_pressure.setText("" + map.getPressure()); - m_humid.setText("" + map.getHumid()); - m_windspeed.setText("" + map.getWindspeed()); - m_winddir.setText("" + map.getWinddir()); - m_sky.setText("" + map.getSky()); - - for (int i = 0; i < 4; i++) { - m_tilePath[i].setText("" + map.getTilePath(i)); - } - } - - /** - * Open a popup and ask user to confirm his map-resizing selection. This - * popup dialog disables all other windows (and threads). - * @return true if user confirmed, false if user cancelled resize - */ - private boolean askConfirmResize(final Size2D size) { - return JOptionPane.showConfirmDialog(this, - "You selected a new map size of " + size.getWidth() + "x" + size.getHeight() + ". If the map was\n" + - "resized in this way, some objects would get cut off and deleted.\n" + - "Are you really sure you want this?", - "Confirm", - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE) - == JOptionPane.YES_OPTION; - } - -} // class CMapPropertiesDialog Added: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2006-12-02 10:50:19 UTC (rev 784) @@ -0,0 +1,665 @@ +/* + * 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.map; + +import cfeditor.CDialogBase; +import cfeditor.CMainControl; +import cfeditor.GridderException; +import cfeditor.IGUIConstants; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapControl; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.help.Help; + +/** + * Dialog used to ask the user the properties for the new level. + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + */ +public final class MapPropertiesDialog extends CDialogBase { + + public static final String CENTER_MAP_KEY = "MapProperties.centerMapOnResize"; + + private final CMainControl mainControl; + + private final MapControl m_level; + + // input components, see MapArchObject for expl. of purpose + private final JTextArea m_textArea; // the msg text/arch text + + private final JTextArea m_loreArea; // the lore text + + private final JTextField m_nameField = new JTextField(); // name of arch + + private final JTextField m_regionField = new JTextField(); // map's region + + private final JTextField m_levelWidthField = new JTextField(); // len x + + private final JTextField m_levelHeightField = new JTextField(); // len y + + private final JCheckBox m_unique = new JCheckBox(); // map unique + + private final JCheckBox m_outdoor = new JCheckBox(); // map outdoor + + private final JCheckBox m_fixedReset = new JCheckBox(); // fixed reset + + private final JCheckBox m_nosmooth = new JCheckBox(); // map nosmooth + + private final JTextField m_enterX = new JTextField(); // enter x + + private final JTextField m_enterY = new JTextField(); // enter y + + private final JTextField m_swapTime = new JTextField(); // swap time + + private final JTextField m_resetTimeout = new JTextField(); // reset timeout + + private final JTextField m_difficulty = new JTextField(); // map difficulty + + private final JTextField m_darkness = new JTextField(); // darkness + + private final JTextField[] m_tilePath = new JTextField[IGUIConstants.DIRECTIONS]; // tile paths + + // only for CF: + private final JTextField m_shopitems = new JTextField(); // shopitems + + private final JTextField m_shopgreed = new JTextField(); // shopgreed + + private final JTextField m_shopmax = new JTextField(); // shop maximum price + + private final JTextField m_shopmin = new JTextField(); // shop minimum price + + private final JTextField m_shoprace = new JTextField(); // shop's preferred race + + private final JTextField m_temp = new JTextField(); // temperature + + private final JTextField m_pressure = new JTextField(); // pressure + + private final JTextField m_humid = new JTextField(); // humidity + + private final JTextField m_windspeed = new JTextField(); // wind speed + + private final JTextField m_winddir = new JTextField(); // wind direction + + private final JTextField m_sky = new JTextField(); // sky setting + + // only for ISO: + private final JCheckBox m_no_magic = new JCheckBox(); + + private final JCheckBox m_no_priest = new JCheckBox(); + + private final JCheckBox m_no_summon = new JCheckBox(); + + private final JCheckBox m_no_harm = new JCheckBox(); + + private final JCheckBox m_fixed_login = new JCheckBox(); + + private final JCheckBox m_perm_death = new JCheckBox(); + + private final JCheckBox m_ultra_death = new JCheckBox(); + + private final JCheckBox m_ultimate_death = new JCheckBox(); + + private final JCheckBox m_pvp = new JCheckBox(); + + private static final long serialVersionUID = 1L; + + /** + * Constructs the map-options dialog. + * @param mainControl The controller of this dialog. + * @param parentFrame The parent frame of this dialog. + * @param level The level whose properties are shown/edited. + */ + public MapPropertiesDialog(final CMainControl mainControl, final Frame parentFrame, final MapControl level) { + // set title + super(parentFrame, "" + level.getMapNameWithoutMusic() + " - Map Properties"); + final MapArchObject map = level.getMapModel().getMapArchObject(); // map arch object + + this.mainControl = mainControl; // main control + m_level = level; // map control + + getContentPane().setLayout(new BorderLayout()); + + // main panel (gridbag) + final GridBagLayout gridbag = new GridBagLayout(); + final GridBagConstraints c = new GridBagConstraints(); + final JPanel mainPanel = new JPanel(gridbag); + //mainPanel.setLayout(new CardLayout()); + mainPanel.setBorder(new EmptyBorder( + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS)); + + // 1. map panel: + final JPanel mapPanel = new JPanel(new GridLayout(0, 1)); + mapPanel.setBorder( + new CompoundBorder( + new TitledBorder(new EtchedBorder(), "Map"), + new EmptyBorder( + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS))); + + createPanelLine(mapPanel, m_nameField, 16, m_level.getMapName(), "Name: "); + createPanelLine(mapPanel, m_regionField, 16, map.getMapRegion(), "Region: "); + final Size2D mapSize = m_level.getMapSize(); + createPanelLine(mapPanel, m_levelWidthField, 10, String.valueOf(mapSize.getWidth()), "Width: "); + createPanelLine(mapPanel, m_levelHeightField, 10, String.valueOf(mapSize.getHeight()), "Height: "); + createPanelCBox(mapPanel, m_unique, map.isUnique(), " Unique Map"); + createPanelCBox(mapPanel, m_outdoor, map.isOutdoor(), " Outdoor Map"); + createPanelCBox(mapPanel, m_fixedReset, map.isFixedReset(), " Fixed Reset"); + createPanelCBox(mapPanel, m_nosmooth, map.isNosmooth(), " Nosmooth Map"); + + // set constraints + c.fill = GridBagConstraints.BOTH; + c.weightx = 1.0; + c.weighty = 1.0; + gridbag.setConstraints(mapPanel, c); + mainPanel.add(mapPanel); + + // 2. options panel: + final JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP); + tabPane.setBorder(BorderFactory.createEmptyBorder(0, 3, 3, 0)); + + final JPanel optionPanel = new JPanel(new GridLayout(1, 1)); + final JPanel optionPanel2 = new JPanel(); + optionPanel2.setLayout(new BoxLayout(optionPanel2, BoxLayout.Y_AXIS)); + final JScrollPane scrollPane2 = new JScrollPane(optionPanel2); + scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane2.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); + + createPanelLine(optionPanel2, m_enterX, 10, String.valueOf(map.getEnterX()), "Enter X: "); + createPanelLine(optionPanel2, m_enterY, 10, String.valueOf(map.getEnterY()), "Enter Y: "); + createPanelLine(optionPanel2, m_difficulty, 10, String.valueOf(map.getDifficulty()), "Difficulty: "); + createPanelLine(optionPanel2, m_darkness, 10, String.valueOf(map.getDarkness()), "Darkness: "); + createPanelLine(optionPanel2, m_swapTime, 10, String.valueOf(map.getSwapTime()), "Swap Time: "); + createPanelLine(optionPanel2, m_resetTimeout, 10, String.valueOf(map.getResetTimeout()), "Reset Timeout: "); + + createPanelLine(optionPanel2, m_shopitems, 10, map.getShopItems(), "Shop Type: "); + createPanelLine(optionPanel2, m_shopgreed, 10, String.valueOf(map.getShopGreed()), "Shop Greed: "); + createPanelLine(optionPanel2, m_shopmax, 10, String.valueOf(map.getShopMax()), "Upper Price Limit: "); + createPanelLine(optionPanel2, m_shopmin, 10, String.valueOf(map.getShopMin()), "Lower Price Limit: "); + createPanelLine(optionPanel2, m_shoprace, 10, map.getShopRace(), "Shop Race: "); + + createPanelLine(optionPanel2, m_temp, 10, String.valueOf(map.getTemp()), "Temperature: "); + createPanelLine(optionPanel2, m_pressure, 10, String.valueOf(map.getPressure()), "Pressure: "); + createPanelLine(optionPanel2, m_humid, 10, String.valueOf(map.getHumid()), "Humidity: "); + createPanelLine(optionPanel2, m_windspeed, 10, String.valueOf(map.getWindspeed()), "Wind Speed: "); + createPanelLine(optionPanel2, m_winddir, 10, String.valueOf(map.getWinddir()), "Wind Direction: "); + createPanelLine(optionPanel2, m_sky, 10, String.valueOf(map.getSky()), "Sky Setting: "); + + optionPanel.add(scrollPane2); + + optionPanel.setPreferredSize(new Dimension(240, 185)); + + // set constraints + c.weightx = 1.0; + c.weighty = 1.0; + c.gridwidth = GridBagConstraints.REMAINDER; //end row + m_loreArea = new JTextArea(); + gridbag.setConstraints(tabPane, c); + + tabPane.addTab("Options", optionPanel); + m_loreArea.setText(m_level.getMapLore()); + m_loreArea.setCaretPosition(0); + m_loreArea.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0)); + final JScrollPane lscrollPane = new JScrollPane(m_loreArea); + lscrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + lscrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + lscrollPane.setPreferredSize(new Dimension(20, 20)); + + tabPane.addTab("Lore", lscrollPane); + mainPanel.add(tabPane); + + // 3. map text panel: + final JPanel mapDataPanel = new JPanel(new BorderLayout(1, 1)); + mapDataPanel.setBorder( + new CompoundBorder( + new TitledBorder(new EtchedBorder(), "Map Text"), + new EmptyBorder( + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS))); + + final JPanel labelPanel = new JPanel(new BorderLayout(1, 1)); + m_textArea = new JTextArea(4, 4); + m_textArea.setText(m_level.getMapText()); + m_textArea.setCaretPosition(0); + m_textArea.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0)); + final JScrollPane scrollPane = new JScrollPane(m_textArea); + scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + + labelPanel.add(scrollPane, BorderLayout.CENTER); + mapDataPanel.add(labelPanel); + + // set constraints + c.weightx = 1.0; + c.weighty = 1.0; + c.gridwidth = GridBagConstraints.RELATIVE; + gridbag.setConstraints(mapDataPanel, c); + mainPanel.add(mapDataPanel); + + // 4. map tiling panel: + final JPanel tilePathPanel = new JPanel(new GridLayout(IGUIConstants.DIRECTIONS, 2)); + tilePathPanel.setBorder( + new CompoundBorder( + new TitledBorder(new EtchedBorder(), "Paths for Map-Tiling"), + new EmptyBorder( + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS, + IGUIConstants.DIALOG_INSETS))); + + createPanelLine(tilePathPanel, m_tilePath[0] = new JTextField(), 16, map.getTilePath(0), "North: "); + createPanelLine(tilePathPanel, m_tilePath[1] = new JTextField(), 16, map.getTilePath(1), "East: "); + createPanelLine(tilePathPanel, m_tilePath[2] = new JTextField(), 16, map.getTilePath(2), "South: "); + createPanelLine(tilePathPanel, m_tilePath[3] = new JTextField(), 16, map.getTilePath(3), "West: "); + createPanelLine(tilePathPanel, m_tilePath[4] = new JTextField(), 16, map.getTilePath(4), "Top: "); + createPanelLine(tilePathPanel, m_tilePath[5] = new JTextField(), 16, map.getTilePath(5), "Bottom: "); + + // set constraints + c.weightx = 1.0; + c.weighty = 1.0; + gridbag.setConstraints(tilePathPanel, c); + mainPanel.add(tilePathPanel); + + getContentPane().add(mainPanel, BorderLayout.CENTER); + + // build the button panel + final JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new BorderLayout()); + buttonPanel.add(Box.createGlue()); + final JPanel left_buttons = new JPanel(new FlowLayout(FlowLayout.LEFT)); + final JPanel right_buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); + + // Help button + JButton button = new JButton("Help"); + button.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent event) { + // open the help window + new Help(mainControl.getMainView(), "tut_mapattr.html").setVisible(true); + } + }); + left_buttons.add(button); + + // OK button + button = new JButton("OK"); + button.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent event) { + // try to apply changes, then kill window + if (modifyMapProperties()) { + dispose(); + } + } + }); + right_buttons.add(button); + + // Restore Button + button = new JButton("Restore"); + button.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent event) { + // restore to saved values from maparch + restoreMapProperties(); + } + }); + right_buttons.add(button); + + // Cancel Button + button = new JButton("Cancel"); + button.addActionListener(new ActionListener() { + public void actionPerformed(final ActionEvent event) { + // kill window + dispose(); + } + }); + right_buttons.add(button); + + buttonPanel.add(left_buttons, BorderLayout.WEST); + buttonPanel.add(right_buttons, BorderLayout.EAST); + + getContentPane().add(buttonPanel, BorderLayout.SOUTH); + + setBounds(this.mainControl.getMainView().getX() + (this.mainControl.getMainView().getWidth() - 545) / 2, + this.mainControl.getMainView().getY() + (this.mainControl.getMainView().getHeight() - 480) / 2, + 545, 480); + pack(); + setVisible(true); + } + + /** + * create an "attribute"-line (format: <label> <textfield>) and insert it + * into the given parent layout + * @param parent parent panel where line gets inserted + * @param textField textfield + * @param n lenght of textfield + * @param defaultText initial text in textfield + * @param label (attribute-)label + */ + void createPanelLine(final JPanel parent, final JTextField textField, final int n, + final String defaultText, final String label) { + final JPanel lineLayout = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // layout for this line + lineLayout.add(new JLabel(label)); // create label (attr. name) + //textField = new JTextField(n); // create text field + textField.setColumns(n); + textField.setText(defaultText); // insert default text + lineLayout.add(textField); // add textf. to line + parent.add(lineLayout); // add line to parent layout + } + + /** + * create a checkbox-line and insert it into the given parent layout. + * similar to createPanelLine + * @param parent parent panel where checkbox gets inserted + * @param checkBox checkbox + * @param state initial state + * @param label (attribute-)label + */ + void createPanelCBox(final JPanel parent, final JCheckBox checkBox, + final boolean state, final String label) { + final JPanel lineLayout = new JPanel(new FlowLayout(FlowLayout.CENTER)); // layout for this line + //checkBox = new JCheckBox(label); // create checkbox + checkBox.setText(label); + checkBox.setSelected(state); // set to current state + lineLayout.add(checkBox); // add checkbox to line + parent.add(lineLayout); // add line to parent layout + } + + /** + * Checks the given values and modifies the current level. + * @return true if the level properties were edited, false if the + * parameters were wrong. + */ + private boolean modifyMapProperties() { + final MapArchObject map = m_level.getMapModel().getMapArchObject(); // map arch object + boolean modifyTilepaths = false; // true when map tile-paths were modified + + // tmp variables for parsing + final int width, height; + final int t_enter_x, t_enter_y; + final int t_reset_timeout, t_swap_time; + final int t_difficulty, t_darkness; + final int t_temp, t_pressure, t_humid; + final int t_winds, t_windd, t_sky; + final double t_shopgreed; + final int t_shopmax, t_shopmin; + final String t_shopitems, t_shoprace; + final String t_region; + + // first check if the entries are all okay + try { + // try to parse everything + width = parseProperty(m_levelWidthField.getText(), "Width"); + height = parseProperty(m_levelHeightField.getText(), "Height"); + t_enter_x = parseProperty(m_enterX.getText(), "Enter X"); + t_enter_y = parseProperty(m_enterY.getText(), "Enter Y"); + t_swap_time = parseProperty(m_swapTime.getText(), "Swap Time"); + t_reset_timeout = parseProperty(m_resetTimeout.getText(), "Reset Timeout"); + t_difficulty = parseProperty(m_difficulty.getText(), "Difficulty"); + t_darkness = parseProperty(m_darkness.getText(), "Darkness"); + t_region = m_regionField.getText(); + + t_shopitems = m_shopitems.getText(); + t_shoprace = m_shoprace.getText(); + t_shopmax = parseProperty(m_shopmax.getText(), "Shop Maximum"); + t_shopmin = parseProperty(m_shopmin.getText(), "Shop Minimum"); + t_shopgreed = parsePropertyToDouble(m_shopgreed.getText(), "Shop Greed"); + t_temp = parseProperty(m_temp.getText(), "Temperature"); + t_pressure = parseProperty(m_pressure.getText(), "Pressure"); + t_humid = parseProperty(m_humid.getText(), "Humidity"); + t_winds = parseProperty(m_windspeed.getText(), "Wind Speed"); + t_windd = parseProperty(m_winddir.getText(), "Wind Direction"); + t_sky = parseProperty(m_sky.getText(), "Sky Setting"); + + // Now do some sanity checks: + if (width < 1 || height < 1) { + mainControl.showMessage( + "Illegal Value", + "Level dimensions must be greater than zero."); + return false; + } + if (t_darkness > 5) { + mainControl.showMessage( + "Illegal Value", + "Darkness level must be in range 0-5."); + return false; + } + if (m_nameField.getText().length() == 0) { + mainControl.showMessage( + "missing Map Name", + "You must specify a Map Name."); + return false; + } + } catch (final GridderException e) { + mainControl.showMessage("Invalid Entry", e.getMessage()); + return false; + } + + // if the mapsize has been modified, see if we should ask for a confirm + Size2D size = new Size2D(width, height); + if (!m_level.isCutoffSave(size)) { + if (!askConfirmResize(size)) { + // resizing has been cancelled + size = m_level.getMapSize(); + } + } + + // now that all is well, write the new values into the maparch + mainControl.setLevelProperties(m_level, m_textArea.getText(), m_loreArea.getText(), + m_nameField.getText(), size); + + map.setMapRegion(t_region); + map.setEnterX(t_enter_x); + map.setEnterY(t_enter_y); + map.setResetTimeout(t_reset_timeout); + map.setSwapTime(t_swap_time); + map.setDifficulty(t_difficulty); + map.setDarkness(t_darkness); + map.setUnique(m_unique.isSelected()); + map.setOutdoor(m_outdoor.isSelected()); + map.setFixedReset(m_fixedReset.isSelected()); + map.setNosmooth(m_nosmooth.isSelected()); + + map.setShopItems(t_shopitems); + map.setShopRace(t_shoprace); + map.setShopMin(t_shopmin); + map.setShopMax(t_shopmax); + map.setShopGreed(t_shopgreed); + + map.setTemp(t_temp); + map.setPressure(t_pressure); + map.setHumid(t_humid); + map.setWindspeed(t_winds); + map.setWinddir(t_windd); + map.setSky(t_sky); + + // update tilepaths + for (int i = 0; i < IGUIConstants.DIRECTIONS; i++) { + if ((map.getTilePath(i) == null && (m_tilePath[i].getText() == null || m_tilePath[i].getText().length() == 0)) + || (map.getTilePath(i) != null && !map.getTilePath(i).equals(m_tilePath[i].getText()))) { + modifyTilepaths = true; + } + map.setTilePath(i, m_tilePath[i].getText()); + } + + // refresh menus if tilepaths have been modified + if (modifyTilepaths) { + mainControl.refreshMenus(); + } + + // set flag that map has changed + m_level.setLevelChangedFlag(); + + return true; + } + + /** + * This is a simple string-to-int parser that throws CGridder- instead of + * NumberFormatExceptions, with appropriate errormessage. Used in + * modifyMapProperties(). + * @param s string to be parse + * @param label attribute label for errormessage + * @return value of String 's', zero if 's' is empty + * @throws GridderException when parsing fails + */ + private int parseProperty(final String s, final String label) throws GridderException { + final int r; // return value + + if (s.length() == 0) { + return 0; // empty string is interpreted as zero + } + + try { + r = Integer.parseInt(s); // trying to parse + } catch (final NumberFormatException illegalNumbers) { + // 's' is not a number + throw new GridderException(label + ": '" + s + "' is not a numerical integer value."); + } + + // negative values are not allowed + if (r < 0) { + throw new GridderException(label + ": '" + s + "' is negative."); + } + + return r; // everything okay + } + + /** + * This is a simple string-to-double parser that throws CGridder- instead + * of NumberFormatExceptions, with appropriate errormessage. Used in + * modifyMapProperties(). + * @param s string to be parse + * @param label attribute label for errormessage + * @return value of String 's', zero if 's' is empty + * @throws GridderException when parsing fails + */ + private double parsePropertyToDouble(final String s, final String label) throws GridderException { + final double r; // return value + + if (s.length() == 0) { + return 0; // empty string is interpreted as zero + } + + try { + r = Double.parseDouble(s); // trying to parse + } catch (final NumberFormatException illegalNumbers) { + // 's' is not a number + throw new GridderException(label + ": '" + s + "' is not a numerical double value."); + } + + // negative values are not allowed + if (r < 0) { + throw new GridderException(label + ": '" + s + "' is negative."); + } + + return r; // everything okay + } + + /** Reset all map properties to the saved values in the maparch */ + private void restoreMapProperties() { + final MapArchObject map = m_level.getMapModel().getMapArchObject(); // map arch object + + m_level.getMapModel().getMapArchObject().getText(); + m_textArea.setText(m_level.getMapText()); + m_loreArea.setText(m_level.getMapLore()); + m_nameField.setText(m_level.getMapName()); + m_regionField.setText("" + map.getMapRegion()); + final Size2D mapSize = map.getMapSize(); + m_levelWidthField.setText(String.valueOf(mapSize.getWidth())); + m_levelHeightField.setText(String.valueOf(mapSize.getHeight())); + m_enterX.setText("" + map.getEnterX()); + m_enterY.setText("" + map.getEnterY()); + m_swapTime.setText("" + map.getSwapTime()); + m_resetTimeout.setText("" + map.getResetTimeout()); + m_darkness.setText("" + map.getDarkness()); + m_difficulty.setText("" + map.getDifficulty()); + + m_unique.setSelected(map.isUnique()); + m_outdoor.setSelected(map.isOutdoor()); + m_fixedReset.setSelected(map.isFixedReset()); + m_nosmooth.setSelected(map.isNosmooth()); + + m_shopitems.setText("" + map.getShopItems()); + m_shoprace.setText("" + map.getShopRace()); + m_shopmax.setText("" + map.getShopMax()); + m_shopmin.setText("" + map.getShopMin()); + m_shopgreed.setText("" + map.getShopGreed()); + m_temp.setText("" + map.getTemp()); + m_pressure.setText("" + map.getPressure()); + m_humid.setText("" + map.getHumid()); + m_windspeed.setText("" + map.getWindspeed()); + m_winddir.setText("" + map.getWinddir()); + m_sky.setText("" + map.getSky()); + + for (int i = 0; i < 4; i++) { + m_tilePath[i].setText("" + map.getTilePath(i)); + } + } + + /** + * Open a popup and ask user to confirm his map-resizing selection. This + * popup dialog disables all other windows (and threads). + * @return true if user confirmed, false if user cancelled resize + */ + private boolean askConfirmResize(final Size2D size) { + return JOptionPane.showConfirmDialog(this, + "You selected a new map size of " + size.getWidth() + "x" + size.getHeight() + ". If the map was\n" + + "resized in this way, some objects would get cut off and deleted.\n" + + "Are... [truncated message content] |
From: <aki...@us...> - 2006-12-02 09:42:44
|
Revision: 783 http://svn.sourceforge.net/gridarta/?rev=783&view=rev Author: akirschbaum Date: 2006-12-02 01:42:45 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Add "permanent experience" attribute for SKILL objects. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/conf/types.xml Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-02 09:41:20 UTC (rev 782) +++ trunk/crossfire/ChangeLog 2006-12-02 09:42:45 UTC (rev 783) @@ -1,3 +1,7 @@ +2006-12-02 Andreas Kirschbaum + + * Add "permanent experience" attribute for SKILL objects. + 2006-11-30 Andreas Kirschbaum * Update archetypes, images and treasurelists. Modified: trunk/crossfire/resource/conf/types.xml =================================================================== --- trunk/crossfire/resource/conf/types.xml 2006-12-02 09:41:20 UTC (rev 782) +++ trunk/crossfire/resource/conf/types.xml 2006-12-02 09:42:45 UTC (rev 783) @@ -4276,6 +4276,11 @@ </attribute> <attribute arch="exp" editor="experience" type="int"> </attribute> + <attribute arch="perm_exp" editor="permanent experience" type="long"> + <Permanent experience> is the experience the player gained + permanently. Even if a player dies multiple times or gets drained, his + <experience> will not fall below <permanent experience>. + </attribute> <attribute arch="can_use_skill" editor="is native skill" type="bool"> The <is native skill> flag has an effect only when this skill object is placed in the inventory of a monster (or player). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-02 09:41:20
|
Revision: 782 http://svn.sourceforge.net/gridarta/?rev=782&view=rev Author: akirschbaum Date: 2006-12-02 01:41:20 -0800 (Sat, 02 Dec 2006) Log Message: ----------- Implement 'long' attribute type for game object attibutes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-01 23:57:05 UTC (rev 781) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-02 09:41:20 UTC (rev 782) @@ -623,6 +623,7 @@ } break; case INT: + case LONG: case FLOAT: { cLabel = new JLabel(type.getAttr()[i].getNameNew() + ": "); cLabel.setForeground(dType == ArchAttribType.FLOAT ? IGUIConstants.FLOAT_COLOR : IGUIConstants.INT_COLOR); @@ -631,6 +632,7 @@ final NumberFormat format; switch (dType) { case INT: + case LONG: format = NumberFormat.getIntegerInstance(); break; case FLOAT: @@ -651,6 +653,9 @@ case INT: value = gameObject.getAttributeInt(nameOld, true); break; + case LONG: + value = gameObject.getAttributeLong(nameOld, true); + break; case FLOAT: value = gameObject.getAttributeDouble(nameOld, true); break; @@ -912,6 +917,7 @@ } break; case INT: + case LONG: case FLOAT: { final String value = ((DialogAttrib<JFormattedTextField>) attr).input.getText(); // the attrib value if (value != null && value.length() > 0 && !value.equals("0")) { @@ -1017,12 +1023,17 @@ } break; case INT: + case LONG: case FLOAT: { // an int attribute if (dType == ArchAttribType.INT && ((DialogAttrib<JFormattedTextField>) attr).input.getText().trim().length() == 0) { if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { newArchText = newArchText + attr.ref.getNameOld() + " 0\n"; } + } else if (dType == ArchAttribType.LONG && ((DialogAttrib<JFormattedTextField>) attr).input.getText().trim().length() == 0) { + if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { + newArchText = newArchText + attr.ref.getNameOld() + " 0\n"; + } } else if (dType == ArchAttribType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).input.getText().trim().length() == 0) { if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { newArchText = newArchText + attr.ref.getNameOld() + " 0.0\n"; @@ -1037,6 +1048,13 @@ } } break; + case LONG: { + final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).input.getValue()).longValue(); + if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { + newArchText = newArchText + attr.ref.getNameOld() + ' ' + value + '\n'; + } + } + break; case FLOAT: { final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).input.getValue()).doubleValue(); final String defValueStr = archetype.getAttributeString(attr.ref.getNameOld()).trim(); Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-01 23:57:05 UTC (rev 781) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-02 09:41:20 UTC (rev 782) @@ -150,6 +150,8 @@ misc[1] = a2.getValue().trim(); // string for false } else if (atype.equalsIgnoreCase("int")) { dataType = ArchAttribType.INT; + } else if (atype.equalsIgnoreCase("long")) { + dataType = ArchAttribType.LONG; } else if (atype.equalsIgnoreCase("float")) { dataType = ArchAttribType.FLOAT; } else if (atype.equalsIgnoreCase("string")) { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java 2006-12-01 23:57:05 UTC (rev 781) +++ trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java 2006-12-02 09:41:20 UTC (rev 782) @@ -36,6 +36,9 @@ /** Integer -> Textfield. */ INT, + /** Long -> Textfield. */ + LONG, + /** Float -> Textfield. */ FLOAT, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:57:07
|
Revision: 781 http://svn.sourceforge.net/gridarta/?rev=781&view=rev Author: akirschbaum Date: 2006-12-01 15:57:05 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify whitespace. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-01 23:57:05 UTC (rev 781) @@ -208,7 +208,6 @@ } else if (atype.startsWith("list")) { // got a bitmask attribute final String listName = atype.substring(5).trim(); - if (tlist.getListTable().containsKey(listName)) { // the list is well defined dataType = ArchAttribType.LIST; Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-01 23:57:05 UTC (rev 781) @@ -294,7 +294,6 @@ // 'realNode' is the real instance of that treasurelist final TreasureTreeNode realNode = treasureTable.get(node.getTreasureObj().getName()); - if (realNode != null) { // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); @@ -314,7 +313,6 @@ // 'realNode' is the real instance of that treasurelist final TreasureTreeNode realNode = treasureTable.get(node.getTreasureObj().getName()); - if (realNode != null) { // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 23:57:05 UTC (rev 781) @@ -226,6 +226,7 @@ // Initialise the main view mainView.init(doShow); loadDefTiles(); + if (autoPopupDocu) { // do an automated help popup because the docu version has increased // (people won't notice the docu otherwise - nobody expects a docu in opensource) @@ -243,6 +244,7 @@ // load the list with archtype-data from "types.txt" typeList = new CFArchTypeList(); + GameObject.setTypeList(typeList); // set reference in GameObject // now collect all arch you can find in the arch path!! @@ -954,6 +956,7 @@ */ boolean collectTempList(final List<GameObject> objects, final File file) { final List<GameObject> tailList = new ArrayList<GameObject>(); + // first: attach our map sucker to a default arch we have loaded for (final Iterator<GameObject> it = objects.iterator(); it.hasNext();) { final GameObject gameObject = it.next(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-01 23:57:05 UTC (rev 781) @@ -599,7 +599,6 @@ /** Gives focus to the next window. */ public void previousWindowWanted() { - if (mapViews.size() > 1) { final MapViewIFrame view = mapViews.get(0); mapViews.remove(view); @@ -610,13 +609,11 @@ /** Gives focus to the previous window. */ public void nextWindowWanted() { - if (mapViews.size() > 1) { final MapViewIFrame view = mapViews.get(mapViews.size() - 1); mapViews.remove(view); mapViews.add(0, view); } - updateFocus(false); } @@ -665,7 +662,6 @@ final MapControl level = view.getLevel(); mainControl.setCurrentLevel(level); //statusBar.setLevelInfo(level); - } /** @@ -680,10 +676,8 @@ * @param e the occurred <code>InternalFrameEvent</code> */ public void internalFrameClosing(final InternalFrameEvent e) { - final MapViewIFrame view = (MapViewIFrame) e.getSource(); removeLevelView(view); - } /** Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-01 23:57:05 UTC (rev 781) @@ -220,11 +220,13 @@ log.warn("Nullpointer in getListCategoryArray()!", e); } } + return catList; } void showArchList() { final int index = jbox.getSelectedIndex(); + model.removeAllElements(); for (PanelEntry p : archList) { if (index >= 0) { @@ -290,6 +292,7 @@ setIcon(icon); } } + return this; } Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-01 23:57:05 UTC (rev 781) @@ -271,7 +271,6 @@ for (final TreasureTreeNode node : needSecondLink) { // 'realNode' is the real instance of that treasurelist final TreasureTreeNode realNode = treasureTable.get(node.getTreasureObj().getName()); - if (realNode != null) { // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-01 23:57:05 UTC (rev 781) @@ -637,6 +637,7 @@ for (final MapControl level : levels) { level.addEditType(newType); // calculate new type } + setTileEdit(newType); // activate the new type for all views } @@ -1161,7 +1162,6 @@ } } - /** * Load a mapfile and create a view. * @param file mapfile Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-01 23:57:05 UTC (rev 781) @@ -606,7 +606,6 @@ mapViews.add(view); updateFocus(true); } - } /** @@ -621,7 +620,6 @@ level.setFocus(view); mainControl.setCurrentLevel(level); //statusBar.setLevelInfo(level); - } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-01 23:57:05 UTC (rev 781) @@ -181,6 +181,7 @@ } } } + for (final GameObject gameObject : gameObjectsToDelete) { gameObject.remove(); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-01 23:57:05 UTC (rev 781) @@ -286,6 +286,7 @@ /** Load all arches and pngs from the collected files "archtypes" and "daimonin.0" */ private void loadArchFromCollected() { setLoadedFromArchive(true); // load from the collected files + try { mainControl.getAnimationObjects().loadAnimTree( new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)); Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-01 23:39:02 UTC (rev 780) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-01 23:57:05 UTC (rev 781) @@ -122,6 +122,7 @@ } } } + return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:39:01
|
Revision: 780 http://svn.sourceforge.net/gridarta/?rev=780&view=rev Author: akirschbaum Date: 2006-12-01 15:39:02 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify comment. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 23:35:51 UTC (rev 779) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 23:39:02 UTC (rev 780) @@ -340,7 +340,7 @@ /** * A new edit type was selected from the view menu. Now - * we activate the new type and calculate it for each arch on + * we activate the new type and calculate it for each GameObject on * each map where this type has not yet been used. * @param newType new selected edit type (should not be more than one) */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:35:51
|
Revision: 779 http://svn.sourceforge.net/gridarta/?rev=779&view=rev Author: akirschbaum Date: 2006-12-01 15:35:51 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Replace Vector with List. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 23:27:43 UTC (rev 778) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 23:35:51 UTC (rev 779) @@ -41,10 +41,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Iterator; import java.util.List; -import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; @@ -139,7 +137,7 @@ private final ArchetypeSet archetypeSet; // the one and only arch list /** All open maps. */ - private final Vector<MapControl> levels = new Vector<MapControl>(1, 2); + private final List<MapControl> levels = new ArrayList<MapControl>(); /** The current top map we are working with */ private MapControl currentMap; @@ -348,9 +346,7 @@ */ void selectEditType(final int newType) { // calculate the new type for all opened maps: - for (Enumeration<MapControl> enu = levels.elements(); enu.hasMoreElements();) { - final MapControl level = enu.nextElement(); - + for (final MapControl level : levels) { level.addEditType(newType); // calculate new type } @@ -582,8 +578,7 @@ // update the look and feel for all open map views if (levels.size() > 0) { - for (final Enumeration<MapControl> enu = levels.elements(); enu.hasMoreElements();) { - final MapControl level = enu.nextElement(); + for (final MapControl level : levels) { level.getMapViewFrame().updateLookAndFeel(); if (log.isDebugEnabled()) { log.debug("map " + level.getMapName()); @@ -661,7 +656,7 @@ if (show) { mainView.addLevelView(map.getMapViewFrame()); // one view... map.getMapViewFrame().setAutoscrolls(true); - levels.addElement(map); + levels.add(map); setCurrentLevel(map); refreshMenusAndToolbars(); } @@ -753,14 +748,12 @@ mainView.setMapTileList(null, -1); level.levelCloseNotify(); mainView.removeLevelView(level.getMapViewFrame()); - levels.removeElement(level); + levels.remove(level); currentMap = null; if (levels.size() > 0) { // get next open map we can find and set it to currentMap - for (final Enumeration<MapControl> enu = levels.elements(); enu.hasMoreElements();) { - currentMap = enu.nextElement(); - } + currentMap = levels.get(levels.size() - 1); } } refreshMenusAndToolbars(); @@ -1218,8 +1211,7 @@ /** Invoked when user wants to exit from the program. */ void exitWanted() { if (levels.size() > 0) { - for (final Enumeration<MapControl> enu = levels.elements(); enu.hasMoreElements();) { - final MapControl level = enu.nextElement(); + for (final MapControl level : levels) { closeLevel(level, false); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:27:44
|
Revision: 778 http://svn.sourceforge.net/gridarta/?rev=778&view=rev Author: akirschbaum Date: 2006-12-01 15:27:43 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Replace Vector with List. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-01 23:19:59 UTC (rev 777) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-01 23:27:43 UTC (rev 778) @@ -34,9 +34,10 @@ import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; -import java.util.Vector; +import java.util.List; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -87,7 +88,7 @@ // all syntax-errors encountered during datafile-parsing get written in this log private final StringBuffer errorLog = new StringBuffer(); - private Vector<TreasureTreeNode> needSecondLink; + private List<TreasureTreeNode> needSecondLink; private boolean processSecondLinking; @@ -129,7 +130,7 @@ // draw thin blue lines connecting the nodes putClientProperty("JTree.lineStyle", "Angled"); - needSecondLink = new Vector<TreasureTreeNode>(); + needSecondLink = new ArrayList<TreasureTreeNode>(); processSecondLinking = false; // set special cell renderer @@ -230,8 +231,8 @@ * has been parsed. False when there is no data and tree remains empty. */ private boolean parseTreasures() { - final Vector<TreasureTreeNode> tmpList = new Vector<TreasureTreeNode>(); // tmp. container for all treasurelists - final Vector<TreasureTreeNode> needLink = new Vector<TreasureTreeNode>(); // all sub-treasurelist nodes that need linking + final List<TreasureTreeNode> tmpList = new ArrayList<TreasureTreeNode>(); // tmp. container for all treasurelists + final List<TreasureTreeNode> needLink = new ArrayList<TreasureTreeNode>(); // all sub-treasurelist nodes that need linking treasureTable = new Hashtable<String, TreasureTreeNode>(); // hashtable for all treasureTreeNodes // first step: parsing datafile, adding all treasurelists to the tmpList vector @@ -248,7 +249,7 @@ if (line.startsWith("treasure") && (i = line.indexOf(" ")) != -1) { // start of a new treasure section node = new TreasureTreeNode(line.substring(i).trim(), line.startsWith("treasureone") ? TreasureObj.TREASUREONE_LIST : TreasureObj.TREASURE_LIST); - tmpList.addElement(node); // put this node to tmplist vector + tmpList.add(node); // put this node to tmplist vector treasureTable.put(node.getTreasureObj().getName(), node); // put it into hashtable tListCount++; @@ -273,7 +274,7 @@ // Loop through all treasureone lists and calculate the real ratio // of chances (Summed up to be 100%). Also attach lists to tree model. for (int i = 0; i < tmpList.size(); i++) { - final TreasureTreeNode realNode = tmpList.elementAt(i); + final TreasureTreeNode realNode = tmpList.get(i); if (realNode.getTreasureObj().getType() == TreasureObj.TREASUREONE_LIST) { recalculateChances(realNode); } @@ -289,7 +290,7 @@ // link the sub-lists first time for (int i = 0; i < needLink.size(); i++) { // 'node' is a sub-treasurelist which needs to be linked to it's content - final TreasureTreeNode node = needLink.elementAt(i); + final TreasureTreeNode node = needLink.get(i); // 'realNode' is the real instance of that treasurelist final TreasureTreeNode realNode = treasureTable.get(node.getTreasureObj().getName()); @@ -309,7 +310,7 @@ final int x = needSecondLink.size(); for (int i = 0; i < x; i++) { // 'node' is a sub-treasurelist which needs to be linked to it's content - final TreasureTreeNode node = needSecondLink.elementAt(i); + final TreasureTreeNode node = needSecondLink.get(i); // 'realNode' is the real instance of that treasurelist final TreasureTreeNode realNode = treasureTable.get(node.getTreasureObj().getName()); @@ -372,16 +373,16 @@ * Sort the TreasureObjects in the given vector in alphabetical order. * Names of the TreasureObjects get compared. The used sorting strategy * is bubblesort because the expected number of objects is low (~300). - * @param v Vector to be sorted + * @param v List to be sorted */ - private void sortVector(final Vector<TreasureTreeNode> v) { + private void sortVector(final List<TreasureTreeNode> v) { for (int j = 0; j < v.size() + 1; j++) { for (int i = 0; i < v.size() - 1; i++) { - if (v.elementAt(i).getTreasureObj().getName().compareToIgnoreCase( - v.elementAt(i + 1).getTreasureObj().getName()) > 0) { - final TreasureTreeNode node = v.elementAt(i); - v.setElementAt(v.elementAt(i + 1), i); - v.setElementAt(node, i + 1); + if (v.get(i).getTreasureObj().getName().compareToIgnoreCase( + v.get(i + 1).getTreasureObj().getName()) > 0) { + final TreasureTreeNode node = v.get(i); + v.set(i, v.get(i + 1)); + v.set(i + 1, node); } } } @@ -390,9 +391,9 @@ /** * Read and parse the text inside a treasurelist * @param parentNode parent treenode - * @param needLink vector containing all sub-treasurelist nodes which need linking + * @param needLink List containing all sub-treasurelist nodes which need linking */ - private void readInsideList(final TreasureTreeNode parentNode, final BufferedReader reader, final Vector<TreasureTreeNode> needLink) throws IOException { + private void readInsideList(final TreasureTreeNode parentNode, final BufferedReader reader, final List<TreasureTreeNode> needLink) throws IOException { String line; // read line of file TreasureTreeNode node = null; // tmp. treenode This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:19:59
|
Revision: 777 http://svn.sourceforge.net/gridarta/?rev=777&view=rev Author: akirschbaum Date: 2006-12-01 15:19:59 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify comments. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CFArchTypeList.java Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-01 23:09:48 UTC (rev 776) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-01 23:19:59 UTC (rev 777) @@ -64,9 +64,9 @@ private int[] spellNum; // array of spell numbers - private Map<String, CAttribBitmask> bitmaskTable; // table with CAttribBitmask objects (value) sorted by name (key) + private final Map<String, CAttribBitmask> bitmaskTable; // table with CAttribBitmask objects (value) sorted by name (key) - private Map<String, List<?>> listTable; // table with List objects for lists (value) sorted by name (key) + private final Map<String, List<?>> listTable; // table with List objects for lists (value) sorted by name (key) private Map<String, List<String>> ignoreListTable; // table with List objects for ignore_lists (value) sorted by name (key) Modified: trunk/daimonin/src/daieditor/CFArchTypeList.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-01 23:09:48 UTC (rev 776) +++ trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-01 23:19:59 UTC (rev 777) @@ -87,12 +87,12 @@ private final List<CFArchType> archTypeList = new ArrayList<CFArchType>(); // All but the default ArchType // spell info: - private final Map<String, CAttribBitmask> bitmaskTable; // table with CAttrBitmask objects (value) sorted by name (key) + private final Map<String, CAttribBitmask> bitmaskTable; // table with CAttribBitmask objects (value) sorted by name (key) // TODO: Find value type of List - private final Map<String, List<?>> listTable; // table with List objects for lists (value) sorted by name (key) + private final Map<String, List<?>> listTable; // table with List objects for lists (value) sorted by name (key) - private Map<String, List<String>> ignoreListTable; // table with List objects for ignore_lists (value) sorted by name (key) + private Map<String, List<String>> ignoreListTable; // table with List objects for ignore_lists (value) sorted by name (key) /** * Check whether the GameObject is an exit. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:09:48
|
Revision: 776 http://svn.sourceforge.net/gridarta/?rev=776&view=rev Author: akirschbaum Date: 2006-12-01 15:09:48 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify comment. Modified Paths: -------------- trunk/daimonin/src/daieditor/CFJavaEditor.java Modified: trunk/daimonin/src/daieditor/CFJavaEditor.java =================================================================== --- trunk/daimonin/src/daieditor/CFJavaEditor.java 2006-12-01 23:07:38 UTC (rev 775) +++ trunk/daimonin/src/daieditor/CFJavaEditor.java 2006-12-01 23:09:48 UTC (rev 776) @@ -44,7 +44,7 @@ private static final Logger log = Logger.getLogger(CFJavaEditor.class); - /** Private UtilityClass constructor . */ + /** Prevent instantiation. */ private CFJavaEditor() { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:07:41
|
Revision: 775 http://svn.sourceforge.net/gridarta/?rev=775&view=rev Author: akirschbaum Date: 2006-12-01 15:07:38 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify field initialization. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchType.java trunk/daimonin/src/daieditor/CFArchType.java Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 23:04:08 UTC (rev 774) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 23:07:38 UTC (rev 775) @@ -69,21 +69,21 @@ /** Section Element Name. */ public static final String XML_SECTION = "section"; - private int typenr; // type number of this CF type + private int typenr = 0; // type number of this CF type private String typeName; // type name (artificial) - private String[] typeAttributes; // list of aditional attributes that an object + private String[] typeAttributes = null; // list of aditional attributes that an object // must have, in order to be of this type: // typeAttributes[0] is attr. name, typeAttributes[1] is attr. value, ... private final CFArchType defaultArchType; // contains default attributes - private CFArchType next; // next CFArchType in the list + private CFArchType next = null; // next CFArchType in the list - private String desc; // descrption of this type + private String desc = null; // descrption of this type - private String use; // notes on usage of this type + private String use = null; // notes on usage of this type private CFArchAttrib[] attr; // list of arch attributes (/array)) @@ -98,12 +98,7 @@ * @param defaultArchType default archetype */ public CFArchType(final CFArchType defaultArchType) { - next = null; - desc = null; - use = null; - typenr = 0; typeName = ""; - typeAttributes = null; sectionNum = 2; // there's always the "general" and "special" sections (even if empty) this.defaultArchType = defaultArchType; // set head of list } Modified: trunk/daimonin/src/daieditor/CFArchType.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchType.java 2006-12-01 23:04:08 UTC (rev 774) +++ trunk/daimonin/src/daieditor/CFArchType.java 2006-12-01 23:07:38 UTC (rev 775) @@ -72,19 +72,19 @@ /** Section Element Name. */ public static final String XML_SECTION = "section"; - private int typenr; // type number of this CF type + private int typenr = 0; // type number of this CF type private String typeName; // type name (artificial) - private String[] typeAttributes; // list of aditional attributes that an object + private String[] typeAttributes = null; // list of aditional attributes that an object // must have, in order to be of this type: // typeAttributes[0] is attr. name, typeAttributes[1] is attr. value, ... private final CFArchType defaultArchType; // contains default attributes - private String desc; // descrption of this type + private String desc = null; // descrption of this type - private String use; // notes on usage of this type + private String use = null; // notes on usage of this type private CFArchAttrib[] attr; // list of arch attributes (/array)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:04:11
|
Revision: 774 http://svn.sourceforge.net/gridarta/?rev=774&view=rev Author: akirschbaum Date: 2006-12-01 15:04:08 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchType.java Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 23:02:25 UTC (rev 773) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 23:04:08 UTC (rev 774) @@ -69,9 +69,6 @@ /** Section Element Name. */ public static final String XML_SECTION = "section"; - /** File with type definitions. */ - public static final String filename = IGUIConstants.TYPEDEF_FILE; - private int typenr; // type number of this CF type private String typeName; // type name (artificial) @@ -334,7 +331,7 @@ } } } else { - log.error("Syntax Error in file '" + filename + "' (" + typeName + "):"); + log.error("Syntax Error in file '" + IGUIConstants.TYPEDEF_FILE + "' (" + typeName + "):"); log.error(" import type \"" + importName + "\" not found!"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:02:24
|
Revision: 773 http://svn.sourceforge.net/gridarta/?rev=773&view=rev Author: akirschbaum Date: 2006-12-01 15:02:25 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Make type parameter more specific. Modified Paths: -------------- trunk/daimonin/src/daieditor/CFArchType.java Modified: trunk/daimonin/src/daieditor/CFArchType.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchType.java 2006-12-01 23:00:36 UTC (rev 772) +++ trunk/daimonin/src/daieditor/CFArchType.java 2006-12-01 23:02:25 UTC (rev 773) @@ -119,7 +119,7 @@ // for internal section handling: final List<String> secNames = new ArrayList<String>(); // list of section names - final Map<Object, String> ignoreTable = new HashMap<Object, String>(); // ignore list + final Map<String, String> ignoreTable = new HashMap<String, String>(); // ignore list if ("default_type".equalsIgnoreCase(root.getNodeName())) { // special case: default type (this one contains the default attribs) @@ -187,7 +187,7 @@ } else if (tlist.getIgnoreListTable().containsKey(a1.getValue().trim())) { // just copy everything from ignorelist to this ignore section final List<? extends String> ignlist = tlist.getIgnoreListTable().get(a1.getValue().trim()); - for (final Object aIgnlist : ignlist) { + for (final String aIgnlist : ignlist) { ignoreTable.put(aIgnlist, ""); } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 23:00:39
|
Revision: 772 http://svn.sourceforge.net/gridarta/?rev=772&view=rev Author: akirschbaum Date: 2006-12-01 15:00:36 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Replace Hashtable with HashMap. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchType.java Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 22:57:27 UTC (rev 771) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 23:00:36 UTC (rev 772) @@ -26,8 +26,9 @@ import cfeditor.gameobject.ArchAttribType; import java.util.ArrayList; -import java.util.Hashtable; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; import org.jdom.Attribute; import org.jdom.Element; @@ -124,7 +125,7 @@ // for internal section handling: final List<String> secNames = new ArrayList<String>(); // list of section names - final Hashtable<String, String> ignoreTable = new Hashtable<String, String>(); // ignore list + final Map<String, String> ignoreTable = new HashMap<String, String>(); // ignore list List<Element> children; // list of children elements Element elem; // xml element This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:57:28
|
Revision: 771 http://svn.sourceforge.net/gridarta/?rev=771&view=rev Author: akirschbaum Date: 2006-12-01 14:57:27 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Remove unused variable. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-01 22:56:24 UTC (rev 770) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-01 22:57:27 UTC (rev 771) @@ -143,8 +143,6 @@ /** The Button for toggling the summary. */ private JButton summaryEditButton; - private JButton applyButton; - /** The Button for cancel. */ private JButton cancelButton; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:56:26
|
Revision: 770 http://svn.sourceforge.net/gridarta/?rev=770&view=rev Author: akirschbaum Date: 2006-12-01 14:56:24 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Replace Vector with List. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchType.java trunk/crossfire/src/cfeditor/CFArchTypeList.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-01 22:32:20 UTC (rev 769) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-01 22:56:24 UTC (rev 770) @@ -51,7 +51,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Vector; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.BorderFactory; @@ -371,18 +370,18 @@ /** * Construct the Combo box for arrays of "list data" (this is used for ArchAttribType.LIST). * @param attr list attribute - * @param listData Vector with list items and corresponding values + * @param listData List with list items and corresponding values, that means the types are altering: String,Integer * @return the completed <code>JComboBox</code> */ - private JComboBox buildArrayBox(final CFArchAttrib attr, final Vector listData) { + private JComboBox buildArrayBox(final CFArchAttrib attr, final List<?> listData) { // build the array of list-items final String []array = new String[(int) (listData.size() / 2.)]; boolean hasSelection = false; int active = gameObject.getAttributeInt(attr.getNameOld()); for (int i = 0; i < array.length; i++) { - array[i] = (String) listData.elementAt(i * 2 + 1); // put string to array - if (!hasSelection && ((Integer) listData.elementAt(i * 2)).intValue() == active) { + array[i] = (String) listData.get(i * 2 + 1); // put string to array + if (!hasSelection && ((Integer) listData.get(i * 2)).intValue() == active) { hasSelection = true; // the selection is valid active = i; // set selection to this index in the array } @@ -718,7 +717,7 @@ case LIST: if (type.getAttr()[i].getMisc() != null && typelist.getListTable().containsKey((String) (type.getAttr()[i].getMisc()[0]))) { // build the list from vector data - input = buildArrayBox(type.getAttr()[i], (Vector) (typelist.getListTable().get((String) (type.getAttr()[i].getMisc()[0])))); + input = buildArrayBox(type.getAttr()[i], typelist.getListTable().get((String) (type.getAttr()[i].getMisc()[0]))); } else { // error: list data is missing or corrupt cComp = new JLabel("Error: Undefined List"); @@ -1120,7 +1119,7 @@ // get selected index of ComboBox final int attrValTmp = ((JComboBox) attr.input).getSelectedIndex(); // fetch value according to this list entry: - attrVal = (Integer) ((Vector) (typelist.getListTable().get(attr.ref.getMisc()[0]))).elementAt(2 * attrValTmp); + attrVal = (Integer) (typelist.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); break; default: assert false; Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 22:32:20 UTC (rev 769) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-01 22:56:24 UTC (rev 770) @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import java.util.Vector; import org.apache.log4j.Logger; import org.jdom.Attribute; import org.jdom.Element; @@ -121,10 +120,10 @@ */ public boolean load(final Element root, final CFArchTypeList tlist) { // this vector is used to store a temporare linked list of attributes - final Vector<CFArchAttrib> attrList = new Vector<CFArchAttrib>(); + final List<CFArchAttrib> attrList = new ArrayList<CFArchAttrib>(); // for internal section handling: - final Vector<String> secNames = new Vector<String>(); // list of section names + final List<String> secNames = new ArrayList<String>(); // list of section names final Hashtable<String, String> ignoreTable = new Hashtable<String, String>(); // ignore list List<Element> children; // list of children elements @@ -203,9 +202,9 @@ log.error("In '" + XML_IGNORE + "' section of type " + typeName + ": ignore_list missing 'name'."); } else if (tlist.getIgnoreListTable().containsKey(a1.getValue().trim())) { // just copy everything from ignorelist to this ignore section - final Vector<String> ignlist = tlist.getIgnoreListTable().get(a1.getValue().trim()); + final List<String> ignlist = tlist.getIgnoreListTable().get(a1.getValue().trim()); for (int k = 0; k < ignlist.size(); k++) { - ignoreTable.put(ignlist.elementAt(k), ""); + ignoreTable.put(ignlist.get(k), ""); } } else { log.error("In '" + XML_IGNORE + "' section of type " + typeName + ": ignore_list with name \"" + a1.getValue() + "\" is undefined."); @@ -318,7 +317,7 @@ !impType.attr[z].getSecName().equalsIgnoreCase("special") && !secNames.contains(impType.attr[z].getSecName())) { sectionNum++; // increment number of valid sections - secNames.addElement(impType.attr[z].getSecName()); + secNames.add(impType.attr[z].getSecName()); } importList[importNum] = impType.attr[z].getClone(); @@ -362,7 +361,7 @@ // put the list of the (non-default) CFArchAttribs into an array: for (int i = 0; numDef < j && i < attrList.size(); numDef++, i++) { - attr[numDef] = attrList.elementAt(i); + attr[numDef] = attrList.get(i); } return true; // archtype was parsed correctly @@ -379,7 +378,7 @@ * @param attrList linked list of attributes * @param tlist arch type list */ - private void parseAttribute(final Element elem, final Vector<String> secNames, final boolean inSection, final String section, final Vector<CFArchAttrib> attrList, final CFArchTypeList tlist) { + private void parseAttribute(final Element elem, final List<String> secNames, final boolean inSection, final String section, final List<CFArchAttrib> attrList, final CFArchTypeList tlist) { // create new instance final CFArchAttrib attrib = new CFArchAttrib(); Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-01 22:32:20 UTC (rev 769) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-01 22:56:24 UTC (rev 770) @@ -33,10 +33,10 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Vector; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.io.IOUtils; @@ -66,9 +66,9 @@ private Map<String, CAttribBitmask> bitmaskTable; // table with CAttribBitmask objects (value) sorted by name (key) - private Map<String, Vector> listTable; // table with Vector objects for lists (value) sorted by name (key) + private Map<String, List<?>> listTable; // table with List objects for lists (value) sorted by name (key) - private Map<String, Vector<String>> ignoreListTable; // table with Vector objects for ignore_lists (value) sorted by name (key) + private Map<String, List<String>> ignoreListTable; // table with List objects for ignore_lists (value) sorted by name (key) private int length = 0; // Number of types in the list @@ -80,8 +80,8 @@ CFArchType cfType = head; // index of CFArchType list // initialize the arrays of "special-data" bitmaskTable = new HashMap<String, CAttribBitmask>(); - listTable = new HashMap<String, Vector>(); - ignoreListTable = new HashMap<String, Vector<String>>(); + listTable = new HashMap<String, List<?>>(); + ignoreListTable = new HashMap<String, List<String>>(); loadSpellsFromXML(); // load spells from file @@ -122,7 +122,7 @@ if (elem.getAttribute("name") == null) { log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); } else { - final Vector list = parseListFromElement(elem); + final List<?> list = parseListFromElement(elem); if (list != null && list.size() > 0) { listTable.put(elem.getAttribute("name").getValue(), list); } @@ -156,11 +156,11 @@ final List<Element> children2 = elem.getChildren(CFArchType.XML_ATTRIBUTE); if (children2 != null && children2.size() > 0) { // load all attribute entries - final Vector<String> content = new Vector<String>(); + final List<String> content = new ArrayList<String>(); for (int k = 0; k < children2.size(); k++) { elem = children2.get(k); if ((a = elem.getAttribute(CFArchAttrib.XML_KEY_ARCH)) != null) { - content.addElement(a.getValue().trim()); + content.add(a.getValue().trim()); } else { log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': ignore_list '" + lname + "' has " + CFArchType.XML_ATTRIBUTE + " missing '" + CFArchAttrib.XML_KEY_ARCH + "'."); } @@ -211,8 +211,8 @@ * Parse a list vector from an xml list element. * @param root element to parse */ - private Vector parseListFromElement(final Element root) { - final Vector list = new Vector(); // list vector + private List<?> parseListFromElement(final Element root) { + final List<Object> list = new ArrayList<Object>(); int num; // number for list element Element elem; @@ -225,8 +225,8 @@ // every list entry adds value (Integer) and name (String) to the vector try { num = elem.getAttribute("value").getIntValue(); - list.addElement(new Integer(num)); - list.addElement(" " + elem.getAttribute("name").getValue().trim()); + list.add(new Integer(num)); + list.add(" " + elem.getAttribute("name").getValue().trim()); } catch (final DataConversionException e) { log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name").getValue() + ": value '" + elem.getAttribute("value").getValue() + "' is not an integer."); } @@ -268,7 +268,7 @@ return bitmaskTable; } - public Map<String, Vector> getListTable() { + public Map<String, List<?>> getListTable() { return listTable; } @@ -276,7 +276,7 @@ * Return the ignore list table which contains all definitions of ignore lists for arch attributes. * @return ignore list table */ - public Map<String, Vector<String>> getIgnoreListTable() { + public Map<String, List<String>> getIgnoreListTable() { return ignoreListTable; } @@ -397,14 +397,14 @@ * @return number of successfully collected spells */ private int importSpells(final File spellfile) { - Vector<String> list = null; // growable array of spellnames+numbers + List<String> list = null; // growable array of spellnames+numbers String tmp; // tmp String for spell names final FileWriter fileWriter; // file writer for "spells.def" final BufferedWriter bufferedWriter; // buffered writer if (spellfile.getName().equalsIgnoreCase("spellist.h")) { - list = new Vector<String>(); + list = new ArrayList<String>(); FileReader fileReader = null; BufferedReader bufferedReader = null; @@ -427,12 +427,12 @@ name = name.trim(); // now insert this string lexographically into the vector for (i = 0; i < list.size(); i++) { - tmp = list.elementAt(i); + tmp = list.get(i); tmp = tmp.substring(tmp.indexOf(" ") + 1); if (name.compareTo(tmp) < 0) { // everything okay, now insert - list.insertElementAt((counter + " " + name), i); + list.add(i, counter + " " + name); i = list.size() + 10; // end for } else if (name.compareTo(tmp) == 0) { // this spell already exist in the list @@ -443,7 +443,7 @@ // if no insertion spot found, add to end of list if (i < list.size() + 10) { - list.insertElementAt((counter + " " + name), list.size()); + list.add(counter + " " + name); } } } catch (final FileNotFoundException e) { @@ -493,7 +493,7 @@ // write spell-entries: for (int i = 0; i < list.size(); i++) { - tmp = String.valueOf(list.elementAt(i)); + tmp = String.valueOf(list.get(i)); final String id = tmp.substring(0, tmp.indexOf(" ")).trim(); final String name = tmp.substring(tmp.indexOf(" ") + 1).trim(); String space = ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:32:20
|
Revision: 769 http://svn.sourceforge.net/gridarta/?rev=769&view=rev Author: akirschbaum Date: 2006-12-01 14:32:20 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify transient modifier. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanel.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-01 22:28:44 UTC (rev 768) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-01 22:32:20 UTC (rev 769) @@ -52,7 +52,7 @@ private static final long serialVersionUID = 1L; /** Controller of this subview. */ - private final CMainControl mainControl; + private final transient CMainControl mainControl; /** The "Import..." button. */ Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-01 22:28:44 UTC (rev 768) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-01 22:32:20 UTC (rev 769) @@ -89,7 +89,7 @@ private int lastClickId = -1; /** The currently selected MapSquare. */ - private Point currentSquare = null; + private transient Point currentSquare = null; /** Build Panel */ CMapTileList(final CMainControl mainControl, final CMainView mainView) { Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-01 22:28:44 UTC (rev 768) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-01 22:32:20 UTC (rev 769) @@ -57,7 +57,7 @@ * The CMainControl used for various operations. * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link CMainControl}. */ - @Deprecated private final CMainControl mainControl; + @Deprecated private final transient CMainControl mainControl; /** * The MapControl that controls this MapModel. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:28:44
|
Revision: 768 http://svn.sourceforge.net/gridarta/?rev=768&view=rev Author: akirschbaum Date: 2006-12-01 14:28:44 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Rename variables/methods. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 22:06:28 UTC (rev 767) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-01 22:28:44 UTC (rev 768) @@ -606,9 +606,9 @@ return currentMap.getMapViewFrame().isGridVisible(); } - public void setGridVisibility(final boolean fVisible) { + public void setGridVisible(final boolean gridVisible) { if (currentMap != null) { - currentMap.getMapViewFrame().setGridVisibility(fVisible); + currentMap.getMapViewFrame().setGridVisible(gridVisible); } } Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-01 22:06:28 UTC (rev 767) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-01 22:28:44 UTC (rev 768) @@ -679,7 +679,7 @@ m_gridToggle.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { - mainControl.setGridVisibility(m_gridToggle.isChecked()); + mainControl.setGridVisible(m_gridToggle.isChecked()); } }); menuManager.addMenuEntry("main.map", m_gridToggle); Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 22:06:28 UTC (rev 767) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 22:28:44 UTC (rev 768) @@ -88,7 +88,7 @@ private boolean changed = false; - private boolean showMapGrid; + private boolean gridVisible = false; // this is needed to check the diamond tile areas and convert rectangles to diamond private final Point mapMousePos = new Point(); @@ -117,7 +117,6 @@ this.mapControl = mapControl; this.mainControl = mainControl; frame = fi; - showMapGrid = false; highlightOn = false; needMpanelUpdate = new boolean[3]; @@ -177,7 +176,7 @@ * @return true if map grid is visible */ public boolean isGridVisible() { - return showMapGrid; + return gridVisible; } /** Update for a new look and feel (-> view menu) */ @@ -213,8 +212,8 @@ return mapControl; } - public void setGridVisibility(final boolean fVisible) { - showMapGrid = fVisible; + public void setGridVisible(final boolean gridVisible) { + this.gridVisible = gridVisible; this.modelChanged(); } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-01 22:06:28 UTC (rev 767) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-01 22:28:44 UTC (rev 768) @@ -154,8 +154,8 @@ return mapControl; } - public void setGridVisibility(final boolean fVisible) { - view.setGridVisibility(fVisible); + public void setGridVisible(final boolean gridVisible) { + view.setGridVisible(gridVisible); } public void closeNotify() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:06:28
|
Revision: 767 http://svn.sourceforge.net/gridarta/?rev=767&view=rev Author: akirschbaum Date: 2006-12-01 14:06:28 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Declare variable more local. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 22:05:22 UTC (rev 766) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 22:06:28 UTC (rev 767) @@ -151,8 +151,6 @@ * @return an image of the entire mapview */ public BufferedImage getFullImage() { - final int storeOffset; // tmp. storage to save map offset - final Size2D mapSize = mapControl.getMapSize(); final int mapWidth = 32 * mapSize.getWidth(); final int mapHeight = 32 * mapSize.getHeight(); @@ -165,7 +163,7 @@ bufGrfx.fillRect(0, 0, mapWidth, mapHeight); // paint the mapview into the image - storeOffset = borderOffset; + final int storeOffset = borderOffset; borderOffset = 0; paintComponent((Graphics2D) bufGrfx, true); borderOffset = storeOffset; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:05:22
|
Revision: 766 http://svn.sourceforge.net/gridarta/?rev=766&view=rev Author: akirschbaum Date: 2006-12-01 14:05:22 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 22:00:38 UTC (rev 765) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 22:05:22 UTC (rev 766) @@ -81,7 +81,7 @@ private final boolean isPickmap; /** offset to map borders (32 for std. rect. maps, 0 for pickmaps). */ - private int bOffset; + private int borderOffset; private final CMainControl mainControl; @@ -115,8 +115,8 @@ } tmpIcon = new ImageIcon(); - bOffset = !pickmap ? 32 : 0; - renderTransform = new AffineTransform(1f, 0f, 0f, 1f, (float) bOffset, (float) bOffset); + borderOffset = !pickmap ? 32 : 0; + renderTransform = new AffineTransform(1f, 0f, 0f, 1f, (float) borderOffset, (float) borderOffset); highLightMask = new Color[]{ new Color(1.0f, 0.0f, 0.0f, 0.33f), new Color(0.0f, 1.0f, 0.0f, 0.33f), @@ -165,10 +165,10 @@ bufGrfx.fillRect(0, 0, mapWidth, mapHeight); // paint the mapview into the image - storeOffset = bOffset; - bOffset = 0; + storeOffset = borderOffset; + borderOffset = 0; paintComponent((Graphics2D) bufGrfx, true); - bOffset = storeOffset; + borderOffset = storeOffset; return bufImage; } @@ -187,10 +187,10 @@ repaint(); } else { log.debug("modelChanged(), we are in a backbuffered behaviour."); - final int storeOffset = bOffset; - bOffset = 0; + final int storeOffset = borderOffset; + borderOffset = 0; paintComponent((Graphics2D) backBuffer.getGraphics(), false); - bOffset = storeOffset; + borderOffset = storeOffset; repaint(); } } @@ -221,9 +221,9 @@ if (!mapControl.getMapModel().containsArchObject(x, y)) { // empty square if (isPickmap) { - grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); + grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); } else { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } } else { for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { @@ -233,17 +233,17 @@ } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + mainControl.getNoarchTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + mainControl.getNofaceTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else { if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else { // draw object face final ImageIcon img = archlist.getFace(node.getFaceNr()); if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else if (node.isHead()) { oversizedMultiHeads.addElement(node); // store oversized arches for later } @@ -259,7 +259,7 @@ final Color alpha = highLightMask[i]; final Color c = grfx.getColor(); grfx.setColor(alpha); - grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); + grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); grfx.setColor(c); } } @@ -267,24 +267,24 @@ // at the end, we have to draw the oversized multipart images on top of the rest for (int i = 0; i < oversizedMultiHeads.size(); i++) { final GameObject node = oversizedMultiHeads.elementAt(i); - archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, node.getMapX() * 32 + bOffset, node.getMapY() * 32 + bOffset); + archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, node.getMapX() * 32 + borderOffset, node.getMapY() * 32 + borderOffset); } // grid lines if (mapViewBasic.isGridVisible() && !isSnapshot) { for (int x = 0; x <= mapViewBasic.getMapSize().getWidth(); x++) { grfx.drawLine( - x * 32 + bOffset, - 0 + bOffset, - x * 32 + bOffset, - mapViewBasic.getMapSize().getHeight() * 32 + bOffset); + x * 32 + borderOffset, + 0 + borderOffset, + x * 32 + borderOffset, + mapViewBasic.getMapSize().getHeight() * 32 + borderOffset); } for (int y = 0; y <= mapViewBasic.getMapSize().getHeight(); y++) { grfx.drawLine( - 0 + bOffset, - y * 32 + bOffset, - mapViewBasic.getMapSize().getWidth() * 32 + bOffset, - y * 32 + bOffset); + 0 + borderOffset, + y * 32 + borderOffset, + mapViewBasic.getMapSize().getWidth() * 32 + borderOffset, + y * 32 + borderOffset); } } if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1 && !isSnapshot) { @@ -322,7 +322,7 @@ // draw the empty-tile icon (direcly to the mapview) if (isPickmap) { grfx.setColor(IGUIConstants.BG_COLOR); - grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); + grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); } else { mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32, y * 32); } @@ -449,7 +449,7 @@ // Draw the Icon: // Rectangular view - mainControl.getMapSelIconX().paintIcon(this, grfx, posx * 32 + bOffset, posy * 32 + bOffset); + mainControl.getMapSelIconX().paintIcon(this, grfx, posx * 32 + borderOffset, posy * 32 + borderOffset); if (signY == 0) { break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 22:00:39
|
Revision: 765 http://svn.sourceforge.net/gridarta/?rev=765&view=rev Author: akirschbaum Date: 2006-12-01 14:00:38 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify comments. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 21:49:33 UTC (rev 764) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 22:00:38 UTC (rev 765) @@ -73,9 +73,15 @@ private ImageIcon tmpIcon; - private final boolean isPickmap; // true if the map is a pickmap (those have different layout!) + /** + * Declares this <code>DefaultLevelRenderer</code> as a renderer for a + * Pickmap. Pickmaps have a special behaviour that's different from normal + * maps. Value: <code>true</code> if pickmap, otherwise <code>false</code>. + */ + private final boolean isPickmap; - private int bOffset; // offset to map borders (32 for std. rect. maps, 0 for pickmaps) + /** offset to map borders (32 for std. rect. maps, 0 for pickmaps). */ + private int bOffset; private final CMainControl mainControl; @@ -134,12 +140,16 @@ } } - /** @return wether rendered map is a pickmap */ + /** + * @return whether rendered map is a pickmap + */ public boolean isPickmap() { return isPickmap; } - /** @return an image of the entire mapview */ + /** + * @return an image of the entire mapview + */ public BufferedImage getFullImage() { final int storeOffset; // tmp. storage to save map offset @@ -159,7 +169,6 @@ bOffset = 0; paintComponent((Graphics2D) bufGrfx, true); bOffset = storeOffset; - //return bufImage.getScaledInstance(16*mapControl.getMapWidth(), 16*mapControl.getMapHeight(), Image.SCALE_SMOOTH); return bufImage; } @@ -169,7 +178,6 @@ } else { ((Graphics2D) grfx).drawImage(backBuffer, renderTransform, null); } - //paintHighLight(grfx); } public void modelChanged() { @@ -189,7 +197,7 @@ /** * Paints this component. - * @param grfx The graphics context to paint to. + * @param grfx The graphics context to paint to. * @param isSnapshot true when this drawing is for a * "screenshot"-image, false for normal drawing */ @@ -410,7 +418,8 @@ } /** - * Painting the highlited (selected) area on the map + * Paints the highlighted (selected) area on the map. + * * @param grfx graphics context of mapview */ public void paintHighlightArea(final Graphics grfx) { @@ -453,8 +462,8 @@ } /** - * Returns the map location at the given point or null if no map - * location is at the point. + * Returns the map location at the given point or null if no map location + * is at the point. * @param point The coordinates in the renderer view. * @return The map location. */ @@ -515,4 +524,4 @@ tmpImage = null; } -} +} // class DefaultLevelRenderer Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-01 21:49:33 UTC (rev 764) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-01 22:00:38 UTC (rev 765) @@ -60,9 +60,9 @@ private static final long serialVersionUID = 1L; /** - * Declares this CLevelRenderer as a renderer for a Pickmap. - * Pickmaps have a special behaviour that's different from normal maps. - * Value: <code>true</code> if pickmap, otherwise <code>false</code>. + * Declares this <code>DefaultLevelRenderer</code> as a renderer for a + * Pickmap. Pickmaps have a special behaviour that's different from normal + * maps. Value: <code>true</code> if pickmap, otherwise <code>false</code>. */ private final boolean isPickmap; @@ -492,5 +492,4 @@ this.erraneousMapSquares = erraneousMapSquares; } -} // class CLevelRenderer - +} // class DefaultLevelRenderer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 21:49:33
|
Revision: 764 http://svn.sourceforge.net/gridarta/?rev=764&view=rev Author: akirschbaum Date: 2006-12-01 13:49:33 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Extract level renderer class from CMapViewBasic. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/map/ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 21:30:36 UTC (rev 763) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 21:49:33 UTC (rev 764) @@ -24,32 +24,21 @@ package cfeditor; -import cfeditor.filter.AttributeFilter; -import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.gui.MapView; import cfeditor.map.MapControl; import cfeditor.map.MapModel; -import java.awt.Color; +import cfeditor.gui.map.DefaultLevelRenderer; import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionListener; -import java.awt.geom.AffineTransform; -import java.awt.geom.NoninvertibleTransformException; -import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Iterator; -import java.util.Vector; import javax.imageio.ImageIO; -import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JScrollPane; import javax.swing.JViewport; @@ -95,7 +84,7 @@ private Size2D mapSize = new Size2D(1, 1); /** The tile palette renderer. */ - private final CLevelRenderer renderer; + private final DefaultLevelRenderer renderer; private boolean changed = false; @@ -145,7 +134,7 @@ if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); } - renderer = new CFlatLevelRenderer(mapControl.getMapModel(), isPickmap()); + renderer = new DefaultLevelRenderer(this, mainControl, mapControl, isPickmap()); setViewportView((JComponent) renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); @@ -493,491 +482,17 @@ renderer.freeBackBuffer(); } - /** - * A lavel renderer, mainly used as central point interfac to iso and flat - * renderer - * @author tchize - */ - public interface CLevelRenderer { + public Size2D getMapSize() { + return mapSize; + } - void updateLookAndFeel(); - - BufferedImage getFullImage(); - - void paintTile(int x, int y); - - Point getTileLocationAt(Point point); - - boolean isPickmap(); - - void paintHighlightTile(Graphics grfx, int x, int y); - - void modelChanged(); - - void setHighlightTile(int x, int y); - - boolean resizeBackBuffer(); - - void freeBackBuffer(); + public Point getMapMousePos() { + return mapMousePos; } - /** - * The component that does the actual rendering of tiles in the palette. - * Flat version - */ - public final class CFlatLevelRenderer extends JComponent implements CLevelRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - private final MapModel mapModel; - - // 32x32 Image and Icon for temprary storing tiles before drawing - private Image tmpImage; - - private Graphics tmpGrfx; - - private ImageIcon tmpIcon; - - private final boolean isPickmap; // true if the map is a pickmap (those have different layout!) - - private int bOffset; // offset to map borders (32 for std. rect. maps, 0 for pickmaps) - - private final AttributeFilter af; - - private final Color[] highLightMask; - - private BufferedImage backBuffer; - - /** Current size of {@link #backBuffer} image. */ - private final Dimension bufferedSize = new Dimension(); - - private final AffineTransform renderTransform; - - /** Constructor */ - CFlatLevelRenderer(final MapModel mapModel, final boolean pickmap) { - this.mapModel = mapModel; - - af = new AttributeFilter(); - af.addAttribute("no_pass", "1"); - isPickmap = pickmap; - // initialize the tmp. graphic buffer - tmpImage = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB); - tmpGrfx = tmpImage.getGraphics(); - if (!pickmap) { - tmpGrfx.setColor(mainControl.getMainView().getBackground()); // background color of window - } else { - tmpGrfx.setColor(IGUIConstants.BG_COLOR); - } - tmpIcon = new ImageIcon(); - - bOffset = !pickmap ? 32 : 0; - renderTransform = new AffineTransform(1f, 0f, 0f, 1f, (float) bOffset, (float) bOffset); - highLightMask = new Color[]{ - new Color(1.0f, 0.0f, 0.0f, 0.33f), - new Color(0.0f, 1.0f, 0.0f, 0.33f), - new Color(0.0f, 1.0f, 1.0f, 0.33f)}; - resizeBackBuffer(); - /*taken from java doc, scroll while dragged*/ - final MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() { - @Override public void mouseDragged(final MouseEvent e) { - final Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1); - ((JComponent) e.getSource()).scrollRectToVisible(r); - } - }; - this.addMouseMotionListener(doScrollRectToVisible); - } - - /** This method is called when the look and feel has changed */ - public void updateLookAndFeel() { - // update background color of window - if (!isPickmap) { - tmpGrfx.setColor(getBackground()); - } - } - - /** @return wether rendered map is a pickmap */ - public boolean isPickmap() { - return isPickmap; - } - - /** @return an image of the entire mapview */ - public BufferedImage getFullImage() { - final int storeOffset; // tmp. storage to save map offset - - final Size2D mapSize = getMapControl().getMapSize(); - final int mapWidth = 32 * mapSize.getWidth(); - final int mapHeight = 32 * mapSize.getHeight(); - - // first create a storing place for the image - final BufferedImage bufImage = new BufferedImage(mapWidth, mapHeight, BufferedImage.TYPE_INT_ARGB); - final Graphics bufGrfx = bufImage.getGraphics(); - bufGrfx.setColor(Color.white); - bufGrfx.setColor(Color.white); - bufGrfx.fillRect(0, 0, mapWidth, mapHeight); - - // paint the mapview into the image - storeOffset = bOffset; - bOffset = 0; - paintComponent((Graphics2D) bufGrfx, true); - bOffset = storeOffset; - //return bufImage.getScaledInstance(16*getMapControl().getMapWidth(), 16*getMapControl().getMapHeight(), Image.SCALE_SMOOTH); - return bufImage; - } - - @Override public void paintComponent(final Graphics grfx) { - if (isPickmap) { - paintComponent((Graphics2D) grfx, false); - } else { - ((Graphics2D) grfx).drawImage(backBuffer, renderTransform, null); - } - //paintHighLight(grfx); - } - - public void modelChanged() { - if (isPickmap) { - //pickmaps don't have double buffers - //maybe later could have them share one single buffer ? - repaint(); - } else { - log.debug("modelChanged(), we are in a backbuffered behaviour."); - final int storeOffset = bOffset; - bOffset = 0; - paintComponent((Graphics2D) backBuffer.getGraphics(), false); - bOffset = storeOffset; - repaint(); - } - } - - /** - * Paints this component. - * @param grfx The graphics context to paint to. - * @param isSnapshot true when this drawing is for a - * "screenshot"-image, false for normal drawing - */ - public void paintComponent(final Graphics2D grfx, final boolean isSnapshot) { - final ArchetypeSet archlist = mainControl.getArchetypeSet(); - - if (isPickmap) { - // draw greenisch background for pickmaps - grfx.setColor(IGUIConstants.BG_COLOR); - } else { - grfx.setColor(mainControl.getMainView().getBackground()); // background color of window - } - grfx.fillRect(0, 0, getWidth(), getHeight()); - // ---------- draw rectangular map -------------- - // this vector contains all heads of multi-tiles with oversized images - final Vector<GameObject> oversizedMultiHeads = new Vector<GameObject>(); - final CFilterControl filter = mainControl.getFilterControl(); - for (int y = 0; y < mapSize.getHeight(); y++) { - for (int x = 0; x < mapSize.getWidth(); x++) { - filter.newSquare(); - if (!mapModel.containsArchObject(x, y)) { - // empty square - if (isPickmap) { - grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); - } else { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); - } - } else { - for (final GameObject node : mapModel.getMapSquare(new Point(x, y))) { - filter.objectInSquare(node); - if (!filter.canShow(node)) { - continue; - } - if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { - if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); - } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); - } else { - if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); - } else { - // draw object face - final ImageIcon img = archlist.getFace(node.getFaceNr()); - if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); - } else if (node.isHead()) { - oversizedMultiHeads.addElement(node); // store oversized arches for later - } - } - } - } - } - } - for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { - if (!filter.highLightedSquare(i)) { - continue; - } - final Color alpha = highLightMask[i]; - final Color c = grfx.getColor(); - grfx.setColor(alpha); - grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); - grfx.setColor(c); - } - } - } - // at the end, we have to draw the oversized multipart images on top of the rest - for (int i = 0; i < oversizedMultiHeads.size(); i++) { - final GameObject node = oversizedMultiHeads.elementAt(i); - archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, node.getMapX() * 32 + bOffset, node.getMapY() * 32 + bOffset); - } - - // grid lines - if (showMapGrid && !isSnapshot) { - for (int x = 0; x <= mapSize.getWidth(); x++) { - grfx.drawLine( - x * 32 + bOffset, - 0 + bOffset, - x * 32 + bOffset, - mapSize.getHeight() * 32 + bOffset); - } - for (int y = 0; y <= mapSize.getHeight(); y++) { - grfx.drawLine( - 0 + bOffset, - y * 32 + bOffset, - mapSize.getWidth() * 32 + bOffset, - y * 32 + bOffset); - } - } - if (highlightOn && mapMouseRightPos.y != -1 && mapMouseRightPos.x != -1 && !isSnapshot) { - // Highlight the selected area - paintHighlightArea(grfx); - } - - - } - - /** - * Paints only one tile of the map. This is an incredible time-saver - * for insert/select/delete tile actions. - * <p/> - * Important: This method currently works only for standard - * (rectangular) view. Iso has overlapping tiles which makes this a lot - * more difficult. :( - * @param x map coordinates for the tile to draw - * @param y map coordinates for the tile to draw - */ - public void paintTile(final int x, final int y) { - final Graphics grfx; - if (isPickmap()) { - grfx = getGraphics(); // graphics context for drawing in the mapview - } else { - grfx = backBuffer.getGraphics(); - } - final ArchetypeSet archlist = mainControl.getArchetypeSet(); // arch stack - - // ---------- draw tile for rectangular view (non-iso) -------------- - final CFilterControl filter = mainControl.getFilterControl(); - filter.newSquare(); - // first, draw the object's faces: - if (!mapModel.containsArchObject(x, y)) { - // draw the empty-tile icon (direcly to the mapview) - if (isPickmap) { - grfx.setColor(IGUIConstants.BG_COLOR); - grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); - } else { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32, y * 32); - } - } else { - tmpGrfx.fillRect(0, 0, 32, 32); - // loop through all arches on that square and draw em - for (final GameObject node : mapModel.getMapSquare(new Point(x, y))) { - filter.objectInSquare(node); - if (!filter.canShow(node)) { - continue; - } - if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0) { - if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIconX().paintIcon(this, tmpGrfx, 0, 0); - } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIconX().paintIcon(this, tmpGrfx, 0, 0); - } else { - if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIconX().paintIcon(this, tmpGrfx, 0, 0); - } else { - final ImageIcon img = archlist.getFace(node.getFaceNr()); - if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - img.paintIcon(this, tmpGrfx, 0, 0); - } else { - // this is an oversized image, so it must be shifted - img.paintIcon(this, tmpGrfx, -32 * node.getMultiX(), -32 * node.getMultiY()); - } - } - } - } - } - } - for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { - if (!filter.highLightedSquare(i)) { - continue; - } - final Color alpha = highLightMask[i]; - final Color c = grfx.getColor(); - tmpGrfx.setColor(alpha); - tmpGrfx.fillRect(0, 0, 32, 32); - tmpGrfx.setColor(c); - } - // We have been drawing to the tmp. buffer, now convert it to - // an ImageIcon and paint it into the mapview: - if (mapModel.containsArchObject(x, y)) { - tmpIcon.setImage(tmpImage); - tmpIcon.paintIcon(this, grfx, x * 32, y * 32); - } - - // if grid is active, draw grid lines (right and bottom) - if (showMapGrid) { - // horizontal: - grfx.drawLine(x * 32, y * 32, x * 32, y * 32 + 32); - // vertical: - grfx.drawLine(x * 32, y * 32, x * 32 + 32, y * 32); - } - - // if tile is highlighted, draw the highlight icon - paintHighlightTile(grfx, x, y); - } - - - public void setHighlightTile(final int x, final int y) { - if (isPickmap()) { - paintHighlightTile(getGraphics(), x, y); - } else { - paintHighlightTile(backBuffer.getGraphics(), x, y); - repaint(); - } - } - - /** - * If the given map-square is highlighted, the highligh-icon is drawn - * on that square. - * @param x map coords of the square - * @param y map coords of the square - * @param grfx graphics context to draw in - */ - public void paintHighlightTile(final Graphics grfx, final int x, final int y) { - // if tile is highlighted, draw the highlight icon: - if (highlightOn && mapMouseRightPos.y != -1 && mapMouseRightPos.x != -1) { - // get rect. coords of highlighted area: top(left) and bot(tomright) corner - final int topx = Math.min(mapMouseRightPos.x, mapMouseRightPos.x + mapMouseRightOff.x); - final int topy = Math.min(mapMouseRightPos.y, mapMouseRightPos.y + mapMouseRightOff.y); - final int botx = Math.max(mapMouseRightPos.x, mapMouseRightPos.x + mapMouseRightOff.x); - final int boty = Math.max(mapMouseRightPos.y, mapMouseRightPos.y + mapMouseRightOff.y); - - // Highlight the selected square - if (x >= topx && x <= botx && y >= topy && y <= boty) { - mainControl.getMapSelIconX().paintIcon(this, grfx, x * 32, y * 32); - } - } - } - - /** - * Painting the highlited (selected) area on the map - * @param grfx graphics context of mapview - */ - public void paintHighlightArea(final Graphics grfx) { - final int signX, signY; // sign = "direction" of the dragging offset - - if (mapMouseRightOff.x > 0) { - signX = 1; - } else if (mapMouseRightOff.x < 0) { - signX = -1; - } else { - signX = 0; - } - - if (mapMouseRightOff.y > 0) { - signY = 1; - } else if (mapMouseRightOff.y < 0) { - signY = -1; - } else { - signY = 0; - } - - // Highlight all tiles that are in the rectangle between drag-start and mouse - for (int posx = mapMouseRightPos.x; Math.abs(posx - mapMouseRightPos.x) - <= Math.abs(mapMouseRightOff.x); posx += signX) { - for (int posy = mapMouseRightPos.y; Math.abs(posy - mapMouseRightPos.y) - <= Math.abs(mapMouseRightOff.y); posy += signY) { - // Draw the Icon: - - // Rectangular view - mainControl.getMapSelIconX().paintIcon(this, grfx, posx * 32 + bOffset, posy * 32 + bOffset); - - if (signY == 0) { - break; - } - } - if (signX == 0) { - break; - } - } - } - - /** - * Returns the map location at the given point or null if no map - * location is at the point. - * @param point The coordinates in the renderer view. - * @return The map location. - */ - - // i'll change it to a fixed point... i want use this for mouse tracking - // and don't want have millions of mallocs here - // this should be reworked more intelligent later - public Point getTileLocationAt(final Point point) { - try { - renderTransform.inverseTransform(point, point); - } catch (final NoninvertibleTransformException e) { - } - mapMousePos.x = -1; - mapMousePos.y = -1; - - final Point mpoint = new Point(); - mpoint.x = mapMousePos.x; - mpoint.y = mapMousePos.y; - if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { - mapMousePos.x = point.x / 32; - mapMousePos.y = point.y / 32; - } - - mpoint.x = mapMousePos.x; - mpoint.y = mapMousePos.y; - return mpoint; - } - - public boolean resizeBackBuffer() { - if (isPickmap) { - return false; - } - - final Size2D mapSize = getMapControl().getMapSize(); - final Dimension size = new Dimension(mapSize.getWidth() * 32, mapSize.getHeight() * 32); - if (bufferedSize.equals(size)) { - return true; - } - bufferedSize.setSize(size); - - if (log.isDebugEnabled()) { - log.debug("Creating a backbuffer of size " + size.width + "x" + size.height + "."); - } - backBuffer = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); - final Graphics g = backBuffer.getGraphics(); - g.setColor(Color.YELLOW); - g.fillRect(0, 0, size.width, size.height); - - return true; - } - - /* (non-Javadoc) - * - * @see cfeditor.CMapViewBasic.CLevelRenderer#freeMapBuffer() - */ - public void freeBackBuffer() { - backBuffer = null; - tmpGrfx = null; - tmpIcon = null; - tmpImage = null; - } + public void setMapMousePos(final int x, final int y) { + mapMousePos.x = x; + mapMousePos.y = y; } /** The mouse listener for the view. */ Added: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-01 21:49:33 UTC (rev 764) @@ -0,0 +1,518 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package cfeditor.gui.map; + +import cfeditor.CFilterControl; +import cfeditor.CMainControl; +import cfeditor.CMapViewBasic; +import cfeditor.IGUIConstants; +import cfeditor.filter.AttributeFilter; +import cfeditor.gameobject.ArchetypeSet; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; +import java.awt.geom.AffineTransform; +import java.awt.geom.NoninvertibleTransformException; +import java.awt.image.BufferedImage; +import java.util.Vector; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import net.sf.gridarta.Size2D; +import org.apache.log4j.Logger; + +/** + * The component that does the actual rendering of tiles in the palette. + * Flat version + */ +public final class DefaultLevelRenderer extends JComponent implements LevelRenderer { + + private static final Logger log = Logger.getLogger(DefaultLevelRenderer.class); + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + private final MapControl mapControl; + + private final CMapViewBasic mapViewBasic; + + // 32x32 Image and Icon for temprary storing tiles before drawing + private Image tmpImage; + + private Graphics tmpGrfx; + + private ImageIcon tmpIcon; + + private final boolean isPickmap; // true if the map is a pickmap (those have different layout!) + + private int bOffset; // offset to map borders (32 for std. rect. maps, 0 for pickmaps) + + private final CMainControl mainControl; + + private final AttributeFilter af; + + private final Color[] highLightMask; + + private BufferedImage backBuffer; + + /** Current size of {@link #backBuffer} image. */ + private final Dimension bufferedSize = new Dimension(); + + private final AffineTransform renderTransform; + + /** Constructor */ + public DefaultLevelRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final boolean pickmap) { + this.mapViewBasic = mapViewBasic; + this.mainControl = mainControl; + this.mapControl = mapControl; + + af = new AttributeFilter(); + af.addAttribute("no_pass", "1"); + isPickmap = pickmap; + // initialize the tmp. graphic buffer + tmpImage = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB); + tmpGrfx = tmpImage.getGraphics(); + if (!pickmap) { + tmpGrfx.setColor(mainControl.getMainView().getBackground()); // background color of window + } else { + tmpGrfx.setColor(IGUIConstants.BG_COLOR); + } + tmpIcon = new ImageIcon(); + + bOffset = !pickmap ? 32 : 0; + renderTransform = new AffineTransform(1f, 0f, 0f, 1f, (float) bOffset, (float) bOffset); + highLightMask = new Color[]{ + new Color(1.0f, 0.0f, 0.0f, 0.33f), + new Color(0.0f, 1.0f, 0.0f, 0.33f), + new Color(0.0f, 1.0f, 1.0f, 0.33f)}; + resizeBackBuffer(); + /*taken from java doc, scroll while dragged*/ + final MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() { + @Override public void mouseDragged(final MouseEvent e) { + final Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1); + ((JComponent) e.getSource()).scrollRectToVisible(r); + } + }; + this.addMouseMotionListener(doScrollRectToVisible); + } + + /** This method is called when the look and feel has changed */ + public void updateLookAndFeel() { + // update background color of window + if (!isPickmap) { + tmpGrfx.setColor(getBackground()); + } + } + + /** @return wether rendered map is a pickmap */ + public boolean isPickmap() { + return isPickmap; + } + + /** @return an image of the entire mapview */ + public BufferedImage getFullImage() { + final int storeOffset; // tmp. storage to save map offset + + final Size2D mapSize = mapControl.getMapSize(); + final int mapWidth = 32 * mapSize.getWidth(); + final int mapHeight = 32 * mapSize.getHeight(); + + // first create a storing place for the image + final BufferedImage bufImage = new BufferedImage(mapWidth, mapHeight, BufferedImage.TYPE_INT_ARGB); + final Graphics bufGrfx = bufImage.getGraphics(); + bufGrfx.setColor(Color.white); + bufGrfx.setColor(Color.white); + bufGrfx.fillRect(0, 0, mapWidth, mapHeight); + + // paint the mapview into the image + storeOffset = bOffset; + bOffset = 0; + paintComponent((Graphics2D) bufGrfx, true); + bOffset = storeOffset; + //return bufImage.getScaledInstance(16*mapControl.getMapWidth(), 16*mapControl.getMapHeight(), Image.SCALE_SMOOTH); + return bufImage; + } + + @Override public void paintComponent(final Graphics grfx) { + if (isPickmap) { + paintComponent((Graphics2D) grfx, false); + } else { + ((Graphics2D) grfx).drawImage(backBuffer, renderTransform, null); + } + //paintHighLight(grfx); + } + + public void modelChanged() { + if (isPickmap) { + //pickmaps don't have double buffers + //maybe later could have them share one single buffer ? + repaint(); + } else { + log.debug("modelChanged(), we are in a backbuffered behaviour."); + final int storeOffset = bOffset; + bOffset = 0; + paintComponent((Graphics2D) backBuffer.getGraphics(), false); + bOffset = storeOffset; + repaint(); + } + } + + /** + * Paints this component. + * @param grfx The graphics context to paint to. + * @param isSnapshot true when this drawing is for a + * "screenshot"-image, false for normal drawing + */ + public void paintComponent(final Graphics2D grfx, final boolean isSnapshot) { + final ArchetypeSet archlist = mainControl.getArchetypeSet(); + + if (isPickmap) { + // draw greenisch background for pickmaps + grfx.setColor(IGUIConstants.BG_COLOR); + } else { + grfx.setColor(mainControl.getMainView().getBackground()); // background color of window + } + grfx.fillRect(0, 0, getWidth(), getHeight()); + // ---------- draw rectangular map -------------- + // this vector contains all heads of multi-tiles with oversized images + final Vector<GameObject> oversizedMultiHeads = new Vector<GameObject>(); + final CFilterControl filter = mainControl.getFilterControl(); + for (int y = 0; y < mapViewBasic.getMapSize().getHeight(); y++) { + for (int x = 0; x < mapViewBasic.getMapSize().getWidth(); x++) { + filter.newSquare(); + if (!mapControl.getMapModel().containsArchObject(x, y)) { + // empty square + if (isPickmap) { + grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); + } else { + mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + } + } else { + for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { + filter.objectInSquare(node); + if (!filter.canShow(node)) { + continue; + } + if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { + if (node.getArchetypeName() == null) { + mainControl.getNoarchTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + } else if (node.getFaceFlag()) { + mainControl.getNofaceTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + } else { + if (node.getFaceNr() == -1) { + mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + } else { + // draw object face + final ImageIcon img = archlist.getFace(node.getFaceNr()); + if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { + archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, x * 32 + bOffset, y * 32 + bOffset); + } else if (node.isHead()) { + oversizedMultiHeads.addElement(node); // store oversized arches for later + } + } + } + } + } + } + for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { + if (!filter.highLightedSquare(i)) { + continue; + } + final Color alpha = highLightMask[i]; + final Color c = grfx.getColor(); + grfx.setColor(alpha); + grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); + grfx.setColor(c); + } + } + } + // at the end, we have to draw the oversized multipart images on top of the rest + for (int i = 0; i < oversizedMultiHeads.size(); i++) { + final GameObject node = oversizedMultiHeads.elementAt(i); + archlist.getFace(node.getFaceNr()).paintIcon(this, grfx, node.getMapX() * 32 + bOffset, node.getMapY() * 32 + bOffset); + } + + // grid lines + if (mapViewBasic.isGridVisible() && !isSnapshot) { + for (int x = 0; x <= mapViewBasic.getMapSize().getWidth(); x++) { + grfx.drawLine( + x * 32 + bOffset, + 0 + bOffset, + x * 32 + bOffset, + mapViewBasic.getMapSize().getHeight() * 32 + bOffset); + } + for (int y = 0; y <= mapViewBasic.getMapSize().getHeight(); y++) { + grfx.drawLine( + 0 + bOffset, + y * 32 + bOffset, + mapViewBasic.getMapSize().getWidth() * 32 + bOffset, + y * 32 + bOffset); + } + } + if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1 && !isSnapshot) { + // Highlight the selected area + paintHighlightArea(grfx); + } + + + } + + /** + * Paints only one tile of the map. This is an incredible time-saver + * for insert/select/delete tile actions. + * <p/> + * Important: This method currently works only for standard + * (rectangular) view. Iso has overlapping tiles which makes this a lot + * more difficult. :( + * @param x map coordinates for the tile to draw + * @param y map coordinates for the tile to draw + */ + public void paintTile(final int x, final int y) { + final Graphics grfx; + if (isPickmap()) { + grfx = getGraphics(); // graphics context for drawing in the mapview + } else { + grfx = backBuffer.getGraphics(); + } + final ArchetypeSet archlist = mainControl.getArchetypeSet(); // arch stack + + // ---------- draw tile for rectangular view (non-iso) -------------- + final CFilterControl filter = mainControl.getFilterControl(); + filter.newSquare(); + // first, draw the object's faces: + if (!mapControl.getMapModel().containsArchObject(x, y)) { + // draw the empty-tile icon (direcly to the mapview) + if (isPickmap) { + grfx.setColor(IGUIConstants.BG_COLOR); + grfx.fillRect(x * 32 + bOffset, y * 32 + bOffset, 32, 32); + } else { + mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32, y * 32); + } + } else { + tmpGrfx.fillRect(0, 0, 32, 32); + // loop through all arches on that square and draw em + for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { + filter.objectInSquare(node); + if (!filter.canShow(node)) { + continue; + } + if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0) { + if (node.getArchetypeName() == null) { + mainControl.getNoarchTileIconX().paintIcon(this, tmpGrfx, 0, 0); + } else if (node.getFaceFlag()) { + mainControl.getNofaceTileIconX().paintIcon(this, tmpGrfx, 0, 0); + } else { + if (node.getFaceNr() == -1) { + mainControl.getUnknownTileIconX().paintIcon(this, tmpGrfx, 0, 0); + } else { + final ImageIcon img = archlist.getFace(node.getFaceNr()); + if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { + img.paintIcon(this, tmpGrfx, 0, 0); + } else { + // this is an oversized image, so it must be shifted + img.paintIcon(this, tmpGrfx, -32 * node.getMultiX(), -32 * node.getMultiY()); + } + } + } + } + } + } + for (int i = 0; i < CFilterControl.MAX_HIGHLIGHT; i++) { + if (!filter.highLightedSquare(i)) { + continue; + } + final Color alpha = highLightMask[i]; + final Color c = grfx.getColor(); + tmpGrfx.setColor(alpha); + tmpGrfx.fillRect(0, 0, 32, 32); + tmpGrfx.setColor(c); + } + // We have been drawing to the tmp. buffer, now convert it to + // an ImageIcon and paint it into the mapview: + if (mapControl.getMapModel().containsArchObject(x, y)) { + tmpIcon.setImage(tmpImage); + tmpIcon.paintIcon(this, grfx, x * 32, y * 32); + } + + // if grid is active, draw grid lines (right and bottom) + if (mapViewBasic.isGridVisible()) { + // horizontal: + grfx.drawLine(x * 32, y * 32, x * 32, y * 32 + 32); + // vertical: + grfx.drawLine(x * 32, y * 32, x * 32 + 32, y * 32); + } + + // if tile is highlighted, draw the highlight icon + paintHighlightTile(grfx, x, y); + } + + + public void setHighlightTile(final int x, final int y) { + if (isPickmap()) { + paintHighlightTile(getGraphics(), x, y); + } else { + paintHighlightTile(backBuffer.getGraphics(), x, y); + repaint(); + } + } + + /** + * If the given map-square is highlighted, the highligh-icon is drawn + * on that square. + * @param x map coords of the square + * @param y map coords of the square + * @param grfx graphics context to draw in + */ + public void paintHighlightTile(final Graphics grfx, final int x, final int y) { + // if tile is highlighted, draw the highlight icon: + if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { + // get rect. coords of highlighted area: top(left) and bot(tomright) corner + final int topx = Math.min(mapViewBasic.getMapMouseRightPos().x, mapViewBasic.getMapMouseRightPos().x + mapViewBasic.getHighlightOffset().x); + final int topy = Math.min(mapViewBasic.getMapMouseRightPos().y, mapViewBasic.getMapMouseRightPos().y + mapViewBasic.getHighlightOffset().y); + final int botx = Math.max(mapViewBasic.getMapMouseRightPos().x, mapViewBasic.getMapMouseRightPos().x + mapViewBasic.getHighlightOffset().x); + final int boty = Math.max(mapViewBasic.getMapMouseRightPos().y, mapViewBasic.getMapMouseRightPos().y + mapViewBasic.getHighlightOffset().y); + + // Highlight the selected square + if (x >= topx && x <= botx && y >= topy && y <= boty) { + mainControl.getMapSelIconX().paintIcon(this, grfx, x * 32, y * 32); + } + } + } + + /** + * Painting the highlited (selected) area on the map + * @param grfx graphics context of mapview + */ + public void paintHighlightArea(final Graphics grfx) { + final int signX, signY; // sign = "direction" of the dragging offset + + if (mapViewBasic.getHighlightOffset().x > 0) { + signX = 1; + } else if (mapViewBasic.getHighlightOffset().x < 0) { + signX = -1; + } else { + signX = 0; + } + + if (mapViewBasic.getHighlightOffset().y > 0) { + signY = 1; + } else if (mapViewBasic.getHighlightOffset().y < 0) { + signY = -1; + } else { + signY = 0; + } + + // Highlight all tiles that are in the rectangle between drag-start and mouse + for (int posx = mapViewBasic.getMapMouseRightPos().x; Math.abs(posx - mapViewBasic.getMapMouseRightPos().x) + <= Math.abs(mapViewBasic.getHighlightOffset().x); posx += signX) { + for (int posy = mapViewBasic.getMapMouseRightPos().y; Math.abs(posy - mapViewBasic.getMapMouseRightPos().y) + <= Math.abs(mapViewBasic.getHighlightOffset().y); posy += signY) { + // Draw the Icon: + + // Rectangular view + mainControl.getMapSelIconX().paintIcon(this, grfx, posx * 32 + bOffset, posy * 32 + bOffset); + + if (signY == 0) { + break; + } + } + if (signX == 0) { + break; + } + } + } + + /** + * Returns the map location at the given point or null if no map + * location is at the point. + * @param point The coordinates in the renderer view. + * @return The map location. + */ + + // i'll change it to a fixed point... i want use this for mouse tracking + // and don't want have millions of mallocs here + // this should be reworked more intelligent later + public Point getTileLocationAt(final Point point) { + try { + renderTransform.inverseTransform(point, point); + } catch (final NoninvertibleTransformException e) { + } + mapViewBasic.setMapMousePos(-1, -1); + + final Point mpoint = new Point(); + mpoint.x = mapViewBasic.getMapMousePos().x; + mpoint.y = mapViewBasic.getMapMousePos().y; + if (point.x >= 0 && point.x < mapViewBasic.getMapSize().getWidth() * 32 && point.y >= 0 && point.y < mapViewBasic.getMapSize().getHeight() * 32) { + mapViewBasic.setMapMousePos(point.x / 32, point.y / 32); + } + + mpoint.x = mapViewBasic.getMapMousePos().x; + mpoint.y = mapViewBasic.getMapMousePos().y; + return mpoint; + } + + public boolean resizeBackBuffer() { + if (isPickmap) { + return false; + } + + final Size2D mapSize = mapControl.getMapSize(); + final Dimension size = new Dimension(mapSize.getWidth() * 32, mapSize.getHeight() * 32); + if (bufferedSize.equals(size)) { + return true; + } + bufferedSize.setSize(size); + + if (log.isDebugEnabled()) { + log.debug("Creating a backbuffer of size " + size.width + "x" + size.height + "."); + } + backBuffer = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); + final Graphics g = backBuffer.getGraphics(); + g.setColor(Color.YELLOW); + g.fillRect(0, 0, size.width, size.height); + + return true; + } + + /* (non-Javadoc) + * + * @see LevelRenderer#freeMapBuffer() + */ + public void freeBackBuffer() { + backBuffer = null; + tmpGrfx = null; + tmpIcon = null; + tmpImage = null; + } + +} Property changes on: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-01 21:49:33 UTC (rev 764) @@ -0,0 +1,53 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 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.map; + +import java.awt.Graphics; +import java.awt.Point; +import java.awt.image.BufferedImage; + +/** + * A lavel renderer, mainly used as central point interfac to iso and flat + * renderer + * @author tchize + */ +public interface LevelRenderer { + + void updateLookAndFeel(); + + BufferedImage getFullImage(); + + void paintTile(int x, int y); + + Point getTileLocationAt(Point point); + + boolean isPickmap(); + + void paintHighlightTile(Graphics grfx, int x, int y); + + void modelChanged(); + + void setHighlightTile(int x, int y); + + boolean resizeBackBuffer(); + + void freeBackBuffer(); +} Property changes on: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.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...> - 2006-12-01 21:30:37
|
Revision: 763 http://svn.sourceforge.net/gridarta/?rev=763&view=rev Author: akirschbaum Date: 2006-12-01 13:30:36 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Remove variable that is written but never read. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 20:14:29 UTC (rev 762) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 21:30:36 UTC (rev 763) @@ -108,8 +108,6 @@ private final Point mapMouseRightOff = new Point(); // offset from the selected tile while left-click draging - private final Point mapMousePosOff = new Point(); - private boolean highlightOn; // Is map-tile selection highlighted? true/false private final boolean[] needMpanelUpdate; // indicates that the mapArchPanel needs @@ -143,8 +141,6 @@ mapMouseRightPos.y = -1; mapMouseRightOff.x = 0; mapMouseRightOff.y = 0; - mapMousePosOff.x = -1; - mapMousePosOff.y = -1; if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); @@ -935,8 +931,6 @@ } mapMousePos.x = -1; mapMousePos.y = -1; - mapMousePosOff.x = -1; - mapMousePosOff.y = -1; final Point mpoint = new Point(); mpoint.x = mapMousePos.x; @@ -944,9 +938,6 @@ if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { mapMousePos.x = point.x / 32; mapMousePos.y = point.y / 32; - - mapMousePosOff.x = point.x % 32; - mapMousePosOff.y = point.y % 32; } mpoint.x = mapMousePos.x; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 20:14:30
|
Revision: 762 http://svn.sourceforge.net/gridarta/?rev=762&view=rev Author: akirschbaum Date: 2006-12-01 12:14:29 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Unify comment. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 20:11:21 UTC (rev 761) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 20:14:29 UTC (rev 762) @@ -88,6 +88,7 @@ /** The controller of this view. */ private final MapControl mapControl; + /** The CMainControl. */ private final CMainControl mainControl; /** Size of the map. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 20:11:21
|
Revision: 761 http://svn.sourceforge.net/gridarta/?rev=761&view=rev Author: akirschbaum Date: 2006-12-01 12:11:21 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Make variable final. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 20:08:55 UTC (rev 760) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-01 20:11:21 UTC (rev 761) @@ -86,7 +86,7 @@ private static final long serialVersionUID = 1L; /** The controller of this view. */ - protected final MapControl mapControl; + private final MapControl mapControl; private final CMainControl mainControl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-01 20:08:59
|
Revision: 760 http://svn.sourceforge.net/gridarta/?rev=760&view=rev Author: akirschbaum Date: 2006-12-01 12:08:55 -0800 (Fri, 01 Dec 2006) Log Message: ----------- Declare variable more local. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-11-30 22:02:41 UTC (rev 759) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-01 20:08:55 UTC (rev 760) @@ -371,11 +371,10 @@ * for default archetypes, and a clone for non-default archetypes. */ private void addArchToMap(final MapControl mapControl, final GameObject gameObject, final Point pos, final boolean allowDouble, final boolean fillBelow) { - final GameObject newHead; if (gameObject.isArchetype()) { mapControl.addArchToMap(gameObject.getArchetypeName(), pos, allowDouble, false, fillBelow); } else { - newHead = gameObject.createClone(pos.x, pos.y); + 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()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |