Erste Anpassungen an Multiplayermenu (sehr grob)
diverse alte ungenutzte Methoden entfernt
This commit is contained in:
parent
f7326a57d9
commit
5bedfddc60
|
@ -21,7 +21,7 @@ public class HalloSchiffeVersenken {
|
|||
*/
|
||||
|
||||
//JOSHUA CODE
|
||||
//startLocalGame localTest = new startLocalGame();
|
||||
startLocalGame localTest = new startLocalGame();
|
||||
//startMultiplayerGame multiplayerTest = new startMultiplayerGame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class MainMenuController implements ActionListener {
|
|||
MultiMenuModel multiModel = new MultiMenuModel();
|
||||
MultiMenuView multiView = new MultiMenuView();
|
||||
MultiMenuController multiMenuController = new MultiMenuController(multiModel, multiView);
|
||||
view.addPanel(multiView.getPanel(), "MultiMenu");
|
||||
view.addPanel(multiView.getMultiPanel(), "MultiMenu");
|
||||
view.showPanel("MultiMenu");
|
||||
}else if (e.getSource() == view.getSoundButton()) {
|
||||
view.toggleMute();
|
||||
|
|
|
@ -25,6 +25,11 @@ public class MainMenuView {
|
|||
titelLabel.setBounds(550, 10, 700, 100);
|
||||
soundButton.setBounds(20, 20, 128, 128);
|
||||
|
||||
lokalButton.setOpaque(true);
|
||||
multiButton.setOpaque(true);
|
||||
titelLabel.setOpaque(true);
|
||||
soundButton.setOpaque(true);
|
||||
|
||||
titelLabel.setFont(robotoFont);
|
||||
lokalButton.setFont(robotoFont.deriveFont(50f));
|
||||
multiButton.setFont(robotoFont.deriveFont(50f));
|
||||
|
@ -54,7 +59,7 @@ public class MainMenuView {
|
|||
JLabel backgroundLabel = new JLabel(new ImageIcon("graphics/mainmenubackground.png"));
|
||||
backgroundLabel.setBounds(0, 0, 1500, 1000);
|
||||
mainPanel.setBounds(0, 0, 1500, 1000);
|
||||
mainPanel.setOpaque(true);
|
||||
// mainPanel.setOpaque(true);
|
||||
|
||||
frame.setContentPane(new JPanel(null));
|
||||
frame.getContentPane().add(backgroundLabel);
|
||||
|
@ -73,9 +78,6 @@ public class MainMenuView {
|
|||
}
|
||||
}
|
||||
|
||||
public void closeWindow(){
|
||||
frame.setVisible(false);
|
||||
}
|
||||
public JFrame getFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ public class MultiMenuController implements ActionListener {
|
|||
public MultiMenuController(MultiMenuModel model, MultiMenuView view) {
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
this.view.getSoundButton().addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == view.getSoundButton()) {
|
||||
view.toggleMute();
|
||||
if (e.getSource() == view.getPlayerLeftButton()){
|
||||
view.togglePlayerIcon();
|
||||
}else if(e.getSource() == view.getPlayerRightButton()){
|
||||
view.togglePlayerIcon();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,56 +3,81 @@ import javax.swing.JFrame;
|
|||
import javax.swing.*;
|
||||
|
||||
public class MultiMenuView {
|
||||
private JPanel mainPanel = new JPanel(new CardLayout()); // CardLayout for switching
|
||||
int semesterCounter = 1;
|
||||
private JPanel multiPanel = new JPanel(null);
|
||||
ImageIcon SoundIcon = new ImageIcon("graphics/sound button.png");
|
||||
private JFrame frame = new JFrame();
|
||||
private JButton soundButton = new JButton(SoundIcon);
|
||||
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
||||
|
||||
private ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
|
||||
private ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
|
||||
|
||||
JButton PlayerLeftButton = new JButton("<-");
|
||||
JButton PlayerRightButton = new JButton("->");
|
||||
JButton semesterUpButton = new JButton("^");
|
||||
JButton semesterDownButton = new JButton("v");
|
||||
|
||||
JLabel semesterLabel = new JLabel("Semester");
|
||||
private JLabel titelLabel = new JLabel("Multiplayer");
|
||||
private JLabel PlayerIcon = new JLabel(humanPlayerIcon);
|
||||
private JLabel PlayerName = new JLabel("Name");
|
||||
private JTextField PlayerTextField = new JTextField(20);
|
||||
JLabel semesterCounterLabel = new JLabel(String.valueOf(semesterCounter));
|
||||
|
||||
private Font robotoFont = new Font("Roboto", Font.BOLD, 45);
|
||||
public MultiMenuView() {
|
||||
buildPanel();
|
||||
}
|
||||
|
||||
|
||||
public void buildPanel(){
|
||||
soundButton.setBounds(20,20,128,128);
|
||||
titelLabel.setBounds(20,20,700,100);
|
||||
PlayerIcon.setBounds(75, 400, 200, 128);
|
||||
PlayerName.setBounds(50, 625, 200, 30);
|
||||
PlayerTextField.setBounds(50, 650, 250, 50);
|
||||
semesterCounterLabel.setBounds(725, 475, 50, 50); // zwischen den Up/Down-Buttons
|
||||
PlayerLeftButton.setBounds(50, 450, 50, 50);
|
||||
PlayerRightButton.setBounds(250, 450, 50, 50);
|
||||
semesterLabel.setBounds(500, 400, 200, 30);
|
||||
semesterUpButton.setBounds(700, 400, 50, 50);
|
||||
semesterDownButton.setBounds(700, 550, 50, 50);
|
||||
|
||||
mainPanel.add(multiPanel, "MultiMenu");
|
||||
soundButton.setFont(robotoFont.deriveFont(50f));
|
||||
|
||||
multiPanel.add(soundButton);
|
||||
multiPanel.setLayout(null);
|
||||
titelLabel.setFont(robotoFont.deriveFont(50f));
|
||||
semesterLabel.setFont(robotoFont.deriveFont(20f));
|
||||
|
||||
multiPanel.add(PlayerName);
|
||||
multiPanel.add(titelLabel);
|
||||
multiPanel.add(PlayerIcon);
|
||||
multiPanel.add(PlayerTextField);
|
||||
multiPanel.add(semesterCounterLabel);
|
||||
multiPanel.add(semesterUpButton);
|
||||
multiPanel.add(semesterDownButton);
|
||||
multiPanel.add(PlayerLeftButton);
|
||||
multiPanel.add(PlayerRightButton);
|
||||
multiPanel.add(semesterLabel);
|
||||
}
|
||||
|
||||
public void toggleMute(){
|
||||
ImageIcon MuteIcon = new ImageIcon("graphics/sound button muted.png");
|
||||
if(soundButton.getIcon()==SoundIcon) {
|
||||
soundButton.setIcon(MuteIcon);
|
||||
}else{
|
||||
soundButton.setIcon(SoundIcon);
|
||||
}
|
||||
}
|
||||
public JPanel getPanel() {
|
||||
public JPanel getMultiPanel() {
|
||||
return multiPanel;
|
||||
}
|
||||
|
||||
public void showPanel(String panelName) {
|
||||
CardLayout cl = (CardLayout)mainPanel.getLayout();
|
||||
cl.show(multiPanel, panelName);
|
||||
//public void showMultiPanel(String panelName) {
|
||||
// CardLayout cl = (CardLayout)mainPanel.getLayout();
|
||||
// cl.show(multiPanel, panelName);
|
||||
//}
|
||||
|
||||
public void togglePlayerIcon() {
|
||||
if (PlayerIcon.getIcon() == humanPlayerIcon) {
|
||||
PlayerIcon.setIcon(aiPlayerIcon);
|
||||
} else {
|
||||
PlayerIcon.setIcon(humanPlayerIcon);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPanel(JPanel panel, String name) {
|
||||
multiPanel.add(panel, name);
|
||||
public JButton getPlayerLeftButton() {
|
||||
return PlayerLeftButton;
|
||||
}
|
||||
|
||||
public void closeWindOw(){
|
||||
frame.dispose();
|
||||
public JButton getPlayerRightButton() {
|
||||
return PlayerRightButton;
|
||||
}
|
||||
public JFrame getFrame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
public JButton getSoundButton() {
|
||||
return soundButton;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue