Skip to content

Commit

Permalink
fix(settings): correct filepickers
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrycu committed Jul 14, 2021
1 parent 4cc1c95 commit 317af5f
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 103 deletions.
3 changes: 3 additions & 0 deletions ffg-star-wars-enhancements.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Hooks.once('init', async function() {
case "in":
bool = b.indexOf(a) > 0;
break;
case "not in":
bool = b.indexOf(a) < 0;
break;
case "contains":
if (a && b) {
bool = a.includes(b);
Expand Down
26 changes: 13 additions & 13 deletions scripts/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'video',
default: base_path + '/Library/Generic/Weapon_Attacks/Melee/LaserSword01_01_Regular_Blue_800x600.webm',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-brawl-sound", {
Expand All @@ -44,7 +44,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'modules/ffg-star-wars-enhancements/audio/brawl.mp3',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-lightsaber-animation", {
Expand All @@ -53,7 +53,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'video',
default: base_path + '/Library/Generic/Weapon_Attacks/Melee/LaserSword01_01_Regular_Blue_800x600.webm',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-lightsaber-sound", {
Expand All @@ -62,7 +62,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'modules/ffg-star-wars-enhancements/audio/lightsaber.mp3',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-melee-animation", {
Expand All @@ -71,7 +71,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'video',
default: base_path + '/Library/Generic/Weapon_Attacks/Melee/Sword01_01_Regular_White_800x600.webm',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-melee-sound", {
Expand All @@ -80,7 +80,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'modules/ffg-star-wars-enhancements/audio/melee.mp3',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-gunnery-animation", {
Expand All @@ -89,7 +89,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'video',
default: base_path + '/Library/Generic/Weapon_Attacks/Ranged/LaserShot_01_Regular_Green_30ft_1600x400.webm',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-gunnery-sound", {
Expand All @@ -98,7 +98,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'modules/ffg-star-wars-enhancements/audio/gunnery.mp3',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-ranged-heavy-animation", {
Expand All @@ -107,7 +107,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'video',
default: base_path + '/Library/Generic/Weapon_Attacks/Ranged/LaserShot_01_Regular_Blue_30ft_1600x400.webm',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-ranged-heavy-sound", {
Expand All @@ -116,7 +116,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'modules/ffg-star-wars-enhancements/audio/blaster_heavy.mp3',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-ranged-light-animation", {
Expand All @@ -125,7 +125,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'video',
default: base_path + '/Library/Generic/Weapon_Attacks/Ranged/LaserShot_01_Regular_Red_30ft_1600x400.webm',
});
game.settings.register("ffg-star-wars-enhancements", "attack-animation-ranged-light-sound", {
Expand All @@ -134,7 +134,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'modules/ffg-star-wars-enhancements/audio/blaster.mp3',
});
log('attack_animation', 'Initialized');
Expand Down Expand Up @@ -328,7 +328,7 @@ class attack_animation_UISettings extends FormApplication {
id: "data-importer",
classes: ["starwarsffg", "data-import"],
title: `${game.i18n.localize("SWFFG.UISettingsLabel")}`,
template: "modules/ffg-star-wars-enhancements/templates/settings_attack_animations.html",
template: "modules/ffg-star-wars-enhancements/templates/settings.html",
});
}

