2016-08-14 15:17:14 +02:00
/ * *
2018-03-01 15:42:47 +01:00
* Project - HomeFlix
*
2019-01-08 17:10:33 +01:00
* Copyright 2016 - 2019 < @Seil0 >
2016-08-14 15:17:14 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston ,
* MA 02110 - 1301 , USA .
*
* /
2019-06-21 21:16:53 +02:00
2018-03-01 15:42:47 +01:00
package kellerkinder.HomeFlix.application ;
2017-02-09 16:27:52 +01:00
2016-08-14 15:17:14 +02:00
import java.io.File ;
import java.io.IOException ;
2017-09-16 18:22:46 +02:00
import org.apache.logging.log4j.LogManager ;
import org.apache.logging.log4j.Logger ;
2018-03-29 12:27:44 +02:00
2016-08-14 15:17:14 +02:00
import javafx.application.Application ;
import javafx.fxml.FXMLLoader ;
import javafx.scene.Scene ;
import javafx.scene.image.Image ;
import javafx.scene.layout.AnchorPane ;
import javafx.stage.Stage ;
2019-01-08 17:10:33 +01:00
import kellerkinder.HomeFlix.controller.XMLController ;
2016-08-14 15:17:14 +02:00
public class Main extends Application {
2018-03-29 18:15:57 +02:00
2018-03-01 15:42:47 +01:00
private Scene scene ;
private AnchorPane pane ;
private MainWindowController mainWindowController ;
2019-01-08 17:10:33 +01:00
private static XMLController xmlController ;
2017-09-16 18:22:46 +02:00
private static Logger LOGGER ;
2019-07-04 12:39:19 +02:00
public static final String version = " 0.8.0 " ;
2019-06-22 21:04:43 +02:00
public static final String buildNumber = " 173 " ;
2019-06-21 21:16:53 +02:00
public static final String versionName = " toothless dragon " ;
2020-04-01 19:48:44 +02:00
// TODO rename streamURL to mediaURL
2018-03-29 18:15:57 +02:00
2016-08-14 15:17:14 +02:00
@Override
2017-04-25 23:35:20 +02:00
public void start ( Stage primaryStage ) throws IOException {
2018-05-17 18:58:54 +02:00
2019-06-21 21:16:53 +02:00
//initialize the mainWindowController and the primaryStage
2016-08-14 15:17:14 +02:00
try {
2017-09-16 18:22:46 +02:00
FXMLLoader loader = new FXMLLoader ( ) ;
2018-09-23 14:33:16 +02:00
loader . setLocation ( getClass ( ) . getResource ( " /fxml/MainWindow.fxml " ) ) ;
2018-03-01 15:42:47 +01:00
pane = ( AnchorPane ) loader . load ( ) ;
2019-06-17 00:44:44 +02:00
primaryStage . setMinHeight ( 600 . 00 + 34 ) ; // 34 -> window decoration
2019-06-15 18:44:35 +02:00
primaryStage . setMinWidth ( 1130 . 00 ) ;
//primaryStage.setResizable(false);
2017-09-16 18:22:46 +02:00
primaryStage . setTitle ( " Project HomeFlix " ) ;
2018-03-01 15:42:47 +01:00
primaryStage . getIcons ( ) . add ( new Image ( Main . class . getResourceAsStream ( " /icons/Homeflix_Icon_64x64.png " ) ) ) ; //adds application icon
2019-06-15 11:09:59 +02:00
primaryStage . setOnCloseRequest ( event - > System . exit ( 0 ) ) ;
2018-03-01 15:42:47 +01:00
2018-03-29 12:27:44 +02:00
// generate window
scene = new Scene ( pane ) ; // create new scene, append pane to scene
scene . getStylesheets ( ) . add ( getClass ( ) . getResource ( " /css/MainWindow.css " ) . toExternalForm ( ) ) ;
primaryStage . setScene ( scene ) ; // append scene to stage
primaryStage . show ( ) ; // show stage
2019-01-09 22:36:50 +01:00
mainWindowController = loader . getController ( ) ; //Link of FXMLController and controller class
mainWindowController . init ( ) ;
2016-08-14 15:17:14 +02:00
} catch ( IOException e ) {
2019-06-21 21:16:53 +02:00
LOGGER . error ( " Error while loading in Main " , e ) ;
2016-08-14 15:17:14 +02:00
}
}
2018-03-29 18:15:57 +02:00
2018-05-17 18:58:54 +02:00
/ * *
* set the log file location and initialize the logger launch the GUI
* @param args arguments given at the start
* /
public static void main ( String [ ] args ) {
2019-01-08 17:10:33 +01:00
// Logger initialization
String logPath = " " ;
if ( System . getProperty ( " os.name " ) . contains ( " Windows " ) ) {
logPath = System . getProperty ( " user.home " ) + " /Documents/HomeFlix/app.log " ;
2018-05-17 18:58:54 +02:00
} else {
2019-01-08 17:10:33 +01:00
logPath = System . getProperty ( " user.home " ) + " /HomeFlix/app.log " ;
2018-05-17 18:58:54 +02:00
}
2019-01-08 17:10:33 +01:00
System . setProperty ( " logFilename " , logPath ) ;
File logFile = new File ( logPath ) ;
2018-05-17 18:58:54 +02:00
logFile . delete ( ) ;
LOGGER = LogManager . getLogger ( Main . class . getName ( ) ) ;
2019-01-08 17:10:33 +01:00
2019-06-21 21:16:53 +02:00
LOGGER . info ( " OS: " + XMLController . getOsName ( ) + " " + XMLController . getOsVers ( ) + " " + XMLController . getOsVers ( ) ) ;
LOGGER . info ( " Java: " + XMLController . getJavaVend ( ) + " " + XMLController . getJavaVers ( ) ) ;
LOGGER . info ( " User: " + XMLController . getUserName ( ) + " " + XMLController . getUserHome ( ) ) ;
2019-01-08 17:10:33 +01:00
xmlController = new XMLController ( ) ;
2017-02-09 16:27:52 +01:00
2019-06-22 21:04:43 +02:00
if ( ! XMLController . getConfigFile ( ) . exists ( ) ) {
xmlController . saveSettings ( ) ; // save the settings file with default values if it doesn't exist
2019-06-21 21:16:53 +02:00
}
2019-06-22 21:04:43 +02:00
xmlController . loadSettings ( ) ;
2018-03-29 18:15:57 +02:00
2019-06-21 21:16:53 +02:00
if ( ! XMLController . getPosterCache ( ) . exists ( ) ) {
XMLController . getPosterCache ( ) . mkdir ( ) ;
}
2018-10-11 12:29:26 +02:00
2019-06-21 21:16:53 +02:00
launch ( args ) ;
2016-08-14 15:17:14 +02:00
}
2019-06-21 21:16:53 +02:00
2018-09-21 18:57:39 +02:00
}