-
-
Notifications
You must be signed in to change notification settings - Fork 19
#168 Added restart track setting #169
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ export default class HypeTrack { | |
| this.playlist = null; | ||
| this.pausedSounds = []; | ||
| } | ||
|
|
||
| /* -------------------------------------------- */ | ||
| /* Hook Handlers */ | ||
| /* -------------------------------------------- */ | ||
|
|
@@ -70,7 +69,7 @@ export default class HypeTrack { | |
| } | ||
|
|
||
| // Stop any active hype tracks | ||
| if (this.playlist?.playing) await this.playlist.stopAll(); | ||
| if (this.playlist?.playing) await Playback.pauseAllTracks(this.playlist); | ||
|
|
||
| // Find the hype track | ||
| const flags = this._getActorHypeFlags(combat?.combatant?.actor); | ||
|
|
@@ -268,13 +267,13 @@ export default class HypeTrack { | |
|
|
||
| return playedTrack; | ||
| } | ||
|
|
||
| async _stopHypeTrack() { | ||
| if (!this.playlist || !isFirstGM()) return; | ||
|
|
||
| // Stop the playlist if it is playing | ||
| if (this.playlist.playing) { | ||
| await this.playlist.stopAll(); | ||
| await Playback.pauseAllTracks(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This call doesn't pass the playlist to |
||
| ui.playlists.render(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| import * as MAESTRO from "./config.js"; | ||
|
|
||
| class PlaybackSettings{ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a static inner class, I'd prefer adding a property to the |
||
|
|
||
| static pauseDictionary = {}; // for hype tracks restarting handling | ||
| } | ||
|
|
||
| /** | ||
| * Get all the sounds in a specific playlist | ||
|
|
@@ -52,8 +56,29 @@ export async function playTrack(trackId, playlistId) { | |
| const sound = playlist.sounds?.get(trackId); | ||
|
|
||
| if (!sound) return; | ||
|
|
||
|
|
||
| const restartHypeTracks = game.settings.get(MAESTRO.MODULE_NAME, MAESTRO.SETTINGS_KEYS.HypeTrack.restartHypeTracks); | ||
| var resumeTime = 0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
| if(restartHypeTracks && PlaybackSettings.pauseDictionary[trackId]) resumeTime = PlaybackSettings.pauseDictionary[trackId]; | ||
|
|
||
| return await sound.update({pausedTime: resumeTime, playing: true}); | ||
| } | ||
|
|
||
| return await sound.update({playing: true}); | ||
| export async function pauseAllTracks(playlist) { | ||
| if(!playlist) return; | ||
|
|
||
| const restartHypeTracks = game.settings.get(MAESTRO.MODULE_NAME, MAESTRO.SETTINGS_KEYS.HypeTrack.restartHypeTracks); | ||
| if(restartHypeTracks && playlist.data && playlist.data.sounds) | ||
| { | ||
| var sounds = playlist.data.sounds; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
| sounds.forEach(sound=>{ | ||
| if(sound.playing) | ||
| { | ||
| PlaybackSettings.pauseDictionary[sound.id] = sound.sound.currentTime; | ||
| } | ||
| })} | ||
| await playlist.stopAll(); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ export const registerModuleSettings = async function() { | |
| await game.maestro.hypeTrack._checkForHypeTracksPlaylist(); | ||
| } | ||
| }), | ||
|
|
||
| game.settings.register(MAESTRO.MODULE_NAME, MAESTRO.SETTINGS_KEYS.HypeTrack.pauseOthers, { | ||
| name: "MAESTRO.SETTINGS.HypeTrackPauseOthersN", | ||
| hint: "MAESTRO.SETTINGS.HypeTrackPauseOthersH", | ||
|
|
@@ -31,7 +31,18 @@ export const registerModuleSettings = async function() { | |
| default: false, | ||
| config: true, | ||
| onChange: async s => {} | ||
| }), | ||
| }) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something weird going on with the indentation here. Please ensure it follows the same format as other settings. |
||
| , | ||
|
|
||
| game.settings.register(MAESTRO.MODULE_NAME, MAESTRO.SETTINGS_KEYS.HypeTrack.restartHypeTracks, { | ||
| name: "MAESTRO.SETTINGS.restartHypeTracksN", | ||
| hint: "MAESTRO.SETTINGS.restartHypeTracksH", | ||
| scope: "world", | ||
| type: Boolean, | ||
| default: false, | ||
| config: true, | ||
| onChange: async s => {} | ||
| }), | ||
|
|
||
| /* -------------------------------------------- */ | ||
| /* Item Track */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please captialise the first letter of each translation key-part.
This should be
"SETTINGS.RestartHypeTracksN"