@novely/solid-renderer 0.0.0-beta.1 → 0.0.0-beta.2

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.
@@ -3,7 +3,7 @@ import type { VoidComponent } from 'solid-js';
3
3
  interface DialogNameProps {
4
4
  character?: string;
5
5
  characters: Record<string, Character>;
6
- lang: string;
6
+ name: string;
7
7
  }
8
8
  declare const DialogName: VoidComponent<DialogNameProps>;
9
9
  export { DialogName };
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() || <>ᅠ</>}</span>;
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}><For each={props.state.choices.choices}>{([text, _, active], i) => {
248
- const disabled = active ? !active() : false;
249
- return <button
250
- type="button"
251
- aria-disabled={disabled}
252
- class={join(root_module_default.button, root_module_default.buttonChoices)}
253
- onClick={[onChoicesButtonClick, [disabled, i()]]}
254
- >{text}</button>;
255
- }}</For></DialogPanel>
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}
@@ -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 });
@@ -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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/solid-renderer",
3
- "version": "0.0.0-beta.1",
3
+ "version": "0.0.0-beta.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"