cleanup
parent
cdf993d998
commit
dc6e6d311b
|
|
@ -0,0 +1,24 @@
|
||||||
|
package de.mannheim.th.chess.controller.controlPanel;
|
||||||
|
|
||||||
|
import de.mannheim.th.chess.ui.SpielFrame;
|
||||||
|
import de.mannheim.th.chess.domain.Game;
|
||||||
|
|
||||||
|
public abstract class BaseButtonViewListener {
|
||||||
|
protected SpielFrame sf;
|
||||||
|
protected Game game;
|
||||||
|
|
||||||
|
public BaseButtonViewListener(Game game, SpielFrame sf) {
|
||||||
|
this.sf = sf;
|
||||||
|
this.game = game;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the gamestate and renders the board
|
||||||
|
*/
|
||||||
|
protected void updateView() {
|
||||||
|
this.game.loadView();
|
||||||
|
this.sf.setDefaultButtons();
|
||||||
|
this.sf.applyBoardButtons();
|
||||||
|
this.sf.ladeBrett();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
|
package de.mannheim.th.chess.controller.controlPanel;
|
||||||
package de.mannheim.th.chess.controller;
|
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package de.mannheim.th.chess.controller;
|
package de.mannheim.th.chess.controller.controlPanel;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
@ -6,23 +6,17 @@ import java.awt.event.ActionListener;
|
||||||
import de.mannheim.th.chess.domain.Game;
|
import de.mannheim.th.chess.domain.Game;
|
||||||
import de.mannheim.th.chess.ui.SpielFrame;
|
import de.mannheim.th.chess.ui.SpielFrame;
|
||||||
|
|
||||||
public class ButtonViewBackListener implements ActionListener {
|
public class ButtonViewBackListener extends BaseButtonViewListener implements ActionListener {
|
||||||
private Game game;
|
|
||||||
private SpielFrame sf;
|
|
||||||
|
|
||||||
public ButtonViewBackListener(Game game, SpielFrame sf) {
|
public ButtonViewBackListener(Game game, SpielFrame sf) {
|
||||||
this.game = game;
|
super(game, sf);
|
||||||
this.sf = sf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (this.game.getViewPointer() > 0) {
|
if (this.game.getViewPointer() > 0) {
|
||||||
this.game.setViewPointer(this.game.getViewPointer() - 1);
|
this.game.setViewPointer(this.game.getViewPointer() - 1);
|
||||||
this.game.loadView();
|
updateView();
|
||||||
this.sf.setDefaultButtons();
|
|
||||||
this.sf.applyBoardButtons();
|
|
||||||
this.sf.ladeBrett();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,22 +6,16 @@ import java.awt.event.ActionListener;
|
||||||
import de.mannheim.th.chess.domain.Game;
|
import de.mannheim.th.chess.domain.Game;
|
||||||
import de.mannheim.th.chess.ui.SpielFrame;
|
import de.mannheim.th.chess.ui.SpielFrame;
|
||||||
|
|
||||||
public class ButtonViewFirstListener implements ActionListener {
|
public class ButtonViewFirstListener extends BaseButtonViewListener implements ActionListener {
|
||||||
private Game game;
|
|
||||||
private SpielFrame sf;
|
|
||||||
|
|
||||||
public ButtonViewFirstListener(Game game, SpielFrame sf) {
|
public ButtonViewFirstListener(Game game, SpielFrame sf) {
|
||||||
this.game = game;
|
super(game, sf);
|
||||||
this.sf = sf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
this.game.setViewPointer(0);
|
this.game.setViewPointer(0);
|
||||||
this.game.loadView();
|
updateView();
|
||||||
this.sf.setDefaultButtons();
|
|
||||||
this.sf.applyBoardButtons();
|
|
||||||
this.sf.ladeBrett();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,17 @@ import java.awt.event.ActionListener;
|
||||||
import de.mannheim.th.chess.domain.Game;
|
import de.mannheim.th.chess.domain.Game;
|
||||||
import de.mannheim.th.chess.ui.SpielFrame;
|
import de.mannheim.th.chess.ui.SpielFrame;
|
||||||
|
|
||||||
public class ButtonViewForwardListener implements ActionListener {
|
public class ButtonViewForwardListener extends BaseButtonViewListener implements ActionListener {
|
||||||
private Game game;
|
|
||||||
private SpielFrame sf;
|
|
||||||
|
|
||||||
public ButtonViewForwardListener(Game game, SpielFrame sf) {
|
public ButtonViewForwardListener(Game game, SpielFrame sf) {
|
||||||
this.game = game;
|
super(game, sf);
|
||||||
this.sf = sf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (this.game.getMoveList().size() > this.game.getViewPointer()) {
|
if (this.game.getMoveList().size() > this.game.getViewPointer()) {
|
||||||
this.game.setViewPointer(this.game.getViewPointer() + 1);
|
this.game.setViewPointer(this.game.getViewPointer() + 1);
|
||||||
this.game.loadView();
|
updateView();
|
||||||
this.sf.setDefaultButtons();
|
|
||||||
this.sf.applyBoardButtons();
|
|
||||||
this.sf.ladeBrett();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,22 +7,16 @@ import java.awt.event.ActionListener;
|
||||||
import de.mannheim.th.chess.domain.Game;
|
import de.mannheim.th.chess.domain.Game;
|
||||||
import de.mannheim.th.chess.ui.SpielFrame;
|
import de.mannheim.th.chess.ui.SpielFrame;
|
||||||
|
|
||||||
public class ButtonViewLastListener implements ActionListener {
|
public class ButtonViewLastListener extends BaseButtonViewListener implements ActionListener {
|
||||||
private Game game;
|
|
||||||
private SpielFrame sf;
|
|
||||||
|
|
||||||
public ButtonViewLastListener(Game game, SpielFrame sf) {
|
public ButtonViewLastListener(Game game, SpielFrame sf) {
|
||||||
this.game = game;
|
super(game, sf);
|
||||||
this.sf = sf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
this.game.setViewPointer(this.game.getMoveList().size());
|
this.game.setViewPointer(this.game.getMoveList().size());
|
||||||
this.game.loadView();
|
updateView();
|
||||||
this.sf.setDefaultButtons();
|
|
||||||
this.sf.applyBoardButtons();
|
|
||||||
this.sf.ladeBrett();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ public class Game {
|
||||||
this.board = new Board();
|
this.board = new Board();
|
||||||
|
|
||||||
this.startPosFen = this.board.getFen();
|
this.startPosFen = this.board.getFen();
|
||||||
|
|
||||||
this.movelist = movelist;
|
this.movelist = movelist;
|
||||||
|
|
||||||
for (Move move : movelist) {
|
for (Move move : movelist) {
|
||||||
|
|
@ -85,9 +84,6 @@ public class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clock = new Clock("blitz");
|
this.clock = new Clock("blitz");
|
||||||
|
|
||||||
// this.clockPlayer1 = new Clock();
|
|
||||||
// this.clockPlayer2 = new Clock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -136,7 +132,8 @@ public class Game {
|
||||||
public void quicksave() {
|
public void quicksave() {
|
||||||
// TODO: save the current clocktime
|
// TODO: save the current clocktime
|
||||||
this.savestate = new MoveList(this.movelist);
|
this.savestate = new MoveList(this.movelist);
|
||||||
logger.info("Quicksaved");
|
|
||||||
|
logger.info("Quicksaved...");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -156,7 +153,7 @@ public class Game {
|
||||||
this.playMove(move);
|
this.playMove(move);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Quickloaded");
|
logger.info("Quickloaded...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,6 +322,12 @@ public class Game {
|
||||||
return this.viewPointer;
|
return this.viewPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the current view
|
||||||
|
*
|
||||||
|
* @brief Creates a new gameboard from the start pos and playes moves until it
|
||||||
|
* reaches the viewPointer
|
||||||
|
*/
|
||||||
public void loadView() {
|
public void loadView() {
|
||||||
this.board = new Board();
|
this.board = new Board();
|
||||||
this.board.loadFromFen(this.startPosFen);
|
this.board.loadFromFen(this.startPosFen);
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,20 @@ public class MainFrame extends JFrame {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the spielframe and game in playmode
|
||||||
|
*/
|
||||||
public void startGame() {
|
public void startGame() {
|
||||||
|
if (this.game != null) {
|
||||||
|
this.game.stopClock();
|
||||||
|
SpielFrame sf = new SpielFrame(this.game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the spielframe and game in view mode
|
||||||
|
*/
|
||||||
|
public void startView() {
|
||||||
if (this.game != null) {
|
if (this.game != null) {
|
||||||
this.game.stopClock();
|
this.game.stopClock();
|
||||||
SpielFrame sf = new SpielFrame(this.game);
|
SpielFrame sf = new SpielFrame(this.game);
|
||||||
|
|
@ -125,11 +138,17 @@ public class MainFrame extends JFrame {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* opens the selectmodeframe
|
||||||
|
*/
|
||||||
private void openSelectModeFrame() {
|
private void openSelectModeFrame() {
|
||||||
ModeSelectionFrame ms = new ModeSelectionFrame(this);
|
new ModeSelectionFrame(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the pgnselectorframe
|
||||||
|
*/
|
||||||
private void openPgnSelectFrame() {
|
private void openPgnSelectFrame() {
|
||||||
PGNLoaderFrame pf = new PGNLoaderFrame(this);
|
new PGNLoaderFrame(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,17 @@ import javax.swing.JScrollPane;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import com.github.bhlangonijr.chesslib.game.Game;
|
import com.github.bhlangonijr.chesslib.game.Game;
|
||||||
import com.github.bhlangonijr.chesslib.pgn.PgnHolder;
|
import com.github.bhlangonijr.chesslib.pgn.PgnHolder;
|
||||||
import com.github.bhlangonijr.chesslib.pgn.PgnLoadListener;
|
import com.github.bhlangonijr.chesslib.pgn.PgnLoadListener;
|
||||||
|
|
||||||
public class PGNLoaderFrame extends JFrame {
|
public class PGNLoaderFrame extends JFrame {
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger(PGNLoaderFrame.class);
|
||||||
|
|
||||||
private PgnHolder pgn;
|
private PgnHolder pgn;
|
||||||
private File selectedFile;
|
private File selectedFile;
|
||||||
private List<Game> games;
|
private List<Game> games;
|
||||||
|
|
@ -30,56 +36,61 @@ public class PGNLoaderFrame extends JFrame {
|
||||||
private JList<String> gameList;
|
private JList<String> gameList;
|
||||||
private JProgressBar progressBar;
|
private JProgressBar progressBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the PNGLoaderFrame
|
||||||
|
*/
|
||||||
public PGNLoaderFrame(MainFrame mf) {
|
public PGNLoaderFrame(MainFrame mf) {
|
||||||
|
|
||||||
|
// ----- Style -----
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setAlwaysOnTop(true);
|
setAlwaysOnTop(true);
|
||||||
setTitle("PGNLoader");
|
setTitle("PGNLoader");
|
||||||
setBounds(100, 100, 500, 500);
|
setBounds(100, 100, 500, 500);
|
||||||
|
|
||||||
|
// ----- contentPane -----
|
||||||
contentPane = new JPanel();
|
contentPane = new JPanel();
|
||||||
setContentPane(contentPane);
|
|
||||||
|
|
||||||
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
|
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
setContentPane(contentPane);
|
||||||
|
|
||||||
|
// ----- FileSelector -----
|
||||||
JButton fileSelectButton = new JButton("Select File");
|
JButton fileSelectButton = new JButton("Select File");
|
||||||
fileSelectButton.addActionListener(new ActionListener() {
|
fileSelectButton.addActionListener(e -> {
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
int returnValue = fileChooser.showOpenDialog(null);
|
int returnValue = fileChooser.showOpenDialog(null);
|
||||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||||
selectedFile = fileChooser.getSelectedFile();
|
selectedFile = fileChooser.getSelectedFile();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
contentPane.add(fileSelectButton);
|
contentPane.add(fileSelectButton);
|
||||||
|
|
||||||
|
// ----- LoadButton -----
|
||||||
JButton loadPgnButton = new JButton("Load file");
|
JButton loadPgnButton = new JButton("Load file");
|
||||||
loadPgnButton.addActionListener(e -> loadFile());
|
loadPgnButton.addActionListener(e -> loadFile());
|
||||||
contentPane.add(loadPgnButton);
|
contentPane.add(loadPgnButton);
|
||||||
|
|
||||||
|
// ----- SelectionList -----
|
||||||
gameListModel = new DefaultListModel<>();
|
gameListModel = new DefaultListModel<>();
|
||||||
|
|
||||||
gameList = new JList<>(gameListModel);
|
gameList = new JList<>(gameListModel);
|
||||||
gameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
gameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
gameList.setVisibleRowCount(5);
|
gameList.setVisibleRowCount(5);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane(gameList);
|
JScrollPane scrollPane = new JScrollPane(gameList);
|
||||||
|
|
||||||
contentPane.add(scrollPane);
|
contentPane.add(scrollPane);
|
||||||
|
|
||||||
|
// ----- ProgressBar -----
|
||||||
progressBar = new JProgressBar(0, 100);
|
progressBar = new JProgressBar(0, 100);
|
||||||
progressBar.setValue(0);
|
progressBar.setValue(0);
|
||||||
progressBar.setStringPainted(true);
|
progressBar.setStringPainted(true);
|
||||||
contentPane.add(progressBar);
|
contentPane.add(progressBar);
|
||||||
|
|
||||||
|
// ----- StartButton -----
|
||||||
JButton startGameButton = new JButton("Starte Spiel");
|
JButton startGameButton = new JButton("Starte Spiel");
|
||||||
startGameButton.addActionListener(e -> {
|
startGameButton.addActionListener(e -> {
|
||||||
int index = gameList.getSelectedIndex();
|
int index = gameList.getSelectedIndex();
|
||||||
de.mannheim.th.chess.domain.Game game = new de.mannheim.th.chess.domain.Game(games.get(index).getHalfMoves());
|
de.mannheim.th.chess.domain.Game game = new de.mannheim.th.chess.domain.Game(games.get(index).getHalfMoves());
|
||||||
|
|
||||||
mf.setGame(game);
|
mf.setGame(game);
|
||||||
mf.startGame();
|
mf.startView();
|
||||||
});
|
});
|
||||||
contentPane.add(startGameButton);
|
contentPane.add(startGameButton);
|
||||||
|
|
||||||
|
|
@ -93,10 +104,8 @@ public class PGNLoaderFrame extends JFrame {
|
||||||
|
|
||||||
LoadPGNWorker loadPGNWorker = new LoadPGNWorker();
|
LoadPGNWorker loadPGNWorker = new LoadPGNWorker();
|
||||||
loadPGNWorker.addPropertyChangeListener(e -> {
|
loadPGNWorker.addPropertyChangeListener(e -> {
|
||||||
System.out.println(e.getNewValue());
|
|
||||||
});
|
|
||||||
|
|
||||||
progressBar.setIndeterminate(true);
|
progressBar.setIndeterminate(true);
|
||||||
|
});
|
||||||
|
|
||||||
pgn.getListener().add(loadPGNWorker);
|
pgn.getListener().add(loadPGNWorker);
|
||||||
loadPGNWorker.execute();
|
loadPGNWorker.execute();
|
||||||
|
|
@ -117,7 +126,7 @@ public class PGNLoaderFrame extends JFrame {
|
||||||
publish(i);
|
publish(i);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
logger.info("Could not load pgn file!");
|
||||||
}
|
}
|
||||||
return pgn.getSize();
|
return pgn.getSize();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import de.mannheim.th.chess.utl.Clock;
|
||||||
import de.mannheim.th.chess.controller.ButtonAufgebenListener;
|
import de.mannheim.th.chess.controller.ButtonAufgebenListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonFileSaverListener;
|
import de.mannheim.th.chess.controller.ButtonFileSaverListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonMovePieceListener;
|
import de.mannheim.th.chess.controller.ButtonMovePieceListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonQuickloadListener;
|
import de.mannheim.th.chess.controller.controlPanel.ButtonQuickloadListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonQuicksaveListener;
|
import de.mannheim.th.chess.controller.controlPanel.ButtonQuicksaveListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonSelectPieceListener;
|
import de.mannheim.th.chess.controller.ButtonSelectPieceListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonToNormalListener;
|
import de.mannheim.th.chess.controller.ButtonToNormalListener;
|
||||||
import de.mannheim.th.chess.controller.ButtonUndoMoveListener;
|
import de.mannheim.th.chess.controller.ButtonUndoMoveListener;
|
||||||
|
|
@ -218,6 +218,9 @@ public class SpielFrame extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the to default buttons
|
||||||
|
*/
|
||||||
public void setDefaultButtons() {
|
public void setDefaultButtons() {
|
||||||
this.clearButtons();
|
this.clearButtons();
|
||||||
this.setDefaultBackground();
|
this.setDefaultBackground();
|
||||||
|
|
@ -326,6 +329,9 @@ public class SpielFrame extends JFrame {
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the controlPanel and its Buttons
|
||||||
|
*/
|
||||||
private JPanel createControlPanel() {
|
private JPanel createControlPanel() {
|
||||||
this.controlPanel = new JPanel();
|
this.controlPanel = new JPanel();
|
||||||
this.controlPanel.setBackground(new Color(90, 90, 90));
|
this.controlPanel.setBackground(new Color(90, 90, 90));
|
||||||
|
|
@ -333,32 +339,40 @@ public class SpielFrame extends JFrame {
|
||||||
|
|
||||||
this.controlPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, controlPanel.getPreferredSize().height));
|
this.controlPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, controlPanel.getPreferredSize().height));
|
||||||
|
|
||||||
JButton viewFirstButton = new JButton("<<-");
|
// ----- ViewQuicksaveButton -----
|
||||||
JButton viewBackButton = new JButton("<-");
|
|
||||||
JButton viewForwardButton = new JButton("->");
|
|
||||||
JButton viewLastButton = new JButton("->>");
|
|
||||||
JButton quicksave = new JButton("Quicksave");
|
JButton quicksave = new JButton("Quicksave");
|
||||||
JButton quickload = new JButton("Quickload");
|
|
||||||
|
|
||||||
viewFirstButton.setEnabled(false);
|
|
||||||
viewBackButton.setEnabled(false);
|
|
||||||
viewForwardButton.setEnabled(false);
|
|
||||||
viewLastButton.setEnabled(false);
|
|
||||||
quicksave.setEnabled(true);
|
quicksave.setEnabled(true);
|
||||||
quickload.setEnabled(true);
|
|
||||||
|
|
||||||
viewFirstButton.addActionListener(new ButtonViewFirstListener(this.game, this));
|
|
||||||
viewBackButton.addActionListener(new ButtonViewBackListener(this.game, this));
|
|
||||||
viewForwardButton.addActionListener(new ButtonViewForwardListener(this.game, this));
|
|
||||||
viewLastButton.addActionListener(new ButtonViewLastListener(this.game, this));
|
|
||||||
quicksave.addActionListener(new ButtonQuicksaveListener(this.game));
|
quicksave.addActionListener(new ButtonQuicksaveListener(this.game));
|
||||||
quickload.addActionListener(new ButtonQuickloadListener(this.game, this));
|
|
||||||
|
|
||||||
this.controlPanel.add(quicksave);
|
this.controlPanel.add(quicksave);
|
||||||
|
|
||||||
|
// ----- ViewFirstButton -----
|
||||||
|
JButton viewFirstButton = new JButton("<<-");
|
||||||
|
viewFirstButton.setEnabled(false);
|
||||||
|
viewFirstButton.addActionListener(new ButtonViewFirstListener(this.game, this));
|
||||||
this.controlPanel.add(viewFirstButton);
|
this.controlPanel.add(viewFirstButton);
|
||||||
|
|
||||||
|
// ----- ViewBackButton -----
|
||||||
|
JButton viewBackButton = new JButton("<-");
|
||||||
|
viewBackButton.setEnabled(false);
|
||||||
|
viewBackButton.addActionListener(new ButtonViewBackListener(this.game, this));
|
||||||
this.controlPanel.add(viewBackButton);
|
this.controlPanel.add(viewBackButton);
|
||||||
|
|
||||||
|
// ----- ViewForwardButton -----
|
||||||
|
JButton viewForwardButton = new JButton("->");
|
||||||
|
viewForwardButton.setEnabled(false);
|
||||||
|
viewForwardButton.addActionListener(new ButtonViewForwardListener(this.game, this));
|
||||||
this.controlPanel.add(viewForwardButton);
|
this.controlPanel.add(viewForwardButton);
|
||||||
|
|
||||||
|
// ----- ViewLastButton -----
|
||||||
|
JButton viewLastButton = new JButton("->>");
|
||||||
|
viewLastButton.setEnabled(false);
|
||||||
|
viewLastButton.addActionListener(new ButtonViewLastListener(this.game, this));
|
||||||
this.controlPanel.add(viewLastButton);
|
this.controlPanel.add(viewLastButton);
|
||||||
|
|
||||||
|
// ----- ViewQuickloadButton -----
|
||||||
|
JButton quickload = new JButton("Quickload");
|
||||||
|
quickload.setEnabled(true);
|
||||||
|
quickload.addActionListener(new ButtonQuickloadListener(this.game, this));
|
||||||
this.controlPanel.add(quickload);
|
this.controlPanel.add(quickload);
|
||||||
|
|
||||||
return controlPanel;
|
return controlPanel;
|
||||||
|
|
@ -587,6 +601,9 @@ public class SpielFrame extends JFrame {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inverts the Enabled property of the controlpanelButtons
|
||||||
|
*/
|
||||||
public void enableControlPanelButtons() {
|
public void enableControlPanelButtons() {
|
||||||
for (Component c : this.controlPanel.getComponents()) {
|
for (Component c : this.controlPanel.getComponents()) {
|
||||||
if (c instanceof JButton) {
|
if (c instanceof JButton) {
|
||||||
|
|
@ -595,6 +612,9 @@ public class SpielFrame extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the buttons to the boardpanel
|
||||||
|
*/
|
||||||
public void applyBoardButtons() {
|
public void applyBoardButtons() {
|
||||||
for (JButton b : buttons) {
|
for (JButton b : buttons) {
|
||||||
panelLinks.add(b);
|
panelLinks.add(b);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue