Skip to content

Commit

Permalink
Merge pull request #1650 from Azmoria/Beta---Adjust-door-menus-to-hav…
Browse files Browse the repository at this point in the history
…e-toggles-for-locked-/-secret

Beta - adjust door/window menus to have toggles
  • Loading branch information
Azmoria authored Oct 22, 2023
2 parents b6aaeb7 + bf67689 commit e01e68a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 130 deletions.
12 changes: 6 additions & 6 deletions Fog.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const POLYGON_CLOSE_DISTANCE = 15;
const doorColors = {
0: {
'open': "rgba(255, 100, 255, 0.5)",
'open': "rgba(255, 100, 255, 0.5)", // door
'closed': "rgba(255, 100, 255, 1)"
},
1: {
'open': "rgba(255, 255, 0, 0.5)",
'open': "rgba(255, 255, 0, 0.5)", // window
'closed': "rgba(255, 255, 0, 1)"
},
2: {
'open': "rgba(150, 50, 150, 0.5)",
'open': "rgba(150, 50, 150, 0.5)", // locked door
'closed': "rgba(150, 50, 150, 1)"
},
3: {
'open': "rgba(150, 150, 0, 0.5)",
'open': "rgba(150, 150, 0, 0.5)", // locked window
'closed': "rgba(150, 150, 0, 1)"
},
4: {
'open': "rgba(100, 0, 255, 0.5)",
'open': "rgba(100, 0, 255, 0.5)", //secret door
'closed': "rgba(100, 0, 255, 1)"
},
5: {
'open': "rgba(50, 0, 180, 0.5)",
'open': "rgba(50, 0, 180, 0.5)", // secret locked door
'closed': "rgba(50, 0, 180, 1)"
},
};
Expand Down
173 changes: 49 additions & 124 deletions TokenMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,75 +146,35 @@ function token_context_menu_expanded(tokenIds, e) {
let y1 = parseInt(door.attr('data-y1'));
let y2 = parseInt(door.attr('data-y2'));

let locked = door.hasClass('locked');
let secret = door.hasClass('secret');

let isDoor = door.children('.door').length>0;

let doors = window.DRAWINGS.filter(d => (d[1] == "wall" && doorColorsArray.includes(d[2]) && parseInt(d[3]) == x1 && parseInt(d[4]) == y1 && parseInt(d[5]) == x2 && parseInt(d[6]) == y2))
let color = doors[0][2];
let isOpen = (/rgba.*0\.5\)/g).test(color) ? 'open' : 'closed';

if(door.children('.door').length>0){

body.append($('<div class="token-image-modal-footer-title" style="margin-top:10px">Door Type</div>'));

let button = $(`<button>Unlocked</button>`);
button.on("click", function() {
door.toggleClass(['locked', 'secret'], false);
window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[0][isOpen],
x1,
y1,
x2,
y2,
12,
doors[0][8]
];
window.DRAWINGS.push(data);

redraw_light_walls();
redraw_light();


sync_drawings();
});
body.append(button);


button = $(`<button>Locked</button>`);
button.on("click", function() {
door.toggleClass('locked', true);
door.toggleClass(['secret', 'open'], false);
body.append($('<div class="token-image-modal-footer-title" style="margin-top:10px">Door Type</div>'));


window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[2]['closed'],
x1,
y1,
x2,
y2,
12,
doors[0][8]
];
window.DRAWINGS.push(data);

redraw_light_walls();
redraw_light();


sync_drawings();
});
body.append(button);
let lockedButton = $(`<button class="${door.hasClass('locked') ? 'single-active active-condition' : 'none-active'} context-menu-icon-hidden door-lock material-icons">Locked</button>`)
lockedButton.off().on("click", function(clickEvent){
let clickedItem = $(this);
let locked = door.hasClass('locked');
let secret = door.hasClass('secret');

const type = isDoor ? (secret ? (!locked ? 5 : 4) : (!locked ? 2 : 0)) : (!locked ? 3 : 1)

button = $(`<button>Secret</button>`);
button.on("click", function() {
door.toggleClass('locked', false);
door.toggleClass('secret', true);
isOpen = !locked ? 'closed' : isOpen;

window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
door.toggleClass('locked', !locked);
window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[4][isOpen],
doorColors[type][isOpen],
x1,
y1,
x2,
Expand All @@ -229,86 +189,51 @@ function token_context_menu_expanded(tokenIds, e) {


sync_drawings();
});
body.append(button);

button = $(`<button>Secret & Locked</button>`);
button.on("click", function() {
door.toggleClass(['locked', 'secret'], true);
door.toggleClass('open', false);
window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[5]['closed'],
x1,
y1,
x2,
y2,
12,
doors[0][8]
];
window.DRAWINGS.push(data);
clickedItem.removeClass("single-active all-active some-active active-condition");

redraw_light_walls();
redraw_light();
clickedItem.addClass(`${!locked ? 'single-active active-condition' : ''}`);
});
body.append(lockedButton);


sync_drawings();
});
body.append(button);

}
else if(door.children('.window').length>0){
body.append($('<div class="token-image-modal-footer-title" style="margin-top:10px">Window Type</div>'));

if(door.children('.door').length>0){
let secretButton = $(`<button class="${door.hasClass('secret') ? 'single-active active-condition' : 'none-active'} context-menu-icon-hidden door-secret material-icons">Secret</button>`)
secretButton.off().on("click", function(clickEvent){
let clickedItem = $(this);
let locked = door.hasClass('locked');
let secret = door.hasClass('secret');

let button = $(`<button>Unlocked</button>`);
button.on("click", function() {
door.toggleClass('locked', false);
window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[1][isOpen],
x1,
y1,
x2,
y2,
12,
doors[0][8]
];
window.DRAWINGS.push(data);
const type = !secret ? (locked ? 5 : 4) : (locked ? 2 : 0)

redraw_light_walls();
redraw_light();
isOpen = locked ? 'closed' : isOpen;

door.toggleClass('secret', !secret);
window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[type][isOpen],
x1,
y1,
x2,
y2,
12,
doors[0][8]
];
window.DRAWINGS.push(data);

sync_drawings();
});
body.append(button);
redraw_light_walls();
redraw_light();

button = $(`<button>Locked</button>`);
button.on("click", function() {
door.toggleClass('locked', true);
door.toggleClass('open', false);
window.DRAWINGS = window.DRAWINGS.filter(d => d != doors[0]);
let data = ['line',
'wall',
doorColors[3]['closed'],
x1,
y1,
x2,
y2,
12,
doors[0][8]
];
window.DRAWINGS.push(data);

redraw_light_walls();
redraw_light();
sync_drawings();

clickedItem.removeClass("single-active all-active some-active active-condition");

sync_drawings();
clickedItem.addClass(`${!secret ? 'single-active active-condition' : ''}`);
});
body.append(button);
body.append(secretButton);
}

}
Expand Down
10 changes: 10 additions & 0 deletions abovevtt.css
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,16 @@ div#scene_properties form > div {
content:"\e898";
}

.door-lock.material-icons:before{
content:"\e897";
padding: 2px 0px;
}

.door-secret.material-icons:before{
content: "S";
margin: 0px 0px 0px 2px;
color: #dc0000;
}

.condition-lock.locked.material-symbols-outlined:before,
.condition-lock.material-symbols-outlined:hover:before {
Expand Down

0 comments on commit e01e68a

Please sign in to comment.