Skip to content

Commit

Permalink
Merge pull request #16 from CodeDead/release/v1.0.1
Browse files Browse the repository at this point in the history
Release/v1.0.1
  • Loading branch information
CodeDead authored Nov 22, 2021
2 parents 3616eb4 + ec3fde1 commit 4cbfabd
Show file tree
Hide file tree
Showing 21 changed files with 161 additions and 49 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ especially if you're targeting a specific platform and installation method.
The following dependencies are universal:

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

* [WiX Toolset](https://wixtoolset.org/)
* [WiX Toolset](https://wixtoolset.org)

### Linux

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

The audio that was included with this project was provided by [ZapSplat](https://www.zapsplat.com/).

Copyright © 2021 CodeDead
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ plugins {
id 'idea'
id 'eclipse'
id 'application'
id 'org.beryx.jlink' version '2.24.2'
id 'org.beryx.jlink' version '2.24.4'
}

group 'com.codedead'
version '1.0.0'
version '1.0.1'

def currentOS = DefaultNativePlatform.currentOperatingSystem

Expand Down Expand Up @@ -112,15 +112,15 @@ if (currentOS.isWindows()) {
}

dependencies {
implementation "org.openjfx:javafx-base:17.0.0.1:${platform}"
implementation "org.openjfx:javafx-controls:17.0.0.1:${platform}"
implementation "org.openjfx:javafx-graphics:17.0.0.1:${platform}"
implementation "org.openjfx:javafx-fxml:17.0.0.1:${platform}"
implementation "org.openjfx:javafx-media:17.0.0.1:${platform}"
implementation "org.openjfx:javafx-base:17.0.1:${platform}"
implementation "org.openjfx:javafx-controls:17.0.1:${platform}"
implementation "org.openjfx:javafx-graphics:17.0.1:${platform}"
implementation "org.openjfx:javafx-fxml:17.0.1:${platform}"
implementation "org.openjfx:javafx-media:17.0.1:${platform}"
implementation "org.apache.logging.log4j:log4j-core:2.14.1"
implementation "com.fasterxml.jackson.core:jackson-databind:2.12.5"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 4 additions & 2 deletions src/main/java/com/codedead/opal/OpalApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.codedead.opal.controller.UpdateController;
import com.codedead.opal.utils.FxUtils;
import com.codedead.opal.utils.SharedVariables;
import javafx.application.Platform;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -93,14 +94,15 @@ public void start(final Stage primaryStage) {
logger.info("Creating the MainWindowController");

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

final Scene scene = new Scene(root);

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

logger.info("Showing the MainWindow");
primaryStage.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public AudioController(final IAudioTimer audioTimer) throws URISyntaxException {
mediaPlayers.put("static", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/static.mp3")).toURI().toString())));
mediaPlayers.put("fantasy", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/fantasy.mp3")).toURI().toString())));
mediaPlayers.put("fan", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/fan.mp3")).toURI().toString())));
mediaPlayers.put("cave", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/cave.mp3")).toURI().toString())));
mediaPlayers.put("frogs", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/frogs.mp3")).toURI().toString())));
mediaPlayers.put("zen", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/zen.mp3")).toURI().toString())));

mediaVolumes = new HashMap<>();
for (final Map.Entry<String, MediaPlayer> entry : mediaPlayers.entrySet()) {
Expand Down
116 changes: 91 additions & 25 deletions src/main/java/com/codedead/opal/controller/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.GridPane;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.apache.logging.log4j.LogManager;
Expand All @@ -26,6 +30,14 @@

public final class MainWindowController implements IAudioTimer {

@FXML
private SoundPane snpZen;
@FXML
private SoundPane snpFrogs;
@FXML
private GridPane grpMain;
@FXML
private SoundPane snpCave;
@FXML
private SoundPane snpFan;
@FXML
Expand Down Expand Up @@ -279,6 +291,9 @@ private void initialize() {
snpStatic.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("static", newValue.doubleValue() / 100));
snpFantasy.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("fantasy", newValue.doubleValue() / 100));
snpFan.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("fan", newValue.doubleValue() / 100));
snpCave.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("cave", newValue.doubleValue() / 100));
snpFrogs.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("frogs", newValue.doubleValue() / 100));
snpZen.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("zen", newValue.doubleValue() / 100));

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

if (file != null && file.exists()) {
try {
audioController.loadSoundPreset(file.getAbsolutePath());
for (final Map.Entry<String, Double> entry : audioController.getVolumes()) {
switch (entry.getKey()) {
case "rain" -> snpRain.getSlider().setValue(entry.getValue() * 100);
case "wind" -> snpWind.getSlider().setValue(entry.getValue() * 100);
case "thunder" -> snpThunder.getSlider().setValue(entry.getValue() * 100);
case "birds" -> snpBird.getSlider().setValue(entry.getValue() * 100);
case "river" -> snpRiver.getSlider().setValue(entry.getValue() * 100);
case "keyboard" -> snpTyping.getSlider().setValue(entry.getValue() * 100);
case "telephone" -> snpTelephone.getSlider().setValue(entry.getValue() * 100);
case "officeChatter" -> snpChatter.getSlider().setValue(entry.getValue() * 100);
case "traffic" -> snpTraffic.getSlider().setValue(entry.getValue() * 100);
case "fireplace" -> snpFireplace.getSlider().setValue(entry.getValue() * 100);
case "static" -> snpStatic.getSlider().setValue(entry.getValue() * 100);
case "fantasy" -> snpFantasy.getSlider().setValue(entry.getValue() * 100);
case "fan" -> snpFan.getSlider().setValue(entry.getValue() * 100);
case "clock" -> snpClock.getSlider().setValue(entry.getValue() * 100);
default -> logger.info("Unknown key found: {}", entry.getKey());
}
}
} catch (final IOException ex) {
logger.error("Unable to open the sound preset from {}", file.getAbsolutePath(), ex);
FxUtils.showErrorAlert(translationBundle.getString("OpenSoundPresetError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
}
openSoundPreset(file.getAbsolutePath());
} else {
logger.info("Cancelled opening a sound preset");
}
}

/**
* Open a sound preset
*
* @param filePath The absolute path of the sound preset file
*/
private void openSoundPreset(final String filePath) {
try {
audioController.loadSoundPreset(filePath);
for (final Map.Entry<String, Double> entry : audioController.getVolumes()) {
switch (entry.getKey()) {
case "rain" -> snpRain.getSlider().setValue(entry.getValue() * 100);
case "wind" -> snpWind.getSlider().setValue(entry.getValue() * 100);
case "thunder" -> snpThunder.getSlider().setValue(entry.getValue() * 100);
case "birds" -> snpBird.getSlider().setValue(entry.getValue() * 100);
case "river" -> snpRiver.getSlider().setValue(entry.getValue() * 100);
case "keyboard" -> snpTyping.getSlider().setValue(entry.getValue() * 100);
case "telephone" -> snpTelephone.getSlider().setValue(entry.getValue() * 100);
case "officeChatter" -> snpChatter.getSlider().setValue(entry.getValue() * 100);
case "traffic" -> snpTraffic.getSlider().setValue(entry.getValue() * 100);
case "fireplace" -> snpFireplace.getSlider().setValue(entry.getValue() * 100);
case "static" -> snpStatic.getSlider().setValue(entry.getValue() * 100);
case "fantasy" -> snpFantasy.getSlider().setValue(entry.getValue() * 100);
case "fan" -> snpFan.getSlider().setValue(entry.getValue() * 100);
case "clock" -> snpClock.getSlider().setValue(entry.getValue() * 100);
case "cave" -> snpCave.getSlider().setValue(entry.getValue() * 100);
case "frogs" -> snpFrogs.getSlider().setValue(entry.getValue() * 100);
case "zen" -> snpZen.getSlider().setValue(entry.getValue() * 100);
default -> logger.info("Unknown key found: {}", entry.getKey());
}
}
} catch (final IOException ex) {
logger.error("Unable to open the sound preset from {}", filePath, ex);
FxUtils.showErrorAlert(translationBundle.getString("OpenSoundPresetError"), ex.getMessage(), getClass().getResourceAsStream(SharedVariables.ICON_URL));
}
}

/**
* Save the sound settings to disk
*/
Expand Down Expand Up @@ -387,6 +414,9 @@ private void resetAction() {
snpStatic.getSlider().setValue(0);
snpFantasy.getSlider().setValue(0);
snpFan.getSlider().setValue(0);
snpCave.getSlider().setValue(0);
snpFrogs.getSlider().setValue(0);
snpZen.getSlider().setValue(0);
}

/**
Expand Down Expand Up @@ -588,6 +618,10 @@ private void updateAction() {
public void fired() {
resetAction();
mniTimerEnabled.setSelected(false);

if (Boolean.parseBoolean(settingsController.getProperties().getProperty("timerApplicationShutdown", "false"))) {
exitAction();
}
}

/**
Expand All @@ -597,4 +631,36 @@ public void fired() {
public void cancelled() {
mniTimerEnabled.setSelected(false);
}

/**
* Method that is invoked when a drag-over event is occurring
*
* @param dragEvent The {@link DragEvent} object
*/
@FXML
private void onDragOver(final DragEvent dragEvent) {
if (dragEvent.getGestureSource() != grpMain && dragEvent.getDragboard().hasFiles()) {
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
}
dragEvent.consume();
}

/**
* Method that is invoked when a drag-drop event occurred
*
* @param dragEvent The {@link DragEvent} object
*/
@FXML
public void onDragDropped(final DragEvent dragEvent) {
final Dragboard db = dragEvent.getDragboard();
boolean success = false;

if (db.hasFiles()) {
openSoundPreset(db.getFiles().get(0).getAbsolutePath());
success = true;
}

dragEvent.setDropCompleted(success);
dragEvent.consume();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

public final class SettingsWindowController {

@FXML
private CheckBox chbTimerApplicationShutdown;
@FXML
private ComboBox<String> cboDelayType;
@FXML
Expand Down Expand Up @@ -83,6 +85,7 @@ private void loadSettings() {
final String logLevel = properties.getProperty("loglevel", "INFO");
long timerDelay = Long.parseLong(properties.getProperty("timerDelay", "3600000"));
final int delayType = Integer.parseInt(properties.getProperty("timerDelayType", "0"));
chbAutoUpdate.setSelected(Boolean.parseBoolean(properties.getProperty("timerApplicationShutdown", "false")));

chbAutoUpdate.setSelected(autoUpdate);
switch (locale.toLowerCase()) {
Expand Down Expand Up @@ -189,6 +192,7 @@ private void saveSettingsAction() {

properties.setProperty("timerDelay", String.valueOf(correctDelay));
properties.setProperty("timerDelayType", String.valueOf(delayType));
properties.setProperty("timerApplicationShutdown", String.valueOf(chbTimerApplicationShutdown.isSelected()));

Configurator.setAllLevels(LogManager.getRootLogger().getName(), level);
settingsController.setProperties(properties);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/codedead/opal/utils/SharedVariables.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public final class SharedVariables {

public static final String ICON_URL = "/images/opal.png";
public static final String CURRENT_VERSION = "1.0.1.0";

public static final String PROPERTIES_RESOURCE_LOCATION = "default.properties";
public static final String PROPERTIES_FILE_LOCATION = System.getProperty("user.home") + "/.opal/opal.properties";
Expand Down
Binary file added src/main/resources/audio/cave.mp3
Binary file not shown.
Binary file added src/main/resources/audio/frogs.mp3
Binary file not shown.
Binary file added src/main/resources/audio/zen.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/resources/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ portable=false
loglevel=INFO
timerDelay=3600000
timerDelayType=2
currentVersion=1.0.0.0
timerApplicationShutdown=false
Binary file added src/main/resources/images/cave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/frogs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/zen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/main/resources/translations/OpalApplication.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
About=About
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0\n\nCopyright © 2021 CodeDead
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0.1\n\nCopyright © 2021 CodeDead
AboutWindowError=Unable to open the About Window!
AboutWindowTitle=Opal - About
AutoUpdate=Automatically check for updates
Expand Down Expand Up @@ -61,3 +61,7 @@ Hours=Hour(s)
TimerDelayTooSmall=Timer delay cannot be smaller than 1!
Fantasy=Fantasy
Fan=Fan
TimerApplicationShutdown=Exit Opal
Cave=Cave
Frogs=Frogs
Zen=Zen
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
About=About
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0\n\nCopyright © 2021 CodeDead
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0.1\n\nCopyright © 2021 CodeDead
AboutWindowError=Unable to open the About Window!
AboutWindowTitle=Opal - About
AutoUpdate=Automatically check for updates
Expand Down Expand Up @@ -61,3 +61,7 @@ Hours=Hour(s)
TimerDelayTooSmall=Timer delay cannot be smaller than 1!
Fantasy=Fantasy
Fan=Fan
TimerApplicationShutdown=Exit Opal
Cave=Cave
Frogs=Frogs
Zen=Zen
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
About=À propos
AboutText=Opal a été créé par DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nThème: Modena\nVersion: 1.0\n\nCopyright © 2021 CodeDead
AboutText=Opal a été créé par DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nThème: Modena\nVersion: 1.0.1\n\nCopyright © 2021 CodeDead
AboutWindowError=Impossible d'ouvrir la fenêtre À propos!
AboutWindowTitle=Opal - À propos
AutoUpdate=Rechercher automatiquement les mises à jour
Expand Down Expand Up @@ -61,3 +61,7 @@ Hours=Heure(s)
TimerDelayTooSmall=Le délai de la minuterie ne peut pas être inférieur à 1!
Fantasy=Fantaisie
Fan=Ventilateur
TimerApplicationShutdown=Fermer Opal
Cave=Grotte
Frogs=Crapauds
Zen=Zen
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
About=Over
AboutText=Opal is gemaakt door DeadLine\n\nAudio: ZapSplat.com\nAfbeeldingen: Remix Icon\nThema: Modena\nVersie: 1.0\n\nCopyright © 2021 CodeDead
AboutText=Opal is gemaakt door DeadLine\n\nAudio: ZapSplat.com\nAfbeeldingen: Remix Icon\nThema: Modena\nVersie: 1.0.1\n\nCopyright © 2021 CodeDead
AboutWindowError=Kan het Over venster niet openen!
AboutWindowTitle=Opal - Over
AutoUpdate=Automatisch controleren op updates
Expand Down Expand Up @@ -61,3 +61,7 @@ Hours=Uur/Uren
TimerDelayTooSmall=Timervertraging kan niet kleiner zijn dan 1!
Fantasy=Fantasie
Fan=Ventilator
TimerApplicationShutdown=Opal afsluiten
Cave=Grot
Frogs=Kikkers
Zen=Zen
Loading

0 comments on commit 4cbfabd

Please sign in to comment.