diff --git a/bin/.gitignore b/bin/.gitignore index b42b859..9eb92dc 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1 +1,2 @@ /application/ +/datatypes/ diff --git a/bin/application/MainWindowController$10.class b/bin/application/MainWindowController$10.class index 8093678..8395b70 100644 Binary files a/bin/application/MainWindowController$10.class and b/bin/application/MainWindowController$10.class differ diff --git a/bin/application/MainWindowController$11.class b/bin/application/MainWindowController$11.class index 27d8d04..434e483 100644 Binary files a/bin/application/MainWindowController$11.class and b/bin/application/MainWindowController$11.class differ diff --git a/bin/application/MainWindowController$12.class b/bin/application/MainWindowController$12.class index c334047..e7bcebc 100644 Binary files a/bin/application/MainWindowController$12.class and b/bin/application/MainWindowController$12.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index 814c074..06a2747 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController$8.class b/bin/application/MainWindowController$8.class index 95da18f..9ebc86b 100644 Binary files a/bin/application/MainWindowController$8.class and b/bin/application/MainWindowController$8.class differ diff --git a/bin/application/MainWindowController$9.class b/bin/application/MainWindowController$9.class index 19e5083..656851c 100644 Binary files a/bin/application/MainWindowController$9.class and b/bin/application/MainWindowController$9.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index 51f1854..a301f7a 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/bin/application/SmmdbApiQuery.class b/bin/application/SmmdbApiQuery.class index 4b5dc68..bd33fc6 100644 Binary files a/bin/application/SmmdbApiQuery.class and b/bin/application/SmmdbApiQuery.class differ diff --git a/bin/datatypes/SmmdbApiDataType.class b/bin/datatypes/SmmdbApiDataType.class index e5bafb5..12f1bba 100644 Binary files a/bin/datatypes/SmmdbApiDataType.class and b/bin/datatypes/SmmdbApiDataType.class differ diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index 991150f..918b88a 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -534,11 +534,13 @@ public class MainWindowController { id = idColumn.getCellData(selected); //get name of selected item for (int i = 0; i < courses.size(); i++) { - if (courses.get(i).getId() == id) { - + if (courses.get(i).getId() == id) { if (courses.get(i).getHasimage() == 1) { try { - URL url = new URL("http://smmdb.ddns.net/img/courses/thumbnails/" + id + ".pic"); +// URL url = new URL("http://smmdb.ddns.net/img/courses/thumbnails/" + id + ".pic"); //alt + System.out.println("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3"); + URL url = new URL("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3"); + Image image = new Image(url.toURI().toString()); smmdbImageView.setImage(image); } catch (MalformedURLException | URISyntaxException e) { @@ -709,7 +711,7 @@ public class MainWindowController { @FXML void smmdbDownloadBtnAction(ActionEvent event){ - String downloadUrl = "http://smmdb.ddns.net/courses/" + id; + String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip"; String downloadFileURL = getCemuPath() + "/" + id + ".rar"; //getCemuPath() + "/" + smmID + "/" + id + ".rar" String outputFile = getCemuPath() + "/"; @@ -1076,7 +1078,7 @@ public class MainWindowController { break; } - switch (course.getLeveltype()) { + switch (course.getGamestyle()) { case 0: leveltype = "NSMBU"; break; diff --git a/src/application/SmmdbApiQuery.java b/src/application/SmmdbApiQuery.java index 52d66c8..d441fe3 100644 --- a/src/application/SmmdbApiQuery.java +++ b/src/application/SmmdbApiQuery.java @@ -41,93 +41,117 @@ public class SmmdbApiQuery { e.printStackTrace(); } - JsonObject mainObject = Json.parse(output).asObject().get("courses").asObject(); - JsonArray objectAssets = Json.parse(output).asObject().get("order").asArray(); + System.out.println(URL); + System.out.println("{ \"courses\": " + output + "}"); - for (JsonValue asset : objectAssets) { - courseIDs.add(asset.asInt()); - } + String apiOutput = "{ \"courses\": " + output + "}"; - //if value is 9 or "notset" the api returned NULL as value - for (int i = 0; i < courseIDs.size(); i++) { - int id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq; + JsonArray items = Json.parse(apiOutput).asObject().get("courses").asArray(); + for (JsonValue item : items) { + int id, owner, coursetype, gamestyle, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq; String nintendoid, title; - JsonObject singleObject = mainObject.get(courseIDs.get(i).toString()).asObject(); - + + //TODO add "courseTheme", "time", "autoScroll" + + //geht try { - id = singleObject.getInt("id", 0); + id = item.asObject().getInt("id", 0); } catch (Exception e) { id = 9; } + + //geht try { - owner = singleObject.getInt("owner", 0); + owner = item.asObject().getInt("owner", 0); } catch (Exception e) { owner = 9; } + + //test try { - coursetype = singleObject.getInt("coursetype", 0); + coursetype = item.asObject().getInt("coursetype", 0); } catch (Exception e) { coursetype = 9; } + + //geht try { - leveltype = singleObject.getInt("leveltype", 0); + gamestyle = item.asObject().getInt("gamestyle", 0); } catch (Exception e) { - leveltype = 9; + gamestyle = 9; } + + //geht try { - difficulty = singleObject.getInt("difficulty", 0); + difficulty = item.asObject().getInt("difficulty", 0); } catch (Exception e) { difficulty = 9; } + + //geht try { - lastmodified = singleObject.getInt("lastmodified", 0); + lastmodified = item.asObject().getInt("lastmodified", 0); } catch (Exception e) { lastmodified = 9; } + + //geht try { - uploaded = singleObject.getInt("uploaded", 0); + uploaded = item.asObject().getInt("uploaded", 0); } catch (Exception e) { uploaded = 9; } + + //gestrichen try { - downloads = singleObject.getInt("downloads", 0); + downloads = item.asObject().getInt("downloads", 0); } catch (Exception e) { downloads = 9; } + + //geht try { - stars = singleObject.getInt("stars", 0); + stars = item.asObject().getInt("stars", 0); } catch (Exception e) { stars = 9; } + + //gestrichen try { - hasimage = singleObject.getInt("hasimage", 0); + hasimage = item.asObject().getInt("hasimage", 0); } catch (Exception e) { hasimage = 9; } + + //gestrichen try { - ispackage = singleObject.getInt("ispackage", 0); + ispackage = item.asObject().getInt("ispackage", 0); } catch (Exception e) { ispackage = 9; } + + //gestrichen try { - updatereq = singleObject.getInt("updatereq", 0); + updatereq = item.asObject().getInt("updatereq", 0); } catch (Exception e) { updatereq = 9; } + + //geht try { - nintendoid = singleObject.getString("nintendoid", ""); + nintendoid = item.asObject().getString("nintendoid", ""); } catch (Exception e) { nintendoid = "notset"; } try { - title = singleObject.getString("title", "");; + title = item.asObject().getString("title", "");; } catch (Exception e) { title = "notset"; } - course.add(new SmmdbApiDataType(id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, + course.add(new SmmdbApiDataType(id, owner, coursetype, gamestyle, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq, nintendoid, title)); - } + } return course; } diff --git a/src/datatypes/SmmdbApiDataType.java b/src/datatypes/SmmdbApiDataType.java index 8c24c80..2284bb6 100644 --- a/src/datatypes/SmmdbApiDataType.java +++ b/src/datatypes/SmmdbApiDataType.java @@ -13,7 +13,7 @@ public class SmmdbApiDataType { private final IntegerProperty id = new SimpleIntegerProperty(); private final IntegerProperty owner = new SimpleIntegerProperty(); private final IntegerProperty coursetype = new SimpleIntegerProperty(); - private final IntegerProperty leveltype = new SimpleIntegerProperty(); + private final IntegerProperty gamestyle = new SimpleIntegerProperty(); private final IntegerProperty difficulty = new SimpleIntegerProperty(); private final IntegerProperty lastmodified = new SimpleIntegerProperty(); private final IntegerProperty uploaded = new SimpleIntegerProperty(); @@ -25,13 +25,13 @@ public class SmmdbApiDataType { private final StringProperty nintendoid = new SimpleStringProperty(); private final StringProperty title = new SimpleStringProperty(); - public SmmdbApiDataType(final int id, final int owner, final int coursetype, final int leveltype, final int difficulty, + public SmmdbApiDataType(final int id, final int owner, final int coursetype, final int gamestyle, final int difficulty, final int lastmodified, final int uploaded, final int downloads, final int stars, final int hasimage, final int ispackage, final int updatereq, final String nintendoid, final String title) { this.id.set(id); this.owner.set(owner); this.coursetype.set(coursetype); - this.leveltype.set(leveltype); + this.gamestyle.set(gamestyle); this.difficulty.set(difficulty); this.lastmodified.set(lastmodified); this.uploaded.set(uploaded); @@ -60,8 +60,8 @@ public class SmmdbApiDataType { return nintendoid; } - public IntegerProperty leveltypeProperty(){ - return leveltype; + public IntegerProperty gamestyleProperty(){ + return gamestyle; } public IntegerProperty difficultyProperty(){ @@ -112,8 +112,8 @@ public class SmmdbApiDataType { return coursetypeProperty().get(); } - public int getLeveltype() { - return leveltypeProperty().get(); + public int getGamestyle() { + return gamestyleProperty().get(); } public int getDifficulty() { @@ -168,8 +168,8 @@ public class SmmdbApiDataType { coursetypeProperty().set(coursetype); } - public final void setLeveltype(int leveltype) { - leveltypeProperty().set(leveltype); + public final void setGamestyle(int leveltype) { + gamestyleProperty().set(leveltype); } public final void setDifficulty(int difficulty) {