new constructor for UIROMDataType

This commit is contained in:
Jannik 2019-05-15 16:39:00 +02:00
parent 922c5197da
commit 3f69169a6a
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
2 changed files with 31 additions and 26 deletions

View File

@ -1023,14 +1023,8 @@ public class MainWindowController {
* @param titleID : game ID
*/
public void addGame(String title, String coverPath, String romPath, String titleID){
Image coverImage = new Image(new File(coverPath).toURI().toString());
UIROMDataType uiROMElement = new UIROMDataType();
UIROMDataType uiROMElement = new UIROMDataType(title, coverPath, gameContextMenu);
generatePosition();
uiROMElement.getLabel().setText(title);
uiROMElement.getImageView().setImage(coverImage);
uiROMElement.getButton().setContextMenu(gameContextMenu);
uiROMElement.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
@ -1131,25 +1125,25 @@ public class MainWindowController {
thread.start();
}
//remove all games from gamesAnchorPane and add them afterwards
public void refreshUIData() {
//remove all games form gamesAnchorPane
gamesAnchorPane.getChildren().clear();
// remove all games from gamesAnchorPane and add them afterwards
public void refreshUIData() {
// remove all games form gamesAnchorPane
gamesAnchorPane.getChildren().clear();
//reset position
xPos = -200;
yPos = 17;
xNextElement = 0;
//add all games to gamesAnchorPane (UI)
for(UIROMDataType game : games) {
generatePosition();
game.setLayoutX(xPos);
game.setLayoutY(yPos);
// reset position
xPos = -200;
yPos = 17;
xNextElement = 0;
// add all games to gamesAnchorPane (UI)
for (UIROMDataType game : games) {
generatePosition();
game.setLayoutX(xPos);
game.setLayoutY(yPos);
gamesAnchorPane.getChildren().add(game);
}
}
}
}
// set the selected local strings to all needed elements
void setUILanguage(){
@ -1353,8 +1347,7 @@ public class MainWindowController {
*/
private void generatePosition() {
int xMaxElements = (int) Math.floor((mainAnchorPane.getWidth() - 36) / 217);
System.out.println(xMaxElements);
if(xNextElement >= xMaxElements){
oldXNextElement = xNextElement;
xPos = 17;

View File

@ -20,10 +20,14 @@
*/
package com.cemu_UI.datatypes;
import java.io.File;
import com.jfoenix.controls.JFXButton;
import javafx.geometry.Insets;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
@ -37,6 +41,14 @@ public class UIROMDataType extends VBox {
private JFXButton button = new JFXButton();
private ImageView imageView = new ImageView();
public UIROMDataType(String text, String coverPath, ContextMenu contextMenu) {
this();
label.setText(text);
imageView.setImage(new Image(new File(coverPath).toURI().toString()));
button.setContextMenu(contextMenu);
}
public UIROMDataType() {
super.getChildren().addAll(label, button);