rlease 0.3.3 #7
|
@ -218,10 +218,10 @@ public class Main extends Application {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, final Number newValue) {
|
public void changed(ObservableValue<? extends Number> observable, Number oldValue, final Number newValue) {
|
||||||
int xPosHelperMax = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217);
|
int xMaxElements = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217);
|
||||||
|
|
||||||
// call only if there is enough space for a new row
|
// call only if there is enough space for a new row
|
||||||
if (mainWindowController.getOldXPosHelper() != xPosHelperMax) {
|
if (mainWindowController.getOldXNextElement() != xMaxElements) {
|
||||||
mainWindowController.refreshUIData();
|
mainWindowController.refreshUIData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.geometry.Insets;
|
|
||||||
import javafx.scene.control.ChoiceBox;
|
import javafx.scene.control.ChoiceBox;
|
||||||
import javafx.scene.control.ContextMenu;
|
import javafx.scene.control.ContextMenu;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
@ -194,8 +193,8 @@ public class MainWindowController {
|
||||||
private String versionName = "Purple Comet";
|
private String versionName = "Purple Comet";
|
||||||
private int xPos = -200;
|
private int xPos = -200;
|
||||||
private int yPos = 17;
|
private int yPos = 17;
|
||||||
private int xPosHelper = 0;
|
private int xNextElement = 0;
|
||||||
private int oldXPosHelper;
|
private int oldXNextElement;
|
||||||
private int selectedUIDataIndex;
|
private int selectedUIDataIndex;
|
||||||
private int selected;
|
private int selected;
|
||||||
private DirectoryChooser directoryChooser = new DirectoryChooser();
|
private DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||||
|
@ -1024,29 +1023,14 @@ public class MainWindowController {
|
||||||
* @param titleID : game ID
|
* @param titleID : game ID
|
||||||
*/
|
*/
|
||||||
public void addGame(String title, String coverPath, String romPath, String titleID){
|
public void addGame(String title, String coverPath, String romPath, String titleID){
|
||||||
VBox VBox = new VBox();
|
|
||||||
Label gameTitleLabel = new Label();
|
|
||||||
JFXButton gameBtn = new JFXButton();
|
|
||||||
ImageView imageView = new ImageView();
|
|
||||||
Image coverImage = new Image(new File(coverPath).toURI().toString());
|
Image coverImage = new Image(new File(coverPath).toURI().toString());
|
||||||
|
UIROMDataType uiROMElement = new UIROMDataType();
|
||||||
|
|
||||||
generatePosition();
|
generatePosition();
|
||||||
|
|
||||||
UIROMDataType uiROMElement = new UIROMDataType(VBox, gameTitleLabel, gameBtn, imageView, titleID, romPath);
|
|
||||||
|
|
||||||
uiROMElement.getLabel().setText(title);
|
uiROMElement.getLabel().setText(title);
|
||||||
uiROMElement.getLabel().setMaxWidth(200);
|
|
||||||
uiROMElement.getLabel().setPadding(new Insets(0,0,0,8));
|
|
||||||
uiROMElement.getLabel().setFont(Font.font("System", FontWeight.BOLD, 14));
|
|
||||||
|
|
||||||
// i think we can do this locally and remove the imageView from the data type since it's used as graphic
|
|
||||||
uiROMElement.getImageView().setImage(coverImage);
|
uiROMElement.getImageView().setImage(coverImage);
|
||||||
uiROMElement.getImageView().setFitHeight(300);
|
|
||||||
uiROMElement.getImageView().setFitWidth(200);
|
|
||||||
|
|
||||||
uiROMElement.getButton().setGraphic(uiROMElement.getImageView());
|
|
||||||
uiROMElement.getButton().setContextMenu(gameContextMenu);
|
uiROMElement.getButton().setContextMenu(gameContextMenu);
|
||||||
uiROMElement.getButton().setStyle("-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 3); ");
|
|
||||||
uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(MouseEvent event) {
|
public void handle(MouseEvent event) {
|
||||||
|
@ -1112,10 +1096,6 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
uiROMElement.getVBox().setLayoutX(getxPos());
|
|
||||||
uiROMElement.getVBox().setLayoutY(getyPos());
|
|
||||||
uiROMElement.getVBox().getChildren().addAll(gameTitleLabel,gameBtn);
|
|
||||||
|
|
||||||
// add uiROMElement to games list
|
// add uiROMElement to games list
|
||||||
games.add(uiROMElement);
|
games.add(uiROMElement);
|
||||||
}
|
}
|
||||||
|
@ -1154,19 +1134,20 @@ public class MainWindowController {
|
||||||
//remove all games from gamesAnchorPane and add them afterwards
|
//remove all games from gamesAnchorPane and add them afterwards
|
||||||
public void refreshUIData() {
|
public void refreshUIData() {
|
||||||
//remove all games form gamesAnchorPane
|
//remove all games form gamesAnchorPane
|
||||||
gamesAnchorPane.getChildren().removeAll(gamesAnchorPane.getChildren());
|
gamesAnchorPane.getChildren().clear();
|
||||||
|
|
||||||
//reset position
|
//reset position
|
||||||
xPos = -200;
|
xPos = -200;
|
||||||
yPos = 17;
|
yPos = 17;
|
||||||
xPosHelper = 0;
|
xNextElement = 0;
|
||||||
|
|
||||||
//add all games to gamesAnchorPane (UI)
|
//add all games to gamesAnchorPane (UI)
|
||||||
for(int i=0; i< games.size(); i++){
|
for(UIROMDataType game : games) {
|
||||||
generatePosition();
|
generatePosition();
|
||||||
games.get(i).getVBox().setLayoutX(getxPos());
|
|
||||||
games.get(i).getVBox().setLayoutY(getyPos());
|
game.setLayoutX(xPos);
|
||||||
gamesAnchorPane.getChildren().add(games.get(i).getVBox());
|
game.setLayoutY(yPos);
|
||||||
|
gamesAnchorPane.getChildren().add(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1367,20 +1348,21 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xPosHelper based on window width = -24(Windows)/-36(Linux)
|
* xMaxElements based on window width -36
|
||||||
* calculates how many games can be displayed in one row
|
* calculates how many games can be displayed in one row
|
||||||
*/
|
*/
|
||||||
private void generatePosition() {
|
private void generatePosition() {
|
||||||
int xPosHelperMax = (int) Math.floor((mainAnchorPane.getWidth() - 36) / 217);
|
int xMaxElements = (int) Math.floor((mainAnchorPane.getWidth() - 36) / 217);
|
||||||
|
System.out.println(xMaxElements);
|
||||||
|
|
||||||
if(xPosHelper == xPosHelperMax){
|
if(xNextElement >= xMaxElements){
|
||||||
oldXPosHelper = xPosHelper;
|
oldXNextElement = xNextElement;
|
||||||
xPos = 17;
|
xPos = 17;
|
||||||
yPos = yPos + 345;
|
yPos = yPos + 345;
|
||||||
xPosHelper = 1;
|
xNextElement = 1;
|
||||||
}else{
|
}else{
|
||||||
xPos = xPos + 217;
|
xPos = xPos + 217;
|
||||||
xPosHelper++;
|
xNextElement++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,30 +1518,6 @@ public class MainWindowController {
|
||||||
return primaryStage;
|
return primaryStage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getxPos() {
|
|
||||||
return xPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setxPos(int xPos) {
|
|
||||||
this.xPos = xPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getyPos() {
|
|
||||||
return yPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setyPos(int yPos) {
|
|
||||||
this.yPos = yPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getxPosHelper() {
|
|
||||||
return xPosHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setxPosHelper(int xPosHelper) {
|
|
||||||
this.xPosHelper = xPosHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGameExecutePath() {
|
public String getGameExecutePath() {
|
||||||
return gameExecutePath;
|
return gameExecutePath;
|
||||||
}
|
}
|
||||||
|
@ -1584,8 +1542,8 @@ public class MainWindowController {
|
||||||
this.playBtn = playBtn;
|
this.playBtn = playBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOldXPosHelper() {
|
public int getOldXNextElement() {
|
||||||
return oldXPosHelper;
|
return oldXNextElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
|
|
|
@ -22,105 +22,73 @@ package com.cemu_UI.datatypes;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.geometry.Insets;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
import javafx.beans.property.StringProperty;
|
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.text.Font;
|
||||||
|
import javafx.scene.text.FontWeight;
|
||||||
|
|
||||||
public class UIROMDataType {
|
public class UIROMDataType extends VBox {
|
||||||
|
|
||||||
private final SimpleObjectProperty<VBox> vBox = new SimpleObjectProperty<>();
|
private String titleID;
|
||||||
private final SimpleObjectProperty<Label> label = new SimpleObjectProperty<>();
|
private String romPath;
|
||||||
private final SimpleObjectProperty<JFXButton> button = new SimpleObjectProperty<>();
|
private Label label = new Label();
|
||||||
private final SimpleObjectProperty<ImageView> imageView = new SimpleObjectProperty<>();
|
private JFXButton button = new JFXButton();
|
||||||
private final StringProperty titleID = new SimpleStringProperty();
|
private ImageView imageView = new ImageView();
|
||||||
private final StringProperty romPath = new SimpleStringProperty();
|
|
||||||
|
|
||||||
/**
|
public UIROMDataType() {
|
||||||
* Data type used for UI ROM elements all uiROMElemts are of this data type
|
super.getChildren().addAll(label, button);
|
||||||
*/
|
|
||||||
public UIROMDataType (final VBox vBox, final Label label, final JFXButton button, final ImageView imageView, final String titleID, final String romPath){
|
label.setMaxWidth(200);
|
||||||
this.vBox.set(vBox);
|
label.setPadding(new Insets(0,0,0,8));
|
||||||
this.label.set(label);
|
label.setFont(Font.font("System", FontWeight.BOLD, 14));
|
||||||
this.button.set(button);
|
|
||||||
this.imageView.set(imageView);
|
imageView.setFitHeight(300);
|
||||||
this.titleID.set(titleID);
|
imageView.setFitWidth(200);
|
||||||
this.romPath.set(romPath);
|
|
||||||
|
button.setStyle("-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 3); ");
|
||||||
|
button.setGraphic(imageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleObjectProperty<VBox> vBoxProperty(){
|
public String getTitleID() {
|
||||||
return vBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<Label> labelProperty(){
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<JFXButton> buttonProperty(){
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SimpleObjectProperty<ImageView> imageViewProperty(){
|
|
||||||
return imageView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringProperty titleIDProperty(){
|
|
||||||
return titleID;
|
return titleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StringProperty romPathProperty(){
|
public String getRomPath() {
|
||||||
return romPath;
|
return romPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Label getLabel() {
|
||||||
public final VBox getVBox() {
|
return label;
|
||||||
return vBoxProperty().get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Label getLabel() {
|
public JFXButton getButton() {
|
||||||
return labelProperty().get();
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final JFXButton getButton() {
|
public ImageView getImageView() {
|
||||||
return buttonProperty().get();
|
return imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ImageView getImageView() {
|
public void setTitleID(String titleID) {
|
||||||
return imageViewProperty().get();
|
this.titleID = titleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getTitleID(){
|
public void setRomPath(String romPath) {
|
||||||
return titleIDProperty().get();
|
this.romPath = romPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getRomPath(){
|
public void setLabel(Label label) {
|
||||||
return romPathProperty().get();
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setButton(JFXButton button) {
|
||||||
public final void setVBox(VBox vBox) {
|
this.button = button;
|
||||||
vBoxProperty().set(vBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setLabel(Label label) {
|
public void setImageView(ImageView imageView) {
|
||||||
labelProperty().set(label);
|
this.imageView = imageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setButton(JFXButton button) {
|
|
||||||
buttonProperty().set(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setImageView(ImageView imageView) {
|
|
||||||
imageViewProperty().set(imageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setTitleID(String titleID){
|
|
||||||
titleIDProperty().set(titleID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setRomPath(String romPath){
|
|
||||||
romPathProperty().set(romPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue