@rpg-engine/long-bow 0.2.87 → 0.2.88
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/long-bow.cjs.development.js +23 -3
- 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 +23 -3
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Equipment/EquipmentSet.tsx +7 -0
- package/src/components/Item/Inventory/ItemQuantitySelector.tsx +6 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +72 -68
package/package.json
CHANGED
|
@@ -119,6 +119,10 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
119
119
|
if (onSelected) onSelected(optionId);
|
|
120
120
|
}}
|
|
121
121
|
onDragStart={(item, slotIndex, itemContainerType) => {
|
|
122
|
+
if (!item) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
122
126
|
if (onItemDragStart)
|
|
123
127
|
onItemDragStart(item, slotIndex, itemContainerType);
|
|
124
128
|
}}
|
|
@@ -127,6 +131,9 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
127
131
|
}}
|
|
128
132
|
checkIfItemCanBeMoved={checkIfItemCanBeMoved}
|
|
129
133
|
onPlaceDrop={(item, slotIndex, itemContainerType) => {
|
|
134
|
+
if (!item) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
130
137
|
if (onItemPlaceDrop)
|
|
131
138
|
onItemPlaceDrop(item, slotIndex, itemContainerType);
|
|
132
139
|
}}
|
|
@@ -2,8 +2,8 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { Button, ButtonTypes } from '../../Button';
|
|
4
4
|
import { Input } from '../../Input';
|
|
5
|
-
import { RangeSlider, RangeSliderType } from '../../RangeSlider';
|
|
6
5
|
import { RPGUIContainer, RPGUIContainerTypes } from '../../RPGUIContainer';
|
|
6
|
+
import { RangeSlider, RangeSliderType } from '../../RangeSlider';
|
|
7
7
|
|
|
8
8
|
export interface IItemQuantitySelectorProps {
|
|
9
9
|
quantity: number;
|
|
@@ -74,6 +74,11 @@ export const ItemQuantitySelector: React.FC<IItemQuantitySelectorProps> = ({
|
|
|
74
74
|
max={quantity}
|
|
75
75
|
value={value}
|
|
76
76
|
onChange={e => {
|
|
77
|
+
if (Number(e.target.value) >= quantity) {
|
|
78
|
+
setValue(quantity);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
77
82
|
setValue((e.target.value as unknown) as number);
|
|
78
83
|
}}
|
|
79
84
|
onBlur={e => {
|
|
@@ -267,78 +267,82 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
267
267
|
?.dispatchEvent(simulatedEvent);
|
|
268
268
|
}}
|
|
269
269
|
>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
270
|
+
<Draggable
|
|
271
|
+
defaultClassName={item ? 'draggable' : 'empty-slot'}
|
|
272
|
+
onStop={() => {
|
|
273
|
+
if (!item) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (wasDragged) {
|
|
278
|
+
setWasDragged(false);
|
|
279
|
+
|
|
280
|
+
const target = dragContainer.current;
|
|
281
|
+
if (!target || !wasDragged) return;
|
|
282
|
+
|
|
283
|
+
const style = window.getComputedStyle(target);
|
|
284
|
+
const matrix = new DOMMatrixReadOnly(style.transform);
|
|
285
|
+
const x = matrix.m41;
|
|
286
|
+
const y = matrix.m42;
|
|
287
|
+
|
|
288
|
+
setDragPosition({ x, y });
|
|
289
|
+
|
|
290
|
+
setTimeout(() => {
|
|
291
|
+
if (checkIfItemCanBeMoved()) {
|
|
292
|
+
if (
|
|
293
|
+
item.stackQty &&
|
|
294
|
+
item.stackQty !== 1 &&
|
|
295
|
+
openQuantitySelector
|
|
296
|
+
)
|
|
297
|
+
openQuantitySelector(item.stackQty, onSuccesfulDrag);
|
|
298
|
+
else onSuccesfulDrag(item.stackQty);
|
|
299
|
+
} else {
|
|
300
|
+
resetItem();
|
|
301
|
+
setDragPosition({ x: 0, y: 0 });
|
|
302
|
+
}
|
|
303
|
+
}, 100);
|
|
304
|
+
} else if (item) {
|
|
305
|
+
if (!isContextMenuDisabled)
|
|
306
|
+
setIsContextMenuVisible(!isContextMenuVisible);
|
|
307
|
+
|
|
308
|
+
onClick(item.type, containerType, item);
|
|
309
|
+
}
|
|
310
|
+
}}
|
|
311
|
+
onStart={() => {
|
|
312
|
+
if (!item) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (onDragStart) {
|
|
317
|
+
onDragStart(item, slotIndex, containerType);
|
|
318
|
+
}
|
|
319
|
+
}}
|
|
320
|
+
onDrag={() => {
|
|
321
|
+
setWasDragged(true);
|
|
322
|
+
setIsFocused(true);
|
|
323
|
+
}}
|
|
324
|
+
position={dragPosition}
|
|
325
|
+
cancel=".empty-slot"
|
|
326
|
+
>
|
|
327
|
+
<ItemContainer
|
|
328
|
+
ref={dragContainer}
|
|
329
|
+
isFocused={isFocused}
|
|
330
|
+
onMouseOver={event => {
|
|
331
|
+
onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
|
|
306
332
|
}}
|
|
307
|
-
|
|
308
|
-
if (
|
|
333
|
+
onMouseOut={() => {
|
|
334
|
+
if (onMouseOut) onMouseOut();
|
|
309
335
|
}}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
336
|
+
onMouseEnter={() => {
|
|
337
|
+
setTooltipVisible(true);
|
|
338
|
+
}}
|
|
339
|
+
onMouseLeave={() => {
|
|
340
|
+
setTooltipVisible(false);
|
|
313
341
|
}}
|
|
314
|
-
position={dragPosition}
|
|
315
342
|
>
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
onMouseOver={event => {
|
|
320
|
-
onMouseOver(
|
|
321
|
-
event,
|
|
322
|
-
slotIndex,
|
|
323
|
-
item,
|
|
324
|
-
event.clientX,
|
|
325
|
-
event.clientY
|
|
326
|
-
);
|
|
327
|
-
}}
|
|
328
|
-
onMouseOut={() => {
|
|
329
|
-
if (onMouseOut) onMouseOut();
|
|
330
|
-
}}
|
|
331
|
-
onMouseEnter={() => {
|
|
332
|
-
setTooltipVisible(true);
|
|
333
|
-
}}
|
|
334
|
-
onMouseLeave={() => {
|
|
335
|
-
setTooltipVisible(false);
|
|
336
|
-
}}
|
|
337
|
-
>
|
|
338
|
-
{onRenderSlot(item)}
|
|
339
|
-
</ItemContainer>
|
|
340
|
-
</Draggable>
|
|
341
|
-
)}
|
|
343
|
+
{onRenderSlot(item)}
|
|
344
|
+
</ItemContainer>
|
|
345
|
+
</Draggable>
|
|
342
346
|
|
|
343
347
|
{isTooltipVisible && item && <ItemTooltip label={item.name} />}
|
|
344
348
|
|