diff --git a/.classpath b/.classpath index 90596a1..e60ceff 100644 --- a/.classpath +++ b/.classpath @@ -18,5 +18,6 @@ + diff --git a/bin/.gitignore b/bin/.gitignore index 2126dd2..a4b7045 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,3 +1,3 @@ /application/ -/cloudControllerInstances/ -/resources/ +/dataTypes/ +/datatypes/ diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index b184e96..cc32e0b 100644 Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class index 86927cb..500c251 100644 Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class index 67adbb6..9bf613a 100644 Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class index 66a3642..9c182b2 100644 Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ diff --git a/bin/application/MainWindowController$5.class b/bin/application/MainWindowController$5.class index 5da9779..4b94679 100644 Binary files a/bin/application/MainWindowController$5.class and b/bin/application/MainWindowController$5.class differ diff --git a/bin/application/MainWindowController$6.class b/bin/application/MainWindowController$6.class index 134c71e..2880dcb 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index 08b0699..ee393b4 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index bc14a50..8bcf389 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/bin/libraries/minimal-json-0.9.4.jar b/bin/libraries/minimal-json-0.9.4.jar new file mode 100644 index 0000000..14c0633 Binary files /dev/null and b/bin/libraries/minimal-json-0.9.4.jar differ diff --git a/bin/resources/icons/ic_add_circle_black_24dp_1x.png b/bin/resources/icons/ic_add_circle_black_24dp_1x.png new file mode 100644 index 0000000..ac376d0 Binary files /dev/null and b/bin/resources/icons/ic_add_circle_black_24dp_1x.png differ diff --git a/bin/resources/icons/ic_add_circle_white_24dp_1x.png b/bin/resources/icons/ic_add_circle_white_24dp_1x.png new file mode 100644 index 0000000..9121d99 Binary files /dev/null and b/bin/resources/icons/ic_add_circle_white_24dp_1x.png differ diff --git a/bin/resources/icons/ic_cached_black_24dp_1x.png b/bin/resources/icons/ic_cached_black_24dp_1x.png new file mode 100644 index 0000000..83b946a Binary files /dev/null and b/bin/resources/icons/ic_cached_black_24dp_1x.png differ diff --git a/bin/resources/icons/ic_cached_white_24dp_1x.png b/bin/resources/icons/ic_cached_white_24dp_1x.png new file mode 100644 index 0000000..91dc808 Binary files /dev/null and b/bin/resources/icons/ic_cached_white_24dp_1x.png differ diff --git a/bin/resources/icons/ic_get_app_black_24dp_1x.png b/bin/resources/icons/ic_get_app_black_24dp_1x.png new file mode 100644 index 0000000..c2c845e Binary files /dev/null and b/bin/resources/icons/ic_get_app_black_24dp_1x.png differ diff --git a/bin/resources/icons/ic_get_app_white_24dp_1x.png b/bin/resources/icons/ic_get_app_white_24dp_1x.png new file mode 100644 index 0000000..d400472 Binary files /dev/null and b/bin/resources/icons/ic_get_app_white_24dp_1x.png differ diff --git a/bin/resources/icons/ic_info_black_24dp_1x.png b/bin/resources/icons/ic_info_black_24dp_1x.png new file mode 100644 index 0000000..5ef3dc0 Binary files /dev/null and b/bin/resources/icons/ic_info_black_24dp_1x.png differ diff --git a/bin/resources/icons/ic_info_white_24dp_1x.png b/bin/resources/icons/ic_info_white_24dp_1x.png new file mode 100644 index 0000000..17faafb Binary files /dev/null and b/bin/resources/icons/ic_info_white_24dp_1x.png differ diff --git a/bin/resources/icons/ic_settings_black_24dp_1x.png b/bin/resources/icons/ic_settings_black_24dp_1x.png new file mode 100644 index 0000000..c59419c Binary files /dev/null and b/bin/resources/icons/ic_settings_black_24dp_1x.png differ diff --git a/bin/resources/icons/ic_settings_white_24dp_1x.png b/bin/resources/icons/ic_settings_white_24dp_1x.png new file mode 100644 index 0000000..8909c35 Binary files /dev/null and b/bin/resources/icons/ic_settings_white_24dp_1x.png differ diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index bc91bff..622f02b 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -25,6 +25,7 @@ import java.math.BigInteger; import java.sql.SQLException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.Optional; import java.util.Properties; @@ -39,6 +40,7 @@ import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXToggleButton; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; +import datatypes.SmmdbApiDataType; import javafx.animation.FadeTransition; import javafx.animation.ParallelTransition; import javafx.animation.TranslateTransition; @@ -140,6 +142,7 @@ public class MainWindowController { Main main; dbController dbController; + SmmdbApiQuery smmdbApiQuery; playGame playGame; private boolean menuTrue = false; private boolean settingsTrue = false; @@ -191,6 +194,7 @@ public class MainWindowController { public void setMain(Main main) { this.main = main; dbController = new dbController(this); + smmdbApiQuery = new SmmdbApiQuery(); } void initUI(){ @@ -200,7 +204,7 @@ public class MainWindowController { fullscreenToggleBtn.setSelected(isFullscreen()); cloudSyncToggleBtn.setSelected(isCloudSync()); edit.setDisable(true); - smmdbBtn.setDisable(true); + smmdbBtn.setDisable(true); //TODO applyColor(); } @@ -470,9 +474,13 @@ public class MainWindowController { @FXML void smmdbBtnAction() { - System.out.println("yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeehaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + //TODO show TODO smmdbAnchorPane + + //TODO start query + ArrayList courses = new ArrayList<>(smmdbApiQuery.startQuery()); + System.out.println(courses.size()); } - + @FXML void playBtnAction(ActionEvent event) throws InterruptedException, IOException{ dbController.setLastPlayed(selectedGameTitleID); diff --git a/src/application/SmmdbApiQuery.java b/src/application/SmmdbApiQuery.java new file mode 100644 index 0000000..ca8d1eb --- /dev/null +++ b/src/application/SmmdbApiQuery.java @@ -0,0 +1,78 @@ +/** + * smmdbapi query + * start query and return all courses as ArrayList + */ +package application; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.ArrayList; +import com.eclipsesource.json.Json; +import com.eclipsesource.json.JsonArray; +import com.eclipsesource.json.JsonObject; +import com.eclipsesource.json.JsonValue; + +import datatypes.SmmdbApiDataType; + +public class SmmdbApiQuery { + + private String url = "http://smmdb.ddns.net/api/getcourses?"; + + public SmmdbApiQuery() { + //Auto-generated constructor stub + } + + //TODO needs to be tested + public ArrayList startQuery() { + ArrayList courseIDs = new ArrayList<>(); + ArrayList course = new ArrayList<>(); + String output = ""; + + + try { + URL apiUrl = new URL(url); + BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream())); + output = ina.readLine(); + ina.close(); + } catch (IOException e) { + //Auto-generated catch block + e.printStackTrace(); + } + + JsonObject mainObject = Json.parse(output).asObject().get("courses").asObject(); + System.out.println(mainObject); + + + JsonArray objectAssets = Json.parse(output).asObject().get("order").asArray(); + for (JsonValue asset : objectAssets) { + courseIDs.add(asset.asInt()); + } + + //FIXME if parameter = null query will stop + for (int i = 0; i < courseIDs.size(); i++) { + System.out.println(i); + JsonObject singleObject = mainObject.get(courseIDs.get(i).toString()).asObject(); + int id = singleObject.getInt("id", 0); + int owner = singleObject.getInt("owner", 0); + int coursetype = singleObject.getInt("coursetype", 0); + int leveltype = singleObject.getInt("leveltype", 0); + int difficulty = singleObject.getInt("difficulty", 0); + int lastmodified = singleObject.getInt("lastmodified", 0); + int uploaded = singleObject.getInt("uploaded", 0); + int downloads = singleObject.getInt("downloads", 0); + int stars = singleObject.getInt("stars", 0); + int ispackage = singleObject.getInt("ispackage", 0); + int updatereq = singleObject.getInt("updatereq", 0); +// String nintendoid = singleObject.getString("nintendoid", ""); + String title = singleObject.getString("title", ""); + + course.add(new SmmdbApiDataType(id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, + stars, ispackage, updatereq, title)); + } + + return course; + } + +} diff --git a/src/datatypes/SmmdbApiDataType.java b/src/datatypes/SmmdbApiDataType.java new file mode 100644 index 0000000..7b3661e --- /dev/null +++ b/src/datatypes/SmmdbApiDataType.java @@ -0,0 +1,200 @@ +package datatypes; + +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +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 difficulty = new SimpleIntegerProperty(); + private final IntegerProperty lastmodified = new SimpleIntegerProperty(); + private final IntegerProperty uploaded = new SimpleIntegerProperty(); + private final IntegerProperty downloads = new SimpleIntegerProperty(); + private final IntegerProperty stars = new SimpleIntegerProperty(); + private final IntegerProperty ispackage = new SimpleIntegerProperty(); + private final IntegerProperty updatereq = new SimpleIntegerProperty(); +// 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, + final int lastmodified, final int uploaded, final int downloads, final int stars, final int ispackage, + final int updatereq, final String title) { + this.id.set(id); + this.owner.set(owner); + this.coursetype.set(coursetype); +// this.nintendoid.set(nintendoid); + this.leveltype.set(leveltype); + this.difficulty.set(difficulty); + this.lastmodified.set(lastmodified); + this.uploaded.set(uploaded); + this.downloads.set(downloads); + this.stars.set(stars); + this.title.set(title); + this.ispackage.set(ispackage); + this.updatereq.set(updatereq); + } + + public IntegerProperty idProperty(){ + return id; + } + + public IntegerProperty ownerProperty(){ + return owner; + } + + public IntegerProperty coursetypeProperty(){ + return coursetype; + } + +// public StringProperty nintendoidProperty(){ +// return nintendoid; +// } + + public IntegerProperty leveltypeProperty(){ + return leveltype; + } + + public IntegerProperty difficultyProperty(){ + return difficulty; + } + + public IntegerProperty lastmodifiedProperty(){ + return lastmodified; + } + + public IntegerProperty uploadedProperty(){ + return uploaded; + } + + public IntegerProperty downloadsProperty(){ + return downloads; + } + + public IntegerProperty starsProperty(){ + return stars; + } + + public IntegerProperty ispackageProperty(){ + return ispackage; + } + + public IntegerProperty updatereqProperty(){ + return updatereq; + } + + public StringProperty titleProperty(){ + return title; + } + + public int getId() { + return idProperty().get(); + } + + public int getOwner() { + return ownerProperty().get(); + } + + public int getCoursetype() { + return coursetypeProperty().get(); + } + + public int getLeveltype() { + return leveltypeProperty().get(); + } + + public int getDifficulty() { + return difficultyProperty().get(); + } + + public int getLastmodified() { + return lastmodifiedProperty().get(); + } + + public int getUploaded() { + return uploadedProperty().get(); + } + + public int getDownloads() { + return downloadsProperty().get(); + } + + public int getStars() { + return starsProperty().get(); + } + + public int getIspackage() { + return ispackageProperty().get(); + } + + public int getUpdatereq() { + return updatereqProperty().get(); + } + +// public String getNintendoid() { +// return nintendoidProperty().get(); +// } + + public String getTitle() { + return titleProperty().get(); + } + + public final void setId(int id) { + idProperty().set(id); + } + + public final void setOwner(int owner) { + ownerProperty().set(owner); + } + + public final void setCoursetype(int coursetype) { + coursetypeProperty().set(coursetype); + } + + public final void setLeveltype(int leveltype) { + leveltypeProperty().set(leveltype); + } + + public final void setDifficulty(int difficulty) { + difficultyProperty().set(difficulty); + } + + public final void setLastmodified(int lastmodified) { + lastmodifiedProperty().set(lastmodified); + } + + public final void setUploaded(int uploaded) { + uploadedProperty().set(uploaded); + } + + public final void setDownloads(int downloads) { + downloadsProperty().set(downloads); + } + + public final void setStars(int stars) { + starsProperty().set(stars); + } + + public final void setIspackage(int ispackage) { + ispackageProperty().set(ispackage); + } + + public final void setUpdatereq(int updatereq) { + updatereqProperty().set(updatereq); + } + +// public final void setNintendoid(String nintendoid) { +// nintendoidProperty().set(nintendoid); +// } + + public final void setTitle(String title) { + titleProperty().set(title); + } + +} diff --git a/src/libraries/minimal-json-0.9.4.jar b/src/libraries/minimal-json-0.9.4.jar new file mode 100644 index 0000000..14c0633 Binary files /dev/null and b/src/libraries/minimal-json-0.9.4.jar differ