added gui + began auto updater

This commit is contained in:
potzplitz 2024-03-01 20:57:46 +01:00
parent 9bfe419ba3
commit 25abd38db8
3 changed files with 102 additions and 2 deletions

View file

@ -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<String> localLevels = new ArrayList<String>();
private ArrayList<String> completed = new ArrayList<String>();
private ArrayList<String> id = new ArrayList<String>();
private ArrayList<String> verifier = new ArrayList<String>();
private ArrayList<String> creator = new ArrayList<String>();
private FetchData data = new FetchData();
public void setId(ArrayList<String> id) {
this.id = id;
@ -40,6 +45,14 @@ public class GuiData {
return id;
}
public ArrayList<String> getVerifier() {
return verifier;
}
public ArrayList<String> 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"));
}
}
}

View file

@ -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);

1
ver/version.txt Normal file
View file

@ -0,0 +1 @@
1.0