@rpg-engine/long-bow 0.8.10 → 0.8.12
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/Item/Inventory/ItemGem.d.ts +3 -0
- package/dist/components/itemSelector/GemSelector.d.ts +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +1593 -105
- 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 +1593 -107
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/UI/dropdownsAndSelectors/GemSelector.stories.d.ts +5 -0
- package/package.json +2 -2
- package/src/components/Item/Inventory/ItemGem.tsx +1 -1
- package/src/components/Item/Inventory/itemContainerHelper.ts +4 -0
- package/src/components/itemSelector/GemSelector.tsx +203 -0
- package/src/index.tsx +2 -0
- package/src/stories/UI/dropdownsAndSelectors/GemSelector.stories.tsx +66 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { IGemSelectorProps } from '../../../components/itemSelector/GemSelector';
|
|
3
|
+
declare const meta: Meta<IGemSelectorProps>;
|
|
4
|
+
export default meta;
|
|
5
|
+
export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IGemSelectorProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/long-bow",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@capacitor/core": "^6.1.0",
|
|
86
86
|
"@rollup/plugin-image": "^2.1.1",
|
|
87
|
-
"@rpg-engine/shared": "^0.9.
|
|
87
|
+
"@rpg-engine/shared": "^0.9.96",
|
|
88
88
|
"dayjs": "^1.11.2",
|
|
89
89
|
"font-awesome": "^4.7.0",
|
|
90
90
|
"fs-extra": "^10.1.0",
|
|
@@ -6,7 +6,7 @@ interface IProps {
|
|
|
6
6
|
item: IItem;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const gemColors: { [key: string]: string } = {
|
|
9
|
+
export const gemColors: { [key: string]: string } = {
|
|
10
10
|
'emerald-gem': '#50C878', // Emerald green
|
|
11
11
|
'topaz-radiance': '#FFC87C', // Topaz yellow
|
|
12
12
|
'sapphire-gem': '#0F52BA', // Sapphire blue
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { IGemSchema, IItem } from '@rpg-engine/shared';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { uiColors } from '../../constants/uiColors';
|
|
5
|
+
import { Button, ButtonTypes } from '../Button';
|
|
6
|
+
import { CheckItem } from '../CheckItem';
|
|
7
|
+
import { useResponsiveSize } from '../CraftBook/hooks/useResponsiveSize';
|
|
8
|
+
import { DraggableContainer } from '../DraggableContainer';
|
|
9
|
+
import { RPGUIContainerTypes } from '../RPGUI/RPGUIContainer';
|
|
10
|
+
import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
|
|
11
|
+
|
|
12
|
+
export interface IGemSelectorProps {
|
|
13
|
+
atlasJSON: any;
|
|
14
|
+
atlasIMG: any;
|
|
15
|
+
item: IItem;
|
|
16
|
+
scale?: number;
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
onSelect: (selectedGems: IGemSchema[]) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const GemSelector: React.FC<IGemSelectorProps> = ({
|
|
22
|
+
atlasJSON,
|
|
23
|
+
atlasIMG,
|
|
24
|
+
item,
|
|
25
|
+
scale,
|
|
26
|
+
onClose,
|
|
27
|
+
onSelect,
|
|
28
|
+
}) => {
|
|
29
|
+
const [selectedGems, setSelectedGems] = useState<IGemSchema[]>([]);
|
|
30
|
+
const size = useResponsiveSize(scale);
|
|
31
|
+
|
|
32
|
+
const handleGemToggle = (gem: IGemSchema) => {
|
|
33
|
+
setSelectedGems(prev =>
|
|
34
|
+
prev.some(selected => selected.key === gem.key)
|
|
35
|
+
? prev.filter(selected => selected.key !== gem.key)
|
|
36
|
+
: [...prev, gem]
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const handleConfirm = () => {
|
|
41
|
+
onSelect(selectedGems);
|
|
42
|
+
onClose();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (!size) return null;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<DraggableContainer
|
|
49
|
+
type={RPGUIContainerTypes.Framed}
|
|
50
|
+
width="450px"
|
|
51
|
+
height={size.height}
|
|
52
|
+
scale={scale}
|
|
53
|
+
cancelDrag=".gem-selector-container"
|
|
54
|
+
onCloseButton={onClose}
|
|
55
|
+
>
|
|
56
|
+
<ContentWrapper>
|
|
57
|
+
<Header>
|
|
58
|
+
<Title>GEM SELECTION</Title>
|
|
59
|
+
<Subtitle>Select gems to detach</Subtitle>
|
|
60
|
+
</Header>
|
|
61
|
+
|
|
62
|
+
<GemGrid>
|
|
63
|
+
{item.attachedGems?.map((gem, index) => {
|
|
64
|
+
return (
|
|
65
|
+
<GemItem key={`${gem.key}-${index}`}>
|
|
66
|
+
<CheckItemWrapper>
|
|
67
|
+
<CheckItem
|
|
68
|
+
defaultValue={selectedGems.some(
|
|
69
|
+
selected => selected.key === gem.key
|
|
70
|
+
)}
|
|
71
|
+
onChange={() => {
|
|
72
|
+
handleGemToggle(gem);
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
</CheckItemWrapper>
|
|
76
|
+
<SpriteWrapper>
|
|
77
|
+
<SpriteFromAtlas
|
|
78
|
+
atlasIMG={atlasIMG}
|
|
79
|
+
atlasJSON={atlasJSON}
|
|
80
|
+
spriteKey={`gems/${gem.key}.png`}
|
|
81
|
+
imgScale={2}
|
|
82
|
+
imgClassname="gem-sprite"
|
|
83
|
+
centered={true}
|
|
84
|
+
/>
|
|
85
|
+
</SpriteWrapper>
|
|
86
|
+
<GemName>
|
|
87
|
+
{gem.name.replace(/ of /gi, '\n').toUpperCase()}
|
|
88
|
+
</GemName>
|
|
89
|
+
</GemItem>
|
|
90
|
+
);
|
|
91
|
+
})}
|
|
92
|
+
</GemGrid>
|
|
93
|
+
|
|
94
|
+
<ButtonWrapper>
|
|
95
|
+
<Button
|
|
96
|
+
buttonType={ButtonTypes.RPGUIButton}
|
|
97
|
+
onPointerDown={() => {
|
|
98
|
+
onClose();
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
Cancel
|
|
102
|
+
</Button>
|
|
103
|
+
<Button
|
|
104
|
+
buttonType={ButtonTypes.RPGUIButton}
|
|
105
|
+
onPointerDown={() => {
|
|
106
|
+
handleConfirm();
|
|
107
|
+
}}
|
|
108
|
+
disabled={selectedGems.length === 0}
|
|
109
|
+
>
|
|
110
|
+
Confirm
|
|
111
|
+
</Button>
|
|
112
|
+
</ButtonWrapper>
|
|
113
|
+
</ContentWrapper>
|
|
114
|
+
</DraggableContainer>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const Title = styled.h1`
|
|
119
|
+
font-size: 0.8rem;
|
|
120
|
+
color: ${uiColors.yellow} !important;
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
const Subtitle = styled.h2`
|
|
124
|
+
font-size: 0.6rem;
|
|
125
|
+
color: ${uiColors.white};
|
|
126
|
+
margin: 0;
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
const Header = styled.div`
|
|
130
|
+
text-align: center;
|
|
131
|
+
padding: 5px;
|
|
132
|
+
border-bottom: 2px solid #444;
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
const GemGrid = styled.div`
|
|
136
|
+
display: grid;
|
|
137
|
+
grid-template-columns: repeat(3, 1fr);
|
|
138
|
+
gap: 15px;
|
|
139
|
+
margin-bottom: 20px;
|
|
140
|
+
margin-top: 10px;
|
|
141
|
+
min-height: 150px;
|
|
142
|
+
overflow-y: auto;
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
const ContentWrapper = styled.div`
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
align-items: center;
|
|
149
|
+
margin-left: 20px;
|
|
150
|
+
justify-content: space-between;
|
|
151
|
+
height: 100%;
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
const GemItem = styled.div`
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
align-items: center;
|
|
158
|
+
justify-content: space-between;
|
|
159
|
+
background-color: ${uiColors.darkGray} !important;
|
|
160
|
+
height: 100px;
|
|
161
|
+
width: 90px;
|
|
162
|
+
padding: 5px;
|
|
163
|
+
`;
|
|
164
|
+
|
|
165
|
+
const GemName = styled.div`
|
|
166
|
+
font-size: 0.5rem;
|
|
167
|
+
color: ${uiColors.yellow} !important;
|
|
168
|
+
text-align: center;
|
|
169
|
+
text-transform: uppercase;
|
|
170
|
+
line-height: 1.2;
|
|
171
|
+
width: 100%;
|
|
172
|
+
min-height: 30px;
|
|
173
|
+
display: -webkit-box;
|
|
174
|
+
-webkit-line-clamp: 2;
|
|
175
|
+
-webkit-box-orient: vertical;
|
|
176
|
+
word-break: break-word;
|
|
177
|
+
`;
|
|
178
|
+
|
|
179
|
+
const ButtonWrapper = styled.div`
|
|
180
|
+
display: flex;
|
|
181
|
+
justify-content: center;
|
|
182
|
+
align-self: center;
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
const CheckItemWrapper = styled.div`
|
|
186
|
+
display: flex;
|
|
187
|
+
justify-content: center;
|
|
188
|
+
width: 100%;
|
|
189
|
+
height: 20px;
|
|
190
|
+
|
|
191
|
+
input.rpgui-checkbox + label {
|
|
192
|
+
margin: 0 !important;
|
|
193
|
+
padding-left: 23px !important;
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
196
|
+
|
|
197
|
+
const SpriteWrapper = styled.div`
|
|
198
|
+
display: flex;
|
|
199
|
+
align-items: center;
|
|
200
|
+
justify-content: center;
|
|
201
|
+
width: 100%;
|
|
202
|
+
height: 50px;
|
|
203
|
+
`;
|
package/src/index.tsx
CHANGED
|
@@ -18,6 +18,7 @@ export * from './components/Friends/FriendList';
|
|
|
18
18
|
export * from './components/HistoryDialog';
|
|
19
19
|
export * from './components/ImageCarousel/ImageCarousel';
|
|
20
20
|
export * from './components/ImageCarousel/SimpleImageCarousel';
|
|
21
|
+
export * from './components/InformationCenter/InformationCenter';
|
|
21
22
|
export * from './components/Input';
|
|
22
23
|
export * from './components/InternalTabs/InternalTabs';
|
|
23
24
|
export { ErrorBoundary } from './components/Item/Inventory/ErrorBoundary';
|
|
@@ -25,6 +26,7 @@ export * from './components/Item/Inventory/ItemContainer';
|
|
|
25
26
|
export * from './components/Item/Inventory/ItemPropertySimpleHandler';
|
|
26
27
|
export * from './components/Item/Inventory/ItemQuantitySelectorModal';
|
|
27
28
|
export * from './components/Item/Inventory/ItemSlot';
|
|
29
|
+
export * from './components/itemSelector/GemSelector';
|
|
28
30
|
export * from './components/itemSelector/ItemSelector';
|
|
29
31
|
export * from './components/Leaderboard/Leaderboard';
|
|
30
32
|
export * from './components/ListMenu';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IItem, ItemType } from '@rpg-engine/shared';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { RPGUIRoot } from '../../..';
|
|
5
|
+
import {
|
|
6
|
+
GemSelector,
|
|
7
|
+
IGemSelectorProps,
|
|
8
|
+
} from '../../../components/itemSelector/GemSelector';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<IGemSelectorProps> = {
|
|
11
|
+
title: 'UI/Dropdowns & Selectors/Gem Selector',
|
|
12
|
+
component: GemSelector,
|
|
13
|
+
parameters: {
|
|
14
|
+
controls: { expanded: true },
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
const Template: Story<IGemSelectorProps> = args => (
|
|
21
|
+
<RPGUIRoot>
|
|
22
|
+
<GemSelector {...args} />
|
|
23
|
+
</RPGUIRoot>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const mockItem = ({
|
|
27
|
+
_id: '123',
|
|
28
|
+
name: 'Example Item',
|
|
29
|
+
type: ItemType.Armor,
|
|
30
|
+
texturePath: 'weapons/sword.png',
|
|
31
|
+
attachedGems: [
|
|
32
|
+
{
|
|
33
|
+
key: 'emerald-gem',
|
|
34
|
+
name: 'Emerald of Power',
|
|
35
|
+
texturePath: 'gems/emerald-gem.png',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'ruby-gem',
|
|
39
|
+
name: 'Ruby of Fire',
|
|
40
|
+
texturePath: 'gems/ruby-gem.png',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: 'sapphire-gem',
|
|
44
|
+
name: 'Sapphire of Wisdom',
|
|
45
|
+
texturePath: 'gems/sapphire-gem.png',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: 'earthstone-gem',
|
|
49
|
+
name: 'EarthStone Guardian',
|
|
50
|
+
texturePath: 'gems/earthstone-gem.png',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
} as unknown) as IItem;
|
|
54
|
+
|
|
55
|
+
export const Default = Template.bind({});
|
|
56
|
+
Default.args = {
|
|
57
|
+
atlasJSON: require('../../../mocks/atlas/items/items.json'),
|
|
58
|
+
atlasIMG: require('../../../mocks/atlas/items/items.png'),
|
|
59
|
+
item: mockItem,
|
|
60
|
+
onClose: () => console.log('Closing Gem Selector'),
|
|
61
|
+
onSelect: gems =>
|
|
62
|
+
console.log(
|
|
63
|
+
'Selected gems:',
|
|
64
|
+
gems.map(gem => gem.name)
|
|
65
|
+
), // Agora imprime os nomes das gemas
|
|
66
|
+
};
|