add scene management (create/delete)
This commit is contained in:
parent
e730f9a870
commit
8f5f82ff31
6 changed files with 58 additions and 0 deletions
|
@ -230,9 +230,21 @@ tavern.onscenelist = (list) => {
|
|||
if (tavern.admin) {
|
||||
row.innerHTML += `<button onclick='tavern.show_scene(${scene[0]});'>Force</button>`;
|
||||
row.innerHTML += `<button onclick='tavern.set_scene_visible(${scene[0]}, !${scene[2]});'>${scene[2] ? 'Hide' : 'Show'}</button>`;
|
||||
// TODO: Add a confirmation dialog
|
||||
row.innerHTML += `<button onclick='tavern.delete_scene(${scene[0]})'>Delete</button>`;
|
||||
}
|
||||
div.appendChild(row);
|
||||
}
|
||||
// Add create scene button at the end
|
||||
if (tavern.admin) {
|
||||
let b = document.createElement('button');
|
||||
b.innerText = 'Create scene';
|
||||
b.onclick = () => {
|
||||
document.getElementById('create-scene-title').value = '';
|
||||
document.getElementById('create-scene-popup').style.display = 'flex';
|
||||
}
|
||||
div.appendChild(b);
|
||||
}
|
||||
}
|
||||
tavern.onconnectedplayers = (connected) => {
|
||||
console.log(connected);
|
||||
|
@ -380,4 +392,9 @@ function onMoveableDivMouseUp(e, id) {
|
|||
function showHideDiv(id) {
|
||||
let div = document.getElementById(id);
|
||||
div.style.display = div.style.display == 'none' ? 'flex' : 'none';
|
||||
}
|
||||
function createSceneAndHidePopup() {
|
||||
document.getElementById('create-scene-popup').style.display = 'none'
|
||||
let title = document.getElementById('create-scene-title').value;
|
||||
tavern.create_scene(title.value);
|
||||
}
|
|
@ -69,6 +69,24 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="create-scene-popup"
|
||||
style="display:none; justify-content: center; width: 100%; height: 100%; background-color: transparent; position: absolute; z-index: 10; top: 0px; left: 0px">
|
||||
<div style="display:flex; width: auto; justify-content: center; flex-direction: column;">
|
||||
<div
|
||||
style="display: flex; height: fit-content; flex-direction: column; background-color: #ffffd6; color: black; border: black solid 1px; padding: 8px; border-radius: 8px;">
|
||||
<h3 id="dice-roll-title" style="align-self: center;">
|
||||
Create scene
|
||||
</h3>
|
||||
<div style="display: grid; grid-template-columns: auto auto; gap: 16px; margin-top: 8px;">
|
||||
<p>Title:</p>
|
||||
<input type="text" id="create-scene-title">
|
||||
<button
|
||||
onclick="document.getElementById('create-scene-popup').style.display = 'none'">Cancel</button>
|
||||
<button onclick="createSceneAndHidePopup()">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style="position: absolute; top: 10px; right: 10px; color: black; z-index: 5; display: flex; flex-direction: row; gap: 4px;">
|
||||
<button style="background-color: #ffffd6;" onclick="showHideDiv('settings-window')"><b>s</b></button>
|
||||
|
|
|
@ -136,6 +136,10 @@ class Tavern {
|
|||
if (!this.connected || this.loggedIn) { return; }
|
||||
this.socket.send(JSON.stringify({ create_scene: { title: title } }));
|
||||
}
|
||||
delete_scene = (scene) => {
|
||||
if (!this.connected || this.loggedIn) { return; }
|
||||
this.socket.send(JSON.stringify({ delete_scene: { scene: scene } }));
|
||||
}
|
||||
shutdown = () => {
|
||||
if (!this.connected || this.loggedIn || !this.admin) { return; }
|
||||
this.socket.send(JSON.stringify('shutdown'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue