@rpg-engine/long-bow 0.1.794 → 0.2.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.
- package/LICENSE +20 -20
- package/README.md +181 -181
- package/dist/components/Button.d.ts +1 -0
- package/dist/components/Equipment/EquipmentSet.d.ts +5 -3
- package/dist/components/Item/Cards/ItemTooltip.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +4 -6
- package/dist/components/Item/Inventory/ItemContainerTypes.d.ts +6 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +5 -9
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -7
- package/dist/components/PropertySelect/PropertySelect.d.ts +12 -0
- package/dist/components/QuestInfo/QuestInfo.d.ts +14 -0
- package/dist/components/RelativeListMenu.d.ts +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +748 -1194
- 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 +748 -1196
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/equipmentSet.mocks.d.ts +2 -2
- package/dist/stories/Button.stories.d.ts +5 -0
- package/dist/stories/Chat.stories.d.ts +5 -0
- package/dist/stories/CheckButton.stories.d.ts +5 -0
- package/dist/stories/DraggableContainer.stories.d.ts +5 -0
- package/dist/stories/Dropdown.stories.d.ts +5 -0
- package/dist/stories/EquipmentSet.stories.d.ts +5 -0
- package/dist/stories/ItemContainer.stories.d.ts +5 -0
- package/dist/stories/ListMenu.stories.d.ts +5 -0
- package/dist/stories/Multitab.stories.d.ts +6 -0
- package/dist/stories/NPCDialog.stories.d.ts +7 -0
- package/dist/stories/ProgressBar.stories.d.ts +8 -0
- package/dist/stories/PropertySelect.stories.d.ts +5 -0
- package/dist/stories/QuestInfo.stories.d.ts +5 -0
- package/dist/stories/RPGUIContainers.stories.d.ts +5 -0
- package/dist/stories/RadioButton.stories.d.ts +5 -0
- package/dist/stories/RangeSlider.stories.d.ts +5 -0
- package/dist/stories/ScrollList.stories.d.ts +5 -0
- package/dist/stories/SimpleProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillProgressBar.stories.d.ts +5 -0
- package/dist/stories/SkillsContainer.stories.d.ts +5 -0
- package/dist/stories/Text.stories.d.ts +7 -0
- package/package.json +98 -96
- package/src/components/Abstractions/SlotsContainer.tsx +42 -42
- package/src/components/Button.tsx +30 -29
- package/src/components/Chat/Chat.tsx +193 -193
- package/src/components/CheckButton.tsx +65 -65
- package/src/components/DraggableContainer.tsx +150 -150
- package/src/components/Dropdown.tsx +57 -57
- package/src/components/Equipment/EquipmentSet.tsx +138 -180
- package/src/components/Input.tsx +11 -11
- package/src/components/Item/Cards/ItemTooltip.tsx +32 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +68 -113
- package/src/components/Item/Inventory/ItemContainerTypes.ts +6 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +212 -158
- package/src/components/Item/Inventory/itemContainerHelper.ts +146 -81
- package/src/components/ListMenu.tsx +65 -65
- package/src/components/Multitab/Tab.tsx +57 -57
- package/src/components/Multitab/TabBody.tsx +13 -13
- package/src/components/Multitab/TabsContainer.tsx +97 -97
- package/src/components/NPCDialog/NPCDialog.tsx +145 -145
- package/src/components/NPCDialog/NPCDialogText.tsx +53 -53
- package/src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx +237 -242
- package/src/components/ProgressBar.tsx +91 -91
- package/src/components/PropertySelect/PropertySelect.tsx +101 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow01-right.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-left.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right-clicked.png +0 -0
- package/src/components/PropertySelect/img/ui-arrows/arrow02-right.png +0 -0
- package/src/components/QuestInfo/QuestInfo.tsx +143 -0
- package/src/components/QuestInfo/img/default.png +0 -0
- package/src/components/RPGUIContainer.tsx +47 -47
- package/src/components/RPGUIRoot.tsx +14 -14
- package/src/components/RadioButton.tsx +53 -53
- package/src/components/RangeSlider.tsx +68 -68
- package/src/components/RelativeListMenu.tsx +83 -0
- package/src/components/ScrollList.tsx +77 -77
- package/src/components/SimpleProgressBar.tsx +62 -62
- package/src/components/SkillProgressBar.tsx +123 -124
- package/src/components/SkillsContainer.tsx +196 -235
- package/src/components/TextArea.tsx +11 -11
- package/src/components/Truncate.tsx +25 -25
- package/src/components/shared/Column.tsx +16 -16
- package/src/components/shared/SpriteFromAtlas.tsx +99 -99
- package/src/components/typography/DynamicText.tsx +49 -49
- package/src/constants/uiColors.ts +10 -10
- package/src/hooks/useEventListener.ts +21 -21
- package/src/hooks/useOutsideAlerter.ts +25 -25
- package/src/index.tsx +25 -25
- package/src/libs/StringHelpers.ts +3 -3
- package/src/mocks/atlas/icons/icons.json +735 -303
- package/src/mocks/atlas/icons/icons.png +0 -0
- package/src/mocks/atlas/items/items.json +5215 -5195
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +347 -347
- package/src/mocks/itemContainer.mocks.ts +281 -249
- package/src/mocks/skills.mocks.ts +122 -122
- package/src/stories/Button.stories.tsx +36 -0
- package/src/stories/Chat.stories.tsx +170 -0
- package/src/stories/CheckButton.stories.tsx +48 -0
- package/src/stories/DraggableContainer.stories.tsx +28 -0
- package/src/stories/Dropdown.stories.tsx +46 -0
- package/src/stories/EquipmentSet.stories.tsx +51 -0
- package/src/stories/ItemContainer.stories.tsx +51 -0
- package/src/stories/ListMenu.stories.tsx +56 -0
- package/src/stories/Multitab.stories.tsx +51 -0
- package/src/stories/NPCDialog.stories.tsx +130 -0
- package/src/stories/ProgressBar.stories.tsx +23 -0
- package/src/stories/PropertySelect.stories.tsx +41 -0
- package/src/stories/QuestInfo.stories.tsx +76 -0
- package/src/stories/RPGUIContainers.stories.tsx +42 -0
- package/src/stories/RadioButton.stories.tsx +49 -0
- package/src/stories/RangeSlider.stories.tsx +60 -0
- package/src/stories/ScrollList.stories.tsx +85 -0
- package/src/stories/SimpleProgressBar.stories.tsx +22 -0
- package/src/stories/SkillProgressBar.stories.tsx +30 -0
- package/src/stories/SkillsContainer.stories.tsx +31 -0
- package/src/stories/Text.stories.tsx +42 -0
- package/src/types/eventTypes.ts +4 -4
- package/src/types/index.d.ts +2 -2
- package/dist/components/Item/Cards/ItemCard.d.ts +0 -9
- package/dist/components/shared/SpriteIcon.d.ts +0 -9
- package/dist/components/store/UI.store.d.ts +0 -38
- package/src/components/Item/Cards/ItemCard.tsx +0 -36
- package/src/components/shared/SpriteIcon.tsx +0 -67
- package/src/components/store/UI.store.ts +0 -232
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import LeftArrowClickIcon from './img/ui-arrows/arrow01-left-clicked.png';
|
|
4
|
+
import LeftArrowIcon from './img/ui-arrows/arrow01-left.png';
|
|
5
|
+
import RightArrowClickIcon from './img/ui-arrows/arrow01-right-clicked.png';
|
|
6
|
+
import RightArrowIcon from './img/ui-arrows/arrow01-right.png';
|
|
7
|
+
|
|
8
|
+
export interface IPropertySelectProps {
|
|
9
|
+
availableProperties: Array<IPropertiesProps>;
|
|
10
|
+
selectedProperty: object;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IPropertiesProps {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const PropertySelect: React.FC<IPropertySelectProps> = ({
|
|
20
|
+
availableProperties,
|
|
21
|
+
}) => {
|
|
22
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
23
|
+
const propertiesLength = availableProperties.length - 1;
|
|
24
|
+
|
|
25
|
+
const onLeftClick = () => {
|
|
26
|
+
if (currentIndex === 0) setCurrentIndex(propertiesLength);
|
|
27
|
+
else setCurrentIndex(index => index - 1);
|
|
28
|
+
};
|
|
29
|
+
const onRightClick = () => {
|
|
30
|
+
if (currentIndex === propertiesLength) setCurrentIndex(0);
|
|
31
|
+
else setCurrentIndex(index => index + 1);
|
|
32
|
+
};
|
|
33
|
+
return (
|
|
34
|
+
<Container>
|
|
35
|
+
<TextOverlay>
|
|
36
|
+
<Item>{availableProperties[currentIndex].name}</Item>
|
|
37
|
+
</TextOverlay>
|
|
38
|
+
<div className="rpgui-progress-track"></div>
|
|
39
|
+
<LeftArrow onClick={onLeftClick}></LeftArrow>
|
|
40
|
+
<RightArrow onClick={onRightClick}></RightArrow>
|
|
41
|
+
</Container>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const Item = styled.span`
|
|
46
|
+
font-size: 1rem;
|
|
47
|
+
color: white;
|
|
48
|
+
text-align: center;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 50%;
|
|
52
|
+
transform: translateX(-50%);
|
|
53
|
+
top: 12px;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const TextOverlay = styled.div`
|
|
57
|
+
width: 100%;
|
|
58
|
+
position: relative;
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
interface IContainerProps {
|
|
62
|
+
percentageWidth?: number;
|
|
63
|
+
minWidth?: number;
|
|
64
|
+
style?: Record<string, any>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const Container = styled.div<IContainerProps>`
|
|
68
|
+
position: relative;
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
justify-content: start;
|
|
72
|
+
align-items: flex-start;
|
|
73
|
+
min-width: 100px;
|
|
74
|
+
width: 40%;
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
const LeftArrow = styled.div`
|
|
78
|
+
background-image: url(${LeftArrowIcon});
|
|
79
|
+
background-size: 100% 100%;
|
|
80
|
+
left: 0;
|
|
81
|
+
position: absolute;
|
|
82
|
+
width: 40px;
|
|
83
|
+
height: 42px;
|
|
84
|
+
:active {
|
|
85
|
+
background-image: url(${LeftArrowClickIcon});
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const RightArrow = styled.div`
|
|
90
|
+
background-image: url(${RightArrowIcon});
|
|
91
|
+
right: 0;
|
|
92
|
+
position: absolute;
|
|
93
|
+
width: 40px;
|
|
94
|
+
background-size: 100% 100%;
|
|
95
|
+
height: 42px;
|
|
96
|
+
:active {
|
|
97
|
+
background-image: url(${RightArrowClickIcon});
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
export default PropertySelect;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Button, ButtonTypes } from '../Button';
|
|
4
|
+
import { DraggableContainer } from '../DraggableContainer';
|
|
5
|
+
import { RPGUIContainerTypes } from '../RPGUIContainer';
|
|
6
|
+
import { Column } from '../shared/Column';
|
|
7
|
+
|
|
8
|
+
import thumbnailDefault from './img/default.png';
|
|
9
|
+
|
|
10
|
+
export interface IQuestInfoProps {
|
|
11
|
+
title: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
button?: Array<IQuestButtonProps>;
|
|
15
|
+
thumbnail?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IQuestButtonProps {
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
title: string;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const QuestInfo: React.FC<IQuestInfoProps> = ({
|
|
25
|
+
title,
|
|
26
|
+
onClose,
|
|
27
|
+
button,
|
|
28
|
+
thumbnail,
|
|
29
|
+
children,
|
|
30
|
+
}) => {
|
|
31
|
+
return (
|
|
32
|
+
<QuestDraggableContainer
|
|
33
|
+
type={RPGUIContainerTypes.Framed}
|
|
34
|
+
onCloseButton={() => {
|
|
35
|
+
if (onClose) onClose();
|
|
36
|
+
}}
|
|
37
|
+
width="730px"
|
|
38
|
+
cancelDrag=".equipment-container-body"
|
|
39
|
+
>
|
|
40
|
+
{title && (
|
|
41
|
+
<TitleContainer className="drag-handler">
|
|
42
|
+
<Title>
|
|
43
|
+
<Thumbnail src={thumbnail || thumbnailDefault} />
|
|
44
|
+
{title}
|
|
45
|
+
</Title>
|
|
46
|
+
<QuestSplitDiv>
|
|
47
|
+
<hr className="golden" />
|
|
48
|
+
</QuestSplitDiv>
|
|
49
|
+
</TitleContainer>
|
|
50
|
+
)}
|
|
51
|
+
<Content>{children}</Content>
|
|
52
|
+
<QuestColumn className="dark-background" justifyContent="flex-end">
|
|
53
|
+
{button &&
|
|
54
|
+
button.map((item, index) => (
|
|
55
|
+
<Button
|
|
56
|
+
key={index}
|
|
57
|
+
onClick={item.onClick}
|
|
58
|
+
disabled={item.disabled}
|
|
59
|
+
buttonType={ButtonTypes.RPGUIButton}
|
|
60
|
+
id={`button-${index}`}
|
|
61
|
+
>
|
|
62
|
+
{item.title}
|
|
63
|
+
</Button>
|
|
64
|
+
))}
|
|
65
|
+
</QuestColumn>
|
|
66
|
+
</QuestDraggableContainer>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const QuestDraggableContainer = styled(DraggableContainer)`
|
|
71
|
+
border: 1px solid black;
|
|
72
|
+
width: 600px;
|
|
73
|
+
height: 500px;
|
|
74
|
+
overflow-y: scroll;
|
|
75
|
+
padding: 0 0 0 0 !important;
|
|
76
|
+
.DraggableContainer__TitleContainer-sc-184mpyl-2 {
|
|
77
|
+
height: auto;
|
|
78
|
+
}
|
|
79
|
+
.container-close {
|
|
80
|
+
position: sticky;
|
|
81
|
+
margin-left: auto;
|
|
82
|
+
top: 10px;
|
|
83
|
+
padding-right: 5px;
|
|
84
|
+
}
|
|
85
|
+
img {
|
|
86
|
+
display: inline-block;
|
|
87
|
+
vertical-align: middle;
|
|
88
|
+
line-height: normal;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
const Content = styled.div`
|
|
93
|
+
padding: 18px;
|
|
94
|
+
h1 {
|
|
95
|
+
text-align: left;
|
|
96
|
+
margin: 14px 0px;
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
const QuestSplitDiv = styled.div`
|
|
101
|
+
width: 100%;
|
|
102
|
+
font-size: 11px;
|
|
103
|
+
margin-bottom: 10px;
|
|
104
|
+
hr {
|
|
105
|
+
margin: 0px;
|
|
106
|
+
padding: 0px;
|
|
107
|
+
}
|
|
108
|
+
p {
|
|
109
|
+
margin-bottom: 0px;
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
const QuestColumn = styled(Column)`
|
|
114
|
+
background: #4e4a4e;
|
|
115
|
+
padding-top: 5px;
|
|
116
|
+
position: sticky;
|
|
117
|
+
bottom: 0;
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
const TitleContainer = styled.div`
|
|
121
|
+
background: #4e4a4e;
|
|
122
|
+
position: sticky;
|
|
123
|
+
top: 0;
|
|
124
|
+
width: 100%;
|
|
125
|
+
display: flex;
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
justify-content: flex-start;
|
|
128
|
+
align-items: center;
|
|
129
|
+
`;
|
|
130
|
+
|
|
131
|
+
const Title = styled.h1`
|
|
132
|
+
color: white;
|
|
133
|
+
z-index: 22;
|
|
134
|
+
font-size: 0.6rem;
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
const Thumbnail = styled.img`
|
|
138
|
+
color: white;
|
|
139
|
+
z-index: 22;
|
|
140
|
+
font-size: 10px;
|
|
141
|
+
width: 64px;
|
|
142
|
+
margin-right: 0.5rem;
|
|
143
|
+
`;
|
|
Binary file
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
|
|
4
|
-
export enum RPGUIContainerTypes {
|
|
5
|
-
Framed = 'framed',
|
|
6
|
-
FramedGold = 'framed-golden',
|
|
7
|
-
FramedGold2 = 'framed-golden-2',
|
|
8
|
-
FramedGrey = 'framed-grey',
|
|
9
|
-
}
|
|
10
|
-
export interface IRPGUIContainerProps {
|
|
11
|
-
type: RPGUIContainerTypes;
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
width?: string;
|
|
14
|
-
height?: string;
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const RPGUIContainer: React.FC<IRPGUIContainerProps> = ({
|
|
19
|
-
children,
|
|
20
|
-
type,
|
|
21
|
-
width = '50%',
|
|
22
|
-
height,
|
|
23
|
-
className,
|
|
24
|
-
}) => {
|
|
25
|
-
return (
|
|
26
|
-
<Container
|
|
27
|
-
width={width}
|
|
28
|
-
height={height || 'auto'}
|
|
29
|
-
className={`rpgui-container ${type} ${className}`}
|
|
30
|
-
>
|
|
31
|
-
{children}
|
|
32
|
-
</Container>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
interface IContainerProps {
|
|
37
|
-
width: string;
|
|
38
|
-
height: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const Container = styled.div<IContainerProps>`
|
|
42
|
-
height: ${props => props.height};
|
|
43
|
-
width: ${({ width }) => width};
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-wrap: wrap;
|
|
46
|
-
image-rendering: pixelated;
|
|
47
|
-
`;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
export enum RPGUIContainerTypes {
|
|
5
|
+
Framed = 'framed',
|
|
6
|
+
FramedGold = 'framed-golden',
|
|
7
|
+
FramedGold2 = 'framed-golden-2',
|
|
8
|
+
FramedGrey = 'framed-grey',
|
|
9
|
+
}
|
|
10
|
+
export interface IRPGUIContainerProps {
|
|
11
|
+
type: RPGUIContainerTypes;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
width?: string;
|
|
14
|
+
height?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const RPGUIContainer: React.FC<IRPGUIContainerProps> = ({
|
|
19
|
+
children,
|
|
20
|
+
type,
|
|
21
|
+
width = '50%',
|
|
22
|
+
height,
|
|
23
|
+
className,
|
|
24
|
+
}) => {
|
|
25
|
+
return (
|
|
26
|
+
<Container
|
|
27
|
+
width={width}
|
|
28
|
+
height={height || 'auto'}
|
|
29
|
+
className={`rpgui-container ${type} ${className}`}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</Container>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
interface IContainerProps {
|
|
37
|
+
width: string;
|
|
38
|
+
height: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Container = styled.div<IContainerProps>`
|
|
42
|
+
height: ${props => props.height};
|
|
43
|
+
width: ${({ width }) => width};
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-wrap: wrap;
|
|
46
|
+
image-rendering: pixelated;
|
|
47
|
+
`;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import 'rpgui/rpgui.min.css';
|
|
3
|
-
import 'rpgui/rpgui.min.js';
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
//@ts-ignore
|
|
10
|
-
export const _RPGUI = RPGUI;
|
|
11
|
-
|
|
12
|
-
export const RPGUIRoot: React.FC<IProps> = ({ children }) => {
|
|
13
|
-
return <div className="rpgui-content">{children}</div>;
|
|
14
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'rpgui/rpgui.min.css';
|
|
3
|
+
import 'rpgui/rpgui.min.js';
|
|
4
|
+
|
|
5
|
+
interface IProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
export const _RPGUI = RPGUI;
|
|
11
|
+
|
|
12
|
+
export const RPGUIRoot: React.FC<IProps> = ({ children }) => {
|
|
13
|
+
return <div className="rpgui-content">{children}</div>;
|
|
14
|
+
};
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface IRadioItems {
|
|
4
|
-
label: string;
|
|
5
|
-
value: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface IRadioProps {
|
|
9
|
-
name: string;
|
|
10
|
-
items: IRadioItems[];
|
|
11
|
-
onChange: (value: string) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const InputRadio: React.FC<IRadioProps> = ({
|
|
15
|
-
name,
|
|
16
|
-
items,
|
|
17
|
-
onChange,
|
|
18
|
-
}) => {
|
|
19
|
-
const [selectedValue, setSelectedValue] = useState<string>();
|
|
20
|
-
const handleClick = () => {
|
|
21
|
-
let element = document.querySelector(
|
|
22
|
-
`input[name=${name}]:checked`
|
|
23
|
-
) as HTMLInputElement;
|
|
24
|
-
const elementValue = element.value;
|
|
25
|
-
setSelectedValue(elementValue);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (selectedValue) {
|
|
30
|
-
onChange(selectedValue);
|
|
31
|
-
}
|
|
32
|
-
}, [selectedValue]);
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div id="elemento-radio">
|
|
36
|
-
{items.map(element => {
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
<input
|
|
40
|
-
key={element.value}
|
|
41
|
-
className="rpgui-radio"
|
|
42
|
-
value={element.value}
|
|
43
|
-
name={name}
|
|
44
|
-
type="radio"
|
|
45
|
-
/>
|
|
46
|
-
<label onClick={handleClick}>{element.label}</label>
|
|
47
|
-
<br />
|
|
48
|
-
</>
|
|
49
|
-
);
|
|
50
|
-
})}
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface IRadioItems {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IRadioProps {
|
|
9
|
+
name: string;
|
|
10
|
+
items: IRadioItems[];
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const InputRadio: React.FC<IRadioProps> = ({
|
|
15
|
+
name,
|
|
16
|
+
items,
|
|
17
|
+
onChange,
|
|
18
|
+
}) => {
|
|
19
|
+
const [selectedValue, setSelectedValue] = useState<string>();
|
|
20
|
+
const handleClick = () => {
|
|
21
|
+
let element = document.querySelector(
|
|
22
|
+
`input[name=${name}]:checked`
|
|
23
|
+
) as HTMLInputElement;
|
|
24
|
+
const elementValue = element.value;
|
|
25
|
+
setSelectedValue(elementValue);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (selectedValue) {
|
|
30
|
+
onChange(selectedValue);
|
|
31
|
+
}
|
|
32
|
+
}, [selectedValue]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div id="elemento-radio">
|
|
36
|
+
{items.map(element => {
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<input
|
|
40
|
+
key={element.value}
|
|
41
|
+
className="rpgui-radio"
|
|
42
|
+
value={element.value}
|
|
43
|
+
name={name}
|
|
44
|
+
type="radio"
|
|
45
|
+
/>
|
|
46
|
+
<label onClick={handleClick}>{element.label}</label>
|
|
47
|
+
<br />
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
})}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
-
import { useEventListener } from '../hooks/useEventListener';
|
|
5
|
-
import { _RPGUI } from './RPGUIRoot';
|
|
6
|
-
|
|
7
|
-
export enum RangeSliderType {
|
|
8
|
-
Slider = 'rpgui-slider',
|
|
9
|
-
GoldSlider = 'rpgui-slider golden',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IRangeSliderProps {
|
|
13
|
-
type: RangeSliderType;
|
|
14
|
-
valueMin: number;
|
|
15
|
-
valueMax: number;
|
|
16
|
-
width: string;
|
|
17
|
-
onChange: (value: number) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const RangeSlider: React.FC<IRangeSliderProps> = ({
|
|
21
|
-
type,
|
|
22
|
-
valueMin,
|
|
23
|
-
valueMax,
|
|
24
|
-
width,
|
|
25
|
-
onChange,
|
|
26
|
-
}) => {
|
|
27
|
-
const sliderId = uuidv4();
|
|
28
|
-
|
|
29
|
-
const [wasMouseDownFirst, setWasMouseDownFirst] = useState<boolean>(false);
|
|
30
|
-
|
|
31
|
-
useEventListener('mouseup', () => {
|
|
32
|
-
if (wasMouseDownFirst) {
|
|
33
|
-
onHandleMouseUp();
|
|
34
|
-
}
|
|
35
|
-
setWasMouseDownFirst(false);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const onHandleMouseUp = () => {
|
|
39
|
-
const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);
|
|
40
|
-
const value = _RPGUI.get_value(rpguiSlider);
|
|
41
|
-
|
|
42
|
-
onChange(Number(value));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div
|
|
47
|
-
onMouseUp={onHandleMouseUp}
|
|
48
|
-
onMouseDown={() => setWasMouseDownFirst(true)}
|
|
49
|
-
>
|
|
50
|
-
<Input
|
|
51
|
-
className={
|
|
52
|
-
type === RangeSliderType.Slider
|
|
53
|
-
? RangeSliderType.Slider
|
|
54
|
-
: RangeSliderType.GoldSlider
|
|
55
|
-
}
|
|
56
|
-
type="range"
|
|
57
|
-
style={{ width: width }}
|
|
58
|
-
min={valueMin}
|
|
59
|
-
max={valueMax}
|
|
60
|
-
id={`rpgui-slider-${sliderId}`}
|
|
61
|
-
/>
|
|
62
|
-
</div>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const Input = styled.input`
|
|
67
|
-
opacity: 0;
|
|
68
|
-
`;
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
import { useEventListener } from '../hooks/useEventListener';
|
|
5
|
+
import { _RPGUI } from './RPGUIRoot';
|
|
6
|
+
|
|
7
|
+
export enum RangeSliderType {
|
|
8
|
+
Slider = 'rpgui-slider',
|
|
9
|
+
GoldSlider = 'rpgui-slider golden',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IRangeSliderProps {
|
|
13
|
+
type: RangeSliderType;
|
|
14
|
+
valueMin: number;
|
|
15
|
+
valueMax: number;
|
|
16
|
+
width: string;
|
|
17
|
+
onChange: (value: number) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const RangeSlider: React.FC<IRangeSliderProps> = ({
|
|
21
|
+
type,
|
|
22
|
+
valueMin,
|
|
23
|
+
valueMax,
|
|
24
|
+
width,
|
|
25
|
+
onChange,
|
|
26
|
+
}) => {
|
|
27
|
+
const sliderId = uuidv4();
|
|
28
|
+
|
|
29
|
+
const [wasMouseDownFirst, setWasMouseDownFirst] = useState<boolean>(false);
|
|
30
|
+
|
|
31
|
+
useEventListener('mouseup', () => {
|
|
32
|
+
if (wasMouseDownFirst) {
|
|
33
|
+
onHandleMouseUp();
|
|
34
|
+
}
|
|
35
|
+
setWasMouseDownFirst(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const onHandleMouseUp = () => {
|
|
39
|
+
const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);
|
|
40
|
+
const value = _RPGUI.get_value(rpguiSlider);
|
|
41
|
+
|
|
42
|
+
onChange(Number(value));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
onMouseUp={onHandleMouseUp}
|
|
48
|
+
onMouseDown={() => setWasMouseDownFirst(true)}
|
|
49
|
+
>
|
|
50
|
+
<Input
|
|
51
|
+
className={
|
|
52
|
+
type === RangeSliderType.Slider
|
|
53
|
+
? RangeSliderType.Slider
|
|
54
|
+
: RangeSliderType.GoldSlider
|
|
55
|
+
}
|
|
56
|
+
type="range"
|
|
57
|
+
style={{ width: width }}
|
|
58
|
+
min={valueMin}
|
|
59
|
+
max={valueMax}
|
|
60
|
+
id={`rpgui-slider-${sliderId}`}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const Input = styled.input`
|
|
67
|
+
opacity: 0;
|
|
68
|
+
`;
|