@rpg-engine/long-bow 0.5.29 → 0.5.31
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/ItemSlotRarity.d.ts +0 -7
- package/dist/long-bow.cjs.development.js +81 -88
- 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 +81 -88
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/ItemContainer.stories.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +21 -4
- package/src/components/Item/Inventory/ItemSlotRarity.ts +17 -0
- package/src/components/Item/Inventory/ItemSlotRenderer.tsx +16 -19
- package/src/stories/ItemContainer.stories.tsx +0 -6
- package/src/components/Item/Inventory/ItemSlotRarity.tsx +0 -46
|
@@ -8,5 +8,4 @@ interface ITemplateProps {
|
|
|
8
8
|
scale?: number;
|
|
9
9
|
}
|
|
10
10
|
export declare const Inventory: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IItemContainerProps & ITemplateProps>;
|
|
11
|
-
export declare const InventoryScaledDown: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IItemContainerProps & ITemplateProps>;
|
|
12
11
|
export declare const Depot: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IItemContainerProps & ITemplateProps>;
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
12
12
|
import Draggable, { DraggableEventHandler } from 'react-draggable';
|
|
13
13
|
import styled from 'styled-components';
|
|
14
14
|
import { IPosition } from '../../../types/eventTypes';
|
|
15
|
+
import { rarityColor } from './ItemSlotRarity';
|
|
15
16
|
import { ItemSlotRenderer } from './ItemSlotRenderer';
|
|
16
17
|
import { ItemSlotToolTips } from './ItemSlotTooltips';
|
|
17
18
|
import { useDragging } from './context/DraggingContext';
|
|
@@ -116,7 +117,7 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
116
117
|
const [dropPosition, setDropPosition] = useState<IPosition | null>(null);
|
|
117
118
|
const dragContainer = useRef<HTMLDivElement>(null);
|
|
118
119
|
|
|
119
|
-
const { setDraggingItem } = useDragging();
|
|
120
|
+
const { item: draggingItem, setDraggingItem } = useDragging();
|
|
120
121
|
|
|
121
122
|
const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
|
|
122
123
|
[]
|
|
@@ -240,8 +241,6 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
if (onDragStart && containerType) {
|
|
243
|
-
setDraggingItem(item);
|
|
244
|
-
|
|
245
244
|
onDragStart(item, slotIndex, containerType);
|
|
246
245
|
}
|
|
247
246
|
};
|
|
@@ -254,10 +253,15 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
254
253
|
setWasDragged(true);
|
|
255
254
|
setIsFocused(true);
|
|
256
255
|
}
|
|
256
|
+
|
|
257
|
+
if (!draggingItem) {
|
|
258
|
+
setDraggingItem(item);
|
|
259
|
+
}
|
|
257
260
|
};
|
|
258
261
|
|
|
259
262
|
return (
|
|
260
263
|
<Container
|
|
264
|
+
isDraggingItem={!!draggingItem}
|
|
261
265
|
item={item}
|
|
262
266
|
className="rpgui-icon empty-slot"
|
|
263
267
|
onMouseUp={() => {
|
|
@@ -362,17 +366,30 @@ interface ContainerTypes {
|
|
|
362
366
|
item: IItem | null;
|
|
363
367
|
containerType?: ItemContainerType | null;
|
|
364
368
|
isSelectingShortcut?: boolean;
|
|
369
|
+
isDraggingItem?: boolean;
|
|
365
370
|
}
|
|
366
371
|
|
|
367
372
|
const Container = styled.div<ContainerTypes>`
|
|
368
373
|
margin: 0.1rem;
|
|
369
374
|
|
|
370
375
|
.react-draggable-dragging {
|
|
371
|
-
opacity
|
|
376
|
+
// if is dragging item, set opacity to 0
|
|
377
|
+
opacity: ${({ isDraggingItem }) => (isDraggingItem ? 0 : 1)};
|
|
372
378
|
}
|
|
373
379
|
|
|
374
380
|
position: relative;
|
|
375
381
|
|
|
382
|
+
.sprite-from-atlas-img--item {
|
|
383
|
+
position: relative;
|
|
384
|
+
top: 1.5rem;
|
|
385
|
+
left: 1.5rem;
|
|
386
|
+
border-color: ${({ item }) => rarityColor(item)};
|
|
387
|
+
box-shadow: ${({ item }) => `0 0 5px 2px ${rarityColor(item)}`} inset, ${({
|
|
388
|
+
item,
|
|
389
|
+
}) => `0 0 4px 3px ${rarityColor(item)}`};
|
|
390
|
+
//background-color: ${({ item }) => rarityColor(item)};
|
|
391
|
+
}
|
|
392
|
+
|
|
376
393
|
&::before {
|
|
377
394
|
content: '';
|
|
378
395
|
position: absolute;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IItem, ItemRarities } from '@rpg-engine/shared';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const rarityColor = (item: IItem | null) => {
|
|
5
|
+
switch (item?.rarity) {
|
|
6
|
+
case ItemRarities.Uncommon:
|
|
7
|
+
return 'rgba(13, 193, 13, 0.6)';
|
|
8
|
+
case ItemRarities.Rare:
|
|
9
|
+
return 'rgba(8, 104, 187, 0.6)';
|
|
10
|
+
case ItemRarities.Epic:
|
|
11
|
+
return 'rgba(191, 0, 255, 0.6)';
|
|
12
|
+
case ItemRarities.Legendary:
|
|
13
|
+
return 'rgba(255, 191, 0,0.6)';
|
|
14
|
+
default:
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -10,7 +10,6 @@ import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
|
10
10
|
import { ErrorBoundary } from './ErrorBoundary';
|
|
11
11
|
import { EquipmentSlotSpriteByType } from './ItemSlot';
|
|
12
12
|
import { onRenderStackInfo } from './ItemSlotQty/ItemSlotQty';
|
|
13
|
-
import { ItemSlotRarity } from './ItemSlotRarity';
|
|
14
13
|
|
|
15
14
|
interface IProps {
|
|
16
15
|
containerType: ItemContainerType | null | undefined;
|
|
@@ -34,24 +33,22 @@ export const ItemSlotRenderer: React.FC<IProps> = ({
|
|
|
34
33
|
|
|
35
34
|
return (
|
|
36
35
|
<ErrorBoundary key={item._id}>
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{onRenderStackInfo(item._id, item.stackQty ?? 0)}
|
|
54
|
-
</ItemSlotRarity>
|
|
36
|
+
<SpriteFromAtlas
|
|
37
|
+
atlasIMG={atlasIMG}
|
|
38
|
+
atlasJSON={atlasJSON}
|
|
39
|
+
spriteKey={getItemTextureKeyPath(
|
|
40
|
+
{
|
|
41
|
+
key: item.texturePath,
|
|
42
|
+
texturePath: item.texturePath,
|
|
43
|
+
stackQty: item.stackQty || 1,
|
|
44
|
+
isStackable: item.isStackable,
|
|
45
|
+
},
|
|
46
|
+
atlasJSON
|
|
47
|
+
)}
|
|
48
|
+
imgScale={3}
|
|
49
|
+
imgClassname="sprite-from-atlas-img--item"
|
|
50
|
+
/>
|
|
51
|
+
{onRenderStackInfo(item._id, item.stackQty ?? 0)}
|
|
55
52
|
</ErrorBoundary>
|
|
56
53
|
);
|
|
57
54
|
};
|
|
@@ -161,12 +161,6 @@ Inventory.args = {
|
|
|
161
161
|
type: ItemContainerType.Inventory,
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
export const InventoryScaledDown = Template.bind({});
|
|
165
|
-
InventoryScaledDown.args = {
|
|
166
|
-
type: ItemContainerType.Inventory,
|
|
167
|
-
scale: 0.8,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
164
|
export const Depot = Template.bind({});
|
|
171
165
|
Depot.args = {
|
|
172
166
|
type: ItemContainerType.Depot,
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { IItem, ItemRarities } from '@rpg-engine/shared';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
interface IProps {
|
|
6
|
-
item: IItem | null;
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const ItemSlotRarity = ({ children, item }: IProps) => {
|
|
11
|
-
if (!item) return <>{children}</>;
|
|
12
|
-
|
|
13
|
-
return <Container item={item}>{children}</Container>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
interface IContainer {
|
|
17
|
-
item: IItem | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const rarityColor = (item: IItem | null) => {
|
|
21
|
-
switch (item?.rarity) {
|
|
22
|
-
case ItemRarities.Uncommon:
|
|
23
|
-
return 'rgba(13, 193, 13, 0.6)';
|
|
24
|
-
case ItemRarities.Rare:
|
|
25
|
-
return 'rgba(8, 104, 187, 0.6)';
|
|
26
|
-
case ItemRarities.Epic:
|
|
27
|
-
return 'rgba(191, 0, 255, 0.6)';
|
|
28
|
-
case ItemRarities.Legendary:
|
|
29
|
-
return 'rgba(255, 191, 0,0.6)';
|
|
30
|
-
default:
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const Container = styled.div<IContainer>`
|
|
35
|
-
.sprite-from-atlas-img--item {
|
|
36
|
-
position: relative;
|
|
37
|
-
top: 1.5rem;
|
|
38
|
-
left: 1.5rem;
|
|
39
|
-
border-color: ${({ item }) => rarityColor(item)};
|
|
40
|
-
box-shadow: ${({ item }) => `0 0 5px 2px ${rarityColor(item)}`} inset, ${({
|
|
41
|
-
item,
|
|
42
|
-
}) => `0 0 4px 3px ${rarityColor(item)}`};
|
|
43
|
-
//background-color: ${({ item }) => rarityColor(item)};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
`;
|