ole #7

Merged
lgc merged 23 commits from ole into main 2024-11-26 14:01:01 +00:00
5 changed files with 71 additions and 43 deletions
Showing only changes of commit 5bedfddc60 - Show all commits

View File

@ -21,7 +21,7 @@ public class HalloSchiffeVersenken {
*/ */
//JOSHUA CODE //JOSHUA CODE
//startLocalGame localTest = new startLocalGame(); startLocalGame localTest = new startLocalGame();
//startMultiplayerGame multiplayerTest = new startMultiplayerGame(); //startMultiplayerGame multiplayerTest = new startMultiplayerGame();
} }
} }

View File

@ -21,7 +21,7 @@ public class MainMenuController implements ActionListener {
MultiMenuModel multiModel = new MultiMenuModel(); MultiMenuModel multiModel = new MultiMenuModel();
MultiMenuView multiView = new MultiMenuView(); MultiMenuView multiView = new MultiMenuView();
MultiMenuController multiMenuController = new MultiMenuController(multiModel, multiView); MultiMenuController multiMenuController = new MultiMenuController(multiModel, multiView);
view.addPanel(multiView.getPanel(), "MultiMenu"); view.addPanel(multiView.getMultiPanel(), "MultiMenu");
view.showPanel("MultiMenu"); view.showPanel("MultiMenu");
}else if (e.getSource() == view.getSoundButton()) { }else if (e.getSource() == view.getSoundButton()) {
view.toggleMute(); view.toggleMute();

View File

@ -25,6 +25,11 @@ public class MainMenuView {
titelLabel.setBounds(550, 10, 700, 100); titelLabel.setBounds(550, 10, 700, 100);
soundButton.setBounds(20, 20, 128, 128); soundButton.setBounds(20, 20, 128, 128);
lokalButton.setOpaque(true);
multiButton.setOpaque(true);
titelLabel.setOpaque(true);
soundButton.setOpaque(true);
titelLabel.setFont(robotoFont); titelLabel.setFont(robotoFont);
lokalButton.setFont(robotoFont.deriveFont(50f)); lokalButton.setFont(robotoFont.deriveFont(50f));
multiButton.setFont(robotoFont.deriveFont(50f)); multiButton.setFont(robotoFont.deriveFont(50f));
@ -34,7 +39,7 @@ public class MainMenuView {
menuPanel.add(multiButton); menuPanel.add(multiButton);
menuPanel.add(soundButton); menuPanel.add(soundButton);
// mainPanel.add(menuPanel, "MainMenu"); //mainPanel.add(menuPanel, "MainMenu");
} }
public void showPanel(String panelName) { public void showPanel(String panelName) {
@ -54,7 +59,7 @@ public class MainMenuView {
JLabel backgroundLabel = new JLabel(new ImageIcon("graphics/mainmenubackground.png")); JLabel backgroundLabel = new JLabel(new ImageIcon("graphics/mainmenubackground.png"));
backgroundLabel.setBounds(0, 0, 1500, 1000); backgroundLabel.setBounds(0, 0, 1500, 1000);
mainPanel.setBounds(0, 0, 1500, 1000); mainPanel.setBounds(0, 0, 1500, 1000);
mainPanel.setOpaque(true); // mainPanel.setOpaque(true);
frame.setContentPane(new JPanel(null)); frame.setContentPane(new JPanel(null));
frame.getContentPane().add(backgroundLabel); frame.getContentPane().add(backgroundLabel);
@ -73,9 +78,6 @@ public class MainMenuView {
} }
} }
public void closeWindow(){
frame.setVisible(false);
}
public JFrame getFrame() { public JFrame getFrame() {
return frame; return frame;
} }

View File

@ -9,13 +9,14 @@ public class MultiMenuController implements ActionListener {
public MultiMenuController(MultiMenuModel model, MultiMenuView view) { public MultiMenuController(MultiMenuModel model, MultiMenuView view) {
this.view = view; this.view = view;
this.model = model; this.model = model;
this.view.getSoundButton().addActionListener(this);
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getSource() == view.getSoundButton()) { if (e.getSource() == view.getPlayerLeftButton()){
view.toggleMute(); view.togglePlayerIcon();
}else if(e.getSource() == view.getPlayerRightButton()){
view.togglePlayerIcon();
} }
} }
} }

View File

@ -3,56 +3,81 @@ import javax.swing.JFrame;
import javax.swing.*; import javax.swing.*;
public class MultiMenuView { public class MultiMenuView {
private JPanel mainPanel = new JPanel(new CardLayout()); // CardLayout for switching int semesterCounter = 1;
private JPanel multiPanel = new JPanel(null); private JPanel multiPanel = new JPanel(null);
ImageIcon SoundIcon = new ImageIcon("graphics/sound button.png");
private JFrame frame = new JFrame(); private ImageIcon humanPlayerIcon = new ImageIcon("graphics/humanPlayer.png");
private JButton soundButton = new JButton(SoundIcon); private ImageIcon aiPlayerIcon = new ImageIcon("graphics/aiPlayer.png");
Font robotoFont = new Font("Roboto", Font.BOLD, 45);
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() { public MultiMenuView() {
buildPanel(); buildPanel();
} }
public void 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(){ public JPanel getMultiPanel() {
ImageIcon MuteIcon = new ImageIcon("graphics/sound button muted.png");
if(soundButton.getIcon()==SoundIcon) {
soundButton.setIcon(MuteIcon);
}else{
soundButton.setIcon(SoundIcon);
}
}
public JPanel getPanel() {
return multiPanel; return multiPanel;
} }
public void showPanel(String panelName) { //public void showMultiPanel(String panelName) {
CardLayout cl = (CardLayout)mainPanel.getLayout(); // CardLayout cl = (CardLayout)mainPanel.getLayout();
cl.show(multiPanel, panelName); // 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) { public JButton getPlayerLeftButton() {
multiPanel.add(panel, name); return PlayerLeftButton;
} }
public void closeWindOw(){ public JButton getPlayerRightButton() {
frame.dispose(); return PlayerRightButton;
} }
public JFrame getFrame() {
return frame;
}
public JButton getSoundButton() {
return soundButton;
}
} }