本文整理汇总了Java中net.sf.freecol.common.option.FileOption类的典型用法代码示例。如果您正苦于以下问题:Java FileOption类的具体用法?Java FileOption怎么用?Java FileOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileOption类属于net.sf.freecol.common.option包,在下文中一共展示了FileOption类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testImport
点赞 3
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
public void testImport() {
File file = ServerTestHelper.createRandomSaveGame();
ServerTestHelper.stopServer();
FreeColServer server = ServerTestHelper.startServer(false, true);
FileOption importOption = server.getSpecification()
.getMapGeneratorOptions()
.getOption(MapGeneratorOptions.IMPORT_FILE, FileOption.class);
importOption.setValue(file);
try {
server.startGame();
} catch (FreeColException e) {
fail(e.getMessage());
}
importOption.setValue(null);
assertEquals(FreeColServer.ServerState.IN_GAME,
server.getServerState());
assertNotNull(server.getGame());
assertNotNull(server.getGame().getMap());
file.delete();
assertFalse(file.exists());
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:24,
代码来源:SaveLoadTest.java
示例2: testWithNoIndians
点赞 3
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
public void testWithNoIndians() {
((FileOption) spec().getOption(MapGeneratorOptions.IMPORT_FILE)).setValue(null);
Game g = new ServerGame(spec());
g.setNationOptions(new NationOptions(spec(), Advantages.SELECTABLE));
// A new game does not have a map yet
assertEquals(null, g.getMap());
MapGenerator gen = new SimpleMapGenerator(new Random(1), spec());
for (Nation n : spec().getNations()) {
if (n.getType().isEuropean() && !n.getType().isREF()) {
g.addPlayer(new ServerPlayer(g, n.getType().getNameKey(), false, n, null, null));
}
}
try {
gen.createMap(g);
} catch (FreeColException e) {
fail();
}
// Check that the map is created at all
assertNotNull(g.getMap());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:27,
代码来源:MapGeneratorTest.java
示例3: testImportMap
点赞 3
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
public void testImportMap() {
/**
* Make sure we can import all distributed maps.
*/
Game g = new ServerGame(spec());
MapGenerator gen = new SimpleMapGenerator(new Random(1), spec());
File mapDir = new File("data/maps/");
for (File importFile : mapDir.listFiles()) {
if (importFile.getName().endsWith(".fsg")) {
((FileOption) gen.getMapGeneratorOptions().getOption(MapGeneratorOptions.IMPORT_FILE))
.setValue(importFile);
try {
gen.createMap(g);
} catch (FreeColException e) {
e.printStackTrace();
fail("Failed to import file " + importFile.getName());
}
}
}
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:21,
代码来源:MapGeneratorTest.java
示例4: testImport
点赞 3
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
public void testImport() {
File file = ServerTestHelper.createRandomSaveGame();
ServerTestHelper.stopServer(server);
server = ServerTestHelper.startServer(false, true);
MapGenerator mapGenerator = server.getMapGenerator();
((FileOption) mapGenerator.getMapGeneratorOptions()
.getOption(MapGeneratorOptions.IMPORT_FILE)).setValue(file);
Controller c = server.getController();
assertNotNull(c);
assertTrue(c instanceof PreGameController);
PreGameController pgc = (PreGameController)c;
try {
pgc.startGame();
} catch (FreeColException e) {
fail(e.getMessage());
}
((FileOption) mapGenerator.getMapGeneratorOptions()
.getOption(MapGeneratorOptions.IMPORT_FILE)).setValue(null);
assertEquals(FreeColServer.GameState.IN_GAME, server.getGameState());
assertNotNull(server.getGame());
assertNotNull(server.getGame().getMap());
file.delete();
assertFalse(file.exists());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:27,
代码来源:SaveLoadTest.java
示例5: getOptionUI
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
/**
* Get an option UI for a given option.
*
* @param gui The {@code GUI} to use.
* @param option The {@code Option} to check.
* @param editable Should the result be editable.
* @return A suitable {@code OptionUI}, or null if none found.
*/
public static OptionUI getOptionUI(GUI gui, Option option, boolean editable) {
if (option instanceof BooleanOption) {
return new BooleanOptionUI((BooleanOption)option, editable);
} else if (option instanceof FileOption) {
return new FileOptionUI(gui, (FileOption)option, editable);
} else if (option instanceof PercentageOption) {
return new PercentageOptionUI((PercentageOption)option, editable);
} else if (option instanceof RangeOption) {
return new RangeOptionUI((RangeOption)option, editable);
} else if (option instanceof SelectOption) {
return new SelectOptionUI((SelectOption)option, editable);
} else if (option instanceof IntegerOption) {
return new IntegerOptionUI((IntegerOption)option, editable);
} else if (option instanceof StringOption) {
return new StringOptionUI((StringOption)option, editable);
} else if (option instanceof LanguageOption) {
return new LanguageOptionUI((LanguageOption)option, editable);
} else if (option instanceof AudioMixerOption) {
return new AudioMixerOptionUI(gui, (AudioMixerOption)option, editable);
} else if (option instanceof FreeColAction) {
return new FreeColActionUI((FreeColAction)option, editable);
} else if (option instanceof AbstractUnitOption) {
return new AbstractUnitOptionUI((AbstractUnitOption)option, editable);
} else if (option instanceof ModOption) {
return new ModOptionUI((ModOption)option, editable);
} else if (option instanceof UnitListOption) {
return new ListOptionUI<>(gui, (UnitListOption)option, editable);
} else if (option instanceof ModListOption) {
return new ListOptionUI<>(gui, (ModListOption)option, editable);
} else if (option instanceof TextOption) {
return new TextOptionUI((TextOption)option, editable);
} else {
return null;
}
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:44,
代码来源:OptionUI.java
示例6: setFile
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
private void setFile(File file) {
OptionGroup group = getGroup();
((FileOption) group.getOption(MapGeneratorOptions.IMPORT_FILE)).setValue(file);
group.setBoolean(MapGeneratorOptions.IMPORT_RUMOURS, false);
group.setBoolean(MapGeneratorOptions.IMPORT_TERRAIN, true);
group.setBoolean(MapGeneratorOptions.IMPORT_BONUSES, false);
getOptionUI().reset();
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:10,
代码来源:MapGeneratorOptionsDialog.java
示例7: getOptionUI
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static OptionUI getOptionUI(GUI gui, Option option, boolean editable) {
if (option instanceof BooleanOption) {
return new BooleanOptionUI(gui, (BooleanOption) option, editable);
} else if (option instanceof FileOption) {
return new FileOptionUI(gui, (FileOption) option, editable);
} else if (option instanceof PercentageOption) {
return new PercentageOptionUI(gui, (PercentageOption) option, editable);
} else if (option instanceof RangeOption) {
return new RangeOptionUI(gui, (RangeOption) option, editable);
} else if (option instanceof SelectOption) {
return new SelectOptionUI(gui, (SelectOption) option, editable);
} else if (option instanceof IntegerOption) {
return new IntegerOptionUI(gui, (IntegerOption) option, editable);
} else if (option instanceof StringOption) {
return new StringOptionUI(gui, (StringOption) option, editable);
} else if (option instanceof LanguageOption) {
return new LanguageOptionUI(gui, (LanguageOption) option, editable);
} else if (option instanceof AudioMixerOption) {
return new AudioMixerOptionUI(gui, (AudioMixerOption) option, editable);
} else if (option instanceof FreeColAction) {
return new FreeColActionUI(gui, (FreeColAction) option, editable);
} else if (option instanceof AbstractUnitOption) {
return new AbstractUnitOptionUI(gui, (AbstractUnitOption) option, editable);
} else if (option instanceof ModOption) {
return new ModOptionUI(gui, (ModOption) option, editable);
} else if (option instanceof UnitListOption) {
return new ListOptionUI(gui, (UnitListOption) option, editable);
} else if (option instanceof ModListOption) {
return new ListOptionUI(gui, (ModListOption) option, editable);
} else {
return null;
}
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:35,
代码来源:OptionUI.java
示例8: buildGameMenu
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
private void buildGameMenu() {
// --> Game
JMenu menu = new JMenu(Messages.message("menuBar.game"));
menu.setOpaque(false);
menu.setMnemonic(KeyEvent.VK_G);
menu.add(getMenuItem(NewAction.id));
menu.add(getMenuItem(NewEmptyMapAction.id));
menu.addSeparator();
menu.add(getMenuItem(OpenAction.id));
menu.add(getMenuItem(SaveAction.id));
JMenuItem playItem = new JMenuItem(Messages.message("startGame"));
playItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
File saveGameFile = new File(FreeColDirectories.getAutosaveDirectory(), "tempMap.fsg");
OptionGroup options = freeColClient.getGame().getMapGeneratorOptions();
FileOption fileOption = (FileOption) options.getOption(MapGeneratorOptions.IMPORT_FILE);
fileOption.setValue(saveGameFile);
freeColClient.getMapEditorController().saveGame(saveGameFile);
freeColClient.newGame();
}
});
menu.add(playItem);
menu.addSeparator();
menu.add(getMenuItem(PreferencesAction.id));
menu.addSeparator();
menu.add(getMenuItem(ShowMainAction.id));
menu.add(getMenuItem(SaveAndQuitAction.id));
add(menu);
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:37,
代码来源:MapEditorMenuBar.java
示例9: createMap
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
/**
* Creates a map given for a game.
*
* @param game The <code>Game</code> to use.
* @see net.sf.freecol.server.generator.MapGenerator#createMap(net.sf.freecol.common.model.Game)
*/
public void createMap(Game game) throws FreeColException {
// Prepare imports:
final File importFile = ((FileOption) getMapGeneratorOptions()
.getOption(MapGeneratorOptions.IMPORT_FILE)).getValue();
final Game importGame;
if (importFile != null) {
Game g = null;
try {
logger.info("Importing file " + importFile.getPath());
g = FreeColServer.readGame(new FreeColSavegameFile(importFile),
game.getSpecification(), null);
} catch (IOException ioe) {
g = null;
}
importGame = g;
} else {
importGame = null;
}
// Create land map.
boolean[][] landMap;
if (importGame != null) {
landMap = LandGenerator.importLandMap(importGame);
} else {
landMap = landGenerator.createLandMap();
}
// Create terrain:
terrainGenerator.createMap(game, importGame, landMap);
Map map = game.getMap();
if (game.getSpecification().getBoolean("model.option.importSettlements")) {
importIndianSettlements(map, importGame);
} else {
createIndianSettlements(map, game.getPlayers());
}
createLostCityRumours(map, importGame);
createEuropeanUnits(map, game.getPlayers());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:46,
代码来源:SimpleMapGenerator.java
示例10: testSinglePlayerOnSmallMap
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
public void testSinglePlayerOnSmallMap() {
((FileOption) spec().getOption(MapGeneratorOptions.IMPORT_FILE)).setValue(null);
Game g = new ServerGame(spec());
g.setNationOptions(new NationOptions(spec(), Advantages.SELECTABLE));
// A new game does not have a map yet
assertEquals(null, g.getMap());
MapGenerator gen = new SimpleMapGenerator(new Random(1), spec());
Nation nation = spec().getNation("model.nation.dutch");
g.addPlayer(new ServerPlayer(g, nation.getType().getNameKey(), false, nation, null, null));
try {
gen.createMap(g);
} catch (FreeColException e) {
fail();
}
// Check that the map is created at all
assertNotNull(g.getMap());
assertEquals(gen.getMapGeneratorOptions().getInteger("model.option.mapWidth"),
g.getMap().getWidth());
assertEquals(gen.getMapGeneratorOptions().getInteger("model.option.mapHeight"),
g.getMap().getHeight());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:30,
代码来源:MapGeneratorTest.java
示例11: actionPerformed
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
/**
* This function analyses an event and calls the right methods to take care
* of the user's requests.
*
* @param event The incoming ActionEvent.
*/
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
try {
switch (Integer.valueOf(command).intValue()) {
case START:
int row = table.getSelectedRow();
int col = table.getSelectedColumn();
if (row > -1 && col > -1){
table.getCellEditor(row, col).stopCellEditing();
}
if (!checkVictoryConditions()) break;
// The ready flag was set to false for single player
// mode in order to allow the player to change
// whatever he wants.
if (singlePlayerGame) {
getMyPlayer().setReady(true);
}
getFreeColClient().getPreGameController().requestLaunch();
break;
case CANCEL:
getFreeColClient().getConnectController().quitGame(true);
getGUI().removeFromCanvas(this);
getGUI().showNewPanel();
break;
case READY:
getFreeColClient().getPreGameController()
.setReady(readyBox.isSelected());
refreshPlayersTable();
break;
case CHAT:
if (chat.getText().trim().length() > 0) {
getFreeColClient().getPreGameController()
.chat(chat.getText());
displayChat(getMyPlayer().getName(), chat.getText(), false);
chat.setText("");
}
break;
case GAME_OPTIONS:
getGUI().showGameOptionsDialog(getFreeColClient().isAdmin(), true);
break;
case MAP_GENERATOR_OPTIONS:
OptionGroup mgo = getFreeColClient().getGame()
.getMapGeneratorOptions();
FileOption importFile = (FileOption) mgo.getOption(MapGeneratorOptions.IMPORT_FILE);
boolean loadCustomOptions = (importFile.getValue() == null);
getGUI().showMapGeneratorOptionsDialog(mgo, getFreeColClient().isAdmin(),
loadCustomOptions);
break;
default:
logger.warning("Invalid Actioncommand: invalid number.");
}
} catch (NumberFormatException e) {
logger.warning("Invalid Actioncommand: not a number.");
}
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:65,
代码来源:StartGamePanel.java
示例12: testRegions
点赞 2
import net.sf.freecol.common.option.FileOption; //导入依赖的package包/类
public void testRegions() {
// Reset import file option value (set by previous tests)
((FileOption) spec().getOption(MapGeneratorOptions.IMPORT_FILE)).setValue(null);
Game game = new ServerGame(spec());
MapGenerator gen = new SimpleMapGenerator(new Random(1), spec());
try {
gen.createMap(game);
} catch (FreeColException e) {
fail();
}
Map map = game.getMap();
Region pacific = map.getRegion("model.region.pacific");
assertNotNull(pacific);
assertTrue(pacific.isPacific());
assertEquals(pacific, pacific.getDiscoverableRegion());
Region southPacific = map.getRegion("model.region.southPacific");
assertNotNull(southPacific);
assertFalse(southPacific.isDiscoverable());
assertTrue(southPacific.isPacific());
assertEquals(pacific, southPacific.getParent());
assertEquals(pacific, southPacific.getDiscoverableRegion());
pacific.discover(new Player(game, "id"), new Turn(1), "someName");
assertFalse(pacific.isDiscoverable());
assertNull(pacific.getDiscoverableRegion());
assertFalse(southPacific.isDiscoverable());
assertTrue(southPacific.isPacific());
assertEquals(pacific, southPacific.getParent());
assertNull(southPacific.getDiscoverableRegion());
Region atlantic = map.getRegion("model.region.atlantic");
assertNotNull(atlantic);
assertFalse(atlantic.isPacific());
assertFalse(atlantic.isDiscoverable());
assertNull(atlantic.getDiscoverableRegion());
Region northAtlantic = map.getRegion("model.region.northAtlantic");
assertNotNull(northAtlantic);
assertFalse(northAtlantic.isPacific());
assertFalse(northAtlantic.isDiscoverable());
assertNull(northAtlantic.getDiscoverableRegion());
}
开发者ID:vishal-mittal,
项目名称:SOEN6471-FreeCol,
代码行数:47,
代码来源:MapGeneratorTest.java