generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Persist challenge trackers across sessions using user flags. - Add forms to manage challenge trackers. - Add button on player list to open forms.
- Loading branch information
1 parent
bbff71a
commit b7a84d2
Showing
14 changed files
with
819 additions
and
199 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 +1,41 @@ | ||
{ | ||
"settings": { | ||
"allowShow" : { | ||
"name": "Show to Others", | ||
"hint": "Allow users with this role (and above) to show Challenge Trackers to others (Requires reload)" | ||
}, | ||
"outerColor" : { | ||
"name": "Outer Color", | ||
"hint": "Set the default color for the outer ring", | ||
"label": "Color Picker" | ||
}, | ||
"innerColor" : { | ||
"name": "Inner Color", | ||
"hint": "Set the default color for the inner circle", | ||
"label": "Color Picker" | ||
}, | ||
"frameColor" : { | ||
"name": "Frame Color", | ||
"hint": "Set the default color of the frame", | ||
"label": "Color Picker" | ||
}, | ||
"size" : { | ||
"name": "Size", | ||
"hint": "Set the default size of the challenge tracker in pixels" | ||
}, | ||
"windowed" : { | ||
"name": "Windowed", | ||
"hint": "Set the challenge tracker to windowed by default" | ||
}, | ||
"scroll" : { | ||
"name": "Scroll", | ||
"hint": "Enable the scroll wheel for increasing/decreasing segments" | ||
} | ||
} | ||
"challengeTracker": { | ||
"labels": { | ||
"challengeTrackerTitle": "Challenge Tracker", | ||
"challengeTrackerButtonTitle": "Challenge Tracker" | ||
}, | ||
"settings": { | ||
"allowShow" : { | ||
"name": "Show to Others", | ||
"hint": "Allow users with this role (and above) to show Challenge Trackers to others (Requires reload)" | ||
}, | ||
"outerColor" : { | ||
"name": "Outer Color", | ||
"hint": "Set the default color for the outer ring", | ||
"label": "Color Picker" | ||
}, | ||
"innerColor" : { | ||
"name": "Inner Color", | ||
"hint": "Set the default color for the inner circle", | ||
"label": "Color Picker" | ||
}, | ||
"frameColor" : { | ||
"name": "Frame Color", | ||
"hint": "Set the default color of the frame", | ||
"label": "Color Picker" | ||
}, | ||
"size" : { | ||
"name": "Size", | ||
"hint": "Set the default size of the challenge tracker in pixels" | ||
}, | ||
"windowed" : { | ||
"name": "Windowed", | ||
"hint": "Set the challenge tracker to windowed by default" | ||
}, | ||
"scroll" : { | ||
"name": "Scroll", | ||
"hint": "Enable the scroll wheel for increasing/decreasing segments" | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { ChallengeTrackerSettings, ChallengeTracker } from './main.js' | ||
import { ChallengeTrackerForm } from './form.js' | ||
|
||
export class ChallengeTrackerFlag { | ||
/** | ||
* Get list of flags by user | ||
* @param {string} userId User that created the flags | ||
**/ | ||
static getList (userId) { | ||
const challengeTrackerList = [] | ||
if (!game.users.get(userId)?.data.flags['challenge-tracker']) return | ||
const flagKeys = Object.keys(game.users.get(userId)?.data.flags['challenge-tracker']) | ||
for (const flagKey of flagKeys) { | ||
challengeTrackerList.push(game.users.get(userId)?.getFlag(ChallengeTrackerSettings.id, flagKey)) | ||
} | ||
return challengeTrackerList | ||
} | ||
|
||
/** | ||
* Get flag by owner and Challenge Tracker | ||
* @param {string} ownerId User that owns the flag | ||
* @param {string} challengeTrackerId Unique identifier for the Challenge Tracker | ||
**/ | ||
static get (ownerId, challengeTrackerId) { | ||
if (!game.users.get(ownerId)?.data.flags['challenge-tracker']) return | ||
const flagKey = Object.keys(game.users.get(ownerId)?.data.flags['challenge-tracker']).find(ct => ct === challengeTrackerId) | ||
if (!flagKey) return | ||
const challengeTracker = game.users.get(ownerId)?.getFlag(ChallengeTrackerSettings.id, flagKey) | ||
return challengeTracker | ||
} | ||
|
||
/** | ||
* Set flag by owner and Challenge Tracker. Used to create a challenge tracker. | ||
* @param {string} ownerId User that owns the flag | ||
* @param {array} challengeTrackerOptions Challenge Tracker Options | ||
* @param {string} challengeTrackerOptions.frameColor Hex color of the frame | ||
* @param {string} challengeTrackerOptions.id Unique identifier of the challenge tracker | ||
* @param {string} challengeTrackerOptions.innerColor Hex color of the inner circle | ||
* @param {number} challengeTrackerOptions.innerCurrent Number of filled segments of the inner circle | ||
* @param {number} challengeTrackerOptions.innerTotal Number of segments for the inner circle | ||
* @param {string} challengeTrackerOptions.outerColor Hex color of the outer ring | ||
* @param {number} challengeTrackerOptions.outerCurrent Number of filled segments of the outer ring | ||
* @param {number} challengeTrackerOptions.outerTotal Number of segments for the outer ring | ||
* @param {boolean} challengeTrackerOptions.persist true = Persist, false = Do not persist | ||
* @param {boolean} challengeTrackerOptions.show true = Show, false = Hide | ||
* @param {number} challengeTrackerOptions.size Size of the challenge tracker in pixels | ||
* @param {string} challengeTrackerOptions.title Title of the challenge tracker | ||
* @param {boolean} challengeTrackerOptions.windowed true = Windowed, false = Windowless | ||
**/ | ||
static async set (ownerId, challengeTrackerOptions) { | ||
await game.users.get(ownerId)?.setFlag(ChallengeTrackerSettings.id, challengeTrackerOptions.id, challengeTrackerOptions) | ||
ChallengeTrackerForm.challengeTrackerForm?.render(false, { width: 'auto', height: 'auto' }) | ||
} | ||
|
||
/** | ||
* Unset flag by owner and Challenge Tracker. Used to delete a challenge tracker. | ||
* @param {string} ownerId User that owns the flag | ||
* @param {string} challengeTrackerId Unique identifier for the Challenge Tracker | ||
**/ | ||
static async unset (ownerId, challengeTrackerId) { | ||
const flagKey = Object.keys(game.users.get(ownerId)?.data.flags['challenge-tracker']).find(ct => ct === challengeTrackerId) | ||
if (!flagKey) { | ||
ui.notifications.error(`Challenge Tracker '${challengeTrackerId}' does not exist.`) | ||
return | ||
} | ||
const deletedFlag = game.users.get(ownerId)?.unsetFlag(ChallengeTrackerSettings.id, challengeTrackerId) | ||
ui.notifications.info(`Challenge Tracker '${challengeTrackerId}' deleted.`) | ||
return deletedFlag | ||
} | ||
} |
Oops, something went wrong.