@rpg-engine/long-bow 0.3.82 → 0.3.84
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/Abstractions/SlotsContainer.d.ts +2 -0
- package/dist/components/DraggableContainer.d.ts +2 -0
- package/dist/components/Equipment/EquipmentSet.d.ts +2 -0
- package/dist/components/Item/Inventory/ItemContainer.d.ts +3 -0
- package/dist/components/Item/Inventory/ItemSlot.d.ts +1 -0
- package/dist/components/Item/Inventory/itemContainerHelper.d.ts +1 -1
- package/dist/components/RelativeListMenu.d.ts +4 -0
- package/dist/long-bow.cjs.development.js +119 -30
- 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 +120 -31
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Abstractions/SlotsContainer.tsx +14 -0
- package/src/components/DraggableContainer.tsx +22 -2
- package/src/components/Equipment/EquipmentSet.tsx +8 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +9 -0
- package/src/components/Item/Inventory/ItemSlot.tsx +21 -3
- package/src/components/Item/Inventory/itemContainerHelper.ts +20 -1
- package/src/components/RelativeListMenu.tsx +23 -16
- package/src/stories/ItemContainer.stories.tsx +1 -0
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@ interface IProps {
|
|
|
8
8
|
title: string;
|
|
9
9
|
onClose?: () => void;
|
|
10
10
|
onPositionChange?: (position: IPosition) => void;
|
|
11
|
+
onPositionChangeEnd?: (position: IPosition) => void;
|
|
12
|
+
onPositionChangeStart?: (position: IPosition) => void;
|
|
11
13
|
onOutsideClick?: () => void;
|
|
12
14
|
initialPosition?: IPosition;
|
|
13
15
|
scale?: number;
|
|
@@ -18,6 +20,8 @@ export const SlotsContainer: React.FC<IProps> = ({
|
|
|
18
20
|
title,
|
|
19
21
|
onClose,
|
|
20
22
|
onPositionChange,
|
|
23
|
+
onPositionChangeEnd,
|
|
24
|
+
onPositionChangeStart,
|
|
21
25
|
onOutsideClick,
|
|
22
26
|
initialPosition,
|
|
23
27
|
scale,
|
|
@@ -38,6 +42,16 @@ export const SlotsContainer: React.FC<IProps> = ({
|
|
|
38
42
|
onPositionChange({ x, y });
|
|
39
43
|
}
|
|
40
44
|
}}
|
|
45
|
+
onPositionChangeEnd={({ x, y }) => {
|
|
46
|
+
if (onPositionChangeEnd) {
|
|
47
|
+
onPositionChangeEnd({ x, y });
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
onPositionChangeStart={({ x, y }) => {
|
|
51
|
+
if (onPositionChangeStart) {
|
|
52
|
+
onPositionChangeStart({ x, y });
|
|
53
|
+
}
|
|
54
|
+
}}
|
|
41
55
|
onOutsideClick={onOutsideClick}
|
|
42
56
|
initialPosition={initialPosition}
|
|
43
57
|
scale={scale}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
|
-
import Draggable
|
|
2
|
+
import Draggable from 'react-draggable';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { uiFonts } from '../constants/uiFonts';
|
|
5
5
|
import { useOutsideClick } from '../hooks/useOutsideAlerter';
|
|
@@ -18,6 +18,8 @@ export interface IDraggableContainerProps {
|
|
|
18
18
|
onCloseButton?: () => void;
|
|
19
19
|
cancelDrag?: string;
|
|
20
20
|
onPositionChange?: (position: IPosition) => void;
|
|
21
|
+
onPositionChangeEnd?: (position: IPosition) => void;
|
|
22
|
+
onPositionChangeStart?: (position: IPosition) => void;
|
|
21
23
|
onOutsideClick?: () => void;
|
|
22
24
|
initialPosition?: IPosition;
|
|
23
25
|
scale?: number;
|
|
@@ -35,6 +37,8 @@ export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
|
|
|
35
37
|
imgWidth = '20px',
|
|
36
38
|
cancelDrag,
|
|
37
39
|
onPositionChange,
|
|
40
|
+
onPositionChangeEnd,
|
|
41
|
+
onPositionChangeStart,
|
|
38
42
|
onOutsideClick,
|
|
39
43
|
initialPosition = { x: 0, y: 0 },
|
|
40
44
|
scale,
|
|
@@ -62,7 +66,7 @@ export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
|
|
|
62
66
|
return (
|
|
63
67
|
<Draggable
|
|
64
68
|
cancel={`.container-close,${cancelDrag}`}
|
|
65
|
-
onDrag={(_e, data
|
|
69
|
+
onDrag={(_e, data) => {
|
|
66
70
|
if (onPositionChange) {
|
|
67
71
|
onPositionChange({
|
|
68
72
|
x: data.x,
|
|
@@ -70,6 +74,22 @@ export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
|
|
|
70
74
|
});
|
|
71
75
|
}
|
|
72
76
|
}}
|
|
77
|
+
onStop={(_e, data) => {
|
|
78
|
+
if (onPositionChangeEnd) {
|
|
79
|
+
onPositionChangeEnd({
|
|
80
|
+
x: data.x,
|
|
81
|
+
y: data.y,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}}
|
|
85
|
+
onStart={(_e, data) => {
|
|
86
|
+
if (onPositionChangeStart) {
|
|
87
|
+
onPositionChangeStart({
|
|
88
|
+
x: data.x,
|
|
89
|
+
y: data.y,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}}
|
|
73
93
|
defaultPosition={initialPosition}
|
|
74
94
|
scale={scale}
|
|
75
95
|
>
|
|
@@ -42,6 +42,8 @@ export interface IEquipmentSetProps {
|
|
|
42
42
|
type: ItemContainerType | null;
|
|
43
43
|
atlasIMG: any;
|
|
44
44
|
atlasJSON: any;
|
|
45
|
+
onPositionChangeEnd?: (position: IPosition) => void;
|
|
46
|
+
onPositionChangeStart?: (position: IPosition) => void;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
@@ -59,6 +61,9 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
59
61
|
checkIfItemCanBeMoved,
|
|
60
62
|
checkIfItemShouldDragEnd,
|
|
61
63
|
scale,
|
|
64
|
+
initialPosition,
|
|
65
|
+
onPositionChangeEnd,
|
|
66
|
+
onPositionChangeStart,
|
|
62
67
|
}) => {
|
|
63
68
|
const {
|
|
64
69
|
neck,
|
|
@@ -163,6 +168,9 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
163
168
|
width="330px"
|
|
164
169
|
cancelDrag=".equipment-container-body"
|
|
165
170
|
scale={scale}
|
|
171
|
+
initialPosition={initialPosition}
|
|
172
|
+
onPositionChangeEnd={onPositionChangeEnd}
|
|
173
|
+
onPositionChangeStart={onPositionChangeStart}
|
|
166
174
|
>
|
|
167
175
|
<EquipmentSetContainer className="equipment-container-body">
|
|
168
176
|
<EquipmentColumn>{onRenderEquipmentSlotRange(0, 3)}</EquipmentColumn>
|
|
@@ -50,6 +50,9 @@ export interface IItemContainerProps {
|
|
|
50
50
|
setItemShortcut?: (key: string, index: number) => void;
|
|
51
51
|
removeShortcut?: (index: number) => void;
|
|
52
52
|
equipmentSet?: IEquipmentSet | null;
|
|
53
|
+
isDepotSystem?: boolean;
|
|
54
|
+
onPositionChangeEnd?: (position: IPosition) => void;
|
|
55
|
+
onPositionChangeStart?: (position: IPosition) => void;
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
@@ -74,6 +77,9 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
74
77
|
setItemShortcut,
|
|
75
78
|
removeShortcut,
|
|
76
79
|
equipmentSet,
|
|
80
|
+
isDepotSystem,
|
|
81
|
+
onPositionChangeEnd,
|
|
82
|
+
onPositionChangeStart,
|
|
77
83
|
}) => {
|
|
78
84
|
const [quantitySelect, setQuantitySelect] = useState({
|
|
79
85
|
isOpen: false,
|
|
@@ -139,6 +145,7 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
139
145
|
atlasJSON={atlasJSON}
|
|
140
146
|
isSelectingShortcut={settingShortcutIndex !== -1}
|
|
141
147
|
equipmentSet={equipmentSet}
|
|
148
|
+
isDepotSystem={isDepotSystem}
|
|
142
149
|
/>
|
|
143
150
|
);
|
|
144
151
|
}
|
|
@@ -152,6 +159,8 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
152
159
|
onClose={onClose}
|
|
153
160
|
initialPosition={initialPosition}
|
|
154
161
|
scale={scale}
|
|
162
|
+
onPositionChangeEnd={onPositionChangeEnd}
|
|
163
|
+
onPositionChangeStart={onPositionChangeStart}
|
|
155
164
|
>
|
|
156
165
|
{type === ItemContainerType.Inventory &&
|
|
157
166
|
shortcuts &&
|
|
@@ -78,6 +78,7 @@ interface IProps {
|
|
|
78
78
|
isContextMenuDisabled?: boolean;
|
|
79
79
|
isSelectingShortcut?: boolean;
|
|
80
80
|
equipmentSet?: IEquipmentSet | null;
|
|
81
|
+
isDepotSystem?: boolean;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export const ItemSlot: React.FC<IProps> = observer(
|
|
@@ -103,11 +104,16 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
103
104
|
dragScale,
|
|
104
105
|
isSelectingShortcut,
|
|
105
106
|
equipmentSet,
|
|
107
|
+
isDepotSystem,
|
|
106
108
|
}) => {
|
|
107
109
|
const [isTooltipVisible, setTooltipVisible] = useState(false);
|
|
108
110
|
const [isTooltipMobileVisible, setIsTooltipMobileVisible] = useState(false);
|
|
109
111
|
|
|
110
112
|
const [isContextMenuVisible, setIsContextMenuVisible] = useState(false);
|
|
113
|
+
const [contextMenuPosition, setContextMenuPosition] = useState({
|
|
114
|
+
x: 0,
|
|
115
|
+
y: 0,
|
|
116
|
+
});
|
|
111
117
|
|
|
112
118
|
const [isFocused, setIsFocused] = useState(false);
|
|
113
119
|
const [wasDragged, setWasDragged] = useState(false);
|
|
@@ -124,9 +130,11 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
124
130
|
setIsFocused(false);
|
|
125
131
|
|
|
126
132
|
if (item) {
|
|
127
|
-
setContextActions(
|
|
133
|
+
setContextActions(
|
|
134
|
+
generateContextMenu(item, containerType, isDepotSystem)
|
|
135
|
+
);
|
|
128
136
|
}
|
|
129
|
-
}, [item]);
|
|
137
|
+
}, [item, isDepotSystem]);
|
|
130
138
|
|
|
131
139
|
useEffect(() => {
|
|
132
140
|
if (onDrop && item && dropPosition) {
|
|
@@ -357,8 +365,17 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
357
365
|
setIsTooltipMobileVisible(true);
|
|
358
366
|
}
|
|
359
367
|
|
|
360
|
-
if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch)
|
|
368
|
+
if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch) {
|
|
361
369
|
setIsContextMenuVisible(!isContextMenuVisible);
|
|
370
|
+
const event = e as MouseEvent;
|
|
371
|
+
|
|
372
|
+
if (event.clientX && event.clientY) {
|
|
373
|
+
setContextMenuPosition({
|
|
374
|
+
x: event.clientX - 10,
|
|
375
|
+
y: event.clientY - 5,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
362
379
|
|
|
363
380
|
onPointerDown(item.type, containerType, item);
|
|
364
381
|
}
|
|
@@ -445,6 +462,7 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
445
462
|
onOutsideClick={() => {
|
|
446
463
|
setIsContextMenuVisible(false);
|
|
447
464
|
}}
|
|
465
|
+
pos={contextMenuPosition}
|
|
448
466
|
/>
|
|
449
467
|
)}
|
|
450
468
|
</Container>
|
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
ActionsForInventory,
|
|
4
4
|
ActionsForLoot,
|
|
5
5
|
ActionsForMapContainer,
|
|
6
|
+
DepotSocketEvents,
|
|
6
7
|
IItem,
|
|
7
8
|
ItemContainerType,
|
|
9
|
+
ItemSocketEvents,
|
|
8
10
|
ItemSocketEventsDisplayLabels,
|
|
9
11
|
ItemType,
|
|
10
12
|
} from '@rpg-engine/shared';
|
|
@@ -25,7 +27,8 @@ const generateContextMenuListOptions = (actionsByTypeList: any) => {
|
|
|
25
27
|
|
|
26
28
|
export const generateContextMenu = (
|
|
27
29
|
item: IItem,
|
|
28
|
-
itemContainerType: ItemContainerType | null
|
|
30
|
+
itemContainerType: ItemContainerType | null,
|
|
31
|
+
isDepotSystem?: boolean
|
|
29
32
|
) => {
|
|
30
33
|
let contextActionMenu: IContextMenuItem[] = [];
|
|
31
34
|
|
|
@@ -66,6 +69,13 @@ export const generateContextMenu = (
|
|
|
66
69
|
);
|
|
67
70
|
break;
|
|
68
71
|
}
|
|
72
|
+
|
|
73
|
+
if (isDepotSystem) {
|
|
74
|
+
contextActionMenu.push({
|
|
75
|
+
id: DepotSocketEvents.Deposit,
|
|
76
|
+
text: 'Deposit',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
69
79
|
}
|
|
70
80
|
if (itemContainerType === ItemContainerType.Equipment) {
|
|
71
81
|
switch (item.type) {
|
|
@@ -151,6 +161,15 @@ export const generateContextMenu = (
|
|
|
151
161
|
contextActionMenu.push({ id: 'use-with', text: 'Use with...' });
|
|
152
162
|
}
|
|
153
163
|
}
|
|
164
|
+
if (itemContainerType === ItemContainerType.Depot) {
|
|
165
|
+
contextActionMenu = [
|
|
166
|
+
{
|
|
167
|
+
id: ItemSocketEvents.GetItemInfo,
|
|
168
|
+
text: ItemSocketEventsDisplayLabels.GetItemInfo,
|
|
169
|
+
},
|
|
170
|
+
{ id: DepotSocketEvents.Withdraw, text: 'Withdraw' },
|
|
171
|
+
];
|
|
172
|
+
}
|
|
154
173
|
|
|
155
174
|
return contextActionMenu;
|
|
156
175
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { useOutsideClick } from '../hooks/useOutsideAlerter';
|
|
4
|
+
import ModalPortal from './Abstractions/ModalPortal';
|
|
4
5
|
|
|
5
6
|
interface IListMenuOption {
|
|
6
7
|
id: string;
|
|
@@ -12,6 +13,7 @@ export interface IRelativeMenuProps {
|
|
|
12
13
|
onSelected: (selectedOptionId: string) => void;
|
|
13
14
|
fontSize?: number;
|
|
14
15
|
onOutsideClick?: () => void;
|
|
16
|
+
pos: { x: number; y: number };
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const RelativeListMenu: React.FC<IRelativeMenuProps> = ({
|
|
@@ -19,6 +21,7 @@ export const RelativeListMenu: React.FC<IRelativeMenuProps> = ({
|
|
|
19
21
|
onSelected,
|
|
20
22
|
onOutsideClick,
|
|
21
23
|
fontSize = 0.8,
|
|
24
|
+
pos,
|
|
22
25
|
}) => {
|
|
23
26
|
const ref = useRef(null);
|
|
24
27
|
|
|
@@ -41,31 +44,35 @@ export const RelativeListMenu: React.FC<IRelativeMenuProps> = ({
|
|
|
41
44
|
}, []);
|
|
42
45
|
|
|
43
46
|
return (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
<ModalPortal>
|
|
48
|
+
<Container fontSize={fontSize} ref={ref} {...pos}>
|
|
49
|
+
<ul className="rpgui-list-imp" style={{ overflow: 'hidden' }}>
|
|
50
|
+
{options.map((params, index) => (
|
|
51
|
+
<ListElement
|
|
52
|
+
key={params?.id || index}
|
|
53
|
+
onPointerDown={() => {
|
|
54
|
+
onSelected(params?.id);
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
{params?.text || 'No text'}
|
|
58
|
+
</ListElement>
|
|
59
|
+
))}
|
|
60
|
+
</ul>
|
|
61
|
+
</Container>
|
|
62
|
+
</ModalPortal>
|
|
58
63
|
);
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
interface IContainerProps {
|
|
62
67
|
fontSize?: number;
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
const Container = styled.div<IContainerProps>`
|
|
66
73
|
position: absolute;
|
|
67
|
-
top:
|
|
68
|
-
left:
|
|
74
|
+
top: ${props => props.y}px;
|
|
75
|
+
left: ${props => props.x}px;
|
|
69
76
|
|
|
70
77
|
display: flex;
|
|
71
78
|
flex-direction: column;
|