|
@@ -1,11 +1,87 @@ |
|
|
|
|
|
/** |
|
|
|
|
|
* Default wall types (walls can be other combinations of vision/movement restriction too) |
|
|
|
|
|
* @readonly |
|
|
|
|
|
* @enum {number} |
|
|
|
|
|
*/ |
|
|
|
|
|
var FOUNDRY_DOOR_TYPES = { |
|
|
|
|
|
WALL: 0, |
|
|
|
|
|
TERRAIN: 1, |
|
|
|
|
|
INVISIBLE: 2, |
|
|
|
|
|
ETHEREAL: 3, |
|
|
|
|
|
DOOR: 4, |
|
|
|
|
|
SECRETDOOR: 5, |
|
|
|
|
|
OTHER: -1 |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Determine what default wall type a Wall object matches, if any |
|
|
|
|
|
* @param {object} wall - the wall to query |
|
|
|
|
|
* @return {number} wall_type - a member of FOUNDRY_DOOR_TYPES |
|
|
|
|
|
*/ |
|
|
|
|
|
function determineWallType(wall) { |
|
|
|
|
|
let move = wall.data.move; |
|
|
|
|
|
let sense = wall.data.sense; |
|
|
|
|
|
let door = wall.data.door; |
|
|
|
|
|
|
|
|
|
|
|
if (move === CONST.WALL_MOVEMENT_TYPES.NORMAL |
|
|
|
|
|
&& sense === CONST.WALL_SENSE_TYPES.NORMAL |
|
|
|
|
|
&& door === CONST.WALL_DOOR_TYPES.NONE) { |
|
|
|
|
|
return FOUNDRY_DOOR_TYPES.WALL; } |
|
|
|
|
|
|
|
|
|
|
|
else if (move === CONST.WALL_MOVEMENT_TYPES.NORMAL |
|
|
|
|
|
&& sense === CONST.WALL_SENSE_TYPES.LIMITED |
|
|
|
|
|
&& door === CONST.WALL_DOOR_TYPES.NONE) { |
|
|
|
|
|
return FOUNDRY_DOOR_TYPES.TERRAIN; } |
|
|
|
|
|
|
|
|
|
|
|
else if (move === CONST.WALL_MOVEMENT_TYPES.NORMAL |
|
|
|
|
|
&& sense === CONST.WALL_SENSE_TYPES.NONE |
|
|
|
|
|
&& door === CONST.WALL_DOOR_TYPES.NONE) { |
|
|
|
|
|
return FOUNDRY_DOOR_TYPES.INVISIBLE; } |
|
|
|
|
|
|
|
|
|
|
|
else if (move === CONST.WALL_MOVEMENT_TYPES.NONE |
|
|
|
|
|
&& sense === CONST.WALL_SENSE_TYPES.NORMAL |
|
|
|
|
|
&& door === CONST.WALL_DOOR_TYPES.NONE) { |
|
|
|
|
|
return FOUNDRY_DOOR_TYPES.ETHEREAL } |
|
|
|
|
|
|
|
|
|
|
|
else if (move === CONST.WALL_MOVEMENT_TYPES.NORMAL |
|
|
|
|
|
&& sense === CONST.WALL_SENSE_TYPES.NORMAL |
|
|
|
|
|
&& door === CONST.WALL_DOOR_TYPES.DOOR) { |
|
|
|
|
|
return FOUNDRY_DOOR_TYPES.DOOR; } |
|
|
|
|
|
|
|
|
|
|
|
else if (move === CONST.WALL_MOVEMENT_TYPES.NORMAL |
|
|
|
|
|
&& sense === CONST.WALL_SENSE_TYPES.NORMAL |
|
|
|
|
|
&& door === CONST.WALL_DOOR_TYPES.SECRET) { |
|
|
|
|
|
return FOUNDRY_DOOR_TYPES.SECRETDOOR; } |
|
|
|
|
|
|
|
|
|
|
|
else { return FOUNDRY_DOOR_TYPES.OTHER; } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
/** @constant {string} */ |
|
|
WALLCOLOUR = "#111111"; |
|
|
|
|
|
|
|
|
MODULENAME = "foundry-walls-to-drawing"; |
|
|
|
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
|
|
|
WALLCOLOUR = "#111111"; |
|
|
/** @constant {number} */ |
|
|
/** @constant {number} */ |
|
|
WALLWIDTH = "4"; |
|
|
WALLWIDTH = "4"; |
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
/** @constant {string} */ |
|
|
MODULENAME = "foundry-walls-to-drawing"; |
|
|
|
|
|
|
|
|
TERRAINCOLOUR = "#116611"; |
|
|
|
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
|
|
|
INVISIBLECOLOUR = "#006666"; |
|
|
|
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
|
|
|
ETHEREALCOLOUR = "#CC00CC"; |
|
|
|
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
|
|
|
//DOORCOLOUR = "#CC9900"; |
|
|
|
|
|
DOORCOLOUR = "#3333FF"; |
|
|
|
|
|
|
|
|
|
|
|
/** @constant {string} */ |
|
|
|
|
|
SECRETDOORCOLOUR = "#CC0000"; |
|
|
|
|
|
|
|
|
|
|
|
/** constant {string} */ |
|
|
|
|
|
let BLACK = "#000000"; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Set up configuration options |
|
|
* Set up configuration options |
|
@@ -20,6 +96,51 @@ Hooks.on("init", () => { |
|
|
hint: "Enter a hexadecimal colour, eg #FF0000 for red" |
|
|
hint: "Enter a hexadecimal colour, eg #FF0000 for red" |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
game.settings.register(MODULENAME, "cvTerrainColour", { |
|
|
|
|
|
name: "Converted Terrain Wall Colour", |
|
|
|
|
|
default: TERRAINCOLOUR, |
|
|
|
|
|
type: String, |
|
|
|
|
|
scope: "client", |
|
|
|
|
|
config: true, |
|
|
|
|
|
hint: "Enter a hexadecimal colour, eg #FF0000 for red" |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
game.settings.register(MODULENAME, "cvInvisibleColour", { |
|
|
|
|
|
name: "Converted Invisible Wall Colour", |
|
|
|
|
|
default: INVISIBLECOLOUR, |
|
|
|
|
|
type: String, |
|
|
|
|
|
scope: "client", |
|
|
|
|
|
config: true, |
|
|
|
|
|
hint: "This only takes effect if rendering invisible walls" |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
game.settings.register(MODULENAME, "cvEtherealColour", { |
|
|
|
|
|
name: "Converted Ethereal Wall Colour", |
|
|
|
|
|
default: ETHEREALCOLOUR, |
|
|
|
|
|
type: String, |
|
|
|
|
|
scope: "client", |
|
|
|
|
|
config: true, |
|
|
|
|
|
hint: "This only takes effect if rendering ethereal walls" |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
game.settings.register(MODULENAME, "cvDoorColour", { |
|
|
|
|
|
name: "Converted Door Colour", |
|
|
|
|
|
default: DOORCOLOUR, |
|
|
|
|
|
type: String, |
|
|
|
|
|
scope: "client", |
|
|
|
|
|
config: true, |
|
|
|
|
|
hint: "This only takes effect if rendering secret doors" |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
game.settings.register(MODULENAME, "cvSecretDoorColour", { |
|
|
|
|
|
name: "Converted Secret Door Colour", |
|
|
|
|
|
default: SECRETDOORCOLOUR, |
|
|
|
|
|
type: String, |
|
|
|
|
|
scope: "client", |
|
|
|
|
|
config: true, |
|
|
|
|
|
hint: "This only takes effect if rendering doors" |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
game.settings.register(MODULENAME, "cvWallWidth", { |
|
|
game.settings.register(MODULENAME, "cvWallWidth", { |
|
|
name: "Converted Wall Width", |
|
|
name: "Converted Wall Width", |
|
|
default: WALLWIDTH, |
|
|
default: WALLWIDTH, |
|
@@ -36,6 +157,11 @@ Hooks.on("init", () => { |
|
|
|
|
|
|
|
|
Hooks.on('getSceneControlButtons', controls => { |
|
|
Hooks.on('getSceneControlButtons', controls => { |
|
|
cvWallColour = game.settings.get(MODULENAME, "cvWallColour"); |
|
|
cvWallColour = game.settings.get(MODULENAME, "cvWallColour"); |
|
|
|
|
|
cvTerrainColour = game.settings.get(MODULENAME, "cvTerrainColour"); |
|
|
|
|
|
cvInvisibleColour = game.settings.get(MODULENAME, "cvInvisibleColour"); |
|
|
|
|
|
cvEtherealColour = game.settings.get(MODULENAME, "cvEtherealColour"); |
|
|
|
|
|
cvDoorColour = game.settings.get(MODULENAME, "cvDoorColour"); |
|
|
|
|
|
cvSecretDoorColour = game.settings.get(MODULENAME, "cvSecretDoorColour"); |
|
|
cvWallWidth = game.settings.get(MODULENAME, "cvWallWidth"); |
|
|
cvWallWidth = game.settings.get(MODULENAME, "cvWallWidth"); |
|
|
|
|
|
|
|
|
let walls = controls.find(e => e.name === "walls"); |
|
|
let walls = controls.find(e => e.name === "walls"); |
|
@@ -44,8 +170,32 @@ Hooks.on('getSceneControlButtons', controls => { |
|
|
"icon": "far fa-square", |
|
|
"icon": "far fa-square", |
|
|
"title": "Convert selected to Drawing", |
|
|
"title": "Convert selected to Drawing", |
|
|
"onClick": () => { |
|
|
"onClick": () => { |
|
|
cvWalls = [] |
|
|
|
|
|
|
|
|
cvWalls = []; |
|
|
|
|
|
var wallRenderColour = BLACK; |
|
|
canvas.walls.controlled.forEach(function(wall) { |
|
|
canvas.walls.controlled.forEach(function(wall) { |
|
|
|
|
|
switch(determineWallType(wall)) { |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.WALL: |
|
|
|
|
|
wallRenderColour = cvWallColour; |
|
|
|
|
|
break; |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.TERRAIN: |
|
|
|
|
|
wallRenderColour = cvTerrainColour; |
|
|
|
|
|
break; |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.INVISIBLE: |
|
|
|
|
|
wallRenderColour = cvInvisibleColour; |
|
|
|
|
|
break |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.ETHEREAL: |
|
|
|
|
|
wallRenderColour = cvEtherealColour; |
|
|
|
|
|
break; |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.DOOR: |
|
|
|
|
|
wallRenderColour = cvDoorColour; |
|
|
|
|
|
break; |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.SECRETDOOR: |
|
|
|
|
|
wallRenderColour = cvSecretDoorColour; |
|
|
|
|
|
break; |
|
|
|
|
|
case FOUNDRY_DOOR_TYPES.OTHER: |
|
|
|
|
|
wallRenderColour = BLACK; |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
cvWalls.push({ |
|
|
cvWalls.push({ |
|
|
type: CONST.DRAWING_TYPES.POLYGON, |
|
|
type: CONST.DRAWING_TYPES.POLYGON, |
|
|
author: game.user._id, |
|
|
author: game.user._id, |
|
@@ -53,7 +203,7 @@ Hooks.on('getSceneControlButtons', controls => { |
|
|
y: 0, |
|
|
y: 0, |
|
|
height: 100, |
|
|
height: 100, |
|
|
strokeWidth: cvWallWidth, |
|
|
strokeWidth: cvWallWidth, |
|
|
strokeColor: cvWallColour, |
|
|
|
|
|
|
|
|
strokeColor: wallRenderColour, |
|
|
points: [ |
|
|
points: [ |
|
|
[wall.coords[0], wall.coords[1]], |
|
|
[wall.coords[0], wall.coords[1]], |
|
|
[wall.coords[2], wall.coords[3]] |
|
|
[wall.coords[2], wall.coords[3]] |
|
|