remove useless labels that weren't actually used in the dialogue editor
@@ -62,6 +62,16 @@ export function initDialoguesModal ({ socket, MessageType })
62
62
}
63
63
}
64
64
65
function addStep ()
66
{
67
draft.steps.push({
68
stepId: `step-${draft.steps.length + 1}`,
69
lines: [{ speaker: "npc", text: "…", effects: [] }],
70
exit: { kind: "end" }
71
});
72
renderEditor();
73
}
74
65
75
function renderEditor ()
66
76
{
67
77
editorEl.replaceChildren();
@@ -99,17 +109,12 @@ export function initDialoguesModal ({ socket, MessageType })
99
109
draft.entryStepId = v;
100
110
})));
101
111
102
const stepsHeader = sectionHeader("Steps", () =>
103
{
104
draft.steps.push({
105
stepId: `step-${draft.steps.length + 1}`,
106
label: "New step",
107
lines: [{ speaker: "npc", text: "…", effects: [] }],
108
exit: { kind: "end" }
109
});
110
renderEditor();
111
});
112
editorEl.append(stepsHeader);
112
const stepsTitle = document.createElement("div");
113
stepsTitle.className = "content-editor-section-header";
114
const stepsStrong = document.createElement("strong");
115
stepsStrong.textContent = "Steps";
116
stepsTitle.append(stepsStrong);
117
editorEl.append(stepsTitle);
113
118
114
119
draft.steps.forEach((step, stepIndex) =>
115
120
{
@@ -122,17 +127,13 @@ export function initDialoguesModal ({ socket, MessageType })
122
127
{
123
128
draft.steps.push({
124
129
stepId: "greeting",
125
label: "Greeting",
126
130
lines: [{ speaker: "npc", text: "…", effects: [] }],
127
131
exit: { kind: "end" }
128
132
});
129
133
}
130
134
renderEditor();
131
135
}));
132
box.append(
133
field("stepId", textInput(step.stepId, (v) => { step.stepId = v; })),
134
field("Label", textInput(step.label, (v) => { step.label = v; }))
135
);
136
box.append(field("stepId", textInput(step.stepId, (v) => { step.stepId = v; })));
136
137
137
138
const linesHead = sectionHeader("Lines", () =>
138
139
{
@@ -163,17 +164,13 @@ export function initDialoguesModal ({ socket, MessageType })
163
164
text.value = line.text ?? "";
164
165
text.style.flex = "1";
165
166
text.addEventListener("input", () => { line.text = text.value; });
166
const remove = document.createElement("button");
167
remove.type = "button";
168
remove.textContent = "×";
169
remove.addEventListener("click", () =>
167
row.append(speaker, text, removeButton(() =>
170
168
{
171
169
step.lines.splice(lineIndex, 1);
172
170
if (step.lines.length === 0)
173
171
{ step.lines.push({ speaker: "npc", text: "…", effects: [] }); }
174
172
renderEditor();
175
});
176
row.append(speaker, text, remove);
173
}));
177
174
box.append(row);
178
175
});
179
176
@@ -197,7 +194,6 @@ export function initDialoguesModal ({ socket, MessageType })
197
194
? step.exit.triggers
198
195
: [{
199
196
trigger: "continue",
200
label: "Continue",
201
197
text: "Continue",
202
198
nextStepId: null,
203
199
when: emptyConditionSet(),
@@ -212,7 +208,6 @@ export function initDialoguesModal ({ socket, MessageType })
212
208
branches: step.exit?.branches?.length
213
209
? step.exit.branches
214
210
: [{
215
label: "default",
216
211
when: emptyConditionSet(),
217
212
nextStepId: null,
218
213
effects: []
@@ -231,7 +226,6 @@ export function initDialoguesModal ({ socket, MessageType })
231
226
{
232
227
step.exit.triggers.push({
233
228
trigger: `choice-${step.exit.triggers.length + 1}`,
234
label: "Choice",
235
229
text: "Choice",
236
230
nextStepId: null,
237
231
when: emptyConditionSet(),
@@ -251,7 +245,6 @@ export function initDialoguesModal ({ socket, MessageType })
251
245
}));
252
246
tBox.append(
253
247
field("trigger", textInput(trig.trigger, (v) => { trig.trigger = v; })),
254
field("label", textInput(trig.label, (v) => { trig.label = v; })),
255
248
field("text (button)", textInput(trig.text, (v) => { trig.text = v; })),
256
249
field("nextStepId (blank=end)", textInput(trig.nextStepId ?? "", (v) =>
257
250
{
@@ -267,7 +260,6 @@ export function initDialoguesModal ({ socket, MessageType })
267
260
const branchHead = sectionHeader("Branches", () =>
268
261
{
269
262
step.exit.branches.push({
270
label: `branch-${step.exit.branches.length + 1}`,
271
263
when: emptyConditionSet(),
272
264
nextStepId: null,
273
265
effects: []
@@ -285,7 +277,6 @@ export function initDialoguesModal ({ socket, MessageType })
285
277
renderEditor();
286
278
}));
287
279
bBox.append(
288
field("label", textInput(branch.label ?? "", (v) => { branch.label = v; })),
289
280
field("nextStepId (blank=end)", textInput(branch.nextStepId ?? "", (v) =>
290
281
{
291
282
branch.nextStepId = v.trim() || null;
@@ -298,6 +289,13 @@ export function initDialoguesModal ({ socket, MessageType })
298
289
299
290
editorEl.append(box);
300
291
});
292
293
const addStepBtn = document.createElement("button");
294
addStepBtn.type = "button";
295
addStepBtn.className = "content-editor-add-step";
296
addStepBtn.textContent = "(add step)";
297
addStepBtn.addEventListener("click", addStep);
298
editorEl.append(addStepBtn);
301
299
}
302
300
303
301
function render ()
@@ -391,6 +389,17 @@ function textInput (value, onChange)
391
389
return input;
392
390
}
393
391
392
function removeButton (onClick)
393
{
394
const remove = document.createElement("button");
395
remove.type = "button";
396
remove.className = "content-editor-remove";
397
remove.textContent = "×";
398
remove.title = "Remove";
399
remove.addEventListener("click", onClick);
400
return remove;
401
}
402
394
403
function sectionHeader (title, onAdd, onRemove)
395
404
{
396
405
const head = document.createElement("div");
@@ -410,14 +419,7 @@ function sectionHeader (title, onAdd, onRemove)
410
419
actions.append(add);
411
420
}
412
421
if (onRemove)
413
{
414
const remove = document.createElement("button");
415
remove.type = "button";
416
remove.textContent = "×";
417
remove.title = "Remove";
418
remove.addEventListener("click", onRemove);
419
actions.append(remove);
420
}
422
{ actions.append(removeButton(onRemove)); }
421
423
head.append(actions);
422
424
return head;
423
425
}
@@ -62,6 +62,16 @@ export function initDialoguesModal ({ socket, MessageType })62
}62
}63
}63
}64
64
65
function addStep ()66
{67
draft.steps.push({68
stepId: `step-${draft.steps.length + 1}`,69
lines: [{ speaker: "npc", text: "…", effects: [] }],70
exit: { kind: "end" }71
});72
renderEditor();73
}74
65
function renderEditor ()75
function renderEditor ()66
{76
{67
editorEl.replaceChildren();77
editorEl.replaceChildren();@@ -99,17 +109,12 @@ export function initDialoguesModal ({ socket, MessageType })99
draft.entryStepId = v;109
draft.entryStepId = v;100
})));110
})));101
111
102
const stepsHeader = sectionHeader("Steps", () =>112
const stepsTitle = document.createElement("div");103
{113
stepsTitle.className = "content-editor-section-header";104
draft.steps.push({114
const stepsStrong = document.createElement("strong");105
stepId: `step-${draft.steps.length + 1}`,115
stepsStrong.textContent = "Steps";106
label: "New step",116
stepsTitle.append(stepsStrong);107
lines: [{ speaker: "npc", text: "…", effects: [] }],117
editorEl.append(stepsTitle);108
exit: { kind: "end" }109
});110
renderEditor();111
});112
editorEl.append(stepsHeader);113
118
114
draft.steps.forEach((step, stepIndex) =>119
draft.steps.forEach((step, stepIndex) =>115
{120
{@@ -122,17 +127,13 @@ export function initDialoguesModal ({ socket, MessageType })122
{127
{123
draft.steps.push({128
draft.steps.push({124
stepId: "greeting",129
stepId: "greeting",125
label: "Greeting",126
lines: [{ speaker: "npc", text: "…", effects: [] }],130
lines: [{ speaker: "npc", text: "…", effects: [] }],127
exit: { kind: "end" }131
exit: { kind: "end" }128
});132
});129
}133
}130
renderEditor();134
renderEditor();131
}));135
}));132
box.append(136
box.append(field("stepId", textInput(step.stepId, (v) => { step.stepId = v; })));133
field("stepId", textInput(step.stepId, (v) => { step.stepId = v; })),134
field("Label", textInput(step.label, (v) => { step.label = v; }))135
);136
137
137
const linesHead = sectionHeader("Lines", () =>138
const linesHead = sectionHeader("Lines", () =>138
{139
{@@ -163,17 +164,13 @@ export function initDialoguesModal ({ socket, MessageType })163
text.value = line.text ?? "";164
text.value = line.text ?? "";164
text.style.flex = "1";165
text.style.flex = "1";165
text.addEventListener("input", () => { line.text = text.value; });166
text.addEventListener("input", () => { line.text = text.value; });166
const remove = document.createElement("button");167
row.append(speaker, text, removeButton(() =>167
remove.type = "button";168
remove.textContent = "×";169
remove.addEventListener("click", () =>170
{168
{171
step.lines.splice(lineIndex, 1);169
step.lines.splice(lineIndex, 1);172
if (step.lines.length === 0)170
if (step.lines.length === 0)173
{ step.lines.push({ speaker: "npc", text: "…", effects: [] }); }171
{ step.lines.push({ speaker: "npc", text: "…", effects: [] }); }174
renderEditor();172
renderEditor();175
});173
}));176
row.append(speaker, text, remove);177
box.append(row);174
box.append(row);178
});175
});179
176
@@ -197,7 +194,6 @@ export function initDialoguesModal ({ socket, MessageType })197
? step.exit.triggers194
? step.exit.triggers198
: [{195
: [{199
trigger: "continue",196
trigger: "continue",200
label: "Continue",201
text: "Continue",197
text: "Continue",202
nextStepId: null,198
nextStepId: null,203
when: emptyConditionSet(),199
when: emptyConditionSet(),@@ -212,7 +208,6 @@ export function initDialoguesModal ({ socket, MessageType })212
branches: step.exit?.branches?.length208
branches: step.exit?.branches?.length213
? step.exit.branches209
? step.exit.branches214
: [{210
: [{215
label: "default",216
when: emptyConditionSet(),211
when: emptyConditionSet(),217
nextStepId: null,212
nextStepId: null,218
effects: []213
effects: []@@ -231,7 +226,6 @@ export function initDialoguesModal ({ socket, MessageType })231
{226
{232
step.exit.triggers.push({227
step.exit.triggers.push({233
trigger: `choice-${step.exit.triggers.length + 1}`,228
trigger: `choice-${step.exit.triggers.length + 1}`,234
label: "Choice",235
text: "Choice",229
text: "Choice",236
nextStepId: null,230
nextStepId: null,237
when: emptyConditionSet(),231
when: emptyConditionSet(),@@ -251,7 +245,6 @@ export function initDialoguesModal ({ socket, MessageType })251
}));245
}));252
tBox.append(246
tBox.append(253
field("trigger", textInput(trig.trigger, (v) => { trig.trigger = v; })),247
field("trigger", textInput(trig.trigger, (v) => { trig.trigger = v; })),254
field("label", textInput(trig.label, (v) => { trig.label = v; })),255
field("text (button)", textInput(trig.text, (v) => { trig.text = v; })),248
field("text (button)", textInput(trig.text, (v) => { trig.text = v; })),256
field("nextStepId (blank=end)", textInput(trig.nextStepId ?? "", (v) =>249
field("nextStepId (blank=end)", textInput(trig.nextStepId ?? "", (v) =>257
{250
{@@ -267,7 +260,6 @@ export function initDialoguesModal ({ socket, MessageType })267
const branchHead = sectionHeader("Branches", () =>260
const branchHead = sectionHeader("Branches", () =>268
{261
{269
step.exit.branches.push({262
step.exit.branches.push({270
label: `branch-${step.exit.branches.length + 1}`,271
when: emptyConditionSet(),263
when: emptyConditionSet(),272
nextStepId: null,264
nextStepId: null,273
effects: []265
effects: []@@ -285,7 +277,6 @@ export function initDialoguesModal ({ socket, MessageType })285
renderEditor();277
renderEditor();286
}));278
}));287
bBox.append(279
bBox.append(288
field("label", textInput(branch.label ?? "", (v) => { branch.label = v; })),289
field("nextStepId (blank=end)", textInput(branch.nextStepId ?? "", (v) =>280
field("nextStepId (blank=end)", textInput(branch.nextStepId ?? "", (v) =>290
{281
{291
branch.nextStepId = v.trim() || null;282
branch.nextStepId = v.trim() || null;@@ -298,6 +289,13 @@ export function initDialoguesModal ({ socket, MessageType })298
289
299
editorEl.append(box);290
editorEl.append(box);300
});291
});292
293
const addStepBtn = document.createElement("button");294
addStepBtn.type = "button";295
addStepBtn.className = "content-editor-add-step";296
addStepBtn.textContent = "(add step)";297
addStepBtn.addEventListener("click", addStep);298
editorEl.append(addStepBtn);301
}299
}302
300
303
function render ()301
function render ()@@ -391,6 +389,17 @@ function textInput (value, onChange)391
return input;389
return input;392
}390
}393
391
392
function removeButton (onClick)393
{394
const remove = document.createElement("button");395
remove.type = "button";396
remove.className = "content-editor-remove";397
remove.textContent = "×";398
remove.title = "Remove";399
remove.addEventListener("click", onClick);400
return remove;401
}402
394
function sectionHeader (title, onAdd, onRemove)403
function sectionHeader (title, onAdd, onRemove)395
{404
{396
const head = document.createElement("div");405
const head = document.createElement("div");@@ -410,14 +419,7 @@ function sectionHeader (title, onAdd, onRemove)410
actions.append(add);419
actions.append(add);411
}420
}412
if (onRemove)421
if (onRemove)413
{422
{ actions.append(removeButton(onRemove)); }414
const remove = document.createElement("button");415
remove.type = "button";416
remove.textContent = "×";417
remove.title = "Remove";418
remove.addEventListener("click", onRemove);419
actions.append(remove);420
}421
head.append(actions);423
head.append(actions);422
return head;424
return head;423
}425
}@@ -1378,6 +1378,40 @@ label {
1378
1378
margin: 0.35rem 0;
1379
1379
}
1380
1380
1381
.content-editor-remove,
1382
#dialogues-delete {
1383
color: #f0e8e8;
1384
background: #8a3030;
1385
border-color: #a84848;
1386
}
1387
1388
.content-editor-remove:hover,
1389
#dialogues-delete:hover:not(:disabled) {
1390
background: #a83838;
1391
border-color: #c06060;
1392
}
1393
1394
#dialogues-delete:disabled {
1395
opacity: 0.45;
1396
}
1397
1398
.content-editor-add-step {
1399
display: block;
1400
width: 100%;
1401
margin: 0.35rem 0 0.75rem;
1402
padding: 0.45rem 0.6rem;
1403
color: #9eb0c8;
1404
background: transparent;
1405
border: 1px dashed #3a4558;
1406
cursor: pointer;
1407
}
1408
1409
.content-editor-add-step:hover {
1410
color: #c5d4e8;
1411
border-color: #5a6a82;
1412
background: #1a2230;
1413
}
1414
1381
1415
.content-editor-clause {
1382
1416
border: 1px dashed #3a4250;
1383
1417
padding: 0.4rem;
@@ -1378,6 +1378,40 @@ label {1378
margin: 0.35rem 0;1378
margin: 0.35rem 0;1379
}1379
}1380
1380
1381
.content-editor-remove,1382
#dialogues-delete {1383
color: #f0e8e8;1384
background: #8a3030;1385
border-color: #a84848;1386
}1387
1388
.content-editor-remove:hover,1389
#dialogues-delete:hover:not(:disabled) {1390
background: #a83838;1391
border-color: #c06060;1392
}1393
1394
#dialogues-delete:disabled {1395
opacity: 0.45;1396
}1397
1398
.content-editor-add-step {1399
display: block;1400
width: 100%;1401
margin: 0.35rem 0 0.75rem;1402
padding: 0.45rem 0.6rem;1403
color: #9eb0c8;1404
background: transparent;1405
border: 1px dashed #3a4558;1406
cursor: pointer;1407
}1408
1409
.content-editor-add-step:hover {1410
color: #c5d4e8;1411
border-color: #5a6a82;1412
background: #1a2230;1413
}1414
1381
.content-editor-clause {1415
.content-editor-clause {1382
border: 1px dashed #3a4250;1416
border: 1px dashed #3a4250;1383
padding: 0.4rem;1417
padding: 0.4rem;