@rpg-engine/long-bow 0.2.23 → 0.2.25
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/Equipment/EquipmentSet.d.ts +2 -0
- package/dist/components/Item/Inventory/ErrorBoundary.d.ts +14 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +2 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +2 -0
- package/dist/libs/ItemSlotHelper.d.ts +2 -0
- package/dist/long-bow.cjs.development.js +1879 -1263
- 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 +1886 -1270
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Character/CharacterSelection.tsx +19 -11
- package/src/components/Equipment/EquipmentSet.tsx +6 -0
- package/src/components/Item/Inventory/ErrorBoundary.tsx +43 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +6 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +53 -25
- package/src/components/SkillProgressBar.tsx +11 -8
- package/src/libs/ItemSlotHelper.ts +21 -0
- package/src/mocks/atlas/items/items.json +748 -244
- package/src/mocks/atlas/items/items.png +0 -0
- package/src/mocks/equipmentSet.mocks.ts +19 -14
- package/src/mocks/itemContainer.mocks.ts +226 -3
- package/src/stories/CharacterSelection.stories.tsx +4 -0
- package/src/stories/EquipmentSet.stories.tsx +4 -0
- package/src/stories/ItemContainer.stories.tsx +4 -0
- package/src/components/NPCDialog/.DS_Store +0 -0
- package/src/mocks/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { SpriteFromAtlas } from '../shared/SpriteFromAtlas';
|
|
|
5
5
|
|
|
6
6
|
import entitiesJSON from '../../mocks/atlas/entities/entities.json';
|
|
7
7
|
import entitiesIMG from '../../mocks/atlas/entities/entities.png';
|
|
8
|
+
import { ErrorBoundary } from '../Item/Inventory/ErrorBoundary';
|
|
8
9
|
import PropertySelect, {
|
|
9
10
|
IPropertiesProps,
|
|
10
11
|
} from '../PropertySelect/PropertySelect';
|
|
@@ -56,17 +57,24 @@ export const CharacterSelection: React.FC<ICharacterSelectionProps> = ({
|
|
|
56
57
|
return (
|
|
57
58
|
<Container>
|
|
58
59
|
{selectedSpriteKey && (
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
<ErrorBoundary>
|
|
61
|
+
<SpriteFromAtlas
|
|
62
|
+
spriteKey={selectedSpriteKey}
|
|
63
|
+
atlasIMG={entitiesIMG}
|
|
64
|
+
atlasJSON={entitiesJSON}
|
|
65
|
+
imgScale={4}
|
|
66
|
+
height={80}
|
|
67
|
+
width={64}
|
|
68
|
+
containerStyle={{
|
|
69
|
+
display: 'flex',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
paddingBottom: '15px',
|
|
72
|
+
}}
|
|
73
|
+
imgStyle={{
|
|
74
|
+
left: '22px',
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
</ErrorBoundary>
|
|
70
78
|
)}
|
|
71
79
|
<PropertySelect
|
|
72
80
|
availableProperties={propertySelectValues}
|
|
@@ -24,6 +24,8 @@ export interface IEquipmentSetProps {
|
|
|
24
24
|
onSelected?: (optionId: string) => void;
|
|
25
25
|
initialPosition?: { x: number; y: number };
|
|
26
26
|
type: ItemContainerType | null;
|
|
27
|
+
atlasIMG: any;
|
|
28
|
+
atlasJSON: any;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
@@ -32,6 +34,8 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
32
34
|
onMouseOver,
|
|
33
35
|
onSelected,
|
|
34
36
|
onItemClick,
|
|
37
|
+
atlasIMG,
|
|
38
|
+
atlasJSON,
|
|
35
39
|
}) => {
|
|
36
40
|
const {
|
|
37
41
|
neck,
|
|
@@ -98,6 +102,8 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
98
102
|
onSelected={(optionId: string) => {
|
|
99
103
|
if (onSelected) onSelected(optionId);
|
|
100
104
|
}}
|
|
105
|
+
atlasIMG={atlasIMG}
|
|
106
|
+
atlasJSON={atlasJSON}
|
|
101
107
|
/>
|
|
102
108
|
);
|
|
103
109
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
+
import atlasJSON from '../../../mocks/atlas/items/items.json';
|
|
3
|
+
import atlasIMG from '../../../mocks/atlas/items/items.png';
|
|
4
|
+
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface State {
|
|
11
|
+
hasError: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ErrorBoundary extends Component<Props, State> {
|
|
15
|
+
public state: State = {
|
|
16
|
+
hasError: false,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
public static getDerivedStateFromError(_: Error): State {
|
|
20
|
+
// Update state so the next render will show the fallback UI.
|
|
21
|
+
return { hasError: true };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
25
|
+
console.error('Uncaught error:', error, errorInfo);
|
|
26
|
+
console.log('quelquer cois');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public render() {
|
|
30
|
+
if (this.state.hasError) {
|
|
31
|
+
return (
|
|
32
|
+
<SpriteFromAtlas
|
|
33
|
+
atlasIMG={atlasIMG}
|
|
34
|
+
atlasJSON={atlasJSON}
|
|
35
|
+
spriteKey={'others/no-image.png'}
|
|
36
|
+
imgScale={3}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return this.props.children;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -16,6 +16,8 @@ export interface IItemContainerProps {
|
|
|
16
16
|
onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
|
|
17
17
|
onSelected?: (optionId: string, item: IItem) => void;
|
|
18
18
|
type: ItemContainerType;
|
|
19
|
+
atlasJSON: any;
|
|
20
|
+
atlasIMG: any;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
@@ -25,6 +27,8 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
25
27
|
onSelected,
|
|
26
28
|
onItemClick,
|
|
27
29
|
type,
|
|
30
|
+
atlasJSON,
|
|
31
|
+
atlasIMG,
|
|
28
32
|
}) => {
|
|
29
33
|
const onRenderSlots = () => {
|
|
30
34
|
const slots = [];
|
|
@@ -45,6 +49,8 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
45
49
|
onSelected={(optionId: string, item: IItem) => {
|
|
46
50
|
if (onSelected) onSelected(optionId, item);
|
|
47
51
|
}}
|
|
52
|
+
atlasIMG={atlasIMG}
|
|
53
|
+
atlasJSON={atlasJSON}
|
|
48
54
|
/>
|
|
49
55
|
);
|
|
50
56
|
}
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
import { observer } from 'mobx-react-lite';
|
|
10
10
|
import React, { useEffect, useState } from 'react';
|
|
11
11
|
import styled from 'styled-components';
|
|
12
|
-
import
|
|
13
|
-
import atlasIMG from '../../../mocks/atlas/items/items.png';
|
|
12
|
+
import { getItemTextureKeyPath } from '../../../libs/ItemSlotHelper';
|
|
14
13
|
import { RelativeListMenu } from '../../RelativeListMenu';
|
|
15
14
|
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
16
15
|
import { ItemTooltip } from '../Cards/ItemTooltip';
|
|
16
|
+
import { ErrorBoundary } from './ErrorBoundary';
|
|
17
17
|
import { generateContextMenu, IContextMenuItem } from './itemContainerHelper';
|
|
18
18
|
|
|
19
19
|
const EquipmentSlotSpriteByType: any = {
|
|
@@ -49,6 +49,8 @@ interface IProps {
|
|
|
49
49
|
itemContainerType: ItemContainerType | null,
|
|
50
50
|
item: IItem
|
|
51
51
|
) => void;
|
|
52
|
+
atlasJSON: any;
|
|
53
|
+
atlasIMG: any;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
export const ItemSlot: React.FC<IProps> = observer(
|
|
@@ -61,6 +63,8 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
61
63
|
onMouseOut,
|
|
62
64
|
onClick,
|
|
63
65
|
onSelected,
|
|
66
|
+
atlasJSON,
|
|
67
|
+
atlasIMG,
|
|
64
68
|
}) => {
|
|
65
69
|
const [isTooltipVisible, setTooltipVisible] = useState(false);
|
|
66
70
|
|
|
@@ -96,18 +100,38 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
96
100
|
return undefined;
|
|
97
101
|
};
|
|
98
102
|
|
|
103
|
+
// const getItemTextureKeyPath = (itemToRender: IItem) => {
|
|
104
|
+
// const stackQty = itemToRender?.stackQty ?? 0;
|
|
105
|
+
// let itemTexturePath = itemToRender.texturePath;
|
|
106
|
+
|
|
107
|
+
// if (stackQty > 1) {
|
|
108
|
+
// const txtExtension: string = itemToRender.texturePath.split('.')[1];
|
|
109
|
+
// const txtDir: string = itemToRender.texturePath.split('/')[0];
|
|
110
|
+
// const idx = stackQty >= 5 ? '5' : stackQty;
|
|
111
|
+
// const newTexturePath = `${txtDir}/${itemToRender.textureKey}-qty-${idx}.${txtExtension}`;
|
|
112
|
+
// const spriteData = atlasJSON.frames[newTexturePath];
|
|
113
|
+
|
|
114
|
+
// if (spriteData !== undefined) {
|
|
115
|
+
// itemTexturePath = newTexturePath;
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
|
|
119
|
+
// return itemTexturePath;
|
|
120
|
+
// };
|
|
121
|
+
|
|
99
122
|
const renderItem = (itemToRender: IItem | null) => {
|
|
100
123
|
const element = [];
|
|
101
124
|
if (itemToRender?.texturePath) {
|
|
102
|
-
console.table(itemToRender);
|
|
103
125
|
element.push(
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
<ErrorBoundary>
|
|
127
|
+
<SpriteFromAtlas
|
|
128
|
+
key={itemToRender._id}
|
|
129
|
+
atlasIMG={atlasIMG}
|
|
130
|
+
atlasJSON={atlasJSON}
|
|
131
|
+
spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
|
|
132
|
+
imgScale={3}
|
|
133
|
+
/>
|
|
134
|
+
</ErrorBoundary>
|
|
111
135
|
);
|
|
112
136
|
}
|
|
113
137
|
const stackInfo = getStackInfo(
|
|
@@ -128,13 +152,15 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
128
152
|
) {
|
|
129
153
|
const element = [];
|
|
130
154
|
element.push(
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
<ErrorBoundary>
|
|
156
|
+
<SpriteFromAtlas
|
|
157
|
+
key={itemToRender._id}
|
|
158
|
+
atlasIMG={atlasIMG}
|
|
159
|
+
atlasJSON={atlasJSON}
|
|
160
|
+
spriteKey={getItemTextureKeyPath(itemToRender, atlasJSON)}
|
|
161
|
+
imgScale={3}
|
|
162
|
+
/>
|
|
163
|
+
</ErrorBoundary>
|
|
138
164
|
);
|
|
139
165
|
const stackInfo = getStackInfo(
|
|
140
166
|
itemToRender?._id ?? '',
|
|
@@ -146,14 +172,16 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
146
172
|
return element;
|
|
147
173
|
} else {
|
|
148
174
|
return (
|
|
149
|
-
<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
175
|
+
<ErrorBoundary>
|
|
176
|
+
<SpriteFromAtlas
|
|
177
|
+
atlasIMG={atlasIMG}
|
|
178
|
+
atlasJSON={atlasJSON}
|
|
179
|
+
spriteKey={EquipmentSlotSpriteByType[slotSpriteMask!]}
|
|
180
|
+
imgScale={3}
|
|
181
|
+
grayScale={true}
|
|
182
|
+
opacity={0.4}
|
|
183
|
+
/>
|
|
184
|
+
</ErrorBoundary>
|
|
157
185
|
);
|
|
158
186
|
}
|
|
159
187
|
};
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import atlasJSON from '../mocks/atlas/items/items.json';
|
|
5
5
|
import atlasIMG from '../mocks/atlas/items/items.png';
|
|
6
|
+
import { ErrorBoundary } from './Item/Inventory/ErrorBoundary';
|
|
6
7
|
import { SpriteFromAtlas } from './shared/SpriteFromAtlas';
|
|
7
8
|
import { SimpleProgressBar } from './SimpleProgressBar';
|
|
8
9
|
|
|
@@ -38,14 +39,16 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
38
39
|
<ProgressIconContainer>
|
|
39
40
|
{atlasIMG && atlasJSON ? (
|
|
40
41
|
<SpriteContainer>
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
<ErrorBoundary>
|
|
43
|
+
<SpriteFromAtlas
|
|
44
|
+
atlasIMG={atlasIMG}
|
|
45
|
+
atlasJSON={atlasJSON}
|
|
46
|
+
spriteKey={texturePath}
|
|
47
|
+
imgScale={1}
|
|
48
|
+
grayScale
|
|
49
|
+
opacity={0.5}
|
|
50
|
+
/>
|
|
51
|
+
</ErrorBoundary>
|
|
49
52
|
</SpriteContainer>
|
|
50
53
|
) : (
|
|
51
54
|
<></>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IItem } from "@rpg-engine/shared";
|
|
2
|
+
|
|
3
|
+
export const getItemTextureKeyPath = (itemToRender: IItem, atlasJSON: any) => {
|
|
4
|
+
const stackQty = itemToRender?.stackQty ?? 0;
|
|
5
|
+
let itemTexturePath = itemToRender.texturePath;
|
|
6
|
+
|
|
7
|
+
if (itemToRender.isStackable && stackQty > 1) {
|
|
8
|
+
const txtExtension: string = itemToRender.texturePath.split('.')[1];
|
|
9
|
+
const txtDir: string = itemToRender.texturePath.split('/')[0];
|
|
10
|
+
const idx = stackQty >= 5 ? '5' : stackQty;
|
|
11
|
+
const newTexturePath = `${txtDir}/${itemToRender.textureKey}-qty-${idx}.${txtExtension}`;
|
|
12
|
+
const spriteData = atlasJSON.frames[newTexturePath];
|
|
13
|
+
|
|
14
|
+
if (spriteData !== undefined) {
|
|
15
|
+
itemTexturePath = newTexturePath;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return itemTexturePath;
|
|
20
|
+
};
|
|
21
|
+
|