From: <aki...@us...> - 2007-01-20 16:54:00
|
Revision: 1631 http://svn.sourceforge.net/gridarta/?rev=1631&view=rev Author: akirschbaum Date: 2007-01-20 08:54:00 -0800 (Sat, 20 Jan 2007) Log Message: ----------- Rename variable names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-20 14:54:18 UTC (rev 1630) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-20 16:54:00 UTC (rev 1631) @@ -382,8 +382,8 @@ */ private void selectEditType(final int newType) { // calculate the new type for all opened maps: - for (final MapControl level : levels) { - level.addEditType(newType); // calculate new type + for (final MapControl mapControl : levels) { + mapControl.addEditType(newType); // calculate new type } setTileEdit(newType); // activate the new type for all views @@ -647,10 +647,10 @@ // update the look and feel for all open map views if (!levels.isEmpty()) { - for (final MapControl level : levels) { - level.getMapViewFrame().updateLookAndFeel(); + for (final MapControl mapControl : levels) { + mapControl.getMapViewFrame().updateLookAndFeel(); if (log.isDebugEnabled()) { - log.debug("map " + level.getMapArchObject().getMapName()); + log.debug("map " + mapControl.getMapArchObject().getMapName()); } } } @@ -705,18 +705,18 @@ if (view) { setStatusText("Creating new map " + maparch.getMapDisplayName()); } - final MapControl map = new MapControl(this, objects, maparch, false, initial); - fireMapCreatedEvent(map); + final MapControl mapControl = new MapControl(this, objects, maparch, false, initial); + fireMapCreatedEvent(mapControl); if (view) { - map.addMapGridListener(mainActions); - map.addMapCursorListener(mainActions); - mainView.addLevelView(map.getMapViewFrame()); // one view... - map.getMapViewFrame().setAutoscrolls(true); - levels.add(map); - setCurrentLevel(map); + mapControl.addMapGridListener(mainActions); + mapControl.addMapCursorListener(mainActions); + mainView.addLevelView(mapControl.getMapViewFrame()); // one view... + mapControl.getMapViewFrame().setAutoscrolls(true); + levels.add(mapControl); + setCurrentLevel(mapControl); refreshMenusAndToolbars(); } - return map; + return mapControl; } /** Invoked when the user wants to close the current level. */ @@ -762,33 +762,33 @@ /** * Closes the given level, asking the user whether to save changes. - * @param level throws level to close + * @param mapControl throws level to close * @return <code>true</code> if the level was successfully closed, otherwise <code>false</code> */ - public boolean closeLevel(final MapControl level) { - return closeLevel(level, false); + public boolean closeLevel(final MapControl mapControl) { + return closeLevel(mapControl, false); } /** * Closes the given level, eventually asking the user whether to save changes. - * @param level the level to close + * @param mapControl the level to close * @param forced when true, user does not get asked and changes do not get saved * @return <code>true</code> if the level was successfully closed, otherwise <code>false</code> */ - public boolean closeLevel(final MapControl level, final boolean forced) { + public boolean closeLevel(final MapControl mapControl, final boolean forced) { - if (level == null) { + if (mapControl == null) { ACTION_FACTORY.showMessageDialog(mainView, "closeLevelNullLevel", levels.size(), currentMap); return false; } - if (!forced && level.isModified()) { - final int result = ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, "confirmSaveChanges", level.getMapArchObject().getMapDisplayName()); + if (!forced && mapControl.isModified()) { + final int result = ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, "confirmSaveChanges", mapControl.getMapArchObject().getMapDisplayName()); if (result == JOptionPane.YES_OPTION) { - if (level.isPlainSaveEnabled()) { - level.save(); + if (mapControl.isPlainSaveEnabled()) { + mapControl.save(); } else { - if (!saveLevelAsWanted(level)) { + if (!saveLevelAsWanted(mapControl)) { return false; } } @@ -797,17 +797,17 @@ } } - fireMapClosingEvent(level); + fireMapClosingEvent(mapControl); - if (level.isPickmap()) { + if (mapControl.isPickmap()) { // special case: close a pickmap - mainView.getPickmapChooserControl().closePickmap(level); - level.levelCloseNotify(); + mainView.getPickmapChooserControl().closePickmap(mapControl); + mapControl.levelCloseNotify(); } else { // Notify the level about the closing - level.levelCloseNotify(); - mainView.removeLevelView(level.getMapViewFrame()); - levels.remove(level); + mapControl.levelCloseNotify(); + mainView.removeLevelView(mapControl.getMapViewFrame()); + levels.remove(mapControl); if (!levels.isEmpty()) { // get next open map we can find and set it to currentMap @@ -919,18 +919,18 @@ } archetypeParser.sortTempList(objects); // sort the list (put multiparts at the end) - final MapControl control = newLevel(objects, maparch, show, initial); // init the map + final MapControl mapControl = newLevel(objects, maparch, show, initial); // init the map - control.setMapFile(file); - control.setMapFileName(file.getPath()); + mapControl.setMapFile(file); + mapControl.setMapFileName(file.getPath()); if (show) { // finally, show the map and refresh toolbars - control.setActiveEditType(tileEdit); // map is loaded with current view settings - control.resetModified(); + mapControl.setActiveEditType(tileEdit); // map is loaded with current view settings + mapControl.resetModified(); refreshMenusAndToolbars(); } - return control; + return mapControl; } /** @@ -1031,11 +1031,11 @@ /** * Invoked when user wants to save a level to certain file. - * @param level map control of the map to be saved + * @param mapControl map control of the map to be saved * @return <code>true</code> if the user confirmed saving the map and the map was saved successfully, otherwise <code>false</code> */ - public boolean saveLevelAsWanted(final MapControl level) { - if (level == null) { + public boolean saveLevelAsWanted(final MapControl mapControl) { + if (mapControl == null) { log.warn(ACTION_FACTORY.getString("logSaveLevelAsWithNull")); return false; } @@ -1053,10 +1053,10 @@ } // if file already exists, select it - if (level.getMapFile() != null && level.getMapFile().exists()) { - fileChooser.setSelectedFile(level.getMapFile()); + if (mapControl.getMapFile() != null && mapControl.getMapFile().exists()) { + fileChooser.setSelectedFile(mapControl.getMapFile()); } else { - fileChooser.setSelectedFile(new File(mapDir, level.getMapFileName())); + fileChooser.setSelectedFile(new File(mapDir, mapControl.getMapFileName())); } final int returnVal = fileChooser.showSaveDialog(mainView); @@ -1064,7 +1064,7 @@ hasChangedDir = true; // user has chosen an active dir final File file = fileChooser.getSelectedFile(); if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - level.saveAs(file); + mapControl.saveAs(file); currentDir = fileChooser.getCurrentDirectory(); refreshMenusAndToolbars(); @@ -1173,11 +1173,11 @@ /** * Shows the given levels properties. - * @param level The level whose properties we want. + * @param mapControl The level whose properties we want. */ - void showMapProperties(final MapControl level) { - if (level != null) { - MapPropertiesDialog.showDialog(mainView, this, level); + void showMapProperties(final MapControl mapControl) { + if (mapControl != null) { + MapPropertiesDialog.showDialog(mainView, this, mapControl); } } @@ -1265,7 +1265,7 @@ return; } - final MapControl oldmap = currentMap; // store old map control + final MapControl oldMapControl = currentMap; // store old map control openFile(newfile); // open the new map if (exitPos.x == 0 && exitPos.y == 0) { @@ -1278,7 +1278,7 @@ // Update the main view so the new map instantly pops up. mainView.update(mainView.getGraphics()); - closeLevel(oldmap, false); // close the old map + closeLevel(oldMapControl, false); // close the old map } if (log.isDebugEnabled()) { log.debug("exit: '" + path + "' " + exitPos.x + ", " + exitPos.y); @@ -1342,12 +1342,12 @@ return; } - final MapControl oldmap = currentMap; // store old map control + final MapControl oldMapControl = currentMap; // store old map control openFile(newfile); // open the new map // set viewport view on the new map final JViewport newViewPort = currentMap.getMapViewFrame().getViewPort(); - final JViewport oldViewPort = oldmap.getMapViewFrame().getViewPort(); + final JViewport oldViewPort = oldMapControl.getMapViewFrame().getViewPort(); final Rectangle scrollto; // new vieport rect if (direction == IGUIConstants.SOUTH) { @@ -1380,7 +1380,7 @@ // Update the main view so the new map instantly pops up. mainView.update(mainView.getGraphics()); - closeLevel(oldmap, false); // close the old map + closeLevel(oldMapControl, false); // close the old map } } @@ -1399,12 +1399,12 @@ * @param map <code>MapControl</code> of the new current map. */ - public void setCurrentLevel(final MapControl map) { - if (currentMap == map) { + public void setCurrentLevel(final MapControl mapControl) { + if (currentMap == mapControl) { return; } - currentMap = map; + currentMap = mapControl; refreshMenusAndToolbars(); //StatusBar.getInstance().setLevelInfo(level); @@ -1454,11 +1454,11 @@ /** Invoked when user wants to revert the current map to previously saved state. */ public void revert() { - final MapControl modmap = currentMap; // "modified map" to be reverted - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", modmap.getMapFileName())) { - final File mfile = modmap.getMapFile(); // store file - final Point initial = modmap.getViewPosition(); - closeLevel(modmap, true); // close the old map + final MapControl mapControl = currentMap; // "modified map" to be reverted + if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", mapControl.getMapFileName())) { + final File mfile = mapControl.getMapFile(); // store file + final Point initial = mapControl.getViewPosition(); + closeLevel(mapControl, true); // close the old map openFile(mfile, true, initial); // open the new map // Update the main view so the new map instantly pops up. Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2007-01-20 14:54:18 UTC (rev 1630) +++ trunk/daimonin/src/daieditor/CMainControl.java 2007-01-20 16:54:00 UTC (rev 1631) @@ -568,8 +568,8 @@ if (state) { alphaType |= v; // XXX THIS IS A BAD HACK - for (final MapControl level : levels) { - level.addEditType(v); // calculate new type + for (final MapControl mapControl : levels) { + mapControl.addEditType(v); // calculate new type } } else { alphaType &= ~v; @@ -636,10 +636,10 @@ * @return map of file <var>path</var> or <code>null</code> if map not open */ @Nullable public MapControl getMapIfOpened(final String path) { - for (final MapControl level : levels) { + for (final MapControl mapControl : levels) { try { - if (level.getMapFile() != null && level.getMapFile().getCanonicalPath().compareTo(path) == 0) { - return level; + if (mapControl.getMapFile() != null && mapControl.getMapFile().getCanonicalPath().compareTo(path) == 0) { + return mapControl; } } catch (final IOException e) { // ignore, get next map @@ -653,10 +653,10 @@ * @param path path to map file */ public void saveMapIfOpened(final String path) { - for (final MapControl level : levels) { + for (final MapControl mapControl : levels) { try { - if (level.getMapFile().getCanonicalPath().compareTo(path) == 0) { - level.save(); + if (mapControl.getMapFile().getCanonicalPath().compareTo(path) == 0) { + mapControl.save(); return; } } catch (final IOException e) { @@ -873,17 +873,17 @@ if (view) { setStatusText("Creating new map " + maparch.getMapName()); } - final MapControl map = new MapControl(this, objects, maparch, false, view); - fireMapCreatedEvent(map); - levels.add(map); + final MapControl mapControl = new MapControl(this, objects, maparch, false, view); + fireMapCreatedEvent(mapControl); + levels.add(mapControl); if (view) { - map.addMapGridListener(mainActions); - map.addMapCursorListener(mainActions); - setCurrentLevel(map); + mapControl.addMapGridListener(mainActions); + mapControl.addMapCursorListener(mainActions); + setCurrentLevel(mapControl); refreshMenusAndToolbars(); } - map.getMapModel().addMapModelListener(this); - return map; + mapControl.getMapModel().addMapModelListener(this); + return mapControl; } /** Invoked when the user wants to close the current level. */ @@ -933,33 +933,33 @@ /** * Closes the given level, asking the user whether to save changes. - * @param level throws level to close + * @param mapControl throws level to close * @return <code>true</code> if the level was successfully closed, otherwise <code>false</code> */ - public boolean closeLevel(final MapControl level) { - return closeLevel(level, false); + public boolean closeLevel(final MapControl mapControl) { + return closeLevel(mapControl, false); } /** * Closes the given level, eventually asking the user whether to save changes. - * @param level the level to close + * @param mapControl the level to close * @param forced when true, user does not get asked and changes do not get saved * @return <code>true</code> if the level was successfully closed, otherwise <code>false</code> */ - public boolean closeLevel(final MapControl level, final boolean forced) { + public boolean closeLevel(final MapControl mapControl, final boolean forced) { - if (level == null) { + if (mapControl == null) { ACTION_FACTORY.showMessageDialog(mainView, "closeLevelNullLevel", levels.size(), currentMap); return false; } - if (!forced && level.isModified()) { - final int result = ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, "confirmSaveChanges", level.getMapArchObject().getMapDisplayName()); + if (!forced && mapControl.isModified()) { + final int result = ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, "confirmSaveChanges", mapControl.getMapArchObject().getMapDisplayName()); if (result == JOptionPane.YES_OPTION) { - if (level.isPlainSaveEnabled()) { - level.save(); + if (mapControl.isPlainSaveEnabled()) { + mapControl.save(); } else { - if (!saveLevelAsWanted(level)) { + if (!saveLevelAsWanted(mapControl)) { return false; } } @@ -968,19 +968,19 @@ } } - fireMapClosingEvent(level); + fireMapClosingEvent(mapControl); - if (level.isPickmap()) { + if (mapControl.isPickmap()) { // special case: close a pickmap - mainView.getPickmapChooserControl().closePickmap(level); - level.levelCloseNotify(); + mainView.getPickmapChooserControl().closePickmap(mapControl); + mapControl.levelCloseNotify(); } else { // Notify the level about the closing - level.levelCloseNotify(); - while (level.getMapViewFrame() != null) { - level.closeView(level.getMapViewFrame()); + mapControl.levelCloseNotify(); + while (mapControl.getMapViewFrame() != null) { + mapControl.closeView(mapControl.getMapViewFrame()); } - levels.remove(level); + levels.remove(mapControl); if (!levels.isEmpty()) { // get next open map we can find and set it to currentMap @@ -1117,15 +1117,15 @@ // If so, return the previously loaded map. try { final File can = file.getCanonicalFile(); - for (final MapControl level : levels) { - final File levelFile = level.getMapFile(); + for (final MapControl mapControl : levels) { + final File levelFile = mapControl.getMapFile(); if (levelFile != null && can.equals(levelFile.getCanonicalFile())) { if (view) { - level.createView(); - setCurrentLevel(level); - setCurrentLevelView(level.getMapViewFrame()); + mapControl.createView(); + setCurrentLevel(mapControl); + setCurrentLevelView(mapControl.getMapViewFrame()); } - return level; + return mapControl; } } } catch (final IOException e) { @@ -1138,18 +1138,18 @@ final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile final MapArchObject maparch = decoder.getMapArch(); // get map arch // go to ArchetypeParser and add the default arch list information to them - final MapControl newMap = newLevel(objects, maparch, view); // init the map + final MapControl newMapControl = newLevel(objects, maparch, view); // init the map // finally, show the map and refresh toolbars - newMap.setMapFile(file); - newMap.setMapFileName(file.getPath()); - newMap.setActiveEditType(tileEdit); // map is loaded with current view settings - newMap.resetModified(); + newMapControl.setMapFile(file); + newMapControl.setMapFileName(file.getPath()); + newMapControl.setActiveEditType(tileEdit); // map is loaded with current view settings + newMapControl.resetModified(); if (view) { refreshMenusAndToolbars(); addRecent(currentMap.getMapArchObject().getMapDisplayName(), file.toString()); } - return newMap; + return newMapControl; } finally { decoder.close(); } @@ -1253,11 +1253,11 @@ /** * Invoked when user wants to save a level to certain file. - * @param level map control of the map to be saved + * @param mapControl map control of the map to be saved * @return <code>true</code> if the user confirmed saving the map and the map was saved successfully, otherwise <code>false</code> */ - public boolean saveLevelAsWanted(final MapControl level) { - if (level == null) { + public boolean saveLevelAsWanted(final MapControl mapControl) { + if (mapControl == null) { log.warn(ACTION_FACTORY.getString("logSaveLevelAsWithNull")); return false; } @@ -1278,10 +1278,10 @@ } // if file already exists, select it - if (level.getMapFile() != null && level.getMapFile().exists()) { - fileChooser.setSelectedFile(level.getMapFile()); + if (mapControl.getMapFile() != null && mapControl.getMapFile().exists()) { + fileChooser.setSelectedFile(mapControl.getMapFile()); } else { - fileChooser.setSelectedFile(new File(mapDir, level.getMapFileName())); + fileChooser.setSelectedFile(new File(mapDir, mapControl.getMapFileName())); } final int returnVal = fileChooser.showSaveDialog(mainView); @@ -1289,7 +1289,7 @@ hasChangedDir = true; // user has chosen an active dir final File file = fileChooser.getSelectedFile(); if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - level.saveAs(file); + mapControl.saveAs(file); currentDir = fileChooser.getCurrentDirectory(); refreshMenusAndToolbars(); @@ -1384,11 +1384,11 @@ /** * Shows the given levels properties. - * @param level The level whose properties we want. + * @param mapControl The level whose properties we want. */ - void showMapProperties(final MapControl level) { - if (level != null) { - MapPropertiesDialog.showDialog(mainView, this, level); + void showMapProperties(final MapControl mapControl) { + if (mapControl != null) { + MapPropertiesDialog.showDialog(mainView, this, mapControl); } } @@ -1566,7 +1566,7 @@ // file path is added every time we use a ../ or a ./ . // This results in giant file names like "xx/../yy/../xx/../yy/.." // and after some times in buffer overflows. - final MapControl oldmap = currentMap; + final MapControl oldMapControl = currentMap; final boolean newFileOpened; try { newFileOpened = openFile(newfile.getCanonicalFile()); @@ -1582,7 +1582,7 @@ currentMap.getMapViewFrame().setHotspot(d); // set hotspot TODO set cursor instead if (newFileOpened && JOptionPane.YES_OPTION == ACTION_FACTORY.showOnetimeConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose")) { // only close current level if a new file was opened and user wants to close it - closeLevel(oldmap); // close the old map + closeLevel(oldMapControl); // close the old map } } @@ -1601,12 +1601,12 @@ * @param map <code>MapControl</code> of the new current map. */ - public void setCurrentLevel(final MapControl map) { - if (currentMap == map) { + public void setCurrentLevel(final MapControl mapControl) { + if (currentMap == mapControl) { return; } - currentMap = map; + currentMap = mapControl; refreshMenusAndToolbars(); //StatusBar.getInstance().setLevelInfo(level); @@ -1656,10 +1656,10 @@ /** Invoked when user wants to revert the current map to previously saved state. */ public void revert() { - final MapControl modmap = currentMap; // "modified map" to be reverted - if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", modmap.getMapFileName())) { - final File mfile = modmap.getMapFile(); // store file - closeLevel(modmap, true); // close the old map + final MapControl modMapControl = currentMap; // "modified map" to be reverted + if (ACTION_FACTORY.showQuestionDialog(mainView, "confirmRevertMap", modMapControl.getMapFileName())) { + final File mfile = modMapControl.getMapFile(); // store file + closeLevel(modMapControl, true); // close the old map openFile(mfile); // open the new map // Update the main view so the new map instantly pops up. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |