本文整理汇总了Java中net.sf.freecol.client.FreeColClient类的典型用法代码示例。如果您正苦于以下问题:Java FreeColClient类的具体用法?Java FreeColClient怎么用?Java FreeColClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FreeColClient类属于net.sf.freecol.client包,在下文中一共展示了FreeColClient类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: requestLogin
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Request this client log in to <i>host:port</i>.
*
* @param user The name of the player to use.
* @param host The name of the machine running the {@code FreeColServer}.
* @param port The port to use when connecting to the host.
* @return True if the player was already logged in, or if the login
* message was sent.
*/
public boolean requestLogin(String user, String host, int port) {
final FreeColClient fcc = getFreeColClient();
if (fcc.isLoggedIn()) return true;
fcc.setMapEditor(false);
// Clean up any old connections
askServer().disconnect();
// Establish the full connection here
StringTemplate err = connect(user, host, port);
if (err == null) {
// Ask the server to log in a player with the given user
// name. Control effectively transfers through the server
// back to PGIH.login() and then to login() below.
logger.info("Login request for client " + FreeCol.getName());
if (askServer().login(user, FreeCol.getVersion(),
fcc.getSinglePlayer(),
fcc.currentPlayerIsMyPlayer())) {
return true;
}
err = StringTemplate.template("server.couldNotLogin");
}
getGUI().showErrorMessage(err);
return false;
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:35,
代码来源:ConnectController.java
示例2: startSinglePlayerGame
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Starts a new single player game by connecting to the server.
*
* FIXME: connect client/server directly (not using network-classes)
*
* @param spec The {@code Specification} for the game.
* @return True if the game starts successfully.
*/
public boolean startSinglePlayerGame(Specification spec) {
final FreeColClient fcc = getFreeColClient();
fcc.setMapEditor(false);
if (!fcc.unblockServer(FreeCol.getServerPort())) return false;
if (fcc.isLoggedIn()) { // Should not happen, warn and suppress
logger.warning("startSinglePlayer while logged in!");
requestLogout(LogoutReason.LOGIN);
}
// Load the player mods into the specification that is about to be
// used to initialize the server.
//
// ATM we only allow mods in single player games.
// FIXME: allow in stand alone server starts?
List<FreeColModFile> mods = getClientOptions().getActiveMods();
spec.loadMods(mods);
Messages.loadActiveModMessageBundle(mods, FreeCol.getLocale());
FreeColServer fcs = fcc.startServer(false, true, spec, -1);
return (fcs == null) ? false
: requestLogin(FreeCol.getName(),
fcs.getHost(), fcs.getPort());
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:34,
代码来源:ConnectController.java
示例3: newGame
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Reset to the NewPanel (except in the map editor).
*/
public void newGame() {
final FreeColClient fcc = getFreeColClient();
if (fcc.isMapEditor()) {
fcc.getMapEditorController().newMap();
return;
}
if (fcc.isLoggedIn()) {
if (getGUI().confirmStopGame()) {
requestLogout(LogoutReason.NEW_GAME);
}
return;
}
fcc.stopServer();
getGUI().removeInGameComponents();
getGUI().showNewPanel(null);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:23,
代码来源:ConnectController.java
示例4: clientHandler
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final Player player = getPlayer(game);
final String text = getMessage();
final boolean isPrivate = isPrivate();
if (player == null || text == null) return;
if (freeColClient.isInGame()) {
igc(freeColClient).chatHandler(player, text, isPrivate);
} else {
pgc(freeColClient).chatHandler(player, text, isPrivate);
}
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:19,
代码来源:ChatMessage.java
示例5: dumpTile
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Debug action to dump a tile to stderr.
*
* Called from tile popup menu.
* Not concerned with i18n for stderr output.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param tile The {@code Tile} to dump.
*/
public static void dumpTile(final FreeColClient freeColClient,
final Tile tile) {
final FreeColServer server = freeColClient.getFreeColServer();
final Game game = freeColClient.getGame();
final Game sGame = server.getGame();
final Player player = freeColClient.getMyPlayer();
System.err.println("\nClient (" + game.getClientUserName()
+ "/" + player.getId() + "):");
tile.save(System.err, WriteScope.toClient(player), true);
System.err.println("\n\nServer:");
Tile sTile = sGame.getFreeColGameObject(tile.getId(), Tile.class);
sTile.save(System.err, WriteScope.toServer(), true);
System.err.println("\n\nSave:");
sTile.save(System.err, WriteScope.toSave(), true);
System.err.println('\n');
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:27,
代码来源:DebugUtils.java
示例6: skipTurns
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Debug action to skip turns.
*
* Called from the debug menu.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public static void skipTurns(FreeColClient freeColClient) {
freeColClient.skipTurns(0); // Clear existing skipping
String response = freeColClient.getGUI().getInput(null,
StringTemplate.key("prompt.selectTurnsToSkip"),
Integer.toString(10), "ok", "cancel");
if (response == null || response.isEmpty()) return;
int skip;
try {
skip = Integer.parseInt(response);
} catch (NumberFormatException nfe) {
skip = -1;
}
if (skip > 0) freeColClient.skipTurns(skip);
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:24,
代码来源:DebugUtils.java
示例7: addImmigration
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Debug action to add immigration.
*
* Called from the debug menu.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public static void addImmigration(final FreeColClient freeColClient) {
final FreeColServer server = freeColClient.getFreeColServer();
final GUI gui = freeColClient.getGUI();
final Player player = freeColClient.getMyPlayer();
final Game sGame = server.getGame();
final Player sPlayer = sGame.getFreeColGameObject(player.getId(),
Player.class);
String response = gui.getInput(null,
StringTemplate.template("prompt.selectImmigration"),
Integer.toString(100), "ok", "cancel");
if (response == null || response.isEmpty()) return;
int crosses;
try {
crosses = Integer.parseInt(response);
} catch (NumberFormatException x) {
return;
}
player.modifyImmigration(crosses);
sPlayer.modifyImmigration(crosses);
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:30,
代码来源:DebugUtils.java
示例8: clientHandler
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final Player player = freeColClient.getMyPlayer();
final Unit unit = getUnit(game);
final Colony colony = getColony(game);
final GoodsType goodsType = getType(game);
final int amount = getAmount();
if (unit == null) {
logger.warning("IndianDemand with null unit.");
return;
}
if (colony == null) {
logger.warning("IndianDemand with null colony");
return;
} else if (!player.owns(colony)) {
throw new IllegalArgumentException("Demand to anothers colony");
}
igc(freeColClient).indianDemandHandler(unit, colony, goodsType, amount);
clientGeneric(freeColClient);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:27,
代码来源:IndianDemandMessage.java
示例9: MapSizeDialog
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a dialog to choose the map size.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
*/
public MapSizeDialog(FreeColClient freeColClient, JFrame frame) {
super(freeColClient, frame);
JLabel widthLabel = Utility.localizedLabel("width");
widthLabel.setLabelFor(inputWidth);
JLabel heightLabel = Utility.localizedLabel("height");
heightLabel.setLabelFor(inputHeight);
MigPanel panel = new MigPanel(new MigLayout("wrap 2"));
panel.add(Utility.localizedHeader("mapSizeDialog.mapSize", true),
"span, align center");
panel.add(widthLabel, "newline 20");
panel.add(inputWidth);
panel.add(heightLabel);
panel.add(inputHeight);
initializeInputDialog(frame, true, panel, null, "ok", "cancel");
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:26,
代码来源:MapSizeDialog.java
示例10: SaveDialog
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a dialog to choose a file to load.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param directory The directory to display when choosing the file.
* @param fileFilters The available file filters in the dialog.
* @param defaultName Name of the default save game file.
*/
public SaveDialog(FreeColClient freeColClient, JFrame frame,
File directory, FileFilter[] fileFilters, String defaultName) {
super(freeColClient, frame);
final JFileChooser fileChooser = new JFileChooser(directory);
if (fileFilters.length > 0) {
for (FileFilter fileFilter : fileFilters) {
fileChooser.addChoosableFileFilter(fileFilter);
}
fileChooser.setFileFilter(fileFilters[0]);
fileChooser.setAcceptAllFileFilterUsed(false);
}
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setFileHidingEnabled(false);
fileChooser.setSelectedFile(new File(defaultName));
fileChooser.addActionListener((ActionEvent ae) ->
setValue((JFileChooser.APPROVE_SELECTION
.equals(ae.getActionCommand()))
? fileChooser.getSelectedFile() : cancelFile));
List<ChoiceItem<File>> c = choices();
initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:34,
代码来源:SaveDialog.java
示例11: GameOptionsDialog
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a game options dialog.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param editable Whether the game options can be modified.
* @param custom Whether to load custom options.
*/
public GameOptionsDialog(FreeColClient freeColClient, JFrame frame,
boolean editable, boolean custom) {
super(freeColClient, frame, editable,
freeColClient.getGame().getGameOptions(), GameOptions.TAG,
FreeColDirectories.GAME_OPTIONS_FILE_NAME, GameOptions.TAG);
if (isEditable()) loadDefaultOptions();
// Set special cases
// Disable victory option "All humans defeated"
// when playing single player
if (isEditable() && freeColClient.getSinglePlayer()) {
BooleanOptionUI comp = (BooleanOptionUI) getOptionUI()
.getOptionUI(GameOptions.VICTORY_DEFEAT_HUMANS);
if (comp != null) {
comp.setValue(false);
comp.getComponent().setEnabled(false);
}
}
initialize(frame, choices());
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:31,
代码来源:GameOptionsDialog.java
示例12: clientHandler
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final Player winner = getWinner(game);
final String highScore = getScore();
if (winner == null) {
logger.warning("Invalid player for gameEnded");
return;
}
FreeColDebugger.finishDebugRun(freeColClient, true);
if (winner != freeColClient.getMyPlayer()) return;
igc(freeColClient).gameEndedHandler(highScore);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:19,
代码来源:GameEndedMessage.java
示例13: clientHandler
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final String id = getStringAttribute(ID_TAG);
if (id == null) {
logger.warning("Partial update is missing identifier attribute");
return;
}
FreeColGameObject fcgo = game.getFreeColGameObject(id);
if (fcgo == null) {
logger.warning("Partial update of missing object: " + id);
return;
}
if (freeColClient.isInGame()) {
igc(freeColClient).partialHandler(fcgo, getStringAttributeMap());
} else {
logger.warning("Partial update when not in game.");
}
clientGeneric(freeColClient);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:26,
代码来源:PartialMessage.java
示例14: animateUnitAttack
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void animateUnitAttack(Unit attacker, Unit defender,
Tile attackerTile, Tile defenderTile,
boolean success) {
// Note: we used to focus the map on the unit even when
// animation is off as long as the center-active-unit option
// was set. However IR#115 requested that if animation is off
// that we display nothing so as to speed up the other player
// moves as much as possible.
final FreeColClient fcc = getFreeColClient();
if (fcc.getAnimationSpeed(attacker.getOwner()) <= 0
&& fcc.getAnimationSpeed(defender.getOwner()) <= 0) return;
if (!Animations.unitAttack(fcc, attacker, defender,
attackerTile, defenderTile, success)) {
logger.warning("Attack animation failure: " + attacker
+ " v " + defender);
}
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:23,
代码来源:SwingGUI.java
示例15: clientHandler
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final Stance stance = getStance();
final Player p1 = getFirstPlayer(game);
final Player p2 = getSecondPlayer(game);
if (p1 == null) {
logger.warning("Invalid player1 for setStance");
return;
}
if (p2 == null) {
logger.warning("Invalid player2 for setStance");
return;
}
igc(freeColClient).setStanceHandler(stance, p1, p2);
clientGeneric(freeColClient);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:23,
代码来源:SetStanceMessage.java
示例16: ReportProductionPanel
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* The constructor that will add the items to this panel.
*
* FIXME: can we extend this to cover farmed goods?
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public ReportProductionPanel(FreeColClient freeColClient) {
super(freeColClient, "reportProductionAction");
this.goodsTypes = transform(getSpecification().getGoodsTypeList(),
gt -> !gt.isFarmed());
List<String> goodsNames = transform(this.goodsTypes, alwaysTrue(),
gt -> Messages.getName(gt));
goodsNames.add(0, Messages.message("nothing"));
String[] model = goodsNames.toArray(new String[0]);
for (int index = 0; index < NUMBER_OF_GOODS; index++) {
JComboBox<String> newBox = new JComboBox<>(model);
newBox.setSelectedIndex(0);
this.boxes.add(newBox);
}
reportPanel.setLayout(new MigLayout("gap 0 0", "[fill]", "[fill]"));
update();
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:26,
代码来源:ReportProductionPanel.java
示例17: mainTitle
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Reset to the MainPanel.
*
* Called from ShowMainAction.
*/
public void mainTitle() {
final FreeColClient fcc = getFreeColClient();
if (fcc.isMapEditor()) fcc.setMapEditor(false);
if (fcc.isLoggedIn()) {
if (getGUI().confirmStopGame()) {
requestLogout(LogoutReason.MAIN_TITLE);
}
return;
}
fcc.stopServer();
getGUI().removeInGameComponents();
getGUI().mainTitle();
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:22,
代码来源:ConnectController.java
示例18: addLiberty
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Debug action to add liberty to the player colonies.
*
* Called from the debug menu.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public static void addLiberty(final FreeColClient freeColClient) {
final FreeColServer server = freeColClient.getFreeColServer();
final GUI gui = freeColClient.getGUI();
final Player player = freeColClient.getMyPlayer();
final Game sGame = server.getGame();
String response = gui.getInput(null,
StringTemplate.template("prompt.selectLiberty"),
Integer.toString(100), "ok", "cancel");
if (response == null || response.isEmpty()) return;
int liberty;
try {
liberty = Integer.parseInt(response);
} catch (NumberFormatException x) {
return;
}
for (Colony c : player.getColonyList()) {
c.addLiberty(liberty);
sGame.getFreeColGameObject(c.getId(), Colony.class)
.addLiberty(liberty);
}
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:31,
代码来源:DebugUtils.java
示例19: animateUnitAttack
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void animateUnitAttack(Unit attacker, Unit defender,
Tile attackerTile, Tile defenderTile,
boolean success) {
// Note: we used to focus the map on the unit even when
// animation is off as long as the center-active-unit option
// was set. However IR#115 requested that if animation is off
// that we display nothing so as to speed up the other player
// moves as much as possible.
final FreeColClient fcc = getFreeColClient();
if (fcc.getAnimationSpeed(attacker.getOwner()) <= 0
&& fcc.getAnimationSpeed(defender.getOwner()) <= 0) return;
Animations.unitAttack(fcc, attacker, defender,
attackerTile, defenderTile, success);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:20,
代码来源:SwingGUI.java
示例20: resetMoves
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Debug action to reset the moves left of the units on a tile.
*
* Called from tile popup menu.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param units The {@code Unit}s to reactivate.
*/
public static void resetMoves(final FreeColClient freeColClient,
List<Unit> units) {
final FreeColServer server = freeColClient.getFreeColServer();
final Game sGame = server.getGame();
final GUI gui = freeColClient.getGUI();
boolean first = true;
for (Unit u : units) {
Unit su = sGame.getFreeColGameObject(u.getId(), Unit.class);
u.setMovesLeft(u.getInitialMovesLeft());
su.setMovesLeft(su.getInitialMovesLeft());
if (first) {
gui.setActiveUnit(u);
first = false;
}
for (Unit u2 : u.getUnitList()) {
Unit su2 = sGame.getFreeColGameObject(u2.getId(), Unit.class);
u2.setMovesLeft(u2.getInitialMovesLeft());
su2.setMovesLeft(su2.getInitialMovesLeft());
}
}
gui.refresh();
gui.resetMenuBar();
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:33,
代码来源:DebugUtils.java
示例21: showClientOptionsDialog
点赞 3
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void showClientOptionsDialog() {
OptionGroup group = null;
try {
group = canvas.showClientOptionsDialog();
} finally {
resetMenuBar();
if (group != null) {
// Immediately redraw the minimap if that was updated.
updateMapControls();
}
}
FreeColClient fcc = getFreeColClient();
if (fcc.isMapEditor()) {
startMapEditorGUI();
} else if (fcc.isInGame()) {
; // do nothing
} else {
showMainPanel(null); // back to the main panel
}
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:25,
代码来源:SwingGUI.java
示例22: WarehouseDialog
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a dialog to display the warehouse.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param colony The {@code Colony} containing the warehouse.
*/
public WarehouseDialog(FreeColClient freeColClient, JFrame frame,
Colony colony) {
super(freeColClient, frame);
warehousePanel = new MigPanel(new MigLayout("wrap 4"));
warehousePanel.setOpaque(false);
for (GoodsType type : freeColClient.getGame().getSpecification()
.getStorableGoodsTypeList()) {
warehousePanel.add(new WarehouseGoodsPanel(freeColClient,
colony, type));
}
JScrollPane scrollPane = new JScrollPane(warehousePanel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
scrollPane.getViewport().setOpaque(false);
scrollPane.setBorder(null);
MigPanel panel = new MigPanel(new MigLayout("fill, wrap 1", "", ""));
panel.add(Utility.localizedHeader(Messages.nameKey("warehouseDialog"), false),
"align center");
panel.add(scrollPane, "grow");
panel.setSize(panel.getPreferredSize());
ImageIcon icon = new ImageIcon(
getImageLibrary().getSmallSettlementImage(colony));
initializeConfirmDialog(frame, true, panel, icon, "ok", "cancel");
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:37,
代码来源:WarehouseDialog.java
示例23: createMenuBar
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
public JMenuBar createMenuBar() {
JMenuBar menuBar = null;
FreeColClient client = new FreeColClient(null, null);
client.startClient(null, null, true, true, null, null);
//Create the menu bar.
menuBar = new InGameMenuBar(client, null);
client.updateActions();
((FreeColMenuBar)menuBar).update();
return menuBar;
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:14,
代码来源:FreeColMenuTest.java
示例24: ColopediaGameObjectTypePanel
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Create a new Colopedia game object type panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param colopediaPanel The parent {@code ColopediaPanel}.
* @param id The panel type identifier.
*/
protected ColopediaGameObjectTypePanel(FreeColClient freeColClient,
ColopediaPanel colopediaPanel,
String id) {
super(freeColClient);
this.colopediaPanel = colopediaPanel;
this.id = "colopediaAction." + id;
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:16,
代码来源:ColopediaGameObjectTypePanel.java
示例25: DeclarationPanel
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a DeclarationPanel.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public DeclarationPanel(FreeColClient freeColClient) {
super(freeColClient, null);
Image image = ResourceManager.getImage("image.flavor.Declaration");
setSize(image.getWidth(null), image.getHeight(null));
setOpaque(false);
setBorder(null);
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent k) {
getGUI().removeFromCanvas(DeclarationPanel.this);
}
});
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
getGUI().removeFromCanvas(DeclarationPanel.this);
}
});
final SignaturePanel signaturePanel = new SignaturePanel();
signaturePanel.initialize(getMyPlayer().getName());
signaturePanel.setLocation((getWidth()-signaturePanel.getWidth()) / 2,
(getHeight() + SIGNATURE_Y - signaturePanel.getHeight()) / 2 - 15);
signaturePanel.addActionListener(this);
add(signaturePanel);
Timer t = new Timer(START_DELAY, (ActionEvent ae) -> {
signaturePanel.startAnimation();
});
t.setRepeats(false);
t.start();
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:40,
代码来源:DeclarationPanel.java
示例26: MapGeneratorOptionsDialog
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a dialog to set the map generator options.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param editable Whether the options may be edited.
*/
public MapGeneratorOptionsDialog(FreeColClient freeColClient, JFrame frame,
boolean editable) {
super(freeColClient, frame, editable,
freeColClient.getGame().getMapGeneratorOptions(),
MapGeneratorOptions.TAG,
FreeColDirectories.MAP_GENERATOR_OPTIONS_FILE_NAME,
MapGeneratorOptions.TAG);
if (isEditable()) {
loadDefaultOptions();
// FIXME: The update should be solved by PropertyEvent.
final List<File> mapFiles = FreeColDirectories.getMapFileList();
JPanel mapPanel = new JPanel();
for (File f : mapFiles) {
JButton mapButton = makeMapButton(f);
if (mapButton == null) continue;
mapButton.addActionListener((ActionEvent ae) -> {
updateFile(f);
});
mapPanel.add(mapButton);
}
JScrollPane scrollPane = new JScrollPane(mapPanel,
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
scrollPane.getViewport().setOpaque(false);
// FIXME: find out how to do this properly
scrollPane.setMinimumSize(new Dimension(400, 110));
panel.add(scrollPane);
}
initialize(frame, choices());
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:42,
代码来源:MapGeneratorOptionsDialog.java
示例27: MapViewer
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* The constructor to use.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
MapViewer(FreeColClient freeColClient) {
super(freeColClient);
this.gui = (SwingGUI)getGUI();
this.size = null;
tv = new TileViewer(freeColClient);
setImageLibraryAndUpdateData(new ImageLibrary());
cursor = null;
unitsOutForAnimation = new HashMap<>();
unitsOutForAnimationLabels = new HashMap<>();
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:20,
代码来源:MapViewer.java
示例28: changeOwnership
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Debug action to change ownership of a unit.
*
* Called from tile popup menu.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param unit The {@code Unit} to take ownership of.
*/
public static void changeOwnership(final FreeColClient freeColClient,
final Unit unit) {
final FreeColServer server = freeColClient.getFreeColServer();
final GUI gui = freeColClient.getGUI();
final Game game = unit.getGame();
final Function<Player, ChoiceItem<Player>> mapper = p ->
new ChoiceItem<Player>(Messages.message(p.getCountryLabel()), p);
Player player = gui.getChoice(null,
StringTemplate.template("prompt.selectOwner"), "cancel",
transform(game.getLivePlayers(),
p -> unit.getType().isAvailableTo(p), mapper,
Comparator.naturalOrder()));
if (player == null || unit.getOwner() == player) return;
final Game sGame = server.getGame();
ServerUnit sUnit = sGame.getFreeColGameObject(unit.getId(),
ServerUnit.class);
ServerPlayer sPlayer = sGame.getFreeColGameObject(player.getId(),
ServerPlayer.class);
server.getInGameController().debugChangeOwner(sUnit, sPlayer);
Player myPlayer = freeColClient.getMyPlayer();
if (unit.getOwner() == myPlayer) {
gui.setActiveUnit(unit);
} else {
freeColClient.getInGameController().nextActiveUnit();
}
gui.refresh();
gui.resetMenuBar();
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:40,
代码来源:DebugUtils.java
示例29: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final List<FoundingFather> fathers = getFathers(game);
igc(freeColClient).chooseFoundingFatherHandler(fathers);
clientGeneric(freeColClient);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:12,
代码来源:ChooseFoundingFatherMessage.java
示例30: OptionsDialog
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* The constructor that will add the items to this panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param editable Whether the dialog is editable.
* @param group The {@code OptionGroup} to display.
* @param headerKey The message identifier for the header.
* @param defaultFileName The name of the default file to back
* this dialog with.
* @param optionGroupId The identifier for the overall option group.
*/
protected OptionsDialog(FreeColClient freeColClient, JFrame frame,
boolean editable, OptionGroup group, String headerKey,
String defaultFileName, String optionGroupId) {
super(freeColClient, frame);
this.editable = editable;
this.group = group;
this.ui = new OptionGroupUI(getGUI(), this.group, this.editable);
this.defaultFileName = defaultFileName;
this.optionGroupId = optionGroupId;
preparePanel(headerKey, this.ui);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:25,
代码来源:OptionsDialog.java
示例31: getSkin
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Get a skin for this panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @return A skin image.
*/
private static BufferedImage getSkin(FreeColClient freeColClient) {
Player player = freeColClient.getMyPlayer();
String key = (player == null) ? "image.skin.InformationPanel"
: (player.isRebel()) ? "image.skin.InformationPanel.rebel"
: "image.skin.InformationPanel." + player.getNationResourceKey();
if (!ResourceManager.hasImageResource(key))
key = "image.skin.InformationPanel";
return ResourceManager.getImage(key);
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:16,
代码来源:InformationPanel.java
示例32: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final Specification spec = game.getSpecification();
final OptionGroup mapOptions = getMapGeneratorOptions();
if (freeColClient.isInGame()) {
; // Ignore
} else {
pgc(freeColClient).updateMapGeneratorOptionsHandler(mapOptions);
}
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:16,
代码来源:UpdateMapGeneratorOptionsMessage.java
示例33: LoadDialog
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates a dialog to choose a file to load.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param directory The directory to display when choosing the file.
* @param fileFilters The available file filters in the dialog.
*/
public LoadDialog(FreeColClient freeColClient, JFrame frame,
File directory, FileFilter[] fileFilters) {
super(freeColClient, frame);
final JFileChooser fileChooser = new JFileChooser(directory);
if (fileFilters.length > 0) {
for (FileFilter fileFilter : fileFilters) {
fileChooser.addChoosableFileFilter(fileFilter);
}
fileChooser.setFileFilter(fileFilters[0]);
fileChooser.setAcceptAllFileFilterUsed(false);
}
fileChooser.setControlButtonsAreShown(true);
fileChooser.setApproveButtonText(Messages.message("ok"));
//fileChooser.setCancelButtonText(Messages.message("cancel"));
fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setFileHidingEnabled(false);
fileChooser.addActionListener((ActionEvent ae) -> {
final String cmd = ae.getActionCommand();
File value = (JFileChooser.APPROVE_SELECTION.equals(cmd))
? ((JFileChooser)ae.getSource()).getSelectedFile()
: cancelFile;
setValue(value);
});
List<ChoiceItem<File>> c = choices();
initializeDialog(frame, DialogType.QUESTION, true, fileChooser, null, c);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:38,
代码来源:LoadDialog.java
示例34: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final StringTemplate template = getTemplate();
final String message = getMessage();
if (freeColClient.isInGame()) {
igc(freeColClient).errorHandler(template, message);
clientGeneric(freeColClient);
} else {
pgc(freeColClient).errorHandler(template, message);
}
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:16,
代码来源:ErrorMessage.java
示例35: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final List<String> vacant = getVacantPlayers();
freeColClient.setVacantPlayerNames(vacant);
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:10,
代码来源:VacantPlayersMessage.java
示例36: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void clientHandler(FreeColClient freeColClient) {
final Game game = freeColClient.getGame();
final int n = getMigrants();
if (n <= 0) {
logger.warning("Invalid migrants attribute: " + n);
return;
}
igc(freeColClient).fountainOfYouthHandler(n);
clientGeneric(freeColClient);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:16,
代码来源:FountainOfYouthMessage.java
示例37: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient)
throws FreeColException {
final Game game = freeColClient.getGame();
final Player player = getPlayer(game);
if (player == null) {
throw new FreeColException("Invalid player: "
+ getStringAttribute(PLAYER_TAG));
}
igc(freeColClient).setCurrentPlayerHandler(player);
clientGeneric(freeColClient);
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:18,
代码来源:SetCurrentPlayerMessage.java
示例38: StatisticsPanel
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* Creates the statistics panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param serverStatistics A map of key,value pairs of server statistics.
* @param clientStatistics A map of key,value pairs of client statistics.
*/
public StatisticsPanel(FreeColClient freeColClient,
Map<String, String> serverStatistics,
Map<String, String> clientStatistics) {
super(freeColClient, new BorderLayout());
// Title
JPanel header = new JPanel();
this.add(header, BorderLayout.PAGE_START);
header.add(Utility.localizedLabel("statistics"), JPanel.CENTER_ALIGNMENT);
// Actual stats panel
JPanel statsPanel = new JPanel(new GridLayout(1,2));
JScrollPane scrollPane = new JScrollPane(statsPanel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
// correct way to make scroll pane opaque
scrollPane.getViewport().setOpaque(false);
scrollPane.setBorder(null);
this.add(scrollPane,BorderLayout.CENTER);
statsPanel.add(displayStatsMessage("client", clientStatistics));
statsPanel.add(displayStatsMessage("server", serverStatistics));
add(okButton, BorderLayout.PAGE_END);
setSize(getPreferredSize());
}
开发者ID:FreeCol,
项目名称:freecol,
代码行数:35,
代码来源:StatisticsPanel.java
示例39: clientHandler
点赞 2
import net.sf.freecol.client.FreeColClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void clientHandler(FreeColClient freeColClient) {
final int turn = getTurnNumber();
if (turn < 0) {
logger.warning("Invalid turn for newTurn: "
+ Integer.toString(turn) );
return;
}
igc(freeColClient).newTurnHandler(turn);
clientGeneric(freeColClient);
}
开发者ID:wintertime,
项目名称:FreeCol,
代码行数:17,
代码来源:NewTurnMessage.java