From 25abd38db89dfac4532461af9a287bdc8947a6b1 Mon Sep 17 00:00:00 2001 From: potzplitz <127513690+potzplitz@users.noreply.github.com> Date: Fri, 1 Mar 2024 20:57:46 +0100 Subject: [PATCH] added gui + began auto updater --- src/data/GuiData.java | 79 ++++++++++++++++++++++++++++++++++++++++++- src/gui/MainGUI.java | 24 ++++++++++++- ver/version.txt | 1 + 3 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 ver/version.txt diff --git a/src/data/GuiData.java b/src/data/GuiData.java index 386b656..efd1298 100644 --- a/src/data/GuiData.java +++ b/src/data/GuiData.java @@ -9,6 +9,8 @@ import java.nio.file.Paths; import java.util.ArrayList; import org.apache.commons.io.FileUtils; +import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; public class GuiData { @@ -16,7 +18,10 @@ public class GuiData { private ArrayList localLevels = new ArrayList(); private ArrayList completed = new ArrayList(); private ArrayList id = new ArrayList(); + private ArrayList verifier = new ArrayList(); + private ArrayList creator = new ArrayList(); + private FetchData data = new FetchData(); public void setId(ArrayList id) { this.id = id; @@ -40,6 +45,14 @@ public class GuiData { return id; } + public ArrayList getVerifier() { + return verifier; + } + + public ArrayList getCreator() { + return creator; + } + public void IndexLevelName() throws IOException { @@ -76,7 +89,7 @@ public class GuiData { public void IndexLevelID() throws IOException { -FetchData data = new FetchData(); + File filelength = new File("C:\\ExtremeDemonList\\levels"); File[] filelengthindex = filelength.listFiles(); @@ -103,5 +116,69 @@ FetchData data = new FetchData(); } } + + public void IndexVerifiers() throws IOException { + + FetchData data = new FetchData(); + + File filelength = new File("C:\\ExtremeDemonList\\levels"); + File[] filelengthindex = filelength.listFiles(); + + String jsonstring; + + localLength = filelengthindex.length; + + System.out.println(filelengthindex.length); + + for(int i = 0; i < filelengthindex.length; i++) { + + + + jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); + jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); + + JSONObject obj = new JSONObject(jsonstring); + + verifier.add(obj.getString("verifier")); + + + + } + + + + } + + public void IndexCreators() throws IOException { + + FetchData data = new FetchData(); + + File filelength = new File("C:\\ExtremeDemonList\\levels"); + File[] filelengthindex = filelength.listFiles(); + + String jsonstring; + + localLength = filelengthindex.length; + + System.out.println(filelengthindex.length); + + for(int i = 0; i < filelengthindex.length; i++) { + + + + jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8); + jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", ""); + + JSONObject obj = new JSONObject(jsonstring); + + creator.add(obj.getString("author")); + + + + } + + + + } } diff --git a/src/gui/MainGUI.java b/src/gui/MainGUI.java index d2dac89..815c95a 100644 --- a/src/gui/MainGUI.java +++ b/src/gui/MainGUI.java @@ -47,6 +47,11 @@ public class MainGUI { public JTextField search = new JTextField(); public JLabel levelname; public JLabel level = new JLabel("Liste"); + public JLabel creator = new JLabel("Creator"); + public JLabel separator = new JLabel("_______________________________________________________________________________________________________________"); + public JLabel verifier = new JLabel("Verifier"); + public JPanel recordspanel = new JPanel(); + public JScrollPane records = new JScrollPane(recordspanel); public JCheckBox filtercompleted = new JCheckBox("Nach geschaft filtern"); public Button copyid = new Button("Level ID kopieren"); private FetchData fetch = new FetchData(); @@ -58,6 +63,8 @@ public class MainGUI { GuiData data = new GuiData(); data.IndexLevelName(); data.IndexLevelID(); + data.IndexVerifiers(); + data.IndexCreators(); main.setSize(900, 700); main.setLayout(null); @@ -81,7 +88,11 @@ public class MainGUI { levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); levelpanel.setLayout(new GridLayout(data.getLocalLevels().size(), 1)); - copyid.setBounds(10, 50, 100, 30); + recordspanel.setBackground(Color.LIGHT_GRAY); + recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + recordspanel.setLayout(new GridLayout(data.getLocalLevels().size(), 1)); + + copyid.setBounds(10, 50, 164, 30); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -92,6 +103,12 @@ public class MainGUI { elements.infopanel().setBounds(700, 61, 184, 600); elements.infopanel().setVisible(false); + separator.setBounds(0, 70, 300, 30); + + creator.setBounds(10, 90, 164, 30); + + verifier.setBounds(10, 110, 164, 30); + search.setBounds(1, 1, 700, 60); Thread thread = new Thread(new Runnable() { @@ -171,6 +188,8 @@ public class MainGUI { public void mouseClicked(MouseEvent e) { level.setText(data.getLocalLevels().get(index)); + verifier.setText("Verifier: " + data.getVerifier().get(index)); + creator.setText("Creator: " + data.getCreator().get(index)); level.setVerticalAlignment(SwingConstants.CENTER); copyid.addActionListener(new ActionListener() { @@ -265,6 +284,9 @@ public class MainGUI { elements.infopanel().add(copyid); elements.infopanel().add(level, SwingConstants.CENTER); + elements.infopanel().add(separator); + elements.infopanel().add(creator); + elements.infopanel().add(verifier); main.add(search); diff --git a/ver/version.txt b/ver/version.txt new file mode 100644 index 0000000..9f8e9b6 --- /dev/null +++ b/ver/version.txt @@ -0,0 +1 @@ +1.0 \ No newline at end of file