Skip to content

Commit

Permalink
#19
Browse files Browse the repository at this point in the history
- Add options for a background image and a completed segments image.
  • Loading branch information
Larkinabout committed Sep 2, 2022
1 parent f69c900 commit 6f7a846
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 82 deletions.
Binary file added images/clock-challenge-tracker.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 images/image-challenge-tracker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"showTooltip": "Show the challenge tracker to others",
"windowed": "Windowed",
"windowedTooltip": "Display the challenge tracker in a window",
"outerTitle": "Outer",
"outerTitle": "Outer Track",
"outerTotal": "Total Segments",
"outerTotalTooltip": "Set the number of segments on the outer ring",
"outerCurrent": "Current Segments",
Expand All @@ -43,7 +43,7 @@
"outerColorTooltip": "Set the hex color of the outer ring",
"outerBackgroundColor": "Background Color",
"outerBackgroundColorTooltip": "Set the background hex color of the outer ring",
"innerTitle": "Inner",
"innerTitle": "Inner Track",
"innerTotal": "Total Segments",
"innerTotalTooltip": "Set the number of segments on the inner circle",
"innerCurrent": "Current Segments",
Expand All @@ -52,6 +52,11 @@
"innerColorTooltip": "Set the hex color of the inner circle",
"innerBackgroundColor": "Background Color",
"innerBackgroundColorTooltip": "Set the background hex color of the inner circle",
"imageTitle": "Images",
"image": "Image",
"imageTooltip": "Set the image for the current segments",
"backgroundImage": "Background Image",
"backgroundImageTooltip": "Set the background image",
"frameTitle": "Frame",
"frameWidth": "Width",
"frameWidthTooltip": "Set the width of the frame",
Expand Down
10 changes: 2 additions & 8 deletions scripts/challenge-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,7 @@ Hooks.on('renderSceneControls', (controls, html) => {
})

/* Draw the challenge trackers once rendered */
Hooks.on('renderChallengeTracker', async () => {
Hooks.on('renderChallengeTracker', async (challengeTracker) => {
if (!game.challengeTracker) return
for (const challengeTracker of Object.values(game.challengeTracker)) {
if (challengeTracker._state === 1) {
challengeTracker.setVariables()
challengeTracker._draw()
challengeTracker.activateListenersPostDraw()
}
}
challengeTracker._draw()
})
7 changes: 5 additions & 2 deletions scripts/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ export class ChallengeTrackerEditForm extends FormApplication {
} else {
return {
challengeTracker: {
backgroundImage: null,
frameColor: null,
frameWidth: 'medium',
id: `${ChallengeTrackerSettings.id}-${Math.random().toString(16).slice(2)}`,
image: null,
innerBackgroundColor: null,
innerColor: null,
innerCurrent: 0,
Expand Down Expand Up @@ -252,10 +254,11 @@ export class ChallengeTrackerEditForm extends FormApplication {
const title = formData.title ?? game.i18n.localize('challengeTracker.labels.challengeTrackerTitle')
const persist = true
const id = challengeTrackerId
const listPosition = Object.keys(game.users.get(ownerId).data.flags['challenge-tracker']).length + 1
const listPosition = Object.keys(game.users.get(ownerId).data.flags['challenge-tracker'] || {}).length + 1
challengeTrackerOptions = foundry.utils.mergeObject(formData, { ownerId, id, listPosition, persist, title })
}
await ChallengeTrackerFlag.set(ownerId, challengeTrackerOptions)
await ChallengeTracker.draw(challengeTrackerOptions)
const challengeTracker = Object.values(game.challengeTracker).find(ct => ct.challengeTrackerOptions.id === challengeTrackerId)
if (challengeTracker) challengeTracker.draw(challengeTrackerOptions)
}
}
Loading

0 comments on commit 6f7a846

Please sign in to comment.