Skip to content

Commit 4cbfabd

Browse files
authored
Merge pull request #16 from CodeDead/release/v1.0.1
Release/v1.0.1
2 parents 3616eb4 + ec3fde1 commit 4cbfabd

21 files changed

+161
-49
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ especially if you're targeting a specific platform and installation method.
6060
The following dependencies are universal:
6161

6262
* [JDK17](https://openjdk.java.net/projects/jdk/17/)
63-
* [JavaFX](https://openjfx.io/)
63+
* [JavaFX](https://openjfx.io)
6464
* [Gradle](https://gradle.org)
6565
* [FasterXML/jackson](https://github.com/FasterXML/jackson)
6666
* [badass-jlink-plugin](https://github.com/beryx/badass-jlink-plugin)
@@ -71,7 +71,7 @@ The following dependencies are universal:
7171
#### MSI
7272
In order to build an installer (*MSI*) of Opal on Windows, you will need:
7373

74-
* [WiX Toolset](https://wixtoolset.org/)
74+
* [WiX Toolset](https://wixtoolset.org)
7575

7676
### Linux
7777

@@ -99,6 +99,4 @@ This library is maintained by CodeDead. You can find more about us using the fol
9999
* [Facebook](https://facebook.com/deadlinecodedead)
100100
* [Reddit](https://reddit.com/r/CodeDead/)
101101

102-
The audio that was included with this project was provided by [ZapSplat](https://www.zapsplat.com/).
103-
104102
Copyright © 2021 CodeDead

build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ plugins {
55
id 'idea'
66
id 'eclipse'
77
id 'application'
8-
id 'org.beryx.jlink' version '2.24.2'
8+
id 'org.beryx.jlink' version '2.24.4'
99
}
1010

1111
group 'com.codedead'
12-
version '1.0.0'
12+
version '1.0.1'
1313

1414
def currentOS = DefaultNativePlatform.currentOperatingSystem
1515

@@ -112,15 +112,15 @@ if (currentOS.isWindows()) {
112112
}
113113

114114
dependencies {
115-
implementation "org.openjfx:javafx-base:17.0.0.1:${platform}"
116-
implementation "org.openjfx:javafx-controls:17.0.0.1:${platform}"
117-
implementation "org.openjfx:javafx-graphics:17.0.0.1:${platform}"
118-
implementation "org.openjfx:javafx-fxml:17.0.0.1:${platform}"
119-
implementation "org.openjfx:javafx-media:17.0.0.1:${platform}"
115+
implementation "org.openjfx:javafx-base:17.0.1:${platform}"
116+
implementation "org.openjfx:javafx-controls:17.0.1:${platform}"
117+
implementation "org.openjfx:javafx-graphics:17.0.1:${platform}"
118+
implementation "org.openjfx:javafx-fxml:17.0.1:${platform}"
119+
implementation "org.openjfx:javafx-media:17.0.1:${platform}"
120120
implementation "org.apache.logging.log4j:log4j-core:2.14.1"
121-
implementation "com.fasterxml.jackson.core:jackson-databind:2.12.5"
121+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
122122
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
123-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
123+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
124124
}
125125

126126
test {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/com/codedead/opal/OpalApplication.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.codedead.opal.controller.UpdateController;
44
import com.codedead.opal.utils.FxUtils;
55
import com.codedead.opal.utils.SharedVariables;
6+
import javafx.application.Platform;
67
import org.apache.logging.log4j.Level;
78
import org.apache.logging.log4j.LogManager;
89
import org.apache.logging.log4j.Logger;
@@ -93,14 +94,15 @@ public void start(final Stage primaryStage) {
9394
logger.info("Creating the MainWindowController");
9495

9596
final MainWindowController mainWindowController = loader.getController();
96-
mainWindowController.setControllers(settingsController, new UpdateController(properties.getProperty("updateApi", "https://codedead.com/Software/Opal/version.json"), properties.getProperty("currentVersion", "1.0.0.0"))
97-
);
97+
final UpdateController updateController = new UpdateController(properties.getProperty("updateApi", "https://codedead.com/Software/Opal/version.json"), SharedVariables.CURRENT_VERSION);
98+
mainWindowController.setControllers(settingsController, updateController);
9899

99100
final Scene scene = new Scene(root);
100101

101102
primaryStage.setTitle(translationBundle.getString("MainWindowTitle"));
102103
primaryStage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream(SharedVariables.ICON_URL))));
103104
primaryStage.setScene(scene);
105+
primaryStage.setOnCloseRequest(e -> System.exit(0));
104106

105107
logger.info("Showing the MainWindow");
106108
primaryStage.show();

src/main/java/com/codedead/opal/controller/AudioController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public AudioController(final IAudioTimer audioTimer) throws URISyntaxException {
5757
mediaPlayers.put("static", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/static.mp3")).toURI().toString())));
5858
mediaPlayers.put("fantasy", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/fantasy.mp3")).toURI().toString())));
5959
mediaPlayers.put("fan", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/fan.mp3")).toURI().toString())));
60+
mediaPlayers.put("cave", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/cave.mp3")).toURI().toString())));
61+
mediaPlayers.put("frogs", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/frogs.mp3")).toURI().toString())));
62+
mediaPlayers.put("zen", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/zen.mp3")).toURI().toString())));
6063

6164
mediaVolumes = new HashMap<>();
6265
for (final Map.Entry<String, MediaPlayer> entry : mediaPlayers.entrySet()) {

src/main/java/com/codedead/opal/controller/MainWindowController.java

Lines changed: 91 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
import javafx.scene.control.*;
1515
import javafx.scene.image.Image;
1616
import javafx.scene.image.ImageView;
17+
import javafx.scene.input.DragEvent;
18+
import javafx.scene.input.Dragboard;
19+
import javafx.scene.input.TransferMode;
20+
import javafx.scene.layout.GridPane;
1721
import javafx.stage.FileChooser;
1822
import javafx.stage.Stage;
1923
import org.apache.logging.log4j.LogManager;
@@ -26,6 +30,14 @@
2630

2731
public final class MainWindowController implements IAudioTimer {
2832

33+
@FXML
34+
private SoundPane snpZen;
35+
@FXML
36+
private SoundPane snpFrogs;
37+
@FXML
38+
private GridPane grpMain;
39+
@FXML
40+
private SoundPane snpCave;
2941
@FXML
3042
private SoundPane snpFan;
3143
@FXML
@@ -279,6 +291,9 @@ private void initialize() {
279291
snpStatic.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("static", newValue.doubleValue() / 100));
280292
snpFantasy.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("fantasy", newValue.doubleValue() / 100));
281293
snpFan.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("fan", newValue.doubleValue() / 100));
294+
snpCave.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("cave", newValue.doubleValue() / 100));
295+
snpFrogs.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("frogs", newValue.doubleValue() / 100));
296+
snpZen.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("zen", newValue.doubleValue() / 100));
282297

283298
mniTimerEnabled.setOnAction(e ->
284299
{
@@ -307,36 +322,48 @@ private void openSoundPresetAction() {
307322
final File file = chooser.showOpenDialog(new Stage());
308323

309324
if (file != null && file.exists()) {
310-
try {
311-
audioController.loadSoundPreset(file.getAbsolutePath());
312-
for (final Map.Entry<String, Double> entry : audioController.getVolumes()) {
313-
switch (entry.getKey()) {
314-
case "rain" -> snpRain.getSlider().setValue(entry.getValue() * 100);
315-
case "wind" -> snpWind.getSlider().setValue(entry.getValue() * 100);
316-
case "thunder" -> snpThunder.getSlider().setValue(entry.getValue() * 100);
317-
case "birds" -> snpBird.getSlider().setValue(entry.getValue() * 100);
318-
case "river" -> snpRiver.getSlider().setValue(entry.getValue() * 100);
319-
case "keyboard" -> snpTyping.getSlider().setValue(entry.getValue() * 100);
320-
case "telephone" -> snpTelephone.getSlider().setValue(entry.getValue() * 100);
321-
case "officeChatter" -> snpChatter.getSlider().setValue(entry.getValue() * 100);
322-
case "traffic" -> snpTraffic.getSlider().setValue(entry.getValue() * 100);
323-
case "fireplace" -> snpFireplace.getSlider().setValue(entry.getValue() * 100);
324-
case "static" -> snpStatic.getSlider().setValue(entry.getValue() * 100);
325-
case "fantasy" -> snpFantasy.getSlider().setValue(entry.getValue() * 100);
326-
case "fan" -> snpFan.getSlider().setValue(entry.getValue() * 100);
327-
case "clock" -> snpClock.getSlider().setValue(entry.getValue() * 100);
328-
default -> logger.info("Unknown key found: {}", entry.getKey());
329-
}
330-
}
331-
} catch (final IOException ex) {
332-
logger.error("Unable to open the sound preset from {}", file.getAbsolutePath(), ex);
333-
FxUtils.showErrorAlert(translationBundle.getString("OpenSoundPresetError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
334-
}
325+
openSoundPreset(file.getAbsolutePath());
335326
} else {
336327
logger.info("Cancelled opening a sound preset");
337328
}
338329
}
339330

331+
/**
332+
* Open a sound preset
333+
*
334+
* @param filePath The absolute path of the sound preset file
335+
*/
336+
private void openSoundPreset(final String filePath) {
337+
try {
338+
audioController.loadSoundPreset(filePath);
339+
for (final Map.Entry<String, Double> entry : audioController.getVolumes()) {
340+
switch (entry.getKey()) {
341+
case "rain" -> snpRain.getSlider().setValue(entry.getValue() * 100);
342+
case "wind" -> snpWind.getSlider().setValue(entry.getValue() * 100);
343+
case "thunder" -> snpThunder.getSlider().setValue(entry.getValue() * 100);
344+
case "birds" -> snpBird.getSlider().setValue(entry.getValue() * 100);
345+
case "river" -> snpRiver.getSlider().setValue(entry.getValue() * 100);
346+
case "keyboard" -> snpTyping.getSlider().setValue(entry.getValue() * 100);
347+
case "telephone" -> snpTelephone.getSlider().setValue(entry.getValue() * 100);
348+
case "officeChatter" -> snpChatter.getSlider().setValue(entry.getValue() * 100);
349+
case "traffic" -> snpTraffic.getSlider().setValue(entry.getValue() * 100);
350+
case "fireplace" -> snpFireplace.getSlider().setValue(entry.getValue() * 100);
351+
case "static" -> snpStatic.getSlider().setValue(entry.getValue() * 100);
352+
case "fantasy" -> snpFantasy.getSlider().setValue(entry.getValue() * 100);
353+
case "fan" -> snpFan.getSlider().setValue(entry.getValue() * 100);
354+
case "clock" -> snpClock.getSlider().setValue(entry.getValue() * 100);
355+
case "cave" -> snpCave.getSlider().setValue(entry.getValue() * 100);
356+
case "frogs" -> snpFrogs.getSlider().setValue(entry.getValue() * 100);
357+
case "zen" -> snpZen.getSlider().setValue(entry.getValue() * 100);
358+
default -> logger.info("Unknown key found: {}", entry.getKey());
359+
}
360+
}
361+
} catch (final IOException ex) {
362+
logger.error("Unable to open the sound preset from {}", filePath, ex);
363+
FxUtils.showErrorAlert(translationBundle.getString("OpenSoundPresetError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
364+
}
365+
}
366+
340367
/**
341368
* Save the sound settings to disk
342369
*/
@@ -387,6 +414,9 @@ private void resetAction() {
387414
snpStatic.getSlider().setValue(0);
388415
snpFantasy.getSlider().setValue(0);
389416
snpFan.getSlider().setValue(0);
417+
snpCave.getSlider().setValue(0);
418+
snpFrogs.getSlider().setValue(0);
419+
snpZen.getSlider().setValue(0);
390420
}
391421

392422
/**
@@ -588,6 +618,10 @@ private void updateAction() {
588618
public void fired() {
589619
resetAction();
590620
mniTimerEnabled.setSelected(false);
621+
622+
if (Boolean.parseBoolean(settingsController.getProperties().getProperty("timerApplicationShutdown", "false"))) {
623+
exitAction();
624+
}
591625
}
592626

593627
/**
@@ -597,4 +631,36 @@ public void fired() {
597631
public void cancelled() {
598632
mniTimerEnabled.setSelected(false);
599633
}
634+
635+
/**
636+
* Method that is invoked when a drag-over event is occurring
637+
*
638+
* @param dragEvent The {@link DragEvent} object
639+
*/
640+
@FXML
641+
private void onDragOver(final DragEvent dragEvent) {
642+
if (dragEvent.getGestureSource() != grpMain && dragEvent.getDragboard().hasFiles()) {
643+
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
644+
}
645+
dragEvent.consume();
646+
}
647+
648+
/**
649+
* Method that is invoked when a drag-drop event occurred
650+
*
651+
* @param dragEvent The {@link DragEvent} object
652+
*/
653+
@FXML
654+
public void onDragDropped(final DragEvent dragEvent) {
655+
final Dragboard db = dragEvent.getDragboard();
656+
boolean success = false;
657+
658+
if (db.hasFiles()) {
659+
openSoundPreset(db.getFiles().get(0).getAbsolutePath());
660+
success = true;
661+
}
662+
663+
dragEvent.setDropCompleted(success);
664+
dragEvent.consume();
665+
}
600666
}

src/main/java/com/codedead/opal/controller/SettingsWindowController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
public final class SettingsWindowController {
2323

24+
@FXML
25+
private CheckBox chbTimerApplicationShutdown;
2426
@FXML
2527
private ComboBox<String> cboDelayType;
2628
@FXML
@@ -83,6 +85,7 @@ private void loadSettings() {
8385
final String logLevel = properties.getProperty("loglevel", "INFO");
8486
long timerDelay = Long.parseLong(properties.getProperty("timerDelay", "3600000"));
8587
final int delayType = Integer.parseInt(properties.getProperty("timerDelayType", "0"));
88+
chbAutoUpdate.setSelected(Boolean.parseBoolean(properties.getProperty("timerApplicationShutdown", "false")));
8689

8790
chbAutoUpdate.setSelected(autoUpdate);
8891
switch (locale.toLowerCase()) {
@@ -189,6 +192,7 @@ private void saveSettingsAction() {
189192

190193
properties.setProperty("timerDelay", String.valueOf(correctDelay));
191194
properties.setProperty("timerDelayType", String.valueOf(delayType));
195+
properties.setProperty("timerApplicationShutdown", String.valueOf(chbTimerApplicationShutdown.isSelected()));
192196

193197
Configurator.setAllLevels(LogManager.getRootLogger().getName(), level);
194198
settingsController.setProperties(properties);

src/main/java/com/codedead/opal/utils/SharedVariables.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public final class SharedVariables {
44

55
public static final String ICON_URL = "/images/opal.png";
6+
public static final String CURRENT_VERSION = "1.0.1.0";
67

78
public static final String PROPERTIES_RESOURCE_LOCATION = "default.properties";
89
public static final String PROPERTIES_FILE_LOCATION = System.getProperty("user.home") + "/.opal/opal.properties";

src/main/resources/audio/cave.mp3

1.45 MB
Binary file not shown.

src/main/resources/audio/frogs.mp3

1.24 MB
Binary file not shown.

0 commit comments

Comments
 (0)