import java.awt.*;
import java.awt.event.*;
/**
* Title: GameControls</p>
*
* Description: A game control panel for Pancet, a game applet.
* It displays game response messages and allows user input.</p>
*
* Copyright: Copyright (c) 2004<p>
*
* @author Mark Bondurant
* @version 3.0
*/
class GameControls extends Panel {
private Label responseMsg, libMoveCnt;
private Button buttonC, buttonD;
private GridLayout controlLayout;
/**
* This sets up the control panel using a simple grid layout, it
* adds two message displays, one for the move library stored
* move count and one for game response, and two buttons that
* allow users to choose one of their bowls to move.
*/
GameControls(int m) {
controlLayout = new GridLayout(0, 1);
controlLayout.setVgap(10);
setLayout(controlLayout);
setBackground(Color.white);
libMoveCnt = new Label("Stored moves: " + m, Label.CENTER);
libMoveCnt.setFont(new Font("Helvetica", Font.PLAIN, 16));
libMoveCnt.setBackground(Color.white);
add(libMoveCnt);
responseMsg = new Label("Your Move", Label.CENTER);
responseMsg.setFont(new Font("Helvetica", Font.BOLD, 22));
responseMsg.setBackground(Color.white);
add(responseMsg);
buttonC = new Button("Bowl C");
buttonC.setFont(new Font("Helvetica", Font.PLAIN, 16));
add(buttonC);
buttonD = new Button("Bowl D");
buttonD.setFont(new Font("Helvetica", Font.PLAIN, 16));
add(buttonD);
}
/**
* This is used to connect the action event response to the
* root class Pancet.
*/
void connectControls(Pancet b) {
buttonC.addActionListener(b);
buttonD.addActionListener(b);
}
/**
* This puts a game response message up for the user to see.
*/
void setMessage(String m) {
responseMsg.setText(m);
}
/**
* This displays the stored moves count so the user can see some
* indication of the move tree in action.
*/
void setStoredMoves(int m) {
libMoveCnt.setText("Stored moves: " + m);
}
}