Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

"SETTINGS.HypeTrackEnableN": "Enable Hype Track",
"SETTINGS.HypeTrackEnableH": "Enable the ability to set a Track for an Actor",
"SETTINGS.restartHypeTracksN": "Restart Hype Track",
Copy link
Member

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"

"SETTINGS.restartHypeTracksH": "Enable the ability to restart a Track for an Actor instead of always running from the beginning",
"SETTINGS.HypeTrackPauseOthersN": "Pause Other Playlist Sounds (Hype Track)",
"SETTINGS.HypeTrackPauseOthersH": "Select to pause other Sounds (eg. music) while Hype Track is playing",
"SETTINGS.ItemTrackEnableN": "Enable Item Track",
Expand Down
5 changes: 3 additions & 2 deletions modules/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ export const SETTINGS_KEYS = {
get HypeTrack() {
return {
enable: "enableHypeTrack",
pauseOthers: "hypeTrackPauseOthers"
pauseOthers: "hypeTrackPauseOthers",
restartHypeTracks: "restartHypeTracks"
}
},

get CombatTrack() {
return {
enable: "enableCombatTrack",
Expand Down
7 changes: 3 additions & 4 deletions modules/hype-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default class HypeTrack {
this.playlist = null;
this.pausedSounds = [];
}

/* -------------------------------------------- */
/* Hook Handlers */
/* -------------------------------------------- */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call doesn't pass the playlist to pauseAllTracks, is that correct?

ui.playlists.render();
}

Expand Down
27 changes: 26 additions & 1 deletion modules/playback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as MAESTRO from "./config.js";

class PlaybackSettings{
Copy link
Member

Choose a reason for hiding this comment

The 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 game.maestro object. Eg. game.maestro.pausedTracks or similar.


static pauseDictionary = {}; // for hype tracks restarting handling
}

/**
* Get all the sounds in a specific playlist
Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use let instead of var for consistency sake

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use let instead of var for consistency sake

sounds.forEach(sound=>{
if(sound.playing)
{
PlaybackSettings.pauseDictionary[sound.id] = sound.sound.currentTime;
}
})}
await playlist.stopAll();
}

/**
Expand Down
15 changes: 13 additions & 2 deletions modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -31,7 +31,18 @@ export const registerModuleSettings = async function() {
default: false,
config: true,
onChange: async s => {}
}),
})
Copy link
Member

Choose a reason for hiding this comment

The 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 */
Expand Down