* Some minor changes to game end window.

This commit is contained in:
LevelX2 2018-03-13 18:01:26 +01:00
parent 537f7dd1ae
commit bd56b074a0
3 changed files with 41 additions and 35 deletions

View file

@ -233,6 +233,7 @@
</Component>
<Component class="javax.swing.JLabel" name="txtDurationGame">
<Properties>
<Property name="text" type="java.lang.String" value="Duration Game"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,18 +20,17 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
/*
* GameEndDialog.java
*
* Created on Jul 31, 2013, 9:41:00 AM
*/
package mage.client.dialog;
import java.awt.Color;
@ -63,19 +62,21 @@ public class GameEndDialog extends MageDialog {
private final DateFormat df = DateFormat.getDateTimeInstance();
/** Creates new form GameEndDialog
* @param gameEndView */
/**
* Creates new form GameEndDialog
*
* @param gameEndView
*/
public GameEndDialog(GameEndView gameEndView) {
initComponents();
this.modal = true;
pnlText.setOpaque(true);
pnlText.setBackground(new Color(240,240,240,140));
pnlText.setBackground(new Color(240, 240, 240, 140));
Rectangle r = new Rectangle(610, 250);
Image image = ImageHelper.getImageFromResources(gameEndView.hasWon() ?"/game_won.jpg":"/game_lost.jpg");
Image image = ImageHelper.getImageFromResources(gameEndView.hasWon() ? "/game_won.jpg" : "/game_lost.jpg");
BufferedImage imageResult = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
ImageIcon icon = new ImageIcon(imageResult);
lblResultImage.setIcon(icon);
@ -90,15 +91,15 @@ public class GameEndDialog extends MageDialog {
}
// game duration
txtDurationGame.setText(Format.getDuration(gameEndView.getStartTime(), gameEndView.getEndTime()));
txtDurationGame.setToolTipText(new StringBuilder(df.format(gameEndView.getStartTime())).append(" - ").append(df.format(gameEndView.getEndTime())).toString() );
txtDurationGame.setText(" " + Format.getDuration(gameEndView.getStartTime(), gameEndView.getEndTime()));
txtDurationGame.setToolTipText(new StringBuilder(df.format(gameEndView.getStartTime())).append(" - ").append(df.format(gameEndView.getEndTime())).toString());
// match duration
Calendar cal = Calendar.getInstance();
txtDurationMatch.setText(Format.getDuration(gameEndView.getMatchView().getStartTime(), cal.getTime()));
txtDurationMatch.setToolTipText(new StringBuilder(df.format(gameEndView.getMatchView().getStartTime())).append(" - ").append(df.format(cal.getTime())).toString() );
txtDurationMatch.setText(" " + Format.getDuration(gameEndView.getMatchView().getStartTime(), cal.getTime()));
txtDurationMatch.setToolTipText(new StringBuilder(df.format(gameEndView.getMatchView().getStartTime())).append(" - ").append(df.format(cal.getTime())).toString());
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(" ");
for (PlayerView player : gameEndView.getPlayers()) {
sb.append(player.getName()).append(" Life: ").append(player.getLife()).append(' ');
}
@ -117,15 +118,15 @@ public class GameEndDialog extends MageDialog {
String dir = "gamelogs";
File saveDir = new File(dir);
//Here comes the existence check
if(!saveDir.exists()) {
if (!saveDir.exists()) {
saveDir.mkdirs();
}
// get game log
try {
GamePanel gamePanel = MageFrame.getGame(gameEndView.getMatchView().getGames().get(gameEndView.getMatchView().getGames().size()-1));
try {
GamePanel gamePanel = MageFrame.getGame(gameEndView.getMatchView().getGames().get(gameEndView.getMatchView().getGames().size() - 1));
if (gamePanel != null) {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.applyPattern( "yyyyMMdd_HHmmss" );
sdf.applyPattern("yyyyMMdd_HHmmss");
String fileName = new StringBuilder(dir).append(File.separator)
.append(sdf.format(gameEndView.getStartTime()))
.append('_').append(gameEndView.getMatchView().getGameType())
@ -146,10 +147,10 @@ public class GameEndDialog extends MageDialog {
this.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -223,6 +224,7 @@ public class GameEndDialog extends MageDialog {
lblDurationGame.setText("Duration game:");
txtDurationGame.setText("Duration Game");
txtDurationGame.setBorder(javax.swing.BorderFactory.createEtchedBorder());
lblLife.setText("Life at end:");
@ -290,7 +292,11 @@ public class GameEndDialog extends MageDialog {
tabPane.addTab("Statistics", tabStatistics);
btnOk.setText("OK");
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -27,7 +27,6 @@
*/
package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
@ -65,8 +64,8 @@ public class GameEndView implements Serializable {
// set result message
int winner = 0;
Player you = null;
for (Player player: state.getPlayers().values()) {
PlayerView playerView = new PlayerView(player, state, game, playerId, null);
for (Player player : state.getPlayers().values()) {
PlayerView playerView = new PlayerView(player, state, game, playerId, null);
if (playerView.getPlayerId().equals(playerId)) {
clientPlayer = playerView;
you = player;
@ -79,11 +78,11 @@ public class GameEndView implements Serializable {
}
if (you != null) {
if (you.hasWon()) {
gameInfo = new StringBuilder("You won the game on turn ").append(game.getTurnNum()).append('.').toString();
gameInfo = "You won the game on turn " + game.getTurnNum() + ".";
} else if (winner > 0) {
gameInfo = new StringBuilder("You lost the game on turn ").append(game.getTurnNum()).append('.').toString();
gameInfo = "You lost the game on turn " + game.getTurnNum() + ".";
} else {
gameInfo = new StringBuilder("Game is a draw on Turn ").append(game.getTurnNum()).append('.').toString();
gameInfo = "Game is a draw on Turn " + game.getTurnNum() + ".";
}
}
matchView = new MatchView(table);
@ -92,7 +91,7 @@ public class GameEndView implements Serializable {
MatchPlayer matchWinner = null;
winsNeeded = match.getOptions().getWinsNeeded();
StringBuilder additonalText = new StringBuilder();
for (MatchPlayer matchPlayer: match.getPlayers()) {
for (MatchPlayer matchPlayer : match.getPlayers()) {
if (matchPlayer.getPlayer().equals(you)) {
wins = matchPlayer.getWins();
}
@ -127,7 +126,7 @@ public class GameEndView implements Serializable {
matchInfo = new StringBuilder(matchWinner.getName()).append(" won the match!").toString();
}
} else {
matchInfo = new StringBuilder("You need ").append(winsNeeded - wins == 1 ? "one more win ":winsNeeded - wins + " more wins ").append("to win the match.").toString();
matchInfo = new StringBuilder("You need ").append(winsNeeded - wins == 1 ? "one more win " : winsNeeded - wins + " more wins ").append("to win the match.").toString();
}
additionalInfo = additonalText.toString();