Browse Source

Colour wall types are differently

By default, can be configured in menu
tags/0.1.0
bertieb 3 years ago
parent
commit
b319e89878
3 changed files with 157 additions and 7 deletions
  1. +1
    -1
      README.md
  2. +2
    -2
      module.json
  3. +154
    -4
      scripts/wallconvert.js

+ 1
- 1
README.md View File

@@ -17,7 +17,7 @@ The Drawing objects will show up under Drawing Tools.

## Wishlist

- [ ] different colours for different wall types
- [x] different colours for different wall types (as of 0.1.0)
- [ ] selectively ignore certain wall types even if selected (eg ethereal walls)
- [ ] render doors differently
- [ ] a better icon for the button


+ 2
- 2
module.json View File

@@ -3,11 +3,11 @@
"title": "Walls-to-Drawings",
"description": "Convert selected walls to drawings to make walls visible to players",
"authors": [{ "name": "BertieB", "email": "foundry@bertieb.org", "url": "https://bertieb.org" }],
"version": "0.0.8",
"version": "0.1.0",
"minimumCoreVersion": "0.6.5",
"compatibleCoreVersion": "0.6.5",
"scripts": [ "scripts/wallconvert.js" ],
"url": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing",
"manifest": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing/raw/branch/master/module.json",
"download": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing/archive/0.0.8.zip"
"download": "https://git.bertieb.org/bertieb/foundry-walls-to-drawing/archive/0.1.0.zip"
}

+ 154
- 4
scripts/wallconvert.js View File

@@ -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} */
WALLCOLOUR = "#111111";
MODULENAME = "foundry-walls-to-drawing";

/** @constant {string} */
WALLCOLOUR = "#111111";
/** @constant {number} */
WALLWIDTH = "4";

/** @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
@@ -20,6 +96,51 @@ Hooks.on("init", () => {
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", {
name: "Converted Wall Width",
default: WALLWIDTH,
@@ -36,6 +157,11 @@ Hooks.on("init", () => {

Hooks.on('getSceneControlButtons', controls => {
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");

let walls = controls.find(e => e.name === "walls");
@@ -44,8 +170,32 @@ Hooks.on('getSceneControlButtons', controls => {
"icon": "far fa-square",
"title": "Convert selected to Drawing",
"onClick": () => {
cvWalls = []
cvWalls = [];
var wallRenderColour = BLACK;
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({
type: CONST.DRAWING_TYPES.POLYGON,
author: game.user._id,
@@ -53,7 +203,7 @@ Hooks.on('getSceneControlButtons', controls => {
y: 0,
height: 100,
strokeWidth: cvWallWidth,
strokeColor: cvWallColour,
strokeColor: wallRenderColour,
points: [
[wall.coords[0], wall.coords[1]],
[wall.coords[2], wall.coords[3]]


Loading…
Cancel
Save