@rpg-engine/long-bow 0.1.51 → 0.1.55
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/DraggableContainer.d.ts +12 -0
- package/dist/components/SimpleProgressBar.d.ts +8 -0
- package/dist/components/SkillProgressBar.d.ts +9 -0
- package/dist/imgExp.png +0 -0
- package/dist/index.d.ts +3 -1
- package/dist/long-bow.cjs.development.js +179 -57
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +178 -58
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +6 -3
- package/src/components/Button.tsx +5 -7
- package/src/components/Chat/Chat.tsx +1 -1
- package/src/components/CheckButton.tsx +4 -3
- package/src/components/DraggableContainer.tsx +95 -0
- package/src/components/Dropdown.tsx +1 -1
- package/src/components/ListMenu.tsx +4 -4
- package/src/components/NPCDialog/NPCDialog.tsx +3 -2
- package/src/components/NPCDialog/NPCDialogText.tsx +1 -1
- package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +15 -13
- package/src/components/ProgressBar.tsx +4 -4
- package/src/components/RPGUIContainer.tsx +1 -1
- package/src/components/RadioButton.tsx +1 -1
- package/src/components/SimpleProgressBar.tsx +58 -0
- package/src/components/SkillProgressBar.tsx +70 -0
- package/src/components/Truncate.tsx +1 -1
- package/src/components/imgExp.png +0 -0
- package/src/components/shared/Column.tsx +4 -4
- package/src/hooks/useEventListener.ts +1 -1
- package/src/index.tsx +3 -1
|
@@ -37,11 +37,13 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
37
37
|
|
|
38
38
|
const firstAnswerId = currentQuestion.answerIds![0];
|
|
39
39
|
|
|
40
|
-
return answers.find(
|
|
40
|
+
return answers.find(answer => answer.id === firstAnswerId);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const [
|
|
44
|
-
|
|
43
|
+
const [
|
|
44
|
+
currentAnswer,
|
|
45
|
+
setCurrentAnswer,
|
|
46
|
+
] = useState<IQuestionDialogAnswer | null>(onGetFirstAnswer()!);
|
|
45
47
|
|
|
46
48
|
useEffect(() => {
|
|
47
49
|
setCurrentAnswer(onGetFirstAnswer()!);
|
|
@@ -49,7 +51,7 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
49
51
|
|
|
50
52
|
const onGetAnswers = (answerIds: number[]) => {
|
|
51
53
|
return answerIds.map((answerId: number) =>
|
|
52
|
-
answers.find(
|
|
54
|
+
answers.find(answer => answer.id === answerId)
|
|
53
55
|
);
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -64,14 +66,14 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
64
66
|
|
|
65
67
|
const nextAnswerIndex = onGetAnswers(
|
|
66
68
|
currentQuestion.answerIds!
|
|
67
|
-
).findIndex(
|
|
69
|
+
).findIndex(answer => answer?.id === currentAnswer!.id + 1);
|
|
68
70
|
|
|
69
71
|
const nextAnswerID = currentQuestion.answerIds![nextAnswerIndex];
|
|
70
72
|
|
|
71
73
|
// console.log(nextAnswerIndex);
|
|
72
74
|
|
|
73
75
|
const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(
|
|
74
|
-
|
|
76
|
+
answer => answer?.id === nextAnswerID
|
|
75
77
|
);
|
|
76
78
|
|
|
77
79
|
setCurrentAnswer(nextAnswer || onGetFirstAnswer()!);
|
|
@@ -83,14 +85,14 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
83
85
|
|
|
84
86
|
const previousAnswerIndex = onGetAnswers(
|
|
85
87
|
currentQuestion.answerIds!
|
|
86
|
-
).findIndex(
|
|
88
|
+
).findIndex(answer => answer?.id === currentAnswer!.id - 1);
|
|
87
89
|
|
|
88
90
|
const previousAnswerID =
|
|
89
91
|
currentQuestion.answerIds &&
|
|
90
92
|
currentQuestion.answerIds[previousAnswerIndex];
|
|
91
93
|
|
|
92
94
|
const previousAnswer = onGetAnswers(currentQuestion.answerIds!).find(
|
|
93
|
-
|
|
95
|
+
answer => answer?.id === previousAnswerID
|
|
94
96
|
);
|
|
95
97
|
|
|
96
98
|
if (previousAnswer) {
|
|
@@ -109,7 +111,7 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
109
111
|
} else {
|
|
110
112
|
setCurrentQuestion(
|
|
111
113
|
questions.find(
|
|
112
|
-
|
|
114
|
+
question => question.id === currentAnswer!.nextQuestionId
|
|
113
115
|
)!
|
|
114
116
|
);
|
|
115
117
|
}
|
|
@@ -124,7 +126,7 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
124
126
|
if (answer.nextQuestionId) {
|
|
125
127
|
// if there is a next question, go to it
|
|
126
128
|
setCurrentQuestion(
|
|
127
|
-
questions.find(
|
|
129
|
+
questions.find(question => question.id === answer.nextQuestionId)!
|
|
128
130
|
);
|
|
129
131
|
} else {
|
|
130
132
|
// else, finish dialog!
|
|
@@ -144,7 +146,7 @@ export const QuestionDialog: React.FC<IProps> = ({
|
|
|
144
146
|
return null;
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
return answers.map(
|
|
149
|
+
return answers.map(answer => {
|
|
148
150
|
const isSelected = currentAnswer?.id === answer?.id;
|
|
149
151
|
const selectedColor = isSelected ? 'yellow' : 'white';
|
|
150
152
|
|
|
@@ -213,7 +215,7 @@ interface IAnswerProps {
|
|
|
213
215
|
|
|
214
216
|
const Answer = styled.p<IAnswerProps>`
|
|
215
217
|
flex: auto;
|
|
216
|
-
color: ${
|
|
218
|
+
color: ${props => props.color} !important;
|
|
217
219
|
font-size: 0.65rem !important;
|
|
218
220
|
background: inherit;
|
|
219
221
|
border: none;
|
|
@@ -221,7 +223,7 @@ const Answer = styled.p<IAnswerProps>`
|
|
|
221
223
|
|
|
222
224
|
const AnswerSelectedIcon = styled.span<IAnswerProps>`
|
|
223
225
|
flex: 5% 0 0;
|
|
224
|
-
color: ${
|
|
226
|
+
color: ${props => props.color} !important;
|
|
225
227
|
`;
|
|
226
228
|
|
|
227
229
|
const AnswerRow = styled.div`
|
|
@@ -20,7 +20,7 @@ export const ProgressBar: React.FC<IBarProps> = ({
|
|
|
20
20
|
minWidth = 100,
|
|
21
21
|
style,
|
|
22
22
|
}) => {
|
|
23
|
-
const calculatePercentageValue = function
|
|
23
|
+
const calculatePercentageValue = function(max: number, value: number) {
|
|
24
24
|
if (value > max) {
|
|
25
25
|
value = max;
|
|
26
26
|
}
|
|
@@ -83,9 +83,9 @@ interface IContainerProps {
|
|
|
83
83
|
const Container = styled.div<IContainerProps>`
|
|
84
84
|
display: flex;
|
|
85
85
|
flex-direction: column;
|
|
86
|
-
min-width: ${
|
|
87
|
-
width: ${
|
|
86
|
+
min-width: ${props => props.minWidth}px;
|
|
87
|
+
width: ${props => props.percentageWidth}%;
|
|
88
88
|
justify-content: start;
|
|
89
89
|
align-items: flex-start;
|
|
90
|
-
${
|
|
90
|
+
${props => props.style}
|
|
91
91
|
`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
interface IProps {
|
|
5
|
+
value: number;
|
|
6
|
+
height?: string;
|
|
7
|
+
bgColor?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const SimpleProgressBar: React.FC<IProps> = ({
|
|
11
|
+
value,
|
|
12
|
+
|
|
13
|
+
bgColor = 'red',
|
|
14
|
+
}) => {
|
|
15
|
+
return (
|
|
16
|
+
<Container>
|
|
17
|
+
<ProgressBarContainer>
|
|
18
|
+
<BackgroundBar>
|
|
19
|
+
<Progress value={value} bgColor={bgColor} />
|
|
20
|
+
</BackgroundBar>
|
|
21
|
+
</ProgressBarContainer>
|
|
22
|
+
</Container>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Container = styled.div`
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
align-items: center;
|
|
30
|
+
width: 100%;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const BackgroundBar = styled.span`
|
|
34
|
+
background-color: rgba(0, 0, 0, 0.075);
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
interface IProgressProps {
|
|
38
|
+
value: number;
|
|
39
|
+
bgColor: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const Progress = styled.span`
|
|
43
|
+
background-color: ${(props: IProgressProps) => props.bgColor};
|
|
44
|
+
width: ${(props: IProgressProps) => props.value}%;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const ProgressBarContainer = styled.div`
|
|
48
|
+
border-radius: 60px;
|
|
49
|
+
border: 1px solid #282424;
|
|
50
|
+
overflow: hidden;
|
|
51
|
+
width: 100%;
|
|
52
|
+
span {
|
|
53
|
+
display: block;
|
|
54
|
+
height: 100%;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
height: 8px;
|
|
58
|
+
`;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import imgSrcTemplate from './imgExp.png';
|
|
4
|
+
import { SimpleProgressBar } from './SimpleProgressBar';
|
|
5
|
+
|
|
6
|
+
export interface ISkillProgressBarProps {
|
|
7
|
+
value: number;
|
|
8
|
+
|
|
9
|
+
height: string;
|
|
10
|
+
bgColor: string;
|
|
11
|
+
titleName: string;
|
|
12
|
+
|
|
13
|
+
logoSrc?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
17
|
+
value,
|
|
18
|
+
bgColor,
|
|
19
|
+
titleName,
|
|
20
|
+
|
|
21
|
+
logoSrc = imgSrcTemplate,
|
|
22
|
+
}) => {
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<ProgressTitle>
|
|
26
|
+
<TitleName>{titleName}</TitleName>
|
|
27
|
+
<ValueDisplay>{value}</ValueDisplay>
|
|
28
|
+
</ProgressTitle>
|
|
29
|
+
<ProgressBody>
|
|
30
|
+
<ProgressIconContainer>
|
|
31
|
+
<Icon src={logoSrc} />
|
|
32
|
+
</ProgressIconContainer>
|
|
33
|
+
|
|
34
|
+
<SimpleProgressBar value={value} bgColor={bgColor} />
|
|
35
|
+
</ProgressBody>
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const TitleName = styled.span`
|
|
41
|
+
margin-left: 5px;
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const ValueDisplay = styled.span``;
|
|
45
|
+
|
|
46
|
+
const ProgressIconContainer = styled.div`
|
|
47
|
+
display: flex;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
align-items: center;
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const ProgressBody = styled.div`
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: row;
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
const ProgressTitle = styled.div`
|
|
58
|
+
width: 100%;
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: row;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
span {
|
|
63
|
+
font-size: 0.6rem;
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const Icon = styled.img`
|
|
68
|
+
margin-right: 10px;
|
|
69
|
+
height: 30px;
|
|
70
|
+
`;
|
|
@@ -19,7 +19,7 @@ const Container = styled.div<IContainerProps>`
|
|
|
19
19
|
display: -webkit-box;
|
|
20
20
|
max-width: 100%;
|
|
21
21
|
max-height: 100%;
|
|
22
|
-
-webkit-line-clamp: ${
|
|
22
|
+
-webkit-line-clamp: ${props => props.maxLines};
|
|
23
23
|
-webkit-box-orient: vertical;
|
|
24
24
|
overflow: hidden;
|
|
25
25
|
`;
|
|
Binary file
|
|
@@ -8,9 +8,9 @@ interface IColumn {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const Column = styled.div<IColumn>`
|
|
11
|
-
flex: ${
|
|
11
|
+
flex: ${props => props.flex || 'auto'};
|
|
12
12
|
display: flex;
|
|
13
|
-
flex-wrap: ${
|
|
14
|
-
align-items: ${
|
|
15
|
-
justify-content: ${
|
|
13
|
+
flex-wrap: ${props => props.flexWrap || 'nowrap'};
|
|
14
|
+
align-items: ${props => props.alignItems || 'flex-start'};
|
|
15
|
+
justify-content: ${props => props.justifyContent || 'flex-start'};
|
|
16
16
|
`;
|
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './components/Button';
|
|
2
|
-
export * from './components/CheckButton';
|
|
3
2
|
export * from './components/Chat/Chat';
|
|
3
|
+
export * from './components/CheckButton';
|
|
4
|
+
export * from './components/DraggableContainer';
|
|
4
5
|
export * from './components/Dropdown';
|
|
5
6
|
export * from './components/Input';
|
|
6
7
|
export * from './components/ListMenu';
|
|
@@ -11,6 +12,7 @@ export * from './components/RadioButton';
|
|
|
11
12
|
export * from './components/RangeSlider';
|
|
12
13
|
export * from './components/RPGUIContainer';
|
|
13
14
|
export * from './components/RPGUIRoot';
|
|
15
|
+
export * from './components/SkillProgressBar';
|
|
14
16
|
export * from './components/TextArea';
|
|
15
17
|
export * from './components/Truncate';
|
|
16
18
|
export * from './components/typography/DynamicText';
|