@rpg-engine/long-bow 0.2.21 → 0.2.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.2.21",
3
+ "version": "0.2.23",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@rollup/plugin-image": "^2.1.1",
86
- "@rpg-engine/shared": "^0.4.54",
86
+ "@rpg-engine/shared": "^0.4.58",
87
87
  "dayjs": "^1.11.2",
88
88
  "fs-extra": "^10.1.0",
89
89
  "lodash": "^4.17.21",
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { NPCDialog, NPCDialogType } from './NPCDialog/NPCDialog';
4
4
  import { NPCMultiDialog, NPCMultiDialogType } from './NPCDialog/NPCMultiDialog';
@@ -9,7 +9,7 @@ import {
9
9
  } from './NPCDialog/QuestionDialog/QuestionDialog';
10
10
 
11
11
  export interface IHistoryDialogProps {
12
- backgroundImgPath: string;
12
+ backgroundImgPath: string[];
13
13
  fullCoverBackground: boolean;
14
14
  questions?: IQuestionDialog[];
15
15
  answers?: IQuestionDialogAnswer[];
@@ -29,9 +29,26 @@ export const HistoryDialog: React.FC<IHistoryDialogProps> = ({
29
29
  textAndTypeArray,
30
30
  onClose,
31
31
  }) => {
32
+ const [img, setImage] = useState<number>(0);
33
+ const onHandleSpacePress = (event: KeyboardEvent) => {
34
+ if (event.code === 'Space') {
35
+ if (img < backgroundImgPath?.length - 1) {
36
+ setImage(prev => prev + 1);
37
+ } else {
38
+ // if there's no more text chunks, close the dialog
39
+ onClose();
40
+ }
41
+ }
42
+ };
43
+
44
+ useEffect(() => {
45
+ document.addEventListener('keydown', onHandleSpacePress);
46
+
47
+ return () => document.removeEventListener('keydown', onHandleSpacePress);
48
+ }, [backgroundImgPath]);
32
49
  return (
33
50
  <BackgroundContainer
34
- imgPath={backgroundImgPath}
51
+ imgPath={backgroundImgPath[img]}
35
52
  fullImg={fullCoverBackground}
36
53
  >
37
54
  <DialogContainer>
@@ -5,7 +5,7 @@ import { DraggableContainer } from './DraggableContainer';
5
5
  import { RPGUIContainerTypes } from './RPGUIContainer';
6
6
 
7
7
  export interface IQuestListProps {
8
- quests: IQuest[];
8
+ quests?: IQuest[];
9
9
  onClose: () => void;
10
10
  }
11
11
 
@@ -23,15 +23,23 @@ export const QuestList: React.FC<IQuestListProps> = ({ quests, onClose }) => {
23
23
  <hr className="golden" />
24
24
 
25
25
  <QuestListContainer>
26
- {quests.map((quest, i) => (
27
- <div className="quest-item" key={i}>
28
- <span className="quest-number">{i + 1}</span>
29
- <div className="quest-detail">
30
- <p className="quest-detail__title">{quest.title}</p>
31
- <p className="quest-detail__description">{quest.description}</p>
26
+ {quests ? (
27
+ quests.map((quest, i) => (
28
+ <div className="quest-item" key={i}>
29
+ <span className="quest-number">{i + 1}</span>
30
+ <div className="quest-detail">
31
+ <p className="quest-detail__title">{quest.title}</p>
32
+ <p className="quest-detail__description">
33
+ {quest.description}
34
+ </p>
35
+ </div>
32
36
  </div>
33
- </div>
34
- ))}
37
+ ))
38
+ ) : (
39
+ <NoQuestContainer>
40
+ <p>There are no ongoing quests</p>
41
+ </NoQuestContainer>
42
+ )}
35
43
  </QuestListContainer>
36
44
  </div>
37
45
  </QuestDraggableContainer>
@@ -107,4 +115,14 @@ const QuestListContainer = styled.div`
107
115
  .quest-detail__description {
108
116
  margin-top: 5px;
109
117
  }
118
+ .Noquest-detail__description {
119
+ margin-top: 5px;
120
+ margin: auto;
121
+ }
122
+ `;
123
+ const NoQuestContainer = styled.div`
124
+ text-align: center;
125
+ p {
126
+ margin-top: 5px;
127
+ }
110
128
  `;
Binary file
@@ -2,7 +2,9 @@ import { Meta, Story } from '@storybook/react';
2
2
  import React from 'react';
3
3
  import { RPGUIRoot } from '../components/RPGUIRoot';
4
4
  import aliceDefaultThumbnail from '../components/NPCDialog/img/npcDialog/npcThumbnails/alice.png';
5
- import ImgBackground from '../components/NPCDialog/img/background.png';
5
+ import ImgBackground01 from '../components/NPCDialog/img/background01.png';
6
+ import ImgBackground02 from '../components/NPCDialog/img/background02.png';
7
+ import ImgBackground03 from '../components/NPCDialog/img/background03.png';
6
8
  import {
7
9
  HistoryDialog,
8
10
  IHistoryDialogProps,
@@ -55,5 +57,5 @@ const textAndTypeArray: NPCMultiDialogType[] = [
55
57
  HistoryDialogStore.args = {
56
58
  textAndTypeArray,
57
59
  fullCoverBackground: true,
58
- backgroundImgPath: ImgBackground,
60
+ backgroundImgPath: [ImgBackground01, ImgBackground02, ImgBackground03],
59
61
  };