Skip to content

Commit

Permalink
Bug fix for ButtonConfiguration.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohantalkad747 committed Mar 30, 2019
1 parent 91be78b commit 3c661f0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/Talkbox/configurer/ButtonConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ButtonConfiguration(String buttonText, File buttonDir) {
*/
public void addImageFile(File image) {
if (image != null) {
this.imageFile = new File(this.buttonDir + FileIO.SEP + "sound" + FileIO.SEP + "image.png");
this.imageFile = new File(this.buttonDir.getPath() + FileIO.SEP + "image" + FileIO.SEP + "image." + FileIO.getExt(image));
FileIO.copyFile(image,this.imageFile);
FileIO.editTextLine(this.buttonTxtDir, "1", 3);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public static ButtonConfiguration readButtonTxt(File buttonDir) {
sound = new File(buttonDir + FileIO.SEP + "sound" + FileIO.SEP + "sound.wav");
}
if (Integer.parseInt(input.get(3)) == 1) {
image = new File(buttonDir + FileIO.SEP + "image" + FileIO.SEP + "image.png");
image = FileIO.getAllFiles("image", new File(buttonDir.getPath() + FileIO.SEP + "image")).get(0);
}
ButtonConfiguration bc = new ButtonConfiguration(input.get(0), buttonDir);
bc.addColor(new Color(Integer.parseInt(input.get(1))));
Expand All @@ -123,10 +123,14 @@ public void changeDirectory(File newDir) {
this.buttonDir = newDir;
this.buttonTxtDir = new File(newDir.getPath() + FileIO.SEP + "button.txt");
if (this.soundFile != null) {
this.soundFile = new File(this.buttonDir.getPath() + FileIO.SEP + "sound" + FileIO.SEP + "sound.wav");
File newSound = new File(this.buttonDir.getPath() + FileIO.SEP + "sound" + FileIO.SEP + "sound.wav");
FileIO.copyFile(this.soundFile, newSound);
this.soundFile = newSound;
}
if (this.imageFile != null) {
this.imageFile = new File(this.buttonDir.getPath() + FileIO.SEP + "sound" + FileIO.SEP + "image." + FileIO.getExt(this.imageFile));;
File newImage = new File(this.buttonDir.getPath() + FileIO.SEP + "image." + FileIO.getExt(this.imageFile));
FileIO.copyFile(this.imageFile, newImage);
this.imageFile = newImage;
}
}

Expand Down

0 comments on commit 3c661f0

Please sign in to comment.