Expand Down
6 changes: 3 additions & 3 deletions scripts/opening_crawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function init() {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: "",
});
game.settings.register("ffg-star-wars-enhancements", "opening-crawl-logo", {
Expand All @@ -37,7 +37,7 @@ export function init() {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'folder',
default: "",
});
game.settings.register("ffg-star-wars-enhancements", "opening-crawl-music-delay", {
Expand Down Expand Up @@ -360,7 +360,7 @@ class opening_crawl_UISettings extends FormApplication {
id: "data-importer",
classes: ["starwarsffg", "data-import"],
title: `${game.i18n.localize("SWFFG.UISettingsLabel")}`,
template: "modules/ffg-star-wars-enhancements/templates/settings_opening_crawl.html",
template: "modules/ffg-star-wars-enhancements/templates/settings.html",
});
}

Expand Down
17 changes: 9 additions & 8 deletions scripts/shop.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ class Shop {
/* build the raw item array */
for (let i = 0; i < this.compendiums.length; i++) {
try {
let compendium_items = await game.packs.get(this.compendiums[i]).getData();
for (let x = 0; x < compendium_items['index'].length; x++) {
let compendium_items = await game.packs.get(this.compendiums[i]).getDocuments();
for (let x = 0; x < compendium_items.length; x++) {
possible_items_raw.push({
'compendium': this.compendiums[i],
'item': compendium_items['index'][x],
'item': compendium_items[x],
});
}
} catch ( e ) {
Expand Down Expand Up @@ -304,7 +304,7 @@ class Shop {
Helper function to return a list of actors owned by players
*/
async function get_player_actors() {
let actors = game.actors.entries;
let actors = game.actors.filter(actor => actor);
let pcs = []
for (let i = 0; i < actors.length; i++) {
if (actors[i].hasPlayerOwner === true) {
Expand Down Expand Up @@ -431,13 +431,14 @@ class ShopGenerator extends FormApplication {
vendor.setFlag("ffg-star-wars-enhancements", "vendor-data", flag_data);

// actually delete the old items
await vendor.deleteEmbeddedEntity(
"OwnedItem",
await vendor.deleteEmbeddedDocuments(
"Item",
to_delete,
);
console.log(to_create)
// actually create the new items
await vendor.createEmbeddedEntity(
"OwnedItem",
await vendor.createEmbeddedDocuments(
"Item",
to_create,
);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/talent_checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function init () {
scope: "world",
config: false,
type: String,
valueType: "FilePicker",
filePicker: 'audio',
default: 'icons/svg/regen.svg',
});
log(module_name, 'Done initializing');
Expand Down Expand Up @@ -110,7 +110,7 @@ class talent_checker_UISettings extends FormApplication {
id: "talent-checker",
classes: ["starwarsffg", "data-import"],
title: `${game.i18n.localize("ffg-star-wars-enhancements.talent-checker.title")}`,
template: "modules/ffg-star-wars-enhancements/templates/settings_attack_animations.html",
template: "modules/ffg-star-wars-enhancements/templates/settings.html",
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<div class="form-group">
<label>
{{#iff 'animation' 'in' this.key}}
<i class="fas fa-video"></i>
{{#iff 'sound' 'not in' this.key}}
<i class="fas fa-video"></i>
{{/iff}}
{{/iff}}
{{#iff 'sound' 'in' this.key}}
<i class="fas fa-volume-up"></i>
Expand All @@ -25,21 +27,24 @@
step="{{ this.range.step }}" type="range" value="{{ this.value }}"/>
<span class="range-value">{{this.value}}</span>

{{else if this.isFilePicker}}
{{else if this.filePicker}}
<button class="file-picker" data-target="path" data-type="
{{~#iff 'animation' 'in' this.key~}}
{{~#iff 'sound' 'not in' this.key~}}
video
{{~/iff~}}
{{~/iff~}}
{{~#iff 'sound' 'in' this.key~}}
audio
{{~/iff~}}
{{~#iff 'music' 'in' this.key~}}
audio
{{~/iff~}}
" title="Browse Files" type="button">...</button>
<input data-dtype="{{this.type}}" name="{{this.module}}.{{this.key}}" type="text" value="{{this.value}}"/>
<button class="filepicker" type="button">...</button>

{{else}}
<input data-dtype="{{this.type}}" name="{{this.module}}.{{this.key}}" type="text" value="{{this.value}}"/>
{{#iff this.type '==' 'setting_image'}}
<button class="file-picker" data-target="{{this.module}}.{{this.key}}" data-type="image" type="button">
<i class="fas fa-file-import"></i>
</button>
{{/iff}}
{{#iff this.type '==' 'setting_audio'}}
<button class="file-picker" data-target="{{this.module}}.{{this.key}}" data-type="audio" type="button">
<i class="fas fa-file-import"></i>
</button>
{{/iff}}
{{/if}}
</div>

Expand Down
64 changes: 0 additions & 64 deletions templates/settings_opening_crawl.html

This file was deleted.

0 comments on commit 317af5f

Please sign in to comment.