smmdb api integration rework part 2/2

* fixed all remaining parameters
* course is downloaded as .zip now
* junrar is replaced by zip4j
This commit is contained in:
Jannik 2017-08-26 00:13:09 +02:00
parent 7a2112a759
commit 4c8a0a51e9
28 changed files with 237 additions and 231 deletions

View File

@ -17,11 +17,11 @@
<classpathentry kind="lib" path="src/libraries/google_apis/jackson-core-2.8.8.jar"/> <classpathentry kind="lib" path="src/libraries/google_apis/jackson-core-2.8.8.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-codec-1.10.jar"/> <classpathentry kind="lib" path="src/libraries/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="src/libraries/minimal-json-0.9.4.jar"/> <classpathentry kind="lib" path="src/libraries/minimal-json-0.9.4.jar"/>
<classpathentry kind="lib" path="src/libraries/junrar-0.7.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-logging-api-1.1.jar"/> <classpathentry kind="lib" path="src/libraries/commons-logging-api-1.1.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-vfs2-2.1.1744488.2.jar"/> <classpathentry kind="lib" path="src/libraries/commons-vfs2-2.1.1744488.2.jar"/>
<classpathentry kind="lib" path="src/libraries/flow-8.0.1.jar"/> <classpathentry kind="lib" path="src/libraries/flow-8.0.1.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.7.0.jar"/> <classpathentry kind="lib" path="src/libraries/jfoenix-1.7.0.jar"/>
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.19.3.jar"/> <classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.19.3.jar"/>
<classpathentry kind="lib" path="src/libraries/zip4j-1.3.2.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

View File

