smmd rework part 1
due to changes on the smmdb api i have to rework the smmdb integration
This commit is contained in:
parent
9930a4cb15
commit
7a2112a759
1
bin/.gitignore
vendored
1
bin/.gitignore
vendored
@ -1 +1,2 @@
|
||||
/application/
|
||||
/datatypes/
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -535,10 +535,12 @@ public class MainWindowController {
|
||||
|
||||
for (int i = 0; i < courses.size(); i++) {
|
||||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user