Skip to content

Commit

Permalink
Merge pull request #84 from napolitanod/1.7.0
Browse files Browse the repository at this point in the history
1.7.0
  • Loading branch information
napolitanod committed May 29, 2023
2 parents bb00e9b + 0fd8104 commit f802c7e
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 43 deletions.
14 changes: 13 additions & 1 deletion languages/en.json
Expand Up @@ -20,6 +20,7 @@
"ms": "ms",
"none": "None",
"play": "Play",
"preview": "Preview",
"ratio": "(Ratio)",
"save": "Save",
"sec": "sec",
Expand Down Expand Up @@ -59,6 +60,11 @@
"target": "Copy To",
"zone": "Zone"
},
"doorStates":{
"closed": "Closed",
"open": "Open",
"locked": "Locked"
},
"edit-form": {
"actor.label": "Actor",
"allInArea.label": "Danger Targets All Tokens",
Expand Down Expand Up @@ -347,7 +353,9 @@
"restrictions":{
"none": "None",
"limited": "Limited",
"normal": "Normal"
"normal": "Normal",
"proximity": "Proximity",
"distance": "Reverse Proximity"
},
"scene": {
"add-danger-zone": "Add danger zone",
Expand Down Expand Up @@ -958,6 +966,9 @@
"wall":{
"bottom.label": "Wall on Bottom",
"description": "Add walls or doors around the perimeter of the targeted area.",
"doorOptions.label": "Door Options",
"doorSound.label": "Door Sound",
"doorState.label": "Door State",
"direction.label": "Wall Direction",
"door.label": "Is Door?",
"label": "Walls",
Expand All @@ -971,6 +982,7 @@
"sight.label": "Sight Restriction",
"tag.label": "Tag",
"tag.description": "Tagger tag",
"thresholdAttenuation.label": "Proximity Threshold Attenuation",
"top.label": "Wall on Top"
},
"warpgate": {
Expand Down
10 changes: 5 additions & 5 deletions module.json
Expand Up @@ -19,9 +19,9 @@
}
],
"compatibility": {
"minimum": "10",
"verified": "10",
"maximum": "10"
"minimum": "11",
"verified": "11",
"maximum": "11"
},
"id": "danger-zone",
"esmodules": [
Expand All @@ -34,8 +34,8 @@
"styles/danger-zone.css"
],
"title": "Danger Zone",
"version": "1.6.12.6",
"version": "1.7.0",
"url": "https://github.com/napolitanod/Danger-Zone",
"manifest": "https://raw.githubusercontent.com/napolitanod/Danger-Zone/master/module.json",
"download": "https://github.com/napolitanod/Danger-Zone/releases/download/1.6.12.6/module.zip"
"download": "https://github.com/napolitanod/Danger-Zone/releases/download/1.7.0/module.zip"
}
27 changes: 24 additions & 3 deletions scripts/apps/constants.js
Expand Up @@ -260,6 +260,18 @@ export const ITEMTARGET = {

export const DAEDuration = daeOn ? DAE.daeSpecialDurations() : {}

export const DOORSTATES = {
0: "DANGERZONE.doorStates.closed",
1: "DANGERZONE.doorStates.open",
2: "DANGERZONE.doorStates.locked"
}

export const FVTTDOORSTATES = {
0: 0,
1: 1,
2: 2
}

export function actorOps(){
return game.actors.reduce((obj, a) => {obj['']=''; obj[a.id] = a.name; return obj;}, {})
}
Expand All @@ -281,13 +293,18 @@ export const FVTTMOVETYPES = {
export const SENSETYPES = {
0: "DANGERZONE.restrictions.none",
2: "DANGERZONE.restrictions.limited",
1: "DANGERZONE.restrictions.normal"
1: "DANGERZONE.restrictions.normal",
3: "DANGERZONE.restrictions.proximity",
4: "DANGERZONE.restrictions.distance",

}

export const FVTTSENSETYPES = {
0: 0,
1: 20,
2: 10
2: 10,
3: 30,
4: 40
}

export function dirTypes(){
Expand Down Expand Up @@ -325,7 +342,11 @@ export function determineMacroList() {
export function saveTypes() {
switch(game.world.system){
case "dnd5e":
return game.dnd5e.config.abilities
const saveEntries = {};
for ( let [k, v] of Object.entries(game.dnd5e.config.abilities) ) {
saveEntries[k] = v.label;
}
return saveEntries;
default:
return {}
}
Expand Down
77 changes: 62 additions & 15 deletions scripts/apps/danger-form.js
@@ -1,7 +1,7 @@
import {dangerZone} from "../danger-zone.js";
import {dangerZoneType} from './zone-type.js';
import {activeEffectOn, daeOn, fluidCanvasOn, fxMasterOn, itemPileOn, midiQolOn, monksActiveTilesOn, perfectVisionOn, sequencerOn, socketLibOn, taggerOn, timesUpOn, tokenSaysOn, warpgateOn} from '../index.js';
import {actorOps, AMBIENTLIGHTCLEAROPS, animationTypes, COMBATINITIATIVE, DAMAGEONSAVE, damageTypes, DANGERZONELIGHTREPLACE, DANGERZONEREPLACE, DANGERZONESOUNDREPLACE, DANGERZONEWEATHERREPLACE, ITEMTARGET, TRIGGEROPERATION, DANGERZONEWALLREPLACE, determineMacroList, dirTypes, doorTypes, ELEVATIONMOVEMENT, FLUIDCANVASTYPES, getCompendiumOps, HORIZONTALMOVEMENT, MOVETYPES, SAVERESULT, saveTypes, SCENEFOREGROUNDELEVATIONMOVEMENT, SCENEGLOBALILLUMINATION, SENSETYPES, SOURCEDANGERLOCATION, SOURCETREATMENT, STRETCH, TILESBLOCK, TILEOCCLUSIONMODES, TIMESUPMACROREPEAT, TOKENDISPOSITION, TOKENSAYSTYPES, VERTICALMOVEMENT, WALLSBLOCK, weatherTypes, weatherParameters} from './constants.js';
import {actorOps, AMBIENTLIGHTCLEAROPS, animationTypes, COMBATINITIATIVE, DAMAGEONSAVE, damageTypes, DANGERZONELIGHTREPLACE, DANGERZONEREPLACE, DANGERZONESOUNDREPLACE, DANGERZONEWEATHERREPLACE, DOORSTATES, ITEMTARGET, TRIGGEROPERATION, DANGERZONEWALLREPLACE, determineMacroList, dirTypes, doorTypes, ELEVATIONMOVEMENT, FLUIDCANVASTYPES, getCompendiumOps, HORIZONTALMOVEMENT, MOVETYPES, SAVERESULT, saveTypes, SCENEFOREGROUNDELEVATIONMOVEMENT, SCENEGLOBALILLUMINATION, SENSETYPES, SOURCEDANGERLOCATION, SOURCETREATMENT, STRETCH, TILESBLOCK, TILEOCCLUSIONMODES, TIMESUPMACROREPEAT, TOKENDISPOSITION, TOKENSAYSTYPES, VERTICALMOVEMENT, WALLSBLOCK, weatherTypes, weatherParameters} from './constants.js';
import {stringToObj} from './helpers.js';

export class DangerForm extends FormApplication {
Expand Down Expand Up @@ -357,21 +357,45 @@ class DangerZoneActiveEffectForm extends ActiveEffectConfig {
const defaults = super.defaultOptions;

return foundry.utils.mergeObject(defaults, {
height: "600px",
title : game.i18n.localize("DANGERZONE.zone-active-effect-form.form-name")
sheetConfig: false,
height: "600px"
});
}

get title() {
const reference = this.document.name ? ` ${this.document.name}` : "";
return `${game.i18n.localize("DANGERZONE.zone-active-effect-form.form-name")}${reference}`;
}

getData(options) {
const d = this.parent.data
const data = {
changes: d.changes ?? [],
description: d.description ?? "",
disabled: d.disabled ?? false,
duration: d.duration ?? {},
flags: d.flags ?? {},
icon: d.icon,
isSuppressed: false,
name: d.name ?? d.label ?? "",
origin: this.origin,
tint: d.tint,
transfer: true
}
return {
data: this.object,
cssClass: "editable",
data: data,
editable: true,
isActorEffect: true,
isItemEffect: false,
limited: false,
owner: true,
submitText: "EFFECT.Submit",
modes: Object.entries(CONST.ACTIVE_EFFECT_MODES).reduce((obj, e) => {
obj[e[1]] = game.i18n.localize("EFFECT.MODE_"+e[0]);
return obj;
}, {})
}, {}),
title: this.title
};
}

Expand All @@ -382,6 +406,7 @@ class DangerZoneActiveEffectForm extends ActiveEffectConfig {
activateListeners(html) {
super.activateListeners(html);
}


_onEffectControl(event) {
event.preventDefault();
Expand Down Expand Up @@ -470,15 +495,10 @@ class DangerZoneDangerFormActiveEffect extends FormApplication {
}

async _activeEffectConfig(event, eventParent) {
if (!this.data.hasOwnProperty('label')){
const zoneName = $(this.parent.form).find('input[name="name"]').val();
const icon = $(this.parent.form).find('input[name="icon"]').val();
if (!this.data.hasOwnProperty('name') && !this.data.hasOwnProperty('label')){
this.data = {
label: zoneName,
icon: icon,
changes: [],
disabled: false,
transfer: false,
name: $(this.parent.form).find('input[name="name"]').val(),
icon: $(this.parent.form).find('input[name="icon"]').val(),
origin: this.parent.dangerId
}
}
Expand All @@ -491,7 +511,7 @@ class DangerZoneDangerFormActiveEffect extends FormApplication {
isOwner: true,
uuid: `ActiveEffect.${this.parent.dangerId}`
});

new DangerZoneActiveEffectForm(this, eventParent, this.parent.dangerId, effect).render(true);
}

Expand Down Expand Up @@ -1433,6 +1453,12 @@ class DangerZoneDangerFormWall extends FormApplication {
getData(options) {
return {
data: this.data,
doorSounds: CONFIG.Wall.doorSounds,
doorStates: DOORSTATES,
suppressDoorOptions: this.data.door ? false : true,
suppressLightProx : this._notProximity(this.data.light),
suppressSenseProx : this._notProximity(this.data.sense),
suppressSoundProx : this._notProximity(this.data.sound),
moveTypes: MOVETYPES,
senseTypes: SENSETYPES,
dirTypes: dirTypes(),
Expand All @@ -1441,9 +1467,30 @@ class DangerZoneDangerFormWall extends FormApplication {
}

activateListeners(html) {
html.on('change', "[data-action]", this._handleChange.bind(this));
super.activateListeners(html);
}


async _handleChange(event) {
const changedElement = $(event.currentTarget);
const action = changedElement.data().action;
switch(action){
case "door":
this.form.querySelector(".door-options").classList.toggle("hidden", event.currentTarget.value === '0' ? true : false)
this.setPosition({height: "auto"});
break;
case "light":
case "sense":
case "sound":
this.form.querySelector(`.${action}-proximity`).classList.toggle("hidden", this._notProximity(event.currentTarget.value))
break;
}
}

_notProximity(test){
return Number(test) < 3
}

async _updateObject(event, formData) {
const expandedData = foundry.utils.expandObject(formData);
this.parent.wall = expandedData;
Expand Down
23 changes: 21 additions & 2 deletions scripts/apps/workflow.js
Expand Up @@ -1142,7 +1142,12 @@ class activeEffect extends executable {
}

get effect(){
return this._part
const obj = this._part
if(obj.hasOwnProperty('label')) {
obj.name = obj.label;
delete obj.label;
}
return obj
}

get flag(){
Expand Down Expand Up @@ -2981,6 +2986,14 @@ class wall extends executable {
return this._part.door
}

get doorSound(){
return this._part.doorSound
}

get ds(){
return this._part.ds ?? 0
}

get has(){
return (super.has && (this.top || this.right || this.bottom || this.left)) ? true : false
}
Expand Down Expand Up @@ -3017,6 +3030,10 @@ class wall extends executable {
return FVTTSENSETYPES[this._part.sound]
}

get threshold(){
return this._part.threshold ?? {}
}

get top(){
return this._part.top
}
Expand Down Expand Up @@ -3045,11 +3062,13 @@ class wall extends executable {
c:[start.x, start.y, end.x, end.y],
dir: this.dir,
door: this.door,
ds: 0,
doorSound: this.doorSound,
ds: this.ds,
move: this.move,
sight: this.sense,
sound: this.sound,
light: this.light,
threshold: this.threshold,
flags: this.data.flag
}
if(wallHeightOn && (this.data.boundary.bottom || this.data.boundary.top)) wall.flags['wallHeight'] = {"wallHeightTop": this.data.boundary.top-1, "wallHeightBottom": this.data.boundary.bottom}
Expand Down
10 changes: 9 additions & 1 deletion scripts/apps/zone-type.js
Expand Up @@ -194,6 +194,8 @@ export class dangerZoneType {
bottom:false,
dir: 0,
door: 0,
doorSound: undefined,
ds: 0,
left: false,
light: 1,
move: 1,
Expand All @@ -202,7 +204,13 @@ export class dangerZoneType {
sense: 1,
sound: 1,
tag: '',
top: false
top: false,
threshold: {
attenuation: false,
light: null,
sight: null,
sound: null
}
},
macro: ''
}
Expand Down
11 changes: 5 additions & 6 deletions scripts/index.js
Expand Up @@ -351,9 +351,8 @@ Hooks.on('renderSceneControls', async(app, html, options) => {
}
});


Hooks.on("renderSidebarTab", async(app, html) => {
addQuickZonesLaunch(app, html);
Hooks.on("changeSidebarTab", async(app) => {
addQuickZonesLaunch(app);
});

/**
Expand Down Expand Up @@ -507,14 +506,14 @@ function insertWallClearButton (controls, b, c) {
}
}

export function addQuickZonesLaunch(app, html) {
if (game.user.isGM && app.options.id == "scenes" && game.settings.get('danger-zone', 'types-button-display') === true) {
export function addQuickZonesLaunch(app) {
if (game.user.isGM && app.id == "scenes" && game.settings.get('danger-zone', 'types-button-display') === true) {
let button = $('<div class="header-actions action-buttons flexrow"><button class="danger-zone-types-launcher"><i class="fas fa-radiation"></i> ' + game.i18n.localize("DANGERZONE.setting.danger-zone-types-config.name")+ '</button></div>');

button.click(async () => {
dangerZone.DangerZoneTypesForm.render(true);
});
$(html).find(".directory-footer").append(button);
if(!$(app.element).find(".danger-zone-types-launcher")?.length) {$(app.element).find(".directory-footer").append(button);}
}
}

Expand Down
6 changes: 5 additions & 1 deletion styles/danger-zone.css
Expand Up @@ -279,7 +279,7 @@ form.danger-zone-type-form .main-danger {
/*hotbar*/
.danger-zone-hotbar-trigger {
position: absolute;
left: 570px;
right: 160px;
bottom: 11px;
list-style: none;
border-width: 0px;
Expand Down Expand Up @@ -673,3 +673,7 @@ form ol.danger-setting-group .active:hover label {
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: none;
}

form .form-group .form-fields input.danger-zone-proximity {
flex: 0 0 48px;
}

0 comments on commit f802c7e

Please sign in to comment.