feat: Exporting to carousel or file loader.

Possible to export gamelist views or individual games.
This commit is contained in:
lantzelot-swe 2021-06-05 00:01:07 +02:00
parent 803a035777
commit c29adbee4a
9 changed files with 236 additions and 138 deletions

View File

@ -279,7 +279,7 @@ public class MenuManager
private JMenuItem getExportFileLoaderItem()
{
exportFLItem = new JMenuItem("Export to File Loader...");
exportFLItem = new JMenuItem("Export to File loader...");
KeyStroke keyStrokeToExportGames = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK);
exportFLItem.setAccelerator(keyStrokeToExportGames);
exportFLItem.setMnemonic('L');
@ -723,17 +723,33 @@ public class MenuManager
exportSelectionDialog.setLocationRelativeTo(this.mainWindow);
if (exportSelectionDialog.showDialog())
{
List<GameListData> gamesList = exportSelectionDialog.getSelectedGames();
if (!gamesList.isEmpty())
if (exportSelectionDialog.isExportGameViews())
{
exportManager.setGamesToExport(gamesList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(),
exportSelectionDialog.deleteBeforeExport(),
exportSelectionDialog.addGamesSubDirectory());
ExportProgressDialog dialog = new ExportProgressDialog(this.mainWindow);
ExportWorker worker = new ExportWorker(exportManager, dialog);
worker.execute();
dialog.setVisible(true);
List<GameView> viewList = exportSelectionDialog.getSelectedGameViews();
if (!viewList.isEmpty())
{
exportManager.setGameViewsToExport(viewList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(),
exportSelectionDialog.deleteBeforeExport());
ExportProgressDialog dialog = new ExportProgressDialog(this.mainWindow);
ExportWorker worker = new ExportWorker(exportManager, dialog);
worker.execute();
dialog.setVisible(true);
}
}
else
{
List<GameListData> gamesList = exportSelectionDialog.getSelectedGames();
if (!gamesList.isEmpty())
{
exportManager.setGamesToExport(gamesList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(),
exportSelectionDialog.deleteBeforeExport());
ExportProgressDialog dialog = new ExportProgressDialog(this.mainWindow);
ExportWorker worker = new ExportWorker(exportManager, dialog);
worker.execute();
dialog.setVisible(true);
}
}
}
}
@ -745,17 +761,33 @@ public class MenuManager
exportSelectionDialog.setLocationRelativeTo(this.mainWindow);
if (exportSelectionDialog.showDialog())
{
List<GameListData> gamesList = exportSelectionDialog.getSelectedGames();
if (!gamesList.isEmpty())
if (exportSelectionDialog.isExportGameViews())
{
exportManager.setGamesToExport(gamesList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(),
exportSelectionDialog.deleteBeforeExport(),
exportSelectionDialog.addGamesSubDirectory());
ExportProgressDialog dialog = new ExportProgressDialog(this.mainWindow);
ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog);
worker.execute();
dialog.setVisible(true);
List<GameView> viewList = exportSelectionDialog.getSelectedGameViews();
if (!viewList.isEmpty())
{
exportManager.setGameViewsToExport(viewList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(),
exportSelectionDialog.deleteBeforeExport());
ExportProgressDialog dialog = new ExportProgressDialog(this.mainWindow);
ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog);
worker.execute();
dialog.setVisible(true);
}
}
else
{
List<GameListData> gamesList = exportSelectionDialog.getSelectedGames();
if (!gamesList.isEmpty())
{
exportManager.setGamesToExport(gamesList);
exportManager.setTargetDirectory(exportSelectionDialog.getTargetDirectory(),
exportSelectionDialog.deleteBeforeExport());
ExportProgressDialog dialog = new ExportProgressDialog(this.mainWindow);
ExportFileLoaderWorker worker = new ExportFileLoaderWorker(exportManager, dialog);
worker.execute();
dialog.setVisible(true);
}
}
}
}

View File

@ -28,13 +28,14 @@ public class SelectDirPanel extends JPanel
{
public enum Mode
{
CAROUSEL_IMPORT, GB_IMPORT, EXPORT
CAROUSEL_IMPORT, GB_IMPORT, CAROUSEL_EXPORT, FILELOADER_EXPORT
}
private static final Logger logger = LoggerFactory.getLogger(SelectDirPanel.class);
private static final String IMPORT_DIR_PROPERTY = "importDir";
private static final String GB_IMPORT_DIR_PROPERTY = "gbImportDir";
private static final String EXPORT_DIR_PROPERTY = "exportDir";
private static final String CAROUSEL_EXPORT_DIR_PROPERTY = "exportDir";
private static final String FILELOADER_EXPORT_DIR_PROPERTY = "flexportDir";
private JTextField dirTextField;
private JButton selectDirButton;
@ -81,8 +82,15 @@ public class SelectDirPanel extends JPanel
configuredDir = new File(".").getAbsolutePath();
}
break;
case EXPORT:
configuredDir = FileManager.getConfiguredProperties().getProperty(EXPORT_DIR_PROPERTY);
case CAROUSEL_EXPORT:
configuredDir = FileManager.getConfiguredProperties().getProperty(CAROUSEL_EXPORT_DIR_PROPERTY);
if (configuredDir == null)
{
configuredDir = new File("export").getAbsolutePath();
}
break;
case FILELOADER_EXPORT:
configuredDir = FileManager.getConfiguredProperties().getProperty(FILELOADER_EXPORT_DIR_PROPERTY);
if (configuredDir == null)
{
configuredDir = new File("export").getAbsolutePath();
@ -124,8 +132,11 @@ public class SelectDirPanel extends JPanel
case GB_IMPORT:
selectGbImportFile();
break;
case EXPORT:
selectExportDirectory();
case CAROUSEL_EXPORT:
selectExportDirectory(true);
break;
case FILELOADER_EXPORT:
selectExportDirectory(false);
break;
default:
break;
@ -193,7 +204,7 @@ public class SelectDirPanel extends JPanel
}
}
private void selectExportDirectory()
private void selectExportDirectory(boolean carousel)
{
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Select a directory to export to");
@ -204,10 +215,12 @@ public class SelectDirPanel extends JPanel
{
targetDirectory = fileChooser.getSelectedFile();
configuredDir = targetDirectory.toPath().toString();
FileManager.getConfiguredProperties().put(EXPORT_DIR_PROPERTY, configuredDir);
FileManager.getConfiguredProperties().put(carousel ? CAROUSEL_EXPORT_DIR_PROPERTY : FILELOADER_EXPORT_DIR_PROPERTY, configuredDir);
getDirTextField().setText(configuredDir);
}
}
public File getTargetDirectory()
{

View File

@ -267,6 +267,11 @@ public class ExportGameViewsSelectionPanel extends JPanel
private void updateAfterEditingSelectedList()
{
getCountLabel().setText(Integer.toString(selectedListModel.getSize()));
setExportButtonEnablement();
}
public void setExportButtonEnablement()
{
exportButton.setEnabled(selectedListModel.getSize() > 0);
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import se.lantz.gui.BaseDialog;
import se.lantz.model.data.GameListData;
import se.lantz.model.data.GameView;
public class ExportGamesDialog extends BaseDialog
{
@ -21,6 +22,7 @@ public class ExportGamesDialog extends BaseDialog
addContent(getExportGamesPanel());
getOkButton().setText("Export");
this.setPreferredSize(new Dimension(800, 700));
this.setMinimumSize(new Dimension(800, 700));
}
private ExportMainPanel getExportGamesPanel()
@ -31,11 +33,21 @@ public class ExportGamesDialog extends BaseDialog
}
return panel;
}
public boolean isExportGameViews()
{
return getExportGamesPanel().isExportGameViews();
}
public List<GameListData> getSelectedGames()
{
return getExportGamesPanel().getSelectedGames();
}
public List<GameView> getSelectedGameViews()
{
return getExportGamesPanel().getSelectedGameViews();
}
public File getTargetDirectory()
{
@ -46,9 +58,4 @@ public class ExportGamesDialog extends BaseDialog
{
return getExportGamesPanel().deleteBeforeExport();
}
public boolean addGamesSubDirectory()
{
return getExportGamesPanel().addGamesSubDirectory();
}
}

View File

@ -204,10 +204,15 @@ public class ExportGamesSelectionPanel extends JPanel
{
sortSelectedList();
getWarningLabel().setVisible(selectedListModel.getSize() > MAX_GAMES);
exportButton.setEnabled(selectedListModel.getSize() > 0);
setExportButtonEnablement();
getCountLabel().setText(Integer.toString(selectedListModel.getSize()));
}
public void setExportButtonEnablement()
{
exportButton.setEnabled(selectedListModel.getSize() > 0);
}
private JPanel getSelectedListPanel()
{
if (selectedListPanel == null)

View File

@ -73,18 +73,19 @@ public class ExportMainPanel extends JPanel
GridBagConstraints gbc_infoLabel = new GridBagConstraints();
gbc_infoLabel.weightx = 1.0;
gbc_infoLabel.fill = GridBagConstraints.HORIZONTAL;
gbc_infoLabel.insets = new Insets(10, 5, 0, 5);
gbc_infoLabel.insets = new Insets(10, 10, 0, 10);
gbc_infoLabel.gridx = 0;
gbc_infoLabel.gridy = 0;
optionPanel.add(getInfoLabel(), gbc_infoLabel);
GridBagConstraints gbc_viewRadioButton = new GridBagConstraints();
gbc_viewRadioButton.weightx = 1.0;
gbc_viewRadioButton.insets = new Insets(10, 0, 0, 0);
gbc_viewRadioButton.insets = new Insets(10, 5, 0, 0);
gbc_viewRadioButton.anchor = GridBagConstraints.WEST;
gbc_viewRadioButton.gridx = 0;
gbc_viewRadioButton.gridy = 1;
optionPanel.add(getViewRadioButton(), gbc_viewRadioButton);
GridBagConstraints gbc_gamesRadioButton = new GridBagConstraints();
gbc_gamesRadioButton.insets = new Insets(0, 5, 0, 0);
gbc_gamesRadioButton.weightx = 1.0;
gbc_gamesRadioButton.anchor = GridBagConstraints.WEST;
gbc_gamesRadioButton.gridx = 0;
@ -101,14 +102,14 @@ public class ExportMainPanel extends JPanel
StringBuilder infoBuilder = new StringBuilder();
if (this.carouselMode)
{
infoBuilder.append("<html>When exporting to Carousel a TSG file is generated and the game files are copied into the selected folder below.<br>");
infoBuilder.append("<html>When exporting to Carousel a TSG file is generated and the game files are copied into the selected target folder.<br>");
infoBuilder.append("Copy the folder into Project Carousel USB on a USB stick.</html>");
}
else
{
infoBuilder.append("<html>When exporting to File loader a CJM file is generated and the game file is copied into the selected folder below.<br>");
infoBuilder.append("<html>When exporting to File loader a CJM file is generated and the game file is copied into the target folder. ");
infoBuilder.append("The files are named after the game title.<br>");
infoBuilder.append("Copy the folder into a USB stick and load the games using the File loader.</html>");
infoBuilder.append("Copy the folder to a USB stick and load the games using the File loader.</html>");
}
infoLabel =
new JLabel(infoBuilder.toString());
@ -120,13 +121,12 @@ public class ExportMainPanel extends JPanel
{
if (viewRadioButton == null)
{
viewRadioButton = new JRadioButton("Export gamelist views");
viewRadioButton = new JRadioButton("Export gamelist views. A subfolder is created in the target folder for each list.");
viewRadioButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
showGameViewSelectionPanel();
getOutputDirPanel().showGamesSubdirCheckbox(false);
}
});
buttonGroup.add(viewRadioButton);
@ -139,13 +139,12 @@ public class ExportMainPanel extends JPanel
{
if (gamesRadioButton == null)
{
gamesRadioButton = new JRadioButton("Export individual games");
gamesRadioButton = new JRadioButton("Export individual games to the target folder");
gamesRadioButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
showGameSelectionPanel();
getOutputDirPanel().showGamesSubdirCheckbox(true);
}
});
buttonGroup.add(gamesRadioButton);
@ -160,7 +159,7 @@ public class ExportMainPanel extends JPanel
cardPanel = new JPanel();
cardPanel.setLayout(cardLayout);
cardPanel.add(getGameViewsSelectionPanel(), "views");
cardPanel.add(getExportGamesSelectionPanel(), "games");
cardPanel.add(getGamesSelectionPanel(), "games");
}
return cardPanel;
}
@ -168,11 +167,14 @@ public class ExportMainPanel extends JPanel
private void showGameViewSelectionPanel()
{
cardLayout.show(getCardPanel(), "views");
getGameViewsSelectionPanel().setExportButtonEnablement();
}
private void showGameSelectionPanel()
{
cardLayout.show(getCardPanel(), "games");
getGamesSelectionPanel().setExportButtonEnablement();
}
private ExportGameViewsSelectionPanel getGameViewsSelectionPanel()
@ -188,8 +190,7 @@ public class ExportMainPanel extends JPanel
{
if (outputDirPanel == null)
{
outputDirPanel = new OutputDirPanel();
outputDirPanel.showGamesSubdirCheckbox(false);
outputDirPanel = new OutputDirPanel(carouselMode);
}
return outputDirPanel;
}
@ -204,22 +205,22 @@ public class ExportMainPanel extends JPanel
return getOutputDirPanel().getDeleteCheckBox().isSelected();
}
boolean addGamesSubDirectory()
{
return getOutputDirPanel().getGamesFolderCheckBox().isSelected();
}
List<GameListData> getSelectedGames()
{
return getExportGamesSelectionPanel().getSelectedGames();
return getGamesSelectionPanel().getSelectedGames();
}
List<GameView> getSelectedGameViews()
{
return getGameViewsSelectionPanel().getSelectedViews();
}
boolean isExportGameViews()
{
return getViewRadioButton().isSelected();
}
private ExportGamesSelectionPanel getExportGamesSelectionPanel()
private ExportGamesSelectionPanel getGamesSelectionPanel()
{
if (exportGamesSelectionPanel == null)
{

View File

@ -17,9 +17,10 @@ public class OutputDirPanel extends JPanel
private JLabel outputDirLabel;
private SelectDirPanel selectDirPanel;
private JCheckBox deleteCheckBox;
private JCheckBox gamesFolderCheckBox;
private boolean carouselMode;
public OutputDirPanel() {
public OutputDirPanel(boolean carouselMode) {
this.carouselMode = carouselMode;
GridBagLayout gbl_outputDirPanel = new GridBagLayout();
gbl_outputDirPanel.columnWidths = new int[] { 0, 0 };
gbl_outputDirPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 };
@ -33,17 +34,11 @@ public class OutputDirPanel extends JPanel
gbc_outputDirLabel.gridy = 0;
add(getOutputDirLabel(), gbc_outputDirLabel);
GridBagConstraints gbc_selectDirPanel = new GridBagConstraints();
gbc_selectDirPanel.insets = new Insets(0, 5, 5, 0);
gbc_selectDirPanel.insets = new Insets(0, 5, 5, 5);
gbc_selectDirPanel.fill = GridBagConstraints.BOTH;
gbc_selectDirPanel.gridx = 0;
gbc_selectDirPanel.gridy = 1;
add(getSelectDirPanel(), gbc_selectDirPanel);
GridBagConstraints gbc_gamesFolderCheckBox = new GridBagConstraints();
gbc_gamesFolderCheckBox.anchor = GridBagConstraints.WEST;
gbc_gamesFolderCheckBox.insets = new Insets(0, 10, 0, 0);
gbc_gamesFolderCheckBox.gridx = 0;
gbc_gamesFolderCheckBox.gridy = 3;
add(getGamesFolderCheckBox(), gbc_gamesFolderCheckBox);
GridBagConstraints gbc_deleteCheckBox = new GridBagConstraints();
gbc_deleteCheckBox.insets = new Insets(0, 10, 0, 0);
gbc_deleteCheckBox.anchor = GridBagConstraints.WEST;
@ -56,7 +51,7 @@ public class OutputDirPanel extends JPanel
{
if (outputDirLabel == null)
{
outputDirLabel = new JLabel("Select directory to export to:");
outputDirLabel = new JLabel("Select target folder to export to:");
}
return outputDirLabel;
}
@ -65,7 +60,7 @@ public class OutputDirPanel extends JPanel
{
if (selectDirPanel == null)
{
selectDirPanel = new SelectDirPanel(Mode.EXPORT);
selectDirPanel = new SelectDirPanel(carouselMode ? Mode.CAROUSEL_EXPORT: Mode.FILELOADER_EXPORT);
}
return selectDirPanel;
}
@ -74,7 +69,7 @@ public class OutputDirPanel extends JPanel
{
if (deleteCheckBox == null)
{
deleteCheckBox = new JCheckBox("Delete existing games in the selected directory before exporting");
deleteCheckBox = new JCheckBox("Delete existing games in the target folder before exporting");
deleteCheckBox.setSelected(true);
}
return deleteCheckBox;
@ -89,24 +84,4 @@ public class OutputDirPanel extends JPanel
{
return getDeleteCheckBox().isSelected();
}
JCheckBox getGamesFolderCheckBox()
{
if (gamesFolderCheckBox == null)
{
gamesFolderCheckBox = new JCheckBox("Export to a \"games\" subdirectory");
}
return gamesFolderCheckBox;
}
boolean addGamesSubDirectory()
{
return getGamesFolderCheckBox().isSelected();
}
void showGamesSubdirCheckbox(boolean show)
{
getGamesFolderCheckBox().setVisible(show);
}
}

View File

@ -6,8 +6,11 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
@ -16,18 +19,23 @@ import org.slf4j.LoggerFactory;
import se.lantz.model.MainViewModel;
import se.lantz.model.data.GameDetails;
import se.lantz.model.data.GameListData;
import se.lantz.model.data.GameView;
import se.lantz.util.ExceptionHandler;
import se.lantz.util.FileManager;
public class ExportManager
{
private static final Logger logger = LoggerFactory.getLogger(ExportManager.class);
private List<GameListData> gamesList;
private List<GameDetails> gameDetailsList;
private List<GameListData> gamesList = new ArrayList<>();
private List<GameDetails> gameDetailsList = new ArrayList<>();
private List<GameView> gameViewList = new ArrayList<>();
private Map<GameView, List<GameDetails>> gameDetailsForViewsMap = new HashMap<>();
private File targetDir;
private MainViewModel uiModel;
private boolean deleteBeforeExport = false;
private boolean gameViewMode = true;
public ExportManager(MainViewModel uiModel)
{
this.uiModel = uiModel;
@ -36,60 +44,37 @@ public class ExportManager
public void setGamesToExport(List<GameListData> gamesList)
{
this.gamesList = gamesList;
gameViewMode = false;
}
public void setTargetDirectory(File targetDir, boolean delete, boolean gamesDir)
public void setGameViewsToExport(List<GameView> gameViewList)
{
this.gameViewList = gameViewList;
gameViewMode = true;
}
public void setTargetDirectory(File targetDir, boolean delete)
{
this.deleteBeforeExport = delete;
Path targetDirPath = targetDir.toPath();
if (delete)
{
//Delete target folder first
try
{
if (Files.exists(targetDirPath))
{
if (Files.exists(targetDirPath.resolve("games").resolve("games")))
{
//Delete entire games folder
Files.walk(targetDirPath.resolve("games")).sorted(Comparator.reverseOrder()).map(Path::toFile)
.forEach(File::delete);
}
else
{
//Delete covers, screens, and games folders and all tsg files
if (Files.exists(targetDirPath.resolve("covers")))
{
Files.walk(targetDirPath.resolve("covers")).sorted(Comparator.reverseOrder()).map(Path::toFile)
.forEach(File::delete);
}
if (Files.exists(targetDirPath.resolve("screens")))
{
Files.walk(targetDirPath.resolve("screens")).sorted(Comparator.reverseOrder()).map(Path::toFile)
.forEach(File::delete);
}
if (Files.exists(targetDirPath.resolve("games")))
{
Files.walk(targetDirPath.resolve("games")).sorted(Comparator.reverseOrder()).map(Path::toFile)
.forEach(File::delete);
}
Files.walk(targetDirPath, 1).filter(p -> p.toString().endsWith(".tsg")).map(Path::toFile)
.forEach(File::delete);
}
//Delete entire folder
Files.walk(targetDirPath).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}
}
catch (IOException e)
{
ExceptionHandler.handleException(e, "Could not delete games folder");
ExceptionHandler.handleException(e, "Could not delete target folder");
}
}
if (gamesDir)
{
targetDirPath = targetDirPath.resolve("games");
}
this.targetDir = targetDirPath.toFile();
try
{
@ -103,14 +88,46 @@ public class ExportManager
public void readFromDb(StringBuilder infoBuilder)
{
gameDetailsList = uiModel.readGameDetailsForExport(infoBuilder, gamesList);
if (gameViewMode)
{
for (GameView gameView : gameViewList)
{
gameDetailsForViewsMap.put(gameView, uiModel.readGameDetailsForGameView(infoBuilder, gameView));
}
}
else
{
gameDetailsList = uiModel.readGameDetailsForExport(infoBuilder, gamesList);
}
}
public void createGameInfoFiles(StringBuilder infoBuilder, boolean fileLoader)
{
for (GameDetails gameDetails : gameDetailsList)
if (gameViewMode)
{
uiModel.exportGameInfoFile(gameDetails, targetDir, infoBuilder, fileLoader);
for (GameView gameView : gameViewList)
{
Path targetPath = targetDir.toPath().resolve(gameView.getName());
try
{
Files.createDirectories(targetPath);
}
catch (IOException e)
{
ExceptionHandler.handleException(e, "Could not create " + targetPath);
}
for (GameDetails gameDetails : gameDetailsForViewsMap.get(gameView))
{
uiModel.exportGameInfoFile(gameDetails, targetPath.toFile(), infoBuilder, fileLoader);
}
}
}
else
{
for (GameDetails gameDetails : gameDetailsList)
{
uiModel.exportGameInfoFile(gameDetails, targetDir, infoBuilder, fileLoader);
}
}
}
@ -120,14 +137,30 @@ public class ExportManager
}
public void copyFiles(StringBuilder infoBuilder)
{
if (gameViewMode)
{
for (GameView gameView : gameViewList)
{
Path targetPath = targetDir.toPath().resolve(gameView.getName());
copyFiles(infoBuilder, targetPath, gameDetailsForViewsMap.get(gameView));
}
}
else
{
copyFiles(infoBuilder, targetDir.toPath(), gameDetailsList);
}
}
private void copyFiles(StringBuilder infoBuilder, Path targetPath, List<GameDetails> gameDetailsList)
{
try
{
Path targetCoverPath = targetDir.toPath().resolve("covers");
Path targetCoverPath = targetPath.resolve("covers");
Files.createDirectories(targetCoverPath);
Path targetScreenPath = targetDir.toPath().resolve("screens");
Path targetScreenPath = targetPath.resolve("screens");
Files.createDirectories(targetScreenPath);
Path targetGamePath = targetDir.toPath().resolve("games");
Path targetGamePath = targetPath.resolve("games");
Files.createDirectories(targetGamePath);
}
catch (IOException e)
@ -139,15 +172,15 @@ public class ExportManager
for (GameDetails gameDetails : gameDetailsList)
{
Path coverPath = Paths.get("./covers/" + gameDetails.getCover());
Path targetCoverPath = targetDir.toPath().resolve("covers/" + gameDetails.getCover());
Path targetCoverPath = targetPath.resolve("covers/" + gameDetails.getCover());
Path screens1Path = Paths.get("./screens/" + gameDetails.getScreen1());
Path targetScreen1Path = targetDir.toPath().resolve("screens/" + gameDetails.getScreen1());
Path targetScreen1Path = targetPath.resolve("screens/" + gameDetails.getScreen1());
Path screens2Path = Paths.get("./screens/" + gameDetails.getScreen2());
Path targetScreen2Path = targetDir.toPath().resolve("screens/" + gameDetails.getScreen2());
Path targetScreen2Path = targetPath.resolve("screens/" + gameDetails.getScreen2());
Path gamePath = Paths.get("./games/" + gameDetails.getGame());
Path targetGamePath = targetDir.toPath().resolve("games/" + gameDetails.getGame());
Path targetGamePath = targetPath.resolve("games/" + gameDetails.getGame());
try
{
@ -187,12 +220,29 @@ public class ExportManager
}
}
}
public void copyGamesForFileLoader(StringBuilder infoBuilder)
{
if (gameViewMode)
{
for (GameView gameView : gameViewList)
{
Path targetPath = targetDir.toPath().resolve(gameView.getName());
copyGamesForFileLoader(infoBuilder, targetPath, gameDetailsForViewsMap.get(gameView));
}
}
else
{
copyGamesForFileLoader(infoBuilder, targetDir.toPath(), gameDetailsList);
}
}
private void copyGamesForFileLoader(StringBuilder infoBuilder, Path targetPath, List<GameDetails> gameDetailsList)
{
try
{
Path targetGamePath = targetDir.toPath();
Path targetGamePath = targetPath;
Files.createDirectories(targetGamePath);
}
catch (IOException e)
@ -204,7 +254,7 @@ public class ExportManager
for (GameDetails gameDetails : gameDetailsList)
{
String gameName = gameDetails.getGame();
Path gamePath = Paths.get("./games/" + gameName);
String extension = FilenameUtils.getExtension(gameName);
boolean zipped = false;
@ -220,8 +270,11 @@ public class ExportManager
}
zipped = true;
}
Path targetGamePath = targetDir.toPath().resolve(FileManager.generateFileNameFromTitleForFileLoader(gameDetails.getTitle(), gameDetails.getDuplicateIndex()) + "." + extension);
Path targetGamePath = targetPath
.resolve(FileManager.generateFileNameFromTitleForFileLoader(gameDetails.getTitle(),
gameDetails.getDuplicateIndex()) +
"." + extension);
try
{
if (!gameDetails.getGame().isEmpty())
@ -253,6 +306,7 @@ public class ExportManager
{
gamesList.clear();
gameDetailsList.clear();
gameDetailsForViewsMap.clear();
targetDir = null;
deleteBeforeExport = false;
}

View File

@ -273,6 +273,12 @@ public class MainViewModel extends AbstractModel
}
return returnList;
}
public List<GameDetails> readGameDetailsForGameView(StringBuilder infoBuilder, GameView gameView)
{
List<GameListData> gamesList = dbConnector.fetchGamesByView(gameView);
return readGameDetailsForExport(infoBuilder, gamesList);
}
public void exportGameInfoFile(GameDetails gameDetails, File targetDir, StringBuilder infoBuilder, boolean fileLoader)
{