diff --git a/Fog.js b/Fog.js index 38e40eaad..880a3cf24 100644 --- a/Fog.js +++ b/Fog.js @@ -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)" }, }; diff --git a/TokenMenu.js b/TokenMenu.js index 7457f783f..e163e4b6b 100644 --- a/TokenMenu.js +++ b/TokenMenu.js @@ -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($('
')); - - let 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.on("click", function() { - door.toggleClass('locked', true); - door.toggleClass(['secret', 'open'], false); + body.append($(' ')); - 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 = $(``) + 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.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, @@ -229,86 +189,51 @@ function token_context_menu_expanded(tokenIds, e) { sync_drawings(); - }); - body.append(button); - 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($(' ')); + + if(door.children('.door').length>0){ + let secretButton = $(``) + secretButton.off().on("click", function(clickEvent){ + let clickedItem = $(this); + let locked = door.hasClass('locked'); + let secret = door.hasClass('secret'); - let 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.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); } } diff --git a/abovevtt.css b/abovevtt.css index b77178f39..642a595a9 100644 --- a/abovevtt.css +++ b/abovevtt.css @@ -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 {