UI: fixed rare error with game end dialog;

This commit is contained in:
Oleg Agafonov 2020-01-14 18:21:45 +04:00
parent e768c375dc
commit 4c55fe701e

View file

@ -7,18 +7,6 @@
*/
package mage.client.dialog;
import java.awt.Color;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import mage.client.MageFrame;
import mage.client.game.GamePanel;
import mage.client.util.Format;
@ -28,8 +16,17 @@ import mage.client.util.gui.BufferedImageBuilder;
import mage.view.GameEndView;
import mage.view.PlayerView;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
*
* @author LevelX2
*/
public class GameEndDialog extends MageDialog {
@ -97,6 +94,7 @@ public class GameEndDialog extends MageDialog {
}
// get game log
try {
if (gameEndView.getMatchView().getGames().size() > 0) {
GamePanel gamePanel = MageFrame.getGame(gameEndView.getMatchView().getGames().get(gameEndView.getMatchView().getGames().size() - 1));
if (gamePanel != null) {
SimpleDateFormat sdf = new SimpleDateFormat();
@ -110,6 +108,7 @@ public class GameEndDialog extends MageDialog {
out.print(gamePanel.getGameLog());
out.close();
}
}
} catch (FileNotFoundException ex) {
JOptionPane.showMessageDialog(this, "Error while writing game log to file\n\n" + ex, "Error writing gamelog", JOptionPane.ERROR_MESSAGE);
}