mirror of https://github.com/FreeCol/freecol.git
Map editor: A new game is now always loaded before importing or generating a new map. This fixes lots of issues caused by stuff from the old map leaking into the new one.
This commit is contained in:
parent
16b98ecf42
commit
8e4c9c7ed9
|
@ -27,13 +27,13 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
import net.sf.freecol.FreeCol;
|
||||
import net.sf.freecol.client.ClientOptions;
|
||||
import net.sf.freecol.client.FreeColClient;
|
||||
import net.sf.freecol.client.gui.GUI;
|
||||
import net.sf.freecol.client.gui.panel.MiniMap; // FIXME: should go away
|
||||
|
@ -282,11 +282,14 @@ public final class MapEditorController extends FreeColClientHolder {
|
|||
*/
|
||||
public void newMap() {
|
||||
final FreeColServer freeColServer = getFreeColServer();
|
||||
final ServerGame serverGame = freeColServer.getGame();
|
||||
|
||||
getGUI().removeInGameComponents();
|
||||
getGUI().showMapGeneratorOptionsDialog(true, mgo -> {
|
||||
if (mgo != null) {
|
||||
final ServerGame serverGame = new ServerGame(getDefaultSpecification(), new Random());
|
||||
getFreeColClient().getFreeColServer().setGame(serverGame);
|
||||
getFreeColClient().setGame(serverGame);
|
||||
|
||||
serverGame.setMapGeneratorOptions(mgo);
|
||||
freeColServer.generateMap(false);
|
||||
requireNativeNations(serverGame);
|
||||
|
|
|
@ -21,12 +21,14 @@ package net.sf.freecol.client.gui.action;
|
|||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Random;
|
||||
|
||||
import net.sf.freecol.client.ClientOptions;
|
||||
import net.sf.freecol.client.FreeColClient;
|
||||
import net.sf.freecol.client.gui.GUI;
|
||||
import net.sf.freecol.common.model.Map;
|
||||
import net.sf.freecol.common.model.Tile;
|
||||
import net.sf.freecol.server.model.ServerGame;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -65,11 +67,18 @@ public class NewEmptyMapAction extends MapboardAction {
|
|||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
Dimension size = getGUI().showMapSizeDialog();
|
||||
if (size == null) return;
|
||||
Map map = getFreeColClient().getFreeColServer()
|
||||
.generateEmptyMap(size.width, size.height);
|
||||
Tile tile = map.getTile(size.width/2, size.height/2);
|
||||
final Dimension size = getGUI().showMapSizeDialog();
|
||||
if (size == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final FreeColClient fcc = getFreeColClient();
|
||||
final ServerGame game = new ServerGame(fcc.getMapEditorController().getDefaultSpecification(), new Random());
|
||||
fcc.getFreeColServer().setGame(game);
|
||||
fcc.setGame(game);
|
||||
|
||||
final Map map = fcc.getFreeColServer().generateEmptyMap(size.width, size.height);
|
||||
final Tile tile = map.getTile(size.width/2, size.height/2);
|
||||
getGUI().removeInGameComponents();
|
||||
getGUI().startMapEditorGUI();
|
||||
getGUI().refresh();
|
||||
|
|
Loading…
Reference in New Issue