konogonka/src/main/java/konogonka/Child/ChildWindow.java

106 lines
4.2 KiB
Java
Raw Normal View History

2020-04-05 22:21:14 +03:00
/*
Copyright 2019-2022 Dmitry Isaenko
2020-04-05 22:21:14 +03:00
This file is part of Konogonka.
Konogonka 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.
Konogonka 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 Konogonka. If not, see <https://www.gnu.org/licenses/>.
*/
2019-08-19 17:22:42 +03:00
package konogonka.Child;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import konogonka.Controllers.IRowModel;
2019-08-21 06:36:51 +03:00
import konogonka.Controllers.ITabController;
import konogonka.Controllers.XML.XMLController;
import libKonogonka.Tools.ISuperProvider;
2019-08-19 17:22:42 +03:00
import java.io.IOException;
import java.util.Locale;
import java.util.Objects;
2019-08-19 17:22:42 +03:00
import java.util.ResourceBundle;
public class ChildWindow {
2019-08-24 07:29:56 +03:00
public ChildWindow(ISuperProvider provider, IRowModel model) throws IOException {
2019-08-19 17:22:42 +03:00
Stage stageSettings = new Stage();
stageSettings.setMinWidth(570);
stageSettings.setMinHeight(500);
FXMLLoader loaderSettings;
2019-08-24 07:29:56 +03:00
if (model.getFileName().endsWith(".nca")) {
2019-08-19 17:22:42 +03:00
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/NCA/NCATab.fxml"));
2019-08-24 07:29:56 +03:00
} else if (model.getFileName().endsWith(".tik")) {
2019-08-20 07:02:40 +03:00
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/TIK/TIKTab.fxml"));
2019-08-24 07:29:56 +03:00
} else if (model.getFileName().endsWith(".xml")) {
2019-08-21 06:36:51 +03:00
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/XML/XMLTab.fxml"));
2019-08-19 17:22:42 +03:00
}
2019-08-24 07:29:56 +03:00
else if(model.getFileName().endsWith(".npdm")){
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/NPDM/NPDMTab.fxml"));
}
2019-08-21 06:36:51 +03:00
else if(model.getFileName().endsWith(".cert")){
2019-08-19 17:22:42 +03:00
// TODO: IMPLEMENT
return;
}
2019-08-21 06:36:51 +03:00
else if(model.getFileName().endsWith(".cnmt")){
2019-08-24 07:29:56 +03:00
// todo: implement
2019-08-19 17:22:42 +03:00
return;
}
2019-08-21 06:36:51 +03:00
else // TODO: Dynamic detection function
2019-08-19 17:22:42 +03:00
return;
Locale userLocale = new Locale(Locale.getDefault().getISO3Language());
ResourceBundle resourceBundle = ResourceBundle.getBundle("locale", userLocale);
loaderSettings.setResources(resourceBundle);
Parent parentAbout = loaderSettings.load();
2019-08-21 06:36:51 +03:00
// TODO: fix?
if(model.getFileName().endsWith(".xml")){
XMLController myController = loaderSettings.getController();
2019-08-21 06:36:51 +03:00
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset(), model.getFileSize());
2019-08-19 17:22:42 +03:00
}
2019-08-24 07:29:56 +03:00
else if (model.getFileName().endsWith(".npdm")){
ITabController myController = loaderSettings.getController();
2019-08-24 07:29:56 +03:00
try {
myController.analyze(provider, model.getNumber());
}
catch (Exception e){
System.out.println("ERR"+e.getMessage());
}
}
2019-08-21 06:36:51 +03:00
else {
ITabController myController = loaderSettings.getController();
2019-08-21 06:36:51 +03:00
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
2019-08-20 07:02:40 +03:00
}
2019-08-19 17:22:42 +03:00
stageSettings.setTitle(model.getFileName());
stageSettings.getIcons().addAll(
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon32x32.png"))),
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon48x48.png"))),
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon64x64.png"))),
new Image(Objects.requireNonNull(getClass().getResourceAsStream("/res/app_icon128x128.png")))
2019-08-19 17:22:42 +03:00
);
Scene settingsScene = new Scene(parentAbout, 800, 800);
settingsScene.getStylesheets().add("/res/app_light.css");
stageSettings.setScene(settingsScene);
stageSettings.setMinWidth(550.0);
stageSettings.setMinHeight(550.0);
stageSettings.show();
}
}