smmdbapi part 4

* added additional information and finished ui design
This commit is contained in:
Jannik 2017-06-18 00:33:07 +02:00
parent fe88271c90
commit 1b828d6e4b
15 changed files with 103 additions and 13 deletions

1
bin/.gitignore vendored
View File

@ -1 +1,2 @@
/application/ /application/
/datatypes/

View File

@ -9,10 +9,12 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?> <?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import javafx.scene.text.TextFlow?>
<AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController"> <AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children> <children>
@ -85,7 +87,18 @@
</AnchorPane> </AnchorPane>
<AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0"> <AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="14.0" prefHeight="537.0" prefWidth="350.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" /> <JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="14.0" prefHeight="537.0" prefWidth="400.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" />
<ImageView fx:id="smmdbImageView" fitHeight="150.0" fitWidth="267.0" layoutX="436.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
<ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="181.0" prefHeight="314.0" prefWidth="267.0" AnchorPane.bottomAnchor="67.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="181.0">
<content>
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
</content>
</ScrollPane>
<JFXButton fx:id="smmdbDownloadBtn" buttonType="RAISED" layoutX="436.0" layoutY="510.0" onAction="#smmdbDownloadBtnAction" prefHeight="38.0" prefWidth="267.0" text="download" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="510.0">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
</children></AnchorPane> </children></AnchorPane>
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0"> <JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0">
<font> <font>

Binary file not shown.

View File

@ -9,10 +9,12 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?> <?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import javafx.scene.text.TextFlow?>
<AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController"> <AnchorPane prefHeight="600.0" prefWidth="892.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.MainWindowController">
<children> <children>
@ -85,7 +87,18 @@
</AnchorPane> </AnchorPane>
<AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0"> <AnchorPane fx:id="smmdbAnchorPane" style="-fx-background-color: white;" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="175.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="38.0">
<children> <children>
<JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="14.0" prefHeight="537.0" prefWidth="350.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" /> <JFXTreeTableView fx:id="courseTreeTable" layoutX="14.0" layoutY="14.0" prefHeight="537.0" prefWidth="400.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0" />
<ImageView fx:id="smmdbImageView" fitHeight="150.0" fitWidth="267.0" layoutX="436.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
<ScrollPane fx:id="smmdbScrollPane" layoutX="436.0" layoutY="181.0" prefHeight="314.0" prefWidth="267.0" AnchorPane.bottomAnchor="67.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="181.0">
<content>
<TextFlow fx:id="smmdbTextFlow" maxWidth="265.0" prefWidth="265.0" />
</content>
</ScrollPane>
<JFXButton fx:id="smmdbDownloadBtn" buttonType="RAISED" layoutX="436.0" layoutY="510.0" onAction="#smmdbDownloadBtnAction" prefHeight="38.0" prefWidth="267.0" text="download" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="436.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="510.0">
<font>
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
</children></AnchorPane> </children></AnchorPane>
<JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0"> <JFXButton fx:id="playBtn" buttonType="RAISED" maxHeight="38.0" maxWidth="100.0" onAction="#playBtnAction" ripplerFill="#c92a2a" text="play" visible="false" AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="396.0" AnchorPane.rightAnchor="396.0" AnchorPane.topAnchor="555.0">
<font> <font>

View File

