Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8f044069f | |||
| 538c11c597 | |||
| d860a7d797 | |||
| 39b80c1bf7 | |||
| 1265df634c | |||
| 47e1c660b8 |
@@ -1,7 +1,6 @@
|
||||
package de.oszimt.ls.aliendefence.view.menue;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Vector;
|
||||
@@ -15,6 +14,7 @@ import javax.swing.JTable;
|
||||
import de.oszimt.ls.aliendefence.controller.AttemptController;
|
||||
import de.oszimt.ls.aliendefence.model.Level;
|
||||
|
||||
|
||||
public class Highscore extends JFrame {
|
||||
|
||||
// Attribute
|
||||
@@ -50,13 +50,25 @@ public class Highscore extends JFrame {
|
||||
|
||||
// Tablle basierend auf zweidimensionalem Vector
|
||||
JTable table = new JTable(vecRow, title);
|
||||
table.setBackground(Color.BLACK);
|
||||
table.setForeground(Color.YELLOW);
|
||||
table.setSelectionBackground(Color.YELLOW);
|
||||
table.setSelectionForeground(Color.BLACK);
|
||||
table.getTableHeader().setOpaque(false);
|
||||
table.getTableHeader().setBackground(Color.BLACK);
|
||||
table.getTableHeader().setForeground(Color.YELLOW);
|
||||
|
||||
if (mark >= 0)
|
||||
table.setRowSelectionInterval(mark, mark);
|
||||
setMinimumSize(new Dimension(650, 500));
|
||||
getContentPane().add(new JScrollPane(table), BorderLayout.NORTH);
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
scrollPane.getViewport().setBackground(Color.BLACK);
|
||||
getContentPane().add(scrollPane, BorderLayout.NORTH);
|
||||
setTitle("Highscore-Liste"); // Titel
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
pack();
|
||||
getContentPane().setBackground(Color.BLACK);
|
||||
|
||||
setVisible(true);
|
||||
|
||||
JButton btnZielndern = new JButton("Highscoreliste löschen");
|
||||
@@ -67,6 +79,7 @@ public class Highscore extends JFrame {
|
||||
});
|
||||
|
||||
JPanel pnlSouth = new JPanel();
|
||||
pnlSouth.setBackground(Color.BLACK);
|
||||
pnlSouth.add(btnZielndern);
|
||||
|
||||
// fügt Panel mit Button hinzu
|
||||
|
||||
@@ -2,22 +2,40 @@
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.oszimt.ls.aliendefence.view.menue.LevelChoice">
|
||||
<grid id="27dc6" binding="panel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="501" height="400"/>
|
||||
<xy x="20" y="20" width="677" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<background color="-16777216"/>
|
||||
<foreground color="-16777216"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="6dda1" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints border-constraint="South"/>
|
||||
<properties/>
|
||||
<properties>
|
||||
<background color="-16777216"/>
|
||||
<foreground color="-16777216"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a4374" class="javax.swing.JButton" binding="btnBack">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="zurück"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="cdd2d" class="javax.swing.JButton" binding="btnPlay">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="Spielen"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a6b5c" class="javax.swing.JButton" binding="btnHighscore">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<text value="Highscore"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c85bc" class="javax.swing.JButton" binding="btnNewLevel">
|
||||
<constraints/>
|
||||
<properties>
|
||||
@@ -41,19 +59,30 @@
|
||||
<component id="fc00" class="javax.swing.JLabel">
|
||||
<constraints border-constraint="North"/>
|
||||
<properties>
|
||||
<enabled value="true"/>
|
||||
<font size="18" style="1"/>
|
||||
<foreground color="-16711936"/>
|
||||
<horizontalAlignment value="0"/>
|
||||
<text value="Levelauswahl"/>
|
||||
</properties>
|
||||
</component>
|
||||
<scrollpane id="231d4">
|
||||
<scrollpane id="231d4" binding="scrollPane">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<properties>
|
||||
<background color="-16777216"/>
|
||||
<foreground color="-16711936"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="28513" class="javax.swing.JTable" binding="tblLevels">
|
||||
<constraints/>
|
||||
<properties/>
|
||||
<properties>
|
||||
<background color="-16777216"/>
|
||||
<foreground color="-16711936"/>
|
||||
<gridColor color="-16777216"/>
|
||||
<selectionBackground color="-16711936"/>
|
||||
<selectionForeground color="-16777216"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
|
||||
@@ -21,6 +21,9 @@ public class LevelChoice {
|
||||
private JTable tblLevels;
|
||||
private JButton btnDeleteLevel;
|
||||
private JButton btnPlay;
|
||||
private JScrollPane scrollPane;
|
||||
private JButton btnBack;
|
||||
private JButton btnHighscore;
|
||||
|
||||
private final LevelController lvlControl;
|
||||
private final LeveldesignWindow leveldesignWindow;
|
||||
@@ -65,12 +68,30 @@ public class LevelChoice {
|
||||
|
||||
if (source == LeveldesignWindow.LEVELEDITOR) {
|
||||
btnPlay.setVisible(false);
|
||||
btnHighscore.setVisible(false);
|
||||
}
|
||||
else if (source == LeveldesignWindow.TESTEN) {
|
||||
btnNewLevel.setVisible(false);
|
||||
btnUpdateLevel.setVisible(false);
|
||||
btnDeleteLevel.setVisible(false);
|
||||
}
|
||||
scrollPane.getViewport().setBackground(Color.BLACK);
|
||||
|
||||
tblLevels.getTableHeader().setOpaque(false);
|
||||
tblLevels.getTableHeader().setBackground(Color.BLACK);
|
||||
tblLevels.getTableHeader().setForeground(Color.YELLOW);
|
||||
btnBack.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
leveldesignWindow.dispose();
|
||||
}
|
||||
});
|
||||
btnHighscore.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnHighscore_Clicked(controller);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String[][] getLevelsAsTableModel() {
|
||||
@@ -119,6 +140,14 @@ public class LevelChoice {
|
||||
t.start();
|
||||
}
|
||||
|
||||
public void btnHighscore_Clicked(AlienDefenceController alienDefenceController) {
|
||||
//Level_id des selektierten Elements auslesen
|
||||
int level_id = Integer
|
||||
.parseInt((String) this.tblLevels.getModel().getValueAt(this.tblLevels.getSelectedRow(), 0));
|
||||
|
||||
new Highscore(alienDefenceController.getAttemptController(), alienDefenceController.getLevelController().readLevel(level_id));
|
||||
}
|
||||
|
||||
|
||||
public JPanel getPanel() {
|
||||
return panel;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.oszimt.ls.aliendefence.view.menue;
|
||||
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
@@ -21,8 +21,8 @@ public class LeveldesignWindow extends JFrame {
|
||||
|
||||
private CardLayout cards;
|
||||
|
||||
public static int TESTEN = 0;
|
||||
public static int LEVELEDITOR = 1;
|
||||
public static final int TESTEN = 0;
|
||||
public static final int LEVELEDITOR = 1;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
@@ -35,6 +35,8 @@ public class LeveldesignWindow extends JFrame {
|
||||
setBounds(100, 100, 1200, 800);
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setBackground(Color.BLACK);
|
||||
|
||||
setContentPane(contentPane);
|
||||
this.cards = new CardLayout();
|
||||
contentPane.setLayout(cards);
|
||||
@@ -47,6 +49,8 @@ public class LeveldesignWindow extends JFrame {
|
||||
|
||||
this.showLevelChooser();
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setUndecorated(true);
|
||||
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.oszimt.ls.aliendefence.view.menue.MainMenu">
|
||||
<grid id="27dc6" binding="main" layout-manager="GridLayoutManager" row-count="13" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="main" layout-manager="GridLayoutManager" row-count="14" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="326" height="715"/>
|
||||
@@ -15,8 +15,8 @@
|
||||
<children>
|
||||
<component id="c5b1d" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="177" height="9"/>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="177" height="100"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -27,8 +27,8 @@
|
||||
</component>
|
||||
<component id="8961e" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="1" use-parent-layout="false">
|
||||
<preferred-size width="200" height="103"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="1" use-parent-layout="false">
|
||||
<preferred-size width="200" height="200"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -40,7 +40,7 @@
|
||||
</component>
|
||||
<component id="965b" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font size="14" style="1"/>
|
||||
@@ -50,7 +50,7 @@
|
||||
</component>
|
||||
<component id="14947" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font size="14" style="1"/>
|
||||
@@ -60,31 +60,15 @@
|
||||
</component>
|
||||
<component id="b84a7" class="javax.swing.JPasswordField" binding="passwordTextField">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="4aca1" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font size="14" style="1"/>
|
||||
<foreground color="-256"/>
|
||||
<text value="Level:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a16d0" class="javax.swing.JComboBox" binding="level">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="39eaf" class="javax.swing.JButton" binding="playButton">
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<actionCommand value=""/>
|
||||
@@ -93,7 +77,7 @@
|
||||
</component>
|
||||
<component id="6cda2" class="javax.swing.JButton" binding="testButton">
|
||||
<constraints>
|
||||
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Testen"/>
|
||||
@@ -101,23 +85,15 @@
|
||||
</component>
|
||||
<component id="9d215" class="javax.swing.JTextField" binding="loginTextField">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="e66c9" class="javax.swing.JButton" binding="highscoreButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Highscore"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7ae73" class="javax.swing.JButton" binding="levelEditorButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-256"/>
|
||||
@@ -127,7 +103,7 @@
|
||||
</component>
|
||||
<component id="ef1af" class="javax.swing.JButton" binding="exitButton">
|
||||
<constraints>
|
||||
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<background color="-3552823"/>
|
||||
@@ -135,6 +111,44 @@
|
||||
<text value="Beenden"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="abee9">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<hspacer id="da8b7">
|
||||
<constraints>
|
||||
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<vspacer id="c33be">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<vspacer id="8c4ad">
|
||||
<constraints>
|
||||
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<vspacer id="109a4">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="30"/>
|
||||
<preferred-size width="-1" height="30"/>
|
||||
<maximum-size width="-1" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<vspacer id="99842">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="30"/>
|
||||
<preferred-size width="-1" height="30"/>
|
||||
<maximum-size width="-1" height="30"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -15,21 +15,17 @@ public class MainMenu {
|
||||
|
||||
private JPanel main;
|
||||
private JTextField loginTextField;
|
||||
private JComboBox level;
|
||||
private JButton playButton;
|
||||
private JButton testButton;
|
||||
private JButton highscoreButton;
|
||||
private JButton levelEditorButton;
|
||||
private JButton exitButton;
|
||||
private JPasswordField passwordTextField;
|
||||
|
||||
public MainMenu(AlienDefenceController alienDefenceController) {
|
||||
|
||||
//fill level chooser
|
||||
// Levelliste für die ComboBox abrufen
|
||||
List<Level> arrLevel = alienDefenceController.getLevelController().readAllLevels();
|
||||
String[] arrLevelNames = getLevelNames(arrLevel);
|
||||
level.setModel(new DefaultComboBoxModel<String>(arrLevelNames));
|
||||
|
||||
// Button Spielen - ActionListener
|
||||
playButton.addActionListener(new ActionListener() {
|
||||
@@ -45,8 +41,8 @@ public class MainMenu {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
GameController gameController = alienDefenceController.startGame(arrLevel.get(level.getSelectedIndex()), user);
|
||||
new GameGUI(gameController).start();
|
||||
//GameController gameController = alienDefenceController.startGame(arrLevel.get(level.getSelectedIndex()), user);
|
||||
//new GameGUI(gameController).start();
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
@@ -68,14 +64,6 @@ public class MainMenu {
|
||||
}
|
||||
});
|
||||
|
||||
// Button Highscore
|
||||
highscoreButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Highscore(alienDefenceController.getAttemptController(), arrLevel.get(level.getSelectedIndex()));
|
||||
}
|
||||
});
|
||||
|
||||
// Button Leveleditor
|
||||
levelEditorButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@@ -106,10 +94,12 @@ public class MainMenu {
|
||||
|
||||
public static void show(AlienDefenceController alienDefenceController) {
|
||||
JFrame frame = new JFrame("AlienDefence");
|
||||
frame.setUndecorated(true);
|
||||
frame.setContentPane(new MainMenu(alienDefenceController).main);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user