From 9ccb7e6b425bcae13a20b086752dc528202e19d4 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Dec 2017 11:19:33 +0100 Subject: [PATCH 01/15] better coding style * used gettersand setter for accessing the mainparts of the UI elements, uch aus primarStage * dbController -> DBController --- .../java/com/cemu_UI/application/Main.java | 42 +++++++++--- .../application/MainWindowController.java | 65 +++++++++---------- .../com/cemu_UI/application/playGame.java | 12 ++-- .../{dbController.java => DBController.java} | 15 +++-- 4 files changed, 80 insertions(+), 54 deletions(-) rename src/main/java/com/cemu_UI/controller/{dbController.java => DBController.java} (97%) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 18778cd..fd81aa9 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -51,11 +51,13 @@ import javafx.scene.layout.AnchorPane; public class Main extends Application { - Stage primaryStage; - public MainWindowController mainWindowController; // TODO find a better way - CloudController cloudController; - AnchorPane pane; - Scene scene; // TODO make private + private Stage primaryStage; // TODO same as #Test01 + private MainWindowController mainWindowController; // TODO Needs more testing: if cemu_UI will work as + //normally expected this waring can be removed #Test01 + // if not working correctly remove private! + private CloudController cloudController; // TODO same as #Test01 + private AnchorPane pane; // TODO same as #Test01 + private Scene scene; // TODO same as #Test01 private static String userHome = System.getProperty("user.home"); private static String userName = System.getProperty("user.name"); private static String osName = System.getProperty("os.name"); @@ -69,8 +71,6 @@ public class Main extends Application { private File directory; private File configFile; private File gamesDBFile; - @SuppressWarnings("unused") - private File localDB; private File pictureCache; private static Logger LOGGER; @@ -106,13 +106,11 @@ public class Main extends Application { directory = new File(dirLinux); configFile = new File(dirLinux + "/config.xml"); gamesDBFile = new File(dirLinux + "/games.db"); - localDB = new File(dirLinux+"/localRoms.db"); pictureCache= new File(dirLinux+"/picture_cache"); } else { directory = new File(dirWin); configFile = new File(dirWin + "/config.xml"); gamesDBFile = new File(dirWin + "/games.db"); - localDB = new File(dirWin+"/localRoms.db"); pictureCache= new File(dirWin+"/picture_cache"); } @@ -165,7 +163,7 @@ public class Main extends Application { // loading settings and initialize UI, dbController.main() loads all databases mainWindowController.init(); - mainWindowController.dbController.main(); + mainWindowController.dbController.init(); // if cloud sync is activated start sync if(mainWindowController.isCloudSync()) { cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); @@ -308,4 +306,28 @@ public class Main extends Application { public void stop() { System.exit(0); } + + public Stage getPrimaryStage() { + return primaryStage; + } + + public void setPrimaryStage(Stage primaryStage) { + this.primaryStage = primaryStage; + } + + public CloudController getCloudController() { + return cloudController; + } + + public void setCloudController(CloudController cloudController) { + this.cloudController = cloudController; + } + + public AnchorPane getPane() { + return pane; + } + + public void setPane(AnchorPane pane) { + this.pane = pane; + } } diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 14a7c71..31332a9 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -54,7 +54,7 @@ import org.apache.logging.log4j.Logger; import com.cemu_UI.controller.SmmdbAPIController; import com.cemu_UI.controller.UpdateController; -import com.cemu_UI.controller.dbController; +import com.cemu_UI.controller.DBController; import com.cemu_UI.datatypes.CourseTableDataType; import com.cemu_UI.datatypes.SmmdbApiDataType; import com.cemu_UI.datatypes.UIROMDataType; @@ -253,7 +253,7 @@ public class MainWindowController { private JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("time"); Main main; - dbController dbController; + DBController dbController; SmmdbAPIController smmdbAPIController; playGame playGame; private static MainWindowController MWC; @@ -322,10 +322,10 @@ public class MainWindowController { private ImageView cached_white = new ImageView(new Image("icons/ic_cached_white_24dp_1x.png")); private ImageView smmdb_white = new ImageView(new Image("icons/ic_get_app_white_24dp_1x.png")); private Image close_black = new Image("icons/close_black_2048x2048.png"); - - public void setMain(Main main) { - this.main = main; - dbController = new dbController(this); + + public void setMain(Main m) { + this.main = m; + dbController = new DBController(this); smmdbAPIController = new SmmdbAPIController(); } @@ -436,7 +436,7 @@ public class MainWindowController { String headingText = "edit a game"; String bodyText = "You can edit the tile and rom/cover path."; JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, - 300, 1, MWC, main.primaryStage, main.pane); + 300, 1, MWC, main.getPrimaryStage(), main.getPane()); editGameDialog.setTitle(gameInfo[0]); editGameDialog.setCoverPath(gameInfo[1]); editGameDialog.setRomPath(gameInfo[2]); @@ -471,12 +471,12 @@ public class MainWindowController { EventHandler cancelAction = new EventHandler() { @Override public void handle(ActionEvent event) { - // do nothing + LOGGER.info("Action canceld by user!"); } }; JFXOkayCancelDialog removeGameDialog = new JFXOkayCancelDialog(headingText, bodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane); + dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane()); removeGameDialog.show(); } catch (Exception e) { LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e); @@ -495,7 +495,7 @@ public class MainWindowController { @Override public void handle(ActionEvent event) { DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirecroty = directoryChooser.showDialog(main.primaryStage); + File selectedDirecroty = directoryChooser.showDialog(main.getPrimaryStage()); String updatePath = selectedDirecroty.getAbsolutePath(); String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" File srcDir = new File(updatePath); @@ -529,12 +529,12 @@ public class MainWindowController { EventHandler cancelAction = new EventHandler() { @Override public void handle(ActionEvent event) { - // do nothing + LOGGER.info("Action canceld by user!"); } }; JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, bodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.pane); + dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane()); updateGameDialog.show(); } catch (Exception e) { LOGGER.warn("trying to update " + selectedGameTitleID + ",which is not a valid type!", e); @@ -553,7 +553,7 @@ public class MainWindowController { @Override public void handle(ActionEvent event) { DirectoryChooser directoryChooser = new DirectoryChooser(); - File selectedDirecroty = directoryChooser.showDialog(main.primaryStage); + File selectedDirecroty = directoryChooser.showDialog(main.getPrimaryStage()); String dlcPath = selectedDirecroty.getAbsolutePath(); String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" File srcDir = new File(dlcPath); @@ -587,12 +587,12 @@ public class MainWindowController { EventHandler cancelAction = new EventHandler() { @Override public void handle(ActionEvent event) { - // do nothing + LOGGER.info("Action canceld by user!"); } }; JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, - 350, 170, okayAction, cancelAction, main.pane); + 350, 170, okayAction, cancelAction, main.getPane()); addDLCDialog.show(); } catch (Exception e) { LOGGER.warn("trying to add a dlc to " + selectedGameTitleID + ",which is not a valid type!", e); @@ -650,7 +650,6 @@ public class MainWindowController { public void changed(ObservableValue observable, Object oldVal, Object newVal) { selected = courseTreeTable.getSelectionModel().getSelectedIndex(); // get 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++) { @@ -750,14 +749,14 @@ public class MainWindowController { } JFXTextAreaInfoDialog licenseDialog = new JFXTextAreaInfoDialog(headingText, bodyText, - dialogBtnStyle, 510, 450, main.pane); + dialogBtnStyle, 510, 450, main.getPane()); licenseDialog.show(); licenseDialog.getTextArea().setEditable(false); } }; JFXOkayCancelDialog licenseOverviewDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, - 350, 275, okayAction, cancelAction, main.pane); + 350, 275, okayAction, cancelAction, main.getPane()); licenseOverviewDialog.setCancelText("show licenses"); licenseOverviewDialog.show(); } @@ -779,7 +778,7 @@ public class MainWindowController { + "This Application is made with free Software\n" + "and licensed under the terms of GNU GPL 3.\n\n" + "www.kellerkinder.xyz"; - JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 200, main.pane); + JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 200, main.getPane()); aboutDialog.show(); } @@ -805,9 +804,9 @@ public class MainWindowController { JFXSpinner spinner = new JFXSpinner(); spinner.setPrefSize(30, 30); spinner.setStyle(" -fx-background-color: #f4f4f4;"); - main.pane.getChildren().add(spinner); - AnchorPane.setTopAnchor(spinner, (main.pane.getHeight()-spinner.getPrefHeight())/2); - AnchorPane.setLeftAnchor(spinner, (main.pane.getWidth()-spinner.getPrefWidth())/2); + main.getPane().getChildren().add(spinner); + AnchorPane.setTopAnchor(spinner, (main.getPane().getHeight()-spinner.getPrefHeight())/2); + AnchorPane.setLeftAnchor(spinner, (main.getPane().getWidth()-spinner.getPrefWidth())/2); Thread thread = new Thread(new Runnable() { @Override @@ -816,7 +815,7 @@ public class MainWindowController { Platform.runLater(() -> { refreshUIData(); // refresh the list of games displayed on screen - main.pane.getChildren().remove(spinner); + main.getPane().getChildren().remove(spinner); }); } }); @@ -882,7 +881,7 @@ public class MainWindowController { @FXML void cemuTFBtnAction(ActionEvent event) { - File cemuDirectory = directoryChooser.showDialog(main.primaryStage); + File cemuDirectory = directoryChooser.showDialog(main.getPrimaryStage()); if (cemuDirectory == null) { LOGGER.info("No Directory selected"); } else { @@ -900,7 +899,7 @@ public class MainWindowController { @FXML void romTFBtnAction(ActionEvent event) { - File romDirectory = directoryChooser.showDialog(main.primaryStage); + File romDirectory = directoryChooser.showDialog(main.getPrimaryStage()); if (romDirectory == null) { LOGGER.info("No Directory selected"); } else { @@ -1050,8 +1049,8 @@ public class MainWindowController { @Override public void run() { - if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) { - main.cloudController.sync(getCloudService(), getCemuPath()); + if (main.getCloudController().initializeConnection(getCloudService(), getCemuPath())) { + main.getCloudController().sync(getCloudService(), getCemuPath()); saveSettings(); } else { cloudSyncToggleBtn.setSelected(false); @@ -1061,7 +1060,7 @@ public class MainWindowController { String bodyText = "There was some truble adding your game." + "\nPlease upload the app.log (which can be found in the cemu_UI directory)" + "\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this."; - JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane); + JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.getPane()); cloudSyncErrorDialog.show(); } @@ -1079,7 +1078,7 @@ public class MainWindowController { }; JFXOkayCancelDialog cloudSyncErrorDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, - 419, 140, okayAction, cancelAction, main.pane); + 419, 140, okayAction, cancelAction, main.getPane()); cloudSyncErrorDialog.show(); } } @@ -1095,7 +1094,7 @@ public class MainWindowController { String headingText = "add a new game to cemu_UI"; String bodyText = ""; JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0, - this, main.primaryStage, main.pane); + this, main.getPrimaryStage(), main.getPane()); addGameDialog.show(); } @@ -1119,7 +1118,7 @@ public class MainWindowController { String headingTextError = "Error while adding a new Game!"; String bodyTextError = "There was some truble adding your game." + "\nOne of the needed values was empty, please try again to add your game."; - JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350, 170, main.pane); + JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350, 170, main.getPane()); errorDialog.show(); } else { @@ -1556,7 +1555,7 @@ public class MainWindowController { } else { props.setProperty("cloudService", getCloudService()); } - props.setProperty("folderID", main.cloudController.getFolderID(getCloudService())); + props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); if(System.getProperty("os.name").equals("Linux")){ @@ -1644,7 +1643,7 @@ public class MainWindowController { } try { - main.cloudController.setFolderID(props.getProperty("folderID"), getCloudService()); + main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService()); } catch (Exception e) { LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e); setCloudSync(false); diff --git a/src/main/java/com/cemu_UI/application/playGame.java b/src/main/java/com/cemu_UI/application/playGame.java index 89d8474..3237488 100644 --- a/src/main/java/com/cemu_UI/application/playGame.java +++ b/src/main/java/com/cemu_UI/application/playGame.java @@ -26,17 +26,17 @@ import java.io.IOException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.cemu_UI.controller.dbController; +import com.cemu_UI.controller.DBController; import javafx.application.Platform; public class playGame extends Thread{ MainWindowController mainWindowController; - dbController dbController; + DBController dbController; private static final Logger LOGGER = LogManager.getLogger(playGame.class.getName()); - public playGame(MainWindowController m, com.cemu_UI.controller.dbController db){ + public playGame(MainWindowController m, com.cemu_UI.controller.DBController db){ mainWindowController = m; dbController = db; } @@ -52,7 +52,7 @@ public class playGame extends Thread{ Process p; Platform.runLater(() -> { - mainWindowController.main.primaryStage.setIconified(true); + mainWindowController.main.getPrimaryStage().setIconified(true); // minimize cemu_UI }); startTime = System.currentTimeMillis(); try{ @@ -86,13 +86,13 @@ public class playGame extends Thread{ }else{ mainWindowController.totalPlaytimeBtn.setText(dbController.getTotalPlaytime(selectedGameTitleID)+ " min"); } - mainWindowController.main.primaryStage.setIconified(false); + mainWindowController.main.getPrimaryStage().setIconified(false); // maximize cemu_UI }); // System.out.println(mainWindowController.getCemuPath()+"/mlc01/emulatorSave/"+); //sync savegame with cloud service if(mainWindowController.isCloudSync()) { - mainWindowController.main.cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); + mainWindowController.main.getCloudController().sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); } }catch (IOException | InterruptedException e){ diff --git a/src/main/java/com/cemu_UI/controller/dbController.java b/src/main/java/com/cemu_UI/controller/DBController.java similarity index 97% rename from src/main/java/com/cemu_UI/controller/dbController.java rename to src/main/java/com/cemu_UI/controller/DBController.java index be4facf..a84ba1e 100644 --- a/src/main/java/com/cemu_UI/controller/dbController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -47,10 +47,10 @@ import org.xml.sax.SAXException; import com.cemu_UI.application.MainWindowController; -public class dbController { +public class DBController { - public dbController(MainWindowController m) { - mainWindowController = m; + public DBController(MainWindowController mwc) { + mainWindowController = mwc; } private MainWindowController mainWindowController; @@ -59,9 +59,14 @@ public class dbController { private String DB_PATH_games; private Connection connection = null; private Connection connectionGames = null; - private static final Logger LOGGER = LogManager.getLogger(dbController.class.getName()); + private static final Logger LOGGER = LogManager.getLogger(DBController.class.getName()); - public void main(){ + /** + * initialize the sqlite database controller + * load ROM and games database + * load all games + */ + public void init(){ LOGGER.info("<==========starting loading sql==========>"); loadRomDatabase(); loadGamesDatabase(); From a3a7d415c7cc3a5b860ff0cab942f0394ca58d83 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Dec 2017 12:02:28 +0100 Subject: [PATCH 02/15] fixed a few bugs * games.db -> reference_games.db * fix picture cache path under linux --- src/main/java/com/cemu_UI/application/Main.java | 16 +++++++++++++--- .../application/MainWindowController.java | 10 ++++------ .../com/cemu_UI/controller/DBController.java | 7 ++++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index fd81aa9..5425d79 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -71,6 +71,7 @@ public class Main extends Application { private File directory; private File configFile; private File gamesDBFile; + private File reference_gamesFile; private File pictureCache; private static Logger LOGGER; @@ -106,11 +107,13 @@ public class Main extends Application { directory = new File(dirLinux); configFile = new File(dirLinux + "/config.xml"); gamesDBFile = new File(dirLinux + "/games.db"); + reference_gamesFile = new File(dirLinux + "/reference_games.db"); pictureCache= new File(dirLinux+"/picture_cache"); } else { directory = new File(dirWin); configFile = new File(dirWin + "/config.xml"); gamesDBFile = new File(dirWin + "/games.db"); + reference_gamesFile = new File(dirWin + "/reference_games.db"); pictureCache= new File(dirWin+"/picture_cache"); } @@ -147,12 +150,16 @@ public class Main extends Application { pictureCache.mkdir(); } - if (gamesDBFile.exists() != true) { + + if (!reference_gamesFile.exists()) { + if (gamesDBFile.exists()) { + gamesDBFile.delete(); + } try { - LOGGER.info("downloading games.db... "); + LOGGER.info("downloading ReferenceGameList.db... "); URL website = new URL(gamesDBdownloadURL); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(gamesDBFile); + FileOutputStream fos = new FileOutputStream(reference_gamesFile); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); fos.close(); LOGGER.info("finished downloading games.db"); @@ -161,6 +168,9 @@ public class Main extends Application { } } + + + // loading settings and initialize UI, dbController.main() loads all databases mainWindowController.init(); mainWindowController.dbController.init(); diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 31332a9..4b78766 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1103,14 +1103,11 @@ public class MainWindowController { * and add them to the database and the UI */ public void addBtnReturn(String title, String coverPath, String romPath, String titleID) { - File pictureCache; - /** * if one parameter dosen't contain any value do not add the game * else convert the cover to .png add copy it into the picture cache, * then add the rom to the local_roms database */ - System.out.println(romPath.length()); if (romPath.length() == 0 || coverPath.length() == 0 || title.length() == 0 || titleID.length() == 0) { LOGGER.info("No parameter set!"); @@ -1121,7 +1118,8 @@ public class MainWindowController { JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350, 170, main.getPane()); errorDialog.show(); - } else { + } else { + File pictureCache; String coverName = new File(coverPath).getName(); try { if (System.getProperty("os.name").equals("Linux")) { @@ -1133,8 +1131,8 @@ public class MainWindowController { BufferedImage originalImage = ImageIO.read(new File(coverPath)); //load cover int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600); - ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+coverName)); //save image to pictureCache - coverPath = pictureCache+"\\"+coverName; + coverPath = pictureCache + "/" + coverName; + ImageIO.write(resizeImagePNG, "png", new File(coverPath)); //save image to pictureCache } catch (IOException e) { LOGGER.error("Ops something went wrong! Error while resizing cover.", e); } diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java index a84ba1e..22c1039 100644 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -102,13 +102,13 @@ public class DBController { * set the path to the localRoms.db file and initialize the connection * * games.dbcontains a reverence list to for the automatic detection mode - * TODO this should be called ReferenceGameList the games table should be called reference_games + * TODO rework paths */ private void loadGamesDatabase() { if (System.getProperty("os.name").equals("Linux")) { - DB_PATH_games = System.getProperty("user.home") + "/cemu_UI/games.db"; + DB_PATH_games = System.getProperty("user.home") + "/cemu_UI/reference_games.db"; } else { - DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "games.db"; + DB_PATH_games = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "reference_games.db"; } try { // create a database connection @@ -247,6 +247,7 @@ public class DBController { BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));//change path to where file is located int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600); + // TODO rework paths if(System.getProperty("os.name").equals("Linux")) { ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"/"+rs.getString(3)+".png")); //change path where you want it saved coverPath = pictureCache+"/"+rs.getString(3)+".png"; From c70786cdf440011b9e389d64158a916b2ab9e243 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Dec 2017 19:01:17 +0100 Subject: [PATCH 03/15] minor ui improvements --- .../java/com/cemu_UI/application/MainWindowController.java | 2 +- .../java/com/cemu_UI/uiElements/JFXEditGameDialog.java | 7 ++----- .../java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java | 5 +---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 4b78766..8df3587 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1131,7 +1131,7 @@ public class MainWindowController { BufferedImage originalImage = ImageIO.read(new File(coverPath)); //load cover int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600); - coverPath = pictureCache + "/" + coverName; + coverPath = pictureCache + "/" + coverName; // TODO test path ImageIO.write(resizeImagePNG, "png", new File(coverPath)); //save image to pictureCache } catch (IOException e) { LOGGER.error("Ops something went wrong! Error while resizing cover.", e); diff --git a/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java index 3e25f36..e00d168 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java @@ -88,10 +88,7 @@ public class JFXEditGameDialog { StackPane stackPane = new StackPane(); stackPane.autosize(); JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); - - Label placeholder = new Label(); - placeholder.setPrefSize(15, 10); - + TextField gameTitleTF = new TextField(); gameTitleTF.setPromptText("game tile"); TextField gameTitleIDTF = new TextField(); @@ -207,7 +204,7 @@ public class JFXEditGameDialog { content.setHeading(new Text(headingText)); content.setBody(vbox); - content.setActions(cancelBtn, placeholder, okayBtn); + content.setActions(cancelBtn, okayBtn); content.setPrefSize(dialogWidth, dialogHeight); pane.getChildren().add(stackPane); AnchorPane.setTopAnchor(stackPane, (pane.getHeight()-content.getPrefHeight())/2); diff --git a/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java index 4bf378f..fa02760 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java @@ -28,7 +28,6 @@ import com.jfoenix.controls.JFXDialogLayout; import javafx.event.ActionEvent; import javafx.event.EventHandler; -import javafx.scene.control.Label; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; @@ -93,9 +92,7 @@ public class JFXOkayCancelDialog { cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); cancelBtn.setPrefHeight(32); cancelBtn.setStyle(dialogBtnStyle); - Label placeholder = new Label(); - placeholder.setPrefSize(15, 10); - content.setActions(cancelBtn, placeholder, okayBtn); + content.setActions(cancelBtn, okayBtn); content.setPrefSize(dialogWidth, dialogHeight); pane.getChildren().add(stackPane); AnchorPane.setTopAnchor(stackPane, (pane.getHeight()-content.getPrefHeight())/2); From 9b443dfeae0dfb246547e2f88605cd176e071842 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Dec 2017 19:19:01 +0100 Subject: [PATCH 04/15] small DBController code clean up --- .../application/MainWindowController.java | 2 +- .../com/cemu_UI/controller/DBController.java | 36 ++++++++----------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 8df3587..4b78766 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1131,7 +1131,7 @@ public class MainWindowController { BufferedImage originalImage = ImageIO.read(new File(coverPath)); //load cover int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600); - coverPath = pictureCache + "/" + coverName; // TODO test path + coverPath = pictureCache + "/" + coverName; ImageIO.write(resizeImagePNG, "png", new File(coverPath)); //save image to pictureCache } catch (IOException e) { LOGGER.error("Ops something went wrong! Error while resizing cover.", e); diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java index 22c1039..394b7ca 100644 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -226,38 +226,30 @@ public class DBController { LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories"); // for all files in dir get the app.xml for (File file : files) { - if(System.getProperty("os.name").equals("Linux")){ - appFile = new File(file.getParent()+"/app.xml"); - } else { - appFile = new File(file.getParent()+"\\app.xml"); - } + appFile = new File(file.getParent() + "/app.xml"); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(appFile); - String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent(); //get titile_ID from app.xml + String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent(); // get titile_ID from app.xml title_ID = title_ID.substring(0, 8) + "-" + title_ID.substring(8, title_ID.length()); - LOGGER.info("Name: "+file.getName()+"; Title ID: "+title_ID); - ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '"+title_ID+"';"); + LOGGER.info("Name: " + file.getName() + "; Title ID: " + title_ID); + ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '" + title_ID + "';"); + // for all elements in the games table check if it's already present, else add it while (rs.next()) { if (checkEntry(rs.getString(2))) { LOGGER.info(rs.getString(2) + ": game already in database"); - }else{ + } else { LOGGER.info("adding cover to cache ..."); - BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));//change path to where file is located - int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); - BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600); - // TODO rework paths - if(System.getProperty("os.name").equals("Linux")) { - ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"/"+rs.getString(3)+".png")); //change path where you want it saved - coverPath = pictureCache+"/"+rs.getString(3)+".png"; - } else { - ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+rs.getString(3)+".png")); //change path where you want it saved - coverPath = pictureCache+"\\"+rs.getString(3)+".png"; - } - + BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));// change path to where file is located + int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); + BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600); + + ImageIO.write(resizeImagePNG, "png", new File(pictureCache + "/" + rs.getString(3) + ".png")); + coverPath = pictureCache + "/" + rs.getString(3) + ".png"; LOGGER.info(rs.getString(2) + ": adding ROM"); - addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3), rs.getString(5),"","0"); + addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3), + rs.getString(5), "", "0"); } } } From 42b8434a5853b149f6cf47430dfcf29d3120cb4b Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 12 Dec 2017 23:52:54 +0100 Subject: [PATCH 05/15] Cloud sync rework * reworked the hole cloud sync controller this will make it more save to use the cloud sync THIS IS WORK IN PROGRESS, NOT READY FOR DAILY USE! --- .../java/com/cemu_UI/application/Main.java | 12 +- .../application/MainWindowController.java | 24 +- .../com/cemu_UI/application/playGame.java | 9 +- .../cemu_UI/controller/CloudController.java | 233 ++++++++++-------- .../GoogleDriveController.java | 194 +++------------ 5 files changed, 201 insertions(+), 271 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 5425d79..9ff4761 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -141,6 +141,7 @@ public class Main extends Application { mainWindowController.setColor("00a8cc"); mainWindowController.setAutoUpdate(false); mainWindowController.setxPosHelper(0); + mainWindowController.setLastLocalSync(0); mainWindowController.saveSettings(); Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs) System.exit(0); //finishes itself @@ -174,10 +175,11 @@ public class Main extends Application { // loading settings and initialize UI, dbController.main() loads all databases mainWindowController.init(); mainWindowController.dbController.init(); + // if cloud sync is activated start sync if(mainWindowController.isCloudSync()) { cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); - cloudController.stratupCheck(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); + cloudController.sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath(), directory.getPath()); } mainWindowController.addUIData(); @@ -340,4 +342,12 @@ public class Main extends Application { public void setPane(AnchorPane pane) { this.pane = pane; } + + public File getDirectory() { + return directory; + } + + public void setDirectory(File directory) { + this.directory = directory; + } } diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 4b78766..ad1dd7c 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -284,6 +284,7 @@ public class MainWindowController { private int oldXPosHelper; private int selectedUIDataIndex; private int selected; + private long lastLocalSync; private double windowWidth; private double windowHeight; private DirectoryChooser directoryChooser = new DirectoryChooser(); @@ -1034,8 +1035,9 @@ public class MainWindowController { cloudSync = false; } else { String headingText = "activate cloud savegame sync (beta)"; - String bodyText = "You just activate the cloud savegame sync function of cemu_UI, " - + "\nwhich is currently in beta. Are you sure you want to do this?"; + String bodyText = "WARNING this is a completly WIP cloud save integration, " + + "\nit's NOT recomended to use this!!\n" + + "\nUse it on your own risk and backup everthing before!"; EventHandler okayAction = new EventHandler(){ @Override @@ -1050,7 +1052,7 @@ public class MainWindowController { public void run() { if (main.getCloudController().initializeConnection(getCloudService(), getCemuPath())) { - main.getCloudController().sync(getCloudService(), getCemuPath()); + main.getCloudController().sync(getCloudService(), getCemuPath(), main.getDirectory().getPath()); saveSettings(); } else { cloudSyncToggleBtn.setSelected(false); @@ -1553,7 +1555,7 @@ public class MainWindowController { } else { props.setProperty("cloudService", getCloudService()); } - props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); + props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); if(System.getProperty("os.name").equals("Linux")){ @@ -1641,10 +1643,10 @@ public class MainWindowController { } try { - main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService()); + setLastLocalSync(Long.parseLong(props.getProperty("lastLocalSync"))); } catch (Exception e) { - LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e); - setCloudSync(false); + LOGGER.error("could not load lastSuccessSync, setting default instead", e); + setLastLocalSync(0); } try { @@ -1828,6 +1830,14 @@ public class MainWindowController { this.xPosHelper = xPosHelper; } + public long getLastLocalSync() { + return lastLocalSync; + } + + public void setLastLocalSync(long lastLocalSync) { + this.lastLocalSync = lastLocalSync; + } + public boolean isFullscreen() { return fullscreen; } diff --git a/src/main/java/com/cemu_UI/application/playGame.java b/src/main/java/com/cemu_UI/application/playGame.java index 3237488..3539212 100644 --- a/src/main/java/com/cemu_UI/application/playGame.java +++ b/src/main/java/com/cemu_UI/application/playGame.java @@ -22,6 +22,7 @@ package com.cemu_UI.application; import java.io.IOException; +import java.time.Instant; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -91,9 +92,11 @@ public class playGame extends Thread{ // System.out.println(mainWindowController.getCemuPath()+"/mlc01/emulatorSave/"+); //sync savegame with cloud service - if(mainWindowController.isCloudSync()) { - mainWindowController.main.getCloudController().sync(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); - } + if (mainWindowController.isCloudSync()) { + mainWindowController.setLastLocalSync(Instant.now().getEpochSecond()); + mainWindowController.main.getCloudController().sync(mainWindowController.getCloudService(), + mainWindowController.getCemuPath(), mainWindowController.main.getDirectory().getPath()); + } }catch (IOException | InterruptedException e){ e.printStackTrace(); diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java index f2db2fd..25b995b 100644 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ b/src/main/java/com/cemu_UI/controller/CloudController.java @@ -22,7 +22,12 @@ package com.cemu_UI.controller; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.time.Instant; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -31,6 +36,8 @@ import com.cemu_UI.application.MainWindowController; import com.cemu_UI.vendorCloudController.GoogleDriveController; import javafx.application.Platform; +import net.lingala.zip4j.core.ZipFile; +import net.lingala.zip4j.exception.ZipException; public class CloudController { @@ -63,118 +70,136 @@ public class CloudController { LOGGER.info("cloud initialisation done!"); return success; } - - public void stratupCheck(String cloudService, String cemuDirectory) { - if(cloudService.equals("GoogleDrive")) { - LOGGER.info("starting startup check google drive ..."); - try { - if (!googleDriveController.checkFolder()) { - googleDriveController.creatFolder(); - mwc.saveSettings(); - - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - Platform.runLater(() -> { - mwc.getPlayBtn().setText("syncing..."); - }); - googleDriveController.uploadAllFiles(); - Platform.runLater(() -> { - mwc.getPlayBtn().setText("play"); - }); - } - }); - thread.start(); - } else { - sync(cloudService, cemuDirectory); - } - } catch (IOException e) { - LOGGER.error("google drive startup check failed", e); - } - } - if(cloudService.equals("Dropbox")) { - - } - } - - - - public void sync(String cloudService, String cemuDirectory) { - - //running sync in a new thread, instead of blocking the main thread + + /** + * to trigger a new sync set the mwc LastLocalSync to the actual time and call the sync method + * @param cloudService + * @param cemuDirectory + * @param cemu_UIDirectory + */ + public void sync(String cloudService, String cemuDirectory, String cemu_UIDirectory) { + + // running sync in a new thread, instead of blocking the main thread Thread thread = new Thread(new Runnable() { @Override public void run() { - Platform.runLater(() -> { - mwc.getPlayBtn().setText("syncing..."); - }); - LOGGER.info("starting synchronization in new thread ..."); - - if(cloudService.equals("GoogleDrive")) { - try { - googleDriveController.sync(cemuDirectory); - } catch (IOException e) { - LOGGER.error("google drive synchronization failed", e); - } - } - if(cloudService.equals("Dropbox")) { - - } - Platform.runLater(() -> { - mwc.getPlayBtn().setText("play"); - mwc.saveSettings(); - }); - LOGGER.info("synchronization successful!"); - } - }); + try { + Platform.runLater(() -> { + mwc.getPlayBtn().setDisable(true); + mwc.getPlayBtn().setText("syncing..."); + }); + LOGGER.info("starting synchronization in new thread ..."); + + // zip the saves folder + File zipFile = zipSavegames(cemu_UIDirectory, cemuDirectory); + + // upload the zip + switch (cloudService) { + + // use GoogleDriveController + case "GoogleDrive": + LOGGER.info("using GoogleDriveController"); + long lastCloudSync = googleDriveController.getLastCloudSync(); + + if (!googleDriveController.checkFolder()) { + LOGGER.info("cloud sync folder dosen't exist, creating one!"); + googleDriveController.creatFolder(); + googleDriveController.uploadZipFile(zipFile); + } else if (mwc.getLastLocalSync() > lastCloudSync) { + LOGGER.info("local is new, going to upload zip"); + googleDriveController.uploadZipFile(zipFile); + } else if(mwc.getLastLocalSync() < lastCloudSync) { + LOGGER.info("cloud is new, going to download zip"); + unzipSavegames(cemuDirectory, googleDriveController.downloadZipFile(cemu_UIDirectory)); + mwc.setLastLocalSync(lastCloudSync); + break; + } else { + LOGGER.info("nothing to do"); + break; + } + mwc.setLastLocalSync(Long.parseLong(zipFile.getName().substring(0, zipFile.getName().length()-4))); // set time of last sucessfull sync + break; + + + + case "Dropbox": + + break; + + + default: + LOGGER.warn("no cloud vendor found!"); + break; + } + + zipFile.delete(); // delete zipfile in cem_UI directory + + Platform.runLater(() -> { + mwc.getPlayBtn().setText("play"); + mwc.getPlayBtn().setDisable(false); + mwc.saveSettings(); + }); + + + LOGGER.info("synchronization successful!"); + } catch (Exception e) { + // TODO: handle exception + } + } + }); thread.start(); - - } - - void uploadFile(String cloudService, File file) { - - //running uploadFile in a new thread, instead of blocking the main thread - new Thread() { - @Override - public void run() { - LOGGER.info("starting uploadFile in new thread ..."); - - if(cloudService.equals("GoogleDrive")) { - try { - googleDriveController.uploadFile(file); - } catch (IOException e) { - LOGGER.error("google drive uploadFile failed" ,e); - } - } - if(cloudService.equals("Dropbox")) { - - } - } - }.start(); - } - public String getFolderID(String cloudService) { - String folderID = ""; - if (cloudService != null) { - if(cloudService.equals("GoogleDrive")) { - folderID = googleDriveController.getFolderID(); - } - if(cloudService.equals("Dropbox")) { - - } - } - return folderID; + private File zipSavegames(String cemu_UIDirectory, String cemuDirectory) throws Exception { + long unixTimestamp = Instant.now().getEpochSecond(); + FileOutputStream fos = new FileOutputStream(cemu_UIDirectory + "/" + unixTimestamp + ".zip"); + ZipOutputStream zos = new ZipOutputStream(fos); + addDirToZipArchive(zos, new File(cemuDirectory + "/mlc01/usr/save"), null); + zos.flush(); + fos.flush(); + zos.close(); + fos.close(); + return new File(cemu_UIDirectory + "/" + unixTimestamp + ".zip"); } + + private static void addDirToZipArchive(ZipOutputStream zos, File fileToZip, String parrentDirectoryName) throws Exception { + if (fileToZip == null || !fileToZip.exists()) { + return; + } - public void setFolderID(String folderID, String cloudService) { - if (cloudService != null) { - if (cloudService.equals("GoogleDrive")) { - googleDriveController.setFolderID(folderID); - } - if (cloudService.equals("Dropbox")) { - - } + String zipEntryName = fileToZip.getName(); + if (parrentDirectoryName!=null && !parrentDirectoryName.isEmpty()) { + zipEntryName = parrentDirectoryName + "/" + fileToZip.getName(); + } + + if (fileToZip.isDirectory()) { +// System.out.println("+" + zipEntryName); + for (File file : fileToZip.listFiles()) { + addDirToZipArchive(zos, file, zipEntryName); + } + } else { +// System.out.println(" " + zipEntryName); + byte[] buffer = new byte[1024]; + FileInputStream fis = new FileInputStream(fileToZip); + zos.putNextEntry(new ZipEntry(zipEntryName)); + int length; + while ((length = fis.read(buffer)) > 0) { + zos.write(buffer, 0, length); + } + zos.closeEntry(); + fis.close(); + } + } + + private void unzipSavegames(String cemuDirectory, File outputFile) { + try { + ZipFile zipFile = new ZipFile(outputFile); + zipFile.extractAll(cemuDirectory + "/mlc01/usr"); + outputFile.delete(); + LOGGER.info("unzip successfull"); + } catch (ZipException e) { + LOGGER.error("an error occurred during unziping the file!", e); } } + } diff --git a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java index 51d55ab..622656c 100644 --- a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java +++ b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java @@ -21,17 +21,12 @@ package com.cemu_UI.vendorCloudController; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; - -import org.apache.commons.io.FileUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -56,15 +51,11 @@ import com.google.api.services.drive.model.FileList; public class GoogleDriveController { Drive service; - private String saveDirectory; private String folderID; - private ArrayList localSavegames = new ArrayList<>(); - private ArrayList cloudSavegames = new ArrayList<>(); - private ArrayList localSavegamesName = new ArrayList<>(); - private ArrayList cloudSavegamesName = new ArrayList<>(); + private File downloadFile; private static final Logger LOGGER = LogManager.getLogger(GoogleDriveController.class.getName()); - private final String APPLICATION_NAME ="cemu_Ui Drive API Controller"; //TODO add Google + private final String APPLICATION_NAME ="cemu_Ui Google Drive API Controller"; //Directory to store user credentials for this application private final java.io.File DATA_STORE_DIR = new java.io.File(System.getProperty("user.home"), ".credentials/cemu_UI_credential"); @@ -127,67 +118,10 @@ public class GoogleDriveController { public void main(String cemuDirectory) throws IOException { - java.io.File dir = new java.io.File(cemuDirectory + "/mlc01/usr/save"); - - service = getDriveService(); - - // cemu >= 1.11 uses /mlc01/usr/save/... instead of /mlc01/emulatorSave/... - if (dir.exists()) { - LOGGER.info("using new save path"); - saveDirectory = cemuDirectory + "/mlc01/usr/save"; - } else { - LOGGER.info("using old save path"); - saveDirectory = cemuDirectory + "/mlc01/emulatorSave"; - } + service = getDriveService(); } - - public void sync(String cemuDirectory) throws IOException { - //in case there is no folderID saved, look it up first - if (getFolderID() == "" || getFolderID() == null) { - getSavegamesFolderID(); - } - getLocalSavegames(); - getCloudSavegames(); - - // download files from cloud which don't exist locally - for (int i = 0; i < cloudSavegames.size(); i++) { - - // if the file exists locally, check which one is newer - if (localSavegamesName.contains(cloudSavegames.get(i).getName())) { - - int localSavegamesNumber = localSavegamesName.indexOf(cloudSavegames.get(i).getName()); - long localModified = new DateTime(localSavegames.get(localSavegamesNumber).lastModified()).getValue(); - long cloudModified = cloudSavegames.get(i).getModifiedTime().getValue(); - FileInputStream fis = new FileInputStream(localSavegames.get(localSavegamesNumber)); - - if (cloudSavegames.get(i).getMd5Checksum().equals(org.apache.commons.codec.digest.DigestUtils.md5Hex(fis))) { - LOGGER.info("both files are the same, nothing to do"); - } else { - if (localModified >= cloudModified) { - LOGGER.info("local is newer"); - updateFile(cloudSavegames.get(i), localSavegames.get(localSavegamesNumber)); - } else { - LOGGER.info("cloud is newer"); - downloadFile(cloudSavegames.get(i)); - } - } - - } else { - LOGGER.info("file doesn't exist locally"); - downloadFile(cloudSavegames.get(i)); - } - } - - // upload file to cloud which don't exist in the cloud - for (int j = 0; j < localSavegames.size(); j++) { - if (!cloudSavegamesName.contains(localSavegamesName.get(j))) { - LOGGER.info("file doesn't exist in the cloud"); - uploadFile(localSavegames.get(j)); - } - } - } - //create a folder in google drive + // create a folder in google drive public void creatFolder() throws IOException { LOGGER.info("creating new folder"); File fileMetadata = new File(); @@ -199,8 +133,8 @@ public class GoogleDriveController { folderID = file.getId(); } - //check if folder already exist - public boolean checkFolder() { + // check if folder already exist + public boolean checkFolder() { try { Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'"); FileList files = request.execute(); @@ -215,52 +149,41 @@ public class GoogleDriveController { } } - //reading all local savegames - private void getLocalSavegames() throws IOException { - java.io.File dir = new java.io.File(saveDirectory); - String[] extensions = new String[] { "dat","sav","bin" }; - localSavegames.removeAll(localSavegames); - localSavegamesName.removeAll(localSavegamesName); - LOGGER.info("Getting all dat,sav,bin files in " + dir.getCanonicalPath()+" including those in subdirectories"); - List files = (List) FileUtils.listFiles(dir, extensions, true); - for (java.io.File file : files) { - localSavegamesName.add(file.getParentFile().getName()+"_"+file.getName()); - localSavegames.add(file); - } - } - - //reading all cloud savegames - private void getCloudSavegames() throws IOException { - LOGGER.info("getting all cloud savegames"); - cloudSavegames.removeAll(cloudSavegames); - cloudSavegamesName.removeAll(cloudSavegamesName); + // FIXME it seams like there is a bug in this method + // get the name of the zip in the semu_savegames folder, which is the last upload Unix time + public long getLastCloudSync() throws IOException { + LOGGER.info("getting last cloud sync"); + long lastCloudSync = 0; Files.List request = service.files().list().setQ("'"+folderID+"' in parents").setFields("nextPageToken, files(id, name, size, modifiedTime, createdTime, md5Checksum)"); FileList files = request.execute(); for (File file : files.getFiles()) { - cloudSavegamesName.add(file.getName()); - cloudSavegames.add(file); - } + downloadFile = file; + lastCloudSync = Long.parseLong(file.getName().substring(0, file.getName().length()-4)); + } + + return lastCloudSync; } - private void getSavegamesFolderID() throws IOException { - Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'"); - FileList files = request.execute(); - - try { - LOGGER.info("FolderID: " + files.getFiles().get(0).getId()); - setFolderID(files.getFiles().get(0).getId()); - } catch (Exception e) { - LOGGER.error("Oops, something went wrong! It seems that you have more than one folder called 'cemu_savegames'!", e); - } - } + /** + * delete all existing files in cemu_savegames at first + * upload the new savegames zip file + * @param uploadFile savegames zip file + * @throws IOException + */ + public void uploadZipFile(java.io.File uploadFile) throws IOException{ + + LOGGER.info("deleting old savegames ..."); + Files.List request = service.files().list().setQ("'"+folderID+"' in parents").setFields("nextPageToken, files(id, name, size, modifiedTime, createdTime, md5Checksum)"); + FileList files = request.execute(); + + for (File file : files.getFiles()) { + service.files().delete(file.getId()).execute(); // deleting old file + } - - //upload a file to the cloud from the local savegames folder - public void uploadFile(java.io.File uploadFile) throws IOException{ LOGGER.info("uploading " + uploadFile.getName() + " ..."); File fileMetadata = new File(); - fileMetadata.setName(uploadFile.getParentFile().getName()+"_"+uploadFile.getName()); + fileMetadata.setName(uploadFile.getName()); fileMetadata.setParents(Collections.singletonList(folderID)); fileMetadata.setModifiedTime(new DateTime(uploadFile.lastModified())); FileContent mediaContent = new FileContent("", uploadFile); @@ -268,57 +191,16 @@ public class GoogleDriveController { LOGGER.info("upload successfull, File ID: " + file.getId()); } - //download a file from the cloud to the local savegames folder - private void downloadFile(File downloadFile) throws IOException{ + // download zip file from the cloud and unzip it + public java.io.File downloadZipFile(String cemu_UIDirectory) throws IOException{ LOGGER.info("downloading "+downloadFile.getName()+" ..."); - java.io.File directory = new java.io.File(saveDirectory + "/" + downloadFile.getName().substring(0,8)); - String file = downloadFile.getName().substring(9,downloadFile.getName().length()); - if(!directory.exists()) { - LOGGER.info("dir dosent exist"); - directory.mkdir(); - } + java.io.File outputFile = new java.io.File(cemu_UIDirectory + "/" + downloadFile.getName()); - OutputStream outputStream = new FileOutputStream(directory +"/"+ file); + OutputStream outputStream = new FileOutputStream(outputFile); service.files().get(downloadFile.getId()).executeMediaAndDownloadTo(outputStream); outputStream.close(); - LOGGER.info("download successfull, File ID: " + file); //TODO add FileID + LOGGER.info("download successfull: " + downloadFile.getName()); + return outputFile; } - //update a file in the cloud, by deleting the old one and uploading an new with the same id - private void updateFile(File oldFile, java.io.File newFile) throws IOException { - LOGGER.info("updating " +oldFile.getName()+" ..."); - service.files().delete(oldFile.getId()).execute(); //deleting old file - - //uploading new file - File fileMetadata = new File(); - fileMetadata.setName(newFile.getParentFile().getName()+"_"+newFile.getName()); - fileMetadata.setParents(Collections.singletonList(folderID)); - fileMetadata.setModifiedTime(new DateTime(newFile.lastModified())); - - FileContent mediaContent = new FileContent("", newFile); - File file = service.files().create(fileMetadata, mediaContent).setFields("id, parents").execute(); - LOGGER.info("update successfull, File ID: " + file.getId()); - } - - public void uploadAllFiles() { - try { - getLocalSavegames(); - LOGGER.info("uploading " + localSavegames.size() + " files ..."); - for (int i = 0; i < localSavegames.size(); i++) { - uploadFile(localSavegames.get(i)); - } - LOGGER.info("finished uploading all files"); - } catch (IOException e) { - LOGGER.error("error while uploading all files", e); - } - } - - - public String getFolderID() { - return folderID; - } - - public void setFolderID(String folderID) { - this.folderID = folderID; - } } From 599669f0f2f196bca4547373978349b611d9dc7f Mon Sep 17 00:00:00 2001 From: Jannik Date: Wed, 13 Dec 2017 00:07:20 +0100 Subject: [PATCH 06/15] fixed a bug that prefent the cloud controller from geting the latest cloud sync --- .../application/MainWindowController.java | 8 +++++ .../cemu_UI/controller/CloudController.java | 24 ++++++++++++++ .../GoogleDriveController.java | 31 ++++++++++++++++--- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index ad1dd7c..1416012 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1555,6 +1555,7 @@ public class MainWindowController { } else { props.setProperty("cloudService", getCloudService()); } + props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); props.setProperty("windowWidth", String.valueOf(mainAnchorPane.getWidth())); props.setProperty("windowHeight", String.valueOf(mainAnchorPane.getHeight())); @@ -1642,6 +1643,13 @@ public class MainWindowController { setCloudService(""); } + try { + main.getCloudController().setFolderID(props.getProperty("folderID"), getCloudService()); + } catch (Exception e) { + LOGGER.error("could not load folderID, disable cloud sync. Please contact an developer", e); + setCloudSync(false); + } + try { setLastLocalSync(Long.parseLong(props.getProperty("lastLocalSync"))); } catch (Exception e) { diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java index 25b995b..3c37c94 100644 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ b/src/main/java/com/cemu_UI/controller/CloudController.java @@ -202,4 +202,28 @@ public class CloudController { } } + public String getFolderID(String cloudService) { + String folderID = ""; + if (cloudService != null) { + if (cloudService.equals("GoogleDrive")) { + folderID = googleDriveController.getFolderID(); + } + if (cloudService.equals("Dropbox")) { + + } + } + return folderID; + } + + public void setFolderID(String folderID, String cloudService) { + if (cloudService != null) { + if (cloudService.equals("GoogleDrive")) { + googleDriveController.setFolderID(folderID); + } + if (cloudService.equals("Dropbox")) { + + } + } + } + } diff --git a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java index 622656c..485ceef 100644 --- a/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java +++ b/src/main/java/com/cemu_UI/vendorCloudController/GoogleDriveController.java @@ -116,10 +116,13 @@ public class GoogleDriveController { .build(); } - - public void main(String cemuDirectory) throws IOException { - service = getDriveService(); - } + public void main(String cemuDirectory) throws IOException { + service = getDriveService(); + + if (getFolderID() == "" || getFolderID() == null) { + getSavegamesFolderID(); + } + } // create a folder in google drive public void creatFolder() throws IOException { @@ -203,4 +206,24 @@ public class GoogleDriveController { return outputFile; } + private void getSavegamesFolderID() throws IOException { + Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder' and name = 'cemu_savegames'"); + FileList files = request.execute(); + + try { + LOGGER.info("FolderID: " + files.getFiles().get(0).getId()); + setFolderID(files.getFiles().get(0).getId()); + } catch (Exception e) { + LOGGER.error("Oops, something went wrong! It seems that you have more than one folder called 'cemu_savegames'!", e); + } +} + + public String getFolderID() { + return folderID; + } + + public void setFolderID(String folderID) { + this.folderID = folderID; +} + } From 595bfbe07d9a8c7e476b19d53b38b6e30319a3c8 Mon Sep 17 00:00:00 2001 From: Jannik Date: Sat, 16 Dec 2017 23:05:26 +0100 Subject: [PATCH 07/15] bummped buildnumber to 065 --- src/main/java/com/cemu_UI/application/MainWindowController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 1416012..f061156 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -276,7 +276,7 @@ public class MainWindowController { private String selectedGameTitle; private String id; private String version = "0.2.2"; - private String buildNumber = "061"; + private String buildNumber = "065"; private String versionName = "Puzzle Plank Galaxy"; private int xPos = -200; private int yPos = 17; From fc0be3945503bd99a56cd50a615e179557dd4194 Mon Sep 17 00:00:00 2001 From: Jannik Date: Mon, 18 Dec 2017 09:58:32 +0100 Subject: [PATCH 08/15] code clean up * cleaned up the playBtn code * added language section in settings --- .../java/com/cemu_UI/application/Main.java | 14 ++--- .../application/MainWindowController.java | 56 ++++++------------- src/main/resources/fxml/MainWindow.fxml | 26 ++++++--- 3 files changed, 39 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 9ff4761..2096c7e 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -51,13 +51,11 @@ import javafx.scene.layout.AnchorPane; public class Main extends Application { - private Stage primaryStage; // TODO same as #Test01 - private MainWindowController mainWindowController; // TODO Needs more testing: if cemu_UI will work as - //normally expected this waring can be removed #Test01 - // if not working correctly remove private! - private CloudController cloudController; // TODO same as #Test01 - private AnchorPane pane; // TODO same as #Test01 - private Scene scene; // TODO same as #Test01 + private Stage primaryStage; + private MainWindowController mainWindowController; + private CloudController cloudController; + private AnchorPane pane; + private Scene scene; private static String userHome = System.getProperty("user.home"); private static String userName = System.getProperty("user.name"); private static String osName = System.getProperty("os.name"); @@ -234,8 +232,6 @@ public class Main extends Application { @Override public void changed(ObservableValue observable, Number oldValue, final Number newValue) { int xPosHelperMax = (int) Math.floor((mainWindowController.getMainAnchorPane().getWidth() - 36) / 217); - - mainWindowController.refreshplayBtnPosition(); // call only if there is enough space for a new row if (mainWindowController.getOldXPosHelper() != xPosHelperMax) { diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index f061156..0d3ebca 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -170,6 +170,9 @@ public class MainWindowController { @FXML private JFXToggleButton fullscreenToggleBtn; + + @FXML + private ChoiceBox languageChoisBox; @FXML private ChoiceBox branchChoisBox; @@ -203,6 +206,9 @@ public class MainWindowController { @FXML private HBox topHBox; + + @FXML + private HBox bottomHBox; @FXML private ImageView smmdbImageView; @@ -221,6 +227,9 @@ public class MainWindowController { @FXML private Label mainColorLbl; + + @FXML + private Label languageLbl; @FXML private Label updateLbl; @@ -276,7 +285,7 @@ public class MainWindowController { private String selectedGameTitle; private String id; private String version = "0.2.2"; - private String buildNumber = "065"; + private String buildNumber = "067"; private String versionName = "Puzzle Plank Galaxy"; private int xPos = -200; private int yPos = 17; @@ -295,6 +304,7 @@ public class MainWindowController { private File pictureCacheWin = new File(dirWin + "/picture_cache"); private File pictureCacheLinux = new File(dirLinux + "/picture_cache"); private ObservableList branches = FXCollections.observableArrayList("stable", "beta"); + private ObservableList languages = FXCollections.observableArrayList("english", "deutsch"); private ObservableList smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs private ObservableList games = FXCollections.observableArrayList(); ObservableList courses = FXCollections.observableArrayList(); @@ -350,7 +360,6 @@ public class MainWindowController { if (getWindowWidth() > 100 && getWindowHeight() > 100) { mainAnchorPane.setPrefSize(getWindowWidth(), getWindowHeight()); } - refreshplayBtnPosition(); cemuTextField.setText(cemuPath); romTextField.setText(romPath); @@ -359,6 +368,8 @@ public class MainWindowController { cloudSyncToggleBtn.setSelected(isCloudSync()); autoUpdateToggleBtn.setSelected(isAutoUpdate()); branchChoisBox.setItems(branches); + languageChoisBox.setItems(languages); + bottomHBox.setPickOnBounds(false); if (isUseBeta()) { branchChoisBox.getSelectionModel().select(1); @@ -1293,19 +1304,6 @@ public class MainWindowController { gamesAnchorPane.getChildren().add(games.get(i).getVBox()); } } - - void refreshplayBtnPosition() { - double width; - - if (mainAnchorPane.getWidth() < 10) { - width = mainAnchorPane.getPrefWidth(); - } else { - width = mainAnchorPane.getWidth(); - } - playBtn.setLayoutX((width / 2) - 50); - totalPlaytimeBtn.setLayoutX((width / 2) - 50 - 20.5 - 100); - lastTimePlayedBtn.setLayoutX((width / 2) + 50 + 20.5); - } private void checkAutoUpdate() { @@ -1696,43 +1694,21 @@ public class MainWindowController { } private void playBtnSlideIn(){ - playBtn.setVisible(true); - lastTimePlayedBtn.setVisible(true); - totalPlaytimeBtn.setVisible(true); + bottomHBox.setVisible(true); playTrue = true; - TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), playBtn); + TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox); playBtnTransition.setFromY(56); playBtnTransition.setToY(0); playBtnTransition.play(); - - TranslateTransition lastTimePlayedBtnTransition = new TranslateTransition(Duration.millis(300), lastTimePlayedBtn); - lastTimePlayedBtnTransition.setFromY(56); - lastTimePlayedBtnTransition.setToY(0); - lastTimePlayedBtnTransition.play(); - - TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), totalPlaytimeBtn); - timePlayedBtnTransition.setFromY(56); - timePlayedBtnTransition.setToY(0); - timePlayedBtnTransition.play(); } private void playBtnSlideOut(){ playTrue = false; - TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), playBtn); + TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox); playBtnTransition.setFromY(0); playBtnTransition.setToY(56); playBtnTransition.play(); - - TranslateTransition lastTimePlayedBtnTransition = new TranslateTransition(Duration.millis(300), lastTimePlayedBtn); - lastTimePlayedBtnTransition.setFromY(0); - lastTimePlayedBtnTransition.setToY(56); - lastTimePlayedBtnTransition.play(); - - TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), totalPlaytimeBtn); - timePlayedBtnTransition.setFromY(0); - timePlayedBtnTransition.setToY(56); - timePlayedBtnTransition.play(); } private void editColor(String input){ diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index 4f85bb4..5502ba9 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -118,10 +118,16 @@ - + + + + @@ -205,13 +211,17 @@ - - - - + + + - - - + + + + + + + + From ce52628554e18007fbdaf3954f6d6b17693a301c Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 19 Dec 2017 19:08:12 +0100 Subject: [PATCH 09/15] language work part 1 * added support for different languages * added english locals --- .../application/MainWindowController.java | 142 +++++++++++++++++- .../locals/cemu_UI-Local_de_DE.properties | 63 ++++++++ .../locals/cemu_UI-Local_en_US.properties | 58 +++++++ 3 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/locals/cemu_UI-Local_de_DE.properties create mode 100644 src/main/resources/locals/cemu_UI-Local_en_US.properties diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 0d3ebca..bb6efe2 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -42,7 +42,9 @@ import java.sql.SQLException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.Locale; import java.util.Properties; +import java.util.ResourceBundle; import javax.imageio.ImageIO; import javax.swing.ProgressMonitor; @@ -304,7 +306,7 @@ public class MainWindowController { private File pictureCacheWin = new File(dirWin + "/picture_cache"); private File pictureCacheLinux = new File(dirLinux + "/picture_cache"); private ObservableList branches = FXCollections.observableArrayList("stable", "beta"); - private ObservableList languages = FXCollections.observableArrayList("english", "deutsch"); + private ObservableList languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); private ObservableList smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); // TODO add more IDs private ObservableList games = FXCollections.observableArrayList(); ObservableList courses = FXCollections.observableArrayList(); @@ -334,6 +336,37 @@ public class MainWindowController { private ImageView smmdb_white = new ImageView(new Image("icons/ic_get_app_white_24dp_1x.png")); private Image close_black = new Image("icons/close_black_2048x2048.png"); + // language support + private ResourceBundle bundle; + private String language; + private String editHeadingText; + private String editBodyText; + private String removeHeadingText; + private String removeBodyText; + private String addUpdateHeadingText; + private String addUpdateBodyText; + private String addDLCHeadingText; + private String addDLCBodyText; + private String licensesLblHeadingText; + private String licensesLblBodyText; + private String aboutBtnHeadingText; + private String aboutBtnBodyText; + private String cloudSyncWaringHeadingText; + private String cloudSyncWaringBodyText; + private String cloudSyncErrorHeadingText; + private String cloudSyncErrorBodyText; + private String addBtnReturnErrorHeadingText; + private String addBtnReturnErrorBodyText; + + private String playBtnPlay; + private String playBtnUpdating; + private String playBtnCopyingFiles; + private String okayBtnText; + private String cancelBtnText; + private String updateBtnCheckNow; + private String updateBtnNoUpdateAvailable; + private String updateBtnUpdateAvailable; + public void setMain(Main m) { this.main = m; dbController = new DBController(this); @@ -399,6 +432,8 @@ public class MainWindowController { courseTreeTable.getColumns().add(idColumn); courseTreeTable.getColumns().get(3).setVisible(false); // the idColumn should not bee displayed + setUILanguage(); + LOGGER.info("initializing UI done"); } @@ -445,7 +480,7 @@ public class MainWindowController { String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); // new edit dialog - String headingText = "edit a game"; + String headingText = "edit \"" + selectedGameTitle + "\""; String bodyText = "You can edit the tile and rom/cover path."; JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 1, MWC, main.getPrimaryStage(), main.getPane()); @@ -706,6 +741,17 @@ public class MainWindowController { } } }); + + languageChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue ov, Number value, Number new_value) { + String language = languageChoisBox.getItems().get((int) new_value).toString(); + language = language.substring(language.length()-6,language.length()-1); //reading only en_US from English (en_US) + setLanguage(language); + setUILanguage(); + saveSettings(); + } + }); branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener() { @Override @@ -1304,6 +1350,82 @@ public class MainWindowController { gamesAnchorPane.getChildren().add(games.get(i).getVBox()); } } + + // TODO add strings for dialogs + void setUILanguage(){ + switch(getLanguage()){ + case "en_US": + bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); //us_English + languageChoisBox.getSelectionModel().select(0); + break; + case "de_DE": + bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.GERMAN); //German + languageChoisBox.getSelectionModel().select(1); + break; + default: + bundle = ResourceBundle.getBundle("locals.cemu_UI-Local", Locale.US); //default local + languageChoisBox.getSelectionModel().select(0); + break; + } + + // Buttons + aboutBtn.setText(bundle.getString("aboutBtn")); + settingsBtn.setText(bundle.getString("settingsBtn")); + addBtn.setText(bundle.getString("addBtn")); + reloadRomsBtn.setText(bundle.getString("reloadRomsBtn")); + smmdbBtn.setText(bundle.getString("smmdbBtn")); + cemuTFBtn.setText(bundle.getString("cemuTFBtn")); + romTFBtn.setText(bundle.getString("romTFBtn")); + updateBtn.setText(bundle.getString("updateBtnCheckNow")); + smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtn")); + playBtn.setText(bundle.getString("playBtn")); + + // Labels + cemu_UISettingsLbl.setText(bundle.getString("cemu_UISettingsLbl")); + cemuDirectoryLbl.setText(bundle.getString("cemuDirectoryLbl")); + romDirectoryLbl.setText(bundle.getString("romDirectoryLbl")); + mainColorLbl.setText(bundle.getString("mainColorLbl")); + languageLbl.setText(bundle.getString("languageLbl")); + updateLbl.setText(bundle.getString("updateLbl")); + branchLbl.setText(bundle.getString("branchLbl")); + cemuSettingsLbl.setText(bundle.getString("cemuSettingsLbl")); + licensesLbl.setText(bundle.getString("licensesLbl")); + + // Columns + titleColumn.setText(bundle.getString("titleColumn")); + idColumn.setText(bundle.getString("idColumn")); + starsColumn.setText(bundle.getString("starsColumn")); + timeColumn.setText(bundle.getString("timeColumn")); + + // Strings + editHeadingText = bundle.getString("editHeadingText"); + editBodyText = bundle.getString("editBodyText"); + removeHeadingText = bundle.getString("removeHeadingText"); + removeBodyText = bundle.getString("removeBodyText"); + addUpdateHeadingText = bundle.getString("addUpdateHeadingText"); + addUpdateBodyText = bundle.getString("addUpdateBodyText"); + addDLCHeadingText = bundle.getString("addDLCHeadingText"); + addDLCBodyText = bundle.getString("addDLCBodyText"); + licensesLblHeadingText = bundle.getString("licensesLblHeadingText"); + licensesLblBodyText = bundle.getString("licensesLblBodyText"); + aboutBtnHeadingText = bundle.getString("aboutBtnHeadingText"); + aboutBtnBodyText = bundle.getString("aboutBtnBodyText"); + cloudSyncWaringHeadingText = bundle.getString("cloudSyncWaringHeadingText"); + cloudSyncWaringBodyText = bundle.getString("cloudSyncWaringBodyText"); + cloudSyncErrorHeadingText = bundle.getString("cloudSyncErrorHeadingText"); + cloudSyncErrorBodyText = bundle.getString("cloudSyncErrorBodyText"); + addBtnReturnErrorHeadingText = bundle.getString("addBtnReturnErrorHeadingText"); + addBtnReturnErrorBodyText = bundle.getString("addBtnReturnErrorBodyText"); + + playBtnPlay = bundle.getString("playBtnPlay"); + playBtnUpdating = bundle.getString("playBtnUpdating"); + playBtnCopyingFiles = bundle.getString("playBtnCopyingFiles"); + okayBtnText = bundle.getString("okayBtnText"); + cancelBtnText = bundle.getString("cancelBtnText"); + updateBtnCheckNow = bundle.getString("updateBtnCheckNow"); + updateBtnNoUpdateAvailable = bundle.getString("updateBtnNoUpdateAvailable"); + updateBtnUpdateAvailable = bundle.getString("updateBtnUpdateAvailable"); + } private void checkAutoUpdate() { @@ -1544,6 +1666,7 @@ public class MainWindowController { props.setProperty("cemuPath", getCemuPath()); props.setProperty("romPath", getRomPath()); props.setProperty("color", getColor()); + props.setProperty("language", getLanguage()); props.setProperty("fullscreen", String.valueOf(isFullscreen())); props.setProperty("cloudSync", String.valueOf(isCloudSync())); props.setProperty("autoUpdate", String.valueOf(isAutoUpdate())); @@ -1605,6 +1728,13 @@ public class MainWindowController { LOGGER.error("could not load color value, setting default instead", e); setColor("00a8cc"); } + + try { + setLanguage(props.getProperty("language")); + } catch (Exception e) { + LOGGER.error("cloud not load language", e); + setLanguage(System.getProperty("user.language")+"_"+System.getProperty("user.country")); + } try { setFullscreen(Boolean.parseBoolean(props.getProperty("fullscreen"))); @@ -1910,6 +2040,14 @@ public class MainWindowController { this.oldXPosHelper = oldXPosHelper; } + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + public AnchorPane getMainAnchorPane() { return mainAnchorPane; } diff --git a/src/main/resources/locals/cemu_UI-Local_de_DE.properties b/src/main/resources/locals/cemu_UI-Local_de_DE.properties new file mode 100644 index 0000000..aa9c214 --- /dev/null +++ b/src/main/resources/locals/cemu_UI-Local_de_DE.properties @@ -0,0 +1,63 @@ +#HomeFlix-Local_de_DE.properties German Local + +#main window translations +info = Info +settings = Einstellungen +streamingSettings = Stream Einst. +tfSearch = Suche... +openFolder = Ordner \u00F6ffnen + +#settings translations +settingsHead1Label = HomeFlix Einstellungen +tfPath = Pfad... +chooseFolder = Ordner ausw\u00E4hlen +mainColorLabel = Hauptfarbe: +fontsizeLabel = Schriftgr\u00F6\u00DFe: +localLabel = Sprache: +checkUpdates = Auf Update pr\u00FCfen +checkingUpdates = Es wird nach Updates gesucht... +updateBtnavail = Update verf\u00FCgbar +updateBtnNotavail = Kein Update verf\u00FCgbar +autoUpdateLabel = beim Start nach Updates suchen: +version = Version: + +#column translations +columnName = Name +columnRating = Bewertung +columnStreamUrl = Datei Name +columnResolution = Aufl\u00F6sung +columnSeason = Staffel +columnYear = Jahr + +#error translations +errorUpdateV = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not check update version (nvc)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz +errorUpdateD = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not download update files (ndf)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz +errorPlay = Beim \u00F6ffnen der Datei ist ein Fehler aufgetreten! \nError: could not open file (nof) \nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz +errorMode = Oh, da lief etwas falsch! Da hat jemand einen falschen Modus verwendet. \nError: mode unknow (muk)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz +errorOpenStream = Beim \u00F6ffnen des Streams ist ein Fehler aufgetreten! +errorLoad = Beim laden der Einstellungen ist ein Fehler aufgetreten! +errorSave = Beim speichern der Einstellungen ist ein Fehler aufgetreten! +noFilmFound = Kein Film mit diesem Titel gefunden! +vlcNotInstalled = Um einen Film abspielen wird der VLC Media Player ben\u00F6tigt! +infoText = \nMaintainer: seilo@kellerkinder.xyz und \nhendrik.schutter@coptersicht.de \n(c) 2016-2017 Kellerkinder www.kellerkinder.xyz + +#textFlow translations +title = Titel +year = Jahr +rating = Einstufung +publishedOn = Ver\u00F6ffentlicht am +duration = Laufzeit +genre = Gener +director = Regisseur +writer = Autor +actors = Schauspieler +plot = Beschreibung +language = Original Sprache +country = Produktionsland +awards = Auszeichnungen +metascore = Metascore +imdbRating = IMDB-Bewertung +type = Type + +firstStartHeader = Es ist kein Stammverzeichnis f\u00FCr Filme angegeben! +firstStartContent = Stammverzeichniss angeben? diff --git a/src/main/resources/locals/cemu_UI-Local_en_US.properties b/src/main/resources/locals/cemu_UI-Local_en_US.properties new file mode 100644 index 0000000..6780842 --- /dev/null +++ b/src/main/resources/locals/cemu_UI-Local_en_US.properties @@ -0,0 +1,58 @@ +#HomeFlix-Local_en_US.properties US-English Local and default + +# Buttons +aboutBtn = About +settingsBtn = Setting +addBtn = Add new Game +reloadRomsBtn = reload ROMs +smmdbBtn = ammdb +cemuTFBtn = choose directory +romTFBtn = choose directory +smmdbDownloadBtn = +playBtn = + +# Labels +cemu_UISettingsLbl = cemu_UI settings +cemuDirectoryLbl = cemu directory +romDirectoryLbl = ROM directory +mainColorLbl = main color +languageLbl = language +updateLbl = updates +branchLbl = branch +cemuSettingsLbl = cemu settings +licensesLbl = licenses + +# Columns +titleColumn = title +idColumn = ID +starsColumn = stars +timeColumn = time + +# Strings +editHeadingText = edit +editBodyText = You can edit the tile and rom/cover path. +removeHeadingText = remove +removeBodyText = Are you sure you want to delete +addUpdateHeadingText = +addUpdateBodyText = +addDLCHeadingText = +addDLCBodyText = +licensesLblHeadingText = +licensesLblBodyText = +aboutBtnHeadingText = +aboutBtnBodyText = +cloudSyncWaringHeadingText = +cloudSyncWaringBodyText = +cloudSyncErrorHeadingText = +cloudSyncErrorBodyText = +addBtnReturnErrorHeadingText = +addBtnReturnErrorBodyText = + +playBtnPlay = +playBtnUpdating = +playBtnCopyingFiles = +okayBtnText = +cancelBtnText = +updateBtnCheckNow = check now! +updateBtnNoUpdateAvailable = no update available +updateBtnUpdateAvailable = update available From 34bed89b400a4856b6bc146eba8667ffc7b07a27 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 19 Dec 2017 21:35:49 +0100 Subject: [PATCH 10/15] language work part 2 * dialogs support different languages now too * finished english language pack --- .../java/com/cemu_UI/application/Main.java | 3 +- .../application/MainWindowController.java | 173 ++++++++---------- .../com/cemu_UI/application/playGame.java | 1 - .../cemu_UI/controller/UpdateController.java | 7 +- .../cemu_UI/uiElements/JFXEditGameDialog.java | 29 ++- .../uiElements/JFXOkayCancelDialog.java | 14 +- .../locals/cemu_UI-Local_en_US.properties | 68 ++++--- 7 files changed, 151 insertions(+), 144 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 2096c7e..94bf57c 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -138,8 +138,9 @@ public class Main extends Application { firstStart(); mainWindowController.setColor("00a8cc"); mainWindowController.setAutoUpdate(false); - mainWindowController.setxPosHelper(0); + mainWindowController.setLanguage("en_US"); mainWindowController.setLastLocalSync(0); + mainWindowController.setxPosHelper(0); mainWindowController.saveSettings(); Runtime.getRuntime().exec("java -jar cemu_UI.jar"); //start again (preventing Bugs) System.exit(0); //finishes itself diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index bb6efe2..60fb0ce 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -287,7 +287,7 @@ public class MainWindowController { private String selectedGameTitle; private String id; private String version = "0.2.2"; - private String buildNumber = "067"; + private String buildNumber = "069"; private String versionName = "Puzzle Plank Galaxy"; private int xPos = -200; private int yPos = 17; @@ -355,17 +355,19 @@ public class MainWindowController { private String cloudSyncWaringBodyText; private String cloudSyncErrorHeadingText; private String cloudSyncErrorBodyText; + private String addGameBtnHeadingText; + private String addGameBtnBodyText; private String addBtnReturnErrorHeadingText; private String addBtnReturnErrorBodyText; + private String lastPlayed; + private String today; + private String yesterday; private String playBtnPlay; private String playBtnUpdating; private String playBtnCopyingFiles; - private String okayBtnText; - private String cancelBtnText; - private String updateBtnCheckNow; - private String updateBtnNoUpdateAvailable; - private String updateBtnUpdateAvailable; + private String smmdbDownloadBtnLoading; + private String smmdbDownloadBtnDownload; public void setMain(Main m) { this.main = m; @@ -480,9 +482,8 @@ public class MainWindowController { String[] gameInfo = dbController.getGameInfo(selectedGameTitleID); // new edit dialog - String headingText = "edit \"" + selectedGameTitle + "\""; - String bodyText = "You can edit the tile and rom/cover path."; - JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, + String headingText = editHeadingText + " \"" + selectedGameTitle + "\""; + JFXEditGameDialog editGameDialog = new JFXEditGameDialog(headingText, editBodyText, dialogBtnStyle, 450, 300, 1, MWC, main.getPrimaryStage(), main.getPane()); editGameDialog.setTitle(gameInfo[0]); editGameDialog.setCoverPath(gameInfo[1]); @@ -500,8 +501,8 @@ public class MainWindowController { public void handle(ActionEvent event) { try { LOGGER.info("remove " + selectedGameTitle + "(" + selectedGameTitleID + ")"); - String headingText = "remove \"" + selectedGameTitle + "\""; - String bodyText = "Are you sure you want to delete " + selectedGameTitle + " ?"; + String headingText = removeHeadingText + " \"" + selectedGameTitle + "\""; + String bodyText = removeBodyText + " " + selectedGameTitle + " ?"; EventHandler okayAction = new EventHandler() { @Override public void handle(ActionEvent event) { @@ -523,7 +524,7 @@ public class MainWindowController { }; JFXOkayCancelDialog removeGameDialog = new JFXOkayCancelDialog(headingText, bodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane()); + dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane(), bundle); removeGameDialog.show(); } catch (Exception e) { LOGGER.error("error while removing " + selectedGameTitle + "(" + selectedGameTitleID + ")", e); @@ -536,8 +537,7 @@ public class MainWindowController { public void handle(ActionEvent event) { try { LOGGER.info("update: " + selectedGameTitleID); - String headingText = "update \"" + selectedGameTitle + "\""; - String bodyText = "pleas select the update root directory"; + String headingText = addUpdateHeadingText + " \"" + selectedGameTitle + "\""; EventHandler okayAction = new EventHandler() { @Override public void handle(ActionEvent event) { @@ -546,13 +546,7 @@ public class MainWindowController { String updatePath = selectedDirecroty.getAbsolutePath(); String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" File srcDir = new File(updatePath); - File destDir; - - if (System.getProperty("os.name").equals("Linux")) { - destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1]); - } else { - destDir = new File(cemuPath + "\\mlc01\\usr\\title\\" + parts[0] + "\\" + parts[1]); - } + File destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1]); // if directory doesn't exist create it if (destDir.exists() != true) { @@ -561,10 +555,10 @@ public class MainWindowController { try { LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString()); - playBtn.setText("updating..."); + playBtn.setText(playBtnUpdating); playBtn.setDisable(true); FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator - playBtn.setText("play"); + playBtn.setText(playBtnPlay); playBtn.setDisable(false); LOGGER.info("copying files done!"); } catch (IOException e) { @@ -580,8 +574,8 @@ public class MainWindowController { } }; - JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, bodyText, - dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane()); + JFXOkayCancelDialog updateGameDialog = new JFXOkayCancelDialog(headingText, addUpdateBodyText, + dialogBtnStyle, 350, 170, okayAction, cancelAction, main.getPane(), bundle); updateGameDialog.show(); } catch (Exception e) { LOGGER.warn("trying to update " + selectedGameTitleID + ",which is not a valid type!", e); @@ -594,8 +588,7 @@ public class MainWindowController { public void handle(ActionEvent event) { try { LOGGER.info("add DLC: " + selectedGameTitleID); - String headingText = "add a DLC to \"" + selectedGameTitle + "\""; - String bodyText = "pleas select the DLC root directory"; + String headingText = addDLCHeadingText + " \"" + selectedGameTitle + "\""; EventHandler okayAction = new EventHandler() { @Override public void handle(ActionEvent event) { @@ -604,13 +597,7 @@ public class MainWindowController { String dlcPath = selectedDirecroty.getAbsolutePath(); String[] parts = selectedGameTitleID.split("-"); // split string into 2 parts at "-" File srcDir = new File(dlcPath); - File destDir; - if (System.getProperty("os.name").equals("Linux")) { - destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1] + "/aoc"); - } else { - destDir = new File( - cemuPath + "\\mlc01\\usr\\title\\" + parts[0] + "\\" + parts[1] + "\\aoc"); - } + File destDir = new File(cemuPath + "/mlc01/usr/title/" + parts[0] + "/" + parts[1] + "/aoc"); // if directory doesn't exist create it if (destDir.exists() != true) { @@ -619,10 +606,10 @@ public class MainWindowController { try { LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString()); - playBtn.setText("copying files..."); + playBtn.setText(playBtnCopyingFiles); playBtn.setDisable(true); FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator - playBtn.setText("play"); + playBtn.setText(playBtnPlay); playBtn.setDisable(false); LOGGER.info("copying files done!"); } catch (IOException e) { @@ -638,8 +625,8 @@ public class MainWindowController { } }; - JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, - 350, 170, okayAction, cancelAction, main.getPane()); + JFXOkayCancelDialog addDLCDialog = new JFXOkayCancelDialog(headingText, addDLCBodyText, dialogBtnStyle, + 350, 170, okayAction, cancelAction, main.getPane(), bundle); addDLCDialog.show(); } catch (Exception e) { LOGGER.warn("trying to add a dlc to " + selectedGameTitleID + ",which is not a valid type!", e); @@ -769,17 +756,7 @@ public class MainWindowController { @Override public void handle(MouseEvent mouseEvent) { if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){ - - String headingText = "cemu_UI"; - String bodyText = "cemu_UI is licensed under the terms of GNU GPL 3.\n\n" - + "JFoenix, Apache License 2.0\n" - + "minimal-json, MIT License\n" - + "sqlite-jdbc, Apache License 2.0\n" - + "Apache Commons IO, Apache License 2.0\n" - + "Apache Commons Logging, Apache License 2.0\n" - + "Apache Commons Codec, Apache License 2.0\n" - + "Apache Log4j 2, Apache License 2.0\n"; - + EventHandler okayAction = new EventHandler() { @Override public void handle(ActionEvent event) { @@ -813,10 +790,11 @@ public class MainWindowController { } }; - JFXOkayCancelDialog licenseOverviewDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, - 350, 275, okayAction, cancelAction, main.getPane()); + JFXOkayCancelDialog licenseOverviewDialog = new JFXOkayCancelDialog(licensesLblHeadingText, + licensesLblBodyText, dialogBtnStyle, 350, 275, okayAction, cancelAction, main.getPane(), + bundle); licenseOverviewDialog.setCancelText("show licenses"); - licenseOverviewDialog.show(); + licenseOverviewDialog.show(); } } }); @@ -831,12 +809,9 @@ public class MainWindowController { @FXML void aboutBtnAction() { - String headingText = "cemu_UI"; String bodyText = "cemu_UI by @Seil0 \nVersion: " + version + " (" + buildNumber + ") \"" + versionName + "\" \n" - + "This Application is made with free Software\n" - + "and licensed under the terms of GNU GPL 3.\n\n" - + "www.kellerkinder.xyz"; - JFXInfoDialog aboutDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 350, 200, main.getPane()); + + aboutBtnBodyText; + JFXInfoDialog aboutDialog = new JFXInfoDialog(aboutBtnHeadingText, bodyText, dialogBtnStyle, 350, 200, main.getPane()); aboutDialog.show(); } @@ -895,7 +870,7 @@ public class MainWindowController { @Override public void run() { Platform.runLater(() -> { - smmdbDownloadBtn.setText("loading ..."); + smmdbDownloadBtn.setText(smmdbDownloadBtnLoading); smmdbDownloadBtn.setDisable(true); root.getChildren().remove(0,root.getChildren().size()); }); @@ -909,7 +884,7 @@ public class MainWindowController { Platform.runLater(() -> { root.getChildren().add(new TreeItem(helpCourse)); // add data to root-node - smmdbDownloadBtn.setText("Download"); + smmdbDownloadBtn.setText(smmdbDownloadBtnDownload); smmdbDownloadBtn.setDisable(false); }); } @@ -1091,11 +1066,6 @@ public class MainWindowController { if(cloudSync) { cloudSync = false; } else { - String headingText = "activate cloud savegame sync (beta)"; - String bodyText = "WARNING this is a completly WIP cloud save integration, " - + "\nit's NOT recomended to use this!!\n" - + "\nUse it on your own risk and backup everthing before!"; - EventHandler okayAction = new EventHandler(){ @Override public void handle(ActionEvent event){ @@ -1115,12 +1085,9 @@ public class MainWindowController { cloudSyncToggleBtn.setSelected(false); //cloud sync init error dialog - String headingText = "Error while initializing cloud sync!"; - String bodyText = "There was some truble adding your game." - + "\nPlease upload the app.log (which can be found in the cemu_UI directory)" - + "\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this."; - JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.getPane()); - cloudSyncErrorDialog.show(); + JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(cloudSyncErrorHeadingText, + cloudSyncErrorBodyText, dialogBtnStyle, 450, 170, main.getPane()); + cloudSyncErrorDialog.show(); } } @@ -1136,9 +1103,10 @@ public class MainWindowController { } }; - JFXOkayCancelDialog cloudSyncErrorDialog = new JFXOkayCancelDialog(headingText, bodyText, dialogBtnStyle, - 419, 140, okayAction, cancelAction, main.getPane()); - cloudSyncErrorDialog.show(); + JFXOkayCancelDialog cloudSyncWarningDialog = new JFXOkayCancelDialog(cloudSyncWaringHeadingText, + cloudSyncWaringBodyText, dialogBtnStyle, 419, 140, okayAction, cancelAction, main.getPane(), + bundle); + cloudSyncWarningDialog.show(); } } @@ -1150,8 +1118,8 @@ public class MainWindowController { @FXML void addBtnAction(ActionEvent event) { - String headingText = "add a new game to cemu_UI"; - String bodyText = ""; + String headingText = addGameBtnHeadingText; + String bodyText = addGameBtnBodyText; JFXEditGameDialog addGameDialog = new JFXEditGameDialog(headingText, bodyText, dialogBtnStyle, 450, 300, 0, this, main.getPrimaryStage(), main.getPane()); addGameDialog.show(); @@ -1171,11 +1139,9 @@ public class MainWindowController { LOGGER.info("No parameter set!"); //addGame error dialog - String headingTextError = "Error while adding a new Game!"; - String bodyTextError = "There was some truble adding your game." - + "\nOne of the needed values was empty, please try again to add your game."; - JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350, 170, main.getPane()); - errorDialog.show(); + JFXInfoDialog errorDialog = new JFXInfoDialog(addBtnReturnErrorHeadingText, addBtnReturnErrorBodyText, + dialogBtnStyle, 350, 170, main.getPane()); + errorDialog.show(); } else { File pictureCache; @@ -1279,16 +1245,16 @@ public class MainWindowController { } else { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - int today = Integer.parseInt(dtf.format(LocalDate.now()).replaceAll("-", "")); - int yesterday = Integer.parseInt(dtf.format(LocalDate.now().minusDays(1)).replaceAll("-", "")); - int lastPlayedDay = Integer.parseInt(dbController.getLastPlayed(titleID).replaceAll("-", "")); + int tToday = Integer.parseInt(dtf.format(LocalDate.now()).replaceAll("-", "")); + int tYesterday = Integer.parseInt(dtf.format(LocalDate.now().minusDays(1)).replaceAll("-", "")); + int tLastPlayedDay = Integer.parseInt(dbController.getLastPlayed(titleID).replaceAll("-", "")); - if (lastPlayedDay == today) { - lastTimePlayedBtn.setText("Last played, today"); - } else if (lastPlayedDay == yesterday) { - lastTimePlayedBtn.setText("Last played, yesterday"); + if (tLastPlayedDay == tToday) { + lastTimePlayedBtn.setText(lastPlayed + today); + } else if (tLastPlayedDay == tYesterday) { + lastTimePlayedBtn.setText(lastPlayed + yesterday); } else { - lastTimePlayedBtn.setText("Last played, " + dbController.getLastPlayed(titleID)); + lastTimePlayedBtn.setText(lastPlayed + dbController.getLastPlayed(titleID)); } } @@ -1351,7 +1317,6 @@ public class MainWindowController { } } - // TODO add strings for dialogs void setUILanguage(){ switch(getLanguage()){ case "en_US": @@ -1414,17 +1379,19 @@ public class MainWindowController { cloudSyncWaringBodyText = bundle.getString("cloudSyncWaringBodyText"); cloudSyncErrorHeadingText = bundle.getString("cloudSyncErrorHeadingText"); cloudSyncErrorBodyText = bundle.getString("cloudSyncErrorBodyText"); + addGameBtnHeadingText = bundle.getString("addGameBtnHeadingText"); + addGameBtnBodyText = bundle.getString("addGameBtnBodyText"); addBtnReturnErrorHeadingText = bundle.getString("addBtnReturnErrorHeadingText"); addBtnReturnErrorBodyText = bundle.getString("addBtnReturnErrorBodyText"); + lastPlayed = bundle.getString("lastPlayed"); + today = bundle.getString("today"); + yesterday = bundle.getString("yesterday"); playBtnPlay = bundle.getString("playBtnPlay"); playBtnUpdating = bundle.getString("playBtnUpdating"); playBtnCopyingFiles = bundle.getString("playBtnCopyingFiles"); - okayBtnText = bundle.getString("okayBtnText"); - cancelBtnText = bundle.getString("cancelBtnText"); - updateBtnCheckNow = bundle.getString("updateBtnCheckNow"); - updateBtnNoUpdateAvailable = bundle.getString("updateBtnNoUpdateAvailable"); - updateBtnUpdateAvailable = bundle.getString("updateBtnUpdateAvailable"); + smmdbDownloadBtnLoading = bundle.getString("smmdbDownloadBtnLoading"); + smmdbDownloadBtnDownload = bundle.getString("smmdbDownloadBtnDownload"); } private void checkAutoUpdate() { @@ -1728,12 +1695,12 @@ public class MainWindowController { LOGGER.error("could not load color value, setting default instead", e); setColor("00a8cc"); } - - try { + + if (props.getProperty("language") == null) { + LOGGER.error("cloud not load language, setting default instead"); + setLanguage("en_US"); + } else { setLanguage(props.getProperty("language")); - } catch (Exception e) { - LOGGER.error("cloud not load language", e); - setLanguage(System.getProperty("user.language")+"_"+System.getProperty("user.country")); } try { @@ -2048,6 +2015,14 @@ public class MainWindowController { this.language = language; } + public ResourceBundle getBundle() { + return bundle; + } + + public void setBundle(ResourceBundle bundle) { + this.bundle = bundle; + } + public AnchorPane getMainAnchorPane() { return mainAnchorPane; } diff --git a/src/main/java/com/cemu_UI/application/playGame.java b/src/main/java/com/cemu_UI/application/playGame.java index 3539212..b6afd6b 100644 --- a/src/main/java/com/cemu_UI/application/playGame.java +++ b/src/main/java/com/cemu_UI/application/playGame.java @@ -90,7 +90,6 @@ public class playGame extends Thread{ mainWindowController.main.getPrimaryStage().setIconified(false); // maximize cemu_UI }); -// System.out.println(mainWindowController.getCemuPath()+"/mlc01/emulatorSave/"+); //sync savegame with cloud service if (mainWindowController.isCloudSync()) { mainWindowController.setLastLocalSync(Instant.now().getEpochSecond()); diff --git a/src/main/java/com/cemu_UI/controller/UpdateController.java b/src/main/java/com/cemu_UI/controller/UpdateController.java index 6b7d820..33c1abc 100644 --- a/src/main/java/com/cemu_UI/controller/UpdateController.java +++ b/src/main/java/com/cemu_UI/controller/UpdateController.java @@ -52,6 +52,7 @@ public class UpdateController implements Runnable { private String browserDownloadUrl; // update download link private String githubApiRelease = "https://api.github.com/repos/Seil0/cemu_UI/releases/latest"; private String githubApiBeta = "https://api.github.com/repos/Seil0/cemu_UI/releases"; + private URL githubApiUrl; private boolean useBeta; private static final Logger LOGGER = LogManager.getLogger(UpdateController.class.getName()); @@ -70,7 +71,7 @@ public class UpdateController implements Runnable { public void run() { LOGGER.info("beta:" + useBeta + "; checking for updates ..."); Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText("checking for updates ..."); + mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnChecking")); }); try { @@ -126,12 +127,12 @@ public class UpdateController implements Runnable { if (iversion >= iaktVersion) { Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText("no update available"); + mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnNoUpdateAvailable")); }); LOGGER.info("no update available"); } else { Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText("update available"); + mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnUpdateAvailable")); }); LOGGER.info("update available"); LOGGER.info("download link: " + browserDownloadUrl); diff --git a/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java index e00d168..c5cdb67 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXEditGameDialog.java @@ -90,13 +90,13 @@ public class JFXEditGameDialog { JFXDialog dialog = new JFXDialog(stackPane, content, JFXDialog.DialogTransition.LEFT, true); TextField gameTitleTF = new TextField(); - gameTitleTF.setPromptText("game tile"); + gameTitleTF.setPromptText(mwc.getBundle().getString("gameTitle")); TextField gameTitleIDTF = new TextField(); - gameTitleIDTF.setPromptText("title ID"); + gameTitleIDTF.setPromptText(mwc.getBundle().getString("titleID")); TextField romPathTF = new TextField(); - romPathTF.setPromptText("ROM path"); + romPathTF.setPromptText(mwc.getBundle().getString("romPath")); TextField gameCoverTF = new TextField(); - gameCoverTF.setPromptText("cover path"); + gameCoverTF.setPromptText(mwc.getBundle().getString("coverPath")); if (mode == 1) { gameTitleTF.setText(title); @@ -107,7 +107,7 @@ public class JFXEditGameDialog { gameTitleIDTF.setEditable(false); } - JFXButton okayBtn = new JFXButton("Okay"); + JFXButton okayBtn = new JFXButton(mwc.getBundle().getString("okayBtnText")); okayBtn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { @@ -117,9 +117,8 @@ public class JFXEditGameDialog { // LOGGER.info("No parameter set!"); // addGame error dialog - String headingTextError = "Error while adding a new Game!"; - String bodyTextError = "There was some truble adding your game." - + "\nOne of the needed values was empty, please try again to add your game."; + String headingTextError = mwc.getBundle().getString("editGameDialogHeadingTextError"); + String bodyTextError = mwc.getBundle().getString("editGameDialogBodyTextError"); JFXInfoDialog errorDialog = new JFXInfoDialog(headingTextError, bodyTextError, dialogBtnStyle, 350,170, pane); errorDialog.show(); } else { @@ -147,7 +146,7 @@ public class JFXEditGameDialog { okayBtn.setPrefHeight(32); okayBtn.setStyle(dialogBtnStyle); - JFXButton cancelBtn = new JFXButton("Cancel"); + JFXButton cancelBtn = new JFXButton(mwc.getBundle().getString("cancelBtnText")); cancelBtn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { @@ -158,7 +157,7 @@ public class JFXEditGameDialog { cancelBtn.setPrefHeight(32); cancelBtn.setStyle(dialogBtnStyle); - JFXButton selectPathBtn = new JFXButton("select .rpx file"); + JFXButton selectPathBtn = new JFXButton(mwc.getBundle().getString("editGameDialogSelectPathBtn")); selectPathBtn.setPrefWidth(110); selectPathBtn.setStyle(dialogBtnStyle); selectPathBtn.setOnAction(new EventHandler() { @@ -170,7 +169,7 @@ public class JFXEditGameDialog { } }); - JFXButton selectCoverBtn = new JFXButton("select cover file"); + JFXButton selectCoverBtn = new JFXButton(mwc.getBundle().getString("editGameDialogSelectCoverBtn")); selectCoverBtn.setPrefWidth(110); selectCoverBtn.setStyle(dialogBtnStyle); selectCoverBtn.setOnAction(new EventHandler() { @@ -186,14 +185,14 @@ public class JFXEditGameDialog { grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(15, 10, 10, 10)); - grid.add(new Label("game title:"), 0, 0); + grid.add(new Label(mwc.getBundle().getString("gameTitle") + ":"), 0, 0); grid.add(gameTitleTF, 1, 0); - grid.add(new Label("title id:"), 0, 1); + grid.add(new Label(mwc.getBundle().getString("titleID") + ":"), 0, 1); grid.add(gameTitleIDTF, 1, 1); - grid.add(new Label("ROM path:"), 0, 2); + grid.add(new Label(mwc.getBundle().getString("romPath") + ":"), 0, 2); grid.add(romPathTF, 1, 2); grid.add(selectPathBtn, 2, 2); - grid.add(new Label("cover path:"), 0, 3); + grid.add(new Label(mwc.getBundle().getString("coverPath") + ":"), 0, 3); grid.add(gameCoverTF, 1, 3); grid.add(selectCoverBtn, 2, 3); diff --git a/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java index fa02760..6e35a75 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java @@ -22,6 +22,8 @@ package com.cemu_UI.uiElements; +import java.util.ResourceBundle; + import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXDialog; import com.jfoenix.controls.JFXDialogLayout; @@ -38,13 +40,14 @@ public class JFXOkayCancelDialog { private String headingText; private String bodyText; private String dialogBtnStyle; - private String okayText = "okay"; - private String cancelText = "cancel"; + private String okayText; + private String cancelText; private int dialogWidth; private int dialogHeight; private EventHandler okayAction; private EventHandler cancelAction; private Pane pane; + private ResourceBundle bundle; /** * Creates a new JFoenix Dialog to show some information with okay and cancel option @@ -58,7 +61,8 @@ public class JFXOkayCancelDialog { * @param pane pane to which the dialog belongs */ public JFXOkayCancelDialog(String headingText, String bodyText, String dialogBtnStyle, int dialogWidth, - int dialogHeight, EventHandler okayAction, EventHandler cancelAction, Pane pane) { + int dialogHeight, EventHandler okayAction, EventHandler cancelAction, Pane pane, + ResourceBundle bundle) { this.headingText = headingText; this.bodyText = bodyText; this.dialogBtnStyle = dialogBtnStyle; @@ -67,9 +71,13 @@ public class JFXOkayCancelDialog { this.okayAction = okayAction; this.cancelAction = cancelAction; this.pane = pane; + this.bundle = bundle; } public void show() { + okayText = bundle.getString("okayBtnText"); + cancelText = bundle.getString("cancelBtnText"); + JFXDialogLayout content = new JFXDialogLayout(); content.setHeading(new Text(headingText)); content.setBody(new Text(bodyText)); diff --git a/src/main/resources/locals/cemu_UI-Local_en_US.properties b/src/main/resources/locals/cemu_UI-Local_en_US.properties index 6780842..f965f2b 100644 --- a/src/main/resources/locals/cemu_UI-Local_en_US.properties +++ b/src/main/resources/locals/cemu_UI-Local_en_US.properties @@ -12,15 +12,15 @@ smmdbDownloadBtn = playBtn = # Labels -cemu_UISettingsLbl = cemu_UI settings +cemu_UISettingsLbl = cemu_UI Settings cemuDirectoryLbl = cemu directory romDirectoryLbl = ROM directory mainColorLbl = main color languageLbl = language updateLbl = updates branchLbl = branch -cemuSettingsLbl = cemu settings -licensesLbl = licenses +cemuSettingsLbl = cemu Settings +licensesLbl = Licenses # Columns titleColumn = title @@ -33,26 +33,50 @@ editHeadingText = edit editBodyText = You can edit the tile and rom/cover path. removeHeadingText = remove removeBodyText = Are you sure you want to delete -addUpdateHeadingText = -addUpdateBodyText = -addDLCHeadingText = -addDLCBodyText = -licensesLblHeadingText = -licensesLblBodyText = -aboutBtnHeadingText = -aboutBtnBodyText = -cloudSyncWaringHeadingText = -cloudSyncWaringBodyText = -cloudSyncErrorHeadingText = -cloudSyncErrorBodyText = -addBtnReturnErrorHeadingText = -addBtnReturnErrorBodyText = +addUpdateHeadingText = update +addUpdateBodyText = Please select the update root directory. +addDLCHeadingText = add a DLC to +addDLCBodyText = Please select the DLC root directory. -playBtnPlay = -playBtnUpdating = -playBtnCopyingFiles = -okayBtnText = -cancelBtnText = +licensesLblHeadingText = cemu_UI +licensesLblBodyText = cemu_UI is licensed under the terms of GNU GPL 3.\n\nJFoenix, Apache License 2.0\nminimal-json, MIT License\nsqlite-jdbc, Apache License 2.0\nApache Commons IO, Apache License 2.0\nApache Commons Logging, Apache License 2.0\nApache Commons Codec, Apache License 2.0\nApache Log4j 2, Apache License 2.0\n + +aboutBtnHeadingText = cemu_UI +aboutBtnBodyText = This Application is made with free Software\nand licensed under the terms of GNU GPL 3.\n\nwww.kellerkinder.xyz + +cloudSyncWaringHeadingText = activate cloud savegame sync (beta) +cloudSyncWaringBodyText = WARNING this is a completly WIP cloud save integration,\nit's NOT recomended to use this!!\n\nUse it on your own risk and backup everthing before! + +cloudSyncErrorHeadingText = Error while initializing cloud sync! +cloudSyncErrorBodyText = There was some truble adding your game.\nPlease upload the app.log (which can be found in the cemu_UI directory)\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this. + +addGameBtnHeadingText = add a new game to cemu_UI +addGameBtnBodyText = +addBtnReturnErrorHeadingText = Error while adding a new Game! +addBtnReturnErrorBodyText = There was some truble adding your game.\nOne of the needed values was empty, please try again to add your game. +lastPlayed = Last played, +today = today +yesterday = yesterday + +# button strings +playBtnPlay = play +playBtnUpdating = updating... +playBtnCopyingFiles = copying files... +smmdbDownloadBtnLoading = loading +smmdbDownloadBtnDownload = Download +okayBtnText = okay +cancelBtnText = cancel updateBtnCheckNow = check now! +updateBtnChecking = checking for updates ... updateBtnNoUpdateAvailable = no update available updateBtnUpdateAvailable = update available + +#EditGameDialog +gameTitle = game title +titleID = title ID +romPath = ROM path +coverPath = cover path +editGameDialogHeadingTextError = Error while adding a new Game! +editGameDialogBodyTextError = There was some truble adding your game.\nOne of the needed values was empty, please try again to add your game. +editGameDialogSelectPathBtn = select .rpx file +editGameDialogSelectCoverBtn = select cover file From c73d02c4333734d929698a7bffbe5f25b9870240 Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 19 Dec 2017 22:18:22 +0100 Subject: [PATCH 11/15] added german local --- log.txt | 8 + .../application/MainWindowController.java | 12 +- .../uiElements/JFXOkayCancelDialog.java | 6 +- src/main/resources/fxml/MainWindow.fxml | 4 +- .../locals/cemu_UI-Local_de_DE.properties | 137 ++++++++++-------- .../locals/cemu_UI-Local_en_US.properties | 12 +- 6 files changed, 109 insertions(+), 70 deletions(-) create mode 100644 log.txt diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..8755ceb --- /dev/null +++ b/log.txt @@ -0,0 +1,8 @@ +[21:08:03] mlc01 path is set to: Z:\home\jannik\Downloads\cemu_1.10.0\mlc01\ +[21:08:03] Using AES-NI for filesystem decryption +[21:08:06] RDTSC measurement test: +[21:08:06] TSC-diff: 0x0000000274783686 +[21:08:06] TSC-freq: 0x00000000d0dadcff +[21:08:06] HPC-diff: 0x0000000001cb27c1 +[21:08:06] HPC-freq: 0x0000000000989680 +[21:08:06] Multiplier: 0x000000000000015e diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 60fb0ce..69017a6 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -287,7 +287,7 @@ public class MainWindowController { private String selectedGameTitle; private String id; private String version = "0.2.2"; - private String buildNumber = "069"; + private String buildNumber = "071"; private String versionName = "Puzzle Plank Galaxy"; private int xPos = -200; private int yPos = 17; @@ -349,6 +349,7 @@ public class MainWindowController { private String addDLCBodyText; private String licensesLblHeadingText; private String licensesLblBodyText; + private String showLicenses; private String aboutBtnHeadingText; private String aboutBtnBodyText; private String cloudSyncWaringHeadingText; @@ -362,6 +363,7 @@ public class MainWindowController { private String lastPlayed; private String today; private String yesterday; + private String never; private String playBtnPlay; private String playBtnUpdating; @@ -793,7 +795,7 @@ public class MainWindowController { JFXOkayCancelDialog licenseOverviewDialog = new JFXOkayCancelDialog(licensesLblHeadingText, licensesLblBodyText, dialogBtnStyle, 350, 275, okayAction, cancelAction, main.getPane(), bundle); - licenseOverviewDialog.setCancelText("show licenses"); + licenseOverviewDialog.setCancelText(showLicenses); licenseOverviewDialog.show(); } } @@ -1240,7 +1242,7 @@ public class MainWindowController { // setting last played, if lastPlayed is empty game was never played before, else set correct date if (dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)) { - lastTimePlayedBtn.setText("Last played, never"); + lastTimePlayedBtn.setText(lastPlayed + never); totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID) + " min"); } else { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @@ -1344,6 +1346,8 @@ public class MainWindowController { updateBtn.setText(bundle.getString("updateBtnCheckNow")); smmdbDownloadBtn.setText(bundle.getString("smmdbDownloadBtn")); playBtn.setText(bundle.getString("playBtn")); + cloudSyncToggleBtn.setText(bundle.getString("cloudSyncToggleBtn")); + autoUpdateToggleBtn.setText(bundle.getString("autoUpdateToggleBtn")); // Labels cemu_UISettingsLbl.setText(bundle.getString("cemu_UISettingsLbl")); @@ -1373,6 +1377,7 @@ public class MainWindowController { addDLCBodyText = bundle.getString("addDLCBodyText"); licensesLblHeadingText = bundle.getString("licensesLblHeadingText"); licensesLblBodyText = bundle.getString("licensesLblBodyText"); + showLicenses = bundle.getString("showLicenses"); aboutBtnHeadingText = bundle.getString("aboutBtnHeadingText"); aboutBtnBodyText = bundle.getString("aboutBtnBodyText"); cloudSyncWaringHeadingText = bundle.getString("cloudSyncWaringHeadingText"); @@ -1386,6 +1391,7 @@ public class MainWindowController { lastPlayed = bundle.getString("lastPlayed"); today = bundle.getString("today"); yesterday = bundle.getString("yesterday"); + never = bundle.getString("never"); playBtnPlay = bundle.getString("playBtnPlay"); playBtnUpdating = bundle.getString("playBtnUpdating"); diff --git a/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java b/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java index 6e35a75..5dd4d1a 100644 --- a/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java +++ b/src/main/java/com/cemu_UI/uiElements/JFXOkayCancelDialog.java @@ -47,7 +47,6 @@ public class JFXOkayCancelDialog { private EventHandler okayAction; private EventHandler cancelAction; private Pane pane; - private ResourceBundle bundle; /** * Creates a new JFoenix Dialog to show some information with okay and cancel option @@ -71,12 +70,11 @@ public class JFXOkayCancelDialog { this.okayAction = okayAction; this.cancelAction = cancelAction; this.pane = pane; - this.bundle = bundle; + okayText = bundle.getString("okayBtnText"); + cancelText = bundle.getString("cancelBtnText"); } public void show() { - okayText = bundle.getString("okayBtnText"); - cancelText = bundle.getString("cancelBtnText"); JFXDialogLayout content = new JFXDialogLayout(); content.setHeading(new Text(headingText)); diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index 5502ba9..d67e830 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -213,14 +213,14 @@ - + - + diff --git a/src/main/resources/locals/cemu_UI-Local_de_DE.properties b/src/main/resources/locals/cemu_UI-Local_de_DE.properties index aa9c214..e6d4b4b 100644 --- a/src/main/resources/locals/cemu_UI-Local_de_DE.properties +++ b/src/main/resources/locals/cemu_UI-Local_de_DE.properties @@ -1,63 +1,86 @@ -#HomeFlix-Local_de_DE.properties German Local +#HomeFlix-Local_de_DE.properties geramn Local -#main window translations -info = Info -settings = Einstellungen -streamingSettings = Stream Einst. -tfSearch = Suche... -openFolder = Ordner \u00F6ffnen +# Buttons +aboutBtn = \u00dcber +settingsBtn = Einstellungen +addBtn = Spiel hinzuf\u00fcgen +reloadRomsBtn = ROMs neu laden +smmdbBtn = smmdb +cemuTFBtn = Ordner \u00F6ffnen +romTFBtn = Ordner \u00F6ffnen +smmdbDownloadBtn = Download +playBtn = spielen +cloudSyncToggleBtn = Spielst\u00e4nde \u00fcber die Cloud syncronisieren (Google Drive) +autoUpdateToggleBtn = beim Start nach Updates suchen -#settings translations -settingsHead1Label = HomeFlix Einstellungen -tfPath = Pfad... -chooseFolder = Ordner ausw\u00E4hlen -mainColorLabel = Hauptfarbe: -fontsizeLabel = Schriftgr\u00F6\u00DFe: -localLabel = Sprache: -checkUpdates = Auf Update pr\u00FCfen -checkingUpdates = Es wird nach Updates gesucht... -updateBtnavail = Update verf\u00FCgbar -updateBtnNotavail = Kein Update verf\u00FCgbar -autoUpdateLabel = beim Start nach Updates suchen: -version = Version: +# Labels +cemu_UISettingsLbl = cemu_UI Einstellungen +cemuDirectoryLbl = cemu directory +romDirectoryLbl = ROM directory +mainColorLbl = Hauptfarbe +languageLbl = Sprache +updateLbl = updates +branchLbl = Updatezweig +cemuSettingsLbl = cemu Einstellungen +licensesLbl = Lizenzen -#column translations -columnName = Name -columnRating = Bewertung -columnStreamUrl = Datei Name -columnResolution = Aufl\u00F6sung -columnSeason = Staffel -columnYear = Jahr +# Columns +titleColumn = Titel +idColumn = ID +starsColumn = Sterne +timeColumn = Zeit -#error translations -errorUpdateV = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not check update version (nvc)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz -errorUpdateD = Beim ausf\u00FChren des Updates ist ein Fehler aufgetreten! \nError: could not download update files (ndf)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz -errorPlay = Beim \u00F6ffnen der Datei ist ein Fehler aufgetreten! \nError: could not open file (nof) \nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz -errorMode = Oh, da lief etwas falsch! Da hat jemand einen falschen Modus verwendet. \nError: mode unknow (muk)\nWeitere Hilfe erhalten sie unter www.kellerkinder.xyz \noder wenden sie sich an support@kellerkinder.xyz -errorOpenStream = Beim \u00F6ffnen des Streams ist ein Fehler aufgetreten! -errorLoad = Beim laden der Einstellungen ist ein Fehler aufgetreten! -errorSave = Beim speichern der Einstellungen ist ein Fehler aufgetreten! -noFilmFound = Kein Film mit diesem Titel gefunden! -vlcNotInstalled = Um einen Film abspielen wird der VLC Media Player ben\u00F6tigt! -infoText = \nMaintainer: seilo@kellerkinder.xyz und \nhendrik.schutter@coptersicht.de \n(c) 2016-2017 Kellerkinder www.kellerkinder.xyz +# Strings +editHeadingText = bearbeiten +editBodyText = Du kannst den Title und den ROM-/Coverpfad bearbeiten. +removeHeadingText = löschen +removeBodyText = Bist du sicher dass du flgendes Spiel l\u00f6schen m\u00f6chtest +addUpdateHeadingText = update +addUpdateBodyText = Bitte w\u00e4hle das Update-Verzeichniss aus. +addDLCHeadingText = ein DLC hinzufügen +addDLCBodyText = Bitte w\u00e4hle das DLC-Verzeichniss aus. -#textFlow translations -title = Titel -year = Jahr -rating = Einstufung -publishedOn = Ver\u00F6ffentlicht am -duration = Laufzeit -genre = Gener -director = Regisseur -writer = Autor -actors = Schauspieler -plot = Beschreibung -language = Original Sprache -country = Produktionsland -awards = Auszeichnungen -metascore = Metascore -imdbRating = IMDB-Bewertung -type = Type +licensesLblHeadingText = cemu_UI +licensesLblBodyText = cemu_UI ist lizensiert unter der GNU GPL 3.\n\nJFoenix, Apache License 2.0\nminimal-json, MIT License\nsqlite-jdbc, Apache License 2.0\nApache Commons IO, Apache License 2.0\nApache Commons Logging, Apache License 2.0\nApache Commons Codec, Apache License 2.0\nApache Log4j 2, Apache License 2.0\n +showLicenses = Lizenzen \u00f6ffnen -firstStartHeader = Es ist kein Stammverzeichnis f\u00FCr Filme angegeben! -firstStartContent = Stammverzeichniss angeben? +aboutBtnHeadingText = cemu_UI +aboutBtnBodyText = Diese Programm wurde mit freier Software erstellt\nund ist lizensiert unter der GNU GPL 3.\n\nwww.kellerkinder.xyz + +cloudSyncWaringHeadingText = Spielst\u00e4nde über die Cloud syncronisieren (beta) +cloudSyncWaringBodyText = WARNING this is a completly WIP cloud save integration,\nit's NOT recomended to use this!!\n\nUse it on your own risk and backup everthing before! + +cloudSyncErrorHeadingText = Fehler beim initialisieren der Cloud-Verbindung! +cloudSyncErrorBodyText = Fehler beim initialisieren der Cloud-Verbindung.\nBitte lade die app.log (welceh du im cemu_UI Verzeichniss findest)\nauf \"https://github.com/Seil0/cemu_UI/issues\" hoch. + +addGameBtnHeadingText = eine neues Spiel zu cemu_Ui hinzuf\u00fcgen +addGameBtnBodyText = +addBtnReturnErrorHeadingText = Fehler beim hinzuf\u00fcgen des Spiels! +addBtnReturnErrorBodyText = Fehler beim hinzuf\u00fcgen des Spiels.\nEiner der benötigten Werte war leer, bitte versuche es erneut. +lastPlayed = zuletzt gespielt, +today = heute +yesterday = gestern +never = nie + +# button strings +playBtnPlay = spieles +playBtnUpdating = updating... +playBtnCopyingFiles = kopiere Dateien... +smmdbDownloadBtnLoading = laden +smmdbDownloadBtnDownload = Download +okayBtnText = okay +cancelBtnText = abbruch +updateBtnCheckNow = Auf Update pr\u00FCfen +updateBtnChecking = Es wird nach Updates gesucht... +updateBtnNoUpdateAvailable = Kein Update verf\u00FCgbar +updateBtnUpdateAvailable = Update verf\u00FCgbar + +#EditGameDialog +gameTitle = Spiel Titel +titleID = Titel ID +romPath = ROM Pfad +coverPath = Cover-Pfad +editGameDialogHeadingTextError = Fehler beim hinzuf\u00fcgen des Spiels! +editGameDialogBodyTextError = Fehler beim hinzuf\u00fcgen des Spiels.\nEiner der benötigten Werte war leer, bitte versuche es erneut. +editGameDialogSelectPathBtn = .rpx Datei ausw\u00E4hlen +editGameDialogSelectCoverBtn = cover Datei ausw\u00E4hlen diff --git a/src/main/resources/locals/cemu_UI-Local_en_US.properties b/src/main/resources/locals/cemu_UI-Local_en_US.properties index f965f2b..960bf3f 100644 --- a/src/main/resources/locals/cemu_UI-Local_en_US.properties +++ b/src/main/resources/locals/cemu_UI-Local_en_US.properties @@ -5,11 +5,13 @@ aboutBtn = About settingsBtn = Setting addBtn = Add new Game reloadRomsBtn = reload ROMs -smmdbBtn = ammdb +smmdbBtn = smmdb cemuTFBtn = choose directory romTFBtn = choose directory -smmdbDownloadBtn = -playBtn = +smmdbDownloadBtn = Download +playBtn = play +cloudSyncToggleBtn = cloud savegames (Google Drive) +autoUpdateToggleBtn = check for updates on startup # Labels cemu_UISettingsLbl = cemu_UI Settings @@ -40,6 +42,7 @@ addDLCBodyText = Please select the DLC root directory. licensesLblHeadingText = cemu_UI licensesLblBodyText = cemu_UI is licensed under the terms of GNU GPL 3.\n\nJFoenix, Apache License 2.0\nminimal-json, MIT License\nsqlite-jdbc, Apache License 2.0\nApache Commons IO, Apache License 2.0\nApache Commons Logging, Apache License 2.0\nApache Commons Codec, Apache License 2.0\nApache Log4j 2, Apache License 2.0\n +showLicenses = show licenses aboutBtnHeadingText = cemu_UI aboutBtnBodyText = This Application is made with free Software\nand licensed under the terms of GNU GPL 3.\n\nwww.kellerkinder.xyz @@ -48,7 +51,7 @@ cloudSyncWaringHeadingText = activate cloud savegame sync (beta) cloudSyncWaringBodyText = WARNING this is a completly WIP cloud save integration,\nit's NOT recomended to use this!!\n\nUse it on your own risk and backup everthing before! cloudSyncErrorHeadingText = Error while initializing cloud sync! -cloudSyncErrorBodyText = There was some truble adding your game.\nPlease upload the app.log (which can be found in the cemu_UI directory)\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this. +cloudSyncErrorBodyText = There was some truble while initializing cloud sync.\nPlease upload the app.log (which can be found in the cemu_UI directory)\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this. addGameBtnHeadingText = add a new game to cemu_UI addGameBtnBodyText = @@ -57,6 +60,7 @@ addBtnReturnErrorBodyText = There was some truble adding your game.\nOne of the lastPlayed = Last played, today = today yesterday = yesterday +never = never # button strings playBtnPlay = play From 8c5d511dfbdef8784b708dece57773c98527243b Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 19 Dec 2017 22:18:58 +0100 Subject: [PATCH 12/15] removed log.txt --- log.txt | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 log.txt diff --git a/log.txt b/log.txt deleted file mode 100644 index 8755ceb..0000000 --- a/log.txt +++ /dev/null @@ -1,8 +0,0 @@ -[21:08:03] mlc01 path is set to: Z:\home\jannik\Downloads\cemu_1.10.0\mlc01\ -[21:08:03] Using AES-NI for filesystem decryption -[21:08:06] RDTSC measurement test: -[21:08:06] TSC-diff: 0x0000000274783686 -[21:08:06] TSC-freq: 0x00000000d0dadcff -[21:08:06] HPC-diff: 0x0000000001cb27c1 -[21:08:06] HPC-freq: 0x0000000000989680 -[21:08:06] Multiplier: 0x000000000000015e From a020992cc2061c85ccc5ef0c6c4e0acddaf96b84 Mon Sep 17 00:00:00 2001 From: Jannik Date: Thu, 21 Dec 2017 11:02:54 +0100 Subject: [PATCH 13/15] release 0.3.2 build 071 * added missing translation --- src/main/java/com/cemu_UI/application/Main.java | 2 +- .../com/cemu_UI/application/MainWindowController.java | 3 ++- .../java/com/cemu_UI/controller/UpdateController.java | 10 ++++++---- .../resources/locals/cemu_UI-Local_de_DE.properties | 1 + .../resources/locals/cemu_UI-Local_en_US.properties | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 94bf57c..905fd98 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -96,7 +96,7 @@ public class Main extends Application { primaryStage.setTitle("cemu_UI"); // primaryStage.getIcons().add(new Image(Main.class.getResourceAsStream("/resources/Homeflix_Icon_64x64.png"))); //adds application icon - mainWindowController = loader.getController(); // Link of FXMLController and controller class + mainWindowController = loader.getController(); // Link of FXMLController and controller class mainWindowController.setMain(this); // call setMain cloudController = new CloudController(mainWindowController); // call cloudController constructor diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 69017a6..157fde2 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -286,7 +286,7 @@ public class MainWindowController { private String selectedGameTitleID; private String selectedGameTitle; private String id; - private String version = "0.2.2"; + private String version = "0.2.3"; private String buildNumber = "071"; private String versionName = "Puzzle Plank Galaxy"; private int xPos = -200; @@ -1348,6 +1348,7 @@ public class MainWindowController { playBtn.setText(bundle.getString("playBtn")); cloudSyncToggleBtn.setText(bundle.getString("cloudSyncToggleBtn")); autoUpdateToggleBtn.setText(bundle.getString("autoUpdateToggleBtn")); + fullscreenToggleBtn.setText(bundle.getString("fullscreenToggleBtn")); // Labels cemu_UISettingsLbl.setText(bundle.getString("cemu_UISettingsLbl")); diff --git a/src/main/java/com/cemu_UI/controller/UpdateController.java b/src/main/java/com/cemu_UI/controller/UpdateController.java index 33c1abc..c5a81d3 100644 --- a/src/main/java/com/cemu_UI/controller/UpdateController.java +++ b/src/main/java/com/cemu_UI/controller/UpdateController.java @@ -49,6 +49,8 @@ public class UpdateController implements Runnable { private String buildNumber; private String apiOutput; private String updateBuildNumber; // tag_name from Github +// private String updateName; +// private String updateChanges; private String browserDownloadUrl; // update download link private String githubApiRelease = "https://api.github.com/repos/Seil0/cemu_UI/releases/latest"; private String githubApiBeta = "https://api.github.com/repos/Seil0/cemu_UI/releases"; @@ -98,8 +100,8 @@ public class UpdateController implements Runnable { JsonArray objectAssets = object.asObject().get("assets").asArray(); updateBuildNumber = object.asObject().getString("tag_name", ""); - // updateName = object.asObject().getString("name", ""); - // updateChanges = object.asObject().getString("body", ""); +// updateName = object.asObject().getString("name", ""); +// updateChanges = object.asObject().getString("body", ""); for (JsonValue asset : objectAssets) { browserDownloadUrl = asset.asObject().getString("browser_download_url", ""); @@ -110,8 +112,8 @@ public class UpdateController implements Runnable { JsonArray objectAssets = Json.parse(apiOutput).asObject().get("assets").asArray(); updateBuildNumber = object.getString("tag_name", ""); - // updateName = object.getString("name", ""); - // updateChanges = object.getString("body", ""); +// updateName = object.getString("name", ""); +// updateChanges = object.getString("body", ""); for (JsonValue asset : objectAssets) { browserDownloadUrl = asset.asObject().getString("browser_download_url", ""); diff --git a/src/main/resources/locals/cemu_UI-Local_de_DE.properties b/src/main/resources/locals/cemu_UI-Local_de_DE.properties index e6d4b4b..598d579 100644 --- a/src/main/resources/locals/cemu_UI-Local_de_DE.properties +++ b/src/main/resources/locals/cemu_UI-Local_de_DE.properties @@ -12,6 +12,7 @@ smmdbDownloadBtn = Download playBtn = spielen cloudSyncToggleBtn = Spielst\u00e4nde \u00fcber die Cloud syncronisieren (Google Drive) autoUpdateToggleBtn = beim Start nach Updates suchen +fullscreenToggleBtn = Spiel im Vollbildmodus starten # Labels cemu_UISettingsLbl = cemu_UI Einstellungen diff --git a/src/main/resources/locals/cemu_UI-Local_en_US.properties b/src/main/resources/locals/cemu_UI-Local_en_US.properties index 960bf3f..f93fce9 100644 --- a/src/main/resources/locals/cemu_UI-Local_en_US.properties +++ b/src/main/resources/locals/cemu_UI-Local_en_US.properties @@ -12,6 +12,7 @@ smmdbDownloadBtn = Download playBtn = play cloudSyncToggleBtn = cloud savegames (Google Drive) autoUpdateToggleBtn = check for updates on startup +fullscreenToggleBtn = start game in fullscreen # Labels cemu_UISettingsLbl = cemu_UI Settings From de2c8d76eabbfdc3545ae5a48ac624272b6e54e8 Mon Sep 17 00:00:00 2001 From: Jannik Date: Thu, 21 Dec 2017 17:33:54 +0100 Subject: [PATCH 14/15] Update CONTRIBUTING.md --- CONTRIBUTING.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ebaf582..d455b01 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,13 @@ # Contributing to cemu_UI The following is a set of guidelines for contributing to cemu_UI. -## Java Sytleguide +## Translating +If you don't want to contibute any code you can support this project by translating it! The translation files are stored in "src/main/resources/locals". + +# Contributing code +If you want to contibute code please read the java code styleguide. + +## Java code sytleguide If your willing to contribute to cemu_UI please us the following example as guide and rules to design your code. * Use names for methods and variables that clarify their purpose. (This will help a lot to understand the code) * Use as many spaces as necessary to make the code clear, but as little as possible. From d3acf387d95cd998ef169e49effa055445f69bab Mon Sep 17 00:00:00 2001 From: Jannik Date: Tue, 26 Dec 2017 17:33:14 +0100 Subject: [PATCH 15/15] code clean up --- pom.xml | 2 +- src/main/java/com/cemu_UI/application/Main.java | 3 --- .../com/cemu_UI/application/MainWindowController.java | 4 ++-- .../java/com/cemu_UI/controller/CloudController.java | 4 +--- .../java/com/cemu_UI/controller/UpdateController.java | 11 +++++------ 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 3a37a6d..c52bdad 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com cemu_UI - 0.2.2-SNAPSHOT + 0.2.3-SNAPSHOT jar cemu_UI diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index 905fd98..652b049 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -168,9 +168,6 @@ public class Main extends Application { } } - - - // loading settings and initialize UI, dbController.main() loads all databases mainWindowController.init(); mainWindowController.dbController.init(); diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 157fde2..55fb730 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -559,7 +559,7 @@ public class MainWindowController { LOGGER.info("copying the content of " + updatePath + " to " + destDir.toString()); playBtn.setText(playBtnUpdating); playBtn.setDisable(true); - FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator + FileUtils.copyDirectory(srcDir, destDir); playBtn.setText(playBtnPlay); playBtn.setDisable(false); LOGGER.info("copying files done!"); @@ -610,7 +610,7 @@ public class MainWindowController { LOGGER.info("copying the content of " + dlcPath + " to " + destDir.toString()); playBtn.setText(playBtnCopyingFiles); playBtn.setDisable(true); - FileUtils.copyDirectory(srcDir, destDir); // TODO progress indicator + FileUtils.copyDirectory(srcDir, destDir); playBtn.setText(playBtnPlay); playBtn.setDisable(false); LOGGER.info("copying files done!"); diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java index 3c37c94..3358eb4 100644 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ b/src/main/java/com/cemu_UI/controller/CloudController.java @@ -143,7 +143,7 @@ public class CloudController { LOGGER.info("synchronization successful!"); } catch (Exception e) { - // TODO: handle exception + LOGGER.error("There was an error during syncronisation! Please open a new issue on the cemu_UI github page:", e); } } }); @@ -173,12 +173,10 @@ public class CloudController { } if (fileToZip.isDirectory()) { -// System.out.println("+" + zipEntryName); for (File file : fileToZip.listFiles()) { addDirToZipArchive(zos, file, zipEntryName); } } else { -// System.out.println(" " + zipEntryName); byte[] buffer = new byte[1024]; FileInputStream fis = new FileInputStream(fileToZip); zos.putNextEntry(new ZipEntry(zipEntryName)); diff --git a/src/main/java/com/cemu_UI/controller/UpdateController.java b/src/main/java/com/cemu_UI/controller/UpdateController.java index c5a81d3..a7d69be 100644 --- a/src/main/java/com/cemu_UI/controller/UpdateController.java +++ b/src/main/java/com/cemu_UI/controller/UpdateController.java @@ -40,7 +40,6 @@ import com.eclipsesource.json.Json; import com.eclipsesource.json.JsonArray; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; - import javafx.application.Platform; public class UpdateController implements Runnable { @@ -140,15 +139,15 @@ public class UpdateController implements Runnable { LOGGER.info("download link: " + browserDownloadUrl); try { // open new Http connection, ProgressMonitorInputStream for downloading the data - HttpURLConnection conn = (HttpURLConnection) new URL(browserDownloadUrl).openConnection(); - ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", conn.getInputStream()); + HttpURLConnection connection = (HttpURLConnection) new URL(browserDownloadUrl).openConnection(); + ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...", connection.getInputStream()); ProgressMonitor pm = pmis.getProgressMonitor(); pm.setMillisToDecideToPopup(0); pm.setMillisToPopup(0); - pm.setMinimum(0);// tell the progress bar that we start at the beginning of the stream - pm.setMaximum(conn.getContentLength());// tell the progress bar the total number of bytes we are going to read. + pm.setMinimum(0);// set beginning of the progress bar to 0 + pm.setMaximum(connection.getContentLength());// set the end to the file length FileUtils.copyInputStreamToFile(pmis, new File("cemu_UI_update.jar")); // download update - org.apache.commons.io.FileUtils.copyFile(new File("cemu_UI_update.jar"), new File("cemu_UI.jar")); // TODO rename update to old name + org.apache.commons.io.FileUtils.copyFile(new File("cemu_UI_update.jar"), new File("cemu_UI.jar")); org.apache.commons.io.FileUtils.deleteQuietly(new File("cemu_UI_update.jar")); // delete update Runtime.getRuntime().exec("java -jar cemu_UI.jar"); // start again System.exit(0); // finishes itself