Merge pull request #3 from potzplitz/main

rgrgas
This commit is contained in:
potzplitz 2024-03-14 09:33:08 +01:00 committed by GitHub
commit 7317536f46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 31 deletions

View file

@ -25,6 +25,7 @@ public class LoadMenu {
load.setBounds(1, 178, 398, 20); load.setBounds(1, 178, 398, 20);
loadwindow.setSize(400, 200); loadwindow.setSize(400, 200);
loadwindow.setUndecorated(true); loadwindow.setUndecorated(true);
loadwindow.setResizable(false); loadwindow.setResizable(false);

View file

@ -60,20 +60,16 @@ public class MainGUI {
public JCheckBox filtercompleted = new JCheckBox("Nach geschafft filtern"); public JCheckBox filtercompleted = new JCheckBox("Nach geschafft filtern");
public Button copyid = new Button("Level ID kopieren"); public Button copyid = new Button("Level ID kopieren");
public Button showinfos = new Button("Mehr Infos anzeigen"); public Button showinfos = new Button("Mehr Infos anzeigen");
public JButton settings = new JButton("");
GridLayout gridLayout = new GridLayout(3, 1); GridLayout gridLayout = new GridLayout(3, 1);
private String[] showing = {"Alle anzeigen", "Top 3", "Top 50", "Top 150", "Top 200"}; private String[] showing = {"Alle anzeigen", "Top 3", "Top 50", "Top 150", "Top 200"};
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public JComboBox show = new JComboBox(showing); public JComboBox show = new JComboBox(showing);
private FetchData fetch = new FetchData(); private FetchData fetch = new FetchData();
private Elements elements = new Elements(); private Elements elements = new Elements();
private int completedcount = 0;
public void build() throws IOException { public void build() throws IOException {
GuiData data = new GuiData(); GuiData data = new GuiData();
data.IndexData(); data.IndexData();
gridLayout.setRows(data.getLocalLevels().size()); gridLayout.setRows(data.getLocalLevels().size());
main.setSize(900, 700); main.setSize(900, 700);
@ -84,7 +80,7 @@ public class MainGUI {
level.setBounds(10, 10, 200, 30); level.setBounds(10, 10, 200, 30);
level.setFont(level.getFont().deriveFont(15f)); level.setFont(level.getFont().deriveFont(15f));
filtercompleted.setBounds(710, 15, 200, 30); filtercompleted.setBounds(720, 15, 200, 30);
progress.setBounds(200, 300, 500, 30); progress.setBounds(200, 300, 500, 30);
progress.setStringPainted(true); progress.setStringPainted(true);
@ -106,10 +102,6 @@ public class MainGUI {
qualify.setBounds(10, 170, 164, 30); qualify.setBounds(10, 170, 164, 30);
settings.setBounds(1, 1, 60, 60);
settings.setFont(settings.getFont().deriveFont(30f));
settings.setBackground(Color.LIGHT_GRAY);
victor.setBounds(1, 276, 164, 30); victor.setBounds(1, 276, 164, 30);
records.getVerticalScrollBar().setUnitIncrement(16); records.getVerticalScrollBar().setUnitIncrement(16);
@ -132,11 +124,13 @@ public class MainGUI {
verifier.setBounds(10, 110, 164, 30); verifier.setBounds(10, 110, 164, 30);
search.setBounds(60, 1, 440, 60); search.setBounds(1, 1, 500, 60);
show.setBounds(500, 1, 200, 60); show.setBounds(500, 1, 200, 60);
recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
@ -173,7 +167,6 @@ public class MainGUI {
try { try {
file.createNewFile(); file.createNewFile();
} catch (IOException e1) { } catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@ -193,7 +186,6 @@ public class MainGUI {
contents.setBackground(Color.decode("#cbffbf")); contents.setBackground(Color.decode("#cbffbf"));
uncompleted.setVisible(true); uncompleted.setVisible(true);
completed.setVisible(false); completed.setVisible(false);
completedcount++;
} }
contents.addMouseListener(new MouseListener() { contents.addMouseListener(new MouseListener() {
@ -215,13 +207,11 @@ public class MainGUI {
qualify.setText("Qualifikation: " + data.getQualification().get(index) + "%"); qualify.setText("Qualifikation: " + data.getQualification().get(index) + "%");
level.setVerticalAlignment(SwingConstants.CENTER); level.setVerticalAlignment(SwingConstants.CENTER);
FetchData fetchData = new FetchData(); FetchData fetchData = new FetchData();
try { try {
recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1)); recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1));
} catch (IOException e1) { } catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
recordspanel.setBackground(Color.GRAY); recordspanel.setBackground(Color.GRAY);
@ -231,13 +221,15 @@ public class MainGUI {
recordspanel.removeAll(); recordspanel.removeAll();
try { try {
ArrayList<String> victors = GuiData.allVictors(fetchData.allLevels().get(index)); // Instanz der FetchData-Klasse erstellen
ArrayList<String> victors = GuiData.allVictors(fetchData.allLevels().get(index)); // Methode allVictors aufrufen
victorcount.setText("Anzahl Victors: " + victors.size()); victorcount.setText("Anzahl Victors: " + victors.size());
recordspanel.setLayout(new GridLayout(victors.size(), 1)); recordspanel.setLayout(new GridLayout(victors.size(), 1));
for(String victor : victors) { for(String victor : victors) {
System.out.println(victor);
JPanel contents = new JPanel(); JPanel contents = new JPanel();
contents.setPreferredSize(new Dimension(165, 50)); contents.setPreferredSize(new Dimension(165, 50));
contents.setLayout(null); contents.setLayout(null);
@ -286,8 +278,6 @@ public class MainGUI {
rank.setBounds(10, 10, 40, 30); rank.setBounds(10, 10, 40, 30);
rank.setName(i + ""); rank.setName(i + "");
filtercompleted.setText("nach Geschafft filtern (" + completedcount + ")");
show.addActionListener(new ActionListener() { show.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -373,7 +363,7 @@ public class MainGUI {
scroll.revalidate(); scroll.revalidate();
} }
} else if (e.getStateChange() == ItemEvent.DESELECTED) { } else if (e.getStateChange() == ItemEvent.DESELECTED) {
levelpanel.add(contents, 0); levelpanel.add(contents, 0); // Füge das Element am Anfang hinzu
} }
levelpanel.repaint(); levelpanel.repaint();
levelpanel.revalidate(); levelpanel.revalidate();
@ -396,17 +386,6 @@ public class MainGUI {
} }
}); });
thread.start(); thread.start();
settings.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SettingsGui gui = new SettingsGui();
gui.showSettings();
}
});
elements.infopanel().add(copyid); elements.infopanel().add(copyid);
elements.infopanel().add(level, SwingConstants.CENTER); elements.infopanel().add(level, SwingConstants.CENTER);
@ -429,7 +408,6 @@ public class MainGUI {
main.add(progress); main.add(progress);
main.add(filtercompleted); main.add(filtercompleted);
main.add(show); main.add(show);
main.add(settings);
main.add(elements.infopanel()); main.add(elements.infopanel());
main.setVisible(true); main.setVisible(true);
} }