GUI Kartenfunktionen Update
This commit is contained in:
@@ -95,7 +95,6 @@ public class Spielerverwaltung {
|
|||||||
int zeilennummer = 0;
|
int zeilennummer = 0;
|
||||||
boolean insArray = false;
|
boolean insArray = false;
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
System.out.println(line);
|
|
||||||
lineArray = line.toCharArray();
|
lineArray = line.toCharArray();
|
||||||
for (int i = 0; i < lineArray.length; i++) {
|
for (int i = 0; i < lineArray.length; i++) {
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ import javax.swing.table.DefaultTableModel;
|
|||||||
import de.jaujau.daten.Audio;
|
import de.jaujau.daten.Audio;
|
||||||
import de.jaujau.daten.Spieler;
|
import de.jaujau.daten.Spieler;
|
||||||
import de.jaujau.daten.Spielerverwaltung;
|
import de.jaujau.daten.Spielerverwaltung;
|
||||||
|
import de.jaujau.daten.Texturenpakete;
|
||||||
import de.jaujau.spiellogik.Anwendung;
|
import de.jaujau.spiellogik.Anwendung;
|
||||||
import de.jaujau.spiellogik.Spiel;
|
import de.jaujau.spiellogik.Spiel;
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ import java.awt.ComponentOrientation;
|
|||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
public class Dashboard_GUI extends JPanel{
|
public class Dashboard_GUI extends JPanel{
|
||||||
private static final long serialVersionUID = -7380187913989942586L;
|
private static final long serialVersionUID = -7380187913989942586L;
|
||||||
@@ -57,35 +59,43 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
private final JLabel ziehstapel = new JLabel("");
|
private final JLabel ziehstapel = new JLabel("");
|
||||||
private final JScrollPane scrollPane = new JScrollPane();
|
private final JScrollPane scrollPane = new JScrollPane();
|
||||||
private final JLabel lblNewLabel_2_1 = new JLabel("");
|
private final JLabel lblNewLabel_2_1 = new JLabel("");
|
||||||
JPanel imagepanel = new JPanel();
|
JPanel spielerkarten = new JPanel();
|
||||||
JLabel labels[] = new JLabel[32];
|
JLabel labels[] = new JLabel[32];
|
||||||
private Audio sound = new Audio();
|
private Audio sound = new Audio();
|
||||||
private Spiel aktuellesSpiel;
|
private Spiel aktuellesSpiel;
|
||||||
|
private final JPanel gegenerkarten = new JPanel();
|
||||||
|
|
||||||
public Dashboard_GUI(Spiel Spiel) {
|
public Dashboard_GUI(Spiel Spiel, Texturenpakete texturenpakete) {
|
||||||
|
texturenpakete.addPaket("StandartTexturenBeta3.zip");
|
||||||
|
texturenpakete.setAktivesPaket(0);
|
||||||
|
System.out.println(texturenpakete.getAktivesPaket());
|
||||||
aktuellesSpiel = Spiel;
|
aktuellesSpiel = Spiel;
|
||||||
setLayout(new BorderLayout(0, 0));
|
setLayout(new BorderLayout(0, 0));
|
||||||
panelCont.setLayout(cl);
|
panelCont.setLayout(cl);
|
||||||
panelCont.add(highscore, "1");
|
panelCont.add(highscore, "1");
|
||||||
panelCont.add(game, "2");
|
panelCont.add(game, "2");
|
||||||
game.setLayout(new BorderLayout(0, 0));
|
game.setLayout(new BorderLayout(0, 0));
|
||||||
|
spielfeld.setBackground(new Color(128, 128, 128));
|
||||||
|
|
||||||
game.add(spielfeld, BorderLayout.CENTER);
|
game.add(spielfeld, BorderLayout.CENTER);
|
||||||
spielfeld.setLayout(null);
|
spielfeld.setLayout(null);
|
||||||
player_hand.setBounds(0, 660, 1269, 212);
|
player_hand.setForeground(new Color(169, 169, 169));
|
||||||
|
player_hand.setBackground(new Color(169, 169, 169));
|
||||||
|
player_hand.setBounds(0, 629, 1269, 243);
|
||||||
|
|
||||||
spielfeld.add(player_hand);
|
spielfeld.add(player_hand);
|
||||||
player_hand.setLayout(new BorderLayout(0, 0));
|
player_hand.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
JScrollPane scrollPane_1 = new JScrollPane();
|
JScrollPane scrollPane_1 = new JScrollPane();
|
||||||
player_hand.add(scrollPane_1, BorderLayout.CENTER);
|
player_hand.add(scrollPane_1, BorderLayout.CENTER);
|
||||||
|
spielerkarten.setBackground(new Color(169, 169, 169));
|
||||||
|
|
||||||
|
|
||||||
imagepanel.setAutoscrolls(true);
|
spielerkarten.setAutoscrolls(true);
|
||||||
imagepanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
spielerkarten.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
scrollPane_1.setViewportView(imagepanel);
|
scrollPane_1.setViewportView(spielerkarten);
|
||||||
imagepanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
spielerkarten.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
||||||
|
gegner_hand.setBackground(UIManager.getColor("Button.shadow"));
|
||||||
|
|
||||||
|
|
||||||
gegner_hand.setBounds(0, 0, 1269, 152);
|
gegner_hand.setBounds(0, 0, 1269, 152);
|
||||||
@@ -94,22 +104,26 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
gegner_hand.setLayout(new BorderLayout(0, 0));
|
gegner_hand.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
gegner_hand.add(scrollPane);
|
gegner_hand.add(scrollPane);
|
||||||
|
gegenerkarten.setBackground(new Color(169, 169, 169));
|
||||||
|
|
||||||
|
scrollPane.setViewportView(gegenerkarten);
|
||||||
ablagestapel.setHorizontalAlignment(SwingConstants.CENTER);
|
ablagestapel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
ablagestapel.setBounds(618, 267, 137, 210);
|
ablagestapel.setBounds(618, 267, 137, 210);
|
||||||
|
|
||||||
|
|
||||||
spielfeld.add(ablagestapel);
|
spielfeld.add(ablagestapel);
|
||||||
ziehstapel.addMouseListener(new MouseAdapter() {
|
ziehstapel.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
aktuellesSpiel.getKartensatz().ziehen(Spieler.SPIELER);
|
||||||
aktualisiereHand(aktuellesSpiel);
|
aktualisiereHand(aktuellesSpiel, texturenpakete);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ziehstapel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
ziehstapel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
ziehstapel.setPreferredSize(new Dimension(242, 362));
|
ziehstapel.setPreferredSize(new Dimension(242, 362));
|
||||||
ziehstapel.setHorizontalAlignment(SwingConstants.CENTER);
|
ziehstapel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
ziehstapel.setBounds(1093, 267, 137, 210);
|
ziehstapel.setBounds(1093, 267, 137, 210);
|
||||||
ziehstapel.setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource("/img/texturen/standart/32.png")).getImage().getScaledInstance(ziehstapel.getWidth(), ziehstapel.getHeight(), Image.SCALE_SMOOTH)));
|
ziehstapel.setIcon(new ImageIcon(texturenpakete.getTextur(32).getScaledInstance(ziehstapel.getWidth(), ziehstapel.getHeight(), Image.SCALE_SMOOTH)));
|
||||||
|
|
||||||
|
|
||||||
spielfeld.add(ziehstapel);
|
spielfeld.add(ziehstapel);
|
||||||
@@ -209,34 +223,34 @@ public class Dashboard_GUI extends JPanel{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void aktualisiereHand(Spiel aktuellesSpiel) {
|
void aktualisiereHand(Spiel aktuellesSpiel, Texturenpakete texturen) {
|
||||||
|
|
||||||
for(Component c : imagepanel.getComponents()){
|
//Alle Elemente entfernen
|
||||||
imagepanel.remove(c);
|
for(Component c : spielerkarten.getComponents()){
|
||||||
imagepanel.revalidate();
|
spielerkarten.remove(c);
|
||||||
|
spielerkarten.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Alle Karten auf der Hand darstellen
|
||||||
for(int i = 0; i< aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).size(); i++){
|
for(int i = 0; i< aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).size(); i++){
|
||||||
|
|
||||||
labels[i] = new JLabel();
|
labels[i] = new JLabel();
|
||||||
String path = "/img/texturen/standart/" + Integer.toString(aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).get(i)) + ".png";
|
|
||||||
labels[i].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
labels[i].setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
labels[i].setAlignmentY(Component.TOP_ALIGNMENT);
|
labels[i].setAlignmentY(Component.TOP_ALIGNMENT);
|
||||||
labels[i].setBounds(new Rectangle(0, 0, 120, 180));
|
labels[i].setBounds(new Rectangle(0, 0, 120, 180));
|
||||||
labels[i].setSize(new Dimension(120, 180));
|
labels[i].setSize(new Dimension(120, 180));
|
||||||
labels[i].setHorizontalTextPosition(SwingConstants.CENTER);
|
labels[i].setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
labels[i].setHorizontalAlignment(SwingConstants.CENTER);
|
labels[i].setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
labels[i].setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource(path)).getImage().getScaledInstance(labels[i].getWidth(), labels[i].getHeight(), Image.SCALE_SMOOTH)));
|
labels[i].setIcon(new ImageIcon(texturen.getTextur(aktuellesSpiel.getKartensatz().getHand(Spieler.SPIELER).get(i)).getScaledInstance(ziehstapel.getWidth(), ziehstapel.getHeight(), Image.SCALE_SMOOTH)));
|
||||||
imagepanel.add(labels[i]);
|
spielerkarten.add(labels[i]);
|
||||||
imagepanel.updateUI(); //Panel erneuern
|
spielerkarten.updateUI(); //Panel erneuern
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void aktualisiereAblage(Spiel aktuellesSpiel, Texturenpakete texturen){
|
||||||
|
ablagestapel.setIcon(new ImageIcon(texturen.getTextur(aktuellesSpiel.getKartensatz().getletzteKarte()).getScaledInstance(ziehstapel.getWidth(), ziehstapel.getHeight(), Image.SCALE_SMOOTH)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -119,7 +119,7 @@ public class GUI extends JFrame{
|
|||||||
getContentPane().add(dashboard, BorderLayout.CENTER);
|
getContentPane().add(dashboard, BorderLayout.CENTER);
|
||||||
dashboard.setLayout(new BorderLayout(0, 0));
|
dashboard.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI(aktuellesSpiel);
|
Dashboard_GUI Dashboard_GUI = new Dashboard_GUI(aktuellesSpiel, texturenpakete);
|
||||||
|
|
||||||
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
//Spiel_GUI Spiel_GUI = new Spiel_GUI();
|
||||||
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
dashboard.add(Dashboard_GUI, BorderLayout.CENTER);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.7 KiB |
Reference in New Issue
Block a user