@ -22,6 +22,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -41,9 +44,9 @@ import com.jfoenix.controls.JFXTreeTableColumn;
import com.jfoenix.controls.JFXTreeTableView; import com.jfoenix.controls.JFXTreeTableView;
import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
import datatypes.CourseTableDataType;
import datatypes.SmmdbApiDataType; import datatypes.SmmdbApiDataType;
import datatypes.UIROMDataType; import datatypes.UIROMDataType;
import datatypes.CourseTableDataType;
import javafx.animation.FadeTransition; import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition; import javafx.animation.ParallelTransition;
import javafx.animation.TranslateTransition; import javafx.animation.TranslateTransition;
@ -74,6 +77,7 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint; import javafx.scene.paint.Paint;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.scene.text.FontWeight; import javafx.scene.text.FontWeight;
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;
@ -101,14 +105,17 @@ public class MainWindowController {
@FXML @FXML
private JFXButton romTFBtn; private JFXButton romTFBtn;
@FXML
private JFXButton smmdbDownloadBtn;
@FXML @FXML
private JFXButton playBtn; private JFXButton playBtn;
@FXML @FXML
JFXButton timePlayedBtn; private JFXButton lastTimePlayedBtn;
@FXML @FXML
private JFXButton lastTimePlayedBtn; JFXButton timePlayedBtn;
@FXML @FXML
private JFXHamburger menuHam; private JFXHamburger menuHam;
@ -119,6 +126,9 @@ public class MainWindowController {
@FXML @FXML
private JFXTextField romTextField; private JFXTextField romTextField;
@FXML
private TextFlow smmdbTextFlow;
@FXML @FXML
private JFXColorPicker colorPicker; private JFXColorPicker colorPicker;
@ -140,12 +150,18 @@ public class MainWindowController {
@FXML @FXML
private ScrollPane scrollPaneMain; private ScrollPane scrollPaneMain;
@FXML
private ScrollPane smmdbScrollPane;
@FXML @FXML
private VBox sideMenuVBox; private VBox sideMenuVBox;
@FXML @FXML
private HBox topHBox; private HBox topHBox;
@FXML
private ImageView smmdbImageView;
@FXML @FXML
private JFXTreeTableView<CourseTableDataType> courseTreeTable = new JFXTreeTableView<CourseTableDataType>(); private JFXTreeTableView<CourseTableDataType> courseTreeTable = new JFXTreeTableView<CourseTableDataType>();
@ -237,9 +253,9 @@ public class MainWindowController {
applyColor(); applyColor();
//initialize courseTable //initialize courseTable
titleColumn.setPrefWidth(150); titleColumn.setPrefWidth(168);
starsColumn.setPrefWidth(85); downloadsColumn.setPrefWidth(130);
downloadsColumn.setPrefWidth(115); starsColumn.setPrefWidth(100);
courseTreeTable.setRoot(root); courseTreeTable.setRoot(root);
courseTreeTable.setShowRoot(false); courseTreeTable.setShowRoot(false);
@ -497,6 +513,20 @@ public class MainWindowController {
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 {
URL url = new URL("http://smmdb.ddns.net/img/courses/thumbnails/" + id + ".pic");
Image image = new Image(url.toURI().toString());
smmdbImageView.setImage(image);
} catch (MalformedURLException | URISyntaxException e) {
e.printStackTrace();
}
} else {
//TODO show an image if none was found
// Image image = new Image(url.toURI().toString());
// smmdbImageView.setImage(image);
}
//TODO show additional information and download option //TODO show additional information and download option
System.out.println(i); System.out.println(i);
} }
@ -626,6 +656,18 @@ public class MainWindowController {
} }
} }
@FXML
void smmdbDownloadBtnAction(ActionEvent event){
//TODO implement download
System.out.println("this needs to be implemented ^^");
try {
URL url = new URL("smmdb.ddns.net/courses/" + id);
} catch (MalformedURLException e) {
System.err.println("something went wrong during downloading the course");
e.printStackTrace();
}
}
@FXML @FXML
void cemuTextFieldAction(ActionEvent event){ void cemuTextFieldAction(ActionEvent event){
setCemuPath(cemuTextField.getText()); setCemuPath(cemuTextField.getText());
@ -918,6 +960,7 @@ public class MainWindowController {
playBtn.setStyle("-fx-text-fill: WHITE; -fx-font-family: Roboto Medium;"); playBtn.setStyle("-fx-text-fill: WHITE; -fx-font-family: Roboto Medium;");
cemuTFBtn.setStyle(btnStyleWhite); cemuTFBtn.setStyle(btnStyleWhite);
romTFBtn.setStyle(btnStyleWhite); romTFBtn.setStyle(btnStyleWhite);
smmdbDownloadBtn.setStyle(btnStyleWhite);
playBtn.setStyle(btnStyleWhite); playBtn.setStyle(btnStyleWhite);
aboutBtn.setGraphic(info_white); aboutBtn.setGraphic(info_white);
@ -936,6 +979,7 @@ public class MainWindowController {
playBtn.setStyle("-fx-text-fill: BLACK; -fx-font-family: Roboto Medium;"); playBtn.setStyle("-fx-text-fill: BLACK; -fx-font-family: Roboto Medium;");
cemuTFBtn.setStyle(btnStyleBlack); cemuTFBtn.setStyle(btnStyleBlack);
romTFBtn.setStyle(btnStyleBlack); romTFBtn.setStyle(btnStyleBlack);
smmdbDownloadBtn.setStyle(btnStyleBlack);
playBtn.setStyle(btnStyleBlack); playBtn.setStyle(btnStyleBlack);
aboutBtn.setGraphic(info_black); aboutBtn.setGraphic(info_black);

View File

@ -50,7 +50,7 @@ public class SmmdbApiQuery {
//if value is 9 or "notset" the api returned NULL as value //if value is 9 or "notset" the api returned NULL as value
for (int i = 0; i < courseIDs.size(); i++) { for (int i = 0; i < courseIDs.size(); i++) {
int id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, stars, ispackage, updatereq; int id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, stars, hasimage, ispackage, updatereq;
String nintendoid, title; String nintendoid, title;
JsonObject singleObject = mainObject.get(courseIDs.get(i).toString()).asObject(); JsonObject singleObject = mainObject.get(courseIDs.get(i).toString()).asObject();
@ -99,6 +99,11 @@ public class SmmdbApiQuery {
} catch (Exception e) { } catch (Exception e) {
stars = 9; stars = 9;
} }
try {
hasimage = singleObject.getInt("hasimage", 0);
} catch (Exception e) {
hasimage = 9;
}
try { try {
ispackage = singleObject.getInt("ispackage", 0); ispackage = singleObject.getInt("ispackage", 0);
} catch (Exception e) { } catch (Exception e) {
@ -121,7 +126,7 @@ public class SmmdbApiQuery {
} }
course.add(new SmmdbApiDataType(id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads, course.add(new SmmdbApiDataType(id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads,
stars, ispackage, updatereq, nintendoid, title)); stars, hasimage, ispackage, updatereq, nintendoid, title));
} }
return course; return course;

View File

@ -19,14 +19,15 @@ public class SmmdbApiDataType {
private final IntegerProperty uploaded = new SimpleIntegerProperty(); private final IntegerProperty uploaded = new SimpleIntegerProperty();
private final IntegerProperty downloads = new SimpleIntegerProperty(); private final IntegerProperty downloads = new SimpleIntegerProperty();
private final IntegerProperty stars = new SimpleIntegerProperty(); private final IntegerProperty stars = new SimpleIntegerProperty();
private final IntegerProperty hasimage = new SimpleIntegerProperty();
private final IntegerProperty ispackage = new SimpleIntegerProperty(); private final IntegerProperty ispackage = new SimpleIntegerProperty();
private final IntegerProperty updatereq = new SimpleIntegerProperty(); private final IntegerProperty updatereq = new SimpleIntegerProperty();
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 leveltype, final int difficulty, 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 lastmodified, final int uploaded, final int downloads, final int stars, final int hasimage,
final int updatereq, final String nintendoid, final String title) { final int ispackage, final int updatereq, 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.coursetype.set(coursetype);
@ -36,6 +37,7 @@ public class SmmdbApiDataType {
this.uploaded.set(uploaded); this.uploaded.set(uploaded);
this.downloads.set(downloads); this.downloads.set(downloads);
this.stars.set(stars); this.stars.set(stars);
this.hasimage.set(hasimage);
this.ispackage.set(ispackage); this.ispackage.set(ispackage);
this.updatereq.set(updatereq); this.updatereq.set(updatereq);
this.nintendoid.set(nintendoid); this.nintendoid.set(nintendoid);
@ -82,6 +84,10 @@ public class SmmdbApiDataType {
return stars; return stars;
} }
public IntegerProperty hasimageProperty(){
return hasimage;
}
public IntegerProperty ispackageProperty(){ public IntegerProperty ispackageProperty(){
return ispackage; return ispackage;
} }
@ -130,6 +136,10 @@ public class SmmdbApiDataType {
return starsProperty().get(); return starsProperty().get();
} }
public int getHasimage() {
return hasimageProperty().get();
}
public int getIspackage() { public int getIspackage() {
return ispackageProperty().get(); return ispackageProperty().get();
} }
@ -182,6 +192,10 @@ public class SmmdbApiDataType {
starsProperty().set(stars); starsProperty().set(stars);
} }
public final void setHasimage(int hasimage) {
hasimageProperty().set(hasimage);
}
public final void setIspackage(int ispackage) { public final void setIspackage(int ispackage) {
ispackageProperty().set(ispackage); ispackageProperty().set(ispackage);
} }
@ -197,5 +211,5 @@ public class SmmdbApiDataType {
public final void setTitle(String title) { public final void setTitle(String title) {
titleProperty().set(title); titleProperty().set(title);
} }
} }