Commit d540545b authored by YuFan Jia's avatar YuFan Jia 💤
Browse files

Merge branch 'Back' into 'Front'

Back

See merge request !13
parents 3fb07063 c14c7efd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@ public class ChessPanel extends BasicComponent {
    private int col;
    private static int size = 8;
    private ChessPiece playersChess;
    ImageIcon emptyImg = new ImageIcon("Model/empty.png");
    ImageIcon whiteImg = new ImageIcon("Model/white1.png");
    ImageIcon blackImg = new ImageIcon("Model/black1.png");
    ImageIcon emptyImg = new ImageIcon("Resources/empty.png");
    ImageIcon whiteImg = new ImageIcon("Resources/white1.png");
    ImageIcon blackImg = new ImageIcon("Resources/black1.png");
    ImageIcon image;

    ChessPanel(int row, int col) {
+0 −3
Original line number Diff line number Diff line
@@ -65,9 +65,6 @@ public class GameCore {
            this.currentPlayer = ChessPiece.BLACK;
        }
        ChessGameUI.thisStatus.setCurrentPlayer(currentPlayer);
        // todo:complete status panel
        // statusPanel.setPlayerText(currentPlayer.name());
        // statusPanel.setScoreText(blackScore, whiteScore);
    }

    public void zoom(int outerWidth, int outHeight) {// 缩放
+5 −1
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@ public class BasicBackground {
	public static StartMenuUI thisStartMenuUI;
	public static JFrame backFrame;

	public static Font standardFont(int size) {
		return new Font("Calibri", Font.PLAIN, size);
	}

	public BasicBackground() {
		initComponents();
		thisChessGameUI = new ChessGameUI();
@@ -34,7 +38,7 @@ public class BasicBackground {
			backFrame.setTitle("Othello");
			backFrame.setName("backFrame");
			Container basicContentPane = backFrame.getContentPane();
			basicContentPane.setPreferredSize(new Dimension(700, 500));
			basicContentPane.setPreferredSize(new Dimension(500, 300));
			backFrame.pack();
			backFrame.setLocationRelativeTo(null);
		}
+15 −7
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ package GameUI;
import java.awt.*;
import java.awt.event.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.DecimalFormat;

import javax.swing.*;
@@ -42,16 +43,19 @@ public class ChessGameUI extends JPanel {
			thisGameCore.setImportpath(tem);
	}

	private void exportButtonActionPerformed() throws FileNotFoundException {// export按钮触发事件
	private void exportButtonActionPerformed() throws IOException {// export按钮触发事件
		String tem = new FileChooser(false).Path();
		if (tem != null) {
			thisGameCore.setImportpath(tem);
			thisGameCore.setExportPath(tem);
		}
	}

	private void restartButtonActionPerformed() {// restart按钮触发事件
		OpinionPanel tem = new OpinionPanel("Are you sure to restart the game?", "Waing", JOptionPane.OK_CANCEL_OPTION);
		if (tem.clickYes()) {
			thisGameCore.restart();
		}
	}

	private void undoButtonActionPerformed() {// undo按钮触发事件
		thisGameCore.undo();
@@ -68,10 +72,13 @@ public class ChessGameUI extends JPanel {
	}

	private void menuBUttonActionPerformed() {
		JOptionPane.showConfirmDialog(null, "Are you sure to exit to menu?", "Waring", 2);
		OpinionPanel tem = new OpinionPanel("Are you sure to exit to the menu?", "Warning",
				JOptionPane.OK_CANCEL_OPTION);
		if (tem.clickYes()) {
			BasicBackground.backFrame.remove(BasicBackground.thisChessGameUI);
			BasicBackground.changePanel(BasicBackground.thisStartMenuUI);
		}
	}

	// private void cheatListener(ItemEvent e) {// 上面出发后弹出的选项卡的触发事件
	// String select = e.getItem().toString();
@@ -149,7 +156,8 @@ public class ChessGameUI extends JPanel {
				exportButton.addActionListener(e -> {
					try {
						exportButtonActionPerformed();
					} catch (FileNotFoundException e1) {

					} catch (IOException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
+19 −0
Original line number Diff line number Diff line
package GameUI;

import javax.swing.JOptionPane;

public class OpinionPanel extends JOptionPane {
    private int flag;

    OpinionPanel(String word, String title, int buttonType) {
        flag = showConfirmDialog(null, word, title, buttonType);
    }

    public boolean clickYes() {
        if (flag == JOptionPane.YES_OPTION)
            return true;
        else
            return false;
    }

}
 No newline at end of file
Loading