From 2e3395caea900fcb59a18f4755ff02d93f5c01ee Mon Sep 17 00:00:00 2001 From: Jannik Date: Sun, 4 Feb 2018 15:19:36 +0100 Subject: [PATCH] minor fixes * fixed a few typos * fixed window is resiable to 0x0 * * formating work work --- .../java/com/cemu_UI/application/Main.java | 8 ++-- .../application/MainWindowController.java | 26 ++++++------ .../com/cemu_UI/application/playGame.java | 42 +++++++++---------- .../com/cemu_UI/controller/DBController.java | 10 ++--- src/main/resources/fxml/MainWindow.fxml | 2 +- .../locals/cemu_UI-Local_en_US.properties | 10 ++--- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/cemu_UI/application/Main.java b/src/main/java/com/cemu_UI/application/Main.java index d14f12f..5a21bb2 100644 --- a/src/main/java/com/cemu_UI/application/Main.java +++ b/src/main/java/com/cemu_UI/application/Main.java @@ -180,6 +180,8 @@ public class Main extends Application { scene = new Scene(pane); // create new scene, append pane to scene scene.getStylesheets().add(Main.class.getResource("/css/MainWindows.css").toExternalForm()); + primaryStage.setMinWidth(265.00); + primaryStage.setMinHeight(425.00); primaryStage.setScene(scene); // append scene to stage primaryStage.show(); // show stage } catch (IOException e) { @@ -187,7 +189,7 @@ public class Main extends Application { } } - private void firstStart(){ + private void firstStart() { Alert alert = new Alert(AlertType.CONFIRMATION); // new alert with file-chooser alert.setTitle("cemu_UI"); alert.setHeaderText("cemu installation"); @@ -293,11 +295,11 @@ public class Main extends Application { public static void main(String[] args) { // delete old log file and create new - if(osName.equals("Linux")){ + if (osName.equals("Linux")) { System.setProperty("logFilename", userHome + "/cemu_UI/app.log"); File logFile = new File(userHome + "/cemu_UI/app.log"); logFile.delete(); - }else{ + } else { System.setProperty("logFilename", userHome + "/Documents/cemu_UI/app.log"); File logFile = new File(userHome + "/Documents/cemu_UI/app.log"); logFile.delete(); diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 64c8d6a..aade0e3 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -1064,24 +1064,24 @@ public class MainWindowController { cloudService = "GoogleDrive"; // start cloud sync in new thread - Thread thread = new Thread(new Runnable() { - @Override + Thread thread = new Thread(new Runnable() { + @Override public void run() { - - if (main.getCloudController().initializeConnection(getCloudService(), getCemuPath())) { - main.getCloudController().sync(getCloudService(), getCemuPath(), main.getDirectory().getPath()); - saveSettings(); - } else { - cloudSyncToggleBtn.setSelected(false); - //cloud sync init error dialog + if (main.getCloudController().initializeConnection(getCloudService(), getCemuPath())) { + main.getCloudController().sync(getCloudService(), getCemuPath(), main.getDirectory().getPath()); + saveSettings(); + } else { + cloudSyncToggleBtn.setSelected(false); + + // cloud sync init error dialog JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(cloudSyncErrorHeadingText, cloudSyncErrorBodyText, dialogBtnStyle, 450, 170, main.getPane()); cloudSyncErrorDialog.show(); - } - - } - }); + } + + } + }); thread.start(); } }; diff --git a/src/main/java/com/cemu_UI/application/playGame.java b/src/main/java/com/cemu_UI/application/playGame.java index 7f7f5a2..9ed18c1 100644 --- a/src/main/java/com/cemu_UI/application/playGame.java +++ b/src/main/java/com/cemu_UI/application/playGame.java @@ -33,18 +33,17 @@ import javafx.application.Platform; public class playGame extends Thread{ - MainWindowController mainWindowController; - DBController dbController; - @SuppressWarnings("unused") + private MainWindowController mainWindowController; + private 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; } - + @Override - public void run(){ + public void run() { String selectedGameTitleID = mainWindowController.getSelectedGameTitleID(); String cemuBin = mainWindowController.getCemuPath() + "/Cemu.exe"; String gameExec = "\"" + mainWindowController.getGameExecutePath() + "\""; @@ -58,8 +57,7 @@ public class playGame extends Thread{ mainWindowController.main.getPrimaryStage().setIconified(true); // minimize cemu_UI }); startTime = System.currentTimeMillis(); - try{ - + try { if (System.getProperty("os.name").equals("Linux")) { if(mainWindowController.isFullscreen()){ p = new ProcessBuilder("wine", cemuBin, "-f", "-g", gameExec).start(); @@ -74,22 +72,22 @@ public class playGame extends Thread{ } } - p.waitFor(); + p.waitFor(); // wait until cemu is closed so we can calculate the played time endTime = System.currentTimeMillis(); timePlayedNow = (int) Math.floor(((endTime - startTime)/1000/60)); timePlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))+timePlayedNow; - dbController.setTotalPlaytime(Integer.toString(timePlayed), selectedGameTitleID); - Platform.runLater(() -> { - if(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) > 60){ - int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))/60); - int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID))-60*hoursPlayed; - mainWindowController.totalPlaytimeBtn.setText(hoursPlayed+"h "+minutesPlayed+"min"); - }else{ - mainWindowController.totalPlaytimeBtn.setText(dbController.getTotalPlaytime(selectedGameTitleID)+ " min"); - } - mainWindowController.main.getPrimaryStage().setIconified(false); // maximize cemu_UI - }); + dbController.setTotalPlaytime(Integer.toString(timePlayed), selectedGameTitleID); + Platform.runLater(() -> { + if (Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) > 60) { + int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) / 60); + int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(selectedGameTitleID)) - 60 * hoursPlayed; + mainWindowController.totalPlaytimeBtn.setText(hoursPlayed + "h " + minutesPlayed + "min"); + } else { + mainWindowController.totalPlaytimeBtn.setText(dbController.getTotalPlaytime(selectedGameTitleID) + " min"); + } + mainWindowController.main.getPrimaryStage().setIconified(false); // maximize cemu_UI + }); //sync savegame with cloud service if (mainWindowController.isCloudSync()) { @@ -98,8 +96,8 @@ public class playGame extends Thread{ mainWindowController.getCemuPath(), mainWindowController.main.getDirectory().getPath()); } - }catch (IOException | InterruptedException e){ - e.printStackTrace(); + } catch (IOException | InterruptedException e) { + LOGGER.error(e); } } diff --git a/src/main/java/com/cemu_UI/controller/DBController.java b/src/main/java/com/cemu_UI/controller/DBController.java index 971035e..f73c554 100644 --- a/src/main/java/com/cemu_UI/controller/DBController.java +++ b/src/main/java/com/cemu_UI/controller/DBController.java @@ -66,7 +66,7 @@ public class DBController { * load ROM and games database * load all games */ - public void init(){ + public void init() { LOGGER.info("<========== starting loading sql ==========>"); loadRomDatabase(); loadGamesDatabase(); @@ -79,18 +79,18 @@ public class DBController { * * TODO this should be called LocalGames */ - private void loadRomDatabase(){ + private void loadRomDatabase() { if (System.getProperty("os.name").equals("Linux")) { DB_PATH_localRoms = System.getProperty("user.home") + "/cemu_UI/localRoms.db"; - }else{ + } else { DB_PATH_localRoms = System.getProperty("user.home") + "\\Documents\\cemu_UI" + "\\" + "localRoms.db"; } try { // create a database connection connection = DriverManager.getConnection("jdbc:sqlite:" + DB_PATH_localRoms); - connection.setAutoCommit(false); //AutoCommit to false -> manual commit is active + connection.setAutoCommit(false); // AutoCommit to false -> manual commit is active } catch (SQLException e) { - // if the error message is "out of memory", it probably means no database file is found + // if the error message is "out of memory", probably no database file is found LOGGER.error("error while loading the ROM database", e); } LOGGER.info("ROM database loaded successfull"); diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index 2f510b1..a17ba18 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -18,7 +18,7 @@ - + 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 f93fce9..c4670e8 100644 --- a/src/main/resources/locals/cemu_UI-Local_en_US.properties +++ b/src/main/resources/locals/cemu_UI-Local_en_US.properties @@ -33,7 +33,7 @@ timeColumn = time # Strings editHeadingText = edit -editBodyText = You can edit the tile and rom/cover path. +editBodyText = You can edit the tile and ROM/cover path. removeHeadingText = remove removeBodyText = Are you sure you want to delete addUpdateHeadingText = update @@ -49,15 +49,15 @@ 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! +cloudSyncWaringBodyText = WARNING this is a completely WIP cloud save integration,\nit's NOT recommended to use this!!\n\nUse it on your own risk and backup everything before! cloudSyncErrorHeadingText = Error while initializing cloud sync! -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. +cloudSyncErrorBodyText = There was some trouble 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 = 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. +addBtnReturnErrorBodyText = There was some trouble adding your game.\nOne of the needed values was empty, please try again to add your game. lastPlayed = Last played, today = today yesterday = yesterday @@ -82,6 +82,6 @@ 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. +editGameDialogBodyTextError = There was some trouble 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