1
0

LS03-02-2 | Highscore jetzt über die Levelauswahl

This commit is contained in:
2021-05-28 10:44:00 +02:00
parent d860a7d797
commit 538c11c597
4 changed files with 54 additions and 31 deletions
@@ -2,7 +2,7 @@
<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="584" height="400"/>
<xy x="20" y="20" width="677" height="400"/>
</constraints>
<properties>
<background color="-16777216"/>
@@ -30,6 +30,12 @@
<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>
@@ -23,6 +23,7 @@ public class LevelChoice {
private JButton btnPlay;
private JScrollPane scrollPane;
private JButton btnBack;
private JButton btnHighscore;
private final LevelController lvlControl;
private final LeveldesignWindow leveldesignWindow;
@@ -67,6 +68,7 @@ public class LevelChoice {
if (source == LeveldesignWindow.LEVELEDITOR) {
btnPlay.setVisible(false);
btnHighscore.setVisible(false);
}
else if (source == LeveldesignWindow.TESTEN) {
btnNewLevel.setVisible(false);
@@ -84,6 +86,12 @@ public class LevelChoice {
leveldesignWindow.dispose();
}
});
btnHighscore.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnHighscore_Clicked(controller);
}
});
}
private String[][] getLevelsAsTableModel() {
@@ -132,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 @@
<?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="3" 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,7 +15,7 @@
<children>
<component id="c5b1d" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="1" fill="0" indent="0" use-parent-layout="false">
<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>
@@ -40,7 +40,7 @@
</component>
<component id="965b" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="1" 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="5" column="1" 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,7 +60,7 @@
</component>
<component id="b84a7" class="javax.swing.JPasswordField" binding="passwordTextField">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" 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>
@@ -68,7 +68,7 @@
</component>
<component id="39eaf" class="javax.swing.JButton" binding="playButton">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" 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=""/>
@@ -77,7 +77,7 @@
</component>
<component id="6cda2" class="javax.swing.JButton" binding="testButton">
<constraints>
<grid row="8" column="1" 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"/>
@@ -85,23 +85,15 @@
</component>
<component id="9d215" class="javax.swing.JTextField" binding="loginTextField">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" 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="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>
<text value="Highscore"/>
</properties>
</component>
<component id="7ae73" class="javax.swing.JButton" binding="levelEditorButton" default-binding="true">
<constraints>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" 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"/>
@@ -111,7 +103,7 @@
</component>
<component id="ef1af" class="javax.swing.JButton" binding="exitButton">
<constraints>
<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"/>
<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"/>
@@ -121,12 +113,12 @@
</component>
<hspacer id="abee9">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<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="3" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<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">
@@ -136,7 +128,25 @@
</vspacer>
<vspacer id="8c4ad">
<constraints>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<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>
@@ -17,7 +17,6 @@ public class MainMenu {
private JTextField loginTextField;
private JButton playButton;
private JButton testButton;
private JButton highscoreButton;
private JButton levelEditorButton;
private JButton exitButton;
private JPasswordField passwordTextField;
@@ -65,14 +64,6 @@ public class MainMenu {
}
});
// Button Highscore
highscoreButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Highscore(alienDefenceController.getAttemptController(), arrLevel.get(1));
}
});
// Button Leveleditor
levelEditorButton.addActionListener(new ActionListener() {
@Override