@ -16,14 +16,16 @@
* TREE TABLE CSS * TREE TABLE CSS
*/ */
.tree-table-view { .tree-table-view {
-fx-tree-table-color: rgba(0, 168, 204, 0.2); -fx-tree-table-color: rgba(0, 168, 204, 0.2);
-fx-tree-table-rippler-color: rgba(0, 168, 204, 0.4); -fx-tree-table-rippler-color: rgba(0, 168, 204, 0.4);
} }
.tree-table-view:focused .tree-table-row-cell:selected { .tree-table-view:focused .tree-table-row-cell:selected {
-fx-background-color: -fx-tree-table-color; -fx-background-color: -fx-tree-table-color;
-fx-table-cell-border-color: -fx-tree-table-color; -fx-table-cell-border-color: -fx-tree-table-color;
-fx-text-fill: BLACK; -fx-text-fill: BLACK;
} }
@ -31,10 +33,13 @@
-fx-text-fill: BLACK; -fx-text-fill: BLACK;
} }
.tree-table-view .jfx-rippler { .tree-table-view .jfx-rippler {
-jfx-rippler-fill: -fx-tree-table-rippler-color; -jfx-rippler-fill: -fx-tree-table-rippler-color;
} }
.tree-table-view .column-header, .tree-table-view .column-header,
.tree-table-view .column-header-background, .tree-table-view .column-header-background,
.tree-table-view .column-header-background .filler { .tree-table-view .column-header-background .filler {

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -86,6 +86,17 @@ public class Main extends Application {
} }
//startup checks //startup checks
//check if client_secret.jason is present
if (Main.class.getResourceAsStream("/resources/client_secret.json") == null) {
System.err.println("client_secret is missing!!!!!");
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("cemu_UI");
alert.setHeaderText("Error");
alert.setContentText("client_secret is missing! Please contact the maintainer. \nIf you compiled cemu_UI by yourself see: \nhttps://github.com/Seil0/cemu_UI/wiki/Documantation");
alert.showAndWait();
}
System.out.println("Directory: " + directory.exists()); System.out.println("Directory: " + directory.exists());
System.out.println("configfile: " + configFile.exists()); System.out.println("configfile: " + configFile.exists());
if(directory.exists() != true){ if(directory.exists() != true){

View File

@ -40,10 +40,6 @@ import javax.swing.ProgressMonitor;
import javax.swing.ProgressMonitorInputStream; import javax.swing.ProgressMonitorInputStream;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import com.github.junrar.Archive;
import com.github.junrar.exception.RarException;
import com.github.junrar.impl.FileVolumeManager;
import com.github.junrar.rarfile.FileHeader;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXColorPicker; import com.jfoenix.controls.JFXColorPicker;
import com.jfoenix.controls.JFXDialog; import com.jfoenix.controls.JFXDialog;
@ -95,6 +91,8 @@ import javafx.scene.text.TextFlow;
import javafx.stage.DirectoryChooser; import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import javafx.util.Duration; import javafx.util.Duration;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
public class MainWindowController { public class MainWindowController {
@ -184,19 +182,19 @@ public class MainWindowController {
private JFXTreeTableView<CourseTableDataType> courseTreeTable = new JFXTreeTableView<CourseTableDataType>(); private JFXTreeTableView<CourseTableDataType> courseTreeTable = new JFXTreeTableView<CourseTableDataType>();
@FXML @FXML
TreeItem<CourseTableDataType> root = new TreeItem<>(new CourseTableDataType("",0,0,0)); TreeItem<CourseTableDataType> root = new TreeItem<>(new CourseTableDataType("","",0,0));
@FXML @FXML
private JFXTreeTableColumn<CourseTableDataType, String> titleColumn = new JFXTreeTableColumn<>("title"); private JFXTreeTableColumn<CourseTableDataType, String> titleColumn = new JFXTreeTableColumn<>("title");
@FXML
private JFXTreeTableColumn<CourseTableDataType, String> idColumn = new JFXTreeTableColumn<>("id");
@FXML @FXML
private JFXTreeTableColumn<CourseTableDataType, Integer> starsColumn = new JFXTreeTableColumn<>("stars"); private JFXTreeTableColumn<CourseTableDataType, Integer> starsColumn = new JFXTreeTableColumn<>("stars");
@FXML @FXML
private JFXTreeTableColumn<CourseTableDataType, Integer> downloadsColumn = new JFXTreeTableColumn<>("downloads"); private JFXTreeTableColumn<CourseTableDataType, Integer> timeColumn = new JFXTreeTableColumn<>("time");
@FXML
private JFXTreeTableColumn<CourseTableDataType, Integer> idColumn = new JFXTreeTableColumn<>("id");
Main main; Main main;
dbController dbController; dbController dbController;
@ -217,14 +215,14 @@ public class MainWindowController {
private String color; private String color;
private String dialogBtnStyle; private String dialogBtnStyle;
private String version = "0.1.6"; private String version = "0.1.6";
private String buildNumber = "029"; private String buildNumber = "031";
private String versionName = "Throwback Galaxy"; private String versionName = "Throwback Galaxy";
private int xPos = -200; private int xPos = -200;
private int yPos = 17; private int yPos = 17;
private int xPosHelper; private int xPosHelper;
private int selectedUIDataIndex; private int selectedUIDataIndex;
private int selected; private int selected;
private int id; private String id;
private DirectoryChooser directoryChooser = new DirectoryChooser(); private DirectoryChooser directoryChooser = new DirectoryChooser();
private File dirWin = new File(System.getProperty("user.home") + "/Documents/cemu_UI"); private File dirWin = new File(System.getProperty("user.home") + "/Documents/cemu_UI");
private File dirLinux = new File(System.getProperty("user.home") + "/cemu_UI"); private File dirLinux = new File(System.getProperty("user.home") + "/cemu_UI");
@ -276,7 +274,7 @@ public class MainWindowController {
//initialize courseTable //initialize courseTable
titleColumn.setPrefWidth(160); titleColumn.setPrefWidth(160);
downloadsColumn.setPrefWidth(127); timeColumn.setPrefWidth(127);
starsColumn.setPrefWidth(100); starsColumn.setPrefWidth(100);
courseTreeTable.setRoot(root); courseTreeTable.setRoot(root);
@ -284,14 +282,17 @@ public class MainWindowController {
courseTreeTable.setEditable(false); courseTreeTable.setEditable(false);
titleColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().title); titleColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().title);
idColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().id);
starsColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().stars.asObject()); starsColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().stars.asObject());
downloadsColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().downloads.asObject()); timeColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().time.asObject());
idColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().id.asObject());
courseTreeTable.getColumns().setAll(titleColumn, downloadsColumn, starsColumn, idColumn); courseTreeTable.getColumns().setAll(titleColumn, timeColumn, starsColumn, idColumn);
courseTreeTable.getColumns().get(3).setVisible(false); //hide idColumn (important) courseTreeTable.getColumns().get(3).setVisible(false); //hide idColumn (important)
} }
/**
* initialize all actions not initialized by a own method
*/
void initActions() { void initActions() {
System.out.println("initializing Actions... "); System.out.println("initializing Actions... ");
@ -531,22 +532,19 @@ public class MainWindowController {
@Override @Override
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){ public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){
selected = courseTreeTable.getSelectionModel().getSelectedIndex(); //get selected item selected = courseTreeTable.getSelectionModel().getSelectedIndex(); //get selected item
id = idColumn.getCellData(selected); //get name of selected item
//FIXME if a item is selected and you change the sorting,you can't select a new item
id = idColumn.getCellData(selected); //get name of selected item
for (int i = 0; i < courses.size(); i++) { 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 {
try { // System.out.println("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3");
// URL url = new URL("http://smmdb.ddns.net/img/courses/thumbnails/" + id + ".pic"); //alt URL url = new URL("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3");
System.out.println("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3"); Image image = new Image(url.toURI().toString());
URL url = new URL("http://smmdb.ddns.net/courseimg/" + id + "_full.jpg?v=3"); smmdbImageView.setImage(image);
} catch (MalformedURLException | URISyntaxException e) {
Image image = new Image(url.toURI().toString()); e.printStackTrace();
smmdbImageView.setImage(image);
} catch (MalformedURLException | URISyntaxException e) {
e.printStackTrace();
}
} else {
smmdbImageView.setImage(close_black); smmdbImageView.setImage(close_black);
} }
addCourseDescription(courses.get(i)); addCourseDescription(courses.get(i));
@ -646,8 +644,8 @@ public class MainWindowController {
//add query response to courseTreeTable //add query response to courseTreeTable
for(int i = 0; i < courses.size(); i++){ for(int i = 0; i < courses.size(); i++){
CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), courses.get(i).getDownloads(), CourseTableDataType helpCourse = new CourseTableDataType(courses.get(i).getTitle(), courses.get(i).getId(),
courses.get(i).getStars(), courses.get(i).getId()); courses.get(i).getTime(), courses.get(i).getStars());
root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); //add data to root-node root.getChildren().add(new TreeItem<CourseTableDataType>(helpCourse)); //add data to root-node
} }
@ -712,7 +710,7 @@ public class MainWindowController {
@FXML @FXML
void smmdbDownloadBtnAction(ActionEvent event){ void smmdbDownloadBtnAction(ActionEvent event){
String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip"; String downloadUrl = "http://smmdb.ddns.net/api/downloadcourse?id=" + id + "&type=zip";
String downloadFileURL = getCemuPath() + "/" + id + ".rar"; //getCemuPath() + "/" + smmID + "/" + id + ".rar" String downloadFileURL = getCemuPath() + "/" + id + ".zip"; //getCemuPath() + "/" + smmID + "/" + id + ".rar"
String outputFile = getCemuPath() + "/"; String outputFile = getCemuPath() + "/";
try { try {
@ -728,44 +726,29 @@ public class MainWindowController {
System.out.println("downloaded successfull"); System.out.println("downloaded successfull");
File downloadFile = new File(downloadFileURL); File downloadFile = new File(downloadFileURL);
Archive a = null;
try { String source = downloadFileURL;
a = new Archive(new FileVolumeManager(downloadFile)); String destination = null;
} catch (RarException | IOException e) {
// Auto-generated catch block for (int i = 0; i < smmIDs.size(); i++) {
e.printStackTrace(); if (new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i)).exists()) {
} File courseDirectory = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i) + "/" + id);
if (a != null) { System.out.println("Path: " + courseDirectory.getAbsolutePath());
a.getMainHeader().print(); if (!courseDirectory.exists()) {
FileHeader fh = a.nextFileHeader(); courseDirectory.mkdir();
for (int i = 0; i < smmIDs.size(); i++) {
if (new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(i)).exists()) {
File courseDirectory = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(0) + "/" + fh.getFileNameString().substring(0, fh.getFileNameString().indexOf('\\')));
System.out.println("Path: " + courseDirectory.getAbsolutePath());
if (!courseDirectory.exists()) {
courseDirectory.mkdir();
}
while (fh != null) {
try {
File out = new File(outputFile + "mlc01/emulatorSave/" + smmIDs.get(0) + "/" + fh.getFileNameString().trim());
if (!out.getAbsolutePath().equals(courseDirectory.getAbsolutePath())) {
System.out.println(out.getAbsolutePath());
FileOutputStream os = new FileOutputStream(out);
a.extractFile(fh, os);
os.close();
}
} catch (RarException | IOException e) {
// Auto-generated catch block
e.printStackTrace();
}
fh = a.nextFileHeader();
}
} }
} destination = courseDirectory.getPath();
}
} }
a.close();
try {
ZipFile zipFile = new ZipFile(source);
zipFile.extractAll(destination);
} catch (ZipException e) {
e.printStackTrace();
System.err.println("an error occurred during unziping the file!");
}
downloadFile.delete(); downloadFile.delete();
} catch (IOException e) { } catch (IOException e) {
System.err.println("something went wrong during downloading the course"); System.err.println("something went wrong during downloading the course");
@ -1056,46 +1039,53 @@ public class MainWindowController {
} }
private void addCourseDescription(SmmdbApiDataType course) { private void addCourseDescription(SmmdbApiDataType course) {
String coursetype; String courseTheme;
String leveltype; String gameStyle;
String difficulty; String difficulty;
String autoscroll;
smmdbTextFlow.getChildren().remove(0, smmdbTextFlow.getChildren().size()); smmdbTextFlow.getChildren().remove(0, smmdbTextFlow.getChildren().size());
nameText.clear(); nameText.clear();
courseText.clear(); courseText.clear();
switch (course.getCoursetype()) { switch (course.getCourseTheme()) {
case 0: case 0:
coursetype = "Creation"; courseTheme = "Ground";
break; break;
case 1: case 1:
coursetype = "Recreation"; courseTheme = "Underground";
break; break;
case 2: case 2:
coursetype = "Wii U Dump"; courseTheme = "Castle";
break;
case 3:
courseTheme = "Airship";
break;
case 4:
courseTheme = "Underwater";
break;
case 5:
courseTheme = "Ghost House";
break; break;
default: default:
coursetype = "notset"; courseTheme = "notset";
break; break;
} }
switch (course.getGamestyle()) { switch (course.getGameStyle()) {
case 0: case 0:
leveltype = "NSMBU"; gameStyle = "SMB";
break; break;
case 1: case 1:
leveltype = "SMW"; gameStyle = "SMB3";
break; break;
case 2: case 2:
leveltype = "SMB3"; gameStyle = "SMW";
break; break;
case 3: case 3:
leveltype = "SMB"; gameStyle = "NSMBU";
break;
case 4:
leveltype = "Mixed";
break; break;
default: default:
leveltype = "notset"; gameStyle = "notset";
break; break;
} }
@ -1120,23 +1110,45 @@ public class MainWindowController {
break; break;
} }
switch (course.getAutoScroll()) {
case 0:
autoscroll = "disabled";
break;
case 1:
autoscroll = "slow";
break;
case 2:
autoscroll = "medium";
break;
case 3:
autoscroll = "fast";
break;
default:
autoscroll = "notset";
break;
}
nameText.add(0, new Text("title" + ": ")); nameText.add(0, new Text("title" + ": "));
nameText.add(1, new Text("owner" + ": ")); nameText.add(1, new Text("owner" + ": "));
nameText.add(2, new Text("coursetype" + ": ")); nameText.add(2, new Text("Course-Theme" + ": "));
nameText.add(3, new Text("leveltype" + ": ")); nameText.add(3, new Text("Game-Style" + ": "));
nameText.add(4, new Text("difficulty" + ": ")); nameText.add(4, new Text("difficulty" + ": "));
nameText.add(5, new Text("lastmodified" + ": ")); nameText.add(5, new Text("Auto-Scroll" + ": "));
nameText.add(6, new Text("uploaded" + ": ")); nameText.add(6, new Text("Time" + ": "));
nameText.add(7, new Text("nintendoid" + ": ")); nameText.add(7, new Text("lastmodified" + ": "));
nameText.add(8, new Text("uploaded" + ": "));
nameText.add(9, new Text("nintendoid" + ": "));
courseText.add(0, new Text(course.getTitle() + "\n")); courseText.add(0, new Text(course.getTitle() + "\n"));
courseText.add(1, new Text(Integer.toString(course.getOwner()) + "\n")); courseText.add(1, new Text(course.getOwner() + "\n"));
courseText.add(2, new Text(coursetype + "\n")); courseText.add(2, new Text(courseTheme + "\n"));
courseText.add(3, new Text(leveltype + "\n")); courseText.add(3, new Text(gameStyle + "\n"));
courseText.add(4, new Text(difficulty + "\n")); courseText.add(4, new Text(difficulty + "\n"));
courseText.add(5, new Text(new java.util.Date((long)course.getLastmodified()*1000) + "\n")); courseText.add(5, new Text(autoscroll + "\n"));
courseText.add(6, new Text(new java.util.Date((long)course.getUploaded()*1000) + "\n")); courseText.add(6, new Text(course.getTime() + "\n"));
courseText.add(7, new Text(course.getNintendoid() + "\n")); courseText.add(7, new Text(new java.util.Date((long)course.getLastmodified()*1000) + "\n"));
courseText.add(8, new Text(new java.util.Date((long)course.getUploaded()*1000) + "\n"));
courseText.add(9, new Text(course.getNintendoid() + "\n"));
for(int i=0; i<nameText.size(); i++){ for(int i=0; i<nameText.size(); i++){
nameText.get(i).setFont(Font.font ("System", FontWeight.BOLD, 14)); nameText.get(i).setFont(Font.font ("System", FontWeight.BOLD, 14));
@ -1146,7 +1158,11 @@ public class MainWindowController {
} }
//TODO xPosHelper based on window with breite -24(windows, Linx = 36) //TODO Changelistener for resizing
/**
* xPosHelper based on window width = -24(Windows)/-36(Linux)
* calculates how many games can be displayed in one row
*/
private void generatePosition() { private void generatePosition() {
int xPosHelperMax; int xPosHelperMax;
if(System.getProperty("os.name").equals("Linux")){ if(System.getProperty("os.name").equals("Linux")){
@ -1361,6 +1377,9 @@ public class MainWindowController {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
/**
* @return the main color in hexadecimal format
*/
private String hexToRgb() { private String hexToRgb() {
System.out.println(getColor()); System.out.println(getColor());
int hex = Integer.parseInt(getColor().substring(0, 5), 16); int hex = Integer.parseInt(getColor().substring(0, 5), 16);
@ -1372,6 +1391,14 @@ public class MainWindowController {
return r + ", " + g + ", " + b; return r + ", " + g + ", " + b;
} }
/**
*
* @param originalImage original image which size is changed
* @param type type of the original image (PNG,JPEG,...)
* @param imgWidth wanted width
* @param imgHeigth wanted height
* @return the rezised image
*/
private static BufferedImage resizeImage(BufferedImage originalImage, int type, int imgWidth, int imgHeigth) { private static BufferedImage resizeImage(BufferedImage originalImage, int type, int imgWidth, int imgHeigth) {
BufferedImage resizedImage = new BufferedImage(imgWidth, imgHeigth, type); BufferedImage resizedImage = new BufferedImage(imgWidth, imgHeigth, type);
Graphics2D g = resizedImage.createGraphics(); Graphics2D g = resizedImage.createGraphics();

View File

@ -16,14 +16,16 @@
* TREE TABLE CSS * TREE TABLE CSS
*/ */
.tree-table-view { .tree-table-view {
-fx-tree-table-color: rgba(0, 168, 204, 0.2); -fx-tree-table-color: rgba(0, 168, 204, 0.2);
-fx-tree-table-rippler-color: rgba(0, 168, 204, 0.4); -fx-tree-table-rippler-color: rgba(0, 168, 204, 0.4);
} }
.tree-table-view:focused .tree-table-row-cell:selected { .tree-table-view:focused .tree-table-row-cell:selected {
-fx-background-color: -fx-tree-table-color; -fx-background-color: -fx-tree-table-color;
-fx-table-cell-border-color: -fx-tree-table-color; -fx-table-cell-border-color: -fx-tree-table-color;
-fx-text-fill: BLACK; -fx-text-fill: BLACK;
} }
@ -31,10 +33,13 @@
-fx-text-fill: BLACK; -fx-text-fill: BLACK;
} }
.tree-table-view .jfx-rippler { .tree-table-view .jfx-rippler {
-jfx-rippler-fill: -fx-tree-table-rippler-color; -jfx-rippler-fill: -fx-tree-table-rippler-color;
} }
.tree-table-view .column-header, .tree-table-view .column-header,
.tree-table-view .column-header-background, .tree-table-view .column-header-background,
.tree-table-view .column-header-background .filler { .tree-table-view .column-header-background .filler {

View File

@ -11,7 +11,6 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import com.eclipsesource.json.Json; import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonArray; import com.eclipsesource.json.JsonArray;
import com.eclipsesource.json.JsonObject;
import com.eclipsesource.json.JsonValue; import com.eclipsesource.json.JsonValue;
import datatypes.SmmdbApiDataType; import datatypes.SmmdbApiDataType;
@ -24,9 +23,11 @@ public class SmmdbApiQuery {
//Auto-generated constructor stub //Auto-generated constructor stub
} }
//start api query /**
* start smmdb api query
* @return a ArryList with all courses found at smmdb
*/
public ArrayList<SmmdbApiDataType> startQuery() { public ArrayList<SmmdbApiDataType> startQuery() {
ArrayList<Integer> courseIDs = new ArrayList<>();
ArrayList<SmmdbApiDataType> course = new ArrayList<>(); ArrayList<SmmdbApiDataType> course = new ArrayList<>();
String output = ""; String output = "";
@ -48,93 +49,77 @@ public class SmmdbApiQuery {
JsonArray items = Json.parse(apiOutput).asObject().get("courses").asArray(); JsonArray items = Json.parse(apiOutput).asObject().get("courses").asArray();
for (JsonValue item : items) { for (JsonValue item : items) {
int id, owner, coursetype, gamestyle, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq; int courseTheme, gameStyle, difficulty, lastmodified, uploaded, autoScroll, stars ,time;
String nintendoid, title; String owner, id, nintendoid, title;
//TODO add "courseTheme", "time", "autoScroll"
//geht //geht
try { try {
id = item.asObject().getInt("id", 0); courseTheme = item.asObject().getInt("courseTheme", 9);
} catch (Exception e) { } catch (Exception e) {
id = 9; courseTheme = 9;
} }
//geht //geht
try { try {
owner = item.asObject().getInt("owner", 0); gameStyle = item.asObject().getInt("gameStyle", 9);
} catch (Exception e) { } catch (Exception e) {
owner = 9; gameStyle = 9;
}
//test
try {
coursetype = item.asObject().getInt("coursetype", 0);
} catch (Exception e) {
coursetype = 9;
} }
//geht //geht
try { try {
gamestyle = item.asObject().getInt("gamestyle", 0); difficulty = item.asObject().getInt("difficulty", 9);
} catch (Exception e) {
gamestyle = 9;
}
//geht
try {
difficulty = item.asObject().getInt("difficulty", 0);
} catch (Exception e) { } catch (Exception e) {
difficulty = 9; difficulty = 9;
} }
//geht //geht
try { try {
lastmodified = item.asObject().getInt("lastmodified", 0); lastmodified = item.asObject().getInt("lastmodified", 9);
} catch (Exception e) { } catch (Exception e) {
lastmodified = 9; lastmodified = 9;
} }
//geht //geht
try { try {
uploaded = item.asObject().getInt("uploaded", 0); uploaded = item.asObject().getInt("uploaded", 9);
} catch (Exception e) { } catch (Exception e) {
uploaded = 9; uploaded = 9;
} }
//gestrichen //geht
try { try {
downloads = item.asObject().getInt("downloads", 0); autoScroll = item.asObject().getInt("autoScroll", 9);
} catch (Exception e) { } catch (Exception e) {
downloads = 9; autoScroll = 9;
} }
//geht //geht
try { try {
stars = item.asObject().getInt("stars", 0); stars = item.asObject().getInt("stars", 9);
} catch (Exception e) { } catch (Exception e) {
stars = 9; stars = 9;
} }
//gestrichen //geht
try { try {
hasimage = item.asObject().getInt("hasimage", 0); time = item.asObject().getInt("time", 9);
} catch (Exception e) { } catch (Exception e) {
hasimage = 9; time = 9;
} }
//gestrichen //geht
try { try {
ispackage = item.asObject().getInt("ispackage", 0); owner = item.asObject().getString("owner", "");
} catch (Exception e) { } catch (Exception e) {
ispackage = 9; owner = "notset";
} }
//gestrichen //geht
try { try {
updatereq = item.asObject().getInt("updatereq", 0); id = item.asObject().getString("id", "");
} catch (Exception e) { } catch (Exception e) {
updatereq = 9; id = "notset";
} }
//geht //geht
@ -149,8 +134,8 @@ public class SmmdbApiQuery {
title = "notset"; title = "notset";
} }
course.add(new SmmdbApiDataType(id, owner, coursetype, gamestyle, difficulty, lastmodified, uploaded, downloads, course.add(new SmmdbApiDataType(courseTheme, gameStyle, difficulty, lastmodified, uploaded, autoScroll,
stars, hasimage, ispackage, updatereq, nintendoid, title)); stars, time, owner, id, nintendoid, title));
} }
return course; return course;

View File

@ -13,14 +13,14 @@ import javafx.beans.property.StringProperty;
public class CourseTableDataType extends RecursiveTreeObject<CourseTableDataType> { public class CourseTableDataType extends RecursiveTreeObject<CourseTableDataType> {
public final StringProperty title; public final StringProperty title;
public final IntegerProperty downloads; public final StringProperty id;
public final IntegerProperty time;
public final IntegerProperty stars; public final IntegerProperty stars;
public final IntegerProperty id;
public CourseTableDataType(String title, int downloads, int stars, int id) { public CourseTableDataType(String title, String id, int time, int stars) {
this.title = new SimpleStringProperty(title); this.title = new SimpleStringProperty(title);
this.downloads = new SimpleIntegerProperty(downloads); this.id = new SimpleStringProperty(id);
this.time = new SimpleIntegerProperty(time);
this.stars = new SimpleIntegerProperty(stars); this.stars = new SimpleIntegerProperty(stars);
this.id = new SimpleIntegerProperty(id);
} }
} }

View File

@ -10,58 +10,43 @@ import javafx.beans.property.StringProperty;
public class SmmdbApiDataType { public class SmmdbApiDataType {
private final IntegerProperty id = new SimpleIntegerProperty(); private final IntegerProperty courseTheme = new SimpleIntegerProperty();
private final IntegerProperty owner = new SimpleIntegerProperty(); private final IntegerProperty gameStyle = new SimpleIntegerProperty();
private final IntegerProperty coursetype = new SimpleIntegerProperty();
private final IntegerProperty gamestyle = new SimpleIntegerProperty();
private final IntegerProperty difficulty = new SimpleIntegerProperty(); private final IntegerProperty difficulty = new SimpleIntegerProperty();
private final IntegerProperty lastmodified = new SimpleIntegerProperty(); private final IntegerProperty lastmodified = new SimpleIntegerProperty();
private final IntegerProperty uploaded = new SimpleIntegerProperty(); private final IntegerProperty uploaded = new SimpleIntegerProperty();
private final IntegerProperty downloads = new SimpleIntegerProperty(); private final IntegerProperty autoScroll = new SimpleIntegerProperty();
private final IntegerProperty stars = new SimpleIntegerProperty(); private final IntegerProperty stars = new SimpleIntegerProperty();
private final IntegerProperty hasimage = new SimpleIntegerProperty(); private final IntegerProperty time = new SimpleIntegerProperty();
private final IntegerProperty ispackage = new SimpleIntegerProperty(); private final StringProperty owner = new SimpleStringProperty();
private final IntegerProperty updatereq = new SimpleIntegerProperty(); private final StringProperty id = new SimpleStringProperty();
private final StringProperty nintendoid = new SimpleStringProperty(); private final StringProperty nintendoid = new SimpleStringProperty();
private final StringProperty title = new SimpleStringProperty(); private final StringProperty title = new SimpleStringProperty();
public SmmdbApiDataType(final int id, final int owner, final int coursetype, final int gamestyle, final int difficulty, public SmmdbApiDataType(final int courseTheme, final int gameStyle, final int difficulty, final int lastmodified,
final int lastmodified, final int uploaded, final int downloads, final int stars, final int hasimage, final int uploaded, final int autoScroll, final int stars, final int time,
final int ispackage, final int updatereq, final String nintendoid, final String title) { final String owner, final String id, final String nintendoid, final String title) {
this.id.set(id); this.id.set(id);
this.owner.set(owner); this.owner.set(owner);
this.coursetype.set(coursetype); this.courseTheme.set(courseTheme);
this.gamestyle.set(gamestyle); this.gameStyle.set(gameStyle);
this.difficulty.set(difficulty); this.difficulty.set(difficulty);
this.lastmodified.set(lastmodified); this.lastmodified.set(lastmodified);
this.uploaded.set(uploaded); this.uploaded.set(uploaded);
this.downloads.set(downloads); this.autoScroll.set(autoScroll);
this.stars.set(stars); this.stars.set(stars);
this.hasimage.set(hasimage); this.time.set(time);
this.ispackage.set(ispackage);
this.updatereq.set(updatereq);
this.nintendoid.set(nintendoid); this.nintendoid.set(nintendoid);
this.title.set(title); this.title.set(title);
} }
public IntegerProperty idProperty(){ public IntegerProperty courseThemeProperty(){
return id; return courseTheme;
} }
public IntegerProperty ownerProperty(){
return owner;
}
public IntegerProperty coursetypeProperty(){ public IntegerProperty gameStyleProperty(){
return coursetype; return gameStyle;
}
public StringProperty nintendoidProperty(){
return nintendoid;
}
public IntegerProperty gamestyleProperty(){
return gamestyle;
} }
public IntegerProperty difficultyProperty(){ public IntegerProperty difficultyProperty(){
@ -76,44 +61,40 @@ public class SmmdbApiDataType {
return uploaded; return uploaded;
} }
public IntegerProperty downloadsProperty(){ public IntegerProperty autoScrollProperty(){
return downloads; return autoScroll;
} }
public IntegerProperty starsProperty(){ public IntegerProperty starsProperty(){
return stars; return stars;
} }
public IntegerProperty hasimageProperty(){ public IntegerProperty timeProperty(){
return hasimage; return time;
} }
public IntegerProperty ispackageProperty(){ public StringProperty ownerProperty(){
return ispackage; return owner;
} }
public IntegerProperty updatereqProperty(){ public StringProperty idProperty(){
return updatereq; return id;
}
public StringProperty nintendoidProperty(){
return nintendoid;
} }
public StringProperty titleProperty(){ public StringProperty titleProperty(){
return title; return title;
} }
public int getId() { public int getCourseTheme() {
return idProperty().get(); return courseThemeProperty().get();
} }
public int getOwner() { public int getGameStyle() {
return ownerProperty().get(); return gameStyleProperty().get();
}
public int getCoursetype() {
return coursetypeProperty().get();
}
public int getGamestyle() {
return gamestyleProperty().get();
} }
public int getDifficulty() { public int getDifficulty() {
@ -128,24 +109,24 @@ public class SmmdbApiDataType {
return uploadedProperty().get(); return uploadedProperty().get();
} }
public int getDownloads() { public int getAutoScroll() {
return downloadsProperty().get(); return autoScrollProperty().get();
} }
public int getStars() { public int getStars() {
return starsProperty().get(); return starsProperty().get();
} }
public int getHasimage() { public int getTime() {
return hasimageProperty().get(); return timeProperty().get();
} }
public int getIspackage() { public String getOwner() {
return ispackageProperty().get(); return ownerProperty().get();
} }
public int getUpdatereq() { public String getId() {
return updatereqProperty().get(); return idProperty().get();
} }
public String getNintendoid() { public String getNintendoid() {
@ -156,20 +137,12 @@ public class SmmdbApiDataType {
return titleProperty().get(); return titleProperty().get();
} }
public final void setId(int id) { public final void setCourseTheme(int courseTheme) {
idProperty().set(id); courseThemeProperty().set(courseTheme);
} }
public final void setOwner(int owner) { public final void setGameStyle(int gameStyle) {
ownerProperty().set(owner); gameStyleProperty().set(gameStyle);
}
public final void setCoursetype(int coursetype) {
coursetypeProperty().set(coursetype);
}
public final void setGamestyle(int leveltype) {
gamestyleProperty().set(leveltype);
} }
public final void setDifficulty(int difficulty) { public final void setDifficulty(int difficulty) {
@ -184,26 +157,26 @@ public class SmmdbApiDataType {
uploadedProperty().set(uploaded); uploadedProperty().set(uploaded);
} }
public final void setDownloads(int downloads) { public final void setAutoScroll(int autoScroll) {
downloadsProperty().set(downloads); autoScrollProperty().set(autoScroll);
} }
public final void setStars(int stars) { public final void setStars(int stars) {
starsProperty().set(stars); starsProperty().set(stars);
} }
public final void setHasimage(int hasimage) { public final void setTime(int time) {
hasimageProperty().set(hasimage); timeProperty().set(time);
} }
public final void setIspackage(int ispackage) { public final void setOwner(String owner) {
ispackageProperty().set(ispackage); ownerProperty().set(owner);
} }
public final void setUpdatereq(int updatereq) { public final void setId(String id) {
updatereqProperty().set(updatereq); idProperty().set(id);
} }
public final void setNintendoid(String nintendoid) { public final void setNintendoid(String nintendoid) {
nintendoidProperty().set(nintendoid); nintendoidProperty().set(nintendoid);
} }

Binary file not shown.

Binary file not shown.