-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a few popups to handle end of week, warnings and gameover
- Loading branch information
Showing
32 changed files
with
1,701 additions
and
508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(del \"C:\\\\Users\\\\perer\\\\Documents\\\\GitHub\\\\Millions\\\\src\\\\main\\\\java\\\\edu\\\\ntnu\\\\idi\\\\idatt2003\\\\gruppe42\\\\View\\\\Apps\\\\DebtWarningApp.java\")" | ||
| ] | ||
| } | ||
| } |
47 changes: 28 additions & 19 deletions
47
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/AudioManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,48 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Audio; | ||
|
|
||
| import javafx.scene.media.AudioClip; | ||
|
|
||
| import java.util.EnumMap; | ||
| import java.util.Map; | ||
| import javafx.scene.Node; | ||
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.media.AudioClip; | ||
|
|
||
| public class AudioManager { | ||
| /** | ||
| * Zero-latency sound effect player. | ||
| * | ||
| * <p>All assets in {@link SoundEffect} are decoded into in-memory | ||
| * {@link AudioClip}s on first instantiation, so {@link #play(SoundEffect)} | ||
| * fires immediately without any I/O.</p> | ||
| */ | ||
| public final class AudioManager { | ||
|
|
||
| private static AudioManager instance = new AudioManager(); | ||
| private Map<SoundEffect, AudioClip> sounds = new EnumMap<>(SoundEffect.class); | ||
| private double volume = 1.0; | ||
| private static final AudioManager INSTANCE = new AudioManager(); | ||
|
|
||
| public AudioManager() { | ||
| private final Map<SoundEffect, AudioClip> clips = new EnumMap<>(SoundEffect.class); | ||
| private double volume = 1.0; | ||
|
|
||
| private AudioManager() { | ||
| for (SoundEffect effect : SoundEffect.values()) { | ||
|
|
||
| AudioClip clip = new AudioClip( | ||
| getClass() | ||
| .getResource(effect.getPath()) | ||
| .toExternalForm() | ||
| getClass().getResource(effect.getPath()).toExternalForm() | ||
| ); | ||
|
|
||
| sounds.put(effect, clip); | ||
| clips.put(effect, clip); | ||
| } | ||
| } | ||
|
|
||
| public static AudioManager getInstance() { | ||
| return instance; | ||
| return INSTANCE; | ||
| } | ||
|
|
||
| public void play(SoundEffect sound) { | ||
| AudioClip audioClip = sounds.get(sound); | ||
|
|
||
| if (audioClip != null) { | ||
| audioClip.play(volume); | ||
| /** Plays the given sound at the current master volume. */ | ||
| public void play(final SoundEffect sound) { | ||
| AudioClip clip = clips.get(sound); | ||
| if (clip != null) { | ||
| clip.play(volume); | ||
| } | ||
| } | ||
|
|
||
| /** Sets the master volume in the range [0.0, 1.0]. */ | ||
| public void setVolume(final double volume) { | ||
| this.volume = Math.max(0.0, Math.min(1.0, volume)); | ||
| } | ||
| } |
14 changes: 10 additions & 4 deletions
14
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/SoundEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.