@novely/solid-renderer 0.0.0-beta.1 → 0.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DialogName.d.ts +1 -1
- package/dist/index.css +7 -5
- package/dist/index.jsx +26 -25
- package/dist/renderer.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -431,15 +431,17 @@
|
|
|
431
431
|
text-align: center;
|
|
432
432
|
justify-content: center;
|
|
433
433
|
align-items: center;
|
|
434
|
-
font-size: 1.
|
|
435
|
-
display:
|
|
434
|
+
font-size: 1.5em;
|
|
435
|
+
display: none;
|
|
436
436
|
position: absolute;
|
|
437
437
|
inset: 0;
|
|
438
438
|
}
|
|
439
439
|
.n-fullscreenText[data-fullscreen-text-shown=true] {
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
background: var(--novely-fullscreen-backgroun-color, #0000004d);
|
|
441
|
+
text-shadow: var(--novely-fullscreen-text-shadow, 2px 2px 4px #00000080);
|
|
442
|
+
color: var(--novely-fullscreen-text-color, white);
|
|
443
|
+
display: flex;
|
|
442
444
|
}
|
|
443
|
-
.n-fullscreenText[data-fullscreen-text-shown=true] >
|
|
445
|
+
.n-fullscreenText[data-fullscreen-text-shown=true] > span {
|
|
444
446
|
cursor: pointer;
|
|
445
447
|
}
|
package/dist/index.jsx
CHANGED
|
@@ -101,11 +101,6 @@ var DialogName = (props) => {
|
|
|
101
101
|
const cs = props.characters;
|
|
102
102
|
return c ? c in cs ? cs[c].color : "#000" : "#000";
|
|
103
103
|
};
|
|
104
|
-
const name = () => {
|
|
105
|
-
const c = props.character;
|
|
106
|
-
const cs = props.characters;
|
|
107
|
-
return c ? c in cs ? typeof cs[c].name === "string" ? cs[c].name : cs[c].name[props.lang] : c : "";
|
|
108
|
-
};
|
|
109
104
|
return <span
|
|
110
105
|
class={root_module_default.dialogName}
|
|
111
106
|
style={{
|
|
@@ -113,7 +108,7 @@ var DialogName = (props) => {
|
|
|
113
108
|
opacity: props.character ? 1 : 0,
|
|
114
109
|
visibility: props.character ? "visible" : "hidden"
|
|
115
110
|
}}
|
|
116
|
-
>{name
|
|
111
|
+
>{props.name || <>ᅠ</>}</span>;
|
|
117
112
|
};
|
|
118
113
|
|
|
119
114
|
// src/components/Character.tsx
|
|
@@ -183,13 +178,13 @@ var Game = (props) => {
|
|
|
183
178
|
if (disabled)
|
|
184
179
|
return;
|
|
185
180
|
const resolve = props.state.choices.resolve;
|
|
186
|
-
setState("choices", { choices: [], visible: false, resolve: void 0 });
|
|
181
|
+
setState("choices", { choices: [], visible: false, resolve: void 0, question: "" });
|
|
187
182
|
resolve?.(i);
|
|
188
183
|
};
|
|
189
184
|
const clearTypewriterEffect = () => {
|
|
190
185
|
if (writer && writer.end()) {
|
|
191
186
|
const resolve = props.state.dialog.resolve || props.state.text.resolve;
|
|
192
|
-
setState("dialog", { content: "", character: void 0, emotion: void 0, visible: false, resolve: void 0 });
|
|
187
|
+
setState("dialog", { content: "", name: "", character: void 0, emotion: void 0, visible: false, resolve: void 0 });
|
|
193
188
|
setState("text", { content: "", resolve: void 0 });
|
|
194
189
|
resolve?.();
|
|
195
190
|
}
|
|
@@ -215,8 +210,8 @@ var Game = (props) => {
|
|
|
215
210
|
>
|
|
216
211
|
<DialogName
|
|
217
212
|
character={props.state.dialog.character}
|
|
213
|
+
name={props.state.dialog.name}
|
|
218
214
|
characters={characters}
|
|
219
|
-
lang={data.storeData().meta[0]}
|
|
220
215
|
/>
|
|
221
216
|
<div class={join(root_module_default.dialogContainer, root_module_default.dialogContainerWithPerson)} data-no-person={!(props.state.dialog.character && props.state.dialog.emotion)}>
|
|
222
217
|
<div class={root_module_default.dialogPerson}><Show when={props.state.dialog.emotion} keyed>{(emotion) => {
|
|
@@ -244,15 +239,19 @@ var Game = (props) => {
|
|
|
244
239
|
class={root_module_default.headlessDialogFix}
|
|
245
240
|
aria-hidden="true"
|
|
246
241
|
></span>
|
|
247
|
-
<DialogPanel class={root_module_default.headlessDialogPanel}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
242
|
+
<DialogPanel class={root_module_default.headlessDialogPanel}>
|
|
243
|
+
<p aria-hidden={!props.state.choices.question}>{props.state.choices.question || <>ᅠ</>}</p>
|
|
244
|
+
<For each={props.state.choices.choices}>{([text, _, active], i) => {
|
|
245
|
+
const disabled = active ? !active() : false;
|
|
246
|
+
const index = i();
|
|
247
|
+
return <button
|
|
248
|
+
type="button"
|
|
249
|
+
aria-disabled={disabled}
|
|
250
|
+
class={join(root_module_default.button, root_module_default.buttonChoices)}
|
|
251
|
+
onClick={[onChoicesButtonClick, [disabled, index]]}
|
|
252
|
+
>{text}</button>;
|
|
253
|
+
}}</For>
|
|
254
|
+
</DialogPanel>
|
|
256
255
|
</div></Dialog>
|
|
257
256
|
<Dialog
|
|
258
257
|
isOpen={props.state.input.visible}
|
|
@@ -276,7 +275,7 @@ var Game = (props) => {
|
|
|
276
275
|
</DialogPanel>
|
|
277
276
|
</div></Dialog>
|
|
278
277
|
<div data-custom={true}><For each={layers()}>{(value) => value.dom}</For></div>
|
|
279
|
-
<div class={root_module_default.fullscreenText} data-fullscreen-text-shown={Boolean(props.state.text.content)}
|
|
278
|
+
<div class={root_module_default.fullscreenText} data-fullscreen-text-shown={Boolean(props.state.text.content)} ref={store.textRef} onClick={clearTypewriterEffect}> </div>
|
|
280
279
|
<div class={root_module_default.controlPanel}>
|
|
281
280
|
<button
|
|
282
281
|
type="button"
|
|
@@ -436,9 +435,11 @@ var createSolidRenderer = () => {
|
|
|
436
435
|
characters: {},
|
|
437
436
|
dialog: {
|
|
438
437
|
content: "",
|
|
438
|
+
name: "",
|
|
439
439
|
visible: false
|
|
440
440
|
},
|
|
441
441
|
choices: {
|
|
442
|
+
question: "",
|
|
442
443
|
visible: false,
|
|
443
444
|
choices: []
|
|
444
445
|
},
|
|
@@ -517,22 +518,22 @@ var createSolidRenderer = () => {
|
|
|
517
518
|
}
|
|
518
519
|
};
|
|
519
520
|
},
|
|
520
|
-
dialog(content, character, emotion) {
|
|
521
|
+
dialog(content, name, character, emotion) {
|
|
521
522
|
return (resolve) => {
|
|
522
|
-
setState("dialog", () => ({ content, character, emotion, visible: true, resolve }));
|
|
523
|
+
setState("dialog", () => ({ content, name, character, emotion, visible: true, resolve }));
|
|
523
524
|
};
|
|
524
525
|
},
|
|
525
|
-
choices(choices) {
|
|
526
|
+
choices(question, choices) {
|
|
526
527
|
return (resolve) => {
|
|
527
|
-
setState("choices", { choices, resolve, visible: true });
|
|
528
|
+
setState("choices", { choices, question, resolve, visible: true });
|
|
528
529
|
};
|
|
529
530
|
},
|
|
530
531
|
clear(goingBack) {
|
|
531
532
|
return (resolve) => {
|
|
532
533
|
setState("background", "#000");
|
|
533
|
-
setState("choices", { visible: false });
|
|
534
|
+
setState("choices", { choices: [], visible: false, resolve: void 0, question: "" });
|
|
534
535
|
setState("input", { element: void 0, question: "", visible: false });
|
|
535
|
-
setState("dialog", { visible: false, content: "" });
|
|
536
|
+
setState("dialog", { visible: false, content: "", name: "" });
|
|
536
537
|
setState("text", { content: "" });
|
|
537
538
|
for (const character of Object.keys(state.characters)) {
|
|
538
539
|
setState("characters", character, { visible: false });
|
package/dist/renderer.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ interface StateDialog {
|
|
|
35
35
|
* Должен ли диалог быть показан
|
|
36
36
|
*/
|
|
37
37
|
visible: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Имя персонажа
|
|
40
|
+
*/
|
|
41
|
+
name: string;
|
|
38
42
|
/**
|
|
39
43
|
* Функция `resolve`
|
|
40
44
|
*/
|
|
@@ -46,6 +50,10 @@ interface StateChoices {
|
|
|
46
50
|
* @param selected `index` выбранного
|
|
47
51
|
*/
|
|
48
52
|
resolve?: (selected: number) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Вопрос (а что выбирать)
|
|
55
|
+
*/
|
|
56
|
+
question: string;
|
|
49
57
|
/**
|
|
50
58
|
* Выборы
|
|
51
59
|
*/
|