Skip to content

Commit

Permalink
🔀 Merge pull request #24 from Komposten/release-1.0.2
Browse files Browse the repository at this point in the history
Release 1.0.2
  • Loading branch information
Komposten committed Aug 5, 2019
2 parents 2e7bcae + 2b57105 commit d54a62a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>komposten.vivaldi</groupId>
<artifactId>VivaldiModder</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>

<properties>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/komposten/vivaldi/backend/Patcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ private boolean hasBeenPatchedPreviously(File vivaldiDir, File versionDir)


/**
* @return A list of all instructions that were backed up successfully.
* @return A list of all instructions that were backed up successfully,
* already had backups, or did not exist (and where thus not in need
* of being backed up).
*/
private List<Instruction> backupFiles(File versionDir)
{
Expand All @@ -294,18 +296,15 @@ private List<Instruction> backupFiles(File versionDir)
File targetFile = new File(targetDir, sourceFile.getName());
File backupFile = new File(targetDir, sourceFile.getName() + ".bak");

if (targetFile.exists())
if (targetFile.exists() && !backupFile.exists())
{
if (!backupFile.exists())
{
anyNeededBackup = true;
if (backupFile(targetFile, backupFile, versionDir))
instructions.add(instruction);
}
else
{
anyNeededBackup = true;
if (backupFile(targetFile, backupFile, versionDir))
instructions.add(instruction);
}
}
else
{
instructions.add(instruction);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public EditInstructionDialog(Window owner)
checkOnlyFolderContent.setToolTipText(Strings.EDIT_INSTRUCTION_FOLDER_CONTENT);
checkIncludeSubfolders.setToolTipText(Strings.EDIT_INSTRUCTION_INCLUDE_SUBFOLDERS);

fieldTarget.setPreferredSize(new Dimension(340, fieldTarget.getPreferredSize().height));
fieldTarget.setPreferredSize(new Dimension(440, fieldTarget.getPreferredSize().height));

fieldMod.setBrowseListener(this::onModFileSelected);
fieldMod.getTextfield().addFocusListener(focusListener);
Expand Down Expand Up @@ -135,6 +135,7 @@ public EditInstructionDialog(Window owner)
add(panelButtons, constraints);

pack();
setResizable(false);
setLocationRelativeTo(owner);
}

Expand Down
34 changes: 28 additions & 6 deletions src/main/java/komposten/vivaldi/ui/ModPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ private void addInstruction()
if (showEditDialog(null) == EditInstructionDialog.RESULT_OK)
{
Instruction instruction = editDialog.getInstruction();
File modFile = new File(fieldModDir.getTextfield().getText(), instruction.sourceFile);

if (modFile.isDirectory())
if (isModFileDirectory(instruction))
{
addDirectoryInstruction(instruction, editDialog.getOnlyFolderContent(),
editDialog.getIncludeSubfolders());
Expand All @@ -255,6 +254,13 @@ private void addInstruction()
}


private boolean isModFileDirectory(Instruction instruction)
{
File modFile = new File(fieldModDir.getTextfield().getText(), instruction.sourceFile);
return modFile.isDirectory();
}


private boolean checkCanEdit()
{
if (listVivaldiDirs.getDirectories().length == 0)
Expand Down Expand Up @@ -339,16 +345,32 @@ private void editInstruction(Instruction instruction)
if (editDialog == null)
editDialog = new EditInstructionDialog(SwingUtilities.getWindowAncestor(this));


if (showEditDialog(instruction) == EditInstructionDialog.RESULT_OK)
instructionsTable.replaceInstruction(instruction, editDialog.getInstruction());
{
Instruction newInstruction = editDialog.getInstruction();

if (isModFileDirectory(newInstruction))
{
removeInstructions(instruction);
addDirectoryInstruction(newInstruction, editDialog.getOnlyFolderContent(),
editDialog.getIncludeSubfolders());
}
else
{
instructionsTable.replaceInstruction(instruction, newInstruction);
}
}
}


private void removeSelectedInstructions()
{
Instruction[] instructions = instructionsTable.getSelectedInstructions();

removeInstructions(instructionsTable.getSelectedInstructions());
}


private void removeInstructions(Instruction... instructions)
{
if (instructions.length > 0)
instructionsTable.removeInstructions(instructions);
}
Expand Down

0 comments on commit d54a62a

Please sign in to